diff --git a/Cargo.lock b/Cargo.lock index 0910238ed85..776fe9e934a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,11 +81,23 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f54319708cdf93563fe45b1afd475901cecbd0edb992305dc91eadc52d7717e" dependencies = [ + "alloy-rlp-derive", "arrayvec", "bytes", "smol_str", ] +[[package]] +name = "alloy-rlp-derive" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece59dee9b64680d9fcdd7a51ebe4e268c26c46273125d39f50dc1ed2e386325" +dependencies = [ + "proc-macro2 1.0.66", + "quote 1.0.32", + "syn 2.0.27", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -2131,6 +2143,7 @@ name = "revm-primitives" version = "1.1.2" dependencies = [ "alloy-primitives", + "alloy-rlp", "arbitrary", "auto_impl", "bitflags 2.3.3", @@ -2144,7 +2157,7 @@ dependencies = [ "primitive-types", "proptest", "proptest-derive", - "ruint2", + "ruint", "serde", "to-binary", ] @@ -2162,16 +2175,16 @@ dependencies = [ name = "revme" version = "0.2.0" dependencies = [ + "alloy-rlp", "hash-db", "hashbrown 0.14.0", "hex", "hex-literal", "indicatif", "plain_hasher", - "primitive-types", "revm", "rlp", - "ruint2", + "ruint", "serde", "serde_json", "structopt", @@ -2244,7 +2257,9 @@ checksum = "77e1574d439643c8962edf612a888e7cc5581bcdf36cb64e6bc88466b03b2daa" dependencies = [ "alloy-rlp", "arbitrary", + "primitive-types", "proptest", + "rlp", "ruint-macro", "serde", "thiserror", @@ -2256,29 +2271,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e666a5496a0b2186dbcd0ff6106e29e093c15591bde62c20d3842007c6978a09" -[[package]] -name = "ruint2" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b066b8e4fcea7fae86b6932d2449670b6b5545b7e8407841b2d3a916ff2a9f86" -dependencies = [ - "arbitrary", - "derive_more", - "primitive-types", - "proptest", - "rlp", - "ruint2-macro", - "rustc_version", - "serde", - "thiserror", -] - -[[package]] -name = "ruint2-macro" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89dc553bc0cf4512a8b96caa2e21ed5f6e4b66bf28a1bd08fd9eb07c0b39b28c" - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2321,7 +2313,7 @@ checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" dependencies = [ "log", "ring", - "rustls-webpki 0.101.1", + "rustls-webpki 0.101.2", "sct", ] @@ -2346,9 +2338,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.1" +version = "0.101.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e" +checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" dependencies = [ "ring", "untrusted", diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index eb4e9a57bdd..5eccd268a9c 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -15,14 +15,14 @@ hashbrown = "0.14" hex = "0.4" indicatif = "0.17" plain_hasher = "0.2" -primitive-types = { version = "0.12", features = ["rlp", "serde"] } revm = { path = "../../crates/revm", version = "3.3.0", default-features = false, features = [ "ethersdb", "std", "serde", ] } rlp = { version = "0.5", default-features = false } -ruint2 = { version = "1.9.0", features = ["rlp", "serde"] } +alloy-rlp = { version = "0.3", default-features = false, features = ["arrayvec"] } +ruint = { version = "1.9.0", features = ["rlp", "serde"] } serde = { version = "1.0", features = ["derive", "rc"] } serde_json = { version = "1.0", features = ["preserve_order"] } structopt = "0.3" diff --git a/bins/revme/src/statetest/merkle_trie.rs b/bins/revme/src/statetest/merkle_trie.rs index 0304a64bc00..cda0bfd2e14 100644 --- a/bins/revme/src/statetest/merkle_trie.rs +++ b/bins/revme/src/statetest/merkle_trie.rs @@ -1,79 +1,74 @@ +use alloy_rlp::{RlpEncodable, RlpMaxEncodedLen}; use hash_db::Hasher; use plain_hasher::PlainHasher; -use primitive_types::{H160, H256}; use revm::{ db::PlainAccount, - primitives::{keccak256, Address, Bytes, Log, B256, U256}, + primitives::{keccak256, Address, Log, B256, U256}, }; -use rlp::RlpStream; use triehash::sec_trie_root; -// TODO(dani): move rlp - -pub fn log_rlp_hash(logs: Vec) -> B256 { - //https://github.com/ethereum/go-ethereum/blob/356bbe343a30789e77bb38f25983c8f2f2bfbb47/cmd/evm/internal/t8ntool/execution.go#L255 - let mut stream = RlpStream::new(); - stream.begin_unbounded_list(); - for log in logs { - stream.begin_list(3); - stream.append(&&log.address[..]); - stream.begin_unbounded_list(); - for topic in log.topics { - stream.append(&&topic[..]); - } - stream.finalize_unbounded_list(); - stream.append(&&log.data[..]); - } - stream.finalize_unbounded_list(); - let out = stream.out().freeze(); - +pub fn log_rlp_hash(logs: &[Log]) -> B256 { + let mut out = Vec::with_capacity(alloy_rlp::list_length(logs)); + alloy_rlp::encode_list(logs, &mut out); keccak256(&out) } pub fn state_merkle_trie_root<'a>( accounts: impl IntoIterator, ) -> B256 { - let vec = accounts - .into_iter() - .map(|(address, info)| { - let acc_root = trie_account_rlp(info); - (H160::from(address.0 .0), acc_root) - }) - .collect(); + trie_root(accounts.into_iter().map(|(address, acc)| { + ( + address, + alloy_rlp::encode_fixed_size(&TrieAccount::new(acc)), + ) + })) +} - trie_root(vec) +#[derive(RlpEncodable, RlpMaxEncodedLen)] +struct TrieAccount { + nonce: u64, + balance: U256, + root_hash: B256, + code_hash: B256, } -/// Returns the RLP for this account. -pub fn trie_account_rlp(acc: &PlainAccount) -> Bytes { - let mut stream = RlpStream::new_list(4); - stream.append(&acc.info.nonce); - stream.append(&acc.info.balance); - stream.append(&{ - sec_trie_root::( - acc.storage - .iter() - .filter(|(_k, &v)| v != U256::ZERO) - .map(|(&k, v)| (H256::from(k.to_be_bytes()), rlp::encode(v))), - ) - }); - stream.append(&acc.info.code_hash.0.as_ref()); - stream.out().freeze().into() +impl TrieAccount { + #[inline(always)] + fn new(acc: &PlainAccount) -> Self { + Self { + nonce: acc.info.nonce, + balance: acc.info.balance, + root_hash: sec_trie_root::( + acc.storage + .iter() + .filter(|(_k, &v)| v != U256::ZERO) + .map(|(k, v)| (k.to_be_bytes::<32>(), alloy_rlp::encode_fixed_size(v))), + ), + code_hash: acc.info.code_hash, + } + } } -pub fn trie_root(acc_data: Vec<(H160, Bytes)>) -> B256 { - B256::new(sec_trie_root::(acc_data).0) +#[inline] +pub fn trie_root(input: I) -> B256 +where + I: IntoIterator, + A: AsRef<[u8]>, + B: AsRef<[u8]>, +{ + sec_trie_root::(input) } #[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct KeccakHasher; impl Hasher for KeccakHasher { - type Out = H256; + type Out = B256; type StdHasher = PlainHasher; const LENGTH: usize = 32; + #[inline] fn hash(x: &[u8]) -> Self::Out { - keccak256(x).0.into() + keccak256(x) } } diff --git a/bins/revme/src/statetest/models/mod.rs b/bins/revme/src/statetest/models/mod.rs index 19571607e3e..99e6442c544 100644 --- a/bins/revme/src/statetest/models/mod.rs +++ b/bins/revme/src/statetest/models/mod.rs @@ -1,5 +1,5 @@ use revm::primitives::{Address, Bytes, HashMap, B256, U256}; -use serde::Deserialize; +use serde::{de, Deserialize}; use std::collections::BTreeMap; mod deserializer; @@ -9,7 +9,7 @@ mod spec; pub use self::spec::SpecName; #[derive(Debug, PartialEq, Eq, Deserialize)] -pub struct TestSuit(pub BTreeMap); +pub struct TestSuite(pub BTreeMap); #[derive(Debug, PartialEq, Eq, Deserialize)] pub struct TestUnit { @@ -72,6 +72,7 @@ pub struct TransactionParts { pub gas_price: Option, pub nonce: U256, pub secret_key: Option, + #[serde(deserialize_with = "deserialize_maybe_empty")] pub to: Option
, pub value: Vec, pub max_fee_per_gas: Option, @@ -87,6 +88,18 @@ pub struct AccessListItem { pub type AccessList = Vec; +pub fn deserialize_maybe_empty<'de, D>(deserializer: D) -> Result, D::Error> +where + D: de::Deserializer<'de>, +{ + let string = String::deserialize(deserializer)?; + if string.is_empty() { + Ok(None) + } else { + string.parse().map_err(de::Error::custom).map(Some) + } +} + #[cfg(test)] mod tests { diff --git a/bins/revme/src/statetest/runner.rs b/bins/revme/src/statetest/runner.rs index 3f1a8b564ac..5c80ad3ca7b 100644 --- a/bins/revme/src/statetest/runner.rs +++ b/bins/revme/src/statetest/runner.rs @@ -1,6 +1,5 @@ use std::io::stdout; use std::{ - ffi::OsStr, path::{Path, PathBuf}, sync::{atomic::AtomicBool, Arc, Mutex}, time::{Duration, Instant}, @@ -8,7 +7,7 @@ use std::{ use super::{ merkle_trie::{log_rlp_hash, state_merkle_trie_root}, - models::{SpecName, TestSuit}, + models::{SpecName, TestSuite}, }; use indicatif::ProgressBar; use revm::inspectors::TracerEip3155; @@ -32,7 +31,7 @@ pub enum TestError { got: B256, expect: B256, }, - #[error("Serde json error")] + #[error("Serde json error: {0}")] SerdeDeserialize(#[from] serde_json::Error), #[error("Internal system error")] SystemError, @@ -49,44 +48,44 @@ pub fn find_all_json_tests(path: &Path) -> Vec { .collect::>() } -pub fn execute_test_suit( +pub fn execute_test_suite( path: &Path, elapsed: &Arc>, trace: bool, ) -> Result<(), TestError> { + let name = path.file_name().unwrap().to_str().unwrap(); + // funky test with `bigint 0x00` value in json :) not possible to happen on mainnet and require custom json parser. // https://github.com/ethereum/tests/issues/971 - if path.file_name() == Some(OsStr::new("ValueOverflow.json")) { + if name == "ValueOverflow.json" { return Ok(()); } // precompiles having storage is not possible - if path.file_name() == Some(OsStr::new("RevertPrecompiledTouch_storage.json")) - || path.file_name() == Some(OsStr::new("RevertPrecompiledTouch.json")) - { + if name == "RevertPrecompiledTouch_storage.json" || name == "RevertPrecompiledTouch.json" { return Ok(()); } // txbyte is of type 02 and we dont parse tx bytes for this test to fail. - if path.file_name() == Some(OsStr::new("typeTwoBerlin.json")) { + if name == "typeTwoBerlin.json" { return Ok(()); } // Test checks if nonce overflows. We are handling this correctly but we are not parsing exception in testsuite // There are more nonce overflow tests that are in internal call/create, and those tests are passing and are enabled. - if path.file_name() == Some(OsStr::new("CreateTransactionHighNonce.json")) { + if name == "CreateTransactionHighNonce.json" { return Ok(()); } // Need to handle Test errors - if path.file_name() == Some(OsStr::new("transactionIntinsicBug.json")) { + if name == "transactionIntinsicBug.json" { return Ok(()); } // Test check if gas price overflows, we handle this correctly but does not match tests specific exception. - if path.file_name() == Some(OsStr::new("HighGasPrice.json")) - || path.file_name() == Some(OsStr::new("CREATE_HighNonce.json")) - || path.file_name() == Some(OsStr::new("CREATE_HighNonceMinus1.json")) + if name == "HighGasPrice.json" + || name == "CREATE_HighNonce.json" + || name == "CREATE_HighNonceMinus1.json" { return Ok(()); } @@ -94,20 +93,20 @@ pub fn execute_test_suit( // Skip test where basefee/accesslist/diffuculty is present but it shouldn't be supported in London/Berlin/TheMerge. // https://github.com/ethereum/tests/blob/5b7e1ab3ffaf026d99d20b17bb30f533a2c80c8b/GeneralStateTests/stExample/eip1559.json#L130 // It is expected to not execute these tests. - if path.file_name() == Some(OsStr::new("accessListExample.json")) - || path.file_name() == Some(OsStr::new("basefeeExample.json")) - || path.file_name() == Some(OsStr::new("eip1559.json")) - || path.file_name() == Some(OsStr::new("mergeTest.json")) + if name == "accessListExample.json" + || name == "basefeeExample.json" + || name == "eip1559.json" + || name == "mergeTest.json" { return Ok(()); } // These tests are passing, but they take a lot of time to execute so we are going to skip them. - if path.file_name() == Some(OsStr::new("loopExp.json")) - || path.file_name() == Some(OsStr::new("Call50000_sha256.json")) - || path.file_name() == Some(OsStr::new("static_Call50000_sha256.json")) - || path.file_name() == Some(OsStr::new("loopMul.json")) - || path.file_name() == Some(OsStr::new("CALLBlake2f_MaxRounds.json")) + if name == "loopExp.json" + || name == "Call50000_sha256.json" + || name == "static_Call50000_sha256.json" + || name == "loopMul.json" + || name == "CALLBlake2f_MaxRounds.json" { return Ok(()); } @@ -121,10 +120,10 @@ pub fn execute_test_suit( return Ok(()); } - let json_reader = std::fs::read(path).unwrap(); - let suit: TestSuit = serde_json::from_reader(&*json_reader)?; + let s = std::fs::read_to_string(path).unwrap(); + let suite: TestSuite = serde_json::from_str(&s)?; - let map_caller_keys: HashMap<_, _> = vec![ + let map_caller_keys: HashMap<_, _> = [ ( b256!("45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"), address!("a94f5374fce5edbc8e2a8697c15331677e6ebf0b"), @@ -150,13 +149,12 @@ pub fn execute_test_suit( address!("dcc5ba93a1ed7e045690d722f2bf460a51c61415"), ), ] - .into_iter() - .collect(); + .into(); - for (name, unit) in suit.0.into_iter() { + for (name, unit) in suite.0 { // Create database and insert cache let mut cache_state = revm::CacheState::new(false); - for (address, info) in unit.pre.into_iter() { + for (address, info) in unit.pre { let acc_info = revm::primitives::AccountInfo { balance: info.balance, code_hash: keccak256(&info.code), // try with dummy hash. @@ -207,29 +205,26 @@ pub fn execute_test_suit( env.cfg.spec_id = spec_name.to_spec_id(); for (id, test) in tests.into_iter().enumerate() { - let gas_limit = *unit.transaction.gas_limit.get(test.indexes.gas).unwrap(); - let gas_limit = u64::try_from(gas_limit).unwrap_or(u64::MAX); - env.tx.gas_limit = gas_limit; + env.tx.gas_limit = unit.transaction.gas_limit[test.indexes.gas].saturating_to(); env.tx.data = unit .transaction .data .get(test.indexes.data) .unwrap() .clone(); - env.tx.value = *unit.transaction.value.get(test.indexes.value).unwrap(); + env.tx.value = unit.transaction.value[test.indexes.value]; let access_list = match unit.transaction.access_lists { Some(ref access_list) => access_list .get(test.indexes.data) - .cloned() - .flatten() + .and_then(Option::as_deref) .unwrap_or_default() - .into_iter() + .iter() .map(|item| { ( item.address, item.storage_keys - .into_iter() + .iter() .map(|key| U256::from_be_bytes(key.0)) .collect::>(), ) @@ -275,7 +270,7 @@ pub fn execute_test_suit( Ok(ExecutionResult::Success { logs, .. }) => logs.clone(), _ => Vec::new(), }; - let logs_root = log_rlp_hash(logs); + let logs_root = log_rlp_hash(&logs); if test.hash != state_root || test.logs != logs_root { println!( "Roots did not match:\nState root: wanted {:?}, got {state_root:?}\nLogs root: wanted {:?}, got {logs_root:?}", @@ -381,7 +376,7 @@ pub fn run( return Ok(()); } //println!("Test:{:?}\n",test_path); - if let Err(err) = execute_test_suit(&test_path, &elapsed, trace) { + if let Err(err) = execute_test_suite(&test_path, &elapsed, trace) { endjob.store(true, Ordering::SeqCst); println!("Test[{index}] named:\n{test_path:?} failed: {err}\n"); return Err(err); diff --git a/crates/precompile/src/secp256k1.rs b/crates/precompile/src/secp256k1.rs index 2e64cdfccce..beb75814048 100644 --- a/crates/precompile/src/secp256k1.rs +++ b/crates/precompile/src/secp256k1.rs @@ -21,7 +21,7 @@ mod secp256k1 { let recovered_key = VerifyingKey::recover_from_prehash(msg, &signature, recid)?; // hash it - let hash = keccak256( + let mut hash = keccak256( &recovered_key .to_encoded_point(/* compress = */ false) .as_bytes()[1..], diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 95758a2793c..4eb4924cb14 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -10,10 +10,11 @@ version = "1.1.2" readme = "../../README.md" [dependencies] -# TODO: Remove git once 0.2.1 is released +# TODO(dani): Remove git alloy-primitives = { version = "0.2", git = "https://github.com/alloy-rs/core", default-features = false, features = [ "rlp", ] } +alloy-rlp = { version = "0.3", default-features = false, features = ["derive"] } bytes = { version = "1.4", default-features = false } hashbrown = "0.14" primitive-types = { version = "0.12", default-features = false } @@ -38,7 +39,7 @@ proptest-derive = { version = "0.3", optional = true } arbitrary = { version = "1.3", features = ["derive"] } proptest = "1.1" proptest-derive = "0.3" -ruint2 = { version = "1.9.0", features = ["primitive-types", "rlp", "proptest", "arbitrary"] } +ruint = { version = "1.9.0", features = ["primitive-types", "rlp", "proptest", "arbitrary"] } [features] default = ["std"] diff --git a/crates/primitives/src/bytecode.rs b/crates/primitives/src/bytecode.rs index c9999a6c6f6..a8a8a51286f 100644 --- a/crates/primitives/src/bytecode.rs +++ b/crates/primitives/src/bytecode.rs @@ -124,9 +124,7 @@ impl Bytecode { match self.state { BytecodeState::Raw => self.bytecode.clone(), BytecodeState::Checked { len } | BytecodeState::Analysed { len, .. } => { - // TODO(dani): - // self.bytecode.slice(0..len) - self.bytecode.0.slice(0..len).into() + self.bytecode.slice(0..len).into() } } } diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 475e6fdd12c..6e269269cc2 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -13,7 +13,6 @@ pub mod specification; pub mod state; pub mod utilities; -pub use ::hex; pub use alloy_primitives::{ self, address, b256, bytes, fixed_bytes, hex, hex_literal, ruint, uint, Address, Bytes, FixedBytes, B256, U256, diff --git a/crates/primitives/src/log.rs b/crates/primitives/src/log.rs index 90c55556878..578f0b243f6 100644 --- a/crates/primitives/src/log.rs +++ b/crates/primitives/src/log.rs @@ -1,7 +1,8 @@ use crate::{Address, Bytes, B256}; use alloc::vec::Vec; +use alloy_rlp::{RlpDecodable, RlpEncodable}; -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq, Eq, RlpDecodable, RlpEncodable)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Log { pub address: Address, diff --git a/crates/primitives/src/utilities.rs b/crates/primitives/src/utilities.rs index 0a91686adcb..48cd545aa50 100644 --- a/crates/primitives/src/utilities.rs +++ b/crates/primitives/src/utilities.rs @@ -6,15 +6,13 @@ pub const KECCAK_EMPTY: B256 = b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); /// Returns the address for the legacy `CREATE` scheme: [`CreateScheme::Create`] +#[inline] pub fn create_address(caller: Address, nonce: u64) -> Address { caller.create(nonce) } /// Returns the address for the `CREATE2` scheme: [`CreateScheme::Create2`] +#[inline] pub fn create2_address(caller: Address, code_hash: B256, salt: U256) -> Address { caller.create2(salt.to_be_bytes::<32>(), code_hash) } - -// TODO(dani): for backwards compatibility? This is not needed anymore -// #[cfg(feature = "serde")] -// pub use alloy_primitives::serde_hex as serde_hex_bytes; diff --git a/crates/revm/src/db/states/bundle_account.rs b/crates/revm/src/db/states/bundle_account.rs index 624f62ef1ae..9e1cf578db2 100644 --- a/crates/revm/src/db/states/bundle_account.rs +++ b/crates/revm/src/db/states/bundle_account.rs @@ -1,7 +1,6 @@ use super::{ - reverts::AccountInfoRevert, reverts::AccountInfoRevert, AccountRevert, AccountRevert, - AccountStatus, AccountStatus, RevertToSlot, RevertToSlot, Storage, StorageWithOriginalValues, - TransitionAccount, TransitionAccount, + reverts::AccountInfoRevert, AccountRevert, AccountStatus, RevertToSlot, + StorageWithOriginalValues, TransitionAccount, }; use revm_interpreter::primitives::{AccountInfo, StorageSlot, U256}; use revm_precompile::HashMap; diff --git a/crates/revm/src/db/states/bundle_state.rs b/crates/revm/src/db/states/bundle_state.rs index 76310b47c31..df725e5a2b1 100644 --- a/crates/revm/src/db/states/bundle_state.rs +++ b/crates/revm/src/db/states/bundle_state.rs @@ -353,7 +353,7 @@ mod tests { #[test] fn transition_all_states() { // dummy data - let address = B160([0x01; 20]); + let address = Address::new([0x01; 20]); let acc1 = AccountInfo { balance: U256::from(10), nonce: 1, diff --git a/crates/revm/src/db/states/transition_state.rs b/crates/revm/src/db/states/transition_state.rs index 27093bac20d..4f24a1003c1 100644 --- a/crates/revm/src/db/states/transition_state.rs +++ b/crates/revm/src/db/states/transition_state.rs @@ -18,11 +18,12 @@ impl Default for TransitionState { impl TransitionState { /// Create new transition state with one transition. - pub fn with_capacity(address: B160, transition: TransitionAccount) -> Self { + pub fn with_capacity(address: Address, transition: TransitionAccount) -> Self { let mut transitions = HashMap::new(); transitions.insert(address, transition); TransitionState { transitions } } + /// Return transition id and all account transitions. Leave empty transition map. pub fn take(&mut self) -> TransitionState { core::mem::take(self) diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 8f616d067d1..5f8b0385045 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -35,14 +35,14 @@ pub struct EVMImpl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> { struct PreparedCreate { gas: Gas, - created_address: B160, + created_address: Address, checkpoint: JournalCheckpoint, contract: Box, } struct CreateResult { result: InstructionResult, - created_address: Option, + created_address: Option
, gas: Gas, return_value: Bytes, } diff --git a/documentation/src/crates/primitives/bits.md b/documentation/src/crates/primitives/bits.md index 606710e82eb..8d562b19b31 100644 --- a/documentation/src/crates/primitives/bits.md +++ b/documentation/src/crates/primitives/bits.md @@ -1,6 +1,6 @@ # bits - +> NOTE: This module's types have been replaced by [`alloy_primitives`](https://github.com/alloy-rs/core)'s `Address` and `FixedBytes`. This module houses the definitions for fixed-size bit arrays, `Address` and `B256`, showcasing its role in managing bits-related operations, to represent 256-bit and 160-bit fixed-size hashes respectively. These are defined using the `construct_fixed_hash!` macro from the `fixed_hash` crate. diff --git a/documentation/src/crates/primitives/utils.md b/documentation/src/crates/primitives/utils.md index 2c105405fb7..283bff3426e 100644 --- a/documentation/src/crates/primitives/utils.md +++ b/documentation/src/crates/primitives/utils.md @@ -9,6 +9,3 @@ The `keccak256` function takes a byte slice input and returns its Keccak-256 has `create_address` function implements the address calculation for the Ethereum `CREATE` operation. It takes as parameters the address of the caller (`caller`) and a nonce (`nonce`). The function serializes these inputs using Recursive Length Prefix (RLP) encoding, calculates the Keccak-256 hash of the result, and returns the last 20 bytes of this hash as the created address. `create2_address` function implements the address calculation for the Ethereum `CREATE2` operation. It takes as parameters the address of the caller (`caller`), a hash of the initializing code (`code_hash`), and a "salt" value (`salt`). The function hashes these inputs together in a specific way, as per the Ethereum `CREATE2` rules, and returns the last 20 bytes of the result as the created address. - - -The `serde_hex_bytes` module includes helper functions for serialization and deserialization of hexadecimal strings representing byte arrays. These functions will be used if the "serde" feature flag is enabled. serialize `function` converts a byte array into a hexadecimal string, while `deserialize` function does the reverse, converting a hexadecimal string back into a byte array.