Skip to content

Commit

Permalink
[SIP-45] Make K configurable and increase max gas price for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
shio-coder committed Dec 26, 2024
1 parent 0266df4 commit 7c11e59
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
10 changes: 8 additions & 2 deletions crates/sui-core/src/consensus_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,14 @@ impl ConsensusAdapter {
let (duration, position, positions_moved, preceding_disconnected) =
match min_digest_and_gas_price {
Some((digest, gas_price)) => {
// TODO: Make this configurable.
let k = 5;
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 multipler = gas_price / epoch_store.reference_gas_price();
amplification_factor = if multipler >= k { multipler } else { 0 };
self.await_submit_delay_user_transaction(
Expand Down
9 changes: 9 additions & 0 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,9 @@ pub struct ProtocolConfig {
/// Adds an absolute cap on the maximum transaction cost when using TotalGasBudgetWithCap at
/// the given multiple of the per-commit budget.
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>,
}

// feature flags
Expand Down Expand Up @@ -2243,6 +2246,8 @@ impl ProtocolConfig {
gas_budget_based_txn_cost_cap_factor: None,

gas_budget_based_txn_cost_absolute_cap_commit_count: None,

sip_45_k: None,
// When adding a new constant, set it to None in the earliest version, like this:
// new_constant: None,
};
Expand Down Expand Up @@ -2999,6 +3004,8 @@ 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 @@ -3075,6 +3082,8 @@ 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);
}
// Use this template when making changes:
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: crates/sui-protocol-config/src/lib.rs
expression: "ProtocolConfig::get_for_version(cur, *chain_id)"
snapshot_kind: text
---
version: 70
feature_flags:
Expand Down Expand Up @@ -339,4 +340,4 @@ 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: crates/sui-protocol-config/src/lib.rs
expression: "ProtocolConfig::get_for_version(cur, *chain_id)"
snapshot_kind: text
---
version: 70
feature_flags:
Expand Down Expand Up @@ -103,7 +104,7 @@ max_move_object_size: 256000
max_move_package_size: 102400
max_publish_or_upgrade_per_ptb: 5
max_tx_gas: 50000000000
max_gas_price: 100000
max_gas_price: 1000000000000
max_gas_computation_bucket: 5000000
gas_rounding_step: 1000
max_loop_depth: 5
Expand Down Expand Up @@ -342,4 +343,4 @@ 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: crates/sui-protocol-config/src/lib.rs
expression: "ProtocolConfig::get_for_version(cur, *chain_id)"
snapshot_kind: text
---
version: 70
feature_flags:
Expand Down Expand Up @@ -109,7 +110,7 @@ max_move_object_size: 256000
max_move_package_size: 102400
max_publish_or_upgrade_per_ptb: 5
max_tx_gas: 50000000000
max_gas_price: 100000
max_gas_price: 1000000000000
max_gas_computation_bucket: 5000000
gas_rounding_step: 1000
max_loop_depth: 5
Expand Down Expand Up @@ -351,4 +352,4 @@ 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

0 comments on commit 7c11e59

Please sign in to comment.