Skip to content

Commit

Permalink
Change precompile/contract.Configuration to not take a blockTime argu…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
qdm12 committed Jan 23, 2025
1 parent a9b334c commit 2cf8ef3
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (*configurator) MakeConfig() precompileconfig.Config {
// This function is called by the EVM once per precompile contract activation.
// You can use this function to set up your precompile contract's initial state,
// by using the [cfg] config and [state] stateDB.
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error {
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
// CUSTOM CODE STARTS HERE
{{- if .Contract.AllowList}}
config, ok := cfg.(*Config)
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func ApplyPrecompileActivations(c *params.ChainConfig, parentTimestamp *uint64,
// can be called from within Solidity contracts. Solidity adds a check before invoking a contract to ensure
// that it does not attempt to invoke a non-existent contract.
statedb.SetCode(module.Address, []byte{0x1})
if err := module.Configure(c, activatingConfig, statedb, blockNumber, blockTime); err != nil {
if err := module.Configure(c, activatingConfig, statedb, blockNumber); err != nil {
return fmt.Errorf("could not configure precompile, name: %s, reason: %w", module.ConfigKey, err)
}
}
Expand Down
1 change: 0 additions & 1 deletion precompile/allowlist/allowlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (d *dummyConfigurator) Configure(
precompileConfig precompileconfig.Config,
state contract.StateDB,
blockNumber *big.Int,
blockTime uint64,
) error {
cfg := precompileConfig.(*dummyConfig)
return cfg.AllowListConfig.Configure(chainConfig, dummyAddr, state)
Expand Down
1 change: 0 additions & 1 deletion precompile/contract/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ type Configurator interface {
precompileconfig precompileconfig.Config,
state StateDB,
blockNumber *big.Int,
blockTime uint64,
) error
}
2 changes: 1 addition & 1 deletion precompile/contracts/deployerallowlist/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (*configurator) MakeConfig() precompileconfig.Config {

// Configure configures [state] with the given [cfg] precompileconfig.
// This function is called by the EVM once per precompile contract activation.
func (c *configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error {
func (c *configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
config, ok := cfg.(*Config)
if !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
Expand Down
2 changes: 1 addition & 1 deletion precompile/contracts/feemanager/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (*configurator) MakeConfig() precompileconfig.Config {

// Configure configures [state] with the given [cfg] precompileconfig.
// This function is called by the EVM once per precompile contract activation.
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error {
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
config, ok := cfg.(*Config)
if !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
Expand Down
2 changes: 1 addition & 1 deletion precompile/contracts/nativeminter/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (*configurator) MakeConfig() precompileconfig.Config {

// Configure configures [state] with the given [cfg] precompileconfig.
// This function is called by the EVM once per precompile contract activation.
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error {
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
config, ok := cfg.(*Config)
if !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
Expand Down
2 changes: 1 addition & 1 deletion precompile/contracts/rewardmanager/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (*configurator) MakeConfig() precompileconfig.Config {
// This function is called by the EVM once per precompile contract activation.
// You can use this function to set up your precompile contract's initial state,
// by using the [cfg] config and [state] stateDB.
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error {
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
config, ok := cfg.(*Config)
if !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
Expand Down
2 changes: 1 addition & 1 deletion precompile/contracts/txallowlist/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (*configurator) MakeConfig() precompileconfig.Config {

// Configure configures [state] with the given [cfg] precompileconfig.
// This function is called by the EVM once per precompile contract activation.
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error {
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
config, ok := cfg.(*Config)
if !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
Expand Down
2 changes: 1 addition & 1 deletion precompile/contracts/warp/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (*configurator) MakeConfig() precompileconfig.Config {
}

// Configure is a no-op for warp since it does not need to store any information in the state
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error {
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
if _, ok := cfg.(*Config); !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
}
Expand Down
2 changes: 1 addition & 1 deletion precompile/testutils/test_precompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (test PrecompileTest) setup(t testing.TB, module modules.Module, state cont
accessibleState.EXPECT().GetChainConfig().Return(chainConfig).AnyTimes()

if test.Config != nil {
err := module.Configure(chainConfig, test.Config, state, blockContext.Number(), blockContext.Time())
err := module.Configure(chainConfig, test.Config, state, blockContext.Number())
require.NoError(t, err)
}

Expand Down

0 comments on commit 2cf8ef3

Please sign in to comment.