From 695b712c5ccf16ad459815814790356acf4c9bb9 Mon Sep 17 00:00:00 2001 From: Anastasios Kichidis Date: Mon, 27 Jan 2025 18:48:38 +0200 Subject: [PATCH] [Consensus] enable GC and new linearizer logic for devnet (#20258) ## Description Enables consensus garbage collection and new linearization logic for devnet. ## Test plan CI/PT --- ## 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. - [x] Protocol: Enables consensus garbage collection & new linearization logic for devnet - [ ] Nodes (Validators and Full nodes): - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: --- consensus/core/src/dag_state.rs | 6 ++++++ consensus/core/src/linearizer.rs | 15 ++++++++++++--- consensus/core/src/transaction.rs | 1 + crates/sui-protocol-config/src/lib.rs | 15 ++++++++++++++- ...protocol_config__test__Mainnet_version_73.snap | 3 +-- ...protocol_config__test__Testnet_version_73.snap | 3 +-- .../sui_protocol_config__test__version_73.snap | 3 ++- ...ot_tests__genesis_config_snapshot_matches.snap | 1 - 8 files changed, 37 insertions(+), 10 deletions(-) diff --git a/consensus/core/src/dag_state.rs b/consensus/core/src/dag_state.rs index 9cb8cef3fd8cb..9174d17d605a1 100644 --- a/consensus/core/src/dag_state.rs +++ b/consensus/core/src/dag_state.rs @@ -1535,6 +1535,9 @@ mod test { let (mut context, _) = Context::new_for_test(4); context.parameters.dag_state_cached_rounds = CACHED_ROUNDS; + context + .protocol_config + .set_consensus_gc_depth_for_testing(0); let context = Arc::new(context); let store = Arc::new(MemStore::new()); @@ -2314,6 +2317,9 @@ mod test { const CACHED_ROUNDS: Round = 1; let (mut context, _) = Context::new_for_test(4); context.parameters.dag_state_cached_rounds = CACHED_ROUNDS; + context + .protocol_config + .set_consensus_gc_depth_for_testing(0); let context = Arc::new(context); let store = Arc::new(MemStore::new()); diff --git a/consensus/core/src/linearizer.rs b/consensus/core/src/linearizer.rs index bb82ad5c5b73a..9954d103abad8 100644 --- a/consensus/core/src/linearizer.rs +++ b/consensus/core/src/linearizer.rs @@ -504,7 +504,16 @@ mod tests { async fn test_handle_already_committed() { telemetry_subscribers::init_for_testing(); let num_authorities = 4; - let context = Arc::new(Context::new_for_test(num_authorities).0); + let (mut context, _) = Context::new_for_test(num_authorities); + context + .protocol_config + .set_consensus_gc_depth_for_testing(0); + context + .protocol_config + .set_consensus_linearize_subdag_v2_for_testing(false); + + let context = Arc::new(context); + let dag_state = Arc::new(RwLock::new(DagState::new( context.clone(), Arc::new(MemStore::new()), @@ -618,10 +627,10 @@ mod tests { .protocol_config .set_consensus_gc_depth_for_testing(gc_depth); - if gc_depth > 0 { + if gc_depth == 0 { context .protocol_config - .set_consensus_linearize_subdag_v2_for_testing(true); + .set_consensus_linearize_subdag_v2_for_testing(false); } let context = Arc::new(context); diff --git a/consensus/core/src/transaction.rs b/consensus/core/src/transaction.rs index 341d32c3c278d..d3152778c2183 100644 --- a/consensus/core/src/transaction.rs +++ b/consensus/core/src/transaction.rs @@ -512,6 +512,7 @@ mod tests { let _guard = ProtocolConfig::apply_overrides_for_testing(|_, mut config| { config.set_consensus_max_transaction_size_bytes_for_testing(2_000); // 2KB config.set_consensus_max_transactions_in_block_bytes_for_testing(2_000); + config.set_consensus_gc_depth_for_testing(0); config }); diff --git a/crates/sui-protocol-config/src/lib.rs b/crates/sui-protocol-config/src/lib.rs index ff11b3f3cc7d3..956e3b66b0c5d 100644 --- a/crates/sui-protocol-config/src/lib.rs +++ b/crates/sui-protocol-config/src/lib.rs @@ -209,6 +209,7 @@ const MAX_PROTOCOL_VERSION: u64 = 73; // Max gas price moved to 50 SUI // Variants as type nodes. // Version 73: Enable new marker table version. +// Enable consensus garbage collection and new commit rule for devnet. #[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub struct ProtocolVersion(u64); @@ -1718,7 +1719,12 @@ impl ProtocolConfig { } pub fn gc_depth(&self) -> u32 { - self.consensus_gc_depth.unwrap_or(0) + if cfg!(msim) { + // exercise a very low gc_depth + 5 + } else { + self.consensus_gc_depth.unwrap_or(0) + } } pub fn mysticeti_fastpath(&self) -> bool { @@ -3159,6 +3165,13 @@ impl ProtocolConfig { 73 => { // Enable new marker table version. cfg.use_object_per_epoch_marker_table_v2 = Some(true); + + if chain != Chain::Mainnet && chain != Chain::Testnet { + // Assuming a round rate of max 15/sec, then using a gc depth of 60 allow blocks within a window of ~4 seconds + // to be included before be considered garbage collected. + cfg.consensus_gc_depth = Some(60); + cfg.feature_flags.consensus_linearize_subdag_v2 = true; + } } // Use this template when making changes: // diff --git a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_73.snap b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_73.snap index 9418866e0f1f4..73826f83ff7dc 100644 --- a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_73.snap +++ b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_73.snap @@ -343,5 +343,4 @@ max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: 3700000 gas_budget_based_txn_cost_cap_factor: 400000 gas_budget_based_txn_cost_absolute_cap_commit_count: 50 sip_45_consensus_amplification_threshold: 5 -use_object_per_epoch_marker_table_v2: true - +use_object_per_epoch_marker_table_v2: true \ No newline at end of file diff --git a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_73.snap b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_73.snap index cf373ab9b8731..2c814eb36656d 100644 --- a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_73.snap +++ b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_73.snap @@ -346,5 +346,4 @@ max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: 3700000 gas_budget_based_txn_cost_cap_factor: 400000 gas_budget_based_txn_cost_absolute_cap_commit_count: 50 sip_45_consensus_amplification_threshold: 5 -use_object_per_epoch_marker_table_v2: true - +use_object_per_epoch_marker_table_v2: true \ No newline at end of file diff --git a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_73.snap b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_73.snap index b07eb45413702..639b8922b505e 100644 --- a/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_73.snap +++ b/crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_73.snap @@ -75,6 +75,7 @@ feature_flags: consensus_smart_ancestor_selection: true consensus_round_prober_probe_accepted_rounds: true native_charging_v2: true + consensus_linearize_subdag_v2: true convert_type_argument_error: true variant_nodes: true max_tx_size_bytes: 131072 @@ -352,8 +353,8 @@ max_soft_bundle_size: 5 bridge_should_try_to_finalize_committee: true max_accumulated_txn_cost_per_object_in_mysticeti_commit: 18500000 max_accumulated_randomness_txn_cost_per_object_in_mysticeti_commit: 3700000 +consensus_gc_depth: 60 gas_budget_based_txn_cost_cap_factor: 400000 gas_budget_based_txn_cost_absolute_cap_commit_count: 50 sip_45_consensus_amplification_threshold: 5 use_object_per_epoch_marker_table_v2: true - diff --git a/crates/sui-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap b/crates/sui-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap index 2b48eb6a78a59..881e8e1956c59 100644 --- a/crates/sui-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap +++ b/crates/sui-swarm-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap @@ -49,4 +49,3 @@ accounts: - 30000000000000000 - 30000000000000000 - 30000000000000000 -