From e08309004de5e54f20c67549ada19f6133a66706 Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Wed, 7 Feb 2024 12:08:06 -0500 Subject: [PATCH] Explicitly pass readOnly flag --- core/vm/evm.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index d1cd9971e043..cbccef594521 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -400,7 +400,10 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte } if p, isPrecompile := evm.precompile(addr); isPrecompile { - ret, gas, err = RunStatefulPrecompiledContract(p, evm, caller.Address(), addr, input, gas, evm.interpreter.readOnly) + // Explicitly pass readOnly as true for StaticCall OpCode. + // Precompile implementation is responsible for honoring readOnly flag. + // No state should be modified, return an error instead. + ret, gas, err = RunStatefulPrecompiledContract(p, evm, caller.Address(), addr, input, gas, true) } else { // At this point, we use a copy of address. If we don't, the go compiler will // leak the 'contract' to the outer scope, and make allocation for 'contract'