From 3ad0d18d9dd7e86da3c56a022e887cea59c09bb9 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:24:24 +0100 Subject: [PATCH] use caller in isSystemCall for future-proofiness Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com> --- core/vm/evm.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index 431f2965ef..9a3c416674 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -170,8 +170,8 @@ func (evm *EVM) Interpreter() *EVMInterpreter { return evm.interpreter } -func (evm *EVM) isSystemCall() bool { - return evm.TxContext.Origin == params.SystemAddress +func isSystemCall(caller ContractRef) bool { + return caller.Address() == params.SystemAddress } // Call executes the contract associated with the addr with the given input as @@ -198,7 +198,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas p, isPrecompile := evm.precompile(addr) if !evm.StateDB.Exist(addr) { - if !isPrecompile && evm.chainRules.IsEIP4762 && !evm.isSystemCall() { + if !isPrecompile && evm.chainRules.IsEIP4762 && !isSystemCall(caller) { // add proof of absence to witness wgas := evm.AccessEvents.AddAccount(addr, false) if gas < wgas { @@ -229,7 +229,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas // If the account has no code, we can abort here // The depth-check is already done, and precompiles handled above contract := NewContract(caller, AccountRef(addrCopy), value, gas) - contract.IsSystemCall = evm.isSystemCall() + contract.IsSystemCall = isSystemCall(caller) contract.SetCallCode(&addrCopy, evm.resolveCodeHash(addrCopy), code) ret, err = evm.interpreter.Run(contract, input, false) gas = contract.Gas