From f64242847d5e916b19edaca1b7f6e5089e954867 Mon Sep 17 00:00:00 2001 From: Tao Zhu <82401714+taozhu-chicago@users.noreply.github.com> Date: Fri, 23 Sep 2022 16:15:31 -0500 Subject: [PATCH] increase instruction data cost (#27992) --- runtime/src/block_cost_limits.rs | 2 +- runtime/src/cost_model.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/src/block_cost_limits.rs b/runtime/src/block_cost_limits.rs index cc279b4dd7..337eb49680 100644 --- a/runtime/src/block_cost_limits.rs +++ b/runtime/src/block_cost_limits.rs @@ -27,7 +27,7 @@ pub const SIGNATURE_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 24; /// Number of compute units for one write lock pub const WRITE_LOCK_UNITS: u64 = COMPUTE_UNIT_TO_US_RATIO * 10; /// Number of data bytes per compute units -pub const DATA_BYTES_UNITS: u64 = 550 /*bytes per us*/ / COMPUTE_UNIT_TO_US_RATIO; +pub const INSTRUCTION_DATA_BYTES_COST: u64 = 140 /*bytes per us*/ / COMPUTE_UNIT_TO_US_RATIO; // Number of compute units for each built-in programs lazy_static! { /// Number of compute units for each built-in programs diff --git a/runtime/src/cost_model.rs b/runtime/src/cost_model.rs index 7ce546ab64..ea854787dd 100644 --- a/runtime/src/cost_model.rs +++ b/runtime/src/cost_model.rs @@ -180,7 +180,7 @@ impl CostModel { } tx_cost.builtins_execution_cost = builtin_costs; tx_cost.bpf_execution_cost = bpf_costs; - tx_cost.data_bytes_cost = data_bytes_len_total / DATA_BYTES_UNITS; + tx_cost.data_bytes_cost = data_bytes_len_total / INSTRUCTION_DATA_BYTES_COST; } fn calculate_account_data_size_on_deserialized_system_instruction( @@ -367,7 +367,7 @@ mod tests { testee.get_transaction_cost(&mut tx_cost, &simple_transaction); assert_eq!(*expected_execution_cost, tx_cost.builtins_execution_cost); assert_eq!(0, tx_cost.bpf_execution_cost); - assert_eq!(0, tx_cost.data_bytes_cost); + assert_eq!(3, tx_cost.data_bytes_cost); } #[test] @@ -397,7 +397,7 @@ mod tests { testee.get_transaction_cost(&mut tx_cost, &tx); assert_eq!(expected_cost, tx_cost.builtins_execution_cost); assert_eq!(0, tx_cost.bpf_execution_cost); - assert_eq!(1, tx_cost.data_bytes_cost); + assert_eq!(6, tx_cost.data_bytes_cost); } #[test]