diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index 07ab0439d9..47e041473f 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -113,6 +113,7 @@ impl Interpreter { bytecode, None, crate::primitives::Address::default(), + None, crate::primitives::Address::default(), U256::ZERO, ), diff --git a/crates/interpreter/src/interpreter/contract.rs b/crates/interpreter/src/interpreter/contract.rs index 49e511f66e..304b700446 100644 --- a/crates/interpreter/src/interpreter/contract.rs +++ b/crates/interpreter/src/interpreter/contract.rs @@ -19,6 +19,9 @@ pub struct Contract { pub hash: Option, /// Target address of the account. Storage of this address is going to be modified. pub target_address: Address, + /// Address of the account the bytecode was loaded from. This can be different from target_address + /// in the case of DELEGATECALL or CALLCODE + pub bytecode_address: Option
, /// Caller of the EVM. pub caller: Address, /// Value send to contract from transaction or from CALL opcodes. @@ -33,6 +36,7 @@ impl Contract { bytecode: Bytecode, hash: Option, target_address: Address, + bytecode_address: Option
, caller: Address, call_value: U256, ) -> Self { @@ -43,6 +47,7 @@ impl Contract { bytecode, hash, target_address, + bytecode_address, caller, call_value, } @@ -55,11 +60,16 @@ impl Contract { TxKind::Call(caller) => caller, TxKind::Create => Address::ZERO, }; + let bytecode_address = match env.tx.transact_to { + TxKind::Call(caller) => Some(caller), + TxKind::Create => None, + }; Self::new( env.tx.data.clone(), bytecode, hash, contract_address, + bytecode_address, env.tx.caller, env.tx.value, ) @@ -78,6 +88,7 @@ impl Contract { bytecode, hash, call_context.target_address, + Some(call_context.bytecode_address), call_context.caller, call_context.call_value(), ) diff --git a/crates/revm/src/context/inner_evm_context.rs b/crates/revm/src/context/inner_evm_context.rs index 32c2826a05..4893f8cef2 100644 --- a/crates/revm/src/context/inner_evm_context.rs +++ b/crates/revm/src/context/inner_evm_context.rs @@ -339,6 +339,7 @@ impl InnerEvmContext { Bytecode::Eof(Arc::new(initcode.clone())), None, created_address, + None, inputs.caller, inputs.value, ); @@ -477,6 +478,7 @@ impl InnerEvmContext { bytecode, Some(init_code_hash), created_address, + None, inputs.caller, inputs.value, );