From c4140e89efa3d0c6ef6f0f55a12b1450429967e4 Mon Sep 17 00:00:00 2001 From: Santiago Carmuega Date: Thu, 23 Jan 2025 17:52:28 -0300 Subject: [PATCH] rename config field --- docs/pages/configuration/schema.mdx | 4 ++-- src/bin/dolos/daemon.rs | 2 +- src/bin/dolos/doctor/rebuild_ledger.rs | 2 +- src/bin/dolos/main.rs | 31 +------------------------- src/bin/dolos/sync.rs | 2 +- src/model.rs | 29 ++++++++++++++++++++++++ src/state/mod.rs | 4 ++-- src/sync/apply.rs | 8 +++---- src/sync/mod.rs | 4 ++-- 9 files changed, 43 insertions(+), 43 deletions(-) diff --git a/docs/pages/configuration/schema.mdx b/docs/pages/configuration/schema.mdx index 26c8f231..07838ba3 100644 --- a/docs/pages/configuration/schema.mdx +++ b/docs/pages/configuration/schema.mdx @@ -71,13 +71,13 @@ The `storage` section controls how Dolos stores data in the local file system. T | wal_cache | integer | 50 | | ledger_cache | integer | 500 | | max_wal_history | integer | 10000 | -| max_slots_before_prune | integer | 10000 | +| max_ledger_history | integer | 10000 | - `path`: is the root directory where all data will be stored. - `wal_cache`: the size (in Mb) of the memory cache for the wal db. - `ledger_cache`: the size (in Mb) of the memory cache for the ledger db. - `max_wal_history`: the max number of slots to keep in the WAL. -- `max_slots_before_prune`: the max number of slots to keep in the ledger store before pruning +- `max_ledger_history`: the max number of slots to keep in the ledger store before pruning. If not set, the ledger will prune past the immutable slot. ## `genesis` section diff --git a/src/bin/dolos/daemon.rs b/src/bin/dolos/daemon.rs index 257caeae..3971eecf 100644 --- a/src/bin/dolos/daemon.rs +++ b/src/bin/dolos/daemon.rs @@ -16,6 +16,7 @@ pub async fn run(config: super::Config, _args: &Args) -> miette::Result<()> { let sync = dolos::sync::pipeline( &config.sync, &config.upstream, + &config.storage, wal.clone(), ledger.clone(), byron, @@ -23,7 +24,6 @@ pub async fn run(config: super::Config, _args: &Args) -> miette::Result<()> { mempool.clone(), &config.retries, false, - config.storage.max_slots_before_prune, ) .into_diagnostic() .context("bootstrapping sync pipeline")?; diff --git a/src/bin/dolos/doctor/rebuild_ledger.rs b/src/bin/dolos/doctor/rebuild_ledger.rs index 1f67d5f7..8df175c7 100644 --- a/src/bin/dolos/doctor/rebuild_ledger.rs +++ b/src/bin/dolos/doctor/rebuild_ledger.rs @@ -86,7 +86,7 @@ pub fn run(config: &crate::Config, _args: &Args, feedback: &Feedback) -> miette: &mut light, &byron, &shelley, - config.storage.max_slots_before_prune, + config.storage.max_ledger_history, ) .into_diagnostic() .context("importing blocks to ledger store")?; diff --git a/src/bin/dolos/main.rs b/src/bin/dolos/main.rs index 5ebe1dc8..23020dae 100644 --- a/src/bin/dolos/main.rs +++ b/src/bin/dolos/main.rs @@ -63,35 +63,6 @@ struct Cli { config: Option, } -#[derive(Serialize, Deserialize)] -pub struct StorageConfig { - path: std::path::PathBuf, - - /// Size (in Mb) of memory allocated for WAL caching - wal_cache: Option, - - /// Size (in Mb) of memory allocated for ledger caching - ledger_cache: Option, - - /// Maximum number of slots (not blocks) to keep in the WAL - max_wal_history: Option, - - /// Maximum number of slots to keep in the ledger before pruning - max_slots_before_prune: Option, -} - -impl Default for StorageConfig { - fn default() -> Self { - Self { - path: PathBuf::from("data"), - wal_cache: None, - ledger_cache: None, - max_wal_history: None, - max_slots_before_prune: None, - } - } -} - #[derive(Serialize, Deserialize)] pub struct GenesisConfig { byron_path: PathBuf, @@ -154,7 +125,7 @@ impl Default for LoggingConfig { #[derive(Serialize, Deserialize)] pub struct Config { pub upstream: dolos::model::UpstreamConfig, - pub storage: StorageConfig, + pub storage: dolos::model::StorageConfig, pub genesis: GenesisConfig, pub sync: dolos::sync::Config, pub submit: dolos::model::SubmitConfig, diff --git a/src/bin/dolos/sync.rs b/src/bin/dolos/sync.rs index 24e4b63d..6138d31d 100644 --- a/src/bin/dolos/sync.rs +++ b/src/bin/dolos/sync.rs @@ -19,6 +19,7 @@ pub fn run(config: &super::Config, args: &Args) -> miette::Result<()> { let sync = dolos::sync::pipeline( &config.sync, &config.upstream, + &config.storage, wal, ledger, byron, @@ -26,7 +27,6 @@ pub fn run(config: &super::Config, args: &Args) -> miette::Result<()> { mempool, &config.retries, args.quit_on_tip, - config.storage.max_slots_before_prune, ) .into_diagnostic() .context("bootstrapping sync pipeline")?; diff --git a/src/model.rs b/src/model.rs index ef0a5c4e..a14d1bfa 100644 --- a/src/model.rs +++ b/src/model.rs @@ -42,3 +42,32 @@ pub struct UpstreamConfig { pub struct SubmitConfig { pub prune_height: Option, } + +#[derive(Serialize, Deserialize)] +pub struct StorageConfig { + pub path: std::path::PathBuf, + + /// Size (in Mb) of memory allocated for WAL caching + pub wal_cache: Option, + + /// Size (in Mb) of memory allocated for ledger caching + pub ledger_cache: Option, + + /// Maximum number of slots (not blocks) to keep in the WAL + pub max_wal_history: Option, + + /// Maximum number of slots to keep in the ledger before pruning + pub max_ledger_history: Option, +} + +impl Default for StorageConfig { + fn default() -> Self { + Self { + path: std::path::PathBuf::from("data"), + wal_cache: None, + ledger_cache: None, + max_wal_history: None, + max_ledger_history: None, + } + } +} diff --git a/src/state/mod.rs b/src/state/mod.rs index 4d95757f..f9cabaab 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -220,7 +220,7 @@ pub fn apply_block_batch<'a>( store: &mut LedgerStore, byron: &byron::GenesisFile, shelley: &shelley::GenesisFile, - max_slots_before_prune: Option, + max_ledger_history: Option, ) -> Result<(), LedgerError> { let mut deltas: Vec = vec![]; @@ -239,7 +239,7 @@ pub fn apply_block_batch<'a>( .map(|x| x.0) .unwrap(); - let to_finalize = max_slots_before_prune + let to_finalize = max_ledger_history .map(|x| tip - x) .unwrap_or(lastest_immutable_slot(tip, byron, shelley)); diff --git a/src/sync/apply.rs b/src/sync/apply.rs index d41a61db..b45dfe23 100644 --- a/src/sync/apply.rs +++ b/src/sync/apply.rs @@ -17,7 +17,7 @@ pub struct Stage { shelley: shelley::GenesisFile, mempool: crate::mempool::Mempool, // Add this line - max_slots_before_prune: Option, + max_ledger_history: Option, pub upstream: UpstreamPort, @@ -35,7 +35,7 @@ impl Stage { mempool: crate::mempool::Mempool, byron: byron::GenesisFile, shelley: shelley::GenesisFile, - max_slots_before_prune: Option, + max_ledger_history: Option, ) -> Self { Self { wal, @@ -43,10 +43,10 @@ impl Stage { mempool, byron, shelley, + max_ledger_history, upstream: Default::default(), block_count: Default::default(), wal_count: Default::default(), - max_slots_before_prune, } } @@ -87,7 +87,7 @@ impl Stage { &mut self.ledger, &self.byron, &self.shelley, - self.max_slots_before_prune, + self.max_ledger_history, ) .or_panic()?; diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 49190f12..9ce1901d 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -47,6 +47,7 @@ fn define_gasket_policy(config: &Option) -> gasket::run pub fn pipeline( config: &Config, upstream: &UpstreamConfig, + storage: &StorageConfig, wal: WalStore, ledger: LedgerStore, byron: byron::GenesisFile, @@ -54,7 +55,6 @@ pub fn pipeline( mempool: Mempool, retries: &Option, quit_on_tip: bool, - max_slots_before_prune: Option, ) -> Result, Error> { let mut pull = pull::Stage::new( upstream.peer_address.clone(), @@ -72,7 +72,7 @@ pub fn pipeline( mempool.clone(), byron, shelley, - max_slots_before_prune, + storage.max_ledger_history, ); let submit = submit::Stage::new(