mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(bin, snapshot): SnapshotSegment, headers segment & refactors (#4979)
This commit is contained in:
@ -38,6 +38,7 @@ tokio-stream.workspace = true
|
||||
# misc
|
||||
bytes.workspace = true
|
||||
byteorder = "1"
|
||||
clap = { workspace = true, features = ["derive"], optional = true }
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde_with = "3.3.0"
|
||||
@ -95,6 +96,7 @@ test-utils = ["dep:plain_hasher", "dep:hash-db", "dep:ethers-core"]
|
||||
# value-256 controls whether transaction Value fields are DB-encoded as 256 bits instead of the
|
||||
# default of 128 bits.
|
||||
value-256 = ["reth-codecs/value-256"]
|
||||
clap = ["dep:clap"]
|
||||
|
||||
[[bench]]
|
||||
name = "recover_ecdsa_crit"
|
||||
|
||||
@ -35,20 +35,19 @@ pub mod listener;
|
||||
mod log;
|
||||
mod net;
|
||||
mod peer;
|
||||
mod precaution;
|
||||
pub mod proofs;
|
||||
mod prune;
|
||||
mod receipt;
|
||||
pub mod serde_helper;
|
||||
pub mod snapshot;
|
||||
pub mod stage;
|
||||
mod storage;
|
||||
|
||||
/// Helpers for working with transactions
|
||||
mod transaction;
|
||||
pub mod trie;
|
||||
mod withdrawal;
|
||||
|
||||
mod precaution;
|
||||
|
||||
pub use account::{Account, Bytecode};
|
||||
pub use block::{
|
||||
Block, BlockBody, BlockBodyRoots, BlockHashOrNumber, BlockId, BlockNumHash, BlockNumberOrTag,
|
||||
@ -83,6 +82,7 @@ pub use prune::{
|
||||
};
|
||||
pub use receipt::{Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts};
|
||||
pub use serde_helper::JsonU256;
|
||||
pub use snapshot::SnapshotSegment;
|
||||
pub use storage::StorageEntry;
|
||||
pub use transaction::{
|
||||
util::secp256k1::{public_key_to_address, recover_signer, sign_message},
|
||||
|
||||
11
crates/primitives/src/snapshot/compression.rs
Normal file
11
crates/primitives/src/snapshot/compression.rs
Normal file
@ -0,0 +1,11 @@
|
||||
#[derive(Debug, Copy, Clone, Default)]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
#[allow(missing_docs)]
|
||||
/// Snapshot compression
|
||||
pub enum Compression {
|
||||
Lz4,
|
||||
Zstd,
|
||||
ZstdWithDictionary,
|
||||
#[default]
|
||||
Uncompressed,
|
||||
}
|
||||
33
crates/primitives/src/snapshot/filters.rs
Normal file
33
crates/primitives/src/snapshot/filters.rs
Normal file
@ -0,0 +1,33 @@
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
/// Snapshot filters.
|
||||
pub enum Filters {
|
||||
/// Snapshot uses filters with [InclusionFilter] and [PerfectHashingFunction].
|
||||
WithFilters(InclusionFilter, PerfectHashingFunction),
|
||||
/// Snapshot doesn't use any filters.
|
||||
WithoutFilters,
|
||||
}
|
||||
|
||||
impl Filters {
|
||||
/// Returns `true` if snapshot uses filters.
|
||||
pub const fn has_filters(&self) -> bool {
|
||||
matches!(self, Self::WithFilters(_, _))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
/// Snapshot inclusion filter. Also see [Filters].
|
||||
pub enum InclusionFilter {
|
||||
/// Cuckoo filter
|
||||
Cuckoo,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
/// Snapshot perfect hashing function. Also see [Filters].
|
||||
pub enum PerfectHashingFunction {
|
||||
/// Fingerprint-Based Minimal Perfect Hash Function
|
||||
Fmph,
|
||||
/// Fingerprint-Based Minimal Perfect Hash Function with Group Optimization
|
||||
GoFmph,
|
||||
}
|
||||
9
crates/primitives/src/snapshot/mod.rs
Normal file
9
crates/primitives/src/snapshot/mod.rs
Normal file
@ -0,0 +1,9 @@
|
||||
//! Snapshot primitives.
|
||||
|
||||
mod compression;
|
||||
mod filters;
|
||||
mod segment;
|
||||
|
||||
pub use compression::Compression;
|
||||
pub use filters::{Filters, InclusionFilter, PerfectHashingFunction};
|
||||
pub use segment::SnapshotSegment;
|
||||
13
crates/primitives/src/snapshot/segment.rs
Normal file
13
crates/primitives/src/snapshot/segment.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
/// Segment of the data that can be snapshotted.
|
||||
pub enum SnapshotSegment {
|
||||
/// Snapshot segment responsible for the `CanonicalHeaders`, `Headers`, `HeaderTD` tables.
|
||||
Headers,
|
||||
/// Snapshot segment responsible for the `Transactions` table.
|
||||
Transactions,
|
||||
/// Snapshot segment responsible for the `Receipts` table.
|
||||
Receipts,
|
||||
}
|
||||
Reference in New Issue
Block a user