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: make cargo t compile for reth-trie-common #12884

Merged
merged 3 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
13 changes: 8 additions & 5 deletions crates/trie/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ 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
Expand All @@ -40,16 +39,19 @@ plain_hasher = { version = "0.2", optional = true }
arbitrary = { workspace = true, features = ["derive"], optional = true }

[dev-dependencies]
reth-primitives-traits = { workspace = true, features = ["serde"] }
alloy-primitives = { workspace = true, features = ["getrandom"] }
alloy-trie = { workspace = true, features = ["arbitrary"] }
alloy-trie = { workspace = true, features = ["arbitrary", "serde"] }
hash-db = "=0.15.2"
plain_hasher = "0.2"
serde_json.workspace = true
arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-arbitrary-interop.workspace = true
criterion.workspace = true
bincode.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_with.workspace = true

[features]
serde = [
Expand All @@ -64,9 +66,10 @@ serde = [
"reth-codecs/serde"
]
serde-bincode-compat = [
"serde_with",
"serde",
"reth-primitives-traits/serde-bincode-compat",
"alloy-consensus/serde-bincode-compat"
"alloy-consensus/serde-bincode-compat",
"dep:serde_with"
]
test-utils = [
"dep:plain_hasher",
Expand Down
2 changes: 1 addition & 1 deletion crates/trie/common/src/hash_builder/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reth_codecs::Compact;
/// The hash builder state for storing in the database.
/// Check the `reth-trie` crate for more info on hash builder.
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "arbitrary",
derive(arbitrary::Arbitrary),
Expand Down
4 changes: 2 additions & 2 deletions crates/trie/common/src/nibbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use nybbles::Nibbles;

/// The representation of nibbles of the merkle trie stored in the database.
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, derive_more::Index)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "test-utils", derive(arbitrary::Arbitrary))]
pub struct StoredNibbles(pub Nibbles);

Expand Down Expand Up @@ -63,7 +63,7 @@ impl Compact for StoredNibbles {

/// The representation of nibbles of the merkle trie stored in the database.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deref)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "test-utils", derive(arbitrary::Arbitrary))]
pub struct StoredNibblesSubKey(pub Nibbles);

Expand Down
6 changes: 3 additions & 3 deletions crates/trie/common/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ impl StorageMultiProof {

/// The merkle proof with the relevant account info.
#[derive(Clone, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), serde(rename_all = "camelCase"))]
pub struct AccountProof {
/// The address associated with the account.
pub address: Address,
Expand Down Expand Up @@ -228,7 +228,7 @@ impl AccountProof {

/// The merkle proof of the storage entry.
#[derive(Clone, PartialEq, Eq, Default, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
pub struct StorageProof {
/// The raw storage key.
pub key: B256,
Expand Down
2 changes: 1 addition & 1 deletion crates/trie/common/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use reth_codecs::Compact;

/// Account storage trie node.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
pub struct StorageTrieEntry {
/// The nibbles of the intermediate node
pub nibbles: StoredNibblesSubKey,
Expand Down
18 changes: 9 additions & 9 deletions crates/trie/common/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use std::collections::{HashMap, HashSet};

/// The aggregation of trie updates.
#[derive(PartialEq, Eq, Clone, Default, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
pub struct TrieUpdates {
/// Collection of updated intermediate account nodes indexed by full path.
#[cfg_attr(feature = "serde", serde(with = "serde_nibbles_map"))]
#[cfg_attr(any(test, feature = "serde"), serde(with = "serde_nibbles_map"))]
pub account_nodes: HashMap<Nibbles, BranchNodeCompact>,
/// Collection of removed intermediate account nodes indexed by full path.
#[cfg_attr(feature = "serde", serde(with = "serde_nibbles_set"))]
#[cfg_attr(any(test, feature = "serde"), serde(with = "serde_nibbles_set"))]
pub removed_nodes: HashSet<Nibbles>,
/// Collection of updated storage tries indexed by the hashed address.
pub storage_tries: HashMap<B256, StorageTrieUpdates>,
Expand Down Expand Up @@ -112,15 +112,15 @@ impl TrieUpdates {

/// Trie updates for storage trie of a single account.
#[derive(PartialEq, Eq, Clone, Default, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
pub struct StorageTrieUpdates {
/// Flag indicating whether the trie was deleted.
pub is_deleted: bool,
/// Collection of updated storage trie nodes.
#[cfg_attr(feature = "serde", serde(with = "serde_nibbles_map"))]
#[cfg_attr(any(test, feature = "serde"), serde(with = "serde_nibbles_map"))]
pub storage_nodes: HashMap<Nibbles, BranchNodeCompact>,
/// Collection of removed storage trie nodes.
#[cfg_attr(feature = "serde", serde(with = "serde_nibbles_set"))]
#[cfg_attr(any(test, feature = "serde"), serde(with = "serde_nibbles_set"))]
pub removed_nodes: HashSet<Nibbles>,
}

Expand Down Expand Up @@ -225,7 +225,7 @@ impl StorageTrieUpdates {
/// hex-encoded packed representation.
///
/// This also sorts the set before serializing.
#[cfg(feature = "serde")]
#[cfg(any(test, feature = "serde"))]
mod serde_nibbles_set {
use crate::Nibbles;
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
Expand Down Expand Up @@ -261,7 +261,7 @@ mod serde_nibbles_set {
/// hex-encoded packed representation.
///
/// This also sorts the map's keys before encoding and serializing.
#[cfg(feature = "serde")]
#[cfg(any(test, feature = "serde"))]
mod serde_nibbles_map {
use crate::Nibbles;
use alloy_primitives::hex;
Expand Down Expand Up @@ -403,7 +403,7 @@ fn exclude_empty_from_pair<V>(
}

/// Bincode-compatible trie updates type serde implementations.
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
#[cfg(feature = "serde-bincode-compat")]
pub mod serde_bincode_compat {
use crate::{BranchNodeCompact, Nibbles};
use alloy_primitives::B256;
Expand Down
Loading