From 02fefde3097429b0fb0c1b7692167075c6deedf1 Mon Sep 17 00:00:00 2001 From: Zhe Wu Date: Fri, 24 May 2024 16:40:29 -0700 Subject: [PATCH] Fix no-op pruner setting (#17928) ## Description Describe the changes or additions included in this PR. ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: --- crates/sui-config/src/node.rs | 2 +- crates/sui-core/src/authority.rs | 2 +- .../sui-core/src/authority/authority_store_pruner.rs | 4 ++-- crates/sui-core/src/db_checkpoint_handler.rs | 2 +- crates/sui-node/src/lib.rs | 11 ++++++----- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/sui-config/src/node.rs b/crates/sui-config/src/node.rs index 2959c8684224d..2ff96097f693f 100644 --- a/crates/sui-config/src/node.rs +++ b/crates/sui-config/src/node.rs @@ -564,7 +564,7 @@ impl Default for CheckpointExecutorConfig { } } -#[derive(Debug, Clone, Copy, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct AuthorityStorePruningConfig { /// number of the latest epoch dbs to retain diff --git a/crates/sui-core/src/authority.rs b/crates/sui-core/src/authority.rs index 435c78766f8ea..8ff3c85e01958 100644 --- a/crates/sui-core/src/authority.rs +++ b/crates/sui-core/src/authority.rs @@ -2599,7 +2599,7 @@ impl AuthorityState { store.perpetual_tables.clone(), checkpoint_store.clone(), store.objects_lock_table.clone(), - config.authority_store_pruning_config, + config.authority_store_pruning_config.clone(), epoch_store.committee().authority_exists(&name), epoch_store.epoch_start_state().epoch_duration_ms(), prometheus_registry, diff --git a/crates/sui-core/src/authority/authority_store_pruner.rs b/crates/sui-core/src/authority/authority_store_pruner.rs index eb301df701577..6e6ce3f5a5053 100644 --- a/crates/sui-core/src/authority/authority_store_pruner.rs +++ b/crates/sui-core/src/authority/authority_store_pruner.rs @@ -670,12 +670,12 @@ impl AuthorityStorePruner { loop { tokio::select! { _ = objects_prune_interval.tick(), if config.num_epochs_to_retain != u64::MAX => { - if let Err(err) = Self::prune_objects_for_eligible_epochs(&perpetual_db, &checkpoint_store, &objects_lock_table, config, metrics.clone(), indirect_objects_threshold, epoch_duration_ms).await { + if let Err(err) = Self::prune_objects_for_eligible_epochs(&perpetual_db, &checkpoint_store, &objects_lock_table, config.clone(), metrics.clone(), indirect_objects_threshold, epoch_duration_ms).await { error!("Failed to prune objects: {:?}", err); } }, _ = checkpoints_prune_interval.tick(), if !matches!(config.num_epochs_to_retain_for_checkpoints(), None | Some(u64::MAX) | Some(0)) => { - if let Err(err) = Self::prune_checkpoints_for_eligible_epochs(&perpetual_db, &checkpoint_store, &objects_lock_table, config, metrics.clone(), indirect_objects_threshold, archive_readers.clone(), epoch_duration_ms).await { + if let Err(err) = Self::prune_checkpoints_for_eligible_epochs(&perpetual_db, &checkpoint_store, &objects_lock_table, config.clone(), metrics.clone(), indirect_objects_threshold, archive_readers.clone(), epoch_duration_ms).await { error!("Failed to prune checkpoints: {:?}", err); } }, diff --git a/crates/sui-core/src/db_checkpoint_handler.rs b/crates/sui-core/src/db_checkpoint_handler.rs index 455cbaec1e2fc..5323c18c21d28 100644 --- a/crates/sui-core/src/db_checkpoint_handler.rs +++ b/crates/sui-core/src/db_checkpoint_handler.rs @@ -261,7 +261,7 @@ impl DBCheckpointHandler { &perpetual_db, &checkpoint_store, &lock_table, - self.pruning_config, + self.pruning_config.clone(), metrics, self.indirect_objects_threshold, epoch_duration_ms, diff --git a/crates/sui-node/src/lib.rs b/crates/sui-node/src/lib.rs index 6d805aea7511c..070206f181bc1 100644 --- a/crates/sui-node/src/lib.rs +++ b/crates/sui-node/src/lib.rs @@ -427,7 +427,7 @@ impl SuiNode { DBMetrics::init(&prometheus_registry); mysten_metrics::init_metrics(&prometheus_registry); - let genesis = config.genesis()?; + let genesis = config.genesis()?.clone(); let secret = Arc::pin(config.protocol_key_pair().copy()); let genesis_committee = genesis.committee()?; @@ -447,7 +447,7 @@ impl SuiNode { .expect("Database read should not fail at init."); let store = - AuthorityStore::open(perpetual_tables, genesis, &config, &prometheus_registry).await?; + AuthorityStore::open(perpetual_tables, &genesis, &config, &prometheus_registry).await?; let cur_epoch = store.get_recovery_epoch_at_restart()?; let committee = committee_store @@ -587,13 +587,14 @@ impl SuiNode { state_snapshot_handle.is_some(), )?; - let mut pruning_config = config.authority_store_pruning_config; if !epoch_store .protocol_config() .simplified_unwrap_then_delete() { // We cannot prune tombstones if simplified_unwrap_then_delete is not enabled. - pruning_config.set_killswitch_tombstone_pruning(true); + config + .authority_store_pruning_config + .set_killswitch_tombstone_pruning(true); } let state = AuthorityState::new( @@ -921,7 +922,7 @@ impl SuiNode { .prune_and_compact_before_upload .unwrap_or(true), config.indirect_objects_threshold, - config.authority_store_pruning_config, + config.authority_store_pruning_config.clone(), prometheus_registry, state_snapshot_enabled, )?;