Skip to content

Commit

Permalink
[SIP-45] Use protocol version 71
Browse files Browse the repository at this point in the history
  • Loading branch information
shio-coder committed Dec 27, 2024
1 parent 6104808 commit 4d761b7
Show file tree
Hide file tree
Showing 8 changed files with 1,062 additions and 20 deletions.
12 changes: 4 additions & 8 deletions crates/sui-core/src/consensus_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,10 @@ impl ConsensusAdapter {
let (duration, position, positions_moved, preceding_disconnected) =
match min_digest_and_gas_price {
Some((digest, gas_price)) => {
let protocol_config_k = epoch_store.protocol_config().sip_45_k();
let k = if protocol_config_k == 0 {
// Disable amplification if k is not set.
u64::MAX
} else {
protocol_config_k
};

let k = epoch_store
.protocol_config()
.sip_45_consensus_amplification_threshold_as_option()
.unwrap_or(u64::MAX);
let multipler = gas_price / epoch_store.reference_gas_price();
amplification_factor = if multipler >= k { multipler } else { 0 };
self.await_submit_delay_user_transaction(
Expand Down
19 changes: 12 additions & 7 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use tracing::{info, warn};

/// The minimum and maximum protocol versions supported by this build.
const MIN_PROTOCOL_VERSION: u64 = 1;
const MAX_PROTOCOL_VERSION: u64 = 70;
const MAX_PROTOCOL_VERSION: u64 = 71;

// Record history of protocol version allocations here:
//
Expand Down Expand Up @@ -203,6 +203,7 @@ const MAX_PROTOCOL_VERSION: u64 = 70;
// Add new gas model version to update charging of native functions.
// Add std::uq64_64 module to Move stdlib.
// Improve gas/wall time efficiency of some Move stdlib vector functions
// Version 71: [SIP-45] Increase max gas price to 1T. Enable consensus amplification.

#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProtocolVersion(u64);
Expand Down Expand Up @@ -1329,7 +1330,8 @@ pub struct ProtocolConfig {
gas_budget_based_txn_cost_absolute_cap_commit_count: Option<u64>,

/// SIP-45: K in the formula `amplification_factor = max(0, gas_price / reference_gas_price - K)`.
sip_45_k: Option<u64>,
/// This is the threshold for activating consensus amplification.
sip_45_consensus_amplification_threshold: Option<u64>,
}

// feature flags
Expand Down Expand Up @@ -2247,7 +2249,7 @@ impl ProtocolConfig {

gas_budget_based_txn_cost_absolute_cap_commit_count: None,

sip_45_k: None,
sip_45_consensus_amplification_threshold: None,
// When adding a new constant, set it to None in the earliest version, like this:
// new_constant: None,
};
Expand Down Expand Up @@ -3004,8 +3006,6 @@ impl ProtocolConfig {
// Enable probing for accepted rounds in round prober for testnet
cfg.feature_flags
.consensus_round_prober_probe_accepted_rounds = true;
// [SIP-45] Set max gas price to 1T.
cfg.max_gas_price = Some(1_000_000_000_000);
}

cfg.poseidon_bn254_cost_per_block = Some(388);
Expand Down Expand Up @@ -3082,8 +3082,13 @@ impl ProtocolConfig {
cfg.group_ops_bls12381_uncompressed_g1_sum_max_terms = Some(1200);

cfg.validator_validate_metadata_cost_base = Some(20000);

cfg.sip_45_k = Some(5);
}
71 => {
if chain != Chain::Mainnet {
// [SIP-45] Set max gas price to 1T.
cfg.max_gas_price = Some(1_000_000_000_000);
}
cfg.sip_45_consensus_amplification_threshold = Some(5);
}
// Use this template when making changes:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,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
sip_45_k: 5
Loading

0 comments on commit 4d761b7

Please sign in to comment.