Skip to content

Commit

Permalink
Protocol config for voting round
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtian committed Oct 26, 2024
1 parent 72c066e commit 47a743f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 13 deletions.
7 changes: 5 additions & 2 deletions consensus/core/src/dag_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,12 @@ impl DagState {
voter_block: &VerifiedBlock,
mut target: BlockRef,
) -> Vec<BlockOutput> {
const VOTING_ROUNDS: u32 = 5;
let mut certified_blocks = vec![];
while target.round >= voter_block.round().saturating_sub(VOTING_ROUNDS) {
while target.round
>= voter_block
.round()
.saturating_sub(self.context.protocol_config.consensus_voting_rounds())
{
let Some(target_block_info) = self.recent_blocks.get_mut(&target) else {
// The target block has been GC'ed.
break;
Expand Down
4 changes: 3 additions & 1 deletion consensus/core/src/linearizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,9 @@ mod tests {

let num_authorities = 4;
let (mut context, _keys) = Context::new_for_test(num_authorities);
context.protocol_config.set_gc_depth_for_testing(gc_depth);
context
.protocol_config
.set_consensus_gc_depth_for_testing(gc_depth);
let context = Arc::new(context);
let dag_state = Arc::new(RwLock::new(DagState::new(
context.clone(),
Expand Down
11 changes: 7 additions & 4 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,9 @@ pub struct ProtocolConfig {
/// The maximum number of transactions included in a consensus block.
consensus_max_num_transactions_in_block: Option<u64>,

/// The maximum number of rounds where transaction voting is allowed.
consensus_voting_rounds: Option<u32>,

/// The max accumulated txn execution cost per object in a Narwhal commit. Transactions
/// in a checkpoint will be deferred once their touch shared objects hit this limit.
/// This config is meant to be used when consensus protocol is Narwhal, where each
Expand Down Expand Up @@ -2160,6 +2163,8 @@ impl ProtocolConfig {

consensus_max_num_transactions_in_block: None,

consensus_voting_rounds: None,

max_accumulated_txn_cost_per_object_in_narwhal_commit: None,

max_deferral_rounds_for_congestion_control: None,
Expand Down Expand Up @@ -2902,6 +2907,8 @@ impl ProtocolConfig {
if chain != Chain::Mainnet && chain != Chain::Testnet {
cfg.feature_flags.uncompressed_g1_group_elements = true;
}

cfg.consensus_voting_rounds = Some(40);
}
// Use this template when making changes:
//
Expand Down Expand Up @@ -3064,10 +3071,6 @@ impl ProtocolConfig {
pub fn set_consensus_round_prober_for_testing(&mut self, val: bool) {
self.feature_flags.consensus_round_prober = val;
}

pub fn set_gc_depth_for_testing(&mut self, val: u32) {
self.consensus_gc_depth = Some(val);
}
}

type OverrideFn = dyn Fn(ProtocolVersion, ProtocolConfig) -> ProtocolConfig + Send;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,3 @@ max_soft_bundle_size: 5
bridge_should_try_to_finalize_committee: true
max_accumulated_txn_cost_per_object_in_mysticeti_commit: 3
gas_budget_based_txn_cost_cap_factor: 400000

Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ random_beacon_dkg_version: 1
consensus_max_transaction_size_bytes: 262144
consensus_max_transactions_in_block_bytes: 524288
consensus_max_num_transactions_in_block: 512
consensus_voting_rounds: 40
max_accumulated_txn_cost_per_object_in_narwhal_commit: 40
max_deferral_rounds_for_congestion_control: 10
min_checkpoint_interval_ms: 200
Expand All @@ -332,4 +333,3 @@ max_soft_bundle_size: 5
bridge_should_try_to_finalize_committee: true
max_accumulated_txn_cost_per_object_in_mysticeti_commit: 3
gas_budget_based_txn_cost_cap_factor: 400000

Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,3 @@ max_soft_bundle_size: 5
bridge_should_try_to_finalize_committee: true
max_accumulated_txn_cost_per_object_in_mysticeti_commit: 3
gas_budget_based_txn_cost_cap_factor: 400000

Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ random_beacon_dkg_version: 1
consensus_max_transaction_size_bytes: 262144
consensus_max_transactions_in_block_bytes: 524288
consensus_max_num_transactions_in_block: 512
consensus_voting_rounds: 40
max_accumulated_txn_cost_per_object_in_narwhal_commit: 40
max_deferral_rounds_for_congestion_control: 10
min_checkpoint_interval_ms: 200
Expand All @@ -332,4 +333,3 @@ max_soft_bundle_size: 5
bridge_should_try_to_finalize_committee: true
max_accumulated_txn_cost_per_object_in_mysticeti_commit: 3
gas_budget_based_txn_cost_cap_factor: 400000

Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,3 @@ max_soft_bundle_size: 5
bridge_should_try_to_finalize_committee: true
max_accumulated_txn_cost_per_object_in_mysticeti_commit: 3
gas_budget_based_txn_cost_cap_factor: 400000

Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ random_beacon_dkg_version: 1
consensus_max_transaction_size_bytes: 262144
consensus_max_transactions_in_block_bytes: 524288
consensus_max_num_transactions_in_block: 512
consensus_voting_rounds: 40
max_accumulated_txn_cost_per_object_in_narwhal_commit: 40
max_deferral_rounds_for_congestion_control: 10
min_checkpoint_interval_ms: 200
Expand All @@ -343,4 +344,3 @@ max_soft_bundle_size: 5
bridge_should_try_to_finalize_committee: true
max_accumulated_txn_cost_per_object_in_mysticeti_commit: 3
gas_budget_based_txn_cost_cap_factor: 400000

0 comments on commit 47a743f

Please sign in to comment.