Skip to content

Commit

Permalink
Add an option to disable fullnode pruning in test cluster (#19490)
Browse files Browse the repository at this point in the history
Currently we aggressive prine FNs by default which causes tests which
depend on reading checkpoints from rest api fail

Existing tests
  • Loading branch information
sadhansood committed Oct 2, 2024
1 parent c9ae0f9 commit f76ef58
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 18 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/sui-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ impl Default for AuthorityStorePruningConfig {
}

impl AuthorityStorePruningConfig {
pub fn set_num_epochs_to_retain(&mut self, num_epochs_to_retain: u64) {
self.num_epochs_to_retain = num_epochs_to_retain;
}

pub fn set_num_epochs_to_retain_for_checkpoints(&mut self, num_epochs_to_retain: Option<u64>) {
self.num_epochs_to_retain_for_checkpoints = num_epochs_to_retain;
}
Expand Down
14 changes: 13 additions & 1 deletion crates/sui-swarm-config/src/node_config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ pub struct FullnodeConfigBuilder {
policy_config: Option<PolicyConfig>,
fw_config: Option<RemoteFirewallConfig>,
data_ingestion_dir: Option<PathBuf>,
disable_pruning: bool,
}

impl FullnodeConfigBuilder {
Expand Down Expand Up @@ -312,6 +313,11 @@ impl FullnodeConfigBuilder {
self
}

pub fn with_disable_pruning(mut self, disable_pruning: bool) -> Self {
self.disable_pruning = disable_pruning;
self
}

pub fn with_expensive_safety_check_config(
mut self,
expensive_safety_check_config: ExpensiveSafetyCheckConfig,
Expand Down Expand Up @@ -458,6 +464,12 @@ impl FullnodeConfigBuilder {
..Default::default()
};

let mut pruning_config = AuthorityStorePruningConfig::default();
if self.disable_pruning {
pruning_config.set_num_epochs_to_retain_for_checkpoints(None);
pruning_config.set_num_epochs_to_retain(u64::MAX);
};

NodeConfig {
protocol_key_pair: AuthorityKeyPairWithPath::new(validator_config.key_pair),
account_key_pair: KeyPairWithPath::new(validator_config.account_key_pair),
Expand Down Expand Up @@ -489,7 +501,7 @@ impl FullnodeConfigBuilder {
grpc_load_shed: None,
grpc_concurrency_limit: None,
p2p_config,
authority_store_pruning_config: AuthorityStorePruningConfig::default(),
authority_store_pruning_config: pruning_config,
end_of_epoch_broadcast_channel_capacity:
default_end_of_epoch_broadcast_channel_capacity(),
checkpoint_executor_config,
Expand Down
11 changes: 10 additions & 1 deletion crates/sui-swarm/src/memory/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct SwarmBuilder<R = OsRng> {
max_submit_position: Option<usize>,
submit_delay_step_override_millis: Option<u64>,
state_accumulator_v2_enabled_config: StateAccumulatorV2EnabledConfig,
disable_fullnode_pruning: bool,
}

impl SwarmBuilder {
Expand Down Expand Up @@ -86,6 +87,7 @@ impl SwarmBuilder {
max_submit_position: None,
submit_delay_step_override_millis: None,
state_accumulator_v2_enabled_config: StateAccumulatorV2EnabledConfig::Global(true),
disable_fullnode_pruning: false,
}
}
}
Expand Down Expand Up @@ -116,6 +118,7 @@ impl<R> SwarmBuilder<R> {
max_submit_position: self.max_submit_position,
submit_delay_step_override_millis: self.submit_delay_step_override_millis,
state_accumulator_v2_enabled_config: self.state_accumulator_v2_enabled_config,
disable_fullnode_pruning: self.disable_fullnode_pruning,
}
}

Expand Down Expand Up @@ -289,6 +292,11 @@ impl<R> SwarmBuilder<R> {
self
}

pub fn with_disable_fullnode_pruning(mut self) -> Self {
self.disable_fullnode_pruning = true;
self
}

pub fn with_submit_delay_step_override_millis(
mut self,
submit_delay_step_override_millis: u64,
Expand Down Expand Up @@ -375,7 +383,8 @@ impl<R: rand::RngCore + rand::CryptoRng> SwarmBuilder<R> {
.with_run_with_range(self.fullnode_run_with_range)
.with_policy_config(self.fullnode_policy_config)
.with_data_ingestion_dir(ingest_data)
.with_fw_config(self.fullnode_fw_config);
.with_fw_config(self.fullnode_fw_config)
.with_disable_pruning(self.disable_fullnode_pruning);

if let Some(spvc) = &self.fullnode_supported_protocol_versions_config {
let supported_versions = match spvc {
Expand Down
11 changes: 11 additions & 0 deletions crates/test-cluster/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ pub struct TestClusterBuilder {
num_validators: Option<usize>,
fullnode_rpc_port: Option<u16>,
enable_fullnode_events: bool,
disable_fullnode_pruning: bool,
validator_supported_protocol_versions_config: ProtocolVersionsConfig,
// Default to validator_supported_protocol_versions_config, but can be overridden.
fullnode_supported_protocol_versions_config: Option<ProtocolVersionsConfig>,
Expand Down Expand Up @@ -912,6 +913,7 @@ impl TestClusterBuilder {
fullnode_rpc_port: None,
num_validators: None,
enable_fullnode_events: false,
disable_fullnode_pruning: false,
validator_supported_protocol_versions_config: ProtocolVersionsConfig::Default,
fullnode_supported_protocol_versions_config: None,
db_checkpoint_config_validators: DBCheckpointConfig::default(),
Expand Down Expand Up @@ -982,6 +984,11 @@ impl TestClusterBuilder {
self
}

pub fn disable_fullnode_pruning(mut self) -> Self {
self.disable_fullnode_pruning = true;
self
}

pub fn with_enable_db_checkpoints_validators(mut self) -> Self {
self.db_checkpoint_config_validators = DBCheckpointConfig {
perform_db_checkpoints_at_epoch_end: true,
Expand Down Expand Up @@ -1455,6 +1462,10 @@ impl TestClusterBuilder {
builder.with_submit_delay_step_override_millis(submit_delay_step_override_millis);
}

if self.disable_fullnode_pruning {
builder = builder.with_disable_fullnode_pruning();
}

let mut swarm = builder.build();
swarm.launch().await?;

Expand Down

0 comments on commit f76ef58

Please sign in to comment.