feat(stages, storage): pruning configuration (#3341)

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
Alexey Shekhirin
2023-06-29 16:04:43 +01:00
committed by GitHub
parent ee322769c9
commit d3465e2e32
12 changed files with 210 additions and 32 deletions

View File

@ -10,17 +10,19 @@ repository.workspace = true
[dependencies]
# reth
reth-network = { path = "../net/network" }
reth-net-nat = { path = "../../crates/net/nat" }
reth-discv4 = { path = "../../crates/net/discv4" }
reth-downloaders = { path = "../../crates/net/downloaders" }
reth-net-nat = { path = "../net/nat" }
reth-discv4 = { path = "../net/discv4" }
reth-downloaders = { path = "../net/downloaders" }
reth-stages = { path = "../../crates/stages" }
reth-primitives = { path = "../primitives" }
# io
serde = { workspace = true }
serde_json = { workspace = true }
#crypto
# crypto
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
confy = "0.5"
tempfile = "3.4"
tempfile = "3.4"

View File

@ -5,6 +5,7 @@ use reth_downloaders::{
headers::reverse_headers::ReverseHeadersDownloaderBuilder,
};
use reth_network::{NetworkConfigBuilder, PeersConfig, SessionsConfig};
use reth_primitives::PruneMode;
use secp256k1::SecretKey;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
@ -16,6 +17,9 @@ pub struct Config {
/// Configuration for each stage in the pipeline.
// TODO(onbjerg): Can we make this easier to maintain when we add/remove stages?
pub stages: StageConfig,
/// Configuration for pruning.
#[serde(skip_serializing_if = "Option::is_none")]
pub prune: Option<PruneConfig>,
/// Configuration for the discovery service.
pub peers: PeersConfig,
/// Configuration for peer sessions.
@ -276,6 +280,43 @@ impl Default for IndexHistoryConfig {
}
}
/// Pruning configuration.
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Serialize)]
#[serde(default)]
pub struct PruneConfig {
/// Minimum pruning interval measured in blocks.
pub block_interval: u64,
/// Pruning configuration for every part of the data that can be pruned.
pub parts: PruneParts,
}
impl Default for PruneConfig {
fn default() -> Self {
Self { block_interval: 10, parts: PruneParts::default() }
}
}
/// Pruning configuration for every part of the data that can be pruned.
#[derive(Debug, Clone, Default, Copy, Deserialize, PartialEq, Serialize)]
#[serde(default)]
pub struct PruneParts {
/// Sender Recovery pruning configuration.
#[serde(skip_serializing_if = "Option::is_none")]
pub sender_recovery: Option<PruneMode>,
/// Transaction Lookup pruning configuration.
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_lookup: Option<PruneMode>,
/// Receipts pruning configuration.
#[serde(skip_serializing_if = "Option::is_none")]
pub receipts: Option<PruneMode>,
/// Account History pruning configuration.
#[serde(skip_serializing_if = "Option::is_none")]
pub account_history: Option<PruneMode>,
/// Storage History pruning configuration.
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_history: Option<PruneMode>,
}
#[cfg(test)]
mod tests {
use super::Config;