mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
chore: update revm and alloy primitives (#11235)
Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
This commit is contained in:
34
Cargo.lock
generated
34
Cargo.lock
generated
@@ -277,9 +277,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "alloy-primitives"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "411aff151f2a73124ee473708e82ed51b2535f68928b6a1caa8bc1246ae6f7cd"
|
||||
checksum = "260d3ff3bff0bb84599f032a2f2c6828180b0ea0cd41fdaf44f39cef3ba41861"
|
||||
dependencies = [
|
||||
"alloy-rlp",
|
||||
"arbitrary",
|
||||
@@ -289,15 +289,20 @@ dependencies = [
|
||||
"derive_arbitrary",
|
||||
"derive_more",
|
||||
"getrandom 0.2.15",
|
||||
"hashbrown 0.14.5",
|
||||
"hex-literal",
|
||||
"indexmap 2.5.0",
|
||||
"itoa",
|
||||
"k256",
|
||||
"keccak-asm",
|
||||
"paste",
|
||||
"proptest",
|
||||
"proptest-derive",
|
||||
"rand 0.8.5",
|
||||
"ruint",
|
||||
"rustc-hash 2.0.0",
|
||||
"serde",
|
||||
"sha3",
|
||||
"tiny-keccak",
|
||||
]
|
||||
|
||||
@@ -3929,6 +3934,7 @@ version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"equivalent",
|
||||
"hashbrown 0.14.5",
|
||||
"serde",
|
||||
@@ -5923,6 +5929,7 @@ dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_core 0.6.4",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9136,9 +9143,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revm"
|
||||
version = "14.0.2"
|
||||
version = "14.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9f3f55d0414c3d73902d876ba3d55a654f05fe937089fbf5f34b1ced26d78d5"
|
||||
checksum = "641702b12847f9ed418d552f4fcabe536d867a2c980e96b6e7e25d7b992f929f"
|
||||
dependencies = [
|
||||
"auto_impl",
|
||||
"cfg-if",
|
||||
@@ -9170,9 +9177,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revm-interpreter"
|
||||
version = "10.0.2"
|
||||
version = "10.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "713dbb271acd13afb06dcd460c1dc43da211e7ac9bc73cdf13528f615f55f96b"
|
||||
checksum = "2e5e14002afae20b5bf1566f22316122f42f57517000e559c55b25bf7a49cba2"
|
||||
dependencies = [
|
||||
"revm-primitives",
|
||||
"serde",
|
||||
@@ -9180,9 +9187,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revm-precompile"
|
||||
version = "11.0.2"
|
||||
version = "11.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f73010c271d53fa7904e9845338e95f3955eb1200a0355e0abfdb89c41aaa9cd"
|
||||
checksum = "3198c06247e8d4ad0d1312591edf049b0de4ddffa9fecb625c318fd67db8639b"
|
||||
dependencies = [
|
||||
"aurora-engine-modexp",
|
||||
"blst",
|
||||
@@ -9200,11 +9207,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revm-primitives"
|
||||
version = "9.0.2"
|
||||
version = "10.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a6bff9dbde3370a5ac9555104117f7e6039b3cc76e8d5d9d01899088beca2a"
|
||||
checksum = "6f1525851a03aff9a9d6a1d018b414d76252d6802ab54695b27093ecd7e7a101"
|
||||
dependencies = [
|
||||
"alloy-eips",
|
||||
"alloy-eip2930",
|
||||
"alloy-eip7702",
|
||||
"alloy-primitives",
|
||||
"auto_impl",
|
||||
"bitflags 2.6.0",
|
||||
@@ -9213,7 +9221,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"dyn-clone",
|
||||
"enumn",
|
||||
"hashbrown 0.14.5",
|
||||
"hex",
|
||||
"serde",
|
||||
]
|
||||
@@ -9359,6 +9366,9 @@ name = "rustc-hash"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
|
||||
dependencies = [
|
||||
"rand 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hex"
|
||||
|
||||
@@ -408,20 +408,20 @@ reth-trie-db = { path = "crates/trie/db" }
|
||||
reth-trie-parallel = { path = "crates/trie/parallel" }
|
||||
|
||||
# revm
|
||||
revm = { version = "14.0.2", features = [
|
||||
revm = { version = "14.0.3", features = [
|
||||
"std",
|
||||
"secp256k1",
|
||||
"blst",
|
||||
], default-features = false }
|
||||
revm-inspectors = "0.7.6"
|
||||
revm-primitives = { version = "9.0.2", features = [
|
||||
revm-primitives = { version = "10.0.0", features = [
|
||||
"std",
|
||||
], default-features = false }
|
||||
|
||||
# eth
|
||||
alloy-chains = "0.1.32"
|
||||
alloy-dyn-abi = "0.8.0"
|
||||
alloy-primitives = { version = "0.8.3", default-features = false }
|
||||
alloy-primitives = { version = "0.8.4", default-features = false }
|
||||
alloy-rlp = "0.3.4"
|
||||
alloy-sol-types = "0.8.0"
|
||||
alloy-trie = { version = "0.5", default-features = false }
|
||||
|
||||
@@ -533,7 +533,7 @@ mod tests {
|
||||
block_indices.insert_non_fork_block(block_number_2, block_hash_3, chain_id_2);
|
||||
|
||||
// Block number 1 should have two block hashes associated with it.
|
||||
let mut expected_hashes_for_block_1 = HashSet::new();
|
||||
let mut expected_hashes_for_block_1 = HashSet::default();
|
||||
expected_hashes_for_block_1.insert(block_hash_1);
|
||||
expected_hashes_for_block_1.insert(block_hash_2);
|
||||
assert_eq!(
|
||||
@@ -601,11 +601,11 @@ mod tests {
|
||||
assert_eq!(block_indices.blocks_to_chain.get(&block_hash_2), Some(&chain_id));
|
||||
|
||||
// Check that block numbers map to their respective hashes.
|
||||
let mut expected_hashes_1 = HashSet::new();
|
||||
let mut expected_hashes_1 = HashSet::default();
|
||||
expected_hashes_1.insert(block_hash_1);
|
||||
assert_eq!(block_indices.block_number_to_block_hashes.get(&1), Some(&expected_hashes_1));
|
||||
|
||||
let mut expected_hashes_2 = HashSet::new();
|
||||
let mut expected_hashes_2 = HashSet::default();
|
||||
expected_hashes_2.insert(block_hash_2);
|
||||
assert_eq!(block_indices.block_number_to_block_hashes.get(&2), Some(&expected_hashes_2));
|
||||
|
||||
|
||||
@@ -589,7 +589,7 @@ where
|
||||
// Find all forks of given block.
|
||||
let mut dependent_block =
|
||||
self.block_indices().fork_to_child().get(block).cloned().unwrap_or_default();
|
||||
let mut dependent_chains = HashSet::new();
|
||||
let mut dependent_chains = HashSet::default();
|
||||
|
||||
while let Some(block) = dependent_block.pop_back() {
|
||||
// Get chain of dependent block.
|
||||
@@ -2180,7 +2180,7 @@ mod tests {
|
||||
(block1.parent_hash, HashSet::from([block1a_hash])),
|
||||
(block1.hash(), HashSet::from([block2.hash()])),
|
||||
]))
|
||||
.with_pending_blocks((block2.number + 1, HashSet::new()))
|
||||
.with_pending_blocks((block2.number + 1, HashSet::default()))
|
||||
.assert(&tree);
|
||||
|
||||
assert_matches!(tree.make_canonical(block1a_hash), Ok(_));
|
||||
@@ -2204,7 +2204,7 @@ mod tests {
|
||||
(block1.parent_hash, HashSet::from([block1.hash()])),
|
||||
(block1.hash(), HashSet::from([block2.hash()])),
|
||||
]))
|
||||
.with_pending_blocks((block1a.number + 1, HashSet::new()))
|
||||
.with_pending_blocks((block1a.number + 1, HashSet::default()))
|
||||
.assert(&tree);
|
||||
|
||||
// check notification.
|
||||
@@ -2241,7 +2241,7 @@ mod tests {
|
||||
(block1.parent_hash, HashSet::from([block1a_hash])),
|
||||
(block1.hash(), HashSet::from([block2a_hash])),
|
||||
]))
|
||||
.with_pending_blocks((block2.number + 1, HashSet::new()))
|
||||
.with_pending_blocks((block2.number + 1, HashSet::default()))
|
||||
.assert(&tree);
|
||||
|
||||
// check notification.
|
||||
@@ -2310,7 +2310,7 @@ mod tests {
|
||||
.with_chain_num(1)
|
||||
.with_block_to_chain(HashMap::from([(block2a_hash, 4.into())]))
|
||||
.with_fork_to_child(HashMap::from([(block1.hash(), HashSet::from([block2a_hash]))]))
|
||||
.with_pending_blocks((block2.number + 1, HashSet::new()))
|
||||
.with_pending_blocks((block2.number + 1, HashSet::default()))
|
||||
.assert(&tree);
|
||||
|
||||
// check notification.
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
ChainInfoTracker, MemoryOverlayStateProvider,
|
||||
};
|
||||
use alloy_eips::BlockNumHash;
|
||||
use alloy_primitives::{Address, TxHash, B256};
|
||||
use alloy_primitives::{map::HashMap, Address, TxHash, B256};
|
||||
use parking_lot::RwLock;
|
||||
use reth_chainspec::ChainInfo;
|
||||
use reth_execution_types::{Chain, ExecutionOutcome};
|
||||
@@ -16,11 +16,7 @@ use reth_primitives::{
|
||||
};
|
||||
use reth_storage_api::StateProviderBox;
|
||||
use reth_trie::{updates::TrieUpdates, HashedPostState};
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
};
|
||||
use std::{collections::BTreeMap, sync::Arc, time::Instant};
|
||||
use tokio::sync::{broadcast, watch};
|
||||
|
||||
/// Size of the broadcast channel used to notify canonical state events.
|
||||
@@ -197,7 +193,7 @@ impl CanonicalInMemoryState {
|
||||
|
||||
/// Create an empty state.
|
||||
pub fn empty() -> Self {
|
||||
Self::new(HashMap::new(), BTreeMap::new(), None, None)
|
||||
Self::new(HashMap::default(), BTreeMap::new(), None, None)
|
||||
}
|
||||
|
||||
/// Create a new in memory state with the given local head and finalized header
|
||||
@@ -843,7 +839,7 @@ impl NewCanonicalChain {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::test_utils::TestBlockBuilder;
|
||||
use alloy_primitives::{BlockNumber, Bytes, StorageKey, StorageValue};
|
||||
use alloy_primitives::{map::HashSet, BlockNumber, Bytes, StorageKey, StorageValue};
|
||||
use rand::Rng;
|
||||
use reth_errors::ProviderResult;
|
||||
use reth_primitives::{Account, Bytecode, Receipt, Requests};
|
||||
@@ -852,7 +848,6 @@ mod tests {
|
||||
StorageRootProvider,
|
||||
};
|
||||
use reth_trie::{AccountProof, HashedStorage, MultiProof, TrieInput};
|
||||
use std::collections::HashSet;
|
||||
|
||||
fn create_mock_state(
|
||||
test_block_builder: &mut TestBlockBuilder,
|
||||
@@ -984,7 +979,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_in_memory_state_impl_state_by_hash() {
|
||||
let mut state_by_hash = HashMap::new();
|
||||
let mut state_by_hash = HashMap::default();
|
||||
let number = rand::thread_rng().gen::<u64>();
|
||||
let mut test_block_builder = TestBlockBuilder::default();
|
||||
let state = Arc::new(create_mock_state(&mut test_block_builder, number, B256::random()));
|
||||
@@ -998,7 +993,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_in_memory_state_impl_state_by_number() {
|
||||
let mut state_by_hash = HashMap::new();
|
||||
let mut state_by_hash = HashMap::default();
|
||||
let mut hash_by_number = BTreeMap::new();
|
||||
|
||||
let number = rand::thread_rng().gen::<u64>();
|
||||
@@ -1017,7 +1012,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_in_memory_state_impl_head_state() {
|
||||
let mut state_by_hash = HashMap::new();
|
||||
let mut state_by_hash = HashMap::default();
|
||||
let mut hash_by_number = BTreeMap::new();
|
||||
let mut test_block_builder = TestBlockBuilder::default();
|
||||
let state1 = Arc::new(create_mock_state(&mut test_block_builder, 1, B256::random()));
|
||||
@@ -1045,7 +1040,7 @@ mod tests {
|
||||
let pending_hash = pending_state.hash();
|
||||
|
||||
let in_memory_state =
|
||||
InMemoryState::new(HashMap::new(), BTreeMap::new(), Some(pending_state));
|
||||
InMemoryState::new(HashMap::default(), BTreeMap::new(), Some(pending_state));
|
||||
|
||||
let result = in_memory_state.pending_state();
|
||||
assert!(result.is_some());
|
||||
@@ -1056,7 +1051,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_in_memory_state_impl_no_pending_state() {
|
||||
let in_memory_state = InMemoryState::new(HashMap::new(), BTreeMap::new(), None);
|
||||
let in_memory_state = InMemoryState::new(HashMap::default(), BTreeMap::new(), None);
|
||||
|
||||
assert_eq!(in_memory_state.pending_state(), None);
|
||||
}
|
||||
@@ -1210,7 +1205,7 @@ mod tests {
|
||||
let state2 = BlockState::with_parent(block2.clone(), Some(state1.clone()));
|
||||
let state3 = BlockState::with_parent(block3.clone(), Some(state2.clone()));
|
||||
|
||||
let mut blocks = HashMap::new();
|
||||
let mut blocks = HashMap::default();
|
||||
blocks.insert(block1.block().hash(), Arc::new(state1));
|
||||
blocks.insert(block2.block().hash(), Arc::new(state2));
|
||||
blocks.insert(block3.block().hash(), Arc::new(state3));
|
||||
@@ -1257,7 +1252,7 @@ mod tests {
|
||||
fn test_canonical_in_memory_state_canonical_chain_single_block() {
|
||||
let block = TestBlockBuilder::default().get_executed_block_with_number(1, B256::random());
|
||||
let hash = block.block().hash();
|
||||
let mut blocks = HashMap::new();
|
||||
let mut blocks = HashMap::default();
|
||||
blocks.insert(hash, Arc::new(BlockState::new(block)));
|
||||
let mut numbers = BTreeMap::new();
|
||||
numbers.insert(1, hash);
|
||||
@@ -1272,7 +1267,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_canonical_in_memory_state_canonical_chain_multiple_blocks() {
|
||||
let mut blocks = HashMap::new();
|
||||
let mut blocks = HashMap::default();
|
||||
let mut numbers = BTreeMap::new();
|
||||
let mut parent_hash = B256::random();
|
||||
let mut block_builder = TestBlockBuilder::default();
|
||||
@@ -1296,7 +1291,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_canonical_in_memory_state_canonical_chain_with_pending_block() {
|
||||
let mut blocks = HashMap::new();
|
||||
let mut blocks = HashMap::default();
|
||||
let mut numbers = BTreeMap::new();
|
||||
let mut parent_hash = B256::random();
|
||||
let mut block_builder = TestBlockBuilder::default();
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
use super::ExecutedBlock;
|
||||
use alloy_primitives::{keccak256, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256};
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{HashMap, HashSet},
|
||||
Address, BlockNumber, Bytes, StorageKey, StorageValue, B256,
|
||||
};
|
||||
use reth_errors::ProviderResult;
|
||||
use reth_primitives::{Account, Bytecode};
|
||||
use reth_storage_api::{
|
||||
@@ -9,10 +13,7 @@ use reth_storage_api::{
|
||||
use reth_trie::{
|
||||
updates::TrieUpdates, AccountProof, HashedPostState, HashedStorage, MultiProof, TrieInput,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::OnceLock,
|
||||
};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
/// A state provider that stores references to in-memory blocks along with their state as well as
|
||||
/// the historical state provider for fallback lookups.
|
||||
|
||||
@@ -267,7 +267,7 @@ where
|
||||
T::Key: Hash,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self { discrepancies: HashMap::new(), extra_elements: HashMap::new() }
|
||||
Self { discrepancies: HashMap::default(), extra_elements: HashMap::default() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ where
|
||||
let bundle_state = db.take_bundle();
|
||||
|
||||
// Initialize a map of preimages.
|
||||
let mut state_preimages = HashMap::new();
|
||||
let mut state_preimages = HashMap::default();
|
||||
|
||||
// Grab all account proofs for the data accessed during block execution.
|
||||
//
|
||||
@@ -170,7 +170,10 @@ where
|
||||
let state = state_provider.witness(Default::default(), hashed_state.clone())?;
|
||||
|
||||
// Write the witness to the output directory.
|
||||
let response = ExecutionWitness { state, keys: Some(state_preimages) };
|
||||
let response = ExecutionWitness {
|
||||
state: std::collections::HashMap::from_iter(state),
|
||||
keys: Some(state_preimages),
|
||||
};
|
||||
let re_executed_witness_path = self.save_file(
|
||||
format!("{}_{}.witness.re_executed.json", block.number, block.hash()),
|
||||
&response,
|
||||
|
||||
@@ -5,7 +5,10 @@ use crate::{
|
||||
persistence::PersistenceHandle,
|
||||
};
|
||||
use alloy_eips::BlockNumHash;
|
||||
use alloy_primitives::{BlockNumber, B256, U256};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
BlockNumber, B256, U256,
|
||||
};
|
||||
use alloy_rpc_types_engine::{
|
||||
CancunPayloadFields, ExecutionPayload, ForkchoiceState, PayloadStatus, PayloadStatusEnum,
|
||||
PayloadValidationError,
|
||||
@@ -43,7 +46,7 @@ use reth_trie::{updates::TrieUpdates, HashedPostState, TrieInput};
|
||||
use reth_trie_parallel::parallel_root::{ParallelStateRoot, ParallelStateRootError};
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{btree_map, hash_map, BTreeMap, HashMap, HashSet, VecDeque},
|
||||
collections::{btree_map, hash_map, BTreeMap, VecDeque},
|
||||
fmt::Debug,
|
||||
ops::Bound,
|
||||
sync::{
|
||||
@@ -101,11 +104,11 @@ impl TreeState {
|
||||
/// Returns a new, empty tree state that points to the given canonical head.
|
||||
fn new(current_canonical_head: BlockNumHash) -> Self {
|
||||
Self {
|
||||
blocks_by_hash: HashMap::new(),
|
||||
blocks_by_hash: HashMap::default(),
|
||||
blocks_by_number: BTreeMap::new(),
|
||||
current_canonical_head,
|
||||
parent_to_child: HashMap::new(),
|
||||
persisted_trie_updates: HashMap::new(),
|
||||
parent_to_child: HashMap::default(),
|
||||
persisted_trie_updates: HashMap::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2697,12 +2700,11 @@ mod tests {
|
||||
}
|
||||
|
||||
fn with_blocks(mut self, blocks: Vec<ExecutedBlock>) -> Self {
|
||||
let mut blocks_by_hash = HashMap::with_capacity(blocks.len());
|
||||
let mut blocks_by_hash = HashMap::default();
|
||||
let mut blocks_by_number = BTreeMap::new();
|
||||
let mut state_by_hash = HashMap::with_capacity(blocks.len());
|
||||
let mut state_by_hash = HashMap::default();
|
||||
let mut hash_by_number = BTreeMap::new();
|
||||
let mut parent_to_child: HashMap<B256, HashSet<B256>> =
|
||||
HashMap::with_capacity(blocks.len());
|
||||
let mut parent_to_child: HashMap<B256, HashSet<B256>> = HashMap::default();
|
||||
let mut parent_hash = B256::ZERO;
|
||||
|
||||
for block in &blocks {
|
||||
@@ -3158,7 +3160,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[0].block.hash()),
|
||||
Some(&HashSet::from([blocks[1].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[1].block.hash()]))
|
||||
);
|
||||
|
||||
assert!(!tree_state.parent_to_child.contains_key(&blocks[1].block.hash()));
|
||||
@@ -3167,7 +3169,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[1].block.hash()),
|
||||
Some(&HashSet::from([blocks[2].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[2].block.hash()]))
|
||||
);
|
||||
assert!(tree_state.parent_to_child.contains_key(&blocks[1].block.hash()));
|
||||
|
||||
@@ -3255,11 +3257,11 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[2].block.hash()),
|
||||
Some(&HashSet::from([blocks[3].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[3].block.hash()]))
|
||||
);
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[3].block.hash()),
|
||||
Some(&HashSet::from([blocks[4].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[4].block.hash()]))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3305,11 +3307,11 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[2].block.hash()),
|
||||
Some(&HashSet::from([blocks[3].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[3].block.hash()]))
|
||||
);
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[3].block.hash()),
|
||||
Some(&HashSet::from([blocks[4].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[4].block.hash()]))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3355,11 +3357,11 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[2].block.hash()),
|
||||
Some(&HashSet::from([blocks[3].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[3].block.hash()]))
|
||||
);
|
||||
assert_eq!(
|
||||
tree_state.parent_to_child.get(&blocks[3].block.hash()),
|
||||
Some(&HashSet::from([blocks[4].block.hash()]))
|
||||
Some(&HashSet::from_iter([blocks[4].block.hash()]))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3546,7 +3548,7 @@ mod tests {
|
||||
let event = test_harness.from_tree_rx.recv().await.unwrap();
|
||||
match event {
|
||||
EngineApiEvent::Download(DownloadRequest::BlockSet(actual_block_set)) => {
|
||||
let expected_block_set = HashSet::from([missing_block.hash()]);
|
||||
let expected_block_set = HashSet::from_iter([missing_block.hash()]);
|
||||
assert_eq!(actual_block_set, expected_block_set);
|
||||
}
|
||||
_ => panic!("Unexpected event: {:#?}", event),
|
||||
@@ -3641,7 +3643,7 @@ mod tests {
|
||||
let event = test_harness.from_tree_rx.recv().await.unwrap();
|
||||
match event {
|
||||
EngineApiEvent::Download(DownloadRequest::BlockSet(hash_set)) => {
|
||||
assert_eq!(hash_set, HashSet::from([main_chain_last_hash]));
|
||||
assert_eq!(hash_set, HashSet::from_iter([main_chain_last_hash]));
|
||||
}
|
||||
_ => panic!("Unexpected event: {:#?}", event),
|
||||
}
|
||||
@@ -3704,7 +3706,7 @@ mod tests {
|
||||
let event = test_harness.from_tree_rx.recv().await.unwrap();
|
||||
match event {
|
||||
EngineApiEvent::Download(DownloadRequest::BlockSet(hash_set)) => {
|
||||
assert_eq!(hash_set, HashSet::from([main_chain_backfill_target_hash]));
|
||||
assert_eq!(hash_set, HashSet::from_iter([main_chain_backfill_target_hash]));
|
||||
}
|
||||
_ => panic!("Unexpected event: {:#?}", event),
|
||||
}
|
||||
@@ -3749,7 +3751,7 @@ mod tests {
|
||||
let event = test_harness.from_tree_rx.recv().await.unwrap();
|
||||
match event {
|
||||
EngineApiEvent::Download(DownloadRequest::BlockSet(target_hash)) => {
|
||||
assert_eq!(target_hash, HashSet::from([main_chain_last_hash]));
|
||||
assert_eq!(target_hash, HashSet::from_iter([main_chain_last_hash]));
|
||||
}
|
||||
_ => panic!("Unexpected event: {:#?}", event),
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ mod tests {
|
||||
BEACON_ROOTS_ADDRESS,
|
||||
beacon_root_contract_account,
|
||||
Some(BEACON_ROOTS_CODE.clone()),
|
||||
HashMap::new(),
|
||||
HashMap::default(),
|
||||
);
|
||||
|
||||
db
|
||||
@@ -524,7 +524,7 @@ mod tests {
|
||||
WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
|
||||
withdrawal_requests_contract_account,
|
||||
Some(WITHDRAWAL_REQUEST_PREDEPLOY_CODE.clone()),
|
||||
HashMap::new(),
|
||||
HashMap::default(),
|
||||
);
|
||||
|
||||
db
|
||||
@@ -685,7 +685,7 @@ mod tests {
|
||||
let mut db = create_state_provider_with_beacon_root_contract();
|
||||
|
||||
// insert an empty SYSTEM_ADDRESS
|
||||
db.insert_account(SYSTEM_ADDRESS, Account::default(), None, HashMap::new());
|
||||
db.insert_account(SYSTEM_ADDRESS, Account::default(), None, HashMap::default());
|
||||
|
||||
let chain_spec = Arc::new(
|
||||
ChainSpecBuilder::from(&*MAINNET)
|
||||
@@ -883,7 +883,7 @@ mod tests {
|
||||
HISTORY_STORAGE_ADDRESS,
|
||||
blockhashes_contract_account,
|
||||
Some(HISTORY_STORAGE_CODE.clone()),
|
||||
HashMap::new(),
|
||||
HashMap::default(),
|
||||
);
|
||||
|
||||
db
|
||||
@@ -1230,7 +1230,7 @@ mod tests {
|
||||
sender_address,
|
||||
Account { nonce: 1, balance: U256::from(ETH_TO_WEI), bytecode_hash: None },
|
||||
None,
|
||||
HashMap::new(),
|
||||
HashMap::default(),
|
||||
);
|
||||
|
||||
// https://github.com/lightclient/7002asm/blob/e0d68e04d15f25057af7b6d180423d94b6b3bdb3/test/Contract.t.sol.in#L49-L64
|
||||
@@ -1313,7 +1313,7 @@ mod tests {
|
||||
sender_address,
|
||||
Account { nonce: 1, balance: U256::from(ETH_TO_WEI), bytecode_hash: None },
|
||||
None,
|
||||
HashMap::new(),
|
||||
HashMap::default(),
|
||||
);
|
||||
|
||||
// Define the validator public key and withdrawal amount as fixed bytes
|
||||
|
||||
@@ -436,16 +436,16 @@ mod tests {
|
||||
);
|
||||
|
||||
// Create a BundleStateInit object and insert initial data
|
||||
let mut state_init: BundleStateInit = HashMap::new();
|
||||
let mut state_init: BundleStateInit = HashMap::default();
|
||||
state_init
|
||||
.insert(Address::new([2; 20]), (None, Some(Account::default()), HashMap::default()));
|
||||
|
||||
// Create a HashMap for account reverts and insert initial data
|
||||
let mut revert_inner: HashMap<Address, AccountRevertInit> = HashMap::new();
|
||||
let mut revert_inner: HashMap<Address, AccountRevertInit> = HashMap::default();
|
||||
revert_inner.insert(Address::new([2; 20]), (None, vec![]));
|
||||
|
||||
// Create a RevertsInit object and insert the revert_inner data
|
||||
let mut revert_init: RevertsInit = HashMap::new();
|
||||
let mut revert_init: RevertsInit = HashMap::default();
|
||||
revert_init.insert(123, revert_inner);
|
||||
|
||||
// Assert that creating a new ExecutionOutcome using the new_init method matches
|
||||
|
||||
@@ -297,7 +297,7 @@ impl Config {
|
||||
pub fn builder(rlpx_tcp_socket: SocketAddr) -> ConfigBuilder {
|
||||
ConfigBuilder {
|
||||
discv5_config: None,
|
||||
bootstrap_nodes: HashSet::new(),
|
||||
bootstrap_nodes: HashSet::default(),
|
||||
fork: None,
|
||||
tcp_socket: rlpx_tcp_socket,
|
||||
other_enr_kv_pairs: Vec::new(),
|
||||
|
||||
@@ -196,9 +196,9 @@ impl FromReader for FileClient {
|
||||
where
|
||||
B: AsyncReadExt + Unpin,
|
||||
{
|
||||
let mut headers = HashMap::new();
|
||||
let mut hash_to_number = HashMap::new();
|
||||
let mut bodies = HashMap::new();
|
||||
let mut headers = HashMap::default();
|
||||
let mut hash_to_number = HashMap::default();
|
||||
let mut bodies = HashMap::default();
|
||||
|
||||
// use with_capacity to make sure the internal buffer contains the entire chunk
|
||||
let mut stream = FramedRead::with_capacity(reader, BlockFileCodec, num_bytes as usize);
|
||||
|
||||
@@ -618,13 +618,13 @@ impl<V> PartiallyValidData<V> {
|
||||
/// Returns a new [`PartiallyValidData`] with empty data from an [`Eth68`](EthVersion::Eth68)
|
||||
/// announcement.
|
||||
pub fn empty_eth68() -> Self {
|
||||
Self::from_raw_data_eth68(HashMap::new())
|
||||
Self::from_raw_data_eth68(HashMap::default())
|
||||
}
|
||||
|
||||
/// Returns a new [`PartiallyValidData`] with empty data from an [`Eth66`](EthVersion::Eth66)
|
||||
/// announcement.
|
||||
pub fn empty_eth66() -> Self {
|
||||
Self::from_raw_data_eth66(HashMap::new())
|
||||
Self::from_raw_data_eth66(HashMap::default())
|
||||
}
|
||||
|
||||
/// Returns the version of the message this data was received in if different versions of the
|
||||
@@ -704,7 +704,7 @@ impl RequestTxHashes {
|
||||
|
||||
/// Returns an new empty instance.
|
||||
fn empty() -> Self {
|
||||
Self::new(HashSet::new())
|
||||
Self::new(HashSet::default())
|
||||
}
|
||||
|
||||
/// Retains the given number of elements, returning and iterator over the rest.
|
||||
|
||||
@@ -291,7 +291,7 @@ pub fn shared_capability_offsets(
|
||||
local_protocols.into_iter().map(Protocol::split).collect::<HashMap<_, _>>();
|
||||
|
||||
// map of capability name to version
|
||||
let mut shared_capabilities: HashMap<_, ProtoVersion> = HashMap::new();
|
||||
let mut shared_capabilities: HashMap<_, ProtoVersion> = HashMap::default();
|
||||
|
||||
// The `Ord` implementation for capability names should be equivalent to geth (and every other
|
||||
// client), since geth uses golang's default string comparison, which orders strings
|
||||
|
||||
@@ -1090,7 +1090,6 @@ impl Display for InboundConnectionError {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
future::{poll_fn, Future},
|
||||
io,
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
@@ -1968,7 +1967,7 @@ mod tests {
|
||||
async fn test_discovery_ban_list() {
|
||||
let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 1, 2));
|
||||
let socket_addr = SocketAddr::new(ip, 8008);
|
||||
let ban_list = BanList::new(HashSet::new(), vec![ip]);
|
||||
let ban_list = BanList::new(vec![], vec![ip]);
|
||||
let config = PeersConfig::default().with_ban_list(ban_list);
|
||||
let mut peer_manager = PeersManager::new(config);
|
||||
peer_manager.add_peer(B512::default(), PeerAddr::from_tcp(socket_addr), None);
|
||||
@@ -1980,7 +1979,7 @@ mod tests {
|
||||
async fn test_on_pending_ban_list() {
|
||||
let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 1, 2));
|
||||
let socket_addr = SocketAddr::new(ip, 8008);
|
||||
let ban_list = BanList::new(HashSet::new(), vec![ip]);
|
||||
let ban_list = BanList::new(vec![], vec![ip]);
|
||||
let config = PeersConfig::test().with_ban_list(ban_list);
|
||||
let mut peer_manager = PeersManager::new(config);
|
||||
let a = peer_manager.on_incoming_pending_session(socket_addr.ip());
|
||||
@@ -2001,7 +2000,7 @@ mod tests {
|
||||
let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 1, 2));
|
||||
let socket_addr = SocketAddr::new(ip, 8008);
|
||||
let given_peer_id = PeerId::random();
|
||||
let ban_list = BanList::new(vec![given_peer_id], HashSet::new());
|
||||
let ban_list = BanList::new(vec![given_peer_id], vec![]);
|
||||
let config = PeersConfig::test().with_ban_list(ban_list);
|
||||
let mut peer_manager = PeersManager::new(config);
|
||||
assert!(peer_manager.on_incoming_pending_session(socket_addr.ip()).is_ok());
|
||||
|
||||
@@ -1459,7 +1459,7 @@ mod test {
|
||||
for hash in &seen_hashes {
|
||||
peer_2_data.seen_transactions.insert(*hash);
|
||||
}
|
||||
let mut peers = HashMap::new();
|
||||
let mut peers = HashMap::default();
|
||||
peers.insert(peer_1, peer_1_data);
|
||||
peers.insert(peer_2, peer_2_data);
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ mod test {
|
||||
|
||||
assert_eq!(outcome, FilterOutcome::ReportPeer);
|
||||
|
||||
let mut expected_data = HashMap::new();
|
||||
let mut expected_data = HashMap::default();
|
||||
expected_data.insert(hashes[1], Some((types[1], sizes[1])));
|
||||
|
||||
assert_eq!(expected_data, valid_data.into_data())
|
||||
@@ -426,7 +426,7 @@ mod test {
|
||||
|
||||
assert_eq!(outcome, FilterOutcome::Ok);
|
||||
|
||||
let mut expected_data = HashMap::new();
|
||||
let mut expected_data = HashMap::default();
|
||||
expected_data.insert(hashes[2], Some((types[2], sizes[2])));
|
||||
|
||||
assert_eq!(expected_data, valid_data.into_data())
|
||||
@@ -465,7 +465,7 @@ mod test {
|
||||
|
||||
assert_eq!(outcome, FilterOutcome::ReportPeer);
|
||||
|
||||
let mut expected_data = HashMap::new();
|
||||
let mut expected_data = HashMap::default();
|
||||
expected_data.insert(hashes[3], Some((types[3], sizes[3])));
|
||||
expected_data.insert(hashes[0], Some((types[0], sizes[0])));
|
||||
|
||||
@@ -509,7 +509,7 @@ mod test {
|
||||
|
||||
assert_eq!(outcome, FilterOutcome::ReportPeer);
|
||||
|
||||
let mut expected_data = HashMap::new();
|
||||
let mut expected_data = HashMap::default();
|
||||
expected_data.insert(hashes[1], None);
|
||||
expected_data.insert(hashes[0], None);
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! Connection tests
|
||||
|
||||
use std::{collections::HashSet, net::SocketAddr, time::Duration};
|
||||
use std::{net::SocketAddr, time::Duration};
|
||||
|
||||
use alloy_node_bindings::Geth;
|
||||
use alloy_primitives::map::HashSet;
|
||||
use alloy_provider::{ext::AdminApi, ProviderBuilder};
|
||||
use futures::StreamExt;
|
||||
use reth_chainspec::MAINNET;
|
||||
@@ -328,7 +329,7 @@ async fn test_incoming_node_id_blacklist() {
|
||||
let enr = provider.node_info().await.unwrap().enr;
|
||||
let geth_peer_id = enr_to_peer_id(enr.parse().unwrap());
|
||||
|
||||
let ban_list = BanList::new(vec![geth_peer_id], HashSet::new());
|
||||
let ban_list = BanList::new(vec![geth_peer_id], vec![]);
|
||||
let peer_config = PeersConfig::default().with_ban_list(ban_list);
|
||||
|
||||
let config = NetworkConfigBuilder::new(secret_key)
|
||||
|
||||
@@ -96,7 +96,7 @@ where
|
||||
client,
|
||||
headers: None,
|
||||
pending_headers: VecDeque::new(),
|
||||
bodies: HashMap::new(),
|
||||
bodies: HashMap::default(),
|
||||
consensus: Arc::clone(&self.consensus),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ pub struct TestFullBlockClient {
|
||||
impl Default for TestFullBlockClient {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
headers: Arc::new(Mutex::new(HashMap::new())),
|
||||
bodies: Arc::new(Mutex::new(HashMap::new())),
|
||||
headers: Arc::new(Mutex::new(HashMap::default())),
|
||||
bodies: Arc::new(Mutex::new(HashMap::default())),
|
||||
soft_limit: 20,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ mod tests {
|
||||
let l1_block_contract_account =
|
||||
Account { balance: U256::ZERO, bytecode_hash: None, nonce: 1 };
|
||||
|
||||
let mut l1_block_storage = HashMap::with_capacity(4);
|
||||
let mut l1_block_storage = HashMap::default();
|
||||
// base fee
|
||||
l1_block_storage.insert(StorageKey::with_last_byte(1), StorageValue::from(1000000000));
|
||||
// l1 fee overhead
|
||||
@@ -529,7 +529,7 @@ mod tests {
|
||||
|
||||
let addr = Address::ZERO;
|
||||
let account = Account { balance: U256::MAX, ..Account::default() };
|
||||
db.insert_account(addr, account, None, HashMap::new());
|
||||
db.insert_account(addr, account, None, HashMap::default());
|
||||
|
||||
let chain_spec = Arc::new(
|
||||
ChainSpecBuilder::from(&Arc::new(BASE_MAINNET.inner.clone()))
|
||||
@@ -613,7 +613,7 @@ mod tests {
|
||||
let addr = Address::ZERO;
|
||||
let account = Account { balance: U256::MAX, ..Account::default() };
|
||||
|
||||
db.insert_account(addr, account, None, HashMap::new());
|
||||
db.insert_account(addr, account, None, HashMap::default());
|
||||
|
||||
let chain_spec = Arc::new(
|
||||
ChainSpecBuilder::from(&Arc::new(BASE_MAINNET.inner.clone()))
|
||||
|
||||
@@ -289,7 +289,7 @@ where
|
||||
revm_acc.mark_touch();
|
||||
|
||||
// Commit the create2 deployer account to the database.
|
||||
db.commit(HashMap::from([(CREATE_2_DEPLOYER_ADDR, revm_acc)]));
|
||||
db.commit(HashMap::from_iter([(CREATE_2_DEPLOYER_ADDR, revm_acc)]));
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -158,6 +158,6 @@ struct CachedAccount {
|
||||
|
||||
impl CachedAccount {
|
||||
fn new(info: Option<AccountInfo>) -> Self {
|
||||
Self { info, storage: HashMap::new() }
|
||||
Self { info, storage: HashMap::default() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ mod tests {
|
||||
// <https://github.com/paradigmxyz/reth/issues/1614>
|
||||
#[test]
|
||||
fn test_withdrawal_serde_roundtrip() {
|
||||
let input = r#"[{"index":"0x0","validatorIndex":"0x0","address":"0x0000000000000000000000000000000000001000","amount":"0x1"},{"index":"0x1","validatorIndex":"0x1","address":"0x0000000000000000000000000000000000001001","amount":"0x1"},{"index":"0x2","validatorIndex":"0x2","address":"0x0000000000000000000000000000000000001002","amount":"0x1"},{"index":"0x3","validatorIndex":"0x3","address":"0x0000000000000000000000000000000000001003","amount":"0x1"},{"index":"0x4","validatorIndex":"0x4","address":"0x0000000000000000000000000000000000001004","amount":"0x1"},{"index":"0x5","validatorIndex":"0x5","address":"0x0000000000000000000000000000000000001005","amount":"0x1"},{"index":"0x6","validatorIndex":"0x6","address":"0x0000000000000000000000000000000000001006","amount":"0x1"},{"index":"0x7","validatorIndex":"0x7","address":"0x0000000000000000000000000000000000001007","amount":"0x1"},{"index":"0x8","validatorIndex":"0x8","address":"0x0000000000000000000000000000000000001008","amount":"0x1"},{"index":"0x9","validatorIndex":"0x9","address":"0x0000000000000000000000000000000000001009","amount":"0x1"},{"index":"0xa","validatorIndex":"0xa","address":"0x000000000000000000000000000000000000100a","amount":"0x1"},{"index":"0xb","validatorIndex":"0xb","address":"0x000000000000000000000000000000000000100b","amount":"0x1"},{"index":"0xc","validatorIndex":"0xc","address":"0x000000000000000000000000000000000000100c","amount":"0x1"},{"index":"0xd","validatorIndex":"0xd","address":"0x000000000000000000000000000000000000100d","amount":"0x1"},{"index":"0xe","validatorIndex":"0xe","address":"0x000000000000000000000000000000000000100e","amount":"0x1"},{"index":"0xf","validatorIndex":"0xf","address":"0x000000000000000000000000000000000000100f","amount":"0x1"}]"#;
|
||||
let input = r#"[{"index":"0x0","validatorIndex":"0x0","address":"0x0000000000000000000000000000000000001000","amount":"0x1"},{"index":"0x1","validatorIndex":"0x1","address":"0x0000000000000000000000000000000000001001","amount":"0x1"},{"index":"0x2","validatorIndex":"0x2","address":"0x0000000000000000000000000000000000001002","amount":"0x1"},{"index":"0x3","validatorIndex":"0x3","address":"0x0000000000000000000000000000000000001003","amount":"0x1"},{"index":"0x4","validatorIndex":"0x4","address":"0x0000000000000000000000000000000000001004","amount":"0x1"},{"index":"0x5","validatorIndex":"0x5","address":"0x0000000000000000000000000000000000001005","amount":"0x1"},{"index":"0x6","validatorIndex":"0x6","address":"0x0000000000000000000000000000000000001006","amount":"0x1"},{"index":"0x7","validatorIndex":"0x7","address":"0x0000000000000000000000000000000000001007","amount":"0x1"},{"index":"0x8","validatorIndex":"0x8","address":"0x0000000000000000000000000000000000001008","amount":"0x1"},{"index":"0x9","validatorIndex":"0x9","address":"0x0000000000000000000000000000000000001009","amount":"0x1"},{"index":"0xa","validatorIndex":"0xa","address":"0x000000000000000000000000000000000000100A","amount":"0x1"},{"index":"0xb","validatorIndex":"0xb","address":"0x000000000000000000000000000000000000100b","amount":"0x1"},{"index":"0xc","validatorIndex":"0xc","address":"0x000000000000000000000000000000000000100C","amount":"0x1"},{"index":"0xd","validatorIndex":"0xd","address":"0x000000000000000000000000000000000000100D","amount":"0x1"},{"index":"0xe","validatorIndex":"0xe","address":"0x000000000000000000000000000000000000100e","amount":"0x1"},{"index":"0xf","validatorIndex":"0xf","address":"0x000000000000000000000000000000000000100f","amount":"0x1"}]"#;
|
||||
|
||||
let withdrawals: Vec<Withdrawal> = serde_json::from_str(input).unwrap();
|
||||
let s = serde_json::to_string(&withdrawals).unwrap();
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
//! Helper for handling execution of multiple blocks.
|
||||
|
||||
use crate::{
|
||||
precompile::{Address, HashSet},
|
||||
primitives::alloy_primitives::BlockNumber,
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
use alloy_primitives::{map::HashSet, Address, BlockNumber};
|
||||
use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError};
|
||||
use reth_primitives::{Receipt, Receipts, Request, Requests};
|
||||
use reth_prune_types::{PruneMode, PruneModes, PruneSegmentError, MINIMUM_PRUNING_DISTANCE};
|
||||
@@ -152,7 +149,7 @@ impl BlockBatchRecord {
|
||||
|
||||
if !contract_log_pruner.is_empty() {
|
||||
let (prev_block, filter) =
|
||||
self.pruning_address_filter.get_or_insert_with(|| (0, HashSet::new()));
|
||||
self.pruning_address_filter.get_or_insert_with(|| (0, Default::default()));
|
||||
for (_, addresses) in contract_log_pruner.range(*prev_block..=block_number) {
|
||||
filter.extend(addresses.iter().copied());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use crate::precompile::HashMap;
|
||||
use alloy_primitives::Address;
|
||||
use alloy_primitives::{map::HashMap, Address};
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_consensus_common::calc;
|
||||
use reth_primitives::{Block, Withdrawal, Withdrawals, U256};
|
||||
@@ -14,7 +13,7 @@ pub fn post_block_balance_increments(
|
||||
block: &Block,
|
||||
total_difficulty: U256,
|
||||
) -> HashMap<Address, u128> {
|
||||
let mut balance_increments = HashMap::new();
|
||||
let mut balance_increments = HashMap::default();
|
||||
|
||||
// Add block rewards if they are enabled.
|
||||
if let Some(base_block_reward) =
|
||||
@@ -52,7 +51,8 @@ pub fn post_block_withdrawals_balance_increments<ChainSpec: EthereumHardforks>(
|
||||
block_timestamp: u64,
|
||||
withdrawals: &[Withdrawal],
|
||||
) -> HashMap<Address, u128> {
|
||||
let mut balance_increments = HashMap::with_capacity(withdrawals.len());
|
||||
let mut balance_increments =
|
||||
HashMap::with_capacity_and_hasher(withdrawals.len(), Default::default());
|
||||
insert_post_block_withdrawals_balance_increments(
|
||||
chain_spec,
|
||||
block_timestamp,
|
||||
@@ -124,7 +124,7 @@ mod tests {
|
||||
];
|
||||
|
||||
// Create an empty HashMap to hold the balance increments
|
||||
let mut balance_increments = HashMap::new();
|
||||
let mut balance_increments = HashMap::default();
|
||||
|
||||
// Act
|
||||
// Call the function with the prepared inputs
|
||||
@@ -168,7 +168,7 @@ mod tests {
|
||||
let withdrawals = Vec::<Withdrawal>::new();
|
||||
|
||||
// Create an empty HashMap to hold the balance increments
|
||||
let mut balance_increments = HashMap::new();
|
||||
let mut balance_increments = HashMap::default();
|
||||
|
||||
// Act
|
||||
// Call the function with the prepared inputs
|
||||
@@ -211,7 +211,7 @@ mod tests {
|
||||
];
|
||||
|
||||
// Create an empty HashMap to hold the balance increments
|
||||
let mut balance_increments = HashMap::new();
|
||||
let mut balance_increments = HashMap::default();
|
||||
|
||||
// Act
|
||||
// Call the function with the prepared inputs
|
||||
@@ -260,7 +260,7 @@ mod tests {
|
||||
];
|
||||
|
||||
// Create an empty HashMap to hold the balance increments
|
||||
let mut balance_increments = HashMap::new();
|
||||
let mut balance_increments = HashMap::default();
|
||||
|
||||
// Act
|
||||
// Call the function with the prepared inputs
|
||||
@@ -296,7 +296,7 @@ mod tests {
|
||||
let withdrawals = None; // No withdrawals provided
|
||||
|
||||
// Create an empty HashMap to hold the balance increments
|
||||
let mut balance_increments = HashMap::new();
|
||||
let mut balance_increments = HashMap::default();
|
||||
|
||||
// Act
|
||||
// Call the function with the prepared inputs
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::precompile::HashMap;
|
||||
use alloc::vec::Vec;
|
||||
use alloy_primitives::{keccak256, Address, BlockNumber, StorageKey};
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{HashMap, HashSet},
|
||||
Address, BlockNumber, StorageKey,
|
||||
};
|
||||
use reth_primitives::{Account, Bytecode, Bytes, B256, U256};
|
||||
use reth_storage_api::{
|
||||
AccountReader, BlockHashReader, StateProofProvider, StateProvider, StateRootProvider,
|
||||
|
||||
10
crates/rpc/rpc-eth-types/src/cache/db.rs
vendored
10
crates/rpc/rpc-eth-types/src/cache/db.rs
vendored
@@ -2,7 +2,10 @@
|
||||
//! <https://github.com/rust-lang/rust/issues/100013> in default implementation of
|
||||
//! `reth_rpc_eth_api::helpers::Call`.
|
||||
|
||||
use alloy_primitives::{Address, B256, U256};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Address, B256, U256,
|
||||
};
|
||||
use reth_errors::ProviderResult;
|
||||
use reth_revm::{database::StateProviderDatabase, db::CacheDB, DatabaseRef};
|
||||
use reth_storage_api::StateProvider;
|
||||
@@ -70,7 +73,7 @@ impl<'a> reth_storage_api::StateProofProvider for StateProviderTraitObjWrapper<'
|
||||
fn multiproof(
|
||||
&self,
|
||||
input: reth_trie::TrieInput,
|
||||
targets: std::collections::HashMap<B256, std::collections::HashSet<B256>>,
|
||||
targets: HashMap<B256, HashSet<B256>>,
|
||||
) -> ProviderResult<reth_trie::MultiProof> {
|
||||
self.0.multiproof(input, targets)
|
||||
}
|
||||
@@ -79,7 +82,8 @@ impl<'a> reth_storage_api::StateProofProvider for StateProviderTraitObjWrapper<'
|
||||
&self,
|
||||
input: reth_trie::TrieInput,
|
||||
target: reth_trie::HashedPostState,
|
||||
) -> reth_errors::ProviderResult<std::collections::HashMap<B256, alloy_primitives::Bytes>> {
|
||||
) -> reth_errors::ProviderResult<alloy_primitives::map::HashMap<B256, alloy_primitives::Bytes>>
|
||||
{
|
||||
self.0.witness(input, target)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ where
|
||||
let block_executor = this.inner.block_executor.executor(db);
|
||||
|
||||
let mut hashed_state = HashedPostState::default();
|
||||
let mut keys = HashMap::new();
|
||||
let mut keys = HashMap::default();
|
||||
let _ = block_executor
|
||||
.execute_with_state_witness(
|
||||
(&block.clone().unseal(), block.difficulty).into(),
|
||||
@@ -666,7 +666,10 @@ where
|
||||
|
||||
let state =
|
||||
state_provider.witness(Default::default(), hashed_state).map_err(Into::into)?;
|
||||
Ok(ExecutionWitness { state, keys: include_preimages.then_some(keys) })
|
||||
Ok(ExecutionWitness {
|
||||
state: std::collections::HashMap::from_iter(state.into_iter()),
|
||||
keys: include_preimages.then_some(keys),
|
||||
})
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ pub struct ActiveFilters<T> {
|
||||
impl<T> ActiveFilters<T> {
|
||||
/// Returns an empty instance.
|
||||
pub fn new() -> Self {
|
||||
Self { inner: Arc::new(Mutex::new(HashMap::new())) }
|
||||
Self { inner: Arc::new(Mutex::new(HashMap::default())) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ where
|
||||
let state = self.provider().state_by_block_id(block_id)?;
|
||||
let accounts_before = self.provider().account_block_changeset(block_number)?;
|
||||
let hash_map = accounts_before.iter().try_fold(
|
||||
HashMap::new(),
|
||||
HashMap::default(),
|
||||
|mut hash_map, account_before| -> RethResult<_> {
|
||||
let current_balance = state.account_balance(account_before.address)?;
|
||||
let prev_balance = account_before.info.map(|info| info.balance);
|
||||
|
||||
@@ -51,7 +51,7 @@ pub struct StageSetBuilder<Provider> {
|
||||
|
||||
impl<Provider> Default for StageSetBuilder<Provider> {
|
||||
fn default() -> Self {
|
||||
Self { stages: HashMap::new(), order: Vec::new() }
|
||||
Self { stages: HashMap::default(), order: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ where
|
||||
let mut changeset_cursor = provider.tx_ref().cursor_read::<CS>()?;
|
||||
|
||||
let mut collector = Collector::new(etl_config.file_size, etl_config.dir.clone());
|
||||
let mut cache: HashMap<P, Vec<u64>> = HashMap::new();
|
||||
let mut cache: HashMap<P, Vec<u64>> = HashMap::default();
|
||||
|
||||
let mut collect = |cache: &HashMap<P, Vec<u64>>| {
|
||||
for (key, indice_list) in cache {
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
use crate::{
|
||||
AccountReader, BlockHashReader, ExecutionDataProvider, StateProvider, StateRootProvider,
|
||||
};
|
||||
use alloy_primitives::{Address, BlockNumber, Bytes, B256};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Address, BlockNumber, Bytes, B256,
|
||||
};
|
||||
use reth_primitives::{Account, Bytecode};
|
||||
use reth_storage_api::{StateProofProvider, StorageRootProvider};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use reth_trie::{
|
||||
updates::TrieUpdates, AccountProof, HashedPostState, HashedStorage, MultiProof, TrieInput,
|
||||
};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// A state provider that resolves to data from either a wrapped [`crate::ExecutionOutcome`]
|
||||
/// or an underlying state provider.
|
||||
|
||||
@@ -913,14 +913,14 @@ impl<TX: DbTx, Spec: Send + Sync> DatabaseProvider<TX, Spec> {
|
||||
// iterate previous value and get plain state value to create changeset
|
||||
// Double option around Account represent if Account state is know (first option) and
|
||||
// account is removed (Second Option)
|
||||
let mut state: BundleStateInit = HashMap::new();
|
||||
let mut state: BundleStateInit = HashMap::default();
|
||||
|
||||
// This is not working for blocks that are not at tip. as plain state is not the last
|
||||
// state of end range. We should rename the functions or add support to access
|
||||
// History state. Accessing history state can be tricky but we are not gaining
|
||||
// anything.
|
||||
|
||||
let mut reverts: RevertsInit = HashMap::new();
|
||||
let mut reverts: RevertsInit = HashMap::default();
|
||||
|
||||
// add account changeset changes
|
||||
for (block_number, account_before) in account_changeset.into_iter().rev() {
|
||||
@@ -928,7 +928,7 @@ impl<TX: DbTx, Spec: Send + Sync> DatabaseProvider<TX, Spec> {
|
||||
match state.entry(address) {
|
||||
hash_map::Entry::Vacant(entry) => {
|
||||
let new_info = plain_accounts_cursor.seek_exact(address)?.map(|kv| kv.1);
|
||||
entry.insert((old_info, new_info, HashMap::new()));
|
||||
entry.insert((old_info, new_info, HashMap::default()));
|
||||
}
|
||||
hash_map::Entry::Occupied(mut entry) => {
|
||||
// overwrite old account state.
|
||||
@@ -946,7 +946,7 @@ impl<TX: DbTx, Spec: Send + Sync> DatabaseProvider<TX, Spec> {
|
||||
let account_state = match state.entry(address) {
|
||||
hash_map::Entry::Vacant(entry) => {
|
||||
let present_info = plain_accounts_cursor.seek_exact(address)?.map(|kv| kv.1);
|
||||
entry.insert((present_info, present_info, HashMap::new()))
|
||||
entry.insert((present_info, present_info, HashMap::default()))
|
||||
}
|
||||
hash_map::Entry::Occupied(entry) => entry.into_mut(),
|
||||
};
|
||||
|
||||
@@ -2,7 +2,10 @@ use crate::{
|
||||
providers::{state::macros::delegate_provider_impls, StaticFileProvider},
|
||||
AccountReader, BlockHashReader, ProviderError, StateProvider, StateRootProvider,
|
||||
};
|
||||
use alloy_primitives::{Address, BlockNumber, Bytes, StorageKey, StorageValue, B256};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Address, BlockNumber, Bytes, StorageKey, StorageValue, B256,
|
||||
};
|
||||
use reth_db::{tables, BlockNumberList};
|
||||
use reth_db_api::{
|
||||
cursor::{DbCursorRO, DbDupCursorRO},
|
||||
@@ -21,10 +24,7 @@ use reth_trie_db::{
|
||||
DatabaseHashedPostState, DatabaseHashedStorage, DatabaseProof, DatabaseStateRoot,
|
||||
DatabaseStorageRoot, DatabaseTrieWitness,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
fmt::Debug,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// State provider for a given block number which takes a tx reference.
|
||||
///
|
||||
|
||||
@@ -2,7 +2,10 @@ use crate::{
|
||||
providers::{state::macros::delegate_provider_impls, StaticFileProvider},
|
||||
AccountReader, BlockHashReader, StateProvider, StateRootProvider,
|
||||
};
|
||||
use alloy_primitives::{Address, BlockNumber, Bytes, StorageKey, StorageValue, B256};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Address, BlockNumber, Bytes, StorageKey, StorageValue, B256,
|
||||
};
|
||||
use reth_db::tables;
|
||||
use reth_db_api::{
|
||||
cursor::{DbCursorRO, DbDupCursorRO},
|
||||
@@ -16,7 +19,6 @@ use reth_trie::{
|
||||
HashedStorage, MultiProof, StateRoot, StorageRoot, TrieInput,
|
||||
};
|
||||
use reth_trie_db::{DatabaseProof, DatabaseStateRoot, DatabaseStorageRoot, DatabaseTrieWitness};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// State provider over latest state that takes tx reference.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -52,8 +52,8 @@ macro_rules! delegate_provider_impls {
|
||||
}
|
||||
StateProofProvider $(where [$($generics)*])? {
|
||||
fn proof(&self, input: reth_trie::TrieInput, address: alloy_primitives::Address, slots: &[alloy_primitives::B256]) -> reth_storage_errors::provider::ProviderResult<reth_trie::AccountProof>;
|
||||
fn multiproof(&self, input: reth_trie::TrieInput, targets: std::collections::HashMap<reth_primitives::B256, std::collections::HashSet<alloy_primitives::B256>>) -> reth_storage_errors::provider::ProviderResult<reth_trie::MultiProof>;
|
||||
fn witness(&self, input: reth_trie::TrieInput, target: reth_trie::HashedPostState) -> reth_storage_errors::provider::ProviderResult<std::collections::HashMap<alloy_primitives::B256, alloy_primitives::Bytes>>;
|
||||
fn multiproof(&self, input: reth_trie::TrieInput, targets: alloy_primitives::map::HashMap<reth_primitives::B256, alloy_primitives::map::HashSet<alloy_primitives::B256>>) -> reth_storage_errors::provider::ProviderResult<reth_trie::MultiProof>;
|
||||
fn witness(&self, input: reth_trie::TrieInput, target: reth_trie::HashedPostState) -> reth_storage_errors::provider::ProviderResult<alloy_primitives::map::HashMap<alloy_primitives::B256, alloy_primitives::Bytes>>;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Dummy blocks and data for tests
|
||||
use crate::{DatabaseProviderRW, ExecutionOutcome};
|
||||
use alloy_consensus::TxLegacy;
|
||||
use alloy_primitives::{Address, BlockNumber, Log, Parity, Sealable, TxKind};
|
||||
use alloy_primitives::{map::HashMap, Address, BlockNumber, Log, Parity, Sealable, TxKind};
|
||||
use once_cell::sync::Lazy;
|
||||
use reth_db::tables;
|
||||
use reth_db_api::{database::Database, models::StoredBlockBodyIndices};
|
||||
@@ -11,10 +11,7 @@ use reth_primitives::{
|
||||
TxType, Withdrawal, Withdrawals, B256, U256,
|
||||
};
|
||||
use reth_trie::root::{state_root_unhashed, storage_root_unhashed};
|
||||
use revm::{
|
||||
db::BundleState,
|
||||
primitives::{AccountInfo, HashMap},
|
||||
};
|
||||
use revm::{db::BundleState, primitives::AccountInfo};
|
||||
use std::str::FromStr;
|
||||
|
||||
/// Assert genesis block
|
||||
@@ -200,7 +197,7 @@ fn block1(number: BlockNumber) -> (SealedBlockWithSenders, ExecutionOutcome) {
|
||||
.revert_account_info(number, account1, Some(None))
|
||||
.state_present_account_info(account2, info)
|
||||
.revert_account_info(number, account2, Some(None))
|
||||
.state_storage(account1, HashMap::from([(slot, (U256::ZERO, U256::from(10)))]))
|
||||
.state_storage(account1, HashMap::from_iter([(slot, (U256::ZERO, U256::from(10)))]))
|
||||
.build(),
|
||||
vec![vec![Some(Receipt {
|
||||
tx_type: TxType::Eip2930,
|
||||
@@ -256,7 +253,7 @@ fn block2(
|
||||
account,
|
||||
AccountInfo { nonce: 3, balance: U256::from(20), ..Default::default() },
|
||||
)
|
||||
.state_storage(account, HashMap::from([(slot, (U256::ZERO, U256::from(15)))]))
|
||||
.state_storage(account, HashMap::from_iter([(slot, (U256::ZERO, U256::from(15)))]))
|
||||
.revert_account_info(
|
||||
number,
|
||||
account,
|
||||
|
||||
@@ -8,8 +8,9 @@ use crate::{
|
||||
};
|
||||
use alloy_eips::{BlockHashOrNumber, BlockId, BlockNumberOrTag};
|
||||
use alloy_primitives::{
|
||||
keccak256, Address, BlockHash, BlockNumber, Bytes, StorageKey, StorageValue, TxHash, TxNumber,
|
||||
B256, U256,
|
||||
keccak256,
|
||||
map::{HashMap, HashSet},
|
||||
Address, BlockHash, BlockNumber, Bytes, StorageKey, StorageValue, TxHash, TxNumber, B256, U256,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use reth_chainspec::{ChainInfo, ChainSpec};
|
||||
@@ -32,7 +33,7 @@ use reth_trie::{
|
||||
};
|
||||
use revm::primitives::{BlockEnv, CfgEnvWithHandlerCfg};
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
collections::BTreeMap,
|
||||
ops::{RangeBounds, RangeInclusive},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
ops::{RangeBounds, RangeInclusive},
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
@@ -7,6 +6,7 @@ use std::{
|
||||
|
||||
use alloy_eips::{BlockHashOrNumber, BlockId, BlockNumberOrTag};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Address, BlockHash, BlockNumber, Bytes, StorageKey, StorageValue, TxHash, TxNumber, B256, U256,
|
||||
};
|
||||
use reth_chain_state::{
|
||||
|
||||
@@ -544,7 +544,7 @@ mod tests {
|
||||
use crate::{
|
||||
test_utils::create_test_provider_factory, AccountReader, StorageTrieWriter, TrieWriter,
|
||||
};
|
||||
use alloy_primitives::{keccak256, Address, B256, U256};
|
||||
use alloy_primitives::{keccak256, map::HashMap, Address, B256, U256};
|
||||
use reth_db::tables;
|
||||
use reth_db_api::{
|
||||
cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO},
|
||||
@@ -570,10 +570,7 @@ mod tests {
|
||||
},
|
||||
DatabaseCommit, State,
|
||||
};
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
str::FromStr,
|
||||
};
|
||||
use std::{collections::BTreeMap, str::FromStr};
|
||||
|
||||
#[test]
|
||||
fn wiped_entries_are_removed() {
|
||||
@@ -644,7 +641,7 @@ mod tests {
|
||||
state.insert_account(address_b, account_b.clone());
|
||||
|
||||
// 0x00.. is created
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address_a,
|
||||
RevmAccount {
|
||||
info: account_a.clone(),
|
||||
@@ -654,7 +651,7 @@ mod tests {
|
||||
)]));
|
||||
|
||||
// 0xff.. is changed (balance + 1, nonce + 1)
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address_b,
|
||||
RevmAccount {
|
||||
info: account_b_changed.clone(),
|
||||
@@ -712,7 +709,7 @@ mod tests {
|
||||
state.insert_account(address_b, account_b_changed.clone());
|
||||
|
||||
// 0xff.. is destroyed
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address_b,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::SelfDestructed,
|
||||
@@ -771,10 +768,10 @@ mod tests {
|
||||
state.insert_account_with_storage(
|
||||
address_b,
|
||||
account_b.clone(),
|
||||
HashMap::from([(U256::from(1), U256::from(1))]),
|
||||
HashMap::from_iter([(U256::from(1), U256::from(1))]),
|
||||
);
|
||||
|
||||
state.commit(HashMap::from([
|
||||
state.commit(HashMap::from_iter([
|
||||
(
|
||||
address_a,
|
||||
RevmAccount {
|
||||
@@ -782,7 +779,7 @@ mod tests {
|
||||
info: RevmAccountInfo::default(),
|
||||
// 0x00 => 0 => 1
|
||||
// 0x01 => 0 => 2
|
||||
storage: HashMap::from([
|
||||
storage: HashMap::from_iter([
|
||||
(
|
||||
U256::from(0),
|
||||
EvmStorageSlot { present_value: U256::from(1), ..Default::default() },
|
||||
@@ -800,7 +797,7 @@ mod tests {
|
||||
status: AccountStatus::Touched,
|
||||
info: account_b,
|
||||
// 0x01 => 1 => 2
|
||||
storage: HashMap::from([(
|
||||
storage: HashMap::from_iter([(
|
||||
U256::from(1),
|
||||
EvmStorageSlot {
|
||||
present_value: U256::from(2),
|
||||
@@ -905,7 +902,7 @@ mod tests {
|
||||
let mut state = State::builder().with_bundle_update().build();
|
||||
state.insert_account(address_a, RevmAccountInfo::default());
|
||||
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address_a,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::SelfDestructed,
|
||||
@@ -962,14 +959,14 @@ mod tests {
|
||||
// Block #0: initial state.
|
||||
let mut init_state = State::builder().with_bundle_update().build();
|
||||
init_state.insert_not_existing(address1);
|
||||
init_state.commit(HashMap::from([(
|
||||
init_state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
info: account_info.clone(),
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
// 0x00 => 0 => 1
|
||||
// 0x01 => 0 => 2
|
||||
storage: HashMap::from([
|
||||
storage: HashMap::from_iter([
|
||||
(
|
||||
U256::ZERO,
|
||||
EvmStorageSlot { present_value: U256::from(1), ..Default::default() },
|
||||
@@ -994,17 +991,17 @@ mod tests {
|
||||
state.insert_account_with_storage(
|
||||
address1,
|
||||
account_info.clone(),
|
||||
HashMap::from([(U256::ZERO, U256::from(1)), (U256::from(1), U256::from(2))]),
|
||||
HashMap::from_iter([(U256::ZERO, U256::from(1)), (U256::from(1), U256::from(2))]),
|
||||
);
|
||||
|
||||
// Block #1: change storage.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
info: account_info.clone(),
|
||||
// 0x00 => 1 => 2
|
||||
storage: HashMap::from([(
|
||||
storage: HashMap::from_iter([(
|
||||
U256::ZERO,
|
||||
EvmStorageSlot {
|
||||
original_value: U256::from(1),
|
||||
@@ -1017,7 +1014,7 @@ mod tests {
|
||||
state.merge_transitions(BundleRetention::Reverts);
|
||||
|
||||
// Block #2: destroy account.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::SelfDestructed,
|
||||
@@ -1028,7 +1025,7 @@ mod tests {
|
||||
state.merge_transitions(BundleRetention::Reverts);
|
||||
|
||||
// Block #3: re-create account and change storage.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
@@ -1039,7 +1036,7 @@ mod tests {
|
||||
state.merge_transitions(BundleRetention::Reverts);
|
||||
|
||||
// Block #4: change storage.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
@@ -1047,7 +1044,7 @@ mod tests {
|
||||
// 0x00 => 0 => 2
|
||||
// 0x02 => 0 => 4
|
||||
// 0x06 => 0 => 6
|
||||
storage: HashMap::from([
|
||||
storage: HashMap::from_iter([
|
||||
(
|
||||
U256::ZERO,
|
||||
EvmStorageSlot { present_value: U256::from(2), ..Default::default() },
|
||||
@@ -1066,7 +1063,7 @@ mod tests {
|
||||
state.merge_transitions(BundleRetention::Reverts);
|
||||
|
||||
// Block #5: Destroy account again.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::SelfDestructed,
|
||||
@@ -1077,7 +1074,7 @@ mod tests {
|
||||
state.merge_transitions(BundleRetention::Reverts);
|
||||
|
||||
// Block #6: Create, change, destroy and re-create in the same block.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
@@ -1085,19 +1082,19 @@ mod tests {
|
||||
storage: HashMap::default(),
|
||||
},
|
||||
)]));
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
info: account_info.clone(),
|
||||
// 0x00 => 0 => 2
|
||||
storage: HashMap::from([(
|
||||
storage: HashMap::from_iter([(
|
||||
U256::ZERO,
|
||||
EvmStorageSlot { present_value: U256::from(2), ..Default::default() },
|
||||
)]),
|
||||
},
|
||||
)]));
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::SelfDestructed,
|
||||
@@ -1105,7 +1102,7 @@ mod tests {
|
||||
storage: HashMap::default(),
|
||||
},
|
||||
)]));
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
@@ -1116,13 +1113,13 @@ mod tests {
|
||||
state.merge_transitions(BundleRetention::Reverts);
|
||||
|
||||
// Block #7: Change storage.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
info: account_info,
|
||||
// 0x00 => 0 => 9
|
||||
storage: HashMap::from([(
|
||||
storage: HashMap::from_iter([(
|
||||
U256::ZERO,
|
||||
EvmStorageSlot { present_value: U256::from(9), ..Default::default() },
|
||||
)]),
|
||||
@@ -1277,14 +1274,14 @@ mod tests {
|
||||
// Block #0: initial state.
|
||||
let mut init_state = State::builder().with_bundle_update().build();
|
||||
init_state.insert_not_existing(address1);
|
||||
init_state.commit(HashMap::from([(
|
||||
init_state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
info: account1.clone(),
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
// 0x00 => 0 => 1
|
||||
// 0x01 => 0 => 2
|
||||
storage: HashMap::from([
|
||||
storage: HashMap::from_iter([
|
||||
(
|
||||
U256::ZERO,
|
||||
EvmStorageSlot { present_value: U256::from(1), ..Default::default() },
|
||||
@@ -1308,11 +1305,11 @@ mod tests {
|
||||
state.insert_account_with_storage(
|
||||
address1,
|
||||
account1.clone(),
|
||||
HashMap::from([(U256::ZERO, U256::from(1)), (U256::from(1), U256::from(2))]),
|
||||
HashMap::from_iter([(U256::ZERO, U256::from(1)), (U256::from(1), U256::from(2))]),
|
||||
);
|
||||
|
||||
// Block #1: Destroy, re-create, change storage.
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::SelfDestructed,
|
||||
@@ -1321,7 +1318,7 @@ mod tests {
|
||||
},
|
||||
)]));
|
||||
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
@@ -1330,13 +1327,13 @@ mod tests {
|
||||
},
|
||||
)]));
|
||||
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
info: account1,
|
||||
// 0x01 => 0 => 5
|
||||
storage: HashMap::from([(
|
||||
storage: HashMap::from_iter([(
|
||||
U256::from(1),
|
||||
EvmStorageSlot { present_value: U256::from(5), ..Default::default() },
|
||||
)]),
|
||||
@@ -1468,7 +1465,7 @@ mod tests {
|
||||
let address1 = Address::with_last_byte(1);
|
||||
let account1_old = prestate.remove(&address1).unwrap();
|
||||
state.insert_account(address1, account1_old.0.into());
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::SelfDestructed,
|
||||
@@ -1488,12 +1485,12 @@ mod tests {
|
||||
state.insert_account_with_storage(
|
||||
address2,
|
||||
account2.0.into(),
|
||||
HashMap::from([(slot2, account2_slot2_old_value)]),
|
||||
HashMap::from_iter([(slot2, account2_slot2_old_value)]),
|
||||
);
|
||||
|
||||
let account2_slot2_new_value = U256::from(100);
|
||||
account2.1.insert(slot2_key, account2_slot2_new_value);
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address2,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
@@ -1513,7 +1510,7 @@ mod tests {
|
||||
state.insert_account(address3, account3.0.into());
|
||||
|
||||
account3.0.balance = U256::from(24);
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address3,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
@@ -1530,7 +1527,7 @@ mod tests {
|
||||
state.insert_account(address4, account4.0.into());
|
||||
|
||||
account4.0.nonce = 128;
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address4,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched,
|
||||
@@ -1545,7 +1542,7 @@ mod tests {
|
||||
let account1_new =
|
||||
Account { nonce: 56, balance: U256::from(123), bytecode_hash: Some(B256::random()) };
|
||||
prestate.insert(address1, (account1_new, BTreeMap::default()));
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
@@ -1561,7 +1558,7 @@ mod tests {
|
||||
let slot20_key = B256::from(slot20);
|
||||
let account1_slot20_value = U256::from(12345);
|
||||
prestate.get_mut(&address1).unwrap().1.insert(slot20_key, account1_slot20_value);
|
||||
state.commit(HashMap::from([(
|
||||
state.commit(HashMap::from_iter([(
|
||||
address1,
|
||||
RevmAccount {
|
||||
status: AccountStatus::Touched | AccountStatus::Created,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use alloy_primitives::{Address, Bytes, B256};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Address, Bytes, B256,
|
||||
};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use reth_trie::{
|
||||
updates::TrieUpdates, AccountProof, HashedPostState, HashedStorage, MultiProof, TrieInput,
|
||||
};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// A type that can compute the state root of a given post state.
|
||||
#[auto_impl::auto_impl(&, Box, Arc)]
|
||||
|
||||
@@ -266,7 +266,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_contains_local_address() {
|
||||
let address = Address::new([1; 20]);
|
||||
let mut local_addresses = HashSet::new();
|
||||
let mut local_addresses = HashSet::default();
|
||||
local_addresses.insert(address);
|
||||
|
||||
let config = LocalTransactionConfig { local_addresses, ..Default::default() };
|
||||
@@ -283,7 +283,7 @@ mod tests {
|
||||
let address = Address::new([1; 20]);
|
||||
let config = LocalTransactionConfig {
|
||||
no_exemptions: true,
|
||||
local_addresses: HashSet::new(),
|
||||
local_addresses: HashSet::default(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -294,7 +294,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_is_local_without_no_exemptions() {
|
||||
let address = Address::new([1; 20]);
|
||||
let mut local_addresses = HashSet::new();
|
||||
let mut local_addresses = HashSet::default();
|
||||
local_addresses.insert(address);
|
||||
|
||||
let config =
|
||||
|
||||
@@ -138,7 +138,7 @@ pub async fn maintain_transaction_pool<Client, P, St, Tasks>(
|
||||
FinalizedBlockTracker::new(client.finalized_block_number().ok().flatten());
|
||||
|
||||
// keeps track of any dirty accounts that we know of are out of sync with the pool
|
||||
let mut dirty_addresses = HashSet::new();
|
||||
let mut dirty_addresses = HashSet::default();
|
||||
|
||||
// keeps track of the state of the pool wrt to blocks
|
||||
let mut maintained_state = MaintainedPoolState::InSync;
|
||||
|
||||
@@ -2708,7 +2708,7 @@ mod tests {
|
||||
|
||||
assert_eq!(pool.pending_pool.len(), 2);
|
||||
|
||||
let mut changed_senders = HashMap::new();
|
||||
let mut changed_senders = HashMap::default();
|
||||
changed_senders.insert(
|
||||
id.sender,
|
||||
SenderInfo { state_nonce: next.get_nonce(), balance: U256::from(1_000) },
|
||||
@@ -2892,7 +2892,7 @@ mod tests {
|
||||
assert_eq!(1, pool.pending_transactions().len());
|
||||
|
||||
// Simulate new block arrival - and chain nonce increasing.
|
||||
let mut updated_accounts = HashMap::new();
|
||||
let mut updated_accounts = HashMap::default();
|
||||
on_chain_nonce += 1;
|
||||
updated_accounts.insert(
|
||||
v0.sender_id(),
|
||||
@@ -2967,7 +2967,7 @@ mod tests {
|
||||
assert_eq!(1, pool.pending_transactions().len());
|
||||
|
||||
// Simulate new block arrival - and chain nonce increasing.
|
||||
let mut updated_accounts = HashMap::new();
|
||||
let mut updated_accounts = HashMap::default();
|
||||
on_chain_nonce += 1;
|
||||
updated_accounts.insert(
|
||||
v0.sender_id(),
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
|
||||
use alloy_primitives::{Address, B256};
|
||||
use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Address, B256,
|
||||
};
|
||||
use reth_db_api::transaction::DbTx;
|
||||
use reth_execution_errors::StateProofError;
|
||||
use reth_trie::{
|
||||
@@ -7,7 +10,6 @@ use reth_trie::{
|
||||
trie_cursor::InMemoryTrieCursorFactory, MultiProof, TrieInput,
|
||||
};
|
||||
use reth_trie_common::AccountProof;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// Extends [`Proof`] with operations specific for working with a database transaction.
|
||||
pub trait DatabaseProof<'a, TX> {
|
||||
|
||||
@@ -267,12 +267,11 @@ impl<TX: DbTx> DatabaseHashedPostState<TX> for HashedPostState {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use alloy_primitives::Address;
|
||||
use alloy_primitives::{map::HashMap, Address};
|
||||
use reth_db::test_utils::create_test_rw_db;
|
||||
use reth_db_api::database::Database;
|
||||
use reth_primitives::{hex, revm_primitives::AccountInfo, U256};
|
||||
use revm::db::BundleState;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
fn from_bundle_state_with_rayon() {
|
||||
@@ -287,8 +286,8 @@ mod tests {
|
||||
let bundle_state = BundleState::builder(2..=2)
|
||||
.state_present_account_info(address1, account1)
|
||||
.state_present_account_info(address2, account2)
|
||||
.state_storage(address1, HashMap::from([(slot1, (U256::ZERO, U256::from(10)))]))
|
||||
.state_storage(address2, HashMap::from([(slot2, (U256::ZERO, U256::from(20)))]))
|
||||
.state_storage(address1, HashMap::from_iter([(slot1, (U256::ZERO, U256::from(10)))]))
|
||||
.state_storage(address2, HashMap::from_iter([(slot2, (U256::ZERO, U256::from(20)))]))
|
||||
.build();
|
||||
assert_eq!(bundle_state.reverts.len(), 1);
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
|
||||
use alloy_primitives::{Bytes, B256};
|
||||
use alloy_primitives::{map::HashMap, Bytes, B256};
|
||||
use reth_db_api::transaction::DbTx;
|
||||
use reth_execution_errors::TrieWitnessError;
|
||||
use reth_trie::{
|
||||
hashed_cursor::HashedPostStateCursorFactory, trie_cursor::InMemoryTrieCursorFactory,
|
||||
witness::TrieWitness, HashedPostState, TrieInput,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Extends [`TrieWitness`] with operations specific for working with a database transaction.
|
||||
pub trait DatabaseTrieWitness<'a, TX> {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#![allow(missing_docs, unreachable_pub)]
|
||||
use alloy_primitives::{keccak256, Address, B256, U256};
|
||||
use alloy_primitives::{keccak256, map::HashMap, Address, B256, U256};
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use proptest::{prelude::*, strategy::ValueTree, test_runner::TestRunner};
|
||||
use reth_trie::{HashedPostState, HashedStorage};
|
||||
use revm::db::{states::BundleBuilder, BundleAccount};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub fn hash_post_state(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("Hash Post State");
|
||||
@@ -68,7 +67,7 @@ fn generate_test_data(size: usize) -> HashMap<Address, BundleAccount> {
|
||||
let mut bundle_builder = BundleBuilder::default();
|
||||
|
||||
for (address, storage) in state {
|
||||
bundle_builder = bundle_builder.state_storage(address, storage);
|
||||
bundle_builder = bundle_builder.state_storage(address, storage.into_iter().collect());
|
||||
}
|
||||
|
||||
let bundle_state = bundle_builder.build();
|
||||
|
||||
@@ -6,13 +6,16 @@ use crate::{
|
||||
walker::TrieWalker,
|
||||
HashBuilder, Nibbles,
|
||||
};
|
||||
use alloy_primitives::{keccak256, Address, B256};
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{HashMap, HashSet},
|
||||
Address, B256,
|
||||
};
|
||||
use alloy_rlp::{BufMut, Encodable};
|
||||
use reth_execution_errors::trie::StateProofError;
|
||||
use reth_trie_common::{
|
||||
proof::ProofRetainer, AccountProof, MultiProof, StorageMultiProof, TrieAccount,
|
||||
};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// A struct for generating merkle proofs.
|
||||
///
|
||||
@@ -70,7 +73,7 @@ impl<T, H> Proof<T, H> {
|
||||
|
||||
/// Set the target account and slots.
|
||||
pub fn with_target(self, target: (B256, HashSet<B256>)) -> Self {
|
||||
self.with_targets(HashMap::from([target]))
|
||||
self.with_targets(HashMap::from_iter([target]))
|
||||
}
|
||||
|
||||
/// Set the target accounts and slots.
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::{
|
||||
hashed_cursor::HashedCursorFactory, prefix_set::TriePrefixSetsMut, proof::Proof,
|
||||
trie_cursor::TrieCursorFactory, HashedPostState,
|
||||
};
|
||||
use alloy_primitives::{keccak256, Bytes, B256};
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{HashMap, HashSet},
|
||||
Bytes, B256,
|
||||
};
|
||||
use alloy_rlp::{BufMut, Decodable, Encodable};
|
||||
use itertools::Either;
|
||||
use reth_execution_errors::{StateProofError, TrieWitnessError};
|
||||
@@ -10,7 +16,6 @@ use reth_primitives::constants::EMPTY_ROOT_HASH;
|
||||
use reth_trie_common::{
|
||||
BranchNode, HashBuilder, Nibbles, TrieAccount, TrieNode, CHILD_INDEX_RANGE,
|
||||
};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
|
||||
/// State transition witness for the trie.
|
||||
#[derive(Debug)]
|
||||
@@ -145,7 +150,7 @@ where
|
||||
self.hashed_cursor_factory.clone(),
|
||||
)
|
||||
.with_prefix_sets_mut(self.prefix_sets.clone())
|
||||
.with_target((hashed_address, HashSet::from([target_key])))
|
||||
.with_target((hashed_address, HashSet::from_iter([target_key])))
|
||||
.storage_multiproof(hashed_address)?;
|
||||
|
||||
// The subtree only contains the proof for a single target.
|
||||
|
||||
Reference in New Issue
Block a user