Skip to content

Commit 29f6067

Browse files
author
Darioush Jalali
committed
params: additional ChainConfig hooks
1 parent 36b6e91 commit 29f6067

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

params/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ func (c *ChainConfig) Description() string {
478478
if c.VerkleTime != nil {
479479
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
480480
}
481-
return banner
481+
return banner + c.Hooks().Description()
482482
}
483483

484484
// IsHomestead returns whether num is either equal to the homestead block or greater.
@@ -671,7 +671,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
671671
lastFork = cur
672672
}
673673
}
674-
return nil
674+
return c.Hooks().CheckConfigForkOrder()
675675
}
676676

677677
func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int, headTimestamp uint64) *ConfigCompatError {
@@ -742,7 +742,7 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
742742
if isForkTimestampIncompatible(c.VerkleTime, newcfg.VerkleTime, headTimestamp) {
743743
return newTimestampCompatError("Verkle fork timestamp", c.VerkleTime, newcfg.VerkleTime)
744744
}
745-
return nil
745+
return c.Hooks().CheckCompatible(newcfg, headNumber, headTimestamp)
746746
}
747747

748748
// BaseFeeChangeDenominator bounds the amount the base fee can change between blocks.

params/hooks.libevm.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
package params
22

33
import (
4+
"math/big"
5+
46
"github.com/ethereum/go-ethereum/common"
57
"github.com/ethereum/go-ethereum/libevm"
68
)
79

810
// ChainConfigHooks are required for all types registered as [Extras] for
911
// [ChainConfig] payloads.
10-
type ChainConfigHooks interface{}
12+
type ChainConfigHooks interface {
13+
CheckCompatible(newcfg *ChainConfig, headNumber *big.Int, headTimestamp uint64) *ConfigCompatError
14+
CheckConfigForkOrder() error
15+
Description() string
16+
}
1117

1218
// TODO(arr4n): given the choice of whether a hook should be defined on a
1319
// ChainConfig or on the Rules, what are the guiding principles? A ChainConfig
@@ -66,6 +72,18 @@ var _ interface {
6672
RulesHooks
6773
} = NOOPHooks{}
6874

75+
func (NOOPHooks) CheckCompatible(_ *ChainConfig, _ *big.Int, _ uint64) *ConfigCompatError {
76+
return nil
77+
}
78+
79+
func (NOOPHooks) CheckConfigForkOrder() error {
80+
return nil
81+
}
82+
83+
func (NOOPHooks) Description() string {
84+
return ""
85+
}
86+
6987
// CanExecuteTransaction allows all (otherwise valid) transactions.
7088
func (NOOPHooks) CanExecuteTransaction(_ common.Address, _ *common.Address, _ libevm.StateReader) error {
7189
return nil

0 commit comments

Comments
 (0)