From 603c2df0f5c7d59a8e0ef347aca0476153cab650 Mon Sep 17 00:00:00 2001 From: Anton Puhach Date: Tue, 18 Apr 2023 13:26:40 +0200 Subject: [PATCH 1/2] impl --- chain/client/src/client_actor.rs | 3 +++ core/chain-configs/src/client_config.rs | 3 +++ core/store/src/config.rs | 6 ++++++ nearcore/src/config.rs | 1 + 4 files changed, 13 insertions(+) diff --git a/chain/client/src/client_actor.rs b/chain/client/src/client_actor.rs index 6240c621c6e..fa62f7c7cf5 100644 --- a/chain/client/src/client_actor.rs +++ b/chain/client/src/client_actor.rs @@ -1430,6 +1430,9 @@ impl ClientActor { } fn start_flat_storage_creation(&mut self, ctx: &mut Context) { + if !self.client.config.flat_storage_creation_enabled { + return; + } match self.client.run_flat_storage_creation_step() { Ok(false) => {} Ok(true) => { diff --git a/core/chain-configs/src/client_config.rs b/core/chain-configs/src/client_config.rs index 797bb43644b..440b26281b6 100644 --- a/core/chain-configs/src/client_config.rs +++ b/core/chain-configs/src/client_config.rs @@ -164,6 +164,8 @@ pub struct ClientConfig { pub enable_statistics_export: bool, /// Number of threads to execute background migration work in client. pub client_background_migration_threads: usize, + /// Enables background flat storage creation. + pub flat_storage_creation_enabled: bool, /// Duration to perform background flat storage creation step. pub flat_storage_creation_period: Duration, /// If enabled, will dump state of every epoch to external storage. @@ -251,6 +253,7 @@ impl ClientConfig { max_gas_burnt_view: None, enable_statistics_export: true, client_background_migration_threads: 1, + flat_storage_creation_enabled: true, flat_storage_creation_period: Duration::from_secs(1), state_sync_dump_enabled: false, state_sync_s3_bucket: String::new(), diff --git a/core/store/src/config.rs b/core/store/src/config.rs index a0f0671511d..1fb2216de11 100644 --- a/core/store/src/config.rs +++ b/core/store/src/config.rs @@ -85,6 +85,10 @@ pub struct StoreConfig { /// with block processing. pub background_migration_threads: usize, + + /// Enables background flat storage creation. + pub flat_storage_creation_enabled: bool, + /// Duration to perform background flat storage creation step. Defines how /// frequently we check creation status and execute work related to it in /// main thread (scheduling and collecting state parts, catching up blocks, etc.). @@ -220,6 +224,8 @@ impl Default for StoreConfig { // regular block processing significantly. background_migration_threads: 8, + flat_storage_creation_enabled: true, + // It shouldn't be very low, because on single flat storage creation step // we do several disk reads from `FlatStateMisc` and `FlatStateDeltas`. // One second should be enough to save deltas on start and catch up diff --git a/nearcore/src/config.rs b/nearcore/src/config.rs index 6c8db4cadde..7f3c8871c1a 100644 --- a/nearcore/src/config.rs +++ b/nearcore/src/config.rs @@ -676,6 +676,7 @@ impl NearConfig { max_gas_burnt_view: config.max_gas_burnt_view, enable_statistics_export: config.store.enable_statistics_export, client_background_migration_threads: config.store.background_migration_threads, + flat_storage_creation_enabled: config.store.flat_storage_creation_enabled, flat_storage_creation_period: config.store.flat_storage_creation_period, state_sync_dump_enabled: config .state_sync From 19ce17f45726c51c9f889e2dc08a312baed0f937 Mon Sep 17 00:00:00 2001 From: Anton Puhach Date: Tue, 18 Apr 2023 13:54:43 +0200 Subject: [PATCH 2/2] fmt --- core/store/src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/core/store/src/config.rs b/core/store/src/config.rs index 1fb2216de11..e1dc776b4c5 100644 --- a/core/store/src/config.rs +++ b/core/store/src/config.rs @@ -85,7 +85,6 @@ pub struct StoreConfig { /// with block processing. pub background_migration_threads: usize, - /// Enables background flat storage creation. pub flat_storage_creation_enabled: bool,