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: Upgrade revm #5489

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ reth-transaction-pool = { path = "crates/transaction-pool" }
reth-trie = { path = "crates/trie" }

# revm
revm = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" }
revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" }
revm = { git = "https://github.com/clabby/revm", branch = "cl/canyon-hardfork" }
revm-primitives = { git = "https://github.com/clabby/revm", branch = "cl/canyon-hardfork" }

# eth
alloy-primitives = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/revm-inspectors/src/access_list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use reth_primitives::{AccessList, AccessListItem, Address, B256};
use revm::{
interpreter::{opcode, Interpreter},
Database, EVMData, Inspector,
Database, EvmContext, Inspector,
};
use std::collections::{BTreeSet, HashMap, HashSet};

Expand Down Expand Up @@ -61,7 +61,7 @@ impl<DB> Inspector<DB> for AccessListInspector
where
DB: Database,
{
fn step(&mut self, interpreter: &mut Interpreter<'_>, _data: &mut EVMData<'_, DB>) {
fn step(&mut self, interpreter: &mut Interpreter, _context: &mut EvmContext<'_, DB>) {
match interpreter.current_opcode() {
opcode::SLOAD | opcode::SSTORE => {
if let Ok(slot) = interpreter.stack().peek(0) {
Expand Down
81 changes: 46 additions & 35 deletions crates/revm/revm-inspectors/src/stack/maybe_owned.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use reth_primitives::U256;
use revm::{
interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter},
interpreter::{
CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, InterpreterResult,
},
primitives::{db::Database, Address, Bytes, B256},
EVMData, Inspector,
EvmContext, Inspector,
};
use std::{
cell::{Ref, RefCell},
ops::Range,
rc::Rc,
};

Expand Down Expand Up @@ -69,14 +72,16 @@ where
DB: Database,
INSP: Inspector<DB>,
{
fn initialize_interp(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) {
fn initialize_interp(&mut self, interp: &mut Interpreter, context: &mut EvmContext<'_, DB>) {
match self {
MaybeOwnedInspector::Owned(insp) => insp.borrow_mut().initialize_interp(interp, data),
MaybeOwnedInspector::Owned(insp) => {
insp.borrow_mut().initialize_interp(interp, context)
}
MaybeOwnedInspector::Stacked(_) => {}
}
}

fn step(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) {
fn step(&mut self, interp: &mut Interpreter, data: &mut EvmContext<'_, DB>) {
match self {
MaybeOwnedInspector::Owned(insp) => insp.borrow_mut().step(interp, data),
MaybeOwnedInspector::Stacked(_) => {}
Expand All @@ -85,86 +90,92 @@ where

fn log(
&mut self,
evm_data: &mut EVMData<'_, DB>,
context: &mut EvmContext<'_, DB>,
address: &Address,
topics: &[B256],
data: &Bytes,
) {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().log(evm_data, address, topics, data)
return insp.borrow_mut().log(context, address, topics, data)
}
MaybeOwnedInspector::Stacked(_) => {}
}
}

fn step_end(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) {
fn step_end(&mut self, interp: &mut Interpreter, context: &mut EvmContext<'_, DB>) {
match self {
MaybeOwnedInspector::Owned(insp) => insp.borrow_mut().step_end(interp, data),
MaybeOwnedInspector::Owned(insp) => insp.borrow_mut().step_end(interp, context),
MaybeOwnedInspector::Stacked(_) => {}
}
}

fn call(
&mut self,
data: &mut EVMData<'_, DB>,
context: &mut EvmContext<'_, DB>,
inputs: &mut CallInputs,
) -> (InstructionResult, Gas, Bytes) {
) -> Option<(InterpreterResult, Range<usize>)> {
match self {
MaybeOwnedInspector::Owned(insp) => return insp.borrow_mut().call(data, inputs),
MaybeOwnedInspector::Owned(insp) => return insp.borrow_mut().call(context, inputs),
MaybeOwnedInspector::Stacked(_) => {}
}

(InstructionResult::Continue, Gas::new(0), Bytes::new())
Some((
InterpreterResult {
result: InstructionResult::Continue,
gas: Gas::new(0),
output: Bytes::new(),
},
0..0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rakita What does this new range in the result here signify? Tests are passing, though I don't think this is correct. Occurs in several places.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to shortcircuit the call you can return the result. So this should be None

))
}

fn call_end(
&mut self,
data: &mut EVMData<'_, DB>,
inputs: &CallInputs,
remaining_gas: Gas,
ret: InstructionResult,
out: Bytes,
) -> (InstructionResult, Gas, Bytes) {
context: &mut EvmContext<'_, DB>,
result: InterpreterResult,
) -> InterpreterResult {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().call_end(data, inputs, remaining_gas, ret, out)
}
MaybeOwnedInspector::Owned(insp) => return insp.borrow_mut().call_end(context, result),
MaybeOwnedInspector::Stacked(_) => {}
}
(ret, remaining_gas, out)
result
}

fn create(
&mut self,
data: &mut EVMData<'_, DB>,
context: &mut EvmContext<'_, DB>,
inputs: &mut CreateInputs,
) -> (InstructionResult, Option<Address>, Gas, Bytes) {
) -> Option<(InterpreterResult, Option<Address>)> {
match self {
MaybeOwnedInspector::Owned(insp) => return insp.borrow_mut().create(data, inputs),
MaybeOwnedInspector::Owned(insp) => return insp.borrow_mut().create(context, inputs),
MaybeOwnedInspector::Stacked(_) => {}
}

(InstructionResult::Continue, None, Gas::new(0), Bytes::default())
Some((
InterpreterResult {
result: InstructionResult::Continue,
gas: Gas::new(0),
output: Bytes::new(),
},
None,
))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

fn create_end(
&mut self,
data: &mut EVMData<'_, DB>,
inputs: &CreateInputs,
ret: InstructionResult,
context: &mut EvmContext<'_, DB>,
result: InterpreterResult,
address: Option<Address>,
remaining_gas: Gas,
out: Bytes,
) -> (InstructionResult, Option<Address>, Gas, Bytes) {
) -> (InterpreterResult, Option<Address>) {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().create_end(data, inputs, ret, address, remaining_gas, out)
return insp.borrow_mut().create_end(context, result, address)
}
MaybeOwnedInspector::Stacked(_) => {}
}

(ret, address, remaining_gas, out)
(result, address)
}

fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) {
Expand Down
Loading