Skip to content

Commit

Permalink
[fastpath] add voting rounds and support env var override
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtian committed Nov 1, 2024
1 parent ef0d78c commit a155d29
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 8 deletions.
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
1 change: 1 addition & 0 deletions crates/sui-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,7 @@
"consensus_max_num_transactions_in_block": null,
"consensus_max_transaction_size_bytes": null,
"consensus_max_transactions_in_block_bytes": null,
"consensus_voting_rounds": null,
"crypto_invalid_arguments_cost": {
"u64": "100"
},
Expand Down
26 changes: 22 additions & 4 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,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>,

/// DEPRECATED. Do not use.
max_accumulated_txn_cost_per_object_in_narwhal_commit: Option<u64>,

Expand Down Expand Up @@ -1653,6 +1656,9 @@ impl ProtocolConfig {
}

pub fn mysticeti_fastpath(&self) -> bool {
if let Some(enabled) = is_mysticeti_fpc_enabled_in_env() {
return enabled;
}
self.feature_flags.mysticeti_fastpath
}

Expand Down Expand Up @@ -2173,6 +2179,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 @@ -2931,6 +2939,9 @@ impl ProtocolConfig {
cfg.random_beacon_reduction_lower_bound = Some(500);

cfg.feature_flags.disallow_new_modules_in_deps_only_packages = true;

// Sets number of rounds allowed for fastpath voting in consensus.
cfg.consensus_voting_rounds = Some(40);
}
// Use this template when making changes:
//
Expand Down Expand Up @@ -3094,10 +3105,6 @@ impl ProtocolConfig {
self.feature_flags.consensus_round_prober = val;
}

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

pub fn set_disallow_new_modules_in_deps_only_packages_for_testing(&mut self, val: bool) {
self.feature_flags
.disallow_new_modules_in_deps_only_packages = val;
Expand Down Expand Up @@ -3192,6 +3199,17 @@ macro_rules! check_limit_by_meter {
}};
}

pub fn is_mysticeti_fpc_enabled_in_env() -> Option<bool> {
if let Ok(v) = std::env::var("CONSENSUS") {
if v == "mysticeti_fpc" {
return Some(true);
} else if v == "mysticeti" {
return Some(false);
}
}
None
}

#[cfg(all(test, not(msim)))]
mod test {
use insta::assert_yaml_snapshot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,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
max_txn_cost_overage_per_object_in_commit: 18446744073709551615
Expand All @@ -336,4 +337,3 @@ max_accumulated_txn_cost_per_object_in_mysticeti_commit: 18500000
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

Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,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
max_txn_cost_overage_per_object_in_commit: 18446744073709551615
Expand All @@ -336,4 +337,3 @@ max_accumulated_txn_cost_per_object_in_mysticeti_commit: 18500000
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

Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,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
max_txn_cost_overage_per_object_in_commit: 18446744073709551615
Expand All @@ -347,4 +348,3 @@ max_accumulated_txn_cost_per_object_in_mysticeti_commit: 18500000
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

1 change: 1 addition & 0 deletions sdk/graphql-transport/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,7 @@ export const RPC_METHODS: {
binary_friend_decls: 'u16',
max_package_dependencies: 'u32',
bridge_should_try_to_finalize_committee: 'bool',
consensus_voting_rounds: 'u32',
};

for (const { key, value } of protocolConfig.configs) {
Expand Down
3 changes: 3 additions & 0 deletions sdk/graphql-transport/test/compatability.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ describe('GraphQL SuiClient compatibility', () => {
const rpc = await toolbox.client.getProtocolConfig();
const graphql = await graphQLClient!.getProtocolConfig();

// If this check fails and the difference is due to types,
// the config field type may need to overridden if it is not u64,
// in sdk/graphql-transport/src/methods.ts getProtocolConfig().
expect(graphql).toEqual(rpc);
});

Expand Down

0 comments on commit a155d29

Please sign in to comment.