Skip to content

Commit

Permalink
Cloning the bytecode structs across fn calls is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
valo committed Jun 27, 2023
1 parent e9665d4 commit 1ed97ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 4 additions & 12 deletions crates/interpreter/src/interpreter/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -47,7 +39,7 @@ impl Contract {
};
Self::new(
env.tx.data.clone(),
&bytecode,
bytecode,
contract_address,
env.tx.caller,
env.tx.value,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
));

Expand Down

0 comments on commit 1ed97ca

Please sign in to comment.