diff --git a/crates/sui-adapter-transactional-tests/tests/size_limits/deleted_id_limits_tests.exp b/crates/sui-adapter-transactional-tests/tests/size_limits/deleted_id_limits_tests.exp index 8a5381a51323c..129e95d15b17d 100644 --- a/crates/sui-adapter-transactional-tests/tests/size_limits/deleted_id_limits_tests.exp +++ b/crates/sui-adapter-transactional-tests/tests/size_limits/deleted_id_limits_tests.exp @@ -15,7 +15,7 @@ gas summary: computation_cost: 10000000, storage_cost: 988000, storage_rebate: task 4 'run'. lines 42-44: mutated: object(0,0) -gas summary: computation_cost: 200000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 96000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 5 'run'. lines 45-47: Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc. diff --git a/crates/sui-adapter-transactional-tests/tests/size_limits/event_limits_tests.exp b/crates/sui-adapter-transactional-tests/tests/size_limits/event_limits_tests.exp index 3decb905b4962..d04b8cd28f377 100644 --- a/crates/sui-adapter-transactional-tests/tests/size_limits/event_limits_tests.exp +++ b/crates/sui-adapter-transactional-tests/tests/size_limits/event_limits_tests.exp @@ -13,7 +13,7 @@ gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 9 task 3 'run'. lines 61-63: events: 50 mutated: 1 -gas summary: computation_cost: 20000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 11000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 4 'run'. lines 64-66: Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::event::emit (function index 0) at offset 0. Arithmetic error, stack overflow, max value depth, etc. @@ -26,12 +26,12 @@ Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { k task 6 'run'. lines 70-72: events: 1 mutated: 1 -gas summary: computation_cost: 5000000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 1521000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 7 'run'. lines 73-75: events: 1 mutated: 1 -gas summary: computation_cost: 5000000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 1948000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 8 'run'. lines 76-78: Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::event::emit (function index 0) at offset 0. Arithmetic error, stack overflow, max value depth, etc. diff --git a/crates/sui-adapter-transactional-tests/tests/size_limits/move_object_size_limit.exp b/crates/sui-adapter-transactional-tests/tests/size_limits/move_object_size_limit.exp index 879fa43febdd2..7c578162eef16 100644 --- a/crates/sui-adapter-transactional-tests/tests/size_limits/move_object_size_limit.exp +++ b/crates/sui-adapter-transactional-tests/tests/size_limits/move_object_size_limit.exp @@ -15,9 +15,9 @@ Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { k task 3 'run'. lines 86-88: created: object(3,0) mutated: object(0,0) -gas summary: computation_cost: 5000000000, storage_cost: 1947553200, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 1996000000, storage_cost: 1947553200, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 4 'run'. lines 89-89: created: object(4,0) mutated: object(0,0) -gas summary: computation_cost: 5000000000, storage_cost: 1947560800, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 1996000000, storage_cost: 1947560800, storage_rebate: 978120, non_refundable_storage_fee: 9880 diff --git a/crates/sui-adapter-transactional-tests/tests/size_limits/new_id_limits_tests.exp b/crates/sui-adapter-transactional-tests/tests/size_limits/new_id_limits_tests.exp index 38b4244fd32ac..5fa5c0d28201f 100644 --- a/crates/sui-adapter-transactional-tests/tests/size_limits/new_id_limits_tests.exp +++ b/crates/sui-adapter-transactional-tests/tests/size_limits/new_id_limits_tests.exp @@ -15,7 +15,7 @@ gas summary: computation_cost: 10000000, storage_cost: 988000, storage_rebate: task 4 'run'. lines 43-45: mutated: object(0,0) -gas summary: computation_cost: 200000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 96000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 5 'run'. lines 46-48: Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc. diff --git a/crates/sui-adapter-transactional-tests/tests/size_limits/object_runtime_limits.exp b/crates/sui-adapter-transactional-tests/tests/size_limits/object_runtime_limits.exp index 9034b745de319..ce883fa937ff2 100644 --- a/crates/sui-adapter-transactional-tests/tests/size_limits/object_runtime_limits.exp +++ b/crates/sui-adapter-transactional-tests/tests/size_limits/object_runtime_limits.exp @@ -11,12 +11,12 @@ gas summary: computation_cost: 1000000, storage_cost: 5821600, storage_rebate: task 2 'run'. lines 30-30: created: 200 mutated: 1 -gas summary: computation_cost: 10000000, storage_cost: 270028000, storage_rebate: 0, non_refundable_storage_fee: 0 +gas summary: computation_cost: 9000000, storage_cost: 270028000, storage_rebate: 0, non_refundable_storage_fee: 0 task 3 'run'. lines 32-32: created: 2000 mutated: 1 -gas summary: computation_cost: 200000000, storage_cost: 2691388000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 106000000, storage_cost: 2691388000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 4 'run'. lines 34-34: Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::dynamic_field::has_child_object (function index 14) at offset 0. Arithmetic error, stack overflow, max value depth, etc. diff --git a/crates/sui-adapter-transactional-tests/tests/size_limits/transfered_id_limits_tests.exp b/crates/sui-adapter-transactional-tests/tests/size_limits/transfered_id_limits_tests.exp index 3474dbad77f5c..3a4da7a5a78df 100644 --- a/crates/sui-adapter-transactional-tests/tests/size_limits/transfered_id_limits_tests.exp +++ b/crates/sui-adapter-transactional-tests/tests/size_limits/transfered_id_limits_tests.exp @@ -18,7 +18,7 @@ gas summary: computation_cost: 10000000, storage_cost: 316175200, storage_rebat task 4 'run'. lines 42-44: created: 2048 mutated: 1 -gas summary: computation_cost: 200000000, storage_cost: 2522485600, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 94000000, storage_cost: 2522485600, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 5 'run'. lines 45-47: Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc. diff --git a/crates/sui-adapter-transactional-tests/tests/size_limits/vector_len_limits.exp b/crates/sui-adapter-transactional-tests/tests/size_limits/vector_len_limits.exp index 03fcc5aa82b6f..d929f11693e44 100644 --- a/crates/sui-adapter-transactional-tests/tests/size_limits/vector_len_limits.exp +++ b/crates/sui-adapter-transactional-tests/tests/size_limits/vector_len_limits.exp @@ -11,11 +11,11 @@ gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 9 task 3 'run'. lines 36-38: mutated: object(0,0) -gas summary: computation_cost: 5000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 2000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 4 'run'. lines 39-41: mutated: object(0,0) -gas summary: computation_cost: 5000000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 +gas summary: computation_cost: 4196000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 task 5 'run'. lines 42-42: Error: Transaction Effects Status: Move Primitive Runtime Error. Location: Test::M1::push_n_items (function index 0) at offset 11. Arithmetic error, stack overflow, max value depth, etc. diff --git a/crates/sui-types/src/gas.rs b/crates/sui-types/src/gas.rs index cbba00e5c5285..1cf78015f5310 100644 --- a/crates/sui-types/src/gas.rs +++ b/crates/sui-types/src/gas.rs @@ -149,7 +149,7 @@ impl SuiCostTable { gas_budget: u64, gas_price: u64, storage_price: u64, - gas_rounding_step: u64, + gas_rounding_step: Option, ) -> SuiGasStatus { match self { Self::V1(cost_table) => SuiGasStatus::V1(SuiGasStatusV1::new_for_testing( diff --git a/crates/sui-types/src/gas_model/gas_v2.rs b/crates/sui-types/src/gas_model/gas_v2.rs index 037548c063309..24337b9e9f6f7 100644 --- a/crates/sui-types/src/gas_model/gas_v2.rs +++ b/crates/sui-types/src/gas_model/gas_v2.rs @@ -207,7 +207,7 @@ pub struct SuiGasStatus { /// This allows us to track how much storage rebate we need to retain in system transactions. unmetered_storage_rebate: u64, /// Rounding value to round up gas charges. - gas_rounding_step: u64, + gas_rounding_step: Option, } impl SuiGasStatus { @@ -218,10 +218,10 @@ impl SuiGasStatus { gas_price: u64, storage_gas_price: u64, rebate_rate: u64, - gas_rounding_step: u64, + gas_rounding_step: Option, cost_table: SuiCostTable, ) -> SuiGasStatus { - let gas_rounding_step = gas_rounding_step.max(1); + let gas_rounding_step = gas_rounding_step.map(|val| val.max(1)); SuiGasStatus { gas_status: move_gas_status, gas_budget, @@ -251,7 +251,7 @@ impl SuiGasStatus { gas_budget }; let sui_cost_table = SuiCostTable::new(config); - let gas_rounding_step = config.gas_rounding_step_as_option().unwrap_or(1u64); + let gas_rounding_step = config.gas_rounding_step_as_option(); Self::new( GasStatus::new_v2( sui_cost_table.execution_cost_table.clone(), @@ -273,7 +273,7 @@ impl SuiGasStatus { gas_budget: u64, gas_price: u64, storage_gas_price: u64, - gas_rounding_step: u64, + gas_rounding_step: Option, cost_table: SuiCostTable, ) -> SuiGasStatus { let protocol_config = ProtocolConfig::get_for_max_version(); @@ -309,7 +309,7 @@ impl SuiGasStatus { 0, 0, 0, - 1, // `gas_rounding_step` used in a division if we ever enter that code + None, SuiCostTable::unmetered(), ) } @@ -326,11 +326,11 @@ impl SuiGasStatusAPI for SuiGasStatus { fn bucketize_computation(&mut self) -> Result<(), ExecutionError> { let gas_used = self.gas_status.gas_used_pre_gas_price(); - let gas_used = if self.gas_status.gas_model_version > 5 { - if gas_used > 0 && gas_used % self.gas_rounding_step == 0 { + let gas_used = if let Some(gas_rounding) = self.gas_rounding_step { + if gas_used > 0 && gas_used % gas_rounding == 0 { gas_used * self.gas_price } else { - ((gas_used / self.gas_rounding_step) + 1) * self.gas_rounding_step * self.gas_price + ((gas_used / gas_rounding) + 1) * gas_rounding * self.gas_price } } else { let bucket_cost = get_bucket_cost(&self.cost_table.computation_bucket, gas_used);