diff --git a/.changeset/lovely-tables-impress.md b/.changeset/lovely-tables-impress.md new file mode 100644 index 000000000..fc85e5cd3 --- /dev/null +++ b/.changeset/lovely-tables-impress.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/edr": patch +--- + +Upgraded revm to commit aceb093 diff --git a/Cargo.lock b/Cargo.lock index c25c054e6..ecb73cc12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,9 +369,9 @@ dependencies = [ [[package]] name = "aurora-engine-modexp" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfacad86e9e138fca0670949eb8ed4ffdf73a55bded8887efe0863cd1a3a6f70" +checksum = "0aef7712851e524f35fbbb74fa6599c5cd8692056a1c36f9ca0d2001b670e7e5" dependencies = [ "hex", "num", @@ -2921,7 +2921,7 @@ dependencies = [ [[package]] name = "revm" version = "8.0.0" -source = "git+https://github.com/Wodann/revm?rev=451f122#451f122b5a234db90e3fa00dedfaec6c03b46d61" +source = "git+https://github.com/NomicFoundation/revm?rev=aceb093#aceb0939b1712faa0e8f45c1f5621c11b81df94e" dependencies = [ "auto_impl", "cfg-if", @@ -2934,7 +2934,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "4.0.0" -source = "git+https://github.com/Wodann/revm?rev=451f122#451f122b5a234db90e3fa00dedfaec6c03b46d61" +source = "git+https://github.com/NomicFoundation/revm?rev=aceb093#aceb0939b1712faa0e8f45c1f5621c11b81df94e" dependencies = [ "revm-primitives", "serde", @@ -2943,7 +2943,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "6.0.0" -source = "git+https://github.com/Wodann/revm?rev=451f122#451f122b5a234db90e3fa00dedfaec6c03b46d61" +source = "git+https://github.com/NomicFoundation/revm?rev=aceb093#aceb0939b1712faa0e8f45c1f5621c11b81df94e" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -2958,7 +2958,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "3.1.1" -source = "git+https://github.com/Wodann/revm?rev=451f122#451f122b5a234db90e3fa00dedfaec6c03b46d61" +source = "git+https://github.com/NomicFoundation/revm?rev=aceb093#aceb0939b1712faa0e8f45c1f5621c11b81df94e" dependencies = [ "alloy-primitives 0.7.0", "auto_impl", diff --git a/crates/edr_eth/Cargo.toml b/crates/edr_eth/Cargo.toml index e0887e895..ab3fc9ba5 100644 --- a/crates/edr_eth/Cargo.toml +++ b/crates/edr_eth/Cargo.toml @@ -20,7 +20,7 @@ reqwest = { version = "0.11", features = ["blocking", "json"] } reqwest-middleware = { version = "0.2.4", default-features = false } reqwest-retry = { version = "0.3.0", default-features = false } reqwest-tracing = { version = "0.4.7", default-features = false, optional = true } -revm-primitives = { git = "https://github.com/Wodann/revm", rev = "451f122", version = "3.1", default-features = false, features = ["hashbrown"] } +revm-primitives = { git = "https://github.com/NomicFoundation/revm", rev = "aceb093", version = "3.1", default-features = false, features = ["hashbrown"] } serde = { version = "1.0.147", default-features = false, features = ["derive"], optional = true } serde_json = { version = "1.0.89", optional = true } sha3 = { version = "0.10.8", default-features = false } diff --git a/crates/edr_eth/src/block/difficulty.rs b/crates/edr_eth/src/block/difficulty.rs index 4e952b4e4..92386061f 100644 --- a/crates/edr_eth/src/block/difficulty.rs +++ b/crates/edr_eth/src/block/difficulty.rs @@ -14,7 +14,7 @@ fn bomb_delay(spec_id: SpecId) -> u64 { // SpecId::LONDON => 9500000, // EIP-3554 SpecId::ARROW_GLACIER => 10700000, SpecId::GRAY_GLACIER => 11400000, - SpecId::MERGE | SpecId::SHANGHAI | SpecId::CANCUN | SpecId::LATEST => { + _ => { unreachable!("Post-merge hardforks don't have a bomb delay") } } diff --git a/crates/edr_eth/src/block/reward.rs b/crates/edr_eth/src/block/reward.rs index 5d60424fc..8f24b82f6 100644 --- a/crates/edr_eth/src/block/reward.rs +++ b/crates/edr_eth/src/block/reward.rs @@ -20,6 +20,6 @@ pub fn miner_reward(spec_id: SpecId) -> Option { | SpecId::LONDON | SpecId::ARROW_GLACIER | SpecId::GRAY_GLACIER => Some(U256::from(2_000_000_000_000_000_000u128)), - SpecId::MERGE | SpecId::SHANGHAI | SpecId::CANCUN | SpecId::LATEST => None, + _ => None, } } diff --git a/crates/edr_evm/Cargo.toml b/crates/edr_evm/Cargo.toml index 7f6f7d98f..d910da9f8 100644 --- a/crates/edr_evm/Cargo.toml +++ b/crates/edr_evm/Cargo.toml @@ -21,7 +21,7 @@ once_cell = { version = "1.18.0", default-features = false, features = ["alloc", parking_lot = { version = "0.12.1", default-features = false } edr_defaults = { version = "0.3.5", path = "../edr_defaults" } edr_eth = { version = "0.3.5", path = "../edr_eth", features = ["rand", "serde"] } -revm = { git = "https://github.com/Wodann/revm", rev = "451f122", version = "8.0", default-features = false, features = ["c-kzg", "dev", "serde"] } +revm = { git = "https://github.com/NomicFoundation/revm", rev = "aceb093", version = "8.0", default-features = false, features = ["c-kzg", "dev", "serde"] } rpds = { version = "1.1.0", default-features = false, features = ["std"] } serde = { version = "1.0.158", default-features = false, features = ["std"] } serde_json = { version = "1.0.94", default-features = false, features = ["std"] } diff --git a/crates/edr_evm/benches/state/util.rs b/crates/edr_evm/benches/state/util.rs index b0c207f92..dd70dc1dc 100644 --- a/crates/edr_evm/benches/state/util.rs +++ b/crates/edr_evm/benches/state/util.rs @@ -234,6 +234,5 @@ pub fn account_has_code(state: &dyn SyncState, address: &Address) -> && !state .code_by_hash(account_info.code_hash) .expect("code_by_hash should succeed") - .bytecode .is_empty() } diff --git a/crates/edr_evm/src/debug_trace.rs b/crates/edr_evm/src/debug_trace.rs index 3de5d2d38..69025c5b0 100644 --- a/crates/edr_evm/src/debug_trace.rs +++ b/crates/edr_evm/src/debug_trace.rs @@ -5,7 +5,7 @@ use revm::{ db::DatabaseComponents, handler::register::EvmHandler, interpreter::{ - opcode::{self, BoxedInstruction, InstructionTables}, + opcode::{self, BoxedInstruction, InstructionTables, OpCode}, InstructionResult, Interpreter, InterpreterResult, }, primitives::{ @@ -326,7 +326,7 @@ impl TracerEip3155 { } fn step(&mut self, interp: &mut Interpreter) { - self.contract_address = interp.contract.address; + self.contract_address = interp.contract.target_address; self.gas_remaining = interp.gas().remaining(); if !self.config.disable_stack { @@ -392,7 +392,7 @@ impl TracerEip3155 { }; let mut error = None; - let op_name = opcode::OPCODE_JUMPMAP[self.opcode as usize].map_or_else( + let op_name = OpCode::new(self.opcode).map_or_else( || { // Matches message from Hardhat // https://github.com/NomicFoundation/hardhat/blob/37c5c5845969b15995cc96cb6bd0596977f8b1f8/packages/hardhat-core/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts#L452 @@ -400,7 +400,7 @@ impl TracerEip3155 { error = Some(fallback.clone()); fallback }, - String::from, + |opcode| opcode.to_string(), ); let gas_cost = self.gas_remaining.saturating_sub(interp.gas().remaining()); diff --git a/crates/edr_evm/src/trace.rs b/crates/edr_evm/src/trace.rs index 301a72d46..2ac0e12ea 100644 --- a/crates/edr_evm/src/trace.rs +++ b/crates/edr_evm/src/trace.rs @@ -5,8 +5,8 @@ use revm::{ handler::register::EvmHandler, interpreter::{ opcode::{self, BoxedInstruction, InstructionTables}, - return_revert, CallInputs, CallOutcome, CreateInputs, CreateOutcome, InstructionResult, - Interpreter, SuccessOrHalt, + return_revert, CallInputs, CallOutcome, CallValue, CreateInputs, CreateOutcome, + InstructionResult, Interpreter, SuccessOrHalt, }, primitives::{Bytecode, EVMError, ExecutionResult, Output}, Database, Evm, EvmContext, FrameOrResult, FrameResult, @@ -118,6 +118,10 @@ pub fn register_trace_collector_handles< let create_inputs = create_input_stack.borrow_mut().pop().unwrap(); tracer.create_transaction_end(&ctx.evm, &create_inputs, outcome); } + // TODO: https://github.com/NomicFoundation/edr/issues/427 + FrameResult::EOFCreate(_) => { + unreachable!("EDR doesn't support EOF yet.") + } } old_handle(ctx, frame_result) }); @@ -284,7 +288,7 @@ impl TraceCollector { let code = data .journaled_state .state - .get(&inputs.contract) + .get(&inputs.bytecode_address) .map(|account| account.info.clone()) .map(|mut account_info| { if let Some(code) = account_info.code.take() { @@ -294,7 +298,7 @@ impl TraceCollector { } }) .unwrap_or_else(|| { - data.db.basic(inputs.contract).unwrap().map_or( + data.db.basic(inputs.bytecode_address).unwrap().map_or( // If an invalid contract address was provided, return empty code Bytecode::new(), |account_info| { @@ -307,12 +311,14 @@ impl TraceCollector { self.pending_before = Some(BeforeMessage { depth: data.journaled_state.depth, - caller: inputs.context.caller, - to: Some(inputs.context.address), + caller: inputs.caller, + to: Some(inputs.target_address), gas_limit: inputs.gas_limit, data: inputs.input.clone(), - value: inputs.context.apparent_value, - code_address: Some(inputs.context.code_address), + value: match inputs.value { + CallValue::Transfer(value) | CallValue::Apparent(value) => value, + }, + code_address: Some(inputs.bytecode_address), code: Some(code), }); } diff --git a/crates/edr_evm/src/transaction/executable.rs b/crates/edr_evm/src/transaction/executable.rs index fd776fb0e..f9588520e 100644 --- a/crates/edr_evm/src/transaction/executable.rs +++ b/crates/edr_evm/src/transaction/executable.rs @@ -8,11 +8,11 @@ use edr_eth::{ Eip1559SignedTransaction, Eip155SignedTransaction, Eip2930SignedTransaction, Eip4844SignedTransaction, LegacySignedTransaction, SignedTransaction, TxKind, }, - Address, U256, + Address, HashMap, U256, }; use revm::{ interpreter::gas::validate_initial_tx_gas, - primitives::{CreateScheme, SpecId, TransactTo, TxEnv}, + primitives::{SpecId, TransactTo, TxEnv}, }; use super::TransactionCreationError; @@ -109,7 +109,7 @@ impl From for TxEnv { fn transact_to(kind: TxKind) -> TransactTo { match kind { TxKind::Call(address) => TransactTo::Call(address), - TxKind::Create => TransactTo::Create(CreateScheme::Create), + TxKind::Create => TransactTo::Create, } } @@ -145,6 +145,9 @@ impl From for TxEnv { access_list: Vec::new(), blob_hashes: Vec::new(), max_fee_per_blob_gas: None, + // TODO: https://github.com/NomicFoundation/edr/issues/427 + eof_initcodes: Vec::new(), + eof_initcodes_hashed: HashMap::new(), }, SignedTransaction::Eip2930(Eip2930SignedTransaction { nonce, @@ -168,6 +171,9 @@ impl From for TxEnv { access_list: access_list.into(), blob_hashes: Vec::new(), max_fee_per_blob_gas: None, + // TODO: https://github.com/NomicFoundation/edr/issues/427 + eof_initcodes: Vec::new(), + eof_initcodes_hashed: HashMap::new(), }, SignedTransaction::Eip1559(Eip1559SignedTransaction { nonce, @@ -192,6 +198,9 @@ impl From for TxEnv { access_list: access_list.into(), blob_hashes: Vec::new(), max_fee_per_blob_gas: None, + // TODO: https://github.com/NomicFoundation/edr/issues/427 + eof_initcodes: Vec::new(), + eof_initcodes_hashed: HashMap::new(), }, SignedTransaction::Eip4844(Eip4844SignedTransaction { nonce, @@ -218,6 +227,9 @@ impl From for TxEnv { gas_priority_fee: Some(max_priority_fee_per_gas), blob_hashes, max_fee_per_blob_gas: Some(max_fee_per_blob_gas), + // TODO: https://github.com/NomicFoundation/edr/issues/427 + eof_initcodes: Vec::new(), + eof_initcodes_hashed: HashMap::new(), }, } } @@ -416,6 +428,8 @@ fn initial_cost(spec_id: SpecId, transaction: &SignedTransaction) -> u64 { access_list .as_ref() .map_or(&[], |access_list| access_list.as_slice()), + // TODO: https://github.com/NomicFoundation/edr/issues/427 + &[], ) } diff --git a/crates/edr_napi/src/trace.rs b/crates/edr_napi/src/trace.rs index 4ec3ee757..04f0085d2 100644 --- a/crates/edr_napi/src/trace.rs +++ b/crates/edr_napi/src/trace.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use edr_evm::{interpreter::OPCODE_JUMPMAP, trace::BeforeMessage}; +use edr_evm::{interpreter::OpCode, trace::BeforeMessage}; use napi::{ bindgen_prelude::{BigInt, Buffer, Either3}, Env, JsBuffer, JsBufferValue, @@ -96,9 +96,7 @@ impl TracingStep { Self { depth: step.depth as u8, pc: BigInt::from(step.pc), - opcode: OPCODE_JUMPMAP[usize::from(step.opcode)] - .unwrap_or("") - .to_string(), + opcode: OpCode::name_by_op(step.opcode).to_string(), stack_top: step.stack_top.map(|v| BigInt { sign_bit: false, words: v.into_limbs().to_vec(), diff --git a/crates/edr_provider/src/console_log.rs b/crates/edr_provider/src/console_log.rs index 288f54c54..2f296a53c 100644 --- a/crates/edr_provider/src/console_log.rs +++ b/crates/edr_provider/src/console_log.rs @@ -20,7 +20,7 @@ pub fn register_console_log_handles< let old_handle = handler.execution.call.clone(); handler.execution.call = Arc::new( move |ctx, inputs| -> Result> { - if inputs.contract == CONSOLE_ADDRESS { + if inputs.bytecode_address == CONSOLE_ADDRESS { let collector = ctx.external.get_context_data(); collector.record_console_log(inputs.input.clone()); } diff --git a/crates/edr_provider/src/mock.rs b/crates/edr_provider/src/mock.rs index 05c1c396f..2d8cede44 100644 --- a/crates/edr_provider/src/mock.rs +++ b/crates/edr_provider/src/mock.rs @@ -39,7 +39,7 @@ pub fn register_mocking_handles