From 1ed97ca0c859560077107451439c3e60439184f3 Mon Sep 17 00:00:00 2001 From: Valentin Mihov Date: Tue, 27 Jun 2023 19:05:41 +0300 Subject: [PATCH] Cloning the bytecode structs across fn calls is ok --- crates/interpreter/src/interpreter/contract.rs | 16 ++++------------ crates/revm/src/evm_impl.rs | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/crates/interpreter/src/interpreter/contract.rs b/crates/interpreter/src/interpreter/contract.rs index 2822776d30..434c1c7156 100644 --- a/crates/interpreter/src/interpreter/contract.rs +++ b/crates/interpreter/src/interpreter/contract.rs @@ -19,16 +19,8 @@ pub struct Contract { } impl Contract { - pub fn new( - input: Bytes, - bytecode: &Bytecode, - address: B160, - caller: B160, - value: U256, - ) -> Self { - let bytecode = to_analysed(bytecode.clone()) - .try_into() - .expect("it is analyzed"); + pub fn new(input: Bytes, bytecode: Bytecode, address: B160, caller: B160, value: U256) -> Self { + let bytecode = to_analysed(bytecode).try_into().expect("it is analyzed"); Self { input, @@ -47,7 +39,7 @@ impl Contract { }; Self::new( env.tx.data.clone(), - &bytecode, + bytecode, contract_address, env.tx.caller, env.tx.value, @@ -58,7 +50,7 @@ impl Contract { self.bytecode.jump_map().is_valid(possition) } - pub fn new_with_context(input: Bytes, bytecode: &Bytecode, call_context: &CallContext) -> Self { + pub fn new_with_context(input: Bytes, bytecode: Bytecode, call_context: &CallContext) -> Self { Self::new( input, bytecode, diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 9ed2fd812a..eaee8cba4a 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -342,7 +342,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB, let contract = Box::new(Contract::new( Bytes::new(), - &Bytecode::new_raw(inputs.init_code.clone()), + Bytecode::new_raw(inputs.init_code.clone()), created_address, inputs.caller, inputs.value, @@ -561,7 +561,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB, let contract = Box::new(Contract::new_with_context( inputs.input.clone(), - &bytecode, + bytecode, &inputs.context, ));