diff --git a/chain-evm/src/machine.rs b/chain-evm/src/machine.rs index 3cbf9d9c6..f97d05c65 100644 --- a/chain-evm/src/machine.rs +++ b/chain-evm/src/machine.rs @@ -135,7 +135,7 @@ pub enum Error { pub struct VirtualMachine<'runtime> { /// EVM Block Configuration. config: Config, - environment: &'runtime Environment, + environment: &'runtime mut Environment, precompiles: Precompiles, state: AccountTrie, logs: LogsState, @@ -170,6 +170,7 @@ impl<'runtime> VirtualMachine<'runtime> { u64, ) -> (ExitReason, T), { + self.environment.origin = caller; let config = &(self.config.into()); let metadata = StackSubstateMetadata::new(gas_limit, config); let memory_stack_state = MemoryStackState::new(metadata, self); @@ -208,14 +209,14 @@ impl<'runtime> VirtualMachine<'runtime> { impl<'runtime> VirtualMachine<'runtime> { /// Creates a new `VirtualMachine` given configuration parameters. - pub fn new(config: Config, environment: &'runtime Environment) -> Self { + pub fn new(config: Config, environment: &'runtime mut Environment) -> Self { Self::new_with_state(config, environment, Default::default(), Default::default()) } /// Creates a new `VirtualMachine` given configuration params and a given account storage. pub fn new_with_state( config: Config, - environment: &'runtime Environment, + environment: &'runtime mut Environment, state: AccountTrie, logs: LogsState, ) -> Self { @@ -460,7 +461,7 @@ mod test { use std::rc::Rc; let config = Config::Istanbul; - let environment = Environment { + let mut environment = Environment { gas_price: Default::default(), origin: Default::default(), chain_id: Default::default(), @@ -475,7 +476,7 @@ mod test { let evm_config = config.into(); - let vm = VirtualMachine::new(config, &environment); + let vm = VirtualMachine::new(config, &mut environment); let gas_limit = u64::max_value(); diff --git a/chain-impl-mockchain/src/ledger/evm.rs b/chain-impl-mockchain/src/ledger/evm.rs index 4cec5143e..78a9428e5 100644 --- a/chain-impl-mockchain/src/ledger/evm.rs +++ b/chain-impl-mockchain/src/ledger/evm.rs @@ -62,7 +62,7 @@ impl Ledger { ) -> Result<(), Error> { let mut vm = VirtualMachine::new_with_state( config, - &self.environment, + &mut self.environment, self.accounts.clone(), self.logs.clone(), ); diff --git a/chain-impl-mockchain/src/ledger/tests/evm_tests.rs b/chain-impl-mockchain/src/ledger/tests/evm_tests.rs index ac1a7160a..5a0744f6f 100644 --- a/chain-impl-mockchain/src/ledger/tests/evm_tests.rs +++ b/chain-impl-mockchain/src/ledger/tests/evm_tests.rs @@ -337,7 +337,6 @@ pub fn run_evm_test(path: PathBuf) { } // TODO: need to fix following tests -// "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmTests/envInfo.json" // "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmIOandFlowOperations/loop_stacklimit.json" // "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmIOandFlowOperations/jumpToPush.json" #[test] @@ -370,6 +369,6 @@ fn run_evm_tests() { #[ignore] fn evm_test() { run_evm_test(PathBuf::from( - "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmTests/blockInfo.json", + "../evm-tests/BlockchainTests/GeneralStateTests/VMTests/vmTests/envInfo.json", )); }