sui_types/gas_model/
gas_predicates.rs1use crate::gas_model::tables::{
10 initial_cost_schedule_v1, initial_cost_schedule_v2, initial_cost_schedule_v3,
11 initial_cost_schedule_v4, initial_cost_schedule_v5,
12};
13use crate::gas_model::units_types::CostTable;
14use sui_protocol_config::ProtocolConfig;
15
16const V2_NATIVE_FUNCTION_CALL_THRESHOLD: u64 = 700;
18
19pub fn dont_charge_budget_on_storage_oog(gas_model_version: u64) -> bool {
21 gas_model_version >= 4
22}
23
24pub fn check_for_gas_price_too_high(gas_model_version: u64) -> bool {
26 gas_model_version >= 4
27}
28
29pub fn charge_input_as_memory(gas_model_version: u64) -> bool {
32 gas_model_version == 4
33}
34
35pub fn use_legacy_abstract_size(gas_model_version: u64) -> bool {
37 gas_model_version <= 7
38}
39
40pub fn txn_base_cost_as_multiplier(protocol_config: &ProtocolConfig) -> bool {
43 protocol_config.txn_base_cost_as_multiplier()
44}
45
46pub fn charge_upgrades(gas_model_version: u64) -> bool {
48 gas_model_version >= 7
49}
50
51pub fn cost_table_for_version(gas_model: u64) -> CostTable {
53 if gas_model <= 3 {
54 initial_cost_schedule_v1()
55 } else if gas_model == 4 {
56 initial_cost_schedule_v2()
57 } else if gas_model == 5 {
58 initial_cost_schedule_v3()
59 } else if gas_model <= 7 {
60 initial_cost_schedule_v4()
61 } else {
62 initial_cost_schedule_v5()
63 }
64}
65
66pub fn native_function_threshold_exceeded(gas_model_version: u64, num_native_calls: u64) -> bool {
68 if gas_model_version > 8 {
69 num_native_calls > V2_NATIVE_FUNCTION_CALL_THRESHOLD
70 } else {
71 false
72 }
73}