increase instruction data cost (#27992)

This commit is contained in:
Tao Zhu 2022-09-23 16:15:31 -05:00 committed by GitHub
parent 9ee53e594d
commit f64242847d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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]