Skip to content

Support for Fusaka #666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
3,588 changes: 1,949 additions & 1,639 deletions Cargo.lock

Large diffs are not rendered by default.

186 changes: 114 additions & 72 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,94 +49,90 @@ codegen-units = 1
incremental = false

[workspace.dependencies]
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-trie = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-trie-parallel = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8", features = [
reth = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-db = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-db-common = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-trie = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-trie-parallel = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-node-core = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3", features = [
"test-utils",
] }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-execution-errors = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-metrics = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-payload-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-execution-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-revm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-payload-builder-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-payload-util = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-testing-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-execution-errors = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-exex = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-metrics = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-payload-primitives = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-execution-types = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-revm = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-payload-builder-primitives = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-payload-util = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-testing-utils = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }

# reth optimism
reth-optimism-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-consensus = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-cli = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-forks = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-node = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-txpool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.8" }
reth-optimism-primitives = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-consensus = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-cli = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-forks = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-evm = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-node = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-payload-builder = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-chainspec = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }
reth-optimism-txpool = { git = "https://github.com/paradigmxyz/reth", branch = "fusaka-devnet-3" }


# compatible with reth v1.4.8 dependencies
revm = { version = "24.0.1", features = [
revm = { version = "27.0.1", features = [
"std",
"secp256k1",
"optional_balance_check",
], default-features = false }
revm-inspectors = { version = "0.23.0", default-features = false }
op-revm = { version = "5.0.0", default-features = false }
revm-inspectors = { version = "0.26.5", default-features = false }
revm-state = { version = "7.0.0", default-features = false }
revm-inspector = { version = "8.0.1", default-features = false }

ethereum_ssz_derive = "0.9.0"
ethereum_ssz = "0.9.0"

alloy-primitives = { version = "1.1.0", default-features = false }
alloy-primitives = { version = "1.2.0", default-features = false }
alloy-rlp = "0.3.10"
alloy-chains = "0.2.0"
alloy-evm = { version = "0.10", default-features = false }
alloy-provider = { version = "1.0.9", features = ["ipc", "pubsub"] }
alloy-pubsub = { version = "1.0.9" }
alloy-eips = { version = "1.0.9" }
alloy-rpc-types = { version = "1.0.9" }
alloy-json-rpc = { version = "1.0.9" }
alloy-transport-http = { version = "1.0.9" }
alloy-network = { version = "1.0.9" }
alloy-network-primitives = { version = "1.0.9" }
alloy-transport = { version = "1.0.9" }
alloy-node-bindings = { version = "1.0.9" }
alloy-consensus = { version = "1.0.9", features = ["kzg"] }
alloy-serde = { version = "1.0.9" }
alloy-rpc-types-beacon = { version = "1.0.9", features = ["ssz"] }
alloy-rpc-types-engine = { version = "1.0.9", features = ["ssz"] }
alloy-rpc-types-eth = { version = "1.0.9" }
alloy-signer-local = { version = "1.0.9" }
alloy-rpc-client = { version = "1.0.9" }
alloy-genesis = { version = "1.0.9" }
alloy-trie = { version = "0.8.1" }

# optimism
alloy-op-evm = { version = "0.5.0", default-features = false }
op-alloy-rpc-types = { version = "0.14.1", default-features = false }
op-alloy-rpc-types-engine = { version = "0.14.1", default-features = false }
op-alloy-rpc-jsonrpsee = { version = "0.14.1", default-features = false }
op-alloy-network = { version = "0.14.1", default-features = false }
op-alloy-consensus = { version = "0.14.1", default-features = false }
alloy-evm = { version = "0.15", default-features = false }
alloy-provider = { version = "1.0.16", features = ["ipc", "pubsub"] }
alloy-pubsub = { version = "1.0.16" }
alloy-eips = { version = "1.0.16" }
alloy-rpc-types = { version = "1.0.16" }
alloy-json-rpc = { version = "1.0.16" }
alloy-transport-http = { version = "1.0.16" }
alloy-network = { version = "1.0.16" }
alloy-network-primitives = { version = "1.0.16" }
alloy-transport = { version = "1.0.16" }
alloy-node-bindings = { version = "1.0.16" }
alloy-consensus = { version = "1.0.16" , features = ["kzg"] }
alloy-serde = { version = "1.0.16" }
alloy-rpc-types-beacon = { version = "1.0.16" , features = ["ssz"] }
alloy-rpc-types-engine = { version = "1.0.16" , features = ["ssz"] }
alloy-rpc-types-eth = { version = "1.0.16" }
alloy-signer-local = { version = "1.0.16" }
alloy-rpc-client = { version = "1.0.16" }
alloy-genesis = { version = "1.0.16" }
alloy-trie = { version = "0.8.1", default-features = false }
nybbles = { version = "0.3.3" }

async-trait = { version = "0.1.83" }
clap = { version = "4.4.3", features = ["derive", "env"] }
Expand Down Expand Up @@ -174,3 +170,49 @@ eth-sparse-mpt = { path = "crates/eth-sparse-mpt" }
rbuilder = { path = "crates/rbuilder" }
sysperf = { path = "crates/sysperf" }
metrics_macros = { path = "crates/rbuilder/src/telemetry/metrics_macros"}


[patch.crates-io]
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-contract = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-admin = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-debug = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-mev = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-rpc-types-txpool = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-serde = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", branch = "fusaka-devnet-3" }

alloy-eip2124 = { git = "https://github.com/alloy-rs/eips", branch = "rkrasiuk/fork-hash-from-bytes-arr" }

revm = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-bytecode = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-database = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-state = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-handler = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-inspector = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-context = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-context-interface = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-database-interface = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
op-revm = { git = "https://github.com/bluealloy/revm", branch = "fusaka-devnet-3" }
2 changes: 2 additions & 0 deletions crates/eth-sparse-mpt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ smallvec = "1.13.2"

tracing.workspace = true

nybbles.workspace = true

# reth
reth-errors.workspace = true
reth-execution-errors.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/eth-sparse-mpt/benches/trie_do_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use eth_sparse_mpt::{
v1::sparse_mpt::{DiffTrie, FixedTrie},
v2::trie::{proof_store::ProofStore, Trie},
};
use reth_trie::Nibbles;
use nybbles::Nibbles;

fn prepare_key_value_data(n: usize) -> (Vec<Bytes>, Vec<Bytes>) {
let mut keys = Vec::with_capacity(n);
Expand Down
21 changes: 17 additions & 4 deletions crates/eth-sparse-mpt/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use std::hash::{Hash, Hasher};

use alloy_primitives::{keccak256, Bytes};
use alloy_rlp::{length_of_length, BufMut, Encodable, Header, EMPTY_STRING_CODE};
use alloy_trie::{
nodes::{ExtensionNodeRef, LeafNodeRef},
Nibbles,
};
use alloy_trie::nodes::{ExtensionNodeRef, LeafNodeRef};
use nybbles::Nibbles;
use reth_trie::RlpNode;
use rustc_hash::{FxBuildHasher, FxHasher};

Expand Down Expand Up @@ -138,3 +136,18 @@ fn mismatch_chunks<const N: usize>(xs: &[u8], ys: &[u8]) -> usize {
.take_while(|(x, y)| x == y)
.count()
}

// rbuilder uses nybbles v3.3.0 and reth_trie uses nybbles v4.1.0. This is a temporary fix to convert between the two.
// We can remove the below methods once rbuilder has been upgraded to nybbles v4.1.0.
// nybbles v4.1.0 has a breaking change in the API which breaks a lot of parts of the eth sparse trie code.
pub fn convert_reth_nybbles_to_nibbles(n: reth_trie::Nibbles) -> Nibbles {
let mut nibbles = Nibbles::new();
nibbles.extend_from_slice_unchecked(n.to_vec().as_slice());
nibbles
}

pub fn convert_nibbles_to_reth_nybbles(n: Nibbles) -> reth_trie::Nibbles {
let mut nibbles = reth_trie::Nibbles::new();
nibbles.extend_from_slice(n.pack().as_slice());
nibbles
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use alloy_primitives::Bytes;
use alloy_primitives::B256;
use alloy_trie::Nibbles;
use nybbles::Nibbles;

/// SparseTrieSharedCache is a storage for fetched parts of the ethereum tries
/// It should be created once for each parent block and can be shared with a different threads.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::time::Instant;

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

use alloy_primitives::{Bytes, B256};
use alloy_trie::Nibbles;
use nybbles::Nibbles;
use rayon::prelude::*;
use reth_errors::ProviderError;
use reth_execution_errors::trie::StateProofError;
Expand Down Expand Up @@ -194,7 +194,7 @@ 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((k, v));
account_subtree.push((convert_reth_nybbles_to_nibbles(k), v));
}
account_subtree.sort_by_key(|a| a.0.clone());
let mut storages = hash_map_with_capacity(reth_proof.storages.len());
Expand All @@ -208,7 +208,7 @@ 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((k, v));
subtree.push((convert_reth_nybbles_to_nibbles(k), v));
}
subtree.sort_by_key(|a| a.0.clone());
let v = StorageMultiProof { subtree };
Expand Down
2 changes: 1 addition & 1 deletion crates/eth-sparse-mpt/src/v1/sparse_mpt/diff_trie/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::utils::{extract_prefix_and_suffix, rlp_pointer, strip_first_nibble_mut, HashMap};
use alloy_primitives::{keccak256, Bytes, B256};
use nybbles::Nibbles;
use parking_lot::Mutex;
use reth_trie::Nibbles;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Seq};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::utils::{
encode_len_extension, encode_len_leaf, encode_null_node, rlp_pointer,
};
use alloy_primitives::Bytes;
use reth_trie::Nibbles;
use nybbles::Nibbles;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion crates/eth-sparse-mpt/src/v1/sparse_mpt/fixed_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloy_trie::nodes::{
BranchNode as AlloyBranchNode, ExtensionNode as AlloyExtensionNode, LeafNode as AlloyLeafNode,
TrieNode as AlloyTrieNode,
};
use reth_trie::Nibbles;
use nybbles::Nibbles;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Seq};
use smallvec::SmallVec;
Expand Down
Loading