Skip to content
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

chore(trie): move trie updates to reth-trie-common #12863

Merged
merged 7 commits into from
Nov 26, 2024
Merged
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
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/engine/invalid-block-hooks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ reth-provider.workspace = true
reth-revm = { workspace = true, features = ["serde"] }
reth-rpc-api = { workspace = true, features = ["client"] }
reth-tracing.workspace = true
reth-trie = { workspace = true, features = ["serde"] }
reth-trie.workspace = true

# alloy
alloy-primitives.workspace = true
Expand Down
10 changes: 6 additions & 4 deletions crates/evm/execution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ workspace = true

[dependencies]
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-execution-errors.workspace = true
reth-trie-common.workspace = true
reth-trie.workspace = true
reth-primitives-traits.workspace = true

revm.workspace = true

Expand All @@ -36,17 +37,18 @@ default = ["std"]
optimism = ["reth-primitives/optimism", "revm/optimism"]
serde = [
"dep:serde",
"reth-trie/serde",
"rand/serde",
"revm/serde",
"alloy-eips/serde",
"alloy-primitives/serde",
"rand/serde",
"reth-primitives-traits/serde",
"reth-trie-common/serde",
"reth-trie/serde",
]
serde-bincode-compat = [
"reth-primitives/serde-bincode-compat",
"reth-primitives-traits/serde-bincode-compat",
"reth-trie/serde-bincode-compat",
"reth-trie-common/serde-bincode-compat",
"serde_with",
"alloy-eips/serde-bincode-compat",
]
Expand Down
10 changes: 4 additions & 6 deletions crates/evm/execution-types/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reth_primitives::{
TransactionSignedEcRecovered,
};
use reth_primitives_traits::NodePrimitives;
use reth_trie::updates::TrieUpdates;
use reth_trie_common::updates::TrieUpdates;
use revm::db::BundleState;

/// A chain of blocks and their final state.
Expand Down Expand Up @@ -513,16 +513,14 @@ pub enum ChainSplit<N: NodePrimitives = reth_primitives::EthPrimitives> {
/// Bincode-compatible [`Chain`] serde implementation.
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub(super) mod serde_bincode_compat {
use std::collections::BTreeMap;

use crate::ExecutionOutcome;
use alloc::borrow::Cow;
use alloy_primitives::BlockNumber;
use reth_primitives::serde_bincode_compat::SealedBlockWithSenders;
use reth_trie::serde_bincode_compat::updates::TrieUpdates;
use reth_trie_common::serde_bincode_compat::updates::TrieUpdates;
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
use serde_with::{DeserializeAs, SerializeAs};

use crate::ExecutionOutcome;
use std::collections::BTreeMap;

/// Bincode-compatible [`super::Chain`] serde implementation.
///
Expand Down
5 changes: 3 additions & 2 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ test-utils = [
"arbitrary",
]
serde-bincode-compat = [
"serde_with",
"alloy-eips/serde-bincode-compat",
"alloy-consensus/serde-bincode-compat",
"op-alloy-consensus?/serde-bincode-compat",
"reth-primitives-traits/serde-bincode-compat",
"serde_with",
"alloy-eips/serde-bincode-compat",
"reth-trie-common/serde-bincode-compat",
]

[[bench]]
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ test-utils = [
]
serde = [
"revm/serde",
"reth-trie?/serde",
"alloy-eips/serde",
"alloy-primitives/serde",
"alloy-consensus/serde",
"reth-primitives-traits/serde",
"reth-trie?/serde",
]
14 changes: 7 additions & 7 deletions crates/storage/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ optimism = [
"revm/optimism",
]
serde = [
"reth-execution-types/serde",
"reth-trie-db/serde",
"reth-trie/serde",
"alloy-consensus/serde",
"alloy-eips/serde",
"alloy-primitives/serde",
"alloy-rpc-types-engine/serde",
"dashmap/serde",
"notify/serde",
"parking_lot/serde",
"rand/serde",
"alloy-primitives/serde",
"alloy-consensus/serde",
"alloy-eips/serde",
"alloy-rpc-types-engine/serde",
"revm/serde",
"reth-codecs/serde",
"reth-optimism-primitives?/serde",
"reth-primitives-traits/serde",
"reth-execution-types/serde",
"reth-trie-db/serde",
"reth-trie/serde",
]
test-utils = [
"reth-db/test-utils",
Expand Down
9 changes: 9 additions & 0 deletions crates/trie/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ nybbles = { workspace = true, features = ["rlp"] }
# `serde` feature
serde = { workspace = true, optional = true }

# `serde-bincode-compat` feature
serde_with = { workspace = true, optional = true }

# `test-utils` feature
hash-db = { version = "=0.15.2", optional = true }
plain_hasher = { version = "0.2", optional = true }
Expand All @@ -46,6 +49,7 @@ arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-arbitrary-interop.workspace = true
criterion.workspace = true
bincode.workspace = true

[features]
serde = [
Expand All @@ -59,6 +63,11 @@ serde = [
"reth-primitives-traits/serde",
"reth-codecs/serde"
]
serde-bincode-compat = [
"serde_with",
"reth-primitives-traits/serde-bincode-compat",
"alloy-consensus/serde-bincode-compat"
]
test-utils = [
"dep:plain_hasher",
"dep:hash-db",
Expand Down
14 changes: 14 additions & 0 deletions crates/trie/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,19 @@ pub use proofs::*;

pub mod root;

/// Buffer for trie updates.
pub mod updates;

/// Bincode-compatible serde implementations for trie types.
///
/// `bincode` crate allows for more efficient serialization of trie types, because it allows
/// non-string map keys.
///
/// Read more: <https://github.com/paradigmxyz/reth/issues/11370>
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub mod serde_bincode_compat {
pub use super::updates::serde_bincode_compat as updates;
}

/// Re-export
pub use alloy_trie::{nodes::*, proof, BranchNodeCompact, HashBuilder, TrieMask, EMPTY_ROOT_HASH};
Loading
Loading