Skip to content

Commit

Permalink
[Consensus] enable GC and new linearizer logic for devnet (#20258)
Browse files Browse the repository at this point in the history
## 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:
  • Loading branch information
akichidis authored Jan 27, 2025
1 parent d7704d4 commit 695b712
Showing 8 changed files with 37 additions and 10 deletions.
6 changes: 6 additions & 0 deletions consensus/core/src/dag_state.rs
Original file line number Diff line number Diff line change
@@ -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());
15 changes: 12 additions & 3 deletions consensus/core/src/linearizer.rs
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions consensus/core/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -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
});

15 changes: 14 additions & 1 deletion crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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:
//
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -49,4 +49,3 @@ accounts:
- 30000000000000000
- 30000000000000000
- 30000000000000000

0 comments on commit 695b712

Please sign in to comment.