Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,382 changes: 2,287 additions & 2,095 deletions Cargo.lock

Large diffs are not rendered by default.

96 changes: 49 additions & 47 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,62 +70,64 @@ codegen-units = 1
incremental = false

[workspace.dependencies]
reth = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-db-common = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-trie = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-trie-parallel = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646", features = [
reth = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-db-common = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-trie = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-trie-parallel = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3", features = [
"test-utils",
] }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-revm = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-execution-errors = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", rev = "27a8c0f5a6dfb27dea84c5751776ecabdd069646" }

# compatible with reth 27a8c0f5a6dfb27dea84c5751776ecabdd069646 dependencies
revm = { version = "31.0.2", features = [
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-revm = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-execution-errors = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", rev = "793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3" }

# compatible with reth 793a3d5fb3e3413e9ecc9b024a5e26672e61e7c3 dependencies
revm = { version = "34.0.0", features = [
"std",
"secp256k1",
"optional_balance_check",
], default-features = false }
revm-inspectors = { version = "0.32.0", default-features = false }
revm-inspectors = { version = "0.34.2", default-features = false }

ethereum_ssz_derive = "0.9.0"
ethereum_ssz = "0.9.0"

alloy-primitives = { version = "1.4.1", default-features = false, features = [
alloy-primitives = { version = "1.5.6", default-features = false, features = [
"getrandom",
"map-foldhash",
] }
alloy-rlp = "0.3.10"
alloy-chains = "0.2.5"
alloy-trie = { version = "0.8.1", default-features = false }
alloy-evm = { version = "0.23.3", default-features = false }
alloy-provider = { version = "1.0.41", features = ["ipc", "pubsub", "ws"] }
alloy-eips = { version = "1.0.41" }
alloy-rpc-types = { version = "1.0.41" }
alloy-json-rpc = { version = "1.0.41" }
alloy-network = { version = "1.0.41" }
alloy-network-primitives = { version = "1.0.41" }
alloy-node-bindings = { version = "1.0.41" }
alloy-consensus = { version = "1.0.41", features = ["kzg"] }
alloy-rpc-types-beacon = { version = "1.0.41", features = ["ssz"] }
alloy-rpc-types-engine = { version = "1.0.41", features = ["ssz"] }
alloy-rpc-types-eth = { version = "1.0.41" }
alloy-signer = { version = "1.0.41" }
alloy-signer-local = { version = "1.0.41" }
alloy-rlp = { version = "0.3.13", default-features = false, features = ["core-net"] }
alloy-chains = { version = "0.2.5", default-features = false }
alloy-trie = { version = "0.9.4", default-features = false }
nybbles = { version = "0.4.8", features = ["serde"], default-features = false }
alloy-evm = { version = "0.27.2", default-features = false }
alloy-provider = { version = "1.6.3", features = ["ipc", "pubsub", "ws"], default-features = false }
alloy-eips = { version = "1.6.3", default-features = false }
alloy-rpc-types = { version = "1.6.3", features = ["eth"], default-features = false }
alloy-json-rpc = { version = "1.6.3", default-features = false }
alloy-network = { version = "1.6.3", default-features = false }
alloy-network-primitives = { version = "1.6.3", default-features = false }
alloy-node-bindings = { version = "1.6.3" }
alloy-consensus = { version = "1.6.3", features = ["kzg"], default-features = false }
alloy-rpc-types-beacon = { version = "1.6.3", features = ["ssz"], default-features = false }
alloy-rpc-types-engine = { version = "1.6.3", default-features = false }
alloy-rpc-types-eth = { version = "1.6.3", default-features = false }
alloy-signer = { version = "1.6.3", default-features = false }
alloy-signer-local = { version = "1.6.3", default-features = false }

# Version required by ethereum-consensus beacon-api-client
mev-share-sse = { git = "https://github.com/paradigmxyz/mev-share-rs", rev = "9eb2b0138ab3202b9eb3af4b19c7b3bf40b0faa8", default-features = false }
Expand All @@ -136,9 +138,9 @@ async-trait = { version = "0.1.83" }
clap = { version = "4.4.3", features = ["derive", "env"] }
thiserror = { version = "1.0.64" }
eyre = { version = "0.6.12" }
jsonrpsee = { version = "0.24.4" }
jsonrpsee = { version = "0.26.0" }
parking_lot = { version = "0.12.3" }
tokio = { version = "1.40.0", default-features = false }
tokio = { version = "1.44.2", default-features = false }
futures = "0.3"
futures-util = "0.3"
reqwest = { version = "0.12.8" }
Expand All @@ -147,7 +149,7 @@ serde_json = { version = "1.0" }
serde_with = { version = "3.8.1" }
secp256k1 = { version = "0.30" }
derive_more = { version = "2" }
tokio-stream = "0.1.16"
tokio-stream = "0.1.11"
tokio-util = "0.7.12"
url = "2.5.2"
warp = "0.3.7"
Expand Down
2 changes: 1 addition & 1 deletion crates/eth-sparse-mpt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rustc-hash = "2.0.0"
rayon = "1.10.0"
smallvec = "1.13.2"
alloy-trie.workspace = true
nybbles = { version = "0.3.3", features = ["serde"] }
nybbles = { workspace = true }

tracing.workspace = true

Expand Down
22 changes: 12 additions & 10 deletions crates/eth-sparse-mpt/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,27 @@ pub fn rlp_pointer(rlp_encode: Bytes) -> Bytes {
}

pub fn concat_path(p1: &Nibbles, p2: &[u8]) -> Nibbles {
let mut result = Nibbles::with_capacity(p1.len() + p2.len());
result.extend_from_slice_unchecked(p1);
result.extend_from_slice_unchecked(p2);
result
let mut result = p1.to_vec();
result.extend_from_slice(p2);
Nibbles::from_nibbles_unchecked(&result)
}

pub fn strip_first_nibble_mut(p: &mut Nibbles) -> u8 {
let nibble = p[0];
let vec = p.as_mut_vec_unchecked();
let mut vec = p.to_vec();
let nibble = vec[0];
vec.remove(0);
*p = Nibbles::from_nibbles_unchecked(&vec);
nibble
}

#[inline]
pub fn extract_prefix_and_suffix(p1: &Nibbles, p2: &Nibbles) -> (Nibbles, Nibbles, Nibbles) {
let p1_vec = p1.to_vec();
let p2_vec = p2.to_vec();
let prefix_len = p1.common_prefix_length(p2);
let prefix = Nibbles::from_nibbles_unchecked(&p1[..prefix_len]);
let suffix1 = Nibbles::from_nibbles_unchecked(&p1[prefix_len..]);
let suffix2 = Nibbles::from_nibbles_unchecked(&p2[prefix_len..]);
let prefix = Nibbles::from_nibbles_unchecked(&p1_vec[..prefix_len]);
let suffix1 = Nibbles::from_nibbles_unchecked(&p1_vec[prefix_len..]);
let suffix2 = Nibbles::from_nibbles_unchecked(&p2_vec[prefix_len..]);

(prefix, suffix1, suffix2)
}
Expand Down Expand Up @@ -147,5 +149,5 @@ pub fn convert_reth_nybbles_to_nibbles(n: reth_trie::Nibbles) -> Nibbles {

#[inline]
pub fn convert_nibbles_to_reth_nybbles(n: Nibbles) -> reth_trie::Nibbles {
reth_trie::Nibbles::from_nibbles(n.as_slice())
reth_trie::Nibbles::from_nibbles(n.to_vec())
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ impl RethSparseTrieShareCacheInternal {
multiproof: MultiProof,
) -> Result<(), AddNodeError> {
let mut nodes: Vec<_> = multiproof.account_subtree.into_iter().collect();
nodes.sort_by_key(|(p, _)| p.clone());
nodes.sort_by_key(|(p, _)| *p);
self.account_trie.add_nodes(&nodes)?;
for (account, storge_proofs) in multiproof.storages {
let mut nodes: Vec<_> = storge_proofs.subtree.into_iter().collect();
nodes.sort_by_key(|(p, _)| p.clone());
nodes.sort_by_key(|(p, _)| *p);
let account = Bytes::copy_from_slice(account.as_slice());
let storage_trie = self.storage_tries.entry(account).or_default();
storage_trie.add_nodes(&nodes)?;
Expand Down
22 changes: 12 additions & 10 deletions crates/eth-sparse-mpt/src/v1/reth_sparse_trie/trie_fetcher/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Instant;

use crate::utils::{convert_reth_nybbles_to_nibbles, hash_map_with_capacity, HashMap, HashSet};
use crate::utils::{hash_map_with_capacity, HashMap, HashSet};
use alloy_primitives::map::HashSet as AlloyHashSet;
use tracing::trace;

Expand Down Expand Up @@ -106,7 +106,9 @@ where
}

fn pad_path(mut path: Nibbles) -> B256 {
path.as_mut_vec_unchecked().resize(64, 0);
let mut path_vec = path.to_vec();
path_vec.resize(64, 0);
path = Nibbles::from_nibbles_unchecked(&path_vec);
let mut res = B256::default();
path.pack_to(res.as_mut_slice());
res
Expand Down Expand Up @@ -164,16 +166,16 @@ fn merge_results(
let mut result = MultiProof::default();
for mut proof in multiproofs {
result.account_subtree.append(&mut proof.account_subtree);
result.account_subtree.sort_by_key(|s| s.0.clone());
result.account_subtree.dedup_by_key(|s| s.0.clone());
result.account_subtree.sort_by_key(|s| s.0);
result.account_subtree.dedup_by_key(|s| s.0);

for (account, mut storage_proof) in proof.storages {
let result_storage_proof = result.storages.entry(account).or_default();
result_storage_proof
.subtree
.append(&mut storage_proof.subtree);
result_storage_proof.subtree.sort_by_key(|s| s.0.clone());
result_storage_proof.subtree.dedup_by_key(|s| s.0.clone());
result_storage_proof.subtree.sort_by_key(|s| s.0);
result_storage_proof.subtree.dedup_by_key(|s| s.0);
}
}

Expand All @@ -192,9 +194,9 @@ fn convert_reth_multiproof(
) -> MultiProof {
let mut account_subtree = Vec::with_capacity(reth_proof.account_subtree.len());
for (k, v) in reth_proof.account_subtree.into_inner() {
account_subtree.push((convert_reth_nybbles_to_nibbles(k), v));
account_subtree.push((k, v));
}
account_subtree.sort_by_key(|a| a.0.clone());
account_subtree.sort_by_key(|a| a.0);
let mut storages = hash_map_with_capacity(reth_proof.storages.len());
for (k, reth_storage_proof) in reth_proof.storages {
if !all_requested_accounts.contains(&k) {
Expand All @@ -206,9 +208,9 @@ fn convert_reth_multiproof(
let mut subtree = Vec::with_capacity(reth_storage_proof.subtree.len());

for (k, v) in reth_storage_proof.subtree.into_inner() {
subtree.push((convert_reth_nybbles_to_nibbles(k), v));
subtree.push((k, v));
}
subtree.sort_by_key(|a| a.0.clone());
subtree.sort_by_key(|a| a.0);
let v = StorageMultiProof { subtree };
storages.insert(k, v);
}
Expand Down
Loading