From 353455def9019cf6edf55fcc4709e1b14c37c358 Mon Sep 17 00:00:00 2001 From: yihuang Date: Mon, 16 Aug 2021 16:19:27 +0800 Subject: [PATCH] evm: prepare access list in `eth_call` (#348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #335 Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- app/ante/ante.go | 1 - x/evm/keeper/state_transition.go | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/ante/ante.go b/app/ante/ante.go index 9fcb12c7..68fe909b 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -74,7 +74,6 @@ func NewAnteHandler( NewEthNonceVerificationDecorator(ak), NewEthGasConsumeDecorator(ak, bankKeeper, evmKeeper), NewCanTransferDecorator(evmKeeper), - NewAccessListDecorator(evmKeeper), NewEthIncrementSenderSequenceDecorator(ak), // innermost AnteDecorator. ) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 30b0e481..dcdeab3e 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -242,6 +242,12 @@ func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message, cfg *params.ChainCo } leftoverGas := msg.Gas() - intrinsicGas + // access list preparaion 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.Rules(big.NewInt(k.Ctx().BlockHeight())); rules.IsBerlin { + k.PrepareAccessList(msg.From(), msg.To(), vm.ActivePrecompiles(rules), msg.AccessList()) + } + if contractCreation { ret, _, leftoverGas, vmErr = evm.Create(sender, msg.Data(), leftoverGas, msg.Value()) } else {