From 44123c08fff2399538677763444c3411ee548ec1 Mon Sep 17 00:00:00 2001 From: Brecht Devos Date: Sun, 15 Sep 2024 03:50:09 +0900 Subject: [PATCH 1/8] Merge remote-tracking branch 'origin/booster' into v43 # Conflicts: # crates/interpreter/src/host.rs # crates/interpreter/src/host/dummy.rs # crates/interpreter/src/inner_models.rs # crates/interpreter/src/instructions/host.rs # crates/interpreter/src/instructions/system.rs # crates/interpreter/src/interpreter.rs # crates/interpreter/src/interpreter/contract.rs # crates/precompile/src/lib.rs # crates/primitives/src/db.rs # crates/primitives/src/db/components.rs # crates/primitives/src/db/components/block_hash.rs # crates/primitives/src/env.rs # crates/primitives/src/precompile.rs # crates/primitives/src/state.rs # crates/revm/src/context/inner_evm_context.rs # crates/revm/src/db/emptydb.rs # crates/revm/src/db/ethersdb.rs # crates/revm/src/db/in_memory_db.rs # crates/revm/src/db/states/bundle_state.rs # crates/revm/src/db/states/cache.rs # crates/revm/src/db/states/reverts.rs # crates/revm/src/db/states/state.rs # crates/revm/src/db/states/transition_state.rs # crates/revm/src/evm.rs # crates/revm/src/inspector.rs # crates/revm/src/inspector/customprinter.rs # crates/revm/src/inspector/gas.rs # crates/revm/src/journaled_state.rs # examples/fork_ref_transact.rs --- crates/interpreter/src/host.rs | 23 ++- crates/interpreter/src/host/dummy.rs | 23 ++- .../interpreter/src/instructions/contract.rs | 98 +++++++-- crates/interpreter/src/instructions/host.rs | 14 +- .../interpreter/src/instructions/host_env.rs | 4 +- crates/interpreter/src/instructions/macros.rs | 15 ++ crates/interpreter/src/instructions/system.rs | 4 +- crates/interpreter/src/interpreter.rs | 15 +- .../interpreter/src/interpreter/contract.rs | 22 +- .../src/interpreter_action/call_inputs.rs | 17 +- .../src/interpreter_action/create_inputs.rs | 31 ++- .../interpreter_action/eof_create_inputs.rs | 16 +- crates/precompile/src/lib.rs | 3 + crates/precompile/src/xcalloptions.rs | 41 ++++ crates/primitives/src/db.rs | 34 +-- crates/primitives/src/db/components.rs | 28 +-- .../src/db/components/block_hash.rs | 12 +- crates/primitives/src/db/components/state.rs | 30 +-- crates/primitives/src/env.rs | 193 +++++++++++++++++- crates/primitives/src/precompile.rs | 16 +- crates/primitives/src/state.rs | 16 +- crates/revm/benches/bench.rs | 2 +- crates/revm/src/context.rs | 26 +-- crates/revm/src/context/evm_context.rs | 40 ++-- crates/revm/src/context/inner_evm_context.rs | 46 +++-- crates/revm/src/db/emptydb.rs | 22 +- crates/revm/src/db/ethersdb.rs | 30 +-- crates/revm/src/db/in_memory_db.rs | 64 +++--- crates/revm/src/db/states/bundle_state.rs | 82 ++++---- crates/revm/src/db/states/cache.rs | 15 +- crates/revm/src/db/states/changes.rs | 12 +- crates/revm/src/db/states/reverts.rs | 7 +- crates/revm/src/db/states/state.rs | 53 ++--- crates/revm/src/db/states/transition_state.rs | 7 +- crates/revm/src/evm.rs | 12 +- crates/revm/src/handler/handle_types.rs | 2 +- .../revm/src/handler/handle_types/generic.rs | 7 + .../src/handler/handle_types/pre_execution.rs | 8 +- crates/revm/src/handler/mainnet/execution.rs | 6 +- .../revm/src/handler/mainnet/pre_execution.rs | 13 +- crates/revm/src/inspector.rs | 4 +- crates/revm/src/inspector/customprinter.rs | 11 +- crates/revm/src/inspector/gas.rs | 6 +- crates/revm/src/journaled_state.rs | 76 +++---- examples/fork_ref_transact.rs | 7 +- 45 files changed, 806 insertions(+), 407 deletions(-) create mode 100644 crates/precompile/src/xcalloptions.rs diff --git a/crates/interpreter/src/host.rs b/crates/interpreter/src/host.rs index 231b1a315c..5fa63f31df 100644 --- a/crates/interpreter/src/host.rs +++ b/crates/interpreter/src/host.rs @@ -3,6 +3,7 @@ use core::ops::{Deref, DerefMut}; mod dummy; pub use dummy::DummyHost; +use revm_primitives::ChainAddress; /// EVM context host. pub trait Host { @@ -13,38 +14,38 @@ pub trait Host { fn env_mut(&mut self) -> &mut Env; /// Load an account code. - fn load_account_delegated(&mut self, address: Address) -> Option; + fn load_account_delegated(&mut self, address: ChainAddress) -> Option; /// Get the block hash of the given block `number`. - fn block_hash(&mut self, number: u64) -> Option; + fn block_hash(&mut self, chain_id: u64, number: u64) -> Option; /// Get balance of `address` and if the account is cold. - fn balance(&mut self, address: Address) -> Option>; + fn balance(&mut self, address: ChainAddress) -> Option>; /// Get code of `address` and if the account is cold. - fn code(&mut self, address: Address) -> Option>; + fn code(&mut self, address: ChainAddress) -> Option>; /// Get code hash of `address` and if the account is cold. - fn code_hash(&mut self, address: Address) -> Option>; + fn code_hash(&mut self, address: ChainAddress) -> Option>; /// Get storage value of `address` at `index` and if the account is cold. - fn sload(&mut self, address: Address, index: U256) -> Option>; + fn sload(&mut self, address: ChainAddress, index: U256) -> Option>; /// Set storage value of account address at index. /// /// Returns [`StateLoad`] with [`SStoreResult`] that contains original/new/old storage value. fn sstore( &mut self, - address: Address, + address: ChainAddress, index: U256, value: U256, ) -> Option>; /// Get the transient storage value of `address` at `index`. - fn tload(&mut self, address: Address, index: U256) -> U256; + fn tload(&mut self, address: ChainAddress, index: U256) -> U256; /// Set the transient storage value of `address` at `index`. - fn tstore(&mut self, address: Address, index: U256, value: U256); + fn tstore(&mut self, address: ChainAddress, index: U256, value: U256); /// Emit a log owned by `address` with given `LogData`. fn log(&mut self, log: Log); @@ -52,8 +53,8 @@ pub trait Host { /// Mark `address` to be deleted, with funds transferred to `target`. fn selfdestruct( &mut self, - address: Address, - target: Address, + address: ChainAddress, + target: ChainAddress, ) -> Option>; } diff --git a/crates/interpreter/src/host/dummy.rs b/crates/interpreter/src/host/dummy.rs index 602fb512da..ac54cb85ca 100644 --- a/crates/interpreter/src/host/dummy.rs +++ b/crates/interpreter/src/host/dummy.rs @@ -3,6 +3,7 @@ use crate::{ Host, SStoreResult, SelfDestructResult, }; use std::vec::Vec; +use revm_primitives::ChainAddress; use super::{AccountLoad, Eip7702CodeLoad, StateLoad}; @@ -45,32 +46,32 @@ impl Host for DummyHost { } #[inline] - fn load_account_delegated(&mut self, _address: Address) -> Option { + fn load_account_delegated(&mut self, _address: ChainAddress) -> Option { Some(AccountLoad::default()) } #[inline] - fn block_hash(&mut self, _number: u64) -> Option { + fn block_hash(&mut self, _chain_id: u64, _number: u64) -> Option { Some(B256::ZERO) } #[inline] - fn balance(&mut self, _address: Address) -> Option> { + fn balance(&mut self, _address: ChainAddress) -> Option> { Some(Default::default()) } #[inline] - fn code(&mut self, _address: Address) -> Option> { + fn code(&mut self, _address: ChainAddress) -> Option> { Some(Default::default()) } #[inline] - fn code_hash(&mut self, _address: Address) -> Option> { + fn code_hash(&mut self, _address: ChainAddress) -> Option> { Some(Eip7702CodeLoad::new_not_delegated(KECCAK_EMPTY, false)) } #[inline] - fn sload(&mut self, _address: Address, index: U256) -> Option> { + fn sload(&mut self, _address: ChainAddress, index: U256) -> Option> { match self.storage.entry(index) { Entry::Occupied(entry) => Some(StateLoad::new(*entry.get(), false)), Entry::Vacant(entry) => { @@ -83,7 +84,7 @@ impl Host for DummyHost { #[inline] fn sstore( &mut self, - _address: Address, + _address: ChainAddress, index: U256, value: U256, ) -> Option> { @@ -99,7 +100,7 @@ impl Host for DummyHost { } #[inline] - fn tload(&mut self, _address: Address, index: U256) -> U256 { + fn tload(&mut self, _address: ChainAddress, index: U256) -> U256 { self.transient_storage .get(&index) .copied() @@ -107,7 +108,7 @@ impl Host for DummyHost { } #[inline] - fn tstore(&mut self, _address: Address, index: U256, value: U256) { + fn tstore(&mut self, _address: ChainAddress, index: U256, value: U256) { self.transient_storage.insert(index, value); } @@ -119,8 +120,8 @@ impl Host for DummyHost { #[inline] fn selfdestruct( &mut self, - _address: Address, - _target: Address, + _address: ChainAddress, + _target: ChainAddress, ) -> Option> { Some(StateLoad::default()) } diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index 281e147582..771d609fc4 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -1,6 +1,7 @@ mod call_helpers; pub use call_helpers::{calc_call_gas, get_memory_input_and_out_ranges, resize_memory}; +use revm_primitives::{CallOptions, ChainAddress}; use crate::{ gas::{self, cost_per_word, EOF_CREATE_GAS, KECCAK256WORD, MIN_CALLEE_GAS}, @@ -14,6 +15,21 @@ use crate::{ use core::cmp::max; use std::boxed::Box; +pub struct CallTargets { + /// The account address of bytecode that is going to be executed. + /// + /// Previously `context.code_address`. + pub bytecode_address: ChainAddress, + /// Target address, this account storage is going to be modified. + /// + /// Previously `context.address`. + pub target_address: ChainAddress, + /// This caller is invoking the call. + /// + /// Previously `context.caller`. + pub caller: ChainAddress, +} + /// EOF Create instruction pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) { require_eof!(interpreter); @@ -62,7 +78,7 @@ pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) let created_address = interpreter .contract .target_address - .create2(salt.to_be_bytes(), keccak256(sub_container)); + .1.create2(salt.to_be_bytes(), keccak256(sub_container)); let gas_limit = interpreter.gas().remaining_63_of_64_parts(); gas!(interpreter, gas_limit); @@ -71,7 +87,7 @@ pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) interpreter.next_action = InterpreterAction::EOFCreate { inputs: Box::new(EOFCreateInputs::new_opcode( interpreter.contract.target_address, - created_address, + ChainAddress(interpreter.chain_id, created_address), value, eof, gas_limit, @@ -163,7 +179,7 @@ pub fn extcall_input(interpreter: &mut Interpreter) -> Option { pub fn extcall_gas_calc( interpreter: &mut Interpreter, host: &mut H, - target: Address, + target: ChainAddress, transfers_value: bool, ) -> Option { let Some(account_load) = host.load_account_delegated(target) else { @@ -201,7 +217,7 @@ pub fn extcall_gas_calc( /// /// Valid address has first 12 bytes as zeroes. #[inline] -pub fn pop_extcall_target_address(interpreter: &mut Interpreter) -> Option
{ +pub fn pop_extcall_target_address(interpreter: &mut Interpreter) -> Option { pop_ret!(interpreter, target_address, None); let target_address = B256::from(target_address); // Check if target is left padded with zeroes. @@ -210,7 +226,7 @@ pub fn pop_extcall_target_address(interpreter: &mut Interpreter) -> Option(interpreter: &mut Interpreter, host: &mut H) { @@ -398,6 +414,10 @@ pub fn create( pub fn call(interpreter: &mut Interpreter, host: &mut H) { pop!(interpreter, local_gas_limit); pop_address!(interpreter, to); + + // Get the target + let call_targets = apply_call_options::(interpreter, host, to, false, false); + // max gas limit is not possible in real ethereum situation. let local_gas_limit = u64::try_from(local_gas_limit).unwrap_or(u64::MAX); @@ -412,7 +432,7 @@ pub fn call(interpreter: &mut Interpreter, host: & return; }; - let Some(account_load) = host.load_account_delegated(to) else { + let Some(account_load) = host.load_account_delegated(call_targets.bytecode_address) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; }; @@ -434,9 +454,9 @@ pub fn call(interpreter: &mut Interpreter, host: & inputs: Box::new(CallInputs { input, gas_limit, - target_address: to, - caller: interpreter.contract.target_address, - bytecode_address: to, + target_address: call_targets.target_address, + caller: call_targets.caller, + bytecode_address: call_targets.bytecode_address, value: CallValue::Transfer(value), scheme: CallScheme::Call, is_static: interpreter.is_static, @@ -450,6 +470,10 @@ pub fn call(interpreter: &mut Interpreter, host: & pub fn call_code(interpreter: &mut Interpreter, host: &mut H) { pop!(interpreter, local_gas_limit); pop_address!(interpreter, to); + + // Get the target + let call_targets = apply_call_options::(interpreter, host, to, false, true); + // max gas limit is not possible in real ethereum situation. let local_gas_limit = u64::try_from(local_gas_limit).unwrap_or(u64::MAX); @@ -458,7 +482,7 @@ pub fn call_code(interpreter: &mut Interpreter, ho return; }; - let Some(mut load) = host.load_account_delegated(to) else { + let Some(mut load) = host.load_account_delegated(call_targets.bytecode_address) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; }; @@ -482,9 +506,9 @@ pub fn call_code(interpreter: &mut Interpreter, ho inputs: Box::new(CallInputs { input, gas_limit, - target_address: interpreter.contract.target_address, - caller: interpreter.contract.target_address, - bytecode_address: to, + target_address: call_targets.target_address, + caller: call_targets.caller, + bytecode_address: call_targets.bytecode_address, value: CallValue::Transfer(value), scheme: CallScheme::CallCode, is_static: interpreter.is_static, @@ -499,6 +523,10 @@ pub fn delegate_call(interpreter: &mut Interpreter check!(interpreter, HOMESTEAD); pop!(interpreter, local_gas_limit); pop_address!(interpreter, to); + + // Get the target + let call_targets = apply_call_options::(interpreter, host, to, true, false); + // max gas limit is not possible in real ethereum situation. let local_gas_limit = u64::try_from(local_gas_limit).unwrap_or(u64::MAX); @@ -506,7 +534,7 @@ pub fn delegate_call(interpreter: &mut Interpreter return; }; - let Some(mut load) = host.load_account_delegated(to) else { + let Some(mut load) = host.load_account_delegated(call_targets.bytecode_address) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; }; @@ -523,9 +551,9 @@ pub fn delegate_call(interpreter: &mut Interpreter inputs: Box::new(CallInputs { input, gas_limit, - target_address: interpreter.contract.target_address, - caller: interpreter.contract.caller, - bytecode_address: to, + target_address: call_targets.target_address, + caller: call_targets.caller, + bytecode_address: call_targets.bytecode_address, value: CallValue::Apparent(interpreter.contract.call_value), scheme: CallScheme::DelegateCall, is_static: interpreter.is_static, @@ -540,6 +568,10 @@ pub fn static_call(interpreter: &mut Interpreter, check!(interpreter, BYZANTIUM); pop!(interpreter, local_gas_limit); pop_address!(interpreter, to); + + // Get the target + let call_targets = apply_call_options::(interpreter, host, to, false, false); + // max gas limit is not possible in real ethereum situation. let local_gas_limit = u64::try_from(local_gas_limit).unwrap_or(u64::MAX); @@ -547,7 +579,7 @@ pub fn static_call(interpreter: &mut Interpreter, return; }; - let Some(mut load) = host.load_account_delegated(to) else { + let Some(mut load) = host.load_account_delegated(call_targets.bytecode_address) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; }; @@ -563,9 +595,9 @@ pub fn static_call(interpreter: &mut Interpreter, inputs: Box::new(CallInputs { input, gas_limit, - target_address: to, - caller: interpreter.contract.target_address, - bytecode_address: to, + target_address: call_targets.target_address, + caller: call_targets.caller, + bytecode_address: call_targets.bytecode_address, value: CallValue::Transfer(U256::ZERO), scheme: CallScheme::StaticCall, is_static: true, @@ -575,3 +607,27 @@ pub fn static_call(interpreter: &mut Interpreter, }; interpreter.instruction_result = InstructionResult::CallOrCreate; } + +pub fn apply_call_options(interpreter: &mut Interpreter, host: &mut H, to: Address, delegate: bool, code: bool) -> CallTargets { + let call_options = interpreter.call_options.clone().unwrap_or_else(|| + CallOptions{ + chain_id: interpreter.chain_id, + sandbox: false, + tx_origin: host.env().tx.caller, + msg_sender: interpreter.contract.target_address, + block_hash: None, + proof: Vec::new(), + } + ); + // Consume the values + interpreter.call_options = None; + + // Set the specified chain id on the to address + let to = ChainAddress(call_options.chain_id, to); + + CallTargets { + target_address: if delegate || code { interpreter.contract.target_address } else { to }, + caller: if code { interpreter.contract.caller } else { interpreter.contract.target_address }, + bytecode_address: to, + } +} \ No newline at end of file diff --git a/crates/interpreter/src/instructions/host.rs b/crates/interpreter/src/instructions/host.rs index 612cbac5c1..fed85d8954 100644 --- a/crates/interpreter/src/instructions/host.rs +++ b/crates/interpreter/src/instructions/host.rs @@ -8,7 +8,7 @@ use core::cmp::min; use std::vec::Vec; pub fn balance(interpreter: &mut Interpreter, host: &mut H) { - pop_address!(interpreter, address); + pop_chain_address!(interpreter, address); let Some(balance) = host.balance(address) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; @@ -41,7 +41,7 @@ pub fn selfbalance(interpreter: &mut Interpreter, } pub fn extcodesize(interpreter: &mut Interpreter, host: &mut H) { - pop_address!(interpreter, address); + pop_chain_address!(interpreter, address); let Some(code) = host.code(address) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; @@ -61,7 +61,7 @@ pub fn extcodesize(interpreter: &mut Interpreter, /// EIP-1052: EXTCODEHASH opcode pub fn extcodehash(interpreter: &mut Interpreter, host: &mut H) { check!(interpreter, CONSTANTINOPLE); - pop_address!(interpreter, address); + pop_chain_address!(interpreter, address); let Some(code_hash) = host.code_hash(address) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; @@ -78,7 +78,7 @@ pub fn extcodehash(interpreter: &mut Interpreter, } pub fn extcodecopy(interpreter: &mut Interpreter, host: &mut H) { - pop_address!(interpreter, address); + pop_chain_address!(interpreter, address); pop!(interpreter, memory_offset, code_offset, len_u256); let Some(code) = host.code(address) else { @@ -110,7 +110,7 @@ pub fn blockhash(interpreter: &mut Interpreter, ho pop_top!(interpreter, number); let number_u64 = as_u64_saturated!(number); - let Some(hash) = host.block_hash(number_u64) else { + let Some(hash) = host.block_hash(interpreter.chain_id, number_u64) else { interpreter.instruction_result = InstructionResult::FatalExternalError; return; }; @@ -199,7 +199,7 @@ pub fn log(interpreter: &mut Interpreter, host } let log = Log { - address: interpreter.contract.target_address, + address: interpreter.contract.target_address.1, // Brecht data: LogData::new(topics, data).expect("LogData should have <=4 topics"), }; @@ -208,7 +208,7 @@ pub fn log(interpreter: &mut Interpreter, host pub fn selfdestruct(interpreter: &mut Interpreter, host: &mut H) { require_non_staticcall!(interpreter); - pop_address!(interpreter, target); + pop_chain_address!(interpreter, target); let Some(res) = host.selfdestruct(interpreter.contract.target_address, target) else { interpreter.instruction_result = InstructionResult::FatalExternalError; diff --git a/crates/interpreter/src/instructions/host_env.rs b/crates/interpreter/src/instructions/host_env.rs index ce934d492f..8994ad5858 100644 --- a/crates/interpreter/src/instructions/host_env.rs +++ b/crates/interpreter/src/instructions/host_env.rs @@ -13,7 +13,7 @@ pub fn chainid(interpreter: &mut Interpreter, host pub fn coinbase(interpreter: &mut Interpreter, host: &mut H) { gas!(interpreter, gas::BASE); - push_b256!(interpreter, host.env().block.coinbase.into_word()); + push_b256!(interpreter, host.env().block.coinbase.1.into_word()); } pub fn timestamp(interpreter: &mut Interpreter, host: &mut H) { @@ -54,7 +54,7 @@ pub fn basefee(interpreter: &mut Interpreter, host pub fn origin(interpreter: &mut Interpreter, host: &mut H) { gas!(interpreter, gas::BASE); - push_b256!(interpreter, host.env().tx.caller.into_word()); + push_b256!(interpreter, host.env().tx.caller.1.into_word()); } // EIP-4844: Shard Blob Transactions diff --git a/crates/interpreter/src/instructions/macros.rs b/crates/interpreter/src/instructions/macros.rs index 4df6f62d1a..39389a76f3 100644 --- a/crates/interpreter/src/instructions/macros.rs +++ b/crates/interpreter/src/instructions/macros.rs @@ -151,6 +151,21 @@ macro_rules! pop_address_ret { }; } +/// Pops `U256` values from the stack. Fails the instruction if the stack is too small. +#[macro_export] +macro_rules! pop_chain_address { + ($interp:expr, $x1:ident) => { + pop_address!($interp, $x1); + let $x1 = $crate::primitives::ChainAddress($interp.chain_id, $x1); + }; + ($interp:expr, $x1:ident, $x2:ident) => { + pop_address!($interp, $x1, $x2); + let $x1 = ChainAddress($interp.chain_id, $x1); + let $x2 = ChainAddress($interp.chain_id, $x2); + }; +} + + /// Pops `U256` values from the stack. Fails the instruction if the stack is too small. #[macro_export] macro_rules! pop { diff --git a/crates/interpreter/src/instructions/system.rs b/crates/interpreter/src/instructions/system.rs index 3605a53705..d68991500a 100644 --- a/crates/interpreter/src/instructions/system.rs +++ b/crates/interpreter/src/instructions/system.rs @@ -21,12 +21,12 @@ pub fn keccak256(interpreter: &mut Interpreter, _host: &mut H) pub fn address(interpreter: &mut Interpreter, _host: &mut H) { gas!(interpreter, gas::BASE); - push_b256!(interpreter, interpreter.contract.target_address.into_word()); + push_b256!(interpreter, interpreter.contract.target_address.1.into_word()); } pub fn caller(interpreter: &mut Interpreter, _host: &mut H) { gas!(interpreter, gas::BASE); - push_b256!(interpreter, interpreter.contract.caller.into_word()); + push_b256!(interpreter, interpreter.contract.caller.1.into_word()); } pub fn codesize(interpreter: &mut Interpreter, _host: &mut H) { diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index ea1389e7fe..212f659b3f 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -14,7 +14,7 @@ use crate::{ FunctionStack, Gas, Host, InstructionResult, InterpreterAction, }; use core::cmp::min; -use revm_primitives::{Bytecode, Eof, U256}; +use revm_primitives::{Bytecode, CallOptions, Eof, U256}; use std::borrow::ToOwned; use std::sync::Arc; @@ -60,17 +60,23 @@ pub struct Interpreter { /// Set inside CALL or CREATE instructions and RETURN or REVERT instructions. Additionally those instructions will set /// InstructionResult to CallOrCreate/Return/Revert so we know the reason. pub next_action: InterpreterAction, + /// Booster: chain storage to use + pub chain_id: u64, + /// Booster: call options set using XCALLOPTIONS + pub call_options: Option, + /// Booster: when running sandboxed, always revert the state changes done inside the call + pub is_sandboxed: bool, } impl Default for Interpreter { fn default() -> Self { - Self::new(Contract::default(), u64::MAX, false) + Self::new(Contract::default(), u64::MAX, false, 0, false) } } impl Interpreter { /// Create new interpreter - pub fn new(contract: Contract, gas_limit: u64, is_static: bool) -> Self { + pub fn new(contract: Contract, gas_limit: u64, is_static: bool, chain_id: u64, sandboxed: bool) -> Self { if !contract.bytecode.is_execution_ready() { panic!("Contract is not execution ready {:?}", contract.bytecode); } @@ -90,6 +96,9 @@ impl Interpreter { shared_memory: EMPTY_SHARED_MEMORY, stack: Stack::new(), next_action: InterpreterAction::None, + chain_id, + call_options: None, + is_sandboxed: sandboxed, } } diff --git a/crates/interpreter/src/interpreter/contract.rs b/crates/interpreter/src/interpreter/contract.rs index 304b700446..945dc4e23a 100644 --- a/crates/interpreter/src/interpreter/contract.rs +++ b/crates/interpreter/src/interpreter/contract.rs @@ -1,4 +1,4 @@ -use revm_primitives::TxKind; +use revm_primitives::{ChainAddress, TransactTo, TxKind}; use super::analysis::to_analysed; use crate::{ @@ -18,12 +18,12 @@ pub struct Contract { /// Bytecode hash for legacy. For EOF this would be None. pub hash: Option, /// Target address of the account. Storage of this address is going to be modified. - pub target_address: Address, + pub target_address: ChainAddress, /// Address of the account the bytecode was loaded from. This can be different from target_address /// in the case of DELEGATECALL or CALLCODE - pub bytecode_address: Option
, + pub bytecode_address: Option, /// Caller of the EVM. - pub caller: Address, + pub caller: ChainAddress, /// Value send to contract from transaction or from CALL opcodes. pub call_value: U256, } @@ -35,9 +35,9 @@ impl Contract { input: Bytes, bytecode: Bytecode, hash: Option, - target_address: Address, - bytecode_address: Option
, - caller: Address, + target_address: ChainAddress, + bytecode_address: Option, + caller: ChainAddress, call_value: U256, ) -> Self { let bytecode = to_analysed(bytecode); @@ -57,12 +57,12 @@ impl Contract { #[inline] pub fn new_env(env: &Env, bytecode: Bytecode, hash: Option) -> Self { let contract_address = match env.tx.transact_to { - TxKind::Call(caller) => caller, - TxKind::Create => Address::ZERO, + TransactTo::Call(caller) => caller, + TransactTo::Create => ChainAddress(0, Address::ZERO), }; let bytecode_address = match env.tx.transact_to { - TxKind::Call(caller) => Some(caller), - TxKind::Create => None, + TransactTo::Call(caller) => Some(caller), + TransactTo::Create => None, }; Self::new( env.tx.data.clone(), diff --git a/crates/interpreter/src/interpreter_action/call_inputs.rs b/crates/interpreter/src/interpreter_action/call_inputs.rs index bc51ceac8d..ad340785c9 100644 --- a/crates/interpreter/src/interpreter_action/call_inputs.rs +++ b/crates/interpreter/src/interpreter_action/call_inputs.rs @@ -1,3 +1,5 @@ +use revm_primitives::{ChainAddress, TransactTo}; + use crate::primitives::{Address, Bytes, TxEnv, TxKind, U256}; use core::ops::Range; use std::boxed::Box; @@ -17,15 +19,15 @@ pub struct CallInputs { /// The account address of bytecode that is going to be executed. /// /// Previously `context.code_address`. - pub bytecode_address: Address, + pub bytecode_address: ChainAddress, /// Target address, this account storage is going to be modified. /// /// Previously `context.address`. - pub target_address: Address, + pub target_address: ChainAddress, /// This caller is invoking the call. /// /// Previously `context.caller`. - pub caller: Address, + pub caller: ChainAddress, /// Call value. /// /// NOTE: This value may not necessarily be transferred from caller to callee, see [`CallValue`]. @@ -40,6 +42,8 @@ pub struct CallInputs { pub is_static: bool, /// Whether the call is initiated from EOF bytecode. pub is_eof: bool, + // Booster: Whether this is a sandboxed call. + //pub is_sandboxed: bool, } impl CallInputs { @@ -47,7 +51,7 @@ impl CallInputs { /// /// Returns `None` if the transaction is not a call. pub fn new(tx_env: &TxEnv, gas_limit: u64) -> Option { - let TxKind::Call(target_address) = tx_env.transact_to else { + let TransactTo::Call(target_address) = tx_env.transact_to else { return None; }; Some(CallInputs { @@ -61,6 +65,7 @@ impl CallInputs { is_static: false, is_eof: false, return_memory_offset: 0..0, + //is_sandboxed: false, }) } @@ -97,7 +102,7 @@ impl CallInputs { /// /// This is only meaningful if `transfers_value` is `true`. #[inline] - pub const fn transfer_from(&self) -> Address { + pub const fn transfer_from(&self) -> ChainAddress { self.caller } @@ -105,7 +110,7 @@ impl CallInputs { /// /// This is only meaningful if `transfers_value` is `true`. #[inline] - pub const fn transfer_to(&self) -> Address { + pub const fn transfer_to(&self) -> ChainAddress { self.target_address } diff --git a/crates/interpreter/src/interpreter_action/create_inputs.rs b/crates/interpreter/src/interpreter_action/create_inputs.rs index adae96ac2d..c660f8f0fe 100644 --- a/crates/interpreter/src/interpreter_action/create_inputs.rs +++ b/crates/interpreter/src/interpreter_action/create_inputs.rs @@ -1,3 +1,5 @@ +use revm_primitives::{ChainAddress, TransactTo}; + pub use crate::primitives::CreateScheme; use crate::primitives::{Address, Bytes, TxEnv, TxKind, U256}; use std::boxed::Box; @@ -7,7 +9,7 @@ use std::boxed::Box; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateInputs { /// Caller address of the EVM. - pub caller: Address, + pub caller: ChainAddress, /// The create scheme. pub scheme: CreateScheme, /// The value to transfer. @@ -21,7 +23,7 @@ pub struct CreateInputs { impl CreateInputs { /// Creates new create inputs. pub fn new(tx_env: &TxEnv, gas_limit: u64) -> Option { - let TxKind::Create = tx_env.transact_to else { + let TransactTo::Create = tx_env.transact_to else { return None; }; @@ -42,10 +44,33 @@ impl CreateInputs { /// Returns the address that this create call will create. pub fn created_address(&self, nonce: u64) -> Address { match self.scheme { - CreateScheme::Create => self.caller.create(nonce), + CreateScheme::Create => self.caller.1.create(nonce), // TODO: Brecht CreateScheme::Create2 { salt } => self .caller + .1 // TODO: Brecht .create2_from_code(salt.to_be_bytes(), &self.init_code), } } + + // TODO: Brecht + // Returns the address that this create call will create, without calculating the init code hash. + // + // Note: `hash` must be `keccak256(&self.init_code)`. + /*pub fn created_address_with_hash(&self, nonce: u64, hash: &B256) -> Address { + match self.scheme { + CreateScheme::Create => self.create(nonce), + CreateScheme::Create2 { salt } => self.caller.1.create2(salt.to_be_bytes(), hash), + } + } + + // Modified CREATE address on booster chains + fn create(&self, nonce: u64) -> Address { + // If we're not on L1, change the CREATE address to contain the chain_id + let chain_id = if self.caller.0 != 1 { + Some(self.caller.0) + } else { + None + }; + self.caller.1.create(nonce, chain_id) + }*/ } diff --git a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs index c5cafb3c87..ede8783d8f 100644 --- a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs +++ b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs @@ -1,3 +1,5 @@ +use revm_primitives::ChainAddress; + use crate::primitives::{Address, Bytes, Eof, TxEnv, U256}; /// EOF create can be called from two places: @@ -18,13 +20,13 @@ pub enum EOFCreateKind { Opcode { initcode: Eof, input: Bytes, - created_address: Address, + created_address: ChainAddress, }, } impl EOFCreateKind { /// Returns created address - pub fn created_address(&self) -> Option<&Address> { + pub fn created_address(&self) -> Option<&ChainAddress> { match self { EOFCreateKind::Opcode { created_address, .. @@ -39,7 +41,7 @@ impl Default for EOFCreateKind { EOFCreateKind::Opcode { initcode: Eof::default(), input: Bytes::default(), - created_address: Address::default(), + created_address: ChainAddress::default(), } } } @@ -49,7 +51,7 @@ impl Default for EOFCreateKind { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EOFCreateInputs { /// Caller of Eof Craate - pub caller: Address, + pub caller: ChainAddress, /// Values of ether transferred pub value: U256, /// Gas limit for the create call. @@ -62,7 +64,7 @@ impl EOFCreateInputs { /// Create new EOF crate input from transaction that has concatenated eof init code and calldata. /// /// Legacy transaction still have optional nonce so we need to obtain it. - pub fn new(caller: Address, value: U256, gas_limit: u64, kind: EOFCreateKind) -> Self { + pub fn new(caller: ChainAddress, value: U256, gas_limit: u64, kind: EOFCreateKind) -> Self { //let (eof_init_code, input) = Eof::decode_dangling(tx.data.clone())?; EOFCreateInputs { caller, @@ -86,8 +88,8 @@ impl EOFCreateInputs { /// Returns a new instance of EOFCreateInput. pub fn new_opcode( - caller: Address, - created_address: Address, + caller: ChainAddress, + created_address: ChainAddress, value: U256, eof_init_code: Eof, gas_limit: u64, diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 488983bcb1..7e872ce446 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -22,6 +22,7 @@ pub mod secp256k1; #[cfg(feature = "secp256r1")] pub mod secp256r1; pub mod utilities; +pub mod xcalloptions; pub use fatal_precompile::fatal_precompile; @@ -32,6 +33,7 @@ pub use primitives::{ precompile::{PrecompileError as Error, *}, Address, Bytes, HashMap, HashSet, Log, B256, }; +use revm_primitives::ChainAddress; #[doc(hidden)] pub use revm_primitives as primitives; @@ -129,6 +131,7 @@ impl Precompiles { precompiles.extend([ // EIP-2565: ModExp Gas Cost. modexp::BERLIN, + xcalloptions::XCALLOPTIONS, ]); Box::new(precompiles) }) diff --git a/crates/precompile/src/xcalloptions.rs b/crates/precompile/src/xcalloptions.rs new file mode 100644 index 0000000000..1912427f10 --- /dev/null +++ b/crates/precompile/src/xcalloptions.rs @@ -0,0 +1,41 @@ +use revm_primitives::{Address, Bytes, CallOptions, ChainAddress, Env, PrecompileOutput}; +use crate::{Error, Precompile, PrecompileResult, PrecompileWithAddress, CtxPrecompileFn}; + +pub const XCALLOPTIONS: PrecompileWithAddress = PrecompileWithAddress( + crate::u64_to_address(1000), + Precompile::Ctx(xcalloptions_run as CtxPrecompileFn), +); + +/// Sets the xcall options +fn xcalloptions_run(input: &[u8], _gas_limit: u64, _env: &Env, call_options: &mut Option) -> PrecompileResult { + // Verify input length. + if input.len() < 83 { + return Err(Error::XCallOptionsInvalidInputLength.into()); + } + + // Read the input data + let version = u16::from_le_bytes(input[0..2].try_into().unwrap()); + let chain_id = u64::from_le_bytes(input[2..10].try_into().unwrap()); + let sandbox = input[10] != 0; + let tx_origin = Address(input[11..31].try_into().unwrap()); + let msg_sender = Address(input[31..51].try_into().unwrap()); + let block_hash = Some(input[51..83].try_into().unwrap()); + let proof = &input[83..]; + + // Check the version + if version != 1 { + return Err(Error::XCallOptionsInvalidInputLength.into()); + } + + // Set the call options + *call_options = Some(CallOptions { + chain_id, + sandbox, + tx_origin: ChainAddress(chain_id, tx_origin), + msg_sender: ChainAddress(chain_id, msg_sender), + block_hash, + proof: proof.to_vec(), + }); + + Ok(PrecompileOutput::new(0, Bytes::default())) +} diff --git a/crates/primitives/src/db.rs b/crates/primitives/src/db.rs index d0dfc464af..8f102431f5 100644 --- a/crates/primitives/src/db.rs +++ b/crates/primitives/src/db.rs @@ -1,4 +1,4 @@ -use crate::{Account, AccountInfo, Address, Bytecode, HashMap, B256, U256}; +use crate::{Account, AccountInfo, ChainAddress, Bytecode, HashMap, B256, U256}; use auto_impl::auto_impl; pub mod components; @@ -13,23 +13,23 @@ pub trait Database { type Error; /// Get basic account information. - fn basic(&mut self, address: Address) -> Result, Self::Error>; + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error>; /// Get account code by its hash. - fn code_by_hash(&mut self, code_hash: B256) -> Result; + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result; /// Get storage value of address at index. - fn storage(&mut self, address: Address, index: U256) -> Result; + fn storage(&mut self, address: ChainAddress, index: U256) -> Result; /// Get block hash by block number. - fn block_hash(&mut self, number: u64) -> Result; + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result; } /// EVM database commit interface. #[auto_impl(&mut, Box)] pub trait DatabaseCommit { /// Commit changes to the database. - fn commit(&mut self, changes: HashMap); + fn commit(&mut self, changes: HashMap); } /// EVM database interface. @@ -44,16 +44,16 @@ pub trait DatabaseRef { type Error; /// Get basic account information. - fn basic_ref(&self, address: Address) -> Result, Self::Error>; + fn basic_ref(&self, address: ChainAddress) -> Result, Self::Error>; /// Get account code by its hash. - fn code_by_hash_ref(&self, code_hash: B256) -> Result; + fn code_by_hash_ref(&self, chain_id: u64, code_hash: B256) -> Result; /// Get storage value of address at index. - fn storage_ref(&self, address: Address, index: U256) -> Result; + fn storage_ref(&self, address: ChainAddress, index: U256) -> Result; /// Get block hash by block number. - fn block_hash_ref(&self, number: u64) -> Result; + fn block_hash_ref(&self, chain_id: u64, number: u64) -> Result; } /// Wraps a [`DatabaseRef`] to provide a [`Database`] implementation. @@ -71,29 +71,29 @@ impl Database for WrapDatabaseRef { type Error = T::Error; #[inline] - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { self.0.basic_ref(address) } #[inline] - fn code_by_hash(&mut self, code_hash: B256) -> Result { - self.0.code_by_hash_ref(code_hash) + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { + self.0.code_by_hash_ref(chain_id, code_hash) } #[inline] - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { self.0.storage_ref(address, index) } #[inline] - fn block_hash(&mut self, number: u64) -> Result { - self.0.block_hash_ref(number) + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { + self.0.block_hash_ref(chain_id, number) } } impl DatabaseCommit for WrapDatabaseRef { #[inline] - fn commit(&mut self, changes: HashMap) { + fn commit(&mut self, changes: HashMap) { self.0.commit(changes) } } diff --git a/crates/primitives/src/db/components.rs b/crates/primitives/src/db/components.rs index 5a2c5259f6..6afefc5e36 100644 --- a/crates/primitives/src/db/components.rs +++ b/crates/primitives/src/db/components.rs @@ -7,7 +7,7 @@ pub use state::{State, StateRef}; use crate::{ db::{Database, DatabaseRef}, - Account, AccountInfo, Address, Bytecode, HashMap, B256, U256, + Account, AccountInfo, Address, ChainAddress, Bytecode, HashMap, B256, U256, }; use super::DatabaseCommit; @@ -27,25 +27,25 @@ pub enum DatabaseComponentError { impl Database for DatabaseComponents { type Error = DatabaseComponentError; - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { self.state.basic(address).map_err(Self::Error::State) } - fn code_by_hash(&mut self, code_hash: B256) -> Result { + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { self.state - .code_by_hash(code_hash) + .code_by_hash(chain_id, code_hash) .map_err(Self::Error::State) } - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { self.state .storage(address, index) .map_err(Self::Error::State) } - fn block_hash(&mut self, number: u64) -> Result { + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { self.block_hash - .block_hash(number) + .block_hash(chain_id, number) .map_err(Self::Error::BlockHash) } } @@ -53,31 +53,31 @@ impl Database for DatabaseComponents { impl DatabaseRef for DatabaseComponents { type Error = DatabaseComponentError; - fn basic_ref(&self, address: Address) -> Result, Self::Error> { + fn basic_ref(&self, address: ChainAddress) -> Result, Self::Error> { self.state.basic(address).map_err(Self::Error::State) } - fn code_by_hash_ref(&self, code_hash: B256) -> Result { + fn code_by_hash_ref(&self, chain_id: u64, code_hash: B256) -> Result { self.state - .code_by_hash(code_hash) + .code_by_hash(chain_id, code_hash) .map_err(Self::Error::State) } - fn storage_ref(&self, address: Address, index: U256) -> Result { + fn storage_ref(&self, address: ChainAddress, index: U256) -> Result { self.state .storage(address, index) .map_err(Self::Error::State) } - fn block_hash_ref(&self, number: u64) -> Result { + fn block_hash_ref(&self, chain_id: u64, number: u64) -> Result { self.block_hash - .block_hash(number) + .block_hash(chain_id, number) .map_err(Self::Error::BlockHash) } } impl DatabaseCommit for DatabaseComponents { - fn commit(&mut self, changes: HashMap) { + fn commit(&mut self, changes: HashMap) { self.state.commit(changes); } } diff --git a/crates/primitives/src/db/components/block_hash.rs b/crates/primitives/src/db/components/block_hash.rs index 8093f278ec..40c598903f 100644 --- a/crates/primitives/src/db/components/block_hash.rs +++ b/crates/primitives/src/db/components/block_hash.rs @@ -11,7 +11,7 @@ pub trait BlockHash { type Error; /// Get block hash by block number - fn block_hash(&mut self, number: u64) -> Result; + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result; } #[auto_impl(&, &mut, Box, Rc, Arc)] @@ -19,7 +19,7 @@ pub trait BlockHashRef { type Error; /// Get block hash by block number - fn block_hash(&self, number: u64) -> Result; + fn block_hash(&self, chain_id: u64, number: u64) -> Result; } impl BlockHash for &T @@ -28,8 +28,8 @@ where { type Error = ::Error; - fn block_hash(&mut self, number: u64) -> Result { - BlockHashRef::block_hash(*self, number) + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { + BlockHashRef::block_hash(*self, chain_id, number) } } @@ -39,7 +39,7 @@ where { type Error = ::Error; - fn block_hash(&mut self, number: u64) -> Result { - self.deref().block_hash(number) + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { + self.deref().block_hash(chain_id, number) } } diff --git a/crates/primitives/src/db/components/state.rs b/crates/primitives/src/db/components/state.rs index d3b948ddaa..8f76f07bf7 100644 --- a/crates/primitives/src/db/components/state.rs +++ b/crates/primitives/src/db/components/state.rs @@ -1,7 +1,7 @@ //! State database component from [`crate::db::Database`] //! it is used inside [`crate::db::DatabaseComponents`] -use crate::{AccountInfo, Address, Bytecode, B256, U256}; +use crate::{AccountInfo, ChainAddress, Bytecode, B256, U256}; use auto_impl::auto_impl; use core::ops::Deref; use std::sync::Arc; @@ -11,13 +11,13 @@ pub trait State { type Error; /// Get basic account information. - fn basic(&mut self, address: Address) -> Result, Self::Error>; + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error>; /// Get account code by its hash - fn code_by_hash(&mut self, code_hash: B256) -> Result; + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result; /// Get storage value of address at index. - fn storage(&mut self, address: Address, index: U256) -> Result; + fn storage(&mut self, address: ChainAddress, index: U256) -> Result; } #[auto_impl(&, &mut, Box, Rc, Arc)] @@ -25,13 +25,13 @@ pub trait StateRef { type Error; /// Get basic account information. - fn basic(&self, address: Address) -> Result, Self::Error>; + fn basic(&self, address: ChainAddress) -> Result, Self::Error>; /// Get account code by its hash - fn code_by_hash(&self, code_hash: B256) -> Result; + fn code_by_hash(&self, chain_id: u64, code_hash: B256) -> Result; /// Get storage value of address at index. - fn storage(&self, address: Address, index: U256) -> Result; + fn storage(&self, address: ChainAddress, index: U256) -> Result; } impl State for &T @@ -40,15 +40,15 @@ where { type Error = ::Error; - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { StateRef::basic(*self, address) } - fn code_by_hash(&mut self, code_hash: B256) -> Result { - StateRef::code_by_hash(*self, code_hash) + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { + StateRef::code_by_hash(*self, chain_id, code_hash) } - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { StateRef::storage(*self, address, index) } } @@ -59,15 +59,15 @@ where { type Error = ::Error; - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { self.deref().basic(address) } - fn code_by_hash(&mut self, code_hash: B256) -> Result { - self.deref().code_by_hash(code_hash) + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { + self.deref().code_by_hash(chain_id, code_hash) } - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { self.deref().storage(address, index) } } diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index ed6bc1b141..f64aefe902 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -5,7 +5,7 @@ pub use handler_cfg::{CfgEnvWithHandlerCfg, EnvWithHandlerCfg, HandlerCfg}; use crate::{ calc_blob_gasprice, AccessListItem, Account, Address, AuthorizationList, Bytes, InvalidHeader, InvalidTransaction, Spec, SpecId, B256, GAS_PER_BLOB, MAX_BLOB_NUMBER_PER_BLOCK, MAX_CODE_SIZE, - MAX_INITCODE_SIZE, U256, VERSIONED_HASH_VERSION_KZG, + MAX_INITCODE_SIZE, U256, VERSIONED_HASH_VERSION_KZG, ChainAddress, }; use alloy_primitives::TxKind; use core::cmp::{min, Ordering}; @@ -335,6 +335,8 @@ pub struct CfgEnv { /// By default, it is set to `false`. #[cfg(feature = "optional_beneficiary_reward")] pub disable_beneficiary_reward: bool, + /// Chain ID of the parent chain, `0` for no parent chain + pub parent_chain_id: u64, } impl CfgEnv { @@ -414,6 +416,7 @@ impl Default for CfgEnv { fn default() -> Self { Self { chain_id: 1, + parent_chain_id: 1, perf_analyse_created_bytecodes: AnalysisKind::default(), limit_contract_code_size: None, #[cfg(any(feature = "c-kzg", feature = "kzg-rs"))] @@ -445,7 +448,7 @@ pub struct BlockEnv { /// Coinbase or miner or address that created and signed the block. /// /// This is the receiver address of all the gas spent in the block. - pub coinbase: Address, + pub coinbase: ChainAddress, /// The timestamp of the block in seconds since the UNIX epoch. pub timestamp: U256, @@ -518,7 +521,7 @@ impl Default for BlockEnv { fn default() -> Self { Self { number: U256::ZERO, - coinbase: Address::ZERO, + coinbase: ChainAddress::default(), timestamp: U256::from(1), gas_limit: U256::MAX, basefee: U256::ZERO, @@ -534,13 +537,13 @@ impl Default for BlockEnv { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TxEnv { /// Caller aka Author aka transaction signer. - pub caller: Address, + pub caller: ChainAddress, /// The gas limit of the transaction. pub gas_limit: u64, /// The gas price of the transaction. pub gas_price: U256, /// The destination of the transaction. - pub transact_to: TxKind, + pub transact_to: TransactTo, /// The value sent to `transact_to`. pub value: U256, /// The data of the transaction. @@ -627,11 +630,12 @@ impl TxEnv { impl Default for TxEnv { fn default() -> Self { Self { - caller: Address::ZERO, + caller: ChainAddress::default(), gas_limit: u64::MAX, gas_price: U256::ZERO, gas_priority_fee: None, - transact_to: TxKind::Call(Address::ZERO), // will do nothing + // TODO: Brecht + transact_to: TransactTo::Call(ChainAddress(0, Address::ZERO)), // will do nothing value: U256::ZERO, data: Bytes::new(), chain_id: None, @@ -705,8 +709,165 @@ pub struct OptimismFields { pub enveloped_tx: Option, } +// TODO: Brecht /// Transaction destination -pub type TransactTo = TxKind; +//pub type TransactTo = TxKind; + + +#[cfg(feature = "rlp")] +use alloy_rlp::{Buf, BufMut, Decodable, Encodable, EMPTY_STRING_CODE}; + +/// The `to` field of a transaction. Either a target address, or empty for a +/// contract creation. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "arbitrary", derive(derive_arbitrary::Arbitrary, proptest_derive::Arbitrary))] +pub enum TransactTo { + /// A transaction that creates a contract. + #[default] + Create, + /// A transaction that calls a contract or transfer. + Call(ChainAddress), +} + +impl From> for TransactTo { + /// Creates a `TransactTo::Call` with the `Some` address, `None` otherwise. + #[inline] + fn from(value: Option) -> Self { + match value { + None => Self::Create, + Some(addr) => Self::Call(addr), + } + } +} + +impl From for TransactTo { + /// Creates a `TxKind::Call` with the given address. + #[inline] + fn from(value: ChainAddress) -> Self { + Self::Call(value) + } +} + +impl TransactTo { + /// Returns the address of the contract that will be called or will receive the transfer. + pub const fn to(&self) -> Option<&ChainAddress> { + match self { + Self::Create => None, + Self::Call(to) => Some(to), + } + } + + /// Returns true if the transaction is a contract creation. + #[inline] + pub const fn is_create(&self) -> bool { + matches!(self, Self::Create) + } + + /// Returns true if the transaction is a contract call. + #[inline] + pub const fn is_call(&self) -> bool { + matches!(self, Self::Call(_)) + } + + /// Calculates a heuristic for the in-memory size of this object. + #[inline] + pub const fn size(&self) -> usize { + core::mem::size_of::() + } +} + +#[cfg(feature = "rlp")] +impl Encodable for TxKind { + fn encode(&self, out: &mut dyn BufMut) { + match self { + Self::Call(to) => to.encode(out), + Self::Create => out.put_u8(EMPTY_STRING_CODE), + } + } + + fn length(&self) -> usize { + match self { + Self::Call(to) => to.length(), + Self::Create => 1, // EMPTY_STRING_CODE is a single byte + } + } +} + +#[cfg(feature = "rlp")] +impl Decodable for TxKind { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + if let Some(&first) = buf.first() { + if first == EMPTY_STRING_CODE { + buf.advance(1); + Ok(Self::Create) + } else { + let addr =
::decode(buf)?; + Ok(Self::Call(addr)) + } + } else { + Err(alloy_rlp::Error::InputTooShort) + } + } +} + +#[cfg(feature = "serde")] +impl serde::Serialize for TransactTo { + fn serialize(&self, serializer: S) -> Result { + self.to().serialize(serializer) + } +} + +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TransactTo { + fn deserialize>(deserializer: D) -> Result { + Ok(Option::::deserialize(deserializer)?.into()) + } +} + + +/* +/// Transaction destination. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum TransactTo { + /// Simple call to an address. + Call(ChainAddress), + /// Contract creation. + Create(CreateScheme), +} + +impl TransactTo { + /// Calls the given address. + #[inline] + pub fn call(address: ChainAddress) -> Self { + Self::Call(address) + } + + /// Creates a contract. + #[inline] + pub fn create() -> Self { + Self::Create(CreateScheme::Create) + } + + /// Creates a contract with the given salt using `CREATE2`. + #[inline] + pub fn create2(salt: U256) -> Self { + Self::Create(CreateScheme::Create2 { salt }) + } + + /// Returns `true` if the transaction is `Call`. + #[inline] + pub fn is_call(&self) -> bool { + matches!(self, Self::Call(_)) + } + + /// Returns `true` if the transaction is `Create` or `Create2`. + #[inline] + pub fn is_create(&self) -> bool { + matches!(self, Self::Create(_)) + } +} +*/ /// Create scheme. #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] @@ -732,6 +893,22 @@ pub enum AnalysisKind { Analyse, } +#[derive(Clone, Debug)] +pub struct CallOptions { + /// The target chain id + pub chain_id: u64, + /// If the call needs to persist state changes or not + pub sandbox: bool, + /// Mocked `tx.origin` + pub tx_origin: ChainAddress, + /// Mocked `msg.sender` + pub msg_sender: ChainAddress, + /// The block hash to execute against (None will execute against the latest known blockhash) + pub block_hash: Option, + /// The data necessary to execute the call + pub proof: Vec, +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/primitives/src/precompile.rs b/crates/primitives/src/precompile.rs index 22a7839021..404e8b057f 100644 --- a/crates/primitives/src/precompile.rs +++ b/crates/primitives/src/precompile.rs @@ -1,4 +1,4 @@ -use crate::{Bytes, Env}; +use crate::{Bytes, Env, CallOptions}; use core::fmt::{self}; use dyn_clone::DynClone; use std::{boxed::Box, string::String, sync::Arc}; @@ -26,6 +26,8 @@ impl PrecompileOutput { pub type StandardPrecompileFn = fn(&Bytes, u64) -> PrecompileResult; pub type EnvPrecompileFn = fn(&Bytes, u64, env: &Env) -> PrecompileResult; +/// TODO: the input is a CallOptions struct to avoid having to put the interpreter in the primitives crate +pub type CtxPrecompileFn = fn(&[u8], u64, env: &Env, interpreter: &mut Option) -> PrecompileResult; /// Stateful precompile trait. It is used to create /// a arc precompile Precompile::Stateful. @@ -60,6 +62,8 @@ pub enum Precompile { /// Mutable stateful precompile that is Box over [`StatefulPrecompileMut`] trait. /// It takes a reference to input, gas limit and environment. StatefulMut(StatefulPrecompileBox), + // Similar to Standard but takes reference to environment. + Ctx(CtxPrecompileFn), } impl From for Precompile { @@ -93,6 +97,7 @@ impl fmt::Debug for Precompile { Precompile::Env(_) => f.write_str("Env"), Precompile::Stateful(_) => f.write_str("Stateful"), Precompile::StatefulMut(_) => f.write_str("StatefulMut"), + Precompile::Ctx(_) => f.write_str("Ctx"), } } } @@ -115,6 +120,7 @@ impl Precompile { Precompile::Env(p) => p(bytes, gas_limit, env), Precompile::Stateful(ref p) => p.call(bytes, gas_limit, env), Precompile::StatefulMut(ref mut p) => p.call_mut(bytes, gas_limit, env), + Precompile::Ctx(ref mut p) => p(bytes, gas_limit, env, &mut None), // TODO: Brecht } } @@ -129,6 +135,7 @@ impl Precompile { Precompile::StatefulMut(_) => Err(PrecompileErrors::Fatal { msg: "call_ref on mutable stateful precompile".into(), }), + Precompile::Ctx(p) => p(bytes, gas_limit, env, &mut None), // TODO: Brecht } } } @@ -174,6 +181,11 @@ pub enum PrecompileError { BlobMismatchedVersion, /// The proof verification failed. BlobVerifyKzgProofFailed, + /// XCALLOPTIONS errors + /// The input length is not the expected length + XCallOptionsInvalidInputLength, + /// The version given is not supported + XCallOptionsInvalidVersion, /// Catch-all variant for other errors. Other(String), } @@ -214,6 +226,8 @@ impl fmt::Display for PrecompileError { Self::BlobInvalidInputLength => "invalid blob input length", Self::BlobMismatchedVersion => "mismatched blob version", Self::BlobVerifyKzgProofFailed => "verifying blob kzg proof failed", + Self::XCallOptionsInvalidInputLength => "XCallOptionsInvalidInputLength", + Self::XCallOptionsInvalidVersion => "XCallOptionsInvalidVersion", Self::Other(s) => s, }; f.write_str(s) diff --git a/crates/primitives/src/state.rs b/crates/primitives/src/state.rs index 47be993043..29d98d2e1c 100644 --- a/crates/primitives/src/state.rs +++ b/crates/primitives/src/state.rs @@ -2,15 +2,27 @@ use crate::{Address, Bytecode, HashMap, SpecId, B256, KECCAK_EMPTY, U256}; use bitflags::bitflags; use core::hash::{Hash, Hasher}; +/// Chain specific address +/// +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct ChainAddress(pub u64, pub Address); + /// EVM State is a mapping from addresses to accounts. -pub type EvmState = HashMap; +pub type EvmState = HashMap; /// Structure used for EIP-1153 transient storage. -pub type TransientStorage = HashMap<(Address, U256), U256>; +pub type TransientStorage = HashMap<(ChainAddress, U256), U256>; /// An account's Storage is a mapping from 256-bit integer keys to [EvmStorageSlot]s. pub type EvmStorage = HashMap; +impl Default for ChainAddress { + fn default() -> Self { + ChainAddress(0, Address::default()) + } +} + #[derive(Debug, Clone, PartialEq, Eq, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Account { diff --git a/crates/revm/benches/bench.rs b/crates/revm/benches/bench.rs index 59cc261c9f..ef2467f502 100644 --- a/crates/revm/benches/bench.rs +++ b/crates/revm/benches/bench.rs @@ -106,7 +106,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(contract.clone(), u64::MAX, false); + let mut interpreter = Interpreter::new(contract.clone(), u64::MAX, false, 0, false); let res = interpreter.run(temp, &instruction_table, &mut host); shared_memory = interpreter.take_memory(); host.clear(); diff --git a/crates/revm/src/context.rs b/crates/revm/src/context.rs index 14d1b12d9d..e29b3b4d68 100644 --- a/crates/revm/src/context.rs +++ b/crates/revm/src/context.rs @@ -13,7 +13,7 @@ use revm_interpreter::{as_u64_saturated, Eip7702CodeLoad, StateLoad}; use crate::{ db::{Database, EmptyDB}, interpreter::{AccountLoad, Host, SStoreResult, SelfDestructResult}, - primitives::{Address, Bytes, Env, HandlerCfg, Log, B256, BLOCK_HASH_HISTORY, U256}, + primitives::{Address, Bytes, ChainAddress, Env, HandlerCfg, Log, B256, BLOCK_HASH_HISTORY, U256}, }; use std::boxed::Box; @@ -108,7 +108,7 @@ impl Host for Context { &mut self.evm.env } - fn block_hash(&mut self, requested_number: u64) -> Option { + fn block_hash(&mut self, chain_id: u64, requested_number: u64) -> Option { let block_number = as_u64_saturated!(self.env().block.number); let Some(diff) = block_number.checked_sub(requested_number) else { @@ -123,7 +123,7 @@ impl Host for Context { if diff <= BLOCK_HASH_HISTORY { return self .evm - .block_hash(requested_number) + .block_hash(chain_id, requested_number) .map_err(|e| self.evm.error = Err(e)) .ok(); } @@ -131,35 +131,35 @@ impl Host for Context { Some(B256::ZERO) } - fn load_account_delegated(&mut self, address: Address) -> Option { + fn load_account_delegated(&mut self, address: ChainAddress) -> Option { self.evm .load_account_delegated(address) .map_err(|e| self.evm.error = Err(e)) .ok() } - fn balance(&mut self, address: Address) -> Option> { + fn balance(&mut self, address: ChainAddress) -> Option> { self.evm .balance(address) .map_err(|e| self.evm.error = Err(e)) .ok() } - fn code(&mut self, address: Address) -> Option> { + fn code(&mut self, address: ChainAddress) -> Option> { self.evm .code(address) .map_err(|e| self.evm.error = Err(e)) .ok() } - fn code_hash(&mut self, address: Address) -> Option> { + fn code_hash(&mut self, address: ChainAddress) -> Option> { self.evm .code_hash(address) .map_err(|e| self.evm.error = Err(e)) .ok() } - fn sload(&mut self, address: Address, index: U256) -> Option> { + fn sload(&mut self, address: ChainAddress, index: U256) -> Option> { self.evm .sload(address, index) .map_err(|e| self.evm.error = Err(e)) @@ -168,7 +168,7 @@ impl Host for Context { fn sstore( &mut self, - address: Address, + address: ChainAddress, index: U256, value: U256, ) -> Option> { @@ -178,11 +178,11 @@ impl Host for Context { .ok() } - fn tload(&mut self, address: Address, index: U256) -> U256 { + fn tload(&mut self, address: ChainAddress, index: U256) -> U256 { self.evm.tload(address, index) } - fn tstore(&mut self, address: Address, index: U256, value: U256) { + fn tstore(&mut self, address: ChainAddress, index: U256, value: U256) { self.evm.tstore(address, index, value) } @@ -192,8 +192,8 @@ impl Host for Context { fn selfdestruct( &mut self, - address: Address, - target: Address, + address: ChainAddress, + target: ChainAddress, ) -> Option> { self.evm .inner diff --git a/crates/revm/src/context/evm_context.rs b/crates/revm/src/context/evm_context.rs index 32a62ba6f1..bfc420184b 100644 --- a/crates/revm/src/context/evm_context.rs +++ b/crates/revm/src/context/evm_context.rs @@ -9,7 +9,7 @@ use crate::{ EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterResult, }, primitives::{ - keccak256, Address, Bytecode, Bytes, CreateScheme, EVMError, Env, Eof, + keccak256, Address, Bytecode, Bytes, ChainAddress, CreateScheme, EVMError, Env, Eof, SpecId::{self, *}, B256, EOF_MAGIC_BYTES, }, @@ -99,11 +99,11 @@ impl EvmContext { /// Sets precompiles #[inline] - pub fn set_precompiles(&mut self, precompiles: ContextPrecompiles) { + pub fn set_precompiles(&mut self, chain_id: u64, precompiles: ContextPrecompiles) { // set warm loaded addresses. self.journaled_state .warm_preloaded_addresses - .extend(precompiles.addresses_set()); + .extend(precompiles.addresses_set().iter().map(|precompile| ChainAddress(chain_id, precompile.clone()))); self.precompiles = precompiles; } @@ -111,13 +111,13 @@ impl EvmContext { #[inline] fn call_precompile( &mut self, - address: &Address, + address: &ChainAddress, input_data: &Bytes, gas: Gas, ) -> Result, EVMError> { let Some(outcome) = self.precompiles - .call(address, input_data, gas.limit(), &mut self.inner) + .call(&address.1, input_data, gas.limit(), &mut self.inner) else { return Ok(None); }; @@ -240,7 +240,7 @@ impl EvmContext { bytecode = self .inner .journaled_state - .load_code(eip7702_bytecode.delegated_address, &mut self.inner.db)? + .load_code(ChainAddress(inputs.bytecode_address.0, eip7702_bytecode.delegated_address), &mut self.inner.db)? .info .code .clone() @@ -253,7 +253,7 @@ impl EvmContext { Ok(FrameOrResult::new_call_frame( inputs.return_memory_offset.clone(), checkpoint, - Interpreter::new(contract, gas.limit(), inputs.is_static), + Interpreter::new(contract, gas.limit(), inputs.is_static, inputs.target_address.0, false), )) } } @@ -265,6 +265,8 @@ impl EvmContext { spec_id: SpecId, inputs: &CreateInputs, ) -> Result> { + let chain_id = inputs.caller.0; + let return_error = |e| { Ok(FrameOrResult::new_create_result( InterpreterResult { @@ -305,10 +307,11 @@ impl EvmContext { // Create address let mut init_code_hash = B256::ZERO; let created_address = match inputs.scheme { - CreateScheme::Create => inputs.caller.create(old_nonce), + // TODO: Brecht + CreateScheme::Create => inputs.caller.1.create(old_nonce), CreateScheme::Create2 { salt } => { init_code_hash = keccak256(&inputs.init_code); - inputs.caller.create2(salt.to_be_bytes(), init_code_hash) + inputs.caller.1.create2(salt.to_be_bytes(), init_code_hash) } }; @@ -317,6 +320,9 @@ impl EvmContext { return return_error(InstructionResult::CreateCollision); } + // TODO: Brecht + let created_address = ChainAddress(chain_id, created_address); + // warm load account. self.load_account(created_address)?; @@ -346,9 +352,9 @@ impl EvmContext { ); Ok(FrameOrResult::new_create_frame( - created_address, + created_address.1, checkpoint, - Interpreter::new(contract, inputs.gas_limit, false), + Interpreter::new(contract, inputs.gas_limit, false, chain_id, false), )) } @@ -370,6 +376,8 @@ impl EvmContext { )) }; + let chain_id = inputs.caller.0; + let (input, initcode, created_address) = match &inputs.kind { EOFCreateKind::Opcode { initcode, @@ -396,7 +404,7 @@ impl EvmContext { .env .tx .nonce - .map(|nonce| self.env.tx.caller.create(nonce)); + .map(|nonce| ChainAddress(chain_id, self.env.tx.caller.1.create(nonce))); // TODO: Brecht (input, eof, nonce) } @@ -422,10 +430,10 @@ impl EvmContext { }; let old_nonce = nonce - 1; - let created_address = created_address.unwrap_or_else(|| inputs.caller.create(old_nonce)); + let created_address = created_address.unwrap_or_else(|| ChainAddress(chain_id, inputs.caller.1.create(old_nonce))); // created address is not allowed to be a precompile. - if self.precompiles.contains(&created_address) { + if self.precompiles.contains(&created_address.1) { return return_error(InstructionResult::CreateCollision); } @@ -456,12 +464,12 @@ impl EvmContext { inputs.value, ); - let mut interpreter = Interpreter::new(contract, inputs.gas_limit, false); + let mut interpreter = Interpreter::new(contract, inputs.gas_limit, false, chain_id, false); // EOF init will enable RETURNCONTRACT opcode. interpreter.set_is_eof_init(); Ok(FrameOrResult::new_eofcreate_frame( - created_address, + created_address.1, checkpoint, interpreter, )) diff --git a/crates/revm/src/context/inner_evm_context.rs b/crates/revm/src/context/inner_evm_context.rs index 0d6797cf84..991716c491 100644 --- a/crates/revm/src/context/inner_evm_context.rs +++ b/crates/revm/src/context/inner_evm_context.rs @@ -6,7 +6,7 @@ use crate::{ }, journaled_state::JournaledState, primitives::{ - AccessListItem, Account, Address, AnalysisKind, Bytecode, Bytes, CfgEnv, EVMError, Env, + AccessListItem, Account, Address, AnalysisKind, Bytecode, Bytes, CfgEnv, ChainAddress, EVMError, Env, Eof, HashSet, Spec, SpecId::{self, *}, B256, EOF_MAGIC_BYTES, EOF_MAGIC_HASH, U256, @@ -98,14 +98,14 @@ impl InnerEvmContext { /// /// Loading of accounts/storages is needed to make them warm. #[inline] - pub fn load_access_list(&mut self) -> Result<(), EVMError> { + pub fn load_access_list(&mut self, chain_id: u64) -> Result<(), EVMError> { for AccessListItem { address, storage_keys, } in self.env.tx.access_list.iter() { self.journaled_state.initial_account_load( - *address, + ChainAddress(chain_id, *address), storage_keys.iter().map(|i| U256::from_be_bytes(i.0)), &mut self.db, )?; @@ -132,13 +132,13 @@ impl InnerEvmContext { /// Fetch block hash from database. #[inline] - pub fn block_hash(&mut self, number: u64) -> Result> { - self.db.block_hash(number).map_err(EVMError::Database) + pub fn block_hash(&mut self, chain_id: u64, number: u64) -> Result> { + self.db.block_hash(chain_id, number).map_err(EVMError::Database) } /// Mark account as touched as only touched accounts will be added to state. #[inline] - pub fn touch(&mut self, address: &Address) { + pub fn touch(&mut self, address: &ChainAddress) { self.journaled_state.touch(address); } @@ -146,7 +146,7 @@ impl InnerEvmContext { #[inline] pub fn load_account( &mut self, - address: Address, + address: ChainAddress, ) -> Result, EVMError> { self.journaled_state.load_account(address, &mut self.db) } @@ -157,7 +157,7 @@ impl InnerEvmContext { #[inline] pub fn load_account_delegated( &mut self, - address: Address, + address: ChainAddress, ) -> Result> { self.journaled_state .load_account_delegated(address, &mut self.db) @@ -165,7 +165,7 @@ impl InnerEvmContext { /// Return account balance and is_cold flag. #[inline] - pub fn balance(&mut self, address: Address) -> Result, EVMError> { + pub fn balance(&mut self, address: ChainAddress) -> Result, EVMError> { self.journaled_state .load_account(address, &mut self.db) .map(|acc| acc.map(|a| a.info.balance)) @@ -177,7 +177,7 @@ impl InnerEvmContext { #[inline] pub fn code( &mut self, - address: Address, + address: ChainAddress, ) -> Result, EVMError> { let a = self.journaled_state.load_code(address, &mut self.db)?; // SAFETY: safe to unwrap as load_code will insert code if it is empty. @@ -189,11 +189,13 @@ impl InnerEvmContext { )); } + let chain_id = address.0; + if let Bytecode::Eip7702(code) = code { let address = code.address(); let is_cold = a.is_cold; - let delegated_account = self.journaled_state.load_code(address, &mut self.db)?; + let delegated_account = self.journaled_state.load_code(ChainAddress(chain_id, address), &mut self.db)?; // SAFETY: safe to unwrap as load_code will insert code if it is empty. let delegated_code = delegated_account.info.code.as_ref().unwrap(); @@ -223,7 +225,7 @@ impl InnerEvmContext { #[inline] pub fn code_hash( &mut self, - address: Address, + address: ChainAddress, ) -> Result, EVMError> { let acc = self.journaled_state.load_code(address, &mut self.db)?; if acc.is_empty() { @@ -232,12 +234,14 @@ impl InnerEvmContext { // SAFETY: safe to unwrap as load_code will insert code if it is empty. let code = acc.info.code.as_ref().unwrap(); + let chain_id = address.0; + // If bytecode is EIP-7702 then we need to load the delegated account. if let Bytecode::Eip7702(code) = code { let address = code.address(); let is_cold = acc.is_cold; - let delegated_account = self.journaled_state.load_code(address, &mut self.db)?; + let delegated_account = self.journaled_state.load_code(ChainAddress(chain_id, address), &mut self.db)?; let hash = if delegated_account.is_empty() { B256::ZERO @@ -266,7 +270,7 @@ impl InnerEvmContext { #[inline] pub fn sload( &mut self, - address: Address, + address: ChainAddress, index: U256, ) -> Result, EVMError> { // account is always warm. reference on that statement https://eips.ethereum.org/EIPS/eip-2929 see `Note 2:` @@ -277,7 +281,7 @@ impl InnerEvmContext { #[inline] pub fn sstore( &mut self, - address: Address, + address: ChainAddress, index: U256, value: U256, ) -> Result, EVMError> { @@ -287,13 +291,13 @@ impl InnerEvmContext { /// Returns transient storage value. #[inline] - pub fn tload(&mut self, address: Address, index: U256) -> U256 { + pub fn tload(&mut self, address: ChainAddress, index: U256) -> U256 { self.journaled_state.tload(address, index) } /// Stores transient storage value. #[inline] - pub fn tstore(&mut self, address: Address, index: U256, value: U256) { + pub fn tstore(&mut self, address: ChainAddress, index: U256, value: U256) { self.journaled_state.tstore(address, index, value) } @@ -301,8 +305,8 @@ impl InnerEvmContext { #[inline] pub fn selfdestruct( &mut self, - address: Address, - target: Address, + address: ChainAddress, + target: ChainAddress, ) -> Result, EVMError> { self.journaled_state .selfdestruct(address, target, &mut self.db) @@ -312,7 +316,7 @@ impl InnerEvmContext { pub fn eofcreate_return( &mut self, interpreter_result: &mut InterpreterResult, - address: Address, + address: ChainAddress, journal_checkpoint: JournalCheckpoint, ) { // Note we still execute RETURN opcode and return the bytes. @@ -373,7 +377,7 @@ impl InnerEvmContext { pub fn create_return( &mut self, interpreter_result: &mut InterpreterResult, - address: Address, + address: ChainAddress, journal_checkpoint: JournalCheckpoint, ) { // if return is not ok revert and return. diff --git a/crates/revm/src/db/emptydb.rs b/crates/revm/src/db/emptydb.rs index 3d14ab23ae..e945ac61ee 100644 --- a/crates/revm/src/db/emptydb.rs +++ b/crates/revm/src/db/emptydb.rs @@ -1,7 +1,7 @@ use core::{convert::Infallible, fmt, marker::PhantomData}; use revm_interpreter::primitives::{ db::{Database, DatabaseRef}, - keccak256, AccountInfo, Address, Bytecode, B256, U256, + keccak256, AccountInfo, ChainAddress, Bytecode, B256, U256, }; use std::string::ToString; @@ -57,23 +57,23 @@ impl Database for EmptyDBTyped { type Error = E; #[inline] - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { ::basic_ref(self, address) } #[inline] - fn code_by_hash(&mut self, code_hash: B256) -> Result { - ::code_by_hash_ref(self, code_hash) + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { + ::code_by_hash_ref(self, chain_id, code_hash) } #[inline] - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { ::storage_ref(self, address, index) } #[inline] - fn block_hash(&mut self, number: u64) -> Result { - ::block_hash_ref(self, number) + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { + ::block_hash_ref(self, chain_id, number) } } @@ -81,22 +81,22 @@ impl DatabaseRef for EmptyDBTyped { type Error = E; #[inline] - fn basic_ref(&self, _address: Address) -> Result, Self::Error> { + fn basic_ref(&self, _address: ChainAddress) -> Result, Self::Error> { Ok(None) } #[inline] - fn code_by_hash_ref(&self, _code_hash: B256) -> Result { + fn code_by_hash_ref(&self, _chain_id: u64, _code_hash: B256) -> Result { Ok(Bytecode::default()) } #[inline] - fn storage_ref(&self, _address: Address, _index: U256) -> Result { + fn storage_ref(&self, _address: ChainAddress, _index: U256) -> Result { Ok(U256::default()) } #[inline] - fn block_hash_ref(&self, number: u64) -> Result { + fn block_hash_ref(&self, _chain_id: u64, number: u64) -> Result { Ok(keccak256(number.to_string().as_bytes())) } } diff --git a/crates/revm/src/db/ethersdb.rs b/crates/revm/src/db/ethersdb.rs index 6e4f813a1b..67d677e5ac 100644 --- a/crates/revm/src/db/ethersdb.rs +++ b/crates/revm/src/db/ethersdb.rs @@ -4,7 +4,7 @@ use ethers_core::types::{Block, BlockId, TxHash, H160 as eH160, H256, U64 as eU6 use ethers_providers::Middleware; use tokio::runtime::{Handle, Runtime}; -use crate::primitives::{AccountInfo, Address, Bytecode, B256, U256}; +use crate::primitives::{AccountInfo, Address, Bytecode, ChainAddress, B256, U256}; use crate::{Database, DatabaseRef}; use super::utils::HandleOrRuntime; @@ -109,11 +109,12 @@ impl EthersDB { } } +// TODO: respect chain id and pick the right client impl DatabaseRef for EthersDB { type Error = M::Error; - fn basic_ref(&self, address: Address) -> Result, Self::Error> { - let add = eH160::from(address.0 .0); + fn basic_ref(&self, address: ChainAddress) -> Result, Self::Error> { + let add = eH160::from(address.1.0 .0); let f = async { let nonce = self.client.get_transaction_count(add, self.block_number); @@ -130,20 +131,20 @@ impl DatabaseRef for EthersDB { Ok(Some(AccountInfo::new(balance, nonce, code_hash, bytecode))) } - fn code_by_hash_ref(&self, _code_hash: B256) -> Result { + fn code_by_hash_ref(&self, _chain_id: u64, _code_hash: B256) -> Result { panic!("Should not be called. Code is already loaded"); // not needed because we already load code with basic info } - fn storage_ref(&self, address: Address, index: U256) -> Result { - let add = eH160::from(address.0 .0); + fn storage_ref(&self, address: ChainAddress, index: U256) -> Result { + let add = eH160::from(address.1.0 .0); let index = H256::from(index.to_be_bytes()); let slot_value: H256 = self.block_on(self.client.get_storage_at(add, index, self.block_number))?; Ok(U256::from_be_bytes(slot_value.to_fixed_bytes())) } - fn block_hash_ref(&self, number: u64) -> Result { + fn block_hash_ref(&self, _chain_id: u64, number: u64) -> Result { let number = eU64::from(number); let block: Option> = self.block_on(self.client.get_block(BlockId::from(number)))?; @@ -156,23 +157,23 @@ impl Database for EthersDB { type Error = M::Error; #[inline] - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { ::basic_ref(self, address) } #[inline] - fn code_by_hash(&mut self, code_hash: B256) -> Result { - ::code_by_hash_ref(self, code_hash) + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { + ::code_by_hash_ref(self, chain_id, code_hash) } #[inline] - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { ::storage_ref(self, address, index) } #[inline] - fn block_hash(&mut self, number: u64) -> Result { - ::block_hash_ref(self, number) + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { + ::block_hash_ref(self, chain_id, number) } } @@ -190,6 +191,7 @@ mod tests { ) .unwrap(); let client = Arc::new(client); + let chain_id = 0; let ethersdb = EthersDB::new( Arc::clone(&client), // public infura mainnet @@ -201,7 +203,7 @@ mod tests { let address = "0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852" .parse::() .unwrap(); - let address = address.as_fixed_bytes().into(); + let address = ChainAddress(chain_id, address.as_fixed_bytes().into()); let acc_info = ethersdb.basic_ref(address).unwrap().unwrap(); diff --git a/crates/revm/src/db/in_memory_db.rs b/crates/revm/src/db/in_memory_db.rs index 58ab9ba1ba..bd9be37ccf 100644 --- a/crates/revm/src/db/in_memory_db.rs +++ b/crates/revm/src/db/in_memory_db.rs @@ -1,6 +1,6 @@ use super::{DatabaseCommit, DatabaseRef, EmptyDB}; use crate::primitives::{ - hash_map::Entry, Account, AccountInfo, Address, Bytecode, HashMap, Log, B256, KECCAK_EMPTY, + hash_map::Entry, Account, AccountInfo, Address, ChainAddress, Bytecode, HashMap, Log, B256, KECCAK_EMPTY, U256, }; use crate::Database; @@ -22,13 +22,13 @@ pub type InMemoryDB = CacheDB; pub struct CacheDB { /// Account info where None means it is not existing. Not existing state is needed for Pre TANGERINE forks. /// `code` is always `None`, and bytecode can be found in `contracts`. - pub accounts: HashMap, + pub accounts: HashMap, /// Tracks all contracts by their code hash. pub contracts: HashMap, /// All logs that were committed via [DatabaseCommit::commit]. pub logs: Vec, /// All cached block hashes from the [DatabaseRef]. - pub block_hashes: HashMap, + pub block_hashes: HashMap<(u64, U256), B256>, /// The underlying database ([DatabaseRef]) that is used to load data. /// /// Note: this is read-only, data is never written to this database. @@ -77,7 +77,7 @@ impl CacheDB { } /// Insert account info but not override storage - pub fn insert_account_info(&mut self, address: Address, mut info: AccountInfo) { + pub fn insert_account_info(&mut self, address: ChainAddress, mut info: AccountInfo) { self.insert_contract(&mut info); self.accounts.entry(address).or_default().info = info; } @@ -87,7 +87,7 @@ impl CacheDB { /// Returns the account for the given address. /// /// If the account was not found in the cache, it will be loaded from the underlying database. - pub fn load_account(&mut self, address: Address) -> Result<&mut DbAccount, ExtDB::Error> { + pub fn load_account(&mut self, address: ChainAddress) -> Result<&mut DbAccount, ExtDB::Error> { let db = &self.db; match self.accounts.entry(address) { Entry::Occupied(entry) => Ok(entry.into_mut()), @@ -105,7 +105,7 @@ impl CacheDB { /// insert account storage without overriding account info pub fn insert_account_storage( &mut self, - address: Address, + address: ChainAddress, slot: U256, value: U256, ) -> Result<(), ExtDB::Error> { @@ -117,7 +117,7 @@ impl CacheDB { /// replace account storage without overriding account info pub fn replace_account_storage( &mut self, - address: Address, + address: ChainAddress, storage: HashMap, ) -> Result<(), ExtDB::Error> { let account = self.load_account(address)?; @@ -128,7 +128,7 @@ impl CacheDB { } impl DatabaseCommit for CacheDB { - fn commit(&mut self, changes: HashMap) { + fn commit(&mut self, changes: HashMap) { for (address, mut account) in changes { if !account.is_touched() { continue; @@ -168,7 +168,7 @@ impl DatabaseCommit for CacheDB { impl Database for CacheDB { type Error = ExtDB::Error; - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { let basic = match self.accounts.entry(address) { Entry::Occupied(entry) => entry.into_mut(), Entry::Vacant(entry) => entry.insert( @@ -184,12 +184,12 @@ impl Database for CacheDB { Ok(basic.info()) } - fn code_by_hash(&mut self, code_hash: B256) -> Result { + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { match self.contracts.entry(code_hash) { Entry::Occupied(entry) => Ok(entry.get().clone()), Entry::Vacant(entry) => { // if you return code bytes when basic fn is called this function is not needed. - Ok(entry.insert(self.db.code_by_hash_ref(code_hash)?).clone()) + Ok(entry.insert(self.db.code_by_hash_ref(chain_id, code_hash)?).clone()) } } } @@ -197,7 +197,7 @@ impl Database for CacheDB { /// Get the value in an account's storage slot. /// /// It is assumed that account is already loaded. - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { match self.accounts.entry(address) { Entry::Occupied(mut acc_entry) => { let acc_entry = acc_entry.get_mut(); @@ -234,11 +234,11 @@ impl Database for CacheDB { } } - fn block_hash(&mut self, number: u64) -> Result { - match self.block_hashes.entry(U256::from(number)) { + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { + match self.block_hashes.entry((chain_id, U256::from(number))) { Entry::Occupied(entry) => Ok(*entry.get()), Entry::Vacant(entry) => { - let hash = self.db.block_hash_ref(number)?; + let hash = self.db.block_hash_ref(chain_id, number)?; entry.insert(hash); Ok(hash) } @@ -249,21 +249,21 @@ impl Database for CacheDB { impl DatabaseRef for CacheDB { type Error = ExtDB::Error; - fn basic_ref(&self, address: Address) -> Result, Self::Error> { + fn basic_ref(&self, address: ChainAddress) -> Result, Self::Error> { match self.accounts.get(&address) { Some(acc) => Ok(acc.info()), None => self.db.basic_ref(address), } } - fn code_by_hash_ref(&self, code_hash: B256) -> Result { + fn code_by_hash_ref(&self, chain_id: u64, code_hash: B256) -> Result { match self.contracts.get(&code_hash) { Some(entry) => Ok(entry.clone()), - None => self.db.code_by_hash_ref(code_hash), + None => self.db.code_by_hash_ref(chain_id, code_hash), } } - fn storage_ref(&self, address: Address, index: U256) -> Result { + fn storage_ref(&self, address: ChainAddress, index: U256) -> Result { match self.accounts.get(&address) { Some(acc_entry) => match acc_entry.storage.get(&index) { Some(entry) => Ok(*entry), @@ -282,10 +282,10 @@ impl DatabaseRef for CacheDB { } } - fn block_hash_ref(&self, number: u64) -> Result { - match self.block_hashes.get(&U256::from(number)) { + fn block_hash_ref(&self, chain_id: u64, number: u64) -> Result { + match self.block_hashes.get(&(chain_id, U256::from(number))) { Some(entry) => Ok(*entry), - None => self.db.block_hash_ref(number), + None => self.db.block_hash_ref(chain_id, number), } } } @@ -372,8 +372,8 @@ impl BenchmarkDB { impl Database for BenchmarkDB { type Error = Infallible; /// Get basic account information. - fn basic(&mut self, address: Address) -> Result, Self::Error> { - if address == Address::ZERO { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { + if address.1 == Address::ZERO { return Ok(Some(AccountInfo { nonce: 1, balance: U256::from(10000000), @@ -381,7 +381,7 @@ impl Database for BenchmarkDB { code_hash: self.1, })); } - if address == Address::with_last_byte(1) { + if address.1 == Address::with_last_byte(1) { return Ok(Some(AccountInfo { nonce: 0, balance: U256::from(10000000), @@ -393,17 +393,17 @@ impl Database for BenchmarkDB { } /// Get account code by its hash - fn code_by_hash(&mut self, _code_hash: B256) -> Result { + fn code_by_hash(&mut self, _chain_id: u64, _code_hash: B256) -> Result { Ok(Bytecode::default()) } /// Get storage value of address at index. - fn storage(&mut self, _address: Address, _index: U256) -> Result { + fn storage(&mut self, _address: ChainAddress, _index: U256) -> Result { Ok(U256::default()) } // History related - fn block_hash(&mut self, _number: u64) -> Result { + fn block_hash(&mut self, _chain_id: u64, _number: u64) -> Result { Ok(B256::default()) } } @@ -411,11 +411,12 @@ impl Database for BenchmarkDB { #[cfg(test)] mod tests { use super::{CacheDB, EmptyDB}; - use crate::primitives::{db::Database, AccountInfo, Address, U256}; + use crate::primitives::{db::Database, AccountInfo, Address, ChainAddress, U256}; #[test] fn test_insert_account_storage() { - let account = Address::with_last_byte(42); + let chain_id = 0; + let account = ChainAddress(chain_id, Address::with_last_byte(42)); let nonce = 42; let mut init_state = CacheDB::new(EmptyDB::default()); init_state.insert_account_info( @@ -438,7 +439,8 @@ mod tests { #[test] fn test_replace_account_storage() { - let account = Address::with_last_byte(42); + let chain_id = 0; + let account = ChainAddress(chain_id, Address::with_last_byte(42)); let nonce = 42; let mut init_state = CacheDB::new(EmptyDB::default()); init_state.insert_account_info( diff --git a/crates/revm/src/db/states/bundle_state.rs b/crates/revm/src/db/states/bundle_state.rs index 55fc3681a6..2ab806ef8d 100644 --- a/crates/revm/src/db/states/bundle_state.rs +++ b/crates/revm/src/db/states/bundle_state.rs @@ -13,19 +13,20 @@ use std::{ collections::{BTreeMap, BTreeSet}, vec::Vec, }; +use crate::primitives::ChainAddress; /// This builder is used to help to facilitate the initialization of `BundleState` struct #[derive(Debug)] pub struct BundleBuilder { - states: HashSet
, - state_original: HashMap, - state_present: HashMap, - state_storage: HashMap>, + states: HashSet, + state_original: HashMap, + state_present: HashMap, + state_storage: HashMap>, - reverts: BTreeSet<(u64, Address)>, + reverts: BTreeSet<(u64, ChainAddress)>, revert_range: RangeInclusive, - revert_account: HashMap<(u64, Address), Option>>, - revert_storage: HashMap<(u64, Address), Vec<(U256, U256)>>, + revert_account: HashMap<(u64, ChainAddress), Option>>, + revert_storage: HashMap<(u64, ChainAddress), Vec<(U256, U256)>>, contracts: HashMap, } @@ -97,25 +98,25 @@ impl BundleBuilder { } /// Collect address info of BundleState state - pub fn state_address(mut self, address: Address) -> Self { + pub fn state_address(mut self, address: ChainAddress) -> Self { self.set_state_address(address); self } /// Collect account info of BundleState state - pub fn state_original_account_info(mut self, address: Address, original: AccountInfo) -> Self { + pub fn state_original_account_info(mut self, address: ChainAddress, original: AccountInfo) -> Self { self.set_state_original_account_info(address, original); self } /// Collect account info of BundleState state - pub fn state_present_account_info(mut self, address: Address, present: AccountInfo) -> Self { + pub fn state_present_account_info(mut self, address: ChainAddress, present: AccountInfo) -> Self { self.set_state_present_account_info(address, present); self } /// Collect storage info of BundleState state - pub fn state_storage(mut self, address: Address, storage: HashMap) -> Self { + pub fn state_storage(mut self, address: ChainAddress, storage: HashMap) -> Self { self.set_state_storage(address, storage); self } @@ -124,7 +125,7 @@ impl BundleBuilder { /// /// `block_number` must respect `revert_range`, or the input /// will be ignored during the final build process - pub fn revert_address(mut self, block_number: u64, address: Address) -> Self { + pub fn revert_address(mut self, block_number: u64, address: ChainAddress) -> Self { self.set_revert_address(block_number, address); self } @@ -136,7 +137,7 @@ impl BundleBuilder { pub fn revert_account_info( mut self, block_number: u64, - address: Address, + address: ChainAddress, account: Option>, ) -> Self { self.set_revert_account_info(block_number, address, account); @@ -150,7 +151,7 @@ impl BundleBuilder { pub fn revert_storage( mut self, block_number: u64, - address: Address, + address: ChainAddress, storage: Vec<(U256, U256)>, ) -> Self { self.set_revert_storage(block_number, address, storage); @@ -164,7 +165,7 @@ impl BundleBuilder { } /// Set address info of BundleState state. - pub fn set_state_address(&mut self, address: Address) -> &mut Self { + pub fn set_state_address(&mut self, address: ChainAddress) -> &mut Self { self.states.insert(address); self } @@ -172,7 +173,7 @@ impl BundleBuilder { /// Set original account info of BundleState state. pub fn set_state_original_account_info( &mut self, - address: Address, + address: ChainAddress, original: AccountInfo, ) -> &mut Self { self.states.insert(address); @@ -183,7 +184,7 @@ impl BundleBuilder { /// Set present account info of BundleState state. pub fn set_state_present_account_info( &mut self, - address: Address, + address: ChainAddress, present: AccountInfo, ) -> &mut Self { self.states.insert(address); @@ -194,7 +195,7 @@ impl BundleBuilder { /// Set storage info of BundleState state. pub fn set_state_storage( &mut self, - address: Address, + address: ChainAddress, storage: HashMap, ) -> &mut Self { self.states.insert(address); @@ -203,7 +204,7 @@ impl BundleBuilder { } /// Set address info of BundleState reverts. - pub fn set_revert_address(&mut self, block_number: u64, address: Address) -> &mut Self { + pub fn set_revert_address(&mut self, block_number: u64, address: ChainAddress) -> &mut Self { self.reverts.insert((block_number, address)); self } @@ -212,7 +213,7 @@ impl BundleBuilder { pub fn set_revert_account_info( &mut self, block_number: u64, - address: Address, + address: ChainAddress, account: Option>, ) -> &mut Self { self.reverts.insert((block_number, address)); @@ -224,7 +225,7 @@ impl BundleBuilder { pub fn set_revert_storage( &mut self, block_number: u64, - address: Address, + address: ChainAddress, storage: Vec<(U256, U256)>, ) -> &mut Self { self.reverts.insert((block_number, address)); @@ -317,32 +318,32 @@ impl BundleBuilder { } /// Getter for `states` field - pub fn get_states(&self) -> &HashSet
{ + pub fn get_states(&self) -> &HashSet { &self.states } /// Mutable getter for `states` field - pub fn get_states_mut(&mut self) -> &mut HashSet
{ + pub fn get_states_mut(&mut self) -> &mut HashSet { &mut self.states } /// Mutable getter for `state_original` field - pub fn get_state_original_mut(&mut self) -> &mut HashMap { + pub fn get_state_original_mut(&mut self) -> &mut HashMap { &mut self.state_original } /// Mutable getter for `state_present` field - pub fn get_state_present_mut(&mut self) -> &mut HashMap { + pub fn get_state_present_mut(&mut self) -> &mut HashMap { &mut self.state_present } /// Mutable getter for `state_storage` field - pub fn get_state_storage_mut(&mut self) -> &mut HashMap> { + pub fn get_state_storage_mut(&mut self) -> &mut HashMap> { &mut self.state_storage } /// Mutable getter for `reverts` field - pub fn get_reverts_mut(&mut self) -> &mut BTreeSet<(u64, Address)> { + pub fn get_reverts_mut(&mut self) -> &mut BTreeSet<(u64, ChainAddress)> { &mut self.reverts } @@ -354,12 +355,12 @@ impl BundleBuilder { /// Mutable getter for `revert_account` field pub fn get_revert_account_mut( &mut self, - ) -> &mut HashMap<(u64, Address), Option>> { + ) -> &mut HashMap<(u64, ChainAddress), Option>> { &mut self.revert_account } /// Mutable getter for `revert_storage` field - pub fn get_revert_storage_mut(&mut self) -> &mut HashMap<(u64, Address), Vec<(U256, U256)>> { + pub fn get_revert_storage_mut(&mut self) -> &mut HashMap<(u64, ChainAddress), Vec<(U256, U256)>> { &mut self.revert_storage } @@ -396,7 +397,7 @@ impl BundleRetention { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BundleState { /// Account state. - pub state: HashMap, + pub state: HashMap, /// All created contracts in this block. pub contracts: HashMap, /// Changes to revert. @@ -420,7 +421,7 @@ impl BundleState { pub fn new( state: impl IntoIterator< Item = ( - Address, + ChainAddress, Option, Option, HashMap, @@ -429,7 +430,7 @@ impl BundleState { reverts: impl IntoIterator< Item = impl IntoIterator< Item = ( - Address, + ChainAddress, Option>, impl IntoIterator, ), @@ -502,7 +503,7 @@ impl BundleState { } /// Return reference to the state. - pub fn state(&self) -> &HashMap { + pub fn state(&self) -> &HashMap { &self.state } @@ -517,7 +518,7 @@ impl BundleState { } /// Get account from state - pub fn account(&self, address: &Address) -> Option<&BundleAccount> { + pub fn account(&self, address: &ChainAddress) -> Option<&BundleAccount> { self.state.get(address) } @@ -656,7 +657,7 @@ impl BundleState { /// Extend the bundle with other state /// /// Update the `other` state only if `other` is not flagged as destroyed. - pub fn extend_state(&mut self, other_state: HashMap) { + pub fn extend_state(&mut self, other_state: HashMap) { for (address, other_account) in other_state { match self.state.entry(address) { hash_map::Entry::Occupied(mut entry) => { @@ -839,7 +840,8 @@ mod tests { #[test] fn transition_states() { // dummy data - let address = Address::new([0x01; 20]); + let chain_id = 0; + let address = ChainAddress(chain_id, Address::new([0x01; 20])); let acc1 = AccountInfo { balance: U256::from(10), nonce: 1, @@ -867,12 +869,12 @@ mod tests { ); } - const fn account1() -> Address { - Address::new([0x60; 20]) + const fn account1() -> ChainAddress { + ChainAddress(0, Address::new([0x60; 20])) } - const fn account2() -> Address { - Address::new([0x61; 20]) + const fn account2() -> ChainAddress { + ChainAddress(0, Address::new([0x61; 20])) } fn slot1() -> U256 { diff --git a/crates/revm/src/db/states/cache.rs b/crates/revm/src/db/states/cache.rs index 5dd6770d49..a1f822e771 100644 --- a/crates/revm/src/db/states/cache.rs +++ b/crates/revm/src/db/states/cache.rs @@ -5,6 +5,7 @@ use revm_interpreter::primitives::{ Account, AccountInfo, Address, Bytecode, EvmState, HashMap, B256, }; use std::vec::Vec; +use crate::primitives::ChainAddress; /// Cache state contains both modified and original values. /// @@ -15,7 +16,7 @@ use std::vec::Vec; #[derive(Clone, Debug, PartialEq, Eq)] pub struct CacheState { /// Block state account with account state. - pub accounts: HashMap, + pub accounts: HashMap, /// Created contracts. // TODO add bytecode counter for number of bytecodes added/removed. pub contracts: HashMap, @@ -47,7 +48,7 @@ impl CacheState { /// Helper function that returns all accounts. /// /// Used inside tests to generate merkle tree. - pub fn trie_account(&self) -> impl IntoIterator { + pub fn trie_account(&self) -> impl IntoIterator { self.accounts.iter().filter_map(|(address, account)| { account .account @@ -57,13 +58,13 @@ impl CacheState { } /// Insert not existing account. - pub fn insert_not_existing(&mut self, address: Address) { + pub fn insert_not_existing(&mut self, address: ChainAddress) { self.accounts .insert(address, CacheAccount::new_loaded_not_existing()); } /// Insert Loaded (Or LoadedEmptyEip161 if account is empty) account. - pub fn insert_account(&mut self, address: Address, info: AccountInfo) { + pub fn insert_account(&mut self, address: ChainAddress, info: AccountInfo) { let account = if !info.is_empty() { CacheAccount::new_loaded(info, HashMap::default()) } else { @@ -75,7 +76,7 @@ impl CacheState { /// Similar to `insert_account` but with storage. pub fn insert_account_with_storage( &mut self, - address: Address, + address: ChainAddress, info: AccountInfo, storage: PlainStorage, ) { @@ -88,7 +89,7 @@ impl CacheState { } /// Apply output of revm execution and create account transitions that are used to build BundleState. - pub fn apply_evm_state(&mut self, evm_state: EvmState) -> Vec<(Address, TransitionAccount)> { + pub fn apply_evm_state(&mut self, evm_state: EvmState) -> Vec<(ChainAddress, TransitionAccount)> { let mut transitions = Vec::with_capacity(evm_state.len()); for (address, account) in evm_state { if let Some(transition) = self.apply_account_state(address, account) { @@ -102,7 +103,7 @@ impl CacheState { /// Returns account transition if applicable. fn apply_account_state( &mut self, - address: Address, + address: ChainAddress, account: Account, ) -> Option { // not touched account are never changed. diff --git a/crates/revm/src/db/states/changes.rs b/crates/revm/src/db/states/changes.rs index 555ba1e015..f7c451dde2 100644 --- a/crates/revm/src/db/states/changes.rs +++ b/crates/revm/src/db/states/changes.rs @@ -1,5 +1,5 @@ use super::RevertToSlot; -use revm_interpreter::primitives::{AccountInfo, Address, Bytecode, B256, U256}; +use revm_interpreter::primitives::{AccountInfo, Address, Bytecode, ChainAddress, B256, U256}; use std::vec::Vec; /// accounts/storages/contracts for inclusion into database. @@ -11,7 +11,7 @@ use std::vec::Vec; #[derive(Clone, Debug, Default)] pub struct StateChangeset { /// Vector of **not** sorted accounts information. - pub accounts: Vec<(Address, Option)>, + pub accounts: Vec<(ChainAddress, Option)>, /// Vector of **not** sorted storage. pub storage: Vec, /// Vector of contracts by bytecode hash. **not** sorted. @@ -23,7 +23,7 @@ pub struct StateChangeset { #[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct PlainStorageChangeset { /// Address of account - pub address: Address, + pub address: ChainAddress, /// Wipe storage, pub wipe_storage: bool, /// Storage key value pairs. @@ -34,7 +34,7 @@ pub struct PlainStorageChangeset { #[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct PlainStorageRevert { /// Address of account - pub address: Address, + pub address: ChainAddress, /// Is storage wiped in this revert. Wiped flag is set on /// first known selfdestruct and would require clearing the /// state of this storage from database (And moving it to revert). @@ -52,7 +52,7 @@ pub struct PlainStateReverts { /// Vector of account with removed contracts bytecode /// /// Note: If AccountInfo is None means that account needs to be removed. - pub accounts: Vec)>>, + pub accounts: Vec)>>, /// Vector of storage with its address. pub storage: Vec>, } @@ -68,4 +68,4 @@ impl PlainStateReverts { } /// Storage reverts -pub type StorageRevert = Vec)>>; +pub type StorageRevert = Vec)>>; diff --git a/crates/revm/src/db/states/reverts.rs b/crates/revm/src/db/states/reverts.rs index 4d8d3f402d..c390af6679 100644 --- a/crates/revm/src/db/states/reverts.rs +++ b/crates/revm/src/db/states/reverts.rs @@ -4,15 +4,16 @@ use super::{ }; use core::ops::{Deref, DerefMut}; use revm_interpreter::primitives::{AccountInfo, Address, HashMap, U256}; +use crate::primitives::ChainAddress; use std::vec::Vec; /// Contains reverts of multiple account in multiple transitions (Transitions as a block). #[derive(Clone, Debug, Default, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Reverts(Vec>); +pub struct Reverts(Vec>); impl Deref for Reverts { - type Target = Vec>; + type Target = Vec>; fn deref(&self) -> &Self::Target { &self.0 @@ -27,7 +28,7 @@ impl DerefMut for Reverts { impl Reverts { /// Create new reverts - pub fn new(reverts: Vec>) -> Self { + pub fn new(reverts: Vec>) -> Self { Self(reverts) } diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index 9c3cc114e7..fd0678b19b 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -5,13 +5,14 @@ use super::{ use crate::db::EmptyDB; use revm_interpreter::primitives::{ db::{Database, DatabaseCommit}, - hash_map, Account, AccountInfo, Address, Bytecode, HashMap, B256, BLOCK_HASH_HISTORY, U256, + hash_map, Account, AccountInfo, Bytecode, HashMap, B256, BLOCK_HASH_HISTORY, U256, }; use std::{ boxed::Box, collections::{btree_map, BTreeMap}, vec::Vec, }; +use crate::primitives::ChainAddress; /// Database boxed with a lifetime and Send. pub type DBBox<'a, E> = Box + Send + 'a>; @@ -83,7 +84,7 @@ impl State { /// balances must be filtered out before calling this function. pub fn increment_balances( &mut self, - balances: impl IntoIterator, + balances: impl IntoIterator, ) -> Result<(), DB::Error> { // make transition and update cache state let mut transitions = Vec::new(); @@ -111,7 +112,7 @@ impl State { /// It is used for DAO hardfork state change to move values from given accounts. pub fn drain_balances( &mut self, - addresses: impl IntoIterator, + addresses: impl IntoIterator, ) -> Result, DB::Error> { // make transition and update cache state let mut transitions = Vec::new(); @@ -134,17 +135,17 @@ impl State { self.cache.set_state_clear_flag(has_state_clear); } - pub fn insert_not_existing(&mut self, address: Address) { + pub fn insert_not_existing(&mut self, address: ChainAddress) { self.cache.insert_not_existing(address) } - pub fn insert_account(&mut self, address: Address, info: AccountInfo) { + pub fn insert_account(&mut self, address: ChainAddress, info: AccountInfo) { self.cache.insert_account(address, info) } pub fn insert_account_with_storage( &mut self, - address: Address, + address: ChainAddress, info: AccountInfo, storage: PlainStorage, ) { @@ -153,7 +154,7 @@ impl State { } /// Apply evm transitions to transition state. - pub fn apply_transition(&mut self, transitions: Vec<(Address, TransitionAccount)>) { + pub fn apply_transition(&mut self, transitions: Vec<(ChainAddress, TransitionAccount)>) { // add transition to transition state. if let Some(s) = self.transition_state.as_mut() { s.add_transitions(transitions) @@ -174,7 +175,7 @@ impl State { /// Get a mutable reference to the [`CacheAccount`] for the given address. /// If the account is not found in the cache, it will be loaded from the /// database and inserted into the cache. - pub fn load_cache_account(&mut self, address: Address) -> Result<&mut CacheAccount, DB::Error> { + pub fn load_cache_account(&mut self, address: ChainAddress) -> Result<&mut CacheAccount, DB::Error> { match self.cache.accounts.entry(address) { hash_map::Entry::Vacant(entry) => { if self.use_preloaded_bundle { @@ -218,11 +219,11 @@ impl State { impl Database for State { type Error = DB::Error; - fn basic(&mut self, address: Address) -> Result, Self::Error> { + fn basic(&mut self, address: ChainAddress) -> Result, Self::Error> { self.load_cache_account(address).map(|a| a.account_info()) } - fn code_by_hash(&mut self, code_hash: B256) -> Result { + fn code_by_hash(&mut self, chain_id: u64, code_hash: B256) -> Result { let res = match self.cache.contracts.entry(code_hash) { hash_map::Entry::Occupied(entry) => Ok(entry.get().clone()), hash_map::Entry::Vacant(entry) => { @@ -233,7 +234,7 @@ impl Database for State { } } // if not found in bundle ask database - let code = self.database.code_by_hash(code_hash)?; + let code = self.database.code_by_hash(chain_id, code_hash)?; entry.insert(code.clone()); Ok(code) } @@ -241,7 +242,7 @@ impl Database for State { res } - fn storage(&mut self, address: Address, index: U256) -> Result { + fn storage(&mut self, address: ChainAddress, index: U256) -> Result { // Account is guaranteed to be loaded. // Note that storage from bundle is already loaded with account. if let Some(account) = self.cache.accounts.get_mut(&address) { @@ -271,11 +272,11 @@ impl Database for State { } } - fn block_hash(&mut self, number: u64) -> Result { + fn block_hash(&mut self, chain_id: u64, number: u64) -> Result { match self.block_hashes.entry(number) { btree_map::Entry::Occupied(entry) => Ok(*entry.get()), btree_map::Entry::Vacant(entry) => { - let ret = *entry.insert(self.database.block_hash(number)?); + let ret = *entry.insert(self.database.block_hash(chain_id, number)?); // prune all hashes that are older then BLOCK_HASH_HISTORY let last_block = number.saturating_sub(BLOCK_HASH_HISTORY); @@ -294,7 +295,7 @@ impl Database for State { } impl DatabaseCommit for State { - fn commit(&mut self, evm_state: HashMap) { + fn commit(&mut self, evm_state: HashMap) { let transitions = self.cache.apply_evm_state(evm_state); self.apply_transition(transitions); } @@ -311,9 +312,10 @@ mod tests { #[test] fn block_hash_cache() { + let chain_id = 0; let mut state = State::builder().build(); - state.block_hash(1u64).unwrap(); - state.block_hash(2u64).unwrap(); + state.block_hash(chain_id, 1u64).unwrap(); + state.block_hash(chain_id, 2u64).unwrap(); let test_number = BLOCK_HASH_HISTORY + 2; @@ -326,7 +328,7 @@ mod tests { BTreeMap::from([(1, block1_hash), (2, block2_hash)]) ); - state.block_hash(test_number).unwrap(); + state.block_hash(chain_id, test_number).unwrap(); assert_eq!( state.block_hashes, BTreeMap::from([(test_number, block_test_hash), (2, block2_hash)]) @@ -341,13 +343,14 @@ mod tests { /// state of the account before the block. #[test] fn reverts_preserve_old_values() { + let chain_id = 0; let mut state = State::builder().with_bundle_update().build(); let (slot1, slot2, slot3) = (U256::from(1), U256::from(2), U256::from(3)); // Non-existing account for testing account state transitions. // [LoadedNotExisting] -> [Changed] (nonce: 1, balance: 1) -> [Changed] (nonce: 2) -> [Changed] (nonce: 3) - let new_account_address = Address::from_slice(&[0x1; 20]); + let new_account_address = ChainAddress(chain_id, Address::from_slice(&[0x1; 20])); let new_account_created_info = AccountInfo { nonce: 1, balance: U256::from(1), @@ -363,7 +366,7 @@ mod tests { }; // Existing account for testing storage state transitions. - let existing_account_address = Address::from_slice(&[0x2; 20]); + let existing_account_address = ChainAddress(chain_id, Address::from_slice(&[0x2; 20])); let existing_account_initial_info = AccountInfo { nonce: 1, ..Default::default() @@ -565,10 +568,11 @@ mod tests { /// block and reverted to their previous state do not appear in the reverts. #[test] fn bundle_scoped_reverts_collapse() { + let chain_id = 0; let mut state = State::builder().with_bundle_update().build(); // Non-existing account. - let new_account_address = Address::from_slice(&[0x1; 20]); + let new_account_address = ChainAddress(chain_id, Address::from_slice(&[0x1; 20])); let new_account_created_info = AccountInfo { nonce: 1, balance: U256::from(1), @@ -576,7 +580,7 @@ mod tests { }; // Existing account. - let existing_account_address = Address::from_slice(&[0x2; 20]); + let existing_account_address = ChainAddress(chain_id, Address::from_slice(&[0x2; 20])); let existing_account_initial_info = AccountInfo { nonce: 1, ..Default::default() @@ -589,7 +593,7 @@ mod tests { // Existing account with storage. let (slot1, slot2) = (U256::from(1), U256::from(2)); - let existing_account_with_storage_address = Address::from_slice(&[0x3; 20]); + let existing_account_with_storage_address = ChainAddress(chain_id, Address::from_slice(&[0x3; 20])); let existing_account_with_storage_info = AccountInfo { nonce: 1, ..Default::default() @@ -689,10 +693,11 @@ mod tests { /// Checks that the behavior of selfdestruct within the block is correct. #[test] fn selfdestruct_state_and_reverts() { + let chain_id = 0; let mut state = State::builder().with_bundle_update().build(); // Existing account. - let existing_account_address = Address::from_slice(&[0x1; 20]); + let existing_account_address = ChainAddress(chain_id, Address::from_slice(&[0x1; 20])); let existing_account_info = AccountInfo { nonce: 1, ..Default::default() diff --git a/crates/revm/src/db/states/transition_state.rs b/crates/revm/src/db/states/transition_state.rs index 8a5556cc77..2ab4079eee 100644 --- a/crates/revm/src/db/states/transition_state.rs +++ b/crates/revm/src/db/states/transition_state.rs @@ -1,16 +1,17 @@ use super::TransitionAccount; use revm_interpreter::primitives::{hash_map::Entry, Address, HashMap}; use std::vec::Vec; +use crate::primitives::ChainAddress; #[derive(Clone, Default, Debug, PartialEq, Eq)] pub struct TransitionState { /// Block state account with account state - pub transitions: HashMap, + pub transitions: HashMap, } impl TransitionState { /// Create new transition state containing one [`TransitionAccount`]. - pub fn single(address: Address, transition: TransitionAccount) -> Self { + pub fn single(address: ChainAddress, transition: TransitionAccount) -> Self { let mut transitions = HashMap::new(); transitions.insert(address, transition); TransitionState { transitions } @@ -25,7 +26,7 @@ impl TransitionState { /// Add transitions to the transition state. This will insert new /// [`TransitionAccount`]s, or update existing ones via /// [`TransitionAccount::update`]. - pub fn add_transitions(&mut self, transitions: Vec<(Address, TransitionAccount)>) { + pub fn add_transitions(&mut self, transitions: Vec<(ChainAddress, TransitionAccount)>) { for (address, account) in transitions { match self.transitions.entry(address) { Entry::Occupied(entry) => { diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index b42abcdcf1..5df527e312 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -6,8 +6,8 @@ use crate::{ CallInputs, CreateInputs, EOFCreateInputs, Host, InterpreterAction, SharedMemory, }, primitives::{ - specification::SpecId, BlockEnv, CfgEnv, EVMError, EVMResult, EnvWithHandlerCfg, - ExecutionResult, HandlerCfg, ResultAndState, TxEnv, TxKind, EOF_MAGIC_BYTES, + specification::SpecId, BlockEnv, CfgEnv, ChainAddress, EVMError, EVMResult, EnvWithHandlerCfg, + ExecutionResult, HandlerCfg, ResultAndState, TransactTo, TxEnv, TxKind, EOF_MAGIC_BYTES, }, Context, ContextWithHandlerCfg, Frame, FrameOrResult, FrameResult, }; @@ -329,11 +329,11 @@ impl Evm<'_, EXT, DB> { let pre_exec = self.handler.pre_execution(); // load access list and beneficiary if needed. - pre_exec.load_accounts(ctx)?; + pre_exec.load_accounts(ctx, ctx.evm.env.cfg.chain_id)?; // load precompiles let precompiles = pre_exec.load_precompiles(); - ctx.evm.set_precompiles(precompiles); + ctx.evm.set_precompiles(ctx.evm.env.cfg.chain_id, precompiles); // deduce caller balance with its limit. pre_exec.deduct_caller(ctx)?; @@ -346,11 +346,11 @@ impl Evm<'_, EXT, DB> { let exec = self.handler.execution(); // call inner handling of call/create let first_frame_or_result = match ctx.evm.env.tx.transact_to { - TxKind::Call(_) => exec.call( + TransactTo::Call(_) => exec.call( ctx, CallInputs::new_boxed(&ctx.evm.env.tx, gas_limit).unwrap(), )?, - TxKind::Create => { + TransactTo::Create => { // if first byte of data is magic 0xEF00, then it is EOFCreate. if spec_id.is_enabled_in(SpecId::PRAGUE_EOF) && ctx.env().tx.data.starts_with(&EOF_MAGIC_BYTES) diff --git a/crates/revm/src/handler/handle_types.rs b/crates/revm/src/handler/handle_types.rs index 28f1e59241..cc26590cd5 100644 --- a/crates/revm/src/handler/handle_types.rs +++ b/crates/revm/src/handler/handle_types.rs @@ -12,7 +12,7 @@ pub use execution::{ ExecutionHandler, FrameCallHandle, FrameCallReturnHandle, FrameCreateHandle, FrameCreateReturnHandle, InsertCallOutcomeHandle, InsertCreateOutcomeHandle, }; -pub use generic::{GenericContextHandle, GenericContextHandleRet}; +pub use generic::{GenericContextHandle, GenericContextHandleRet, GenericContextHandleChain}; pub use post_execution::{ EndHandle, OutputHandle, PostExecutionHandler, ReimburseCallerHandle, RewardBeneficiaryHandle, }; diff --git a/crates/revm/src/handler/handle_types/generic.rs b/crates/revm/src/handler/handle_types/generic.rs index e9d239311c..434e490676 100644 --- a/crates/revm/src/handler/handle_types/generic.rs +++ b/crates/revm/src/handler/handle_types/generic.rs @@ -10,3 +10,10 @@ pub type GenericContextHandle<'a, EXT, DB> = GenericContextHandleRet<'a, EXT, DB /// Generic handle that takes a mutable reference to the context and returns a result. pub type GenericContextHandleRet<'a, EXT, DB, ReturnT> = Arc) -> EVMResultGeneric::Error> + 'a>; + +/// Generic Handle that takes a mutable reference to the context and returns a result. +pub type GenericContextHandleChain<'a, EXT, DB> = GenericContextHandleRetChain<'a, EXT, DB, ()>; + +/// Generic handle that takes a mutable reference to the context and returns a result. +pub type GenericContextHandleRetChain<'a, EXT, DB, ReturnT> = + Arc, u64) -> EVMResultGeneric::Error> + 'a>; diff --git a/crates/revm/src/handler/handle_types/pre_execution.rs b/crates/revm/src/handler/handle_types/pre_execution.rs index 2645b03a19..e64c6081e1 100644 --- a/crates/revm/src/handler/handle_types/pre_execution.rs +++ b/crates/revm/src/handler/handle_types/pre_execution.rs @@ -1,5 +1,5 @@ // Includes. -use super::{GenericContextHandle, GenericContextHandleRet}; +use super::{GenericContextHandle, GenericContextHandleRet, GenericContextHandleChain}; use crate::{ handler::mainnet, primitives::{db::Database, EVMError, Spec}, @@ -13,7 +13,7 @@ pub type LoadPrecompilesHandle<'a, DB> = Arc ContextPrecompiles /// Load access list accounts and beneficiary. /// There is no need to load Caller as it is assumed that /// it will be loaded in DeductCallerHandle. -pub type LoadAccountsHandle<'a, EXT, DB> = GenericContextHandle<'a, EXT, DB>; +pub type LoadAccountsHandle<'a, EXT, DB> = GenericContextHandleChain<'a, EXT, DB>; /// Deduct the caller to its limit. pub type DeductCallerHandle<'a, EXT, DB> = GenericContextHandle<'a, EXT, DB>; @@ -52,8 +52,8 @@ impl<'a, EXT, DB: Database> PreExecutionHandler<'a, EXT, DB> { } /// Main load - pub fn load_accounts(&self, context: &mut Context) -> Result<(), EVMError> { - (self.load_accounts)(context) + pub fn load_accounts(&self, context: &mut Context, chain_id: u64) -> Result<(), EVMError> { + (self.load_accounts)(context, chain_id) } /// Apply EIP-7702 auth list and return gas refund on account that were already present. diff --git a/crates/revm/src/handler/mainnet/execution.rs b/crates/revm/src/handler/mainnet/execution.rs index f39cbf0ac5..a189e96c41 100644 --- a/crates/revm/src/handler/mainnet/execution.rs +++ b/crates/revm/src/handler/mainnet/execution.rs @@ -5,7 +5,7 @@ use crate::{ return_ok, return_revert, CallInputs, CreateInputs, CreateOutcome, Gas, InstructionResult, SharedMemory, }, - primitives::{EVMError, Spec}, + primitives::{ChainAddress, EVMError, Spec}, CallFrame, Context, CreateFrame, Frame, FrameOrResult, FrameResult, }; use core::mem; @@ -118,7 +118,7 @@ pub fn create_return( ) -> Result> { context.evm.create_return::( &mut interpreter_result, - frame.created_address, + ChainAddress(frame.frame_data.interpreter.chain_id, frame.created_address), frame.frame_data.checkpoint, ); Ok(CreateOutcome::new( @@ -158,7 +158,7 @@ pub fn eofcreate_return( ) -> Result> { context.evm.eofcreate_return::( &mut interpreter_result, - frame.created_address, + ChainAddress(frame.frame_data.interpreter.chain_id, frame.created_address), frame.frame_data.checkpoint, ); Ok(CreateOutcome::new( diff --git a/crates/revm/src/handler/mainnet/pre_execution.rs b/crates/revm/src/handler/mainnet/pre_execution.rs index 60933ef44f..dd345b3447 100644 --- a/crates/revm/src/handler/mainnet/pre_execution.rs +++ b/crates/revm/src/handler/mainnet/pre_execution.rs @@ -6,9 +6,9 @@ use crate::{ precompile::PrecompileSpecId, primitives::{ db::Database, - eip7702, Account, Bytecode, EVMError, Env, Spec, + eip7702, Account, Bytecode, ChainAddress, EVMError, Env, Spec, SpecId::{CANCUN, PRAGUE, SHANGHAI}, - TxKind, BLOCKHASH_STORAGE_ADDRESS, U256, + TransactTo, TxKind, BLOCKHASH_STORAGE_ADDRESS, U256, }, Context, ContextPrecompiles, }; @@ -23,6 +23,7 @@ pub fn load_precompiles() -> ContextPrecompiles { #[inline] pub fn load_accounts( context: &mut Context, + chain_id: u64, ) -> Result<(), EVMError> { // set journaling state flag. context.evm.journaled_state.set_spec_id(SPEC::SPEC_ID); @@ -45,11 +46,11 @@ pub fn load_accounts( .evm .journaled_state .warm_preloaded_addresses - .insert(BLOCKHASH_STORAGE_ADDRESS); + .insert(ChainAddress(chain_id, BLOCKHASH_STORAGE_ADDRESS)); } // Load access list - context.evm.load_access_list()?; + context.evm.load_access_list(chain_id)?; Ok(()) } @@ -70,7 +71,7 @@ pub fn deduct_caller_inner(caller_account: &mut Account, env: &Env) caller_account.info.balance = caller_account.info.balance.saturating_sub(gas_cost); // bump the nonce for calls. Nonce for CREATE will be bumped in `handle_create`. - if matches!(env.tx.transact_to, TxKind::Call(_)) { + if matches!(env.tx.transact_to, TransactTo::Call(_)) { // Nonce is already checked caller_account.info.nonce = caller_account.info.nonce.saturating_add(1); } @@ -133,7 +134,7 @@ pub fn apply_eip7702_auth_list( .evm .inner .journaled_state - .load_code(authority, &mut context.evm.inner.db)?; + .load_code(ChainAddress(authorization.chain_id().as_limbs()[0], authority), &mut context.evm.inner.db)?; // 4. Verify the code of authority is either empty or already delegated. if let Some(bytecode) = &authority_acc.info.code { diff --git a/crates/revm/src/inspector.rs b/crates/revm/src/inspector.rs index 046ec50761..025a0138ce 100644 --- a/crates/revm/src/inspector.rs +++ b/crates/revm/src/inspector.rs @@ -12,7 +12,7 @@ use crate::{ interpreter::{ CallInputs, CallOutcome, CreateInputs, CreateOutcome, EOFCreateInputs, Interpreter, }, - primitives::{db::Database, Address, Log, U256}, + primitives::{db::Database, Address, ChainAddress, Log, U256}, EvmContext, }; use auto_impl::auto_impl; @@ -162,7 +162,7 @@ pub trait Inspector { /// Called when a contract has been self-destructed with funds transferred to target. #[inline] - fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { + fn selfdestruct(&mut self, contract: ChainAddress, target: ChainAddress, value: U256) { let _ = contract; let _ = target; let _ = value; diff --git a/crates/revm/src/inspector/customprinter.rs b/crates/revm/src/inspector/customprinter.rs index ed42c4f7b4..b5d195cf7e 100644 --- a/crates/revm/src/inspector/customprinter.rs +++ b/crates/revm/src/inspector/customprinter.rs @@ -8,7 +8,7 @@ use revm_interpreter::OpCode; use crate::{ inspectors::GasInspector, interpreter::{CallInputs, CreateInputs, Interpreter}, - primitives::{Address, U256}, + primitives::{Address, ChainAddress, U256}, Database, EvmContext, Inspector, }; @@ -103,7 +103,7 @@ impl Inspector for CustomPrintTracer { None } - fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { + fn selfdestruct(&mut self, contract: ChainAddress, target: ChainAddress, value: U256) { println!( "SELFDESTRUCT: contract: {:?}, refund target: {:?}, value {:?}", contract, target, value @@ -116,13 +116,14 @@ mod test { use crate::{ inspector_handle_register, inspectors::CustomPrintTracer, - primitives::{address, bytes, SpecId}, + primitives::{address, bytes, SpecId, ChainAddress}, Evm, InMemoryDB, }; #[test] fn gas_calculation_underflow() { - let callee = address!("5fdcca53617f4d2b9134b29090c87d01058e27e9"); + let chain_id = 0; + let callee = ChainAddress(chain_id, address!("5fdcca53617f4d2b9134b29090c87d01058e27e9")); // https://github.com/bluealloy/revm/issues/277 // checks this use case @@ -139,7 +140,7 @@ mod test { db.insert_account_info(callee, info); }) .modify_tx_env(|tx| { - tx.caller = address!("5fdcca53617f4d2b9134b29090c87d01058e27e0"); + tx.caller = ChainAddress(chain_id, address!("5fdcca53617f4d2b9134b29090c87d01058e27e0")); tx.transact_to = crate::primitives::TxKind::Call(callee); tx.data = crate::primitives::Bytes::new(); tx.value = crate::primitives::U256::ZERO; diff --git a/crates/revm/src/inspector/gas.rs b/crates/revm/src/inspector/gas.rs index 69f961efa4..77d610a34c 100644 --- a/crates/revm/src/inspector/gas.rs +++ b/crates/revm/src/inspector/gas.rs @@ -89,7 +89,7 @@ mod tests { use crate::{ inspectors::GasInspector, interpreter::{CallInputs, CreateInputs, Interpreter}, - primitives::Log, + primitives::{Log, ChainAddress}, Database, EvmContext, Inspector, }; @@ -188,8 +188,8 @@ mod tests { .with_external_context(StackInspector::default()) .modify_tx_env(|tx| { tx.clear(); - tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); + tx.caller = ChainAddress(0, address!("1000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(ChainAddress(0, address!("0000000000000000000000000000000000000000"))); tx.gas_limit = 21100; }) .append_handler_register(inspector_handle_register) diff --git a/crates/revm/src/journaled_state.rs b/crates/revm/src/journaled_state.rs index 2d84032987..75c5dbbce5 100644 --- a/crates/revm/src/journaled_state.rs +++ b/crates/revm/src/journaled_state.rs @@ -10,6 +10,7 @@ use crate::{ }; use core::mem; use std::vec::Vec; +use crate::primitives::ChainAddress; /// A journal of state changes internal to the EVM. /// @@ -45,7 +46,7 @@ pub struct JournaledState { /// /// Note that this not include newly loaded accounts, account and storage /// is considered warm if it is found in the `State`. - pub warm_preloaded_addresses: HashSet
, + pub warm_preloaded_addresses: HashSet, } impl JournaledState { @@ -58,7 +59,7 @@ impl JournaledState { /// /// This function will journal state after Spurious Dragon fork. /// And will not take into account if account is not existing or empty. - pub fn new(spec: SpecId, warm_preloaded_addresses: HashSet
) -> JournaledState { + pub fn new(spec: SpecId, warm_preloaded_addresses: HashSet) -> JournaledState { Self { state: HashMap::new(), transient_storage: TransientStorage::default(), @@ -86,7 +87,7 @@ impl JournaledState { /// This is especially important for state clear where touched empty accounts needs to /// be removed from state. #[inline] - pub fn touch(&mut self, address: &Address) { + pub fn touch(&mut self, address: &ChainAddress) { if let Some(account) = self.state.get_mut(address) { Self::touch_account(self.journal.last_mut().unwrap(), address, account); } @@ -94,7 +95,7 @@ impl JournaledState { /// Mark account as touched. #[inline] - fn touch_account(journal: &mut Vec, address: &Address, account: &mut Account) { + fn touch_account(journal: &mut Vec, address: &ChainAddress, account: &mut Account) { if !account.is_touched() { journal.push(JournalEntry::AccountTouched { address: *address }); account.mark_touch(); @@ -140,7 +141,7 @@ impl JournaledState { /// /// Panics if the account has not been loaded and is missing from the state set. #[inline] - pub fn account(&self, address: Address) -> &Account { + pub fn account(&self, address: ChainAddress) -> &Account { self.state .get(&address) .expect("Account expected to be loaded") // Always assume that acc is already loaded @@ -156,7 +157,7 @@ impl JournaledState { /// /// Note: Assume account is warm and that hash is calculated from code. #[inline] - pub fn set_code_with_hash(&mut self, address: Address, code: Bytecode, hash: B256) { + pub fn set_code_with_hash(&mut self, address: ChainAddress, code: Bytecode, hash: B256) { let account = self.state.get_mut(&address).unwrap(); Self::touch_account(self.journal.last_mut().unwrap(), &address, account); @@ -172,13 +173,13 @@ impl JournaledState { /// use it only if you know that acc is warm /// Assume account is warm #[inline] - pub fn set_code(&mut self, address: Address, code: Bytecode) { + pub fn set_code(&mut self, address: ChainAddress, code: Bytecode) { let hash = code.hash_slow(); self.set_code_with_hash(address, code, hash) } #[inline] - pub fn inc_nonce(&mut self, address: Address) -> Option { + pub fn inc_nonce(&mut self, address: ChainAddress) -> Option { let account = self.state.get_mut(&address).unwrap(); // Check if nonce is going to overflow. if account.info.nonce == u64::MAX { @@ -199,8 +200,8 @@ impl JournaledState { #[inline] pub fn transfer( &mut self, - from: &Address, - to: &Address, + from: &ChainAddress, + to: &ChainAddress, balance: U256, db: &mut DB, ) -> Result, EVMError> { @@ -258,8 +259,8 @@ impl JournaledState { #[inline] pub fn create_account_checkpoint( &mut self, - caller: Address, - address: Address, + caller: ChainAddress, + address: ChainAddress, balance: U256, spec_id: SpecId, ) -> Result { @@ -332,7 +333,7 @@ impl JournaledState { state.get_mut(&address).unwrap().mark_cold(); } JournalEntry::AccountTouched { address } => { - if is_spurious_dragon_enabled && address == PRECOMPILE3 { + if is_spurious_dragon_enabled && address.1 == PRECOMPILE3 { continue; } // remove touched status @@ -483,8 +484,8 @@ impl JournaledState { #[inline] pub fn selfdestruct( &mut self, - address: Address, - target: Address, + address: ChainAddress, + target: ChainAddress, db: &mut DB, ) -> Result, EVMError> { let spec = self.spec; @@ -550,7 +551,7 @@ impl JournaledState { #[inline] pub fn initial_account_load( &mut self, - address: Address, + address: ChainAddress, storage_keys: impl IntoIterator, db: &mut DB, ) -> Result<&mut Account, EVMError> { @@ -580,7 +581,7 @@ impl JournaledState { #[inline] pub fn load_account( &mut self, - address: Address, + address: ChainAddress, db: &mut DB, ) -> Result, EVMError> { let load = match self.state.entry(address) { @@ -624,13 +625,14 @@ impl JournaledState { #[inline] pub fn load_account_delegated( &mut self, - address: Address, + address: ChainAddress, db: &mut DB, ) -> Result> { let spec = self.spec; let account = self.load_code(address, db)?; let is_empty = account.state_clear_aware_is_empty(spec); + let chain_id = address.0; let mut account_load = AccountLoad { is_empty, load: Eip7702CodeLoad::new_not_delegated((), account.is_cold), @@ -638,7 +640,7 @@ impl JournaledState { // load delegate code if account is EIP-7702 if let Some(Bytecode::Eip7702(code)) = &account.info.code { let address = code.address(); - let delegate_account = self.load_account(address, db)?; + let delegate_account = self.load_account(ChainAddress(chain_id, address), db)?; account_load .load .set_delegate_load(delegate_account.is_cold); @@ -651,7 +653,7 @@ impl JournaledState { #[inline] pub fn load_code( &mut self, - address: Address, + address: ChainAddress, db: &mut DB, ) -> Result, EVMError> { let account_load = self.load_account(address, db)?; @@ -661,7 +663,7 @@ impl JournaledState { let empty = Bytecode::default(); acc.code = Some(empty); } else { - let code = db.code_by_hash(acc.code_hash).map_err(EVMError::Database)?; + let code = db.code_by_hash(address.0, acc.code_hash).map_err(EVMError::Database)?; acc.code = Some(code); } } @@ -676,7 +678,7 @@ impl JournaledState { #[inline] pub fn sload( &mut self, - address: Address, + address: ChainAddress, key: U256, db: &mut DB, ) -> Result, EVMError> { @@ -724,7 +726,7 @@ impl JournaledState { #[inline] pub fn sstore( &mut self, - address: Address, + address: ChainAddress, key: U256, new: U256, db: &mut DB, @@ -772,7 +774,7 @@ impl JournaledState { /// /// EIP-1153: Transient storage opcodes #[inline] - pub fn tload(&mut self, address: Address, key: U256) -> U256 { + pub fn tload(&mut self, address: ChainAddress, key: U256) -> U256 { self.transient_storage .get(&(address, key)) .copied() @@ -786,7 +788,7 @@ impl JournaledState { /// /// EIP-1153: Transient storage opcodes #[inline] - pub fn tstore(&mut self, address: Address, key: U256, new: U256) { + pub fn tstore(&mut self, address: ChainAddress, key: U256, new: U256) { let had_value = if new.is_zero() { // if new values is zero, remove entry from transient storage. // if previous values was some insert it inside journal. @@ -835,13 +837,13 @@ pub enum JournalEntry { /// Used to mark account that is warm inside EVM in regards to EIP-2929 AccessList. /// Action: We will add Account to state. /// Revert: we will remove account from state. - AccountWarmed { address: Address }, + AccountWarmed { address: ChainAddress }, /// Mark account to be destroyed and journal balance to be reverted /// Action: Mark account and transfer the balance /// Revert: Unmark the account and transfer balance back AccountDestroyed { - address: Address, - target: Address, + address: ChainAddress, + target: ChainAddress, was_destroyed: bool, // if account had already been destroyed before this journal entry had_balance: U256, }, @@ -849,49 +851,49 @@ pub enum JournalEntry { /// Only when account is called (to execute contract or transfer balance) only then account is made touched. /// Action: Mark account touched /// Revert: Unmark account touched - AccountTouched { address: Address }, + AccountTouched { address: ChainAddress }, /// Transfer balance between two accounts /// Action: Transfer balance /// Revert: Transfer balance back BalanceTransfer { - from: Address, - to: Address, + from: ChainAddress, + to: ChainAddress, balance: U256, }, /// Increment nonce /// Action: Increment nonce by one /// Revert: Decrement nonce by one NonceChange { - address: Address, //geth has nonce value, + address: ChainAddress, //geth has nonce value, }, /// Create account: /// Actions: Mark account as created /// Revert: Unmart account as created and reset nonce to zero. - AccountCreated { address: Address }, + AccountCreated { address: ChainAddress }, /// Entry used to track storage changes /// Action: Storage change /// Revert: Revert to previous value StorageChanged { - address: Address, + address: ChainAddress, key: U256, had_value: U256, }, /// Entry used to track storage warming introduced by EIP-2929. /// Action: Storage warmed /// Revert: Revert to cold state - StorageWarmed { address: Address, key: U256 }, + StorageWarmed { address: ChainAddress, key: U256 }, /// It is used to track an EIP-1153 transient storage change. /// Action: Transient storage changed. /// Revert: Revert to previous value. TransientStorageChange { - address: Address, + address: ChainAddress, key: U256, had_value: U256, }, /// Code changed /// Action: Account code changed /// Revert: Revert to previous bytecode. - CodeChange { address: Address }, + CodeChange { address: ChainAddress }, } /// SubRoutine checkpoint that will help us to go back from this diff --git a/examples/fork_ref_transact.rs b/examples/fork_ref_transact.rs index 014e2b1941..c8ff5bcdaf 100644 --- a/examples/fork_ref_transact.rs +++ b/examples/fork_ref_transact.rs @@ -3,13 +3,14 @@ use alloy_sol_types::SolCall; use ethers_providers::{Http, Provider}; use revm::{ db::{CacheDB, EmptyDB, EthersDB}, - primitives::{address, ExecutionResult, Output, TxKind, U256}, + primitives::{address, ExecutionResult, Output, TxKind, U256, ChainAddress}, Database, Evm, }; use std::sync::Arc; #[tokio::main] async fn main() -> anyhow::Result<()> { + let chain_id = 1; // create ethers client and wrap it in Arc let client = Provider::::try_from( "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27", @@ -32,7 +33,7 @@ async fn main() -> anyhow::Result<()> { let slot = U256::from(8); // ETH/USDT pair on Uniswap V2 - let pool_address = address!("0d4a11d5EEaaC28EC3F61d100daF4d40471f1852"); + let pool_address = ChainAddress(chain_id, address!("0d4a11d5EEaaC28EC3F61d100daF4d40471f1852")); // generate abi for the calldata from the human readable interface sol! { @@ -68,7 +69,7 @@ async fn main() -> anyhow::Result<()> { .modify_tx_env(|tx| { // fill in missing bits of env struct // change that to whatever caller you want to be - tx.caller = address!("0000000000000000000000000000000000000000"); + tx.caller = ChainAddress(chain_id, address!("0000000000000000000000000000000000000000")); // account you want to transact with tx.transact_to = TxKind::Call(pool_address); // calldata formed via abigen From 74e2637cdfcf9429b1688894c3c01980347beb20 Mon Sep 17 00:00:00 2001 From: Brecht Devos Date: Sun, 15 Sep 2024 04:32:31 +0900 Subject: [PATCH 2/8] fix call and tests --- crates/interpreter/src/instructions/contract.rs | 2 +- crates/revm/src/builder.rs | 12 +++++++----- crates/revm/src/context/evm_context.rs | 12 +++++++----- crates/revm/src/db/emptydb.rs | 7 ++++--- crates/revm/src/db/states/state.rs | 2 +- crates/revm/src/evm.rs | 7 ++++--- crates/revm/src/inspector/customprinter.rs | 2 +- crates/revm/src/inspector/gas.rs | 4 ++-- crates/revm/src/inspector/handler_register.rs | 7 ++++--- 9 files changed, 31 insertions(+), 24 deletions(-) diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index 771d609fc4..0072cc8d60 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -627,7 +627,7 @@ pub fn apply_call_options(interpreter: &mut Interp CallTargets { target_address: if delegate || code { interpreter.contract.target_address } else { to }, - caller: if code { interpreter.contract.caller } else { interpreter.contract.target_address }, + caller: if delegate { interpreter.contract.caller } else { interpreter.contract.target_address }, bytecode_address: to, } } \ No newline at end of file diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index 1ce88486ba..706ce3c198 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -444,7 +444,7 @@ mod test { inspector::inspector_handle_register, inspectors::NoOpInspector, primitives::{ - address, AccountInfo, Address, Bytecode, Bytes, PrecompileResult, TxKind, U256, + address, AccountInfo, Address, Bytecode, Bytes, ChainAddress, PrecompileResult, TransactTo, TxKind, U256, }, Context, ContextPrecompile, ContextStatefulPrecompile, Evm, InMemoryDB, InnerEvmContext, }; @@ -460,9 +460,10 @@ mod test { #[test] fn simple_add_stateful_instruction() { + let chain_id = 1; let code = Bytecode::new_raw([0xED, 0x00].into()); let code_hash = code.hash_slow(); - let to_addr = address!("ffffffffffffffffffffffffffffffffffffffff"); + let to_addr = ChainAddress(chain_id, address!("ffffffffffffffffffffffffffffffffffffffff")); // initialize the custom context and make sure it's zero let custom_context = CustomContext::default(); @@ -474,7 +475,7 @@ mod test { .modify_db(|db| { db.insert_account_info(to_addr, AccountInfo::new(U256::ZERO, 0, code_hash, code)) }) - .modify_tx_env(|tx| tx.transact_to = TxKind::Call(to_addr)) + .modify_tx_env(|tx| tx.transact_to = TransactTo::Call(to_addr)) // we need to use handle register box to capture the custom context in the handle // register .append_handler_register_box(Box::new(move |handler| { @@ -505,6 +506,7 @@ mod test { #[test] fn simple_add_instruction() { + let chain_id = 1; const CUSTOM_INSTRUCTION_COST: u64 = 133; const INITIAL_TX_GAS: u64 = 21000; const EXPECTED_RESULT_GAS: u64 = INITIAL_TX_GAS + CUSTOM_INSTRUCTION_COST; @@ -516,14 +518,14 @@ mod test { let code = Bytecode::new_raw([0xED, 0x00].into()); let code_hash = code.hash_slow(); - let to_addr = address!("ffffffffffffffffffffffffffffffffffffffff"); + let to_addr = ChainAddress(chain_id, address!("ffffffffffffffffffffffffffffffffffffffff")); let mut evm = Evm::builder() .with_db(InMemoryDB::default()) .modify_db(|db| { db.insert_account_info(to_addr, AccountInfo::new(U256::ZERO, 0, code_hash, code)) }) - .modify_tx_env(|tx| tx.transact_to = TxKind::Call(to_addr)) + .modify_tx_env(|tx| tx.transact_to = TransactTo::Call(to_addr)) .append_handler_register(|handler| { handler.instruction_table.insert(0xED, custom_instruction) }) diff --git a/crates/revm/src/context/evm_context.rs b/crates/revm/src/context/evm_context.rs index bfc420184b..213ce75fab 100644 --- a/crates/revm/src/context/evm_context.rs +++ b/crates/revm/src/context/evm_context.rs @@ -488,15 +488,16 @@ pub(crate) mod test_utils { }; /// Mock caller address. - pub const MOCK_CALLER: Address = address!("0000000000000000000000000000000000000000"); + pub const MOCK_CALLER: ChainAddress = ChainAddress(1, address!("0000000000000000000000000000000000000000")); /// Creates `CallInputs` that calls a provided contract address from the mock caller. pub fn create_mock_call_inputs(to: Address) -> CallInputs { + let chain_id = 1; CallInputs { input: Bytes::new(), gas_limit: 0, - bytecode_address: to, - target_address: to, + bytecode_address: ChainAddress(chain_id, to), + target_address: ChainAddress(chain_id, to), caller: MOCK_CALLER, value: CallValue::Transfer(U256::ZERO), scheme: revm_interpreter::CallScheme::Call, @@ -611,7 +612,7 @@ mod tests { result.interpreter_result().result, InstructionResult::OutOfFunds ); - let checkpointed = vec![vec![JournalEntry::AccountWarmed { address: contract }]]; + let checkpointed = vec![vec![JournalEntry::AccountWarmed { address: call_inputs.bytecode_address }]]; assert_eq!(evm_context.journaled_state.journal, checkpointed); assert_eq!(evm_context.journaled_state.depth, 0); } @@ -633,13 +634,14 @@ mod tests { #[test] fn test_make_call_frame_succeeds() { + let chain_id = 1; let env = Env::default(); let mut cdb = CacheDB::new(EmptyDB::default()); let bal = U256::from(3_000_000_000_u128); let by = Bytecode::new_raw(Bytes::from(vec![0x60, 0x00, 0x60, 0x00])); let contract = address!("dead10000000000000000000000000000001dead"); cdb.insert_account_info( - contract, + ChainAddress(chain_id, contract), crate::primitives::AccountInfo { nonce: 0, balance: bal, diff --git a/crates/revm/src/db/emptydb.rs b/crates/revm/src/db/emptydb.rs index e945ac61ee..e6572ce387 100644 --- a/crates/revm/src/db/emptydb.rs +++ b/crates/revm/src/db/emptydb.rs @@ -108,23 +108,24 @@ mod tests { #[test] fn conform_block_hash_calculation() { + let chain_id = 1; let db = EmptyDB::new(); assert_eq!( - db.block_hash_ref(0u64), + db.block_hash_ref(chain_id, 0u64), Ok(b256!( "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d" )) ); assert_eq!( - db.block_hash_ref(1u64), + db.block_hash_ref(chain_id, 1u64), Ok(b256!( "c89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6" )) ); assert_eq!( - db.block_hash_ref(100u64), + db.block_hash_ref(chain_id, 100u64), Ok(b256!( "8c18210df0d9514f2d2e5d8ca7c100978219ee80d3968ad850ab5ead208287b3" )) diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index fd0678b19b..46abc3dfd0 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -12,7 +12,7 @@ use std::{ collections::{btree_map, BTreeMap}, vec::Vec, }; -use crate::primitives::ChainAddress; +use crate::primitives::{Address, ChainAddress}; /// Database boxed with a lifetime and Send. pub type DBBox<'a, E> = Box + Send + 'a>; diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index 5df527e312..3c46bcb794 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -406,6 +406,7 @@ mod tests { #[test] fn sanity_eip7702_tx() { + let chain_id = 1; let delegate = address!("0000000000000000000000000000000000000000"); let caller = address!("0000000000000000000000000000000000000001"); let auth = address!("0000000000000000000000000000000000000100"); @@ -428,14 +429,14 @@ mod tests { )] .into(), ); - tx.caller = caller; - tx.transact_to = TxKind::Call(auth); + tx.caller = ChainAddress(chain_id, caller); + tx.transact_to = TransactTo::Call(ChainAddress(chain_id, auth)); }) .build(); let ok = evm.transact().unwrap(); - let auth_acc = ok.state.get(&auth).unwrap(); + let auth_acc = ok.state.get(&ChainAddress(chain_id, auth)).unwrap(); assert_eq!(auth_acc.info.code, Some(Bytecode::new_eip7702(delegate))); assert_eq!(auth_acc.info.nonce, 1); assert_eq!( diff --git a/crates/revm/src/inspector/customprinter.rs b/crates/revm/src/inspector/customprinter.rs index b5d195cf7e..09c5a42a4c 100644 --- a/crates/revm/src/inspector/customprinter.rs +++ b/crates/revm/src/inspector/customprinter.rs @@ -141,7 +141,7 @@ mod test { }) .modify_tx_env(|tx| { tx.caller = ChainAddress(chain_id, address!("5fdcca53617f4d2b9134b29090c87d01058e27e0")); - tx.transact_to = crate::primitives::TxKind::Call(callee); + tx.transact_to = crate::primitives::TransactTo::Call(callee); tx.data = crate::primitives::Bytes::new(); tx.value = crate::primitives::U256::ZERO; }) diff --git a/crates/revm/src/inspector/gas.rs b/crates/revm/src/inspector/gas.rs index 77d610a34c..9faa529eb8 100644 --- a/crates/revm/src/inspector/gas.rs +++ b/crates/revm/src/inspector/gas.rs @@ -89,7 +89,7 @@ mod tests { use crate::{ inspectors::GasInspector, interpreter::{CallInputs, CreateInputs, Interpreter}, - primitives::{Log, ChainAddress}, + primitives::{Log, ChainAddress, TransactTo}, Database, EvmContext, Inspector, }; @@ -189,7 +189,7 @@ mod tests { .modify_tx_env(|tx| { tx.clear(); tx.caller = ChainAddress(0, address!("1000000000000000000000000000000000000000")); - tx.transact_to = TxKind::Call(ChainAddress(0, address!("0000000000000000000000000000000000000000"))); + tx.transact_to = TransactTo::Call(ChainAddress(0, address!("0000000000000000000000000000000000000000"))); tx.gas_limit = 21100; }) .append_handler_register(inspector_handle_register) diff --git a/crates/revm/src/inspector/handler_register.rs b/crates/revm/src/inspector/handler_register.rs index 599ab9fc6a..7248b3fa67 100644 --- a/crates/revm/src/inspector/handler_register.rs +++ b/crates/revm/src/inspector/handler_register.rs @@ -336,10 +336,11 @@ mod tests { db::BenchmarkDB, inspector::inspector_handle_register, interpreter::opcode, - primitives::{address, Bytecode, Bytes, TxKind}, + primitives::{address, Bytecode, Bytes, ChainAddress, TxKind, TransactTo}, Evm, }; + let chain_id = 1; let contract_data: Bytes = Bytes::from(vec![ opcode::PUSH1, 0x1, @@ -361,8 +362,8 @@ mod tests { .with_external_context(StackInspector::default()) .modify_tx_env(|tx| { tx.clear(); - tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); + tx.caller = ChainAddress(chain_id, address!("1000000000000000000000000000000000000000")); + tx.transact_to = TransactTo::Call(ChainAddress(chain_id, address!("0000000000000000000000000000000000000000"))); tx.gas_limit = 21100; }) .append_handler_register(inspector_handle_register) From 2eb6e3d600edf2d975a0739c31250ab5d6d84c43 Mon Sep 17 00:00:00 2001 From: Brecht Devos Date: Mon, 16 Sep 2024 02:31:53 +0900 Subject: [PATCH 3/8] make ethereum tests compile --- bins/revme/src/cmd/evmrunner.rs | 8 ++++---- bins/revme/src/cmd/statetest/merkle_trie.rs | 6 +++--- bins/revme/src/cmd/statetest/runner.rs | 15 +++++++-------- crates/interpreter/src/interpreter/serde.rs | 3 +++ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bins/revme/src/cmd/evmrunner.rs b/bins/revme/src/cmd/evmrunner.rs index 6d1b664264..3139ca9e0b 100644 --- a/bins/revme/src/cmd/evmrunner.rs +++ b/bins/revme/src/cmd/evmrunner.rs @@ -2,7 +2,7 @@ use revm::{ db::BenchmarkDB, inspector_handle_register, inspectors::TracerEip3155, - primitives::{Address, Bytecode, BytecodeDecodeError, TxKind}, + primitives::{Address, Bytecode, BytecodeDecodeError, ChainAddress, TransactTo, TxKind}, Evm, }; use std::io::Error as IoError; @@ -79,10 +79,10 @@ impl Cmd { )?)) .modify_tx_env(|tx| { // execution globals block hash/gas_limit/coinbase/timestamp.. - tx.caller = "0x0000000000000000000000000000000000000001" + tx.caller = ChainAddress(1, "0x0000000000000000000000000000000000000001" .parse() - .unwrap(); - tx.transact_to = TxKind::Call(Address::ZERO); + .unwrap()); + tx.transact_to = TransactTo::Call(ChainAddress(1, Address::ZERO)); tx.data = input; }) .build(); diff --git a/bins/revme/src/cmd/statetest/merkle_trie.rs b/bins/revme/src/cmd/statetest/merkle_trie.rs index b7a97cd7c7..5f1fe92f7d 100644 --- a/bins/revme/src/cmd/statetest/merkle_trie.rs +++ b/bins/revme/src/cmd/statetest/merkle_trie.rs @@ -3,7 +3,7 @@ use hash_db::Hasher; use plain_hasher::PlainHasher; use revm::{ db::PlainAccount, - primitives::{keccak256, Address, Log, B256, U256}, + primitives::{keccak256, Address, ChainAddress, Log, B256, U256}, }; use triehash::sec_trie_root; @@ -14,11 +14,11 @@ pub fn log_rlp_hash(logs: &[Log]) -> B256 { } pub fn state_merkle_trie_root<'a>( - accounts: impl IntoIterator, + accounts: impl IntoIterator, ) -> B256 { trie_root(accounts.into_iter().map(|(address, acc)| { ( - address, + address.1, alloy_rlp::encode_fixed_size(&TrieAccount::new(acc)), ) })) diff --git a/bins/revme/src/cmd/statetest/runner.rs b/bins/revme/src/cmd/statetest/runner.rs index c6851cdd2e..c39d481fc8 100644 --- a/bins/revme/src/cmd/statetest/runner.rs +++ b/bins/revme/src/cmd/statetest/runner.rs @@ -10,8 +10,7 @@ use revm::{ inspectors::TracerEip3155, interpreter::analysis::to_analysed, primitives::{ - calc_excess_blob_gas, keccak256, Bytecode, Bytes, EVMResultGeneric, Env, ExecutionResult, - SpecId, TxKind, B256, + calc_excess_blob_gas, keccak256, Bytecode, Bytes, ChainAddress, EVMResultGeneric, Env, ExecutionResult, SpecId, TransactTo, TxKind, B256 }, Evm, State, }; @@ -274,7 +273,7 @@ pub fn execute_test_suite( code: Some(bytecode), nonce: info.nonce, }; - cache_state.insert_account_with_storage(address, acc_info, info.storage); + cache_state.insert_account_with_storage(ChainAddress(1, address), acc_info, info.storage); } let mut env = Box::::default(); @@ -284,7 +283,7 @@ pub fn execute_test_suite( // block env env.block.number = unit.env.current_number; - env.block.coinbase = unit.env.current_coinbase; + env.block.coinbase = ChainAddress(1, unit.env.current_coinbase); env.block.timestamp = unit.env.current_timestamp; env.block.gas_limit = unit.env.current_gas_limit; env.block.basefee = unit.env.current_base_fee.unwrap_or_default(); @@ -307,14 +306,14 @@ pub fn execute_test_suite( } // tx env - env.tx.caller = if let Some(address) = unit.transaction.sender { + env.tx.caller = ChainAddress(1, if let Some(address) = unit.transaction.sender { address } else { recover_address(unit.transaction.secret_key.as_slice()).ok_or_else(|| TestError { name: name.clone(), kind: TestErrorKind::UnknownPrivateKey(unit.transaction.secret_key), })? - }; + }); env.tx.gas_price = unit .transaction .gas_price @@ -365,8 +364,8 @@ pub fn execute_test_suite( env.tx.authorization_list = auth_list; let to = match unit.transaction.to { - Some(add) => TxKind::Call(add), - None => TxKind::Create, + Some(add) => TransactTo::Call(ChainAddress(1, add)), + None => TransactTo::Create, }; env.tx.transact_to = to; diff --git a/crates/interpreter/src/interpreter/serde.rs b/crates/interpreter/src/interpreter/serde.rs index 2cc8fd0496..736baf8f4c 100644 --- a/crates/interpreter/src/interpreter/serde.rs +++ b/crates/interpreter/src/interpreter/serde.rs @@ -95,6 +95,9 @@ impl<'de> Deserialize<'de> for Interpreter { let instruction_pointer = unsafe { bytecode.as_ptr().add(program_counter) }; Ok(Interpreter { + chain_id: 1, + is_sandboxed: false, + call_options: None, instruction_pointer, gas, contract, From 5d68473d1e69fb0e3792afd387a7bb07135adac3 Mon Sep 17 00:00:00 2001 From: Brecht Devos Date: Mon, 16 Sep 2024 23:04:22 +0900 Subject: [PATCH 4/8] default to chain_id 1 for ethereum mainnet --- crates/interpreter/src/interpreter.rs | 2 +- crates/interpreter/src/interpreter/contract.rs | 2 +- crates/primitives/src/env.rs | 2 +- crates/primitives/src/state.rs | 2 +- crates/revm/benches/bench.rs | 2 +- crates/revm/src/db/ethersdb.rs | 2 +- crates/revm/src/db/in_memory_db.rs | 4 ++-- crates/revm/src/db/states/bundle_state.rs | 6 +++--- crates/revm/src/db/states/state.rs | 8 ++++---- crates/revm/src/inspector/customprinter.rs | 2 +- crates/revm/src/inspector/gas.rs | 4 ++-- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index 212f659b3f..a4696ffc87 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -70,7 +70,7 @@ pub struct Interpreter { impl Default for Interpreter { fn default() -> Self { - Self::new(Contract::default(), u64::MAX, false, 0, false) + Self::new(Contract::default(), u64::MAX, false, 1, false) } } diff --git a/crates/interpreter/src/interpreter/contract.rs b/crates/interpreter/src/interpreter/contract.rs index 945dc4e23a..a6938cd4bb 100644 --- a/crates/interpreter/src/interpreter/contract.rs +++ b/crates/interpreter/src/interpreter/contract.rs @@ -58,7 +58,7 @@ impl Contract { pub fn new_env(env: &Env, bytecode: Bytecode, hash: Option) -> Self { let contract_address = match env.tx.transact_to { TransactTo::Call(caller) => caller, - TransactTo::Create => ChainAddress(0, Address::ZERO), + TransactTo::Create => ChainAddress(1, Address::ZERO), }; let bytecode_address = match env.tx.transact_to { TransactTo::Call(caller) => Some(caller), diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index f64aefe902..36e1346d10 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -635,7 +635,7 @@ impl Default for TxEnv { gas_price: U256::ZERO, gas_priority_fee: None, // TODO: Brecht - transact_to: TransactTo::Call(ChainAddress(0, Address::ZERO)), // will do nothing + transact_to: TransactTo::Call(ChainAddress(1, Address::ZERO)), // will do nothing value: U256::ZERO, data: Bytes::new(), chain_id: None, diff --git a/crates/primitives/src/state.rs b/crates/primitives/src/state.rs index 29d98d2e1c..8c0093e796 100644 --- a/crates/primitives/src/state.rs +++ b/crates/primitives/src/state.rs @@ -19,7 +19,7 @@ pub type EvmStorage = HashMap; impl Default for ChainAddress { fn default() -> Self { - ChainAddress(0, Address::default()) + ChainAddress(1, Address::default()) } } diff --git a/crates/revm/benches/bench.rs b/crates/revm/benches/bench.rs index ef2467f502..764e1462e3 100644 --- a/crates/revm/benches/bench.rs +++ b/crates/revm/benches/bench.rs @@ -106,7 +106,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(contract.clone(), u64::MAX, false, 0, false); + let mut interpreter = Interpreter::new(contract.clone(), u64::MAX, false, 1, false); let res = interpreter.run(temp, &instruction_table, &mut host); shared_memory = interpreter.take_memory(); host.clear(); diff --git a/crates/revm/src/db/ethersdb.rs b/crates/revm/src/db/ethersdb.rs index 67d677e5ac..050f8fcbc5 100644 --- a/crates/revm/src/db/ethersdb.rs +++ b/crates/revm/src/db/ethersdb.rs @@ -191,7 +191,7 @@ mod tests { ) .unwrap(); let client = Arc::new(client); - let chain_id = 0; + let chain_id = 1; let ethersdb = EthersDB::new( Arc::clone(&client), // public infura mainnet diff --git a/crates/revm/src/db/in_memory_db.rs b/crates/revm/src/db/in_memory_db.rs index bd9be37ccf..fc98a356f2 100644 --- a/crates/revm/src/db/in_memory_db.rs +++ b/crates/revm/src/db/in_memory_db.rs @@ -415,7 +415,7 @@ mod tests { #[test] fn test_insert_account_storage() { - let chain_id = 0; + let chain_id = 1; let account = ChainAddress(chain_id, Address::with_last_byte(42)); let nonce = 42; let mut init_state = CacheDB::new(EmptyDB::default()); @@ -439,7 +439,7 @@ mod tests { #[test] fn test_replace_account_storage() { - let chain_id = 0; + let chain_id = 1; let account = ChainAddress(chain_id, Address::with_last_byte(42)); let nonce = 42; let mut init_state = CacheDB::new(EmptyDB::default()); diff --git a/crates/revm/src/db/states/bundle_state.rs b/crates/revm/src/db/states/bundle_state.rs index 2ab806ef8d..d8b14771db 100644 --- a/crates/revm/src/db/states/bundle_state.rs +++ b/crates/revm/src/db/states/bundle_state.rs @@ -840,7 +840,7 @@ mod tests { #[test] fn transition_states() { // dummy data - let chain_id = 0; + let chain_id = 1; let address = ChainAddress(chain_id, Address::new([0x01; 20])); let acc1 = AccountInfo { balance: U256::from(10), @@ -870,11 +870,11 @@ mod tests { } const fn account1() -> ChainAddress { - ChainAddress(0, Address::new([0x60; 20])) + ChainAddress(1, Address::new([0x60; 20])) } const fn account2() -> ChainAddress { - ChainAddress(0, Address::new([0x61; 20])) + ChainAddress(1, Address::new([0x61; 20])) } fn slot1() -> U256 { diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index 46abc3dfd0..3f22293f39 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -312,7 +312,7 @@ mod tests { #[test] fn block_hash_cache() { - let chain_id = 0; + let chain_id = 1; let mut state = State::builder().build(); state.block_hash(chain_id, 1u64).unwrap(); state.block_hash(chain_id, 2u64).unwrap(); @@ -343,7 +343,7 @@ mod tests { /// state of the account before the block. #[test] fn reverts_preserve_old_values() { - let chain_id = 0; + let chain_id = 1; let mut state = State::builder().with_bundle_update().build(); let (slot1, slot2, slot3) = (U256::from(1), U256::from(2), U256::from(3)); @@ -568,7 +568,7 @@ mod tests { /// block and reverted to their previous state do not appear in the reverts. #[test] fn bundle_scoped_reverts_collapse() { - let chain_id = 0; + let chain_id = 1; let mut state = State::builder().with_bundle_update().build(); // Non-existing account. @@ -693,7 +693,7 @@ mod tests { /// Checks that the behavior of selfdestruct within the block is correct. #[test] fn selfdestruct_state_and_reverts() { - let chain_id = 0; + let chain_id = 1; let mut state = State::builder().with_bundle_update().build(); // Existing account. diff --git a/crates/revm/src/inspector/customprinter.rs b/crates/revm/src/inspector/customprinter.rs index 09c5a42a4c..5cadea7c4c 100644 --- a/crates/revm/src/inspector/customprinter.rs +++ b/crates/revm/src/inspector/customprinter.rs @@ -122,7 +122,7 @@ mod test { #[test] fn gas_calculation_underflow() { - let chain_id = 0; + let chain_id = 1; let callee = ChainAddress(chain_id, address!("5fdcca53617f4d2b9134b29090c87d01058e27e9")); // https://github.com/bluealloy/revm/issues/277 diff --git a/crates/revm/src/inspector/gas.rs b/crates/revm/src/inspector/gas.rs index 9faa529eb8..20d1a060b7 100644 --- a/crates/revm/src/inspector/gas.rs +++ b/crates/revm/src/inspector/gas.rs @@ -188,8 +188,8 @@ mod tests { .with_external_context(StackInspector::default()) .modify_tx_env(|tx| { tx.clear(); - tx.caller = ChainAddress(0, address!("1000000000000000000000000000000000000000")); - tx.transact_to = TransactTo::Call(ChainAddress(0, address!("0000000000000000000000000000000000000000"))); + tx.caller = ChainAddress(1, address!("1000000000000000000000000000000000000000")); + tx.transact_to = TransactTo::Call(ChainAddress(1, address!("0000000000000000000000000000000000000000"))); tx.gas_limit = 21100; }) .append_handler_register(inspector_handle_register) From f12a99d208cb62d775c35a656553cd5bb162bc2d Mon Sep 17 00:00:00 2001 From: Brecht Devos Date: Tue, 17 Sep 2024 01:59:40 +0900 Subject: [PATCH 5/8] set the address of XCALLOPTIONS to something that doesn't break tests --- crates/precompile/src/xcalloptions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/precompile/src/xcalloptions.rs b/crates/precompile/src/xcalloptions.rs index 1912427f10..f2a870d33c 100644 --- a/crates/precompile/src/xcalloptions.rs +++ b/crates/precompile/src/xcalloptions.rs @@ -2,7 +2,7 @@ use revm_primitives::{Address, Bytes, CallOptions, ChainAddress, Env, Precompile use crate::{Error, Precompile, PrecompileResult, PrecompileWithAddress, CtxPrecompileFn}; pub const XCALLOPTIONS: PrecompileWithAddress = PrecompileWithAddress( - crate::u64_to_address(1000), + crate::u64_to_address(1234), Precompile::Ctx(xcalloptions_run as CtxPrecompileFn), ); From 959611e7a6ceeb693acffe00ba8e4d976591479f Mon Sep 17 00:00:00 2001 From: CeciliaZ030 <45245961+CeciliaZ030@users.noreply.github.com> Date: Tue, 24 Sep 2024 01:33:21 +0900 Subject: [PATCH 6/8] Sync database (#17) * rename SyncDatabase * contracts: Vec<((u64, B256), Bytecode)>, * StateChangeset ilter_for_chain(&mut self, chain_id: u64) * fix comment on state_size * remove * use db::SyncDatabase as Database --- bins/revm-test/src/bin/burntpix/main.rs | 7 +- .../interpreter/src/instructions/bitwise.rs | 8 +- crates/interpreter/src/interpreter.rs | 10 ++- crates/interpreter/src/interpreter/serde.rs | 2 +- crates/primitives/src/db.rs | 49 ++++++++++-- crates/primitives/src/db/components.rs | 2 +- crates/primitives/src/env.rs | 1 - crates/revm/src/builder.rs | 2 +- crates/revm/src/context.rs | 2 +- .../revm/src/context/context_precompiles.rs | 2 +- crates/revm/src/context/evm_context.rs | 2 +- crates/revm/src/context/inner_evm_context.rs | 2 +- crates/revm/src/db/emptydb.rs | 2 +- crates/revm/src/db/ethersdb.rs | 2 +- crates/revm/src/db/in_memory_db.rs | 13 +-- crates/revm/src/db/states/bundle_state.rs | 80 +++++++++++++++---- crates/revm/src/db/states/changes.rs | 47 ++++++++++- crates/revm/src/db/states/state.rs | 4 +- crates/revm/src/db/states/state_builder.rs | 2 +- crates/revm/src/evm.rs | 2 +- crates/revm/src/handler.rs | 2 +- .../src/handler/handle_types/execution.rs | 2 +- .../revm/src/handler/handle_types/generic.rs | 2 +- .../handler/handle_types/post_execution.rs | 2 +- .../src/handler/handle_types/pre_execution.rs | 2 +- .../src/handler/handle_types/validation.rs | 2 +- crates/revm/src/handler/mainnet/execution.rs | 2 +- .../src/handler/mainnet/post_execution.rs | 2 +- .../revm/src/handler/mainnet/pre_execution.rs | 2 +- crates/revm/src/handler/mainnet/validation.rs | 2 +- crates/revm/src/handler/register.rs | 2 +- crates/revm/src/inspector.rs | 2 +- crates/revm/src/inspector/customprinter.rs | 2 +- crates/revm/src/inspector/eip3155.rs | 2 +- crates/revm/src/inspector/gas.rs | 4 +- crates/revm/src/inspector/handler_register.rs | 2 +- crates/revm/src/inspector/noop.rs | 2 +- crates/revm/src/journaled_state.rs | 2 +- crates/revm/src/lib.rs | 2 +- 39 files changed, 209 insertions(+), 72 deletions(-) diff --git a/bins/revm-test/src/bin/burntpix/main.rs b/bins/revm-test/src/bin/burntpix/main.rs index ef0b78ea2a..6808b05625 100644 --- a/bins/revm-test/src/bin/burntpix/main.rs +++ b/bins/revm-test/src/bin/burntpix/main.rs @@ -4,8 +4,7 @@ use regex::bytes::Regex; use revm::{ db::{CacheDB, EmptyDB}, primitives::{ - address, hex, keccak256, AccountInfo, Address, Bytecode, Bytes, ExecutionResult, Output, - TxKind, B256, U256, + address, hex, keccak256, AccountInfo, Address, Bytecode, Bytes, ChainAddress, ExecutionResult, Output, TransactTo, TxKind, B256, U256 }, Evm, }; @@ -37,8 +36,8 @@ fn main() { let mut evm = Evm::builder() .modify_tx_env(|tx| { - tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TxKind::Call(BURNTPIX_MAIN_ADDRESS); + tx.caller = ChainAddress(1, address!("1000000000000000000000000000000000000000")); + tx.transact_to = TransactTo::Call(BURNTPIX_MAIN_ADDRESS); tx.data = run_call_data.clone().into(); }) .with_db(db) diff --git a/crates/interpreter/src/instructions/bitwise.rs b/crates/interpreter/src/instructions/bitwise.rs index 8a87ee5ae0..e9af5b580c 100644 --- a/crates/interpreter/src/instructions/bitwise.rs +++ b/crates/interpreter/src/instructions/bitwise.rs @@ -130,7 +130,7 @@ mod tests { #[test] fn test_shift_left() { let mut host = DummyHost::new(Env::default()); - let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false); + let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false, 1, false); struct TestCase { value: U256, @@ -211,7 +211,7 @@ mod tests { #[test] fn test_logical_shift_right() { let mut host = DummyHost::new(Env::default()); - let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false); + let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false, 1, false); struct TestCase { value: U256, @@ -292,7 +292,7 @@ mod tests { #[test] fn test_arithmetic_shift_right() { let mut host = DummyHost::new(Env::default()); - let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false); + let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false, 1, false); struct TestCase { value: U256, @@ -404,7 +404,7 @@ mod tests { } let mut host = DummyHost::new(Env::default()); - let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false); + let mut interpreter = Interpreter::new(Contract::default(), u64::MAX, false, 1, false); let input_value = U256::from(0x1234567890abcdef1234567890abcdef_u128); let test_cases = (0..32) diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index a4696ffc87..9aeb9ee9d8 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -116,18 +116,22 @@ impl Interpreter { /// Test related helper #[cfg(test)] pub fn new_bytecode(bytecode: Bytecode) -> Self { + use revm_primitives::ChainAddress; + Self::new( Contract::new( Bytes::new(), bytecode, None, - crate::primitives::Address::default(), + ChainAddress::default(), None, - crate::primitives::Address::default(), + ChainAddress::default(), U256::ZERO, ), 0, false, + 1, + false ) } @@ -482,7 +486,7 @@ mod tests { #[test] fn object_safety() { - let mut interp = Interpreter::new(Contract::default(), u64::MAX, false); + let mut interp = Interpreter::new(Contract::default(), u64::MAX, false, 1, false); let mut host = crate::DummyHost::default(); let table: &InstructionTable = diff --git a/crates/interpreter/src/interpreter/serde.rs b/crates/interpreter/src/interpreter/serde.rs index 736baf8f4c..76846a6ba4 100644 --- a/crates/interpreter/src/interpreter/serde.rs +++ b/crates/interpreter/src/interpreter/serde.rs @@ -121,7 +121,7 @@ mod tests { #[test] fn test_serde() { - let interp = Interpreter::new(Contract::default(), u64::MAX, false); + let interp = Interpreter::new(Contract::default(), u64::MAX, false, 1, false); let serialized = bincode::serialize(&interp).unwrap(); let de: Interpreter = bincode::deserialize(&serialized).unwrap(); assert_eq!(interp.program_counter(), de.program_counter()); diff --git a/crates/primitives/src/db.rs b/crates/primitives/src/db.rs index 8f102431f5..7eee14b283 100644 --- a/crates/primitives/src/db.rs +++ b/crates/primitives/src/db.rs @@ -1,4 +1,5 @@ use crate::{Account, AccountInfo, ChainAddress, Bytecode, HashMap, B256, U256}; +use alloy_primitives::Address; use auto_impl::auto_impl; pub mod components; @@ -6,12 +7,48 @@ pub use components::{ BlockHash, BlockHashRef, DatabaseComponentError, DatabaseComponents, State, StateRef, }; -/// EVM database interface. #[auto_impl(&mut, Box)] pub trait Database { /// The database error type. type Error; + /// Get basic account information. + fn basic(&mut self, address: Address) -> Result, Self::Error>; + + /// Get account code by its hash. + fn code_by_hash(&mut self, code_hash: B256) -> Result; + + /// Get storage value of address at index. + fn storage(&mut self, address: Address, index: U256) -> Result; + + /// Get block hash by block number. + fn block_hash(&mut self, number: u64) -> Result; +} + +#[auto_impl(&, &mut, Box, Rc, Arc)] +pub trait DatabaseRef { + /// The database error type. + type Error; + + /// Get basic account information. + fn basic_ref(&self, address: Address) -> Result, Self::Error>; + + /// Get account code by its hash. + fn code_by_hash_ref(&self, code_hash: B256) -> Result; + + /// Get storage value of address at index. + fn storage_ref(&self, address: Address, index: U256) -> Result; + + /// Get block hash by block number. + fn block_hash_ref(&self, number: u64) -> Result; +} + +/// EVM database interface. +#[auto_impl(&mut, Box)] +pub trait SyncDatabase { + /// The database error type. + type Error; + /// Get basic account information. fn basic(&mut self, address: ChainAddress) -> Result, Self::Error>; @@ -39,7 +76,7 @@ pub trait DatabaseCommit { /// Use [`WrapDatabaseRef`] to provide [`Database`] implementation for a type /// that only implements this trait. #[auto_impl(&, &mut, Box, Rc, Arc)] -pub trait DatabaseRef { +pub trait SyncDatabaseRef { /// The database error type. type Error; @@ -58,16 +95,16 @@ pub trait DatabaseRef { /// Wraps a [`DatabaseRef`] to provide a [`Database`] implementation. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct WrapDatabaseRef(pub T); +pub struct WrapDatabaseRef(pub T); -impl From for WrapDatabaseRef { +impl From for WrapDatabaseRef { #[inline] fn from(f: F) -> Self { WrapDatabaseRef(f) } } -impl Database for WrapDatabaseRef { +impl SyncDatabase for WrapDatabaseRef { type Error = T::Error; #[inline] @@ -91,7 +128,7 @@ impl Database for WrapDatabaseRef { } } -impl DatabaseCommit for WrapDatabaseRef { +impl DatabaseCommit for WrapDatabaseRef { #[inline] fn commit(&mut self, changes: HashMap) { self.0.commit(changes) diff --git a/crates/primitives/src/db/components.rs b/crates/primitives/src/db/components.rs index 6afefc5e36..e4d0c55d49 100644 --- a/crates/primitives/src/db/components.rs +++ b/crates/primitives/src/db/components.rs @@ -6,7 +6,7 @@ pub use block_hash::{BlockHash, BlockHashRef}; pub use state::{State, StateRef}; use crate::{ - db::{Database, DatabaseRef}, + db::{SyncDatabase as Database, SyncDatabaseRef as DatabaseRef}, Account, AccountInfo, Address, ChainAddress, Bytecode, HashMap, B256, U256, }; diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index 36e1346d10..598891bcf7 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -720,7 +720,6 @@ use alloy_rlp::{Buf, BufMut, Decodable, Encodable, EMPTY_STRING_CODE}; /// The `to` field of a transaction. Either a target address, or empty for a /// contract creation. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "arbitrary", derive(derive_arbitrary::Arbitrary, proptest_derive::Arbitrary))] pub enum TransactTo { /// A transaction that creates a contract. #[default] diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index 706ce3c198..4b3ca63c37 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -1,5 +1,5 @@ use crate::{ - db::{Database, DatabaseRef, EmptyDB, WrapDatabaseRef}, + db::{SyncDatabase as Database, SyncDatabaseRef as DatabaseRef, EmptyDB, WrapDatabaseRef}, handler::register, primitives::{ BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg, HandlerCfg, SpecId, TxEnv, diff --git a/crates/revm/src/context.rs b/crates/revm/src/context.rs index e29b3b4d68..cb0999e5cb 100644 --- a/crates/revm/src/context.rs +++ b/crates/revm/src/context.rs @@ -11,7 +11,7 @@ pub use inner_evm_context::InnerEvmContext; use revm_interpreter::{as_u64_saturated, Eip7702CodeLoad, StateLoad}; use crate::{ - db::{Database, EmptyDB}, + db::{SyncDatabase as Database, EmptyDB}, interpreter::{AccountLoad, Host, SStoreResult, SelfDestructResult}, primitives::{Address, Bytes, ChainAddress, Env, HandlerCfg, Log, B256, BLOCK_HASH_HISTORY, U256}, }; diff --git a/crates/revm/src/context/context_precompiles.rs b/crates/revm/src/context/context_precompiles.rs index f674093535..d97dae5c51 100644 --- a/crates/revm/src/context/context_precompiles.rs +++ b/crates/revm/src/context/context_precompiles.rs @@ -1,7 +1,7 @@ use super::InnerEvmContext; use crate::{ precompile::{Precompile, PrecompileResult}, - primitives::{db::Database, Address, Bytes, HashMap, HashSet}, + primitives::{db::SyncDatabase as Database, Address, Bytes, HashMap, HashSet}, }; use dyn_clone::DynClone; use revm_precompile::{PrecompileSpecId, PrecompileWithAddress, Precompiles}; diff --git a/crates/revm/src/context/evm_context.rs b/crates/revm/src/context/evm_context.rs index 213ce75fab..3295cac354 100644 --- a/crates/revm/src/context/evm_context.rs +++ b/crates/revm/src/context/evm_context.rs @@ -3,7 +3,7 @@ use revm_precompile::PrecompileErrors; use super::inner_evm_context::InnerEvmContext; use crate::{ - db::Database, + db::SyncDatabase as Database, interpreter::{ analysis::validate_eof, return_ok, CallInputs, Contract, CreateInputs, EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterResult, diff --git a/crates/revm/src/context/inner_evm_context.rs b/crates/revm/src/context/inner_evm_context.rs index 991716c491..e43beadea8 100644 --- a/crates/revm/src/context/inner_evm_context.rs +++ b/crates/revm/src/context/inner_evm_context.rs @@ -1,5 +1,5 @@ use crate::{ - db::Database, + db::SyncDatabase as Database, interpreter::{ analysis::to_analysed, gas, return_ok, AccountLoad, Eip7702CodeLoad, InstructionResult, InterpreterResult, SStoreResult, SelfDestructResult, StateLoad, diff --git a/crates/revm/src/db/emptydb.rs b/crates/revm/src/db/emptydb.rs index e6572ce387..34dd957e03 100644 --- a/crates/revm/src/db/emptydb.rs +++ b/crates/revm/src/db/emptydb.rs @@ -1,6 +1,6 @@ use core::{convert::Infallible, fmt, marker::PhantomData}; use revm_interpreter::primitives::{ - db::{Database, DatabaseRef}, + db::{SyncDatabase as Database, SyncDatabaseRef as DatabaseRef}, keccak256, AccountInfo, ChainAddress, Bytecode, B256, U256, }; use std::string::ToString; diff --git a/crates/revm/src/db/ethersdb.rs b/crates/revm/src/db/ethersdb.rs index 050f8fcbc5..5810374900 100644 --- a/crates/revm/src/db/ethersdb.rs +++ b/crates/revm/src/db/ethersdb.rs @@ -5,7 +5,7 @@ use ethers_providers::Middleware; use tokio::runtime::{Handle, Runtime}; use crate::primitives::{AccountInfo, Address, Bytecode, ChainAddress, B256, U256}; -use crate::{Database, DatabaseRef}; +use crate::{SyncDatabase as Database, SyncDatabaseRef as DatabaseRef}; use super::utils::HandleOrRuntime; diff --git a/crates/revm/src/db/in_memory_db.rs b/crates/revm/src/db/in_memory_db.rs index fc98a356f2..6e78aa4248 100644 --- a/crates/revm/src/db/in_memory_db.rs +++ b/crates/revm/src/db/in_memory_db.rs @@ -1,9 +1,9 @@ -use super::{DatabaseCommit, DatabaseRef, EmptyDB}; +use super::{DatabaseCommit, SyncDatabaseRef as DatabaseRef, EmptyDB}; use crate::primitives::{ hash_map::Entry, Account, AccountInfo, Address, ChainAddress, Bytecode, HashMap, Log, B256, KECCAK_EMPTY, U256, }; -use crate::Database; +use crate::SyncDatabase as Database; use core::convert::Infallible; use std::vec::Vec; @@ -24,6 +24,7 @@ pub struct CacheDB { /// `code` is always `None`, and bytecode can be found in `contracts`. pub accounts: HashMap, /// Tracks all contracts by their code hash. + // FIX(Cecilia): should be (u64, B256) pub contracts: HashMap, /// All logs that were committed via [DatabaseCommit::commit]. pub logs: Vec, @@ -411,7 +412,7 @@ impl Database for BenchmarkDB { #[cfg(test)] mod tests { use super::{CacheDB, EmptyDB}; - use crate::primitives::{db::Database, AccountInfo, Address, ChainAddress, U256}; + use crate::primitives::{db::SyncDatabase as Database, AccountInfo, Address, ChainAddress, U256}; #[test] fn test_insert_account_storage() { @@ -474,7 +475,7 @@ mod tests { let nonce = 420; let mut init_state = CacheDB::new(EmptyDB::default()); init_state.insert_account_info( - account, + ChainAddress(0, account), AccountInfo { nonce, ..Default::default() @@ -484,9 +485,9 @@ mod tests { let serialized = serde_json::to_string(&init_state).unwrap(); let deserialized: CacheDB = serde_json::from_str(&serialized).unwrap(); - assert!(deserialized.accounts.contains_key(&account)); + assert!(deserialized.accounts.contains_key(&ChainAddress(0, account))); assert_eq!( - deserialized.accounts.get(&account).unwrap().info.nonce, + deserialized.accounts.get(&ChainAddress(0, account)).unwrap().info.nonce, nonce ); } diff --git a/crates/revm/src/db/states/bundle_state.rs b/crates/revm/src/db/states/bundle_state.rs index d8b14771db..e43ef18b76 100644 --- a/crates/revm/src/db/states/bundle_state.rs +++ b/crates/revm/src/db/states/bundle_state.rs @@ -28,7 +28,7 @@ pub struct BundleBuilder { revert_account: HashMap<(u64, ChainAddress), Option>>, revert_storage: HashMap<(u64, ChainAddress), Vec<(U256, U256)>>, - contracts: HashMap, + contracts: HashMap<(u64, B256), Bytecode>, } /// Option for [`BundleState`] when converting it to the plain state. @@ -159,8 +159,8 @@ impl BundleBuilder { } /// Collect contracts info - pub fn contract(mut self, address: B256, bytecode: Bytecode) -> Self { - self.set_contract(address, bytecode); + pub fn contract(mut self, chain_id: u64, address: B256, bytecode: Bytecode) -> Self { + self.set_contract(chain_id, address, bytecode); self } @@ -234,8 +234,8 @@ impl BundleBuilder { } /// Set contracts info. - pub fn set_contract(&mut self, address: B256, bytecode: Bytecode) -> &mut Self { - self.contracts.insert(address, bytecode); + pub fn set_contract(&mut self, chain_id: u64, address: B256, bytecode: Bytecode) -> &mut Self { + self.contracts.insert((chain_id, address), bytecode); self } @@ -365,7 +365,7 @@ impl BundleBuilder { } /// Mutable getter for `contracts` field - pub fn get_contracts_mut(&mut self) -> &mut HashMap { + pub fn get_contracts_mut(&mut self) -> &mut HashMap<(u64, B256), Bytecode> { &mut self.contracts } } @@ -399,7 +399,7 @@ pub struct BundleState { /// Account state. pub state: HashMap, /// All created contracts in this block. - pub contracts: HashMap, + pub contracts: HashMap<(u64, B256), Bytecode>, /// Changes to revert. /// /// Note: Inside vector is *not* sorted by address. @@ -436,7 +436,7 @@ impl BundleState { ), >, >, - contracts: impl IntoIterator, + contracts: impl IntoIterator, ) -> Self { // Create state from iterator. let mut state_size = 0; @@ -495,6 +495,58 @@ impl BundleState { } } + pub fn filter_for_chain(&self, chain_id: u64) -> Self { + let mut state_size = self.state_size; + let state = self + .state + .iter() + .filter_map(|(address, account)| { + if address.0 == chain_id { + Some((*address, account.clone())) + } else { + state_size -= account.size_hint(); + None + } + }) + .collect(); + let contracts = self + .contracts + .iter() + .filter_map(|((id, hash), bytecode)| { + if *id == chain_id { + Some(((*id, *hash), bytecode.clone())) + } else { + None + } + }) + .collect(); + let mut reverts_size = self.reverts_size; + let reverts = self + .reverts + .iter() + .map(|block_reverts| { + block_reverts + .iter() + .filter_map(|(address, revert)| { + if address.0 == chain_id { + Some((*address, revert.clone())) + } else { + reverts_size -= revert.size_hint(); + None + } + }) + .collect::>() + }) + .collect::>(); + Self { + state, + contracts, + reverts: Reverts::new(reverts), + state_size, + reverts_size, + } + } + /// Returns the approximate size of changes in the bundle state. /// The estimation is not precise, because the information about the number of /// destroyed entries that need to be removed is not accessible to the bundle state. @@ -523,8 +575,8 @@ impl BundleState { } /// Get bytecode from state - pub fn bytecode(&self, hash: &B256) -> Option { - self.contracts.get(hash).cloned() + pub fn bytecode(&self, chain_id: u64, hash: &B256) -> Option { + self.contracts.get(&(chain_id, *hash)).cloned() } /// Consume [`TransitionState`] by applying the changes and creating the @@ -549,7 +601,7 @@ impl BundleState { for (address, transition) in transitions.transitions.into_iter() { // add new contract if it was created/changed. if let Some((hash, new_bytecode)) = transition.has_new_contract() { - self.contracts.insert(hash, new_bytecode.clone()); + self.contracts.insert((address.0, hash), new_bytecode.clone()); } // update state and create revert. let revert = match self.state.entry(address) { @@ -635,7 +687,7 @@ impl BundleState { .contracts .into_iter() // remove empty bytecodes - .filter(|(b, _)| *b != KECCAK_EMPTY) + .filter(|((_, b), _)| *b != KECCAK_EMPTY) .collect::>(); StateChangeset { accounts, @@ -1302,7 +1354,7 @@ mod tests { assert!(builder.get_contracts_mut().is_empty()); builder .get_contracts_mut() - .insert(B256::default(), Bytecode::default()); - assert!(builder.get_contracts_mut().contains_key(&B256::default())); + .insert((0, B256::default()), Bytecode::default()); + assert!(builder.get_contracts_mut().contains_key(&(0, B256::default()))); } } diff --git a/crates/revm/src/db/states/changes.rs b/crates/revm/src/db/states/changes.rs index f7c451dde2..a87125aa0e 100644 --- a/crates/revm/src/db/states/changes.rs +++ b/crates/revm/src/db/states/changes.rs @@ -15,7 +15,29 @@ pub struct StateChangeset { /// Vector of **not** sorted storage. pub storage: Vec, /// Vector of contracts by bytecode hash. **not** sorted. - pub contracts: Vec<(B256, Bytecode)>, + pub contracts: Vec<((u64, B256), Bytecode)>, +} + +impl StateChangeset { + pub fn filter_for_chain(&mut self, chain_id: u64) { + // multiple Txs has multiple reverts per ChainAddress, + // filter out account chainges and storage changes for given chain_id + self.accounts = self + .accounts + .drain(..) + .filter(|(chain, _)| chain.0 == chain_id) + .collect(); + self.storage = self + .storage + .drain(..) + .filter(|change| change.address.0 == chain_id) + .collect(); + self.contracts = self + .contracts + .drain(..) + .filter(|((chain, _), _)| *chain == chain_id) + .collect(); + } } /// Plain storage changeset. Used to apply storage changes of plain state to @@ -65,6 +87,29 @@ impl PlainStateReverts { storage: Vec::with_capacity(capacity), } } + + pub fn filter_for_chain(&mut self, chain_id: u64) { + // multiple Txs has multiple reverts per ChainAddress, + // filter out account chainges and storage changes for given chain_id + self.accounts = self + .accounts + .drain(..) + .map(|inner| { + inner.into_iter() + .filter(|(chain, _)| chain.0 == chain_id) + .collect() + }) + .collect(); + self.storage = self + .storage + .drain(..) + .map(|inner| { + inner.into_iter() + .filter(|revert| revert.address.0 == chain_id) + .collect() + }) + .collect(); + } } /// Storage reverts diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index 3f22293f39..0dad12be7c 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -4,7 +4,7 @@ use super::{ }; use crate::db::EmptyDB; use revm_interpreter::primitives::{ - db::{Database, DatabaseCommit}, + db::{SyncDatabase as Database, DatabaseCommit}, hash_map, Account, AccountInfo, Bytecode, HashMap, B256, BLOCK_HASH_HISTORY, U256, }; use std::{ @@ -228,7 +228,7 @@ impl Database for State { hash_map::Entry::Occupied(entry) => Ok(entry.get().clone()), hash_map::Entry::Vacant(entry) => { if self.use_preloaded_bundle { - if let Some(code) = self.bundle_state.contracts.get(&code_hash) { + if let Some(code) = self.bundle_state.contracts.get(&(chain_id, code_hash)) { entry.insert(code.clone()); return Ok(code.clone()); } diff --git a/crates/revm/src/db/states/state_builder.rs b/crates/revm/src/db/states/state_builder.rs index f029ae13d4..9f92192a98 100644 --- a/crates/revm/src/db/states/state_builder.rs +++ b/crates/revm/src/db/states/state_builder.rs @@ -1,7 +1,7 @@ use super::{cache::CacheState, state::DBBox, BundleState, State, TransitionState}; use crate::db::EmptyDB; use revm_interpreter::primitives::{ - db::{Database, DatabaseRef, WrapDatabaseRef}, + db::{SyncDatabase as Database, SyncDatabaseRef as DatabaseRef, WrapDatabaseRef}, B256, }; use std::collections::BTreeMap; diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index 3c46bcb794..0a6f60533f 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -1,6 +1,6 @@ use crate::{ builder::{EvmBuilder, HandlerStage, SetGenericStage}, - db::{Database, DatabaseCommit, EmptyDB}, + db::{SyncDatabase as Database, DatabaseCommit, EmptyDB}, handler::Handler, interpreter::{ CallInputs, CreateInputs, EOFCreateInputs, Host, InterpreterAction, SharedMemory, diff --git a/crates/revm/src/handler.rs b/crates/revm/src/handler.rs index ed31917bbe..4d7453bfff 100644 --- a/crates/revm/src/handler.rs +++ b/crates/revm/src/handler.rs @@ -9,7 +9,7 @@ pub use handle_types::*; // Includes. use crate::{ interpreter::{opcode::InstructionTables, Host, InterpreterAction, SharedMemory}, - primitives::{db::Database, spec_to_generic, EVMError, HandlerCfg, Spec, SpecId}, + primitives::{db::SyncDatabase as Database, spec_to_generic, EVMError, HandlerCfg, Spec, SpecId}, Context, Frame, }; use core::mem; diff --git a/crates/revm/src/handler/handle_types/execution.rs b/crates/revm/src/handler/handle_types/execution.rs index 27d31eb118..f15ad7e33e 100644 --- a/crates/revm/src/handler/handle_types/execution.rs +++ b/crates/revm/src/handler/handle_types/execution.rs @@ -2,7 +2,7 @@ use crate::{ frame::EOFCreateFrame, handler::mainnet, interpreter::{CallInputs, CreateInputs, SharedMemory}, - primitives::{db::Database, EVMError, Spec}, + primitives::{db::SyncDatabase as Database, EVMError, Spec}, CallFrame, Context, CreateFrame, Frame, FrameOrResult, FrameResult, }; use revm_interpreter::{ diff --git a/crates/revm/src/handler/handle_types/generic.rs b/crates/revm/src/handler/handle_types/generic.rs index 434e490676..41dd4c4f83 100644 --- a/crates/revm/src/handler/handle_types/generic.rs +++ b/crates/revm/src/handler/handle_types/generic.rs @@ -1,5 +1,5 @@ use crate::{ - primitives::{db::Database, EVMResultGeneric}, + primitives::{db::SyncDatabase as Database, EVMResultGeneric}, Context, }; use std::sync::Arc; diff --git a/crates/revm/src/handler/handle_types/post_execution.rs b/crates/revm/src/handler/handle_types/post_execution.rs index b6899bbfba..eda2bbc164 100644 --- a/crates/revm/src/handler/handle_types/post_execution.rs +++ b/crates/revm/src/handler/handle_types/post_execution.rs @@ -2,7 +2,7 @@ use crate::{ handler::mainnet, interpreter::Gas, - primitives::{db::Database, EVMError, EVMResultGeneric, ResultAndState, Spec}, + primitives::{db::SyncDatabase as Database, EVMError, EVMResultGeneric, ResultAndState, Spec}, Context, FrameResult, }; use std::sync::Arc; diff --git a/crates/revm/src/handler/handle_types/pre_execution.rs b/crates/revm/src/handler/handle_types/pre_execution.rs index e64c6081e1..9926baa3ee 100644 --- a/crates/revm/src/handler/handle_types/pre_execution.rs +++ b/crates/revm/src/handler/handle_types/pre_execution.rs @@ -2,7 +2,7 @@ use super::{GenericContextHandle, GenericContextHandleRet, GenericContextHandleChain}; use crate::{ handler::mainnet, - primitives::{db::Database, EVMError, Spec}, + primitives::{db::SyncDatabase as Database, EVMError, Spec}, Context, ContextPrecompiles, }; use std::sync::Arc; diff --git a/crates/revm/src/handler/handle_types/validation.rs b/crates/revm/src/handler/handle_types/validation.rs index 8aa55c28c2..644c21f391 100644 --- a/crates/revm/src/handler/handle_types/validation.rs +++ b/crates/revm/src/handler/handle_types/validation.rs @@ -1,6 +1,6 @@ use crate::{ handler::mainnet, - primitives::{db::Database, EVMError, Env, Spec}, + primitives::{db::SyncDatabase as Database, EVMError, Env, Spec}, Context, }; use std::sync::Arc; diff --git a/crates/revm/src/handler/mainnet/execution.rs b/crates/revm/src/handler/mainnet/execution.rs index a189e96c41..b7680eeef8 100644 --- a/crates/revm/src/handler/mainnet/execution.rs +++ b/crates/revm/src/handler/mainnet/execution.rs @@ -1,5 +1,5 @@ use crate::{ - db::Database, + db::SyncDatabase as Database, frame::EOFCreateFrame, interpreter::{ return_ok, return_revert, CallInputs, CreateInputs, CreateOutcome, Gas, InstructionResult, diff --git a/crates/revm/src/handler/mainnet/post_execution.rs b/crates/revm/src/handler/mainnet/post_execution.rs index 3e2f520e3e..78331befa9 100644 --- a/crates/revm/src/handler/mainnet/post_execution.rs +++ b/crates/revm/src/handler/mainnet/post_execution.rs @@ -1,7 +1,7 @@ use crate::{ interpreter::{Gas, SuccessOrHalt}, primitives::{ - db::Database, EVMError, ExecutionResult, ResultAndState, Spec, SpecId, SpecId::LONDON, U256, + db::SyncDatabase as Database, EVMError, ExecutionResult, ResultAndState, Spec, SpecId, SpecId::LONDON, U256, }, Context, FrameResult, }; diff --git a/crates/revm/src/handler/mainnet/pre_execution.rs b/crates/revm/src/handler/mainnet/pre_execution.rs index dd345b3447..a7c8c1820c 100644 --- a/crates/revm/src/handler/mainnet/pre_execution.rs +++ b/crates/revm/src/handler/mainnet/pre_execution.rs @@ -5,7 +5,7 @@ use crate::{ precompile::PrecompileSpecId, primitives::{ - db::Database, + db::SyncDatabase as Database, eip7702, Account, Bytecode, ChainAddress, EVMError, Env, Spec, SpecId::{CANCUN, PRAGUE, SHANGHAI}, TransactTo, TxKind, BLOCKHASH_STORAGE_ADDRESS, U256, diff --git a/crates/revm/src/handler/mainnet/validation.rs b/crates/revm/src/handler/mainnet/validation.rs index 18d6241224..7db0538398 100644 --- a/crates/revm/src/handler/mainnet/validation.rs +++ b/crates/revm/src/handler/mainnet/validation.rs @@ -1,7 +1,7 @@ use revm_interpreter::gas; use crate::{ - primitives::{db::Database, EVMError, Env, InvalidTransaction, Spec}, + primitives::{db::SyncDatabase as Database, EVMError, Env, InvalidTransaction, Spec}, Context, }; diff --git a/crates/revm/src/handler/register.rs b/crates/revm/src/handler/register.rs index e05225c17c..d63fae9dfa 100644 --- a/crates/revm/src/handler/register.rs +++ b/crates/revm/src/handler/register.rs @@ -1,4 +1,4 @@ -use crate::{db::Database, handler::Handler, Context}; +use crate::{db::SyncDatabase as Database, handler::Handler, Context}; use std::boxed::Box; /// EVM Handler diff --git a/crates/revm/src/inspector.rs b/crates/revm/src/inspector.rs index 025a0138ce..91ce230fcb 100644 --- a/crates/revm/src/inspector.rs +++ b/crates/revm/src/inspector.rs @@ -12,7 +12,7 @@ use crate::{ interpreter::{ CallInputs, CallOutcome, CreateInputs, CreateOutcome, EOFCreateInputs, Interpreter, }, - primitives::{db::Database, Address, ChainAddress, Log, U256}, + primitives::{db::SyncDatabase as Database, Address, ChainAddress, Log, U256}, EvmContext, }; use auto_impl::auto_impl; diff --git a/crates/revm/src/inspector/customprinter.rs b/crates/revm/src/inspector/customprinter.rs index 5cadea7c4c..0c379bd731 100644 --- a/crates/revm/src/inspector/customprinter.rs +++ b/crates/revm/src/inspector/customprinter.rs @@ -9,7 +9,7 @@ use crate::{ inspectors::GasInspector, interpreter::{CallInputs, CreateInputs, Interpreter}, primitives::{Address, ChainAddress, U256}, - Database, EvmContext, Inspector, + SyncDatabase as Database, EvmContext, Inspector, }; /// Custom print [Inspector], it has step level information of execution. diff --git a/crates/revm/src/inspector/eip3155.rs b/crates/revm/src/inspector/eip3155.rs index aec20ffd8f..de1a49a99e 100644 --- a/crates/revm/src/inspector/eip3155.rs +++ b/crates/revm/src/inspector/eip3155.rs @@ -3,7 +3,7 @@ use crate::{ interpreter::{ CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter, InterpreterResult, }, - primitives::{db::Database, hex, HashMap, B256, U256}, + primitives::{db::SyncDatabase as Database, hex, HashMap, B256, U256}, EvmContext, Inspector, }; use revm_interpreter::OpCode; diff --git a/crates/revm/src/inspector/gas.rs b/crates/revm/src/inspector/gas.rs index 20d1a060b7..3dab85f961 100644 --- a/crates/revm/src/inspector/gas.rs +++ b/crates/revm/src/inspector/gas.rs @@ -4,7 +4,7 @@ use revm_interpreter::CallOutcome; use crate::{ interpreter::{CallInputs, CreateInputs, CreateOutcome}, - primitives::db::Database, + primitives::db::SyncDatabase as Database, EvmContext, Inspector, }; @@ -90,7 +90,7 @@ mod tests { inspectors::GasInspector, interpreter::{CallInputs, CreateInputs, Interpreter}, primitives::{Log, ChainAddress, TransactTo}, - Database, EvmContext, Inspector, + SyncDatabase as Database, EvmContext, Inspector, }; #[derive(Default, Debug)] diff --git a/crates/revm/src/inspector/handler_register.rs b/crates/revm/src/inspector/handler_register.rs index 7248b3fa67..1e9feda0a7 100644 --- a/crates/revm/src/inspector/handler_register.rs +++ b/crates/revm/src/inspector/handler_register.rs @@ -1,5 +1,5 @@ use crate::{ - db::Database, + db::SyncDatabase as Database, handler::register::EvmHandler, interpreter::{opcode, InstructionResult, Interpreter}, primitives::EVMError, diff --git a/crates/revm/src/inspector/noop.rs b/crates/revm/src/inspector/noop.rs index 9e9556e286..528bde61d6 100644 --- a/crates/revm/src/inspector/noop.rs +++ b/crates/revm/src/inspector/noop.rs @@ -1,4 +1,4 @@ -use crate::{Database, Inspector}; +use crate::{SyncDatabase as Database, Inspector}; /// Dummy [Inspector], helpful as standalone replacement. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct NoOpInspector; diff --git a/crates/revm/src/journaled_state.rs b/crates/revm/src/journaled_state.rs index 75c5dbbce5..1506d4d472 100644 --- a/crates/revm/src/journaled_state.rs +++ b/crates/revm/src/journaled_state.rs @@ -3,7 +3,7 @@ use revm_interpreter::Eip7702CodeLoad; use crate::{ interpreter::{AccountLoad, InstructionResult, SStoreResult, SelfDestructResult, StateLoad}, primitives::{ - db::Database, hash_map::Entry, Account, Address, Bytecode, EVMError, EvmState, + db::SyncDatabase as Database, hash_map::Entry, Account, Address, Bytecode, EVMError, EvmState, EvmStorageSlot, HashMap, HashSet, Log, SpecId, SpecId::*, TransientStorage, B256, KECCAK_EMPTY, PRECOMPILE3, U256, }, diff --git a/crates/revm/src/lib.rs b/crates/revm/src/lib.rs index 5097388526..98874411fa 100644 --- a/crates/revm/src/lib.rs +++ b/crates/revm/src/lib.rs @@ -34,7 +34,7 @@ pub use context::{ pub use db::{ CacheState, DBBox, State, StateBuilder, StateDBBox, TransitionAccount, TransitionState, }; -pub use db::{Database, DatabaseCommit, DatabaseRef, InMemoryDB}; +pub use db::{SyncDatabase, DatabaseRef, Database, DatabaseCommit, SyncDatabaseRef, InMemoryDB}; pub use evm::{Evm, CALL_STACK_LIMIT}; pub use frame::{CallFrame, CreateFrame, Frame, FrameData, FrameOrResult, FrameResult}; pub use handler::Handler; From e9072939e9fccdd3457e637cd3c70e64940d881d Mon Sep 17 00:00:00 2001 From: CeciliaZ030 Date: Sun, 20 Oct 2024 14:47:23 -0300 Subject: [PATCH 7/8] build + run --- Cargo.lock | 924 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 530 insertions(+), 394 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eeda490fa8..49689f56b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,18 +15,18 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "ahash" @@ -57,19 +57,20 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.23" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1752d7d62e2665da650a36d84abbf239f812534475d51f072a49a533513b7cdd" +checksum = "d4932d790c723181807738cf1ac68198ab581cd699545b155601332541ee47bd" dependencies = [ + "alloy-primitives", "num_enum", "strum", ] [[package]] name = "alloy-consensus" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7198a527b4c4762cb88d54bcaeb0428f4298b72552c9c8ec4af614b4a4990c59" +checksum = "629b62e38d471cc15fea534eb7283d2f8a4e8bdb1811bcc5d66dda6cfce6fae1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -94,9 +95,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d319bb544ca6caeab58c39cea8921c55d924d4f68f2c60f24f914673f9a74a" +checksum = "ea59dc42102bc9a1905dc57901edc6dd48b9f38115df86c7d252acba70d71d04" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -108,9 +109,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "159eab0e4e15b88571f55673af37314f4b8f17630dc1b393c3d70f2128a1d494" +checksum = "f923dd5fca5f67a43d81ed3ebad0880bd41f6dd0ada930030353ac356c54cd0f" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -119,6 +120,7 @@ dependencies = [ "alloy-serde", "arbitrary", "c-kzg", + "derive_more 1.0.0", "once_cell", "serde", "sha2", @@ -126,9 +128,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299d2a937b6c60968df3dad2a988b0f0e03277b344639a4f7a31bd68e6285e59" +checksum = "d46eb5871592c216d39192499c95a99f7175cb94104f88c307e6dc960676d9f1" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -138,9 +140,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7733446dd531f8eb877331fea02f6c40bdbb47444a17dc3464bf75319cc073a" +checksum = "d3c717b5298fad078cd3a418335b266eba91b511383ca9bd497f742d5975d5ab" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -152,9 +154,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b80851d1697fc4fa2827998e3ee010a3d1fc59c7d25e87070840169fcf465832" +checksum = "fb3705ce7d8602132bcf5ac7a1dd293a42adc2f183abf5907c30ac535ceca049" dependencies = [ "alloy-consensus", "alloy-eips", @@ -173,10 +175,11 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76a2336889f3d0624b18213239d27f4f34eb476eb35bef22f6a8cc24e0c0078" +checksum = "94ad40869867ed2d9cd3842b1e800889e5b49e6b92da346e93862b4a741bedf3" dependencies = [ + "alloy-eips", "alloy-primitives", "alloy-serde", "serde", @@ -184,9 +187,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a767e59c86900dd7c3ce3ecef04f3ace5ac9631ee150beb8b7d22f7fa3bbb2d7" +checksum = "38f35429a652765189c1c5092870d8360ee7b7769b09b06d89ebaefd34676446" dependencies = [ "alloy-rlp", "arbitrary", @@ -194,25 +197,31 @@ dependencies = [ "cfg-if", "const-hex", "derive_arbitrary", - "derive_more", + "derive_more 1.0.0", + "foldhash", "getrandom", + "hashbrown 0.15.0", "hex-literal", + "indexmap", "itoa", "k256", "keccak-asm", + "paste", "proptest", "proptest-derive", "rand", "ruint", + "rustc-hash", "serde", + "sha3", "tiny-keccak", ] [[package]] name = "alloy-provider" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d2a195caa6707f5ce13905794865765afc6d9ea92c3a56e3a973c168d703bc" +checksum = "927f708dd457ed63420400ee5f06945df9632d5d101851952056840426a10dc5" dependencies = [ "alloy-chains", "alloy-consensus", @@ -233,7 +242,7 @@ dependencies = [ "futures-utils-wasm", "lru", "pin-project", - "reqwest 0.12.5", + "reqwest 0.12.8", "serde", "serde_json", "thiserror", @@ -244,9 +253,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" +checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -255,27 +264,27 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" +checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] name = "alloy-rpc-client" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed31cdba2b23d71c555505b06674f8e7459496abfd7f4875d268434ef5a99ee6" +checksum = "7d82952dca71173813d4e5733e2c986d8b04aea9e0f3b0a576664c232ad050a5" dependencies = [ "alloy-json-rpc", "alloy-transport", "alloy-transport-http", "futures", "pin-project", - "reqwest 0.12.5", + "reqwest 0.12.8", "serde", "serde_json", "tokio", @@ -287,9 +296,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ba05d6ee4db0d89113294a614137940f79abfc2c40a9a3bee2995660358776" +checksum = "83aa984386deda02482660aa31cb8ca1e63d533f1c31a52d7d181ac5ec68e9b8" dependencies = [ "alloy-consensus", "alloy-eips", @@ -298,17 +307,19 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", + "cfg-if", + "derive_more 1.0.0", + "hashbrown 0.14.5", "itertools 0.13.0", "serde", "serde_json", - "thiserror", ] [[package]] name = "alloy-serde" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd260ede54f0b53761fdd04133acc10ae70427f66a69aa9590529bbd066cd58" +checksum = "731f75ec5d383107fd745d781619bd9cedf145836c51ecb991623d41278e71fa" dependencies = [ "alloy-primitives", "arbitrary", @@ -318,9 +329,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5193ee6b370b89db154d7dc40c6a8e6ce11213865baaf2b418a9f2006be762" +checksum = "307324cca94354cd654d6713629f0383ec037e1ff9e3e3d547212471209860c0" dependencies = [ "alloy-primitives", "async-trait", @@ -332,66 +343,66 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "183bcfc0f3291d9c41a3774172ee582fb2ce6eb6569085471d8f225de7bb86fc" +checksum = "3b2395336745358cc47207442127c47c63801a7065ecc0aa928da844f8bb5576" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71c4d842beb7a6686d04125603bc57614d5ed78bf95e4753274db3db4ba95214" +checksum = "9ed5047c9a241df94327879c2b0729155b58b941eae7805a7ada2e19436e6b39" dependencies = [ "alloy-sol-macro-input", "const-hex", "heck 0.5.0", "indexmap", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1306e8d3c9e6e6ecf7a39ffaf7291e73a5f655a2defd366ee92c2efebcdf7fee" +checksum = "5dee02a81f529c415082235129f0df8b8e60aa1601b9c9298ffe54d75f57210b" dependencies = [ "const-hex", "dunce", "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4691da83dce9c9b4c775dd701c87759f173bd3021cbf2e60cde00c5fe6d7241" +checksum = "f631f0bd9a9d79619b27c91b6b1ab2c4ef4e606a65192369a1ee05d40dcf81cc" dependencies = [ "serde", - "winnow 0.6.18", + "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "577e262966e92112edbd15b1b2c0947cc434d6e8311df96d3329793fe8047da9" +checksum = "c2841af22d99e2c0f82a78fe107b6481be3dd20b89bfb067290092794734343a" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -402,9 +413,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "454220c714857cf68af87d788d1f0638ad8766268b94f6a49fed96cbc2ab382c" +checksum = "33616b2edf7454302a1d48084db185e52c309f73f6c10be99b0fe39354b3f1e9" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -421,13 +432,13 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.3.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377f2353d7fea03a2dba6b9ffbb7d610402c040dd5700d1fae8b9ec2673eed9b" +checksum = "a944f5310c690b62bbb3e7e5ce34527cbd36b2d18532a797af123271ce595a49" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.5", + "reqwest 0.12.8", "serde_json", "tower", "tracing", @@ -451,15 +462,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" [[package]] name = "arbitrary" @@ -504,7 +515,7 @@ dependencies = [ "num-bigint 0.4.6", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "zeroize", ] @@ -596,15 +607,15 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -613,24 +624,24 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -641,7 +652,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -679,28 +690,28 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -827,9 +838,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -857,9 +868,12 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.0" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -920,18 +934,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstyle", "clap_lex", @@ -939,9 +953,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "console" @@ -958,9 +972,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" +checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" dependencies = [ "cfg-if", "cpufeatures", @@ -975,12 +989,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "core-foundation" version = "0.9.4" @@ -993,15 +1001,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1015,7 +1023,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.9", + "clap 4.5.20", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -1097,13 +1105,13 @@ dependencies = [ [[package]] name = "dashmap" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", "crossbeam-utils", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -1153,7 +1161,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -1162,11 +1170,30 @@ version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn 2.0.70", + "syn 2.0.82", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.82", + "unicode-xid", ] [[package]] @@ -1192,9 +1219,9 @@ dependencies = [ [[package]] name = "dunce" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "dyn-clone" @@ -1282,7 +1309,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -1442,9 +1469,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fastrlp" @@ -1503,6 +1530,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1535,9 +1568,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1550,9 +1583,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1560,15 +1593,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1577,32 +1610,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -1616,9 +1649,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1671,9 +1704,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -1725,9 +1758,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -1769,6 +1802,18 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", + "serde", +] + [[package]] name = "hashers" version = "1.0.1" @@ -1808,6 +1853,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -1867,9 +1918,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http 1.1.0", @@ -1884,15 +1935,15 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -1902,9 +1953,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -1926,16 +1977,16 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "httparse", "itoa", "pin-project-lite", @@ -1952,7 +2003,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", @@ -1960,15 +2011,15 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", - "rustls 0.23.11", + "rustls 0.23.15", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -1983,7 +2034,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "native-tls", "tokio", @@ -1993,20 +2044,19 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", - "hyper 1.4.1", + "http-body 1.0.1", + "hyper 1.5.0", "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -2067,12 +2117,14 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ + "arbitrary", "equivalent", - "hashbrown", + "hashbrown 0.15.0", + "serde", ] [[package]] @@ -2099,17 +2151,17 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi 0.4.0", "libc", "windows-sys 0.52.0", ] @@ -2140,9 +2192,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -2163,9 +2215,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -2186,9 +2238,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" +checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -2218,9 +2270,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libm" @@ -2252,11 +2304,11 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.12.3" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -2279,18 +2331,18 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi 0.3.9", "libc", @@ -2418,23 +2470,23 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -2445,18 +2497,18 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.1" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -2491,9 +2543,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -2512,7 +2564,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -2523,9 +2575,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.102" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -2616,9 +2668,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", "thiserror", @@ -2632,7 +2684,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ "futures", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -2665,7 +2717,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -2679,22 +2731,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -2721,9 +2773,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plain_hasher" @@ -2736,9 +2788,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -2749,24 +2801,24 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -2776,9 +2828,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "primeorder" @@ -2805,9 +2860,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] @@ -2836,11 +2891,33 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.82", +] + [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -2873,7 +2950,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -2884,9 +2961,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -2906,6 +2983,7 @@ dependencies = [ "libc", "rand_chacha", "rand_core", + "serde", ] [[package]] @@ -2958,18 +3036,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.2" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -2979,9 +3057,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -2990,9 +3068,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relative-path" @@ -3014,7 +3092,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -3029,7 +3107,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 0.1.2", - "system-configuration", + "system-configuration 0.5.1", "tokio", "tokio-rustls 0.24.1", "tower-service", @@ -3038,26 +3116,26 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots", - "winreg 0.50.0", + "winreg", ] [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", - "hyper 1.4.1", - "hyper-rustls 0.27.2", + "hyper 1.5.0", + "hyper-rustls 0.27.3", "hyper-tls", "hyper-util", "ipnet", @@ -3068,12 +3146,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.2.0", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 1.0.1", - "system-configuration", + "system-configuration 0.6.1", "tokio", "tokio-native-tls", "tower-service", @@ -3081,7 +3159,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg 0.52.0", + "windows-registry", ] [[package]] @@ -3101,7 +3179,7 @@ dependencies = [ "ethers-core", "ethers-providers", "indicatif", - "reqwest 0.12.5", + "reqwest 0.12.8", "revm-interpreter", "revm-precompile", "rstest", @@ -3162,7 +3240,7 @@ dependencies = [ "cfg-if", "dyn-clone", "enumn", - "hashbrown", + "hashbrown 0.14.5", "hex", "kzg-rs", "serde", @@ -3188,7 +3266,7 @@ version = "0.10.1" dependencies = [ "alloy-rlp", "hash-db", - "hashbrown", + "hashbrown 0.14.5", "hex", "indicatif", "k256", @@ -3283,7 +3361,7 @@ dependencies = [ "futures", "futures-timer", "rstest_macros", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -3299,8 +3377,8 @@ dependencies = [ "quote", "regex", "relative-path", - "rustc_version 0.4.0", - "syn 2.0.70", + "rustc_version 0.4.1", + "syn 2.0.82", "unicode-ident", ] @@ -3341,6 +3419,15 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +dependencies = [ + "rand", +] + [[package]] name = "rustc-hex" version = "2.1.0" @@ -3358,18 +3445,18 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver 1.0.23", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -3392,13 +3479,13 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.11" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "once_cell", "rustls-pki-types", - "rustls-webpki 0.102.5", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -3414,19 +3501,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -3440,9 +3526,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.5" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -3451,9 +3537,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rusty-fork" @@ -3489,7 +3575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "scale-info-derive", ] @@ -3508,11 +3594,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3547,9 +3633,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" dependencies = [ "rand", "secp256k1-sys", @@ -3557,18 +3643,18 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" dependencies = [ "cc", ] [[package]] name = "security-framework" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", "core-foundation", @@ -3579,9 +3665,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -3625,29 +3711,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "indexmap", "itoa", @@ -3702,14 +3788,20 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" +checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" dependencies = [ "cc", "cfg-if", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" version = "2.2.0" @@ -3775,9 +3867,9 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "1.2.0-rc1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f600a97b145e66f0f5e56595527c359f5cc8cb1f9dc8a6da1ba34bb845c9d1e" +checksum = "bea7811abd2d3a991007fcb284f41152840b8388c171288d0c52c6793956609c" dependencies = [ "anyhow", "bincode", @@ -3879,7 +3971,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -3914,9 +4006,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.70" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -3925,14 +4017,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284c41c2919303438fcf8dede4036fd1e82d4fc0fbb2b279bd2a1442c909ca92" +checksum = "ebfc1bfd06acc78f16d8fd3ef846bc222ee7002468d10a7dce8d703d6eab89a3" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -3946,6 +4038,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "system-configuration" @@ -3955,7 +4050,18 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", "core-foundation", - "system-configuration-sys", + "system-configuration-sys 0.5.0", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "system-configuration-sys 0.6.0", ] [[package]] @@ -3968,6 +4074,16 @@ dependencies = [ "libc", ] +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -3976,14 +4092,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3997,22 +4114,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -4091,9 +4208,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -4113,7 +4230,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -4142,16 +4259,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.11", + "rustls 0.23.15", "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -4176,9 +4293,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -4189,48 +4306,46 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", - "winnow 0.5.40", + "winnow", ] [[package]] name = "tower" -version = "0.4.13" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" dependencies = [ "futures-core", "futures-util", - "pin-project", "pin-project-lite", - "tokio", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", - "tracing", ] [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -4238,7 +4353,6 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4252,7 +4366,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -4318,9 +4432,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "uint" @@ -4342,42 +4456,42 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "untrusted" @@ -4428,9 +4542,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wait-timeout" @@ -4468,34 +4582,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -4505,9 +4620,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4515,28 +4630,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -4566,11 +4681,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4579,6 +4694,36 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -4597,6 +4742,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -4720,18 +4874,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.40" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "winnow" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -4746,16 +4891,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -4767,7 +4902,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "send_wrapper 0.6.0", "thiserror", "wasm-bindgen", @@ -4790,6 +4925,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -4801,7 +4937,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] [[package]] @@ -4821,5 +4957,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.82", ] From 3500632f7184d32dabb7d993147e62cf37b4f700 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 07:35:54 +0000 Subject: [PATCH 8/8] chore: release --- bins/revm-test/CHANGELOG.md | 107 ++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/bins/revm-test/CHANGELOG.md b/bins/revm-test/CHANGELOG.md index 19d50a211f..e06e7d6e05 100644 --- a/bins/revm-test/CHANGELOG.md +++ b/bins/revm-test/CHANGELOG.md @@ -6,6 +6,113 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.0](https://github.com/CeciliaZ030/revm/releases/tag/revm-test-v0.1.0) - 2024-10-29 + +### Added + +- EOF (Ethereum Object Format) ([#1143](https://github.com/CeciliaZ030/revm/pull/1143)) +- add tests for shift instructions ([#1254](https://github.com/CeciliaZ030/revm/pull/1254)) +- EvmBuilder and External Contexts ([#888](https://github.com/CeciliaZ030/revm/pull/888)) +- separate initial checks ([#486](https://github.com/CeciliaZ030/revm/pull/486)) +- revm-interpreter created ([#320](https://github.com/CeciliaZ030/revm/pull/320)) +- *(interpreter)* Unify instruction fn signature ([#283](https://github.com/CeciliaZ030/revm/pull/283)) +- Migrate `primitive_types::U256` to `ruint::Uint<256, 4>` ([#239](https://github.com/CeciliaZ030/revm/pull/239)) +- Introduce ByteCode format, Update Readme ([#156](https://github.com/CeciliaZ030/revm/pull/156)) + +### Fixed + +- *(eof)* fixture 2 tests ([#1550](https://github.com/CeciliaZ030/revm/pull/1550)) +- *(clippy)* fix some clippy lints + +### Other + +- Sync database ([#17](https://github.com/CeciliaZ030/revm/pull/17)) +- release ([#1729](https://github.com/CeciliaZ030/revm/pull/1729)) +- release ([#1722](https://github.com/CeciliaZ030/revm/pull/1722)) +- *(deps)* bump alloy and primitives ([#1725](https://github.com/CeciliaZ030/revm/pull/1725)) +- *(deps)* bump bytes from 1.6.1 to 1.7.1 ([#1700](https://github.com/CeciliaZ030/revm/pull/1700)) +- tag v41 revm v13.0.0 ([#1692](https://github.com/CeciliaZ030/revm/pull/1692)) +- release ([#1683](https://github.com/CeciliaZ030/revm/pull/1683)) +- *(deps)* bump regex from 1.10.5 to 1.10.6 ([#1682](https://github.com/CeciliaZ030/revm/pull/1682)) +- bump versions bcs of primitives ([#1631](https://github.com/CeciliaZ030/revm/pull/1631)) +- release ([#1620](https://github.com/CeciliaZ030/revm/pull/1620)) +- *(deps)* bump alloy-sol-types from 0.7.6 to 0.7.7 ([#1614](https://github.com/CeciliaZ030/revm/pull/1614)) +- *(deps)* bump alloy-sol-macro from 0.7.6 to 0.7.7 ([#1613](https://github.com/CeciliaZ030/revm/pull/1613)) +- release ([#1579](https://github.com/CeciliaZ030/revm/pull/1579)) +- release ([#1548](https://github.com/CeciliaZ030/revm/pull/1548)) +- replace TransactTo with TxKind ([#1542](https://github.com/CeciliaZ030/revm/pull/1542)) +- *(deps)* bump regex from 1.10.4 to 1.10.5 ([#1502](https://github.com/CeciliaZ030/revm/pull/1502)) +- release ([#1261](https://github.com/CeciliaZ030/revm/pull/1261)) +- *(interpreter)* rewrite gas accounting for memory expansion ([#1361](https://github.com/CeciliaZ030/revm/pull/1361)) +- revert snailtracer without microbench ([#1259](https://github.com/CeciliaZ030/revm/pull/1259)) +- release ([#1231](https://github.com/CeciliaZ030/revm/pull/1231)) +- *(deps)* bump other alloy deps 0.7.0 ([#1252](https://github.com/CeciliaZ030/revm/pull/1252)) +- *(deps)* bump regex from 1.10.3 to 1.10.4 ([#1223](https://github.com/CeciliaZ030/revm/pull/1223)) +- *(deps)* bump bytes from 1.5.0 to 1.6.0 ([#1224](https://github.com/CeciliaZ030/revm/pull/1224)) +- release ([#1175](https://github.com/CeciliaZ030/revm/pull/1175)) +- tag v32 revm v7.1.0 ([#1176](https://github.com/CeciliaZ030/revm/pull/1176)) +- release ([#1125](https://github.com/CeciliaZ030/revm/pull/1125)) +- *(deps)* bump alloy-sol-types from 0.6.3 to 0.6.4 ([#1148](https://github.com/CeciliaZ030/revm/pull/1148)) +- *(deps)* bump alloy-sol-macro from 0.6.3 to 0.6.4 ([#1136](https://github.com/CeciliaZ030/revm/pull/1136)) +- release tag v30 revm v6.1.0 ([#1100](https://github.com/CeciliaZ030/revm/pull/1100)) +- clippy cleanup ([#1112](https://github.com/CeciliaZ030/revm/pull/1112)) +- *(deps)* bump alloy-sol-types from 0.6.2 to 0.6.3 ([#1103](https://github.com/CeciliaZ030/revm/pull/1103)) +- release ([#1082](https://github.com/CeciliaZ030/revm/pull/1082)) +- *(deps)* bump alloy-sol-macro from 0.6.2 to 0.6.3 ([#1094](https://github.com/CeciliaZ030/revm/pull/1094)) +- license date and revm docs ([#1080](https://github.com/CeciliaZ030/revm/pull/1080)) +- release ([#1067](https://github.com/CeciliaZ030/revm/pull/1067)) +- tag v27, revm v4.0.0 release ([#1061](https://github.com/CeciliaZ030/revm/pull/1061)) +- *(deps)* bump eyre from 0.6.11 to 0.6.12 ([#1051](https://github.com/CeciliaZ030/revm/pull/1051)) +- *(deps)* bump alloy-sol-types from 0.6.0 to 0.6.2 ([#1035](https://github.com/CeciliaZ030/revm/pull/1035)) +- *(deps)* bump alloy-sol-macro from 0.6.0 to 0.6.2 ([#1013](https://github.com/CeciliaZ030/revm/pull/1013)) +- chore(Test) : const to static ([#1016](https://github.com/CeciliaZ030/revm/pull/1016)) +- Burntpix criterion bench ([#1004](https://github.com/CeciliaZ030/revm/pull/1004)) +- Instruction table ([#759](https://github.com/CeciliaZ030/revm/pull/759)) +- rewrite revm-test as a criterion bench ([#579](https://github.com/CeciliaZ030/revm/pull/579)) +- optimize stack usage for recursive `call` and `create` programs ([#522](https://github.com/CeciliaZ030/revm/pull/522)) +- Bump v24, revm v3.3.0 ([#476](https://github.com/CeciliaZ030/revm/pull/476)) +- Release v23, revm v3.2.0 ([#464](https://github.com/CeciliaZ030/revm/pull/464)) +- Release v22, revm v3.1.1 ([#460](https://github.com/CeciliaZ030/revm/pull/460)) +- v21, revm v3.1.0 ([#444](https://github.com/CeciliaZ030/revm/pull/444)) +- remove gas blocks ([#391](https://github.com/CeciliaZ030/revm/pull/391)) +- *(deps)* bump bytes from 1.3.0 to 1.4.0 ([#355](https://github.com/CeciliaZ030/revm/pull/355)) +- Bump v20, changelog ([#350](https://github.com/CeciliaZ030/revm/pull/350)) +- includes to libs ([#338](https://github.com/CeciliaZ030/revm/pull/338)) +- Creating revm-primitives, revm better errors and db components ([#334](https://github.com/CeciliaZ030/revm/pull/334)) +- Cleanup, move hot fields toggether in Interpreter ([#321](https://github.com/CeciliaZ030/revm/pull/321)) +- native bits ([#278](https://github.com/CeciliaZ030/revm/pull/278)) +- *(release)* Bump revm and precompiles versions +- Bump primitive_types. Add statetest spec +- Bump revm v2.1.0 ([#224](https://github.com/CeciliaZ030/revm/pull/224)) +- revm bump v2.0.0, precompile bump v1.1.1 ([#212](https://github.com/CeciliaZ030/revm/pull/212)) +- Cfg choose create analysis, option on bytecode size limit ([#210](https://github.com/CeciliaZ030/revm/pull/210)) +- Cargo sort. Bump lib versions ([#208](https://github.com/CeciliaZ030/revm/pull/208)) +- Return `ExecutionResult`, which includes `gas_refunded` ([#169](https://github.com/CeciliaZ030/revm/pull/169)) +- Bytecode hash, remove override_spec, ([#165](https://github.com/CeciliaZ030/revm/pull/165)) +- revm bump 1.8. update libs. snailtracer rename ([#159](https://github.com/CeciliaZ030/revm/pull/159)) +- v6 changelog, bump versions +- Big Refactor. Machine to Interpreter. refactor instructions. call/create struct ([#52](https://github.com/CeciliaZ030/revm/pull/52)) +- [revm] pop_top and unsafe comments ([#51](https://github.com/CeciliaZ030/revm/pull/51)) +- [precompiles] remove unused borsh +- [recompl] Bump precompile deps, cargo sort on workspace +- [revm] output log. Stetetest test log output. fmt +- Bump versions, Changelogs, fmt, revm readme, clippy. +- [revm] Run test multiple times. fmt, BenchmarkDB +- Multiple changes: web3 db, debugger initial commit, precompile load +- Memory to usize, clippy,fmt +- wip optimize i256 +- TEMP switch stacks H256 with U256 +- [revm] some perfs +- [revm] Perfs stack pop. Benchmark snailtracer. +- [revm] cleanup +- fmt +- EVM Interface changed. Inspector called separately +- Bump revm v0.3.0. README updated +- DB ref mut polished +- And now we debug +- [revm] Interface. Inspector added, Env cleanup. revm-test passes +- Rename bin to bins + ## [0.1.0](https://github.com/bluealloy/revm/releases/tag/revm-test-v0.1.0) - 2024-08-30 ### Added