Skip to content

Commit

Permalink
Extend x/evm module params with enabled_precompiles
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Apr 30, 2024
1 parent d9ad138 commit b9a0598
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 135 deletions.
3 changes: 3 additions & 0 deletions proto/ethermint/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ message Params {
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
// signed) transactions can be executed on the state machine.
bool allow_unprotected_txs = 7;
// enabled_precompiles contains list of hex-encoded evm addresses of enabled precompiled contracts.
// Precompile must be registered before it can be enabled.
repeated string enabled_precompiles = 8;
}

// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
Expand Down
40 changes: 40 additions & 0 deletions x/evm/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,46 @@ func (suite *KeeperTestSuite) TestParams() {
},
true,
},
{
"success - EnabledPrecompiles param is set to empty slice and will be retrieved as nil",
func() interface{} {
params.EnabledPrecompiles = []string{}
suite.app.EvmKeeper.SetParams(suite.ctx, params)
var typedNil []string = nil // NOTE: despite we set EnabledPrecompiles as []string{}, it will be retrieved as nil
return typedNil
},
func() interface{} {
evmParams := suite.app.EvmKeeper.GetParams(suite.ctx)
return evmParams.GetEnabledPrecompiles()
},
true,
},
{
"success - EnabledPrecompiles param is set to nil and can be retrieved correctly",
func() interface{} {
params.EnabledPrecompiles = nil
suite.app.EvmKeeper.SetParams(suite.ctx, params)
return params.EnabledPrecompiles
},
func() interface{} {
evmParams := suite.app.EvmKeeper.GetParams(suite.ctx)
return evmParams.GetEnabledPrecompiles()
},
true,
},
{
"success - EnabledPrecompiles param is set to []string{\"0x100\", \"0x101\"} and can be retrieved correctly",
func() interface{} {
params.EnabledPrecompiles = []string{"0x100", "0x101"}
suite.app.EvmKeeper.SetParams(suite.ctx, params)
return params.EnabledPrecompiles
},
func() interface{} {
evmParams := suite.app.EvmKeeper.GetParams(suite.ctx)
return evmParams.GetEnabledPrecompiles()
},
true,
},
}
for _, tc := range testCases {
suite.Run(tc.name, func() {
Expand Down
Loading

0 comments on commit b9a0598

Please sign in to comment.