From b19992f4b30fef7ba8ea7e1caed95e7e188268b6 Mon Sep 17 00:00:00 2001 From: codchen Date: Mon, 8 Jan 2024 11:29:52 +0800 Subject: [PATCH] Send correct sender to precompile in delegatecall --- 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 79b6ab5930..8b6ef55175 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -340,7 +340,10 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by // It is allowed to call precompiles, even via delegatecall if p, isPrecompile := evm.precompile(addr); isPrecompile { - ret, gas, err = RunPrecompiledContract(p, evm, caller.Address(), input, gas) + // NOTE: caller must, at all times be a contract. It should never happen + // that caller is something other than a Contract. + parent := caller.(*Contract) + ret, gas, err = RunPrecompiledContract(p, evm, parent.CallerAddress, input, gas) } else { addrCopy := addr // Initialise a new contract and make initialise the delegate values