mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(trie): introduce serde feature on reth-trie-common (#12864)
This commit is contained in:
@ -12,21 +12,24 @@ description = "Commonly used types for trie usage in reth."
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
reth-primitives-traits = { workspace = true, features = ["serde"] }
|
||||
reth-codecs.workspace = true
|
||||
|
||||
# alloy
|
||||
alloy-primitives.workspace = true
|
||||
alloy-rlp = { workspace = true, features = ["arrayvec"] }
|
||||
alloy-trie = { workspace = true, features = ["serde"] }
|
||||
alloy-trie.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
alloy-genesis.workspace = true
|
||||
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-codecs.workspace = true
|
||||
revm-primitives.workspace = true
|
||||
|
||||
bytes.workspace = true
|
||||
derive_more.workspace = true
|
||||
serde.workspace = true
|
||||
itertools.workspace = true
|
||||
nybbles = { workspace = true, features = ["serde", "rlp"] }
|
||||
nybbles = { workspace = true, features = ["rlp"] }
|
||||
|
||||
# `serde` feature
|
||||
serde = { workspace = true, optional = true }
|
||||
|
||||
# `test-utils` feature
|
||||
hash-db = { version = "=0.15.2", optional = true }
|
||||
@ -45,6 +48,17 @@ proptest-arbitrary-interop.workspace = true
|
||||
criterion.workspace = true
|
||||
|
||||
[features]
|
||||
serde = [
|
||||
"dep:serde",
|
||||
"bytes/serde",
|
||||
"nybbles/serde",
|
||||
"alloy-primitives/serde",
|
||||
"alloy-consensus/serde",
|
||||
"alloy-trie/serde",
|
||||
"revm-primitives/serde",
|
||||
"reth-primitives-traits/serde",
|
||||
"reth-codecs/serde"
|
||||
]
|
||||
test-utils = [
|
||||
"dep:plain_hasher",
|
||||
"dep:hash-db",
|
||||
|
||||
@ -3,11 +3,11 @@ use alloy_trie::{hash_builder::HashBuilderValue, nodes::RlpNode, HashBuilder};
|
||||
use bytes::Buf;
|
||||
use nybbles::Nibbles;
|
||||
use reth_codecs::Compact;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// 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, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(
|
||||
feature = "arbitrary",
|
||||
derive(arbitrary::Arbitrary),
|
||||
|
||||
@ -1,24 +1,12 @@
|
||||
use bytes::Buf;
|
||||
use derive_more::Deref;
|
||||
use reth_codecs::Compact;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
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,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
derive_more::Index,
|
||||
)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, derive_more::Index)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "test-utils", derive(arbitrary::Arbitrary))]
|
||||
pub struct StoredNibbles(pub Nibbles);
|
||||
|
||||
@ -74,7 +62,8 @@ impl Compact for StoredNibbles {
|
||||
}
|
||||
|
||||
/// The representation of nibbles of the merkle trie stored in the database.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Ord, Hash, Deref)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deref)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "test-utils", derive(arbitrary::Arbitrary))]
|
||||
pub struct StoredNibblesSubKey(pub Nibbles);
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ use alloy_trie::{
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use reth_primitives_traits::Account;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{hash_map, HashMap};
|
||||
|
||||
/// The state multiproof of target accounts and multiproofs of their storage tries.
|
||||
@ -171,8 +170,9 @@ impl StorageMultiProof {
|
||||
}
|
||||
|
||||
/// The merkle proof with the relevant account info.
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
|
||||
pub struct AccountProof {
|
||||
/// The address associated with the account.
|
||||
pub address: Address,
|
||||
@ -227,7 +227,8 @@ impl AccountProof {
|
||||
}
|
||||
|
||||
/// The merkle proof of the storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Default, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, PartialEq, Eq, Default, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct StorageProof {
|
||||
/// The raw storage key.
|
||||
pub key: B256,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
use super::{BranchNodeCompact, StoredNibblesSubKey};
|
||||
use reth_codecs::Compact;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Account storage trie node.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Ord)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct StorageTrieEntry {
|
||||
/// The nibbles of the intermediate node
|
||||
pub nibbles: StoredNibblesSubKey,
|
||||
|
||||
Reference in New Issue
Block a user