evm: prepare access list in eth_call (#348)

Closes: #335

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
yihuang 2021-08-16 16:19:27 +08:00 committed by GitHub
parent df13b398ec
commit 353455def9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -74,7 +74,6 @@ func NewAnteHandler(
NewEthNonceVerificationDecorator(ak), NewEthNonceVerificationDecorator(ak),
NewEthGasConsumeDecorator(ak, bankKeeper, evmKeeper), NewEthGasConsumeDecorator(ak, bankKeeper, evmKeeper),
NewCanTransferDecorator(evmKeeper), NewCanTransferDecorator(evmKeeper),
NewAccessListDecorator(evmKeeper),
NewEthIncrementSenderSequenceDecorator(ak), // innermost AnteDecorator. NewEthIncrementSenderSequenceDecorator(ak), // innermost AnteDecorator.
) )

View File

@ -242,6 +242,12 @@ func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message, cfg *params.ChainCo
} }
leftoverGas := msg.Gas() - intrinsicGas 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 { if contractCreation {
ret, _, leftoverGas, vmErr = evm.Create(sender, msg.Data(), leftoverGas, msg.Value()) ret, _, leftoverGas, vmErr = evm.Create(sender, msg.Data(), leftoverGas, msg.Value())
} else { } else {