Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(interpreter): unbox contract field #1228

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ use revm_primitives::U256;
use std::borrow::ToOwned;
use std::boxed::Box;

/// EVM bytecode interpreter.
#[derive(Debug)]
pub struct Interpreter {
/// Contract information and invoking data
pub contract: Box<Contract>,
pub contract: Contract,
/// The current instruction pointer.
pub instruction_pointer: *const u8,
/// The execution control flag. If this is not set to `Continue`, the interpreter will stop
Expand Down Expand Up @@ -114,7 +115,7 @@ impl InterpreterAction {

impl Interpreter {
/// Create new interpreter
pub fn new(contract: Box<Contract>, gas_limit: u64, is_static: bool) -> Self {
pub fn new(contract: Contract, gas_limit: u64, is_static: bool) -> Self {
Self {
instruction_pointer: contract.bytecode.as_ptr(),
contract,
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn bench_eval(g: &mut BenchmarkGroup<'_, WallTime>, evm: &mut Evm<'static, (), B
// replace memory with empty memory to use it inside interpreter.
// Later return memory back.
let temp = core::mem::replace(&mut shared_memory, EMPTY_SHARED_MEMORY);
let mut interpreter = Interpreter::new(Box::new(contract.clone()), u64::MAX, false);
let mut interpreter = Interpreter::new(contract.clone(), u64::MAX, false);
let res = interpreter.run(temp, &instruction_table, &mut host);
shared_memory = interpreter.take_memory();
host.clear();
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/context/evm_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ impl<DB: Database> EvmContext<DB> {
inputs.return_memory_offset.clone(),
))
} else if !bytecode.is_empty() {
let contract = Box::new(Contract::new_with_context(
let contract = Contract::new_with_context(
inputs.input.clone(),
bytecode,
code_hash,
&inputs.context,
));
);
// Create interpreter and executes call and push new CallStackFrame.
Ok(FrameOrResult::new_call_frame(
inputs.return_memory_offset.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/context/inner_evm_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ impl<DB: Database> InnerEvmContext<DB> {

let bytecode = Bytecode::new_raw(inputs.init_code.clone());

let contract = Box::new(Contract::new(
let contract = Contract::new(
Bytes::new(),
bytecode,
init_code_hash,
created_address,
inputs.caller,
inputs.value,
));
);

Ok(FrameOrResult::new_create_frame(
created_address,
Expand Down
Loading