Skip to content

Commit

Permalink
chore: bump revm to latest main
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Aug 9, 2023
1 parent 24def95 commit ce339f4
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 123 deletions.
29 changes: 23 additions & 6 deletions Cargo.lock

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

19 changes: 10 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ rust-version = "1.70" # Remember to update .clippy.toml and README.md
license = "MIT OR Apache-2.0"
homepage = "https://paradigmxyz.github.io/reth"
repository = "https://github.com/paradigmxyz/reth"
exclude = [
".github/",
]
exclude = [".github/"]

# Like release, but with full debug symbols. Useful for e.g. `perf`.
[profile.debug-fast]
Expand All @@ -78,8 +76,8 @@ codegen-units = 1
incremental = false

[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
revm = { git = "https://github.com/bluealloy/revm/" }
revm-primitives = { git = "https://github.com/bluealloy/revm/" }

[workspace.dependencies]
## reth
Expand All @@ -102,8 +100,7 @@ reth-transaction-pool = { path = "./crates/transaction-pool" }
reth-tasks = { path = "./crates/tasks" }
reth-network = { path = "./crates/net/network" }
reth-network-api = { path = "./crates/net/network-api" }
reth-rpc-types-compat = { path = "./crates/rpc/rpc-types-compat"}

reth-rpc-types-compat = { path = "./crates/rpc/rpc-types-compat" }

## eth
ethers-core = { version = "2.0.8", default-features = false }
Expand Down Expand Up @@ -144,10 +141,14 @@ jsonrpsee-core = { version = "0.19" }
jsonrpsee-types = { version = "0.19" }

## crypto
secp256k1 = { version = "0.27.0", default-features = false, features = ["global-context", "rand-std", "recovery"] }
secp256k1 = { version = "0.27.0", default-features = false, features = [
"global-context",
"rand-std",
"recovery",
] }
# for eip-4844
c-kzg = { git = "https://github.com/ethereum/c-kzg-4844" }

### misc-testing
proptest = "1.0"
arbitrary = "1.1"
arbitrary = "1.1"
5 changes: 3 additions & 2 deletions bin/reth/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ pub fn insert_genesis_state<DB: Database>(
let mut bytecode_hash = None;
if let Some(code) = &account.code {
let bytecode = Bytecode::new_raw(code.0.clone());
let hash = bytecode.hash_slow();
// FIXME: Can bytecode_hash be Some(Bytes::new()) here?
bytecode_hash = Some(bytecode.hash);
state.add_bytecode(bytecode.hash, bytecode);
bytecode_hash = Some(hash);
state.add_bytecode(hash, bytecode);
}
state.create_account(
0,
Expand Down
22 changes: 1 addition & 21 deletions crates/primitives/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ impl Account {
/// Bytecode for an account.
///
/// A wrapper around [`revm::primitives::Bytecode`][RevmBytecode] with encoding/decoding support.
///
/// Note: Upon decoding bytecode from the database, you *should* set the code hash using
/// [`Self::with_code_hash`].
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Bytecode(pub RevmBytecode);

Expand All @@ -61,18 +58,6 @@ impl Bytecode {
pub fn new_raw(bytes: Bytes) -> Self {
Self(RevmBytecode::new_raw(bytes))
}

/// Create new bytecode from raw bytes and its hash.
pub fn new_raw_with_hash(bytes: Bytes, code_hash: H256) -> Self {
let revm_bytecode = unsafe { RevmBytecode::new_raw_with_hash(bytes, code_hash) };
Self(revm_bytecode)
}

/// Set the hash of the inner bytecode.
pub fn with_code_hash(mut self, code_hash: H256) -> Self {
self.0.hash = code_hash;
self
}
}

impl Deref for Bytecode {
Expand Down Expand Up @@ -121,15 +106,10 @@ impl Compact for Bytecode {
let decoded = match variant {
0 => Bytecode(RevmBytecode::new_raw(bytes)),
1 => Bytecode(unsafe {
RevmBytecode::new_checked(
bytes,
buf.read_u64::<BigEndian>().unwrap() as usize,
None,
)
RevmBytecode::new_checked(bytes, buf.read_u64::<BigEndian>().unwrap() as usize)
}),
2 => Bytecode(RevmBytecode {
bytecode: bytes,
hash: KECCAK_EMPTY,
state: BytecodeState::Analysed {
len: buf.read_u64::<BigEndian>().unwrap() as usize,
jump_map: JumpMap::from_slice(buf),
Expand Down
1 change: 0 additions & 1 deletion crates/revm/revm-inspectors/src/access_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ where
&mut self,
interpreter: &mut Interpreter,
_data: &mut EVMData<'_, DB>,
_is_static: bool,
) -> InstructionResult {
let pc = interpreter.program_counter();
let op = interpreter.contract.bytecode.bytecode()[pc];
Expand Down
25 changes: 6 additions & 19 deletions crates/revm/revm-inspectors/src/stack/maybe_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,20 @@ where
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().initialize_interp(interp, data, is_static)
return insp.borrow_mut().initialize_interp(interp, data)
}
MaybeOwnedInspector::Stacked(_) => {}
}

InstructionResult::Continue
}

fn step(
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().step(interp, data, is_static)
}
MaybeOwnedInspector::Owned(insp) => return insp.borrow_mut().step(interp, data),
MaybeOwnedInspector::Stacked(_) => {}
}

Expand All @@ -119,12 +111,11 @@ where
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
eval: InstructionResult,
) -> InstructionResult {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().step_end(interp, data, is_static, eval)
return insp.borrow_mut().step_end(interp, data, eval)
}
MaybeOwnedInspector::Stacked(_) => {}
}
Expand All @@ -136,12 +127,9 @@ where
&mut self,
data: &mut EVMData<'_, DB>,
inputs: &mut CallInputs,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().call(data, inputs, is_static)
}
MaybeOwnedInspector::Owned(insp) => return insp.borrow_mut().call(data, inputs),
MaybeOwnedInspector::Stacked(_) => {}
}

Expand All @@ -155,11 +143,10 @@ where
remaining_gas: Gas,
ret: InstructionResult,
out: Bytes,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
match self {
MaybeOwnedInspector::Owned(insp) => {
return insp.borrow_mut().call_end(data, inputs, remaining_gas, ret, out, is_static)
return insp.borrow_mut().call_end(data, inputs, remaining_gas, ret, out)
}
MaybeOwnedInspector::Stacked(_) => {}
}
Expand Down
15 changes: 5 additions & 10 deletions crates/revm/revm-inspectors/src/stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ where
&mut self,
interpreter: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
call_inspectors!(inspector, [&mut self.custom_print_tracer], {
let status = inspector.initialize_interp(interpreter, data, is_static);
let status = inspector.initialize_interp(interpreter, data);

// Allow inspectors to exit early
if status != InstructionResult::Continue {
Expand All @@ -123,10 +122,9 @@ where
&mut self,
interpreter: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
call_inspectors!(inspector, [&mut self.custom_print_tracer], {
let status = inspector.step(interpreter, data, is_static);
let status = inspector.step(interpreter, data);

// Allow inspectors to exit early
if status != InstructionResult::Continue {
Expand All @@ -153,11 +151,10 @@ where
&mut self,
interpreter: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
eval: InstructionResult,
) -> InstructionResult {
call_inspectors!(inspector, [&mut self.custom_print_tracer], {
let status = inspector.step_end(interpreter, data, is_static, eval);
let status = inspector.step_end(interpreter, data, eval);

// Allow inspectors to exit early
if status != InstructionResult::Continue {
Expand All @@ -172,10 +169,9 @@ where
&mut self,
data: &mut EVMData<'_, DB>,
inputs: &mut CallInputs,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
call_inspectors!(inspector, [&mut self.custom_print_tracer], {
let (status, gas, retdata) = inspector.call(data, inputs, is_static);
let (status, gas, retdata) = inspector.call(data, inputs);

// Allow inspectors to exit early
if status != InstructionResult::Continue {
Expand All @@ -193,11 +189,10 @@ where
remaining_gas: Gas,
ret: InstructionResult,
out: Bytes,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
call_inspectors!(inspector, [&mut self.custom_print_tracer], {
let (new_ret, new_gas, new_out) =
inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static);
inspector.call_end(data, inputs, remaining_gas, ret, out.clone());

// If the inspector returns a different ret or a revert with a non-empty message,
// we assume it wants to tell us something
Expand Down
1 change: 0 additions & 1 deletion crates/revm/revm-inspectors/src/tracing/fourbyte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ where
&mut self,
_data: &mut EVMData<'_, DB>,
call: &mut CallInputs,
_is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
if call.input.len() >= 4 {
let selector = Selector::try_from(&call.input[..4]).expect("input is at least 4 bytes");
Expand Down
10 changes: 1 addition & 9 deletions crates/revm/revm-inspectors/src/tracing/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,7 @@ impl<DB> Inspector<DB> for JsInspector
where
DB: Database,
{
fn step(
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
_is_static: bool,
) -> InstructionResult {
fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult {
if self.step_fn.is_none() {
return InstructionResult::Continue
}
Expand Down Expand Up @@ -332,7 +327,6 @@ where
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
_is_static: bool,
eval: InstructionResult,
) -> InstructionResult {
if self.step_fn.is_none() {
Expand Down Expand Up @@ -366,7 +360,6 @@ where
&mut self,
data: &mut EVMData<'_, DB>,
inputs: &mut CallInputs,
_is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
self.register_precompiles(&data.precompiles);

Expand Down Expand Up @@ -410,7 +403,6 @@ where
remaining_gas: Gas,
ret: InstructionResult,
out: Bytes,
_is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
if self.exit_fn.is_some() {
let frame_result =
Expand Down
Loading

0 comments on commit ce339f4

Please sign in to comment.