From d0f6c1ba45c6f595aa11585574cea3f0d4462d72 Mon Sep 17 00:00:00 2001 From: Artem Vorotnikov Date: Thu, 9 Jul 2020 02:55:55 +0300 Subject: [PATCH] Disable warp sync snapshotting by default --- ethcore/snapshot/src/lib.rs | 6 +++--- parity/cli/mod.rs | 12 ++++++------ parity/cli/tests/config.full.toml | 2 +- parity/cli/tests/config.toml | 2 +- parity/configuration.rs | 2 +- parity/run.rs | 28 +++++++++++++--------------- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/ethcore/snapshot/src/lib.rs b/ethcore/snapshot/src/lib.rs index b3d88d0f82d..2e1a835fb86 100644 --- a/ethcore/snapshot/src/lib.rs +++ b/ethcore/snapshot/src/lib.rs @@ -95,8 +95,8 @@ const MAX_SNAPSHOT_SUBPARTS: usize = 256; /// Configuration for the Snapshot service #[derive(Debug, Clone, PartialEq)] pub struct SnapshotConfiguration { - /// If `true`, no periodic snapshots will be created - pub no_periodic: bool, + /// Enable creation of periodic snapshots + pub enable: bool, /// Number of threads for creating snapshots pub processing_threads: usize, } @@ -104,7 +104,7 @@ pub struct SnapshotConfiguration { impl Default for SnapshotConfiguration { fn default() -> Self { SnapshotConfiguration { - no_periodic: false, + enable: false, processing_threads: ::std::cmp::max(1, num_cpus::get_physical() / 2), } } diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 6fa642deece..8f30b559f90 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -910,9 +910,9 @@ usage! { "Skip block seal check.", ["Snapshot Options"] - FLAG flag_no_periodic_snapshot: (bool) = false, or |c: &Config| c.snapshots.as_ref()?.disable_periodic.clone(), - "--no-periodic-snapshot", - "Disable automated snapshots which usually occur once every 5000 blocks.", + FLAG flag_enable_snapshotting: (bool) = false, or |c: &Config| c.snapshots.as_ref()?.enable.clone(), + "--enable-snapshotting", + "Enable automated snapshots which usually occur once every 5000 blocks.", ARG arg_snapshot_threads: (Option) = None, or |c: &Config| c.snapshots.as_ref()?.processing_threads, "--snapshot-threads=[NUM]", @@ -1396,7 +1396,7 @@ struct Footprint { #[derive(Default, Debug, PartialEq, Deserialize)] #[serde(deny_unknown_fields)] struct Snapshots { - disable_periodic: Option, + enable: Option, processing_threads: Option, } @@ -1913,7 +1913,7 @@ mod tests { // -- Snapshot Optons arg_export_state_at: "latest".into(), arg_snapshot_at: "latest".into(), - flag_no_periodic_snapshot: false, + flag_enable_snapshotting: false, arg_snapshot_threads: None, // -- Light options. @@ -2178,7 +2178,7 @@ mod tests { on_demand_request_consecutive_failures: Some(1), }), snapshots: Some(Snapshots { - disable_periodic: Some(true), + enable: Some(false), processing_threads: None, }), misc: Some(Misc { diff --git a/parity/cli/tests/config.full.toml b/parity/cli/tests/config.full.toml index f58fab3d8ad..3292881b4fe 100644 --- a/parity/cli/tests/config.full.toml +++ b/parity/cli/tests/config.full.toml @@ -160,7 +160,7 @@ on_demand_request_backoff_rounds_max = 100 on_demand_request_consecutive_failures = 1 [snapshots] -disable_periodic = false +enable = false [misc] logging = "own_tx=trace" diff --git a/parity/cli/tests/config.toml b/parity/cli/tests/config.toml index 111f09e5c2e..c95539ed63d 100644 --- a/parity/cli/tests/config.toml +++ b/parity/cli/tests/config.toml @@ -76,7 +76,7 @@ on_demand_request_backoff_rounds_max = 10 on_demand_request_consecutive_failures = 1 [snapshots] -disable_periodic = true +enable = false [misc] logging = "own_tx=trace" diff --git a/parity/configuration.rs b/parity/configuration.rs index d04265c535e..014eb813e4e 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -925,7 +925,7 @@ impl Configuration { fn snapshot_config(&self) -> Result { let mut conf = SnapshotConfiguration::default(); - conf.no_periodic = self.args.flag_no_periodic_snapshot; + conf.enable = self.args.flag_enable_snapshotting; if let Some(threads) = self.args.arg_snapshot_threads { if threads > 0 { conf.processing_threads = threads; diff --git a/parity/run.rs b/parity/run.rs index 23687d66367..71d5d8cfc56 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -800,21 +800,19 @@ fn execute_impl( }); // the watcher must be kept alive. - let watcher = match cmd.snapshot_conf.no_periodic { - true => None, - false => { - let sync = sync_provider.clone(); - let watcher = Arc::new(snapshot::Watcher::new( - service.client(), - move || sync.is_major_syncing(), - service.io().channel(), - SNAPSHOT_PERIOD, - SNAPSHOT_HISTORY, - )); - - service.add_notify(watcher.clone()); - Some(watcher) - }, + let mut watcher = None; + if cmd.snapshot_conf.enable { + let sync = sync_provider.clone(); + let w = Arc::new(snapshot::Watcher::new( + service.client(), + move || sync.is_major_syncing(), + service.io().channel(), + SNAPSHOT_PERIOD, + SNAPSHOT_HISTORY, + )); + + service.add_notify(w.clone()); + watcher = Some(w); }; client.set_exit_handler(on_client_rq);