diff --git a/CHANGELOG.md b/CHANGELOG.md index 778dacf3be..6be6b06e31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - (precompiles) [#2929](https://github.com/evmos/evmos/pull/2929) Distribution: scale balance change entries to the statedb journal to support different EVM denom precision. - (precompiles) [#2927](https://github.com/evmos/evmos/pull/2927) Erc20: scale balance change entries to the statedb journal to support different EVM denom precision. - (erc20) [#2962](https://github.com/evmos/evmos/pull/2962) Register ERC-20 code hash also for native ERC-20 extensions. +- (evm) [#3000](https://github.com/evmos/evmos/pull/3000) Move population of access list with precompile addresses into EVM hook. ### Improvements diff --git a/x/evm/keeper/precompiles.go b/x/evm/keeper/precompiles.go index e7bb5dd88a..c7fdbc916f 100644 --- a/x/evm/keeper/precompiles.go +++ b/x/evm/keeper/precompiles.go @@ -57,9 +57,13 @@ func (k *Keeper) GetPrecompilesCallHook(ctx sdktypes.Context) types.CallHook { return err } + // If the precompile instance is created, we have to update the EVM with + // only the recipient precompile and add it's address to the access list. if found { evm.WithPrecompiles(precompiles.Map, precompiles.Addresses) + evm.StateDB.AddAddressToAccessList(recipient) } + return nil } } diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 556a10aaa2..49e1f03d0d 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -308,7 +308,10 @@ func (k *Keeper) ApplyMessageWithConfig( // access list preparation is moved from ante handler to here, because it's needed when `ApplyMessage` is called // under contexts where ante handlers are not run, for example `eth_call` and `eth_estimateGas`. if rules := cfg.ChainConfig.Rules(big.NewInt(ctx.BlockHeight()), cfg.ChainConfig.MergeNetsplitBlock != nil); rules.IsBerlin { - stateDB.PrepareAccessList(msg.From(), msg.To(), evm.ActivePrecompiles(rules), msg.AccessList()) + // The access list is prepared without any precompile because it is + // filled with only the recipient precompile address in the EVM'hook + // call. + stateDB.PrepareAccessList(msg.From(), msg.To(), []common.Address{}, msg.AccessList()) } if contractCreation {