Skip to content

Commit

Permalink
gas price and budget max (#20858)
Browse files Browse the repository at this point in the history
## Description 

Making a change to move the gas price up to 100Sui and the gas budget at
50_000Sui.
Let's see what breaks and we can go from there

## Test plan 

How did you test the new or updated feature?

---

## 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.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:

---------

Co-authored-by: Mingwei Tian <[email protected]>
  • Loading branch information
dariorussi and mwtian authored Jan 15, 2025
1 parent ca155f3 commit 37fbcd9
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ const GAS_LATENCY_RATIO_BUCKETS: &[f64] = &[
3000.0, 4000.0, 5000.0, 6000.0, 7000.0, 8000.0, 9000.0, 10000.0, 50000.0, 100000.0, 1000000.0,
];

pub const DEV_INSPECT_GAS_COIN_VALUE: u64 = 1_000_000_000_000;
pub const DEV_INSPECT_GAS_COIN_VALUE: u64 = 1_000_000_000_000_000;

impl AuthorityMetrics {
pub fn new(registry: &prometheus::Registry) -> AuthorityMetrics {
Expand Down
21 changes: 21 additions & 0 deletions crates/sui-core/src/unit_tests/gas_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ static MAX_GAS_BUDGET: Lazy<u64> =
static MIN_GAS_BUDGET_PRE_RGP: Lazy<u64> =
Lazy::new(|| ProtocolConfig::get_for_max_version_UNSAFE().base_tx_cost_fixed());

#[test]
fn test_gas_invariants() {
let max_tx_gas = ProtocolConfig::get_for_max_version_UNSAFE().max_tx_gas();
assert!(
DEV_INSPECT_GAS_COIN_VALUE >= max_tx_gas,
"DEV_INSPECT_GAS_COIN_VALUE {} cannot be less than max_tx_gas {}",
DEV_INSPECT_GAS_COIN_VALUE,
max_tx_gas
);

let max_gas_price = ProtocolConfig::get_for_max_version_UNSAFE().max_gas_price();
let base_tx_cost_fixed = ProtocolConfig::get_for_max_version_UNSAFE().base_tx_cost_fixed();
assert!(
max_gas_price * base_tx_cost_fixed <= max_tx_gas,
"max_gas_price {} * base_tx_cost_fixed {} > max_tx_gas {}",
max_gas_price,
base_tx_cost_fixed,
max_tx_gas
);
}

#[tokio::test]
async fn test_tx_less_than_minimum_gas_budget() {
// This test creates a transaction that sets a gas_budget less than the minimum
Expand Down
8 changes: 8 additions & 0 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ const MAX_PROTOCOL_VERSION: u64 = 72;
// Improve gas/wall time efficiency of some Move stdlib vector functions
// Version 71: [SIP-45] Enable consensus amplification.
// Version 72: Fix issue where `convert_type_argument_error` wasn't being used in all cases.
// Max gas budget moved to 50_000 SUI
// Max gas price moved to 50 SUI

#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProtocolVersion(u64);
Expand Down Expand Up @@ -3130,6 +3132,12 @@ impl ProtocolConfig {
}
72 => {
cfg.feature_flags.convert_type_argument_error = true;

// Invariant: max_gas_price * base_tx_cost_fixed <= max_tx_gas
// max gas budget is in MIST and an absolute value 50_000 SUI
cfg.max_tx_gas = Some(50_000_000_000_000);
// max gas price is in MIST and an absolute value 50 SUI
cfg.max_gas_price = Some(50_000_000_000);
}
// Use this template when making changes:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ binary_friend_decls: 100
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_tx_gas: 50000000000000
max_gas_price: 50000000000
max_gas_computation_bucket: 5000000
gas_rounding_step: 1000
max_loop_depth: 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ binary_friend_decls: 100
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_tx_gas: 50000000000000
max_gas_price: 50000000000
max_gas_computation_bucket: 5000000
gas_rounding_step: 1000
max_loop_depth: 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ binary_friend_decls: 100
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_tx_gas: 50000000000000
max_gas_price: 50000000000
max_gas_computation_bucket: 5000000
gas_rounding_step: 1000
max_loop_depth: 5
Expand Down
12 changes: 6 additions & 6 deletions crates/transaction-fuzzer/src/account_universe/transfer_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,21 +470,21 @@ impl AUTransactionGen for P2PTransferGenRandomGasRandomPriceRandomSponsorship {
},
}),
RunInfo {
gas_budget_too_low: true,
gas_budget_too_high: true,
..
} => Err(SuiError::UserInputError {
error: UserInputError::GasBudgetTooLow {
error: UserInputError::GasBudgetTooHigh {
gas_budget: self.gas,
min_budget: PROTOCOL_CONFIG.base_tx_cost_fixed() * self.gas_price,
max_budget: PROTOCOL_CONFIG.max_tx_gas(),
},
}),
RunInfo {
gas_budget_too_high: true,
gas_budget_too_low: true,
..
} => Err(SuiError::UserInputError {
error: UserInputError::GasBudgetTooHigh {
error: UserInputError::GasBudgetTooLow {
gas_budget: self.gas,
max_budget: PROTOCOL_CONFIG.max_tx_gas(),
min_budget: PROTOCOL_CONFIG.base_tx_cost_fixed() * self.gas_price,
},
}),
RunInfo {
Expand Down

0 comments on commit 37fbcd9

Please sign in to comment.