From 69fb25c60cbf4967cfbb8b183fbba684fc0328d0 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Sun, 12 Jan 2025 22:48:55 -0600 Subject: [PATCH] fix merge conflicts --- builtins-default-costs/src/lib.rs | 11 +++--- cost-model/src/cost_model.rs | 59 ------------------------------- 2 files changed, 5 insertions(+), 65 deletions(-) diff --git a/builtins-default-costs/src/lib.rs b/builtins-default-costs/src/lib.rs index 7da01539f33c55..2e167c667cc84d 100644 --- a/builtins-default-costs/src/lib.rs +++ b/builtins-default-costs/src/lib.rs @@ -143,11 +143,6 @@ lazy_static! { }; } -<<<<<<< HEAD -#[inline] -pub fn is_builtin_program(program_id: &Pubkey) -> bool { - BUILTIN_INSTRUCTION_COSTS.contains_key(program_id) -======= pub fn get_builtin_instruction_cost<'a>( program_id: &'a Pubkey, feature_set: &'a FeatureSet, @@ -167,6 +162,11 @@ pub fn get_builtin_instruction_cost<'a>( .map(|builtin_cost| builtin_cost.native_cost) } +#[inline] +pub fn is_builtin_program(program_id: &Pubkey) -> bool { + BUILTIN_INSTRUCTION_COSTS.contains_key(program_id) +} + #[cfg(test)] mod test { use super::*; @@ -201,5 +201,4 @@ mod test { .is_none() ); } ->>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768)) } diff --git a/cost-model/src/cost_model.rs b/cost-model/src/cost_model.rs index 6af5d0eb2b3d29..8f26008131f9d2 100644 --- a/cost-model/src/cost_model.rs +++ b/cost-model/src/cost_model.rs @@ -567,7 +567,6 @@ mod tests { system_transaction::transfer(&mint_keypair, &keypair.pubkey(), 2, start_hash), ); -<<<<<<< HEAD for (feature_set, expected_execution_cost) in [ ( FeatureSet::default(), @@ -583,17 +582,6 @@ mod tests { assert_eq!(expected_execution_cost, program_execution_cost); } -======= - // expected cost for one system transfer instructions - let expected_execution_cost = - solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS; - - let (program_execution_cost, _loaded_accounts_data_size_cost, data_bytes_cost) = - CostModel::get_transaction_cost(&simple_transaction, &FeatureSet::all_enabled()); - - assert_eq!(expected_execution_cost, program_execution_cost); - assert_eq!(3, data_bytes_cost); ->>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768)) } #[test] @@ -754,7 +742,6 @@ mod tests { )); // expected cost for two system transfer instructions -<<<<<<< HEAD for (feature_set, expected_execution_cost) in [ ( FeatureSet::default(), @@ -770,15 +757,6 @@ mod tests { assert_eq!(expected_execution_cost, programs_execution_cost); assert_eq!(6, data_bytes_cost); } -======= - let program_cost = solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS; - let expected_cost = program_cost * 2; - - let (program_execution_cost, _loaded_accounts_data_size_cost, data_bytes_cost) = - CostModel::get_transaction_cost(&tx, &FeatureSet::all_enabled()); - assert_eq!(expected_cost, program_execution_cost); - assert_eq!(6, data_bytes_cost); ->>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768)) } #[test] @@ -864,7 +842,6 @@ mod tests { )); let expected_account_cost = WRITE_LOCK_UNITS * 2; -<<<<<<< HEAD for (feature_set, expected_execution_cost) in [ ( FeatureSet::default(), @@ -891,25 +868,6 @@ mod tests { tx_cost.loaded_accounts_data_size_cost() ); } -======= - let expected_execution_cost = - solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS; - const DEFAULT_PAGE_COST: u64 = 8; - let expected_loaded_accounts_data_size_cost = - solana_compute_budget::compute_budget_limits::MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES.get() - as u64 - / ACCOUNT_DATA_COST_PAGE_SIZE - * DEFAULT_PAGE_COST; - - let tx_cost = CostModel::calculate_cost(&tx, &FeatureSet::all_enabled()); - assert_eq!(expected_account_cost, tx_cost.write_lock_cost()); - assert_eq!(expected_execution_cost, tx_cost.programs_execution_cost()); - assert_eq!(2, tx_cost.writable_accounts().count()); - assert_eq!( - expected_loaded_accounts_data_size_cost, - tx_cost.loaded_accounts_data_size_cost() - ); ->>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768)) } #[test] @@ -929,7 +887,6 @@ mod tests { )); let expected_account_cost = WRITE_LOCK_UNITS * 2; -<<<<<<< HEAD for (feature_set, expected_execution_cost) in [ ( FeatureSet::default(), @@ -942,11 +899,6 @@ mod tests { ), ] { let expected_loaded_accounts_data_size_cost = (data_limit as u64) / (32 * 1024) * 8; -======= - let expected_execution_cost = solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS - + solana_compute_budget_program::DEFAULT_COMPUTE_UNITS; - let expected_loaded_accounts_data_size_cost = (data_limit as u64) / (32 * 1024) * 8; ->>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768)) let tx_cost = CostModel::calculate_cost(&tx, &feature_set); assert_eq!(expected_account_cost, tx_cost.write_lock_cost()); @@ -974,7 +926,6 @@ mod tests { start_hash, )); // transaction has one builtin instruction, and one bpf instruction, no ComputeBudget::compute_unit_limit -<<<<<<< HEAD for (feature_set, expected_execution_cost) in [ ( FeatureSet::default(), @@ -989,10 +940,6 @@ mod tests { ] { let (programs_execution_cost, _loaded_accounts_data_size_cost, _data_bytes_cost) = CostModel::get_transaction_cost(&transaction, &feature_set); -======= - let expected_builtin_cost = solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS; - let expected_bpf_cost = DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT; ->>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768)) assert_eq!(expected_execution_cost, programs_execution_cost); } @@ -1013,7 +960,6 @@ mod tests { &[&mint_keypair], start_hash, )); -<<<<<<< HEAD for (feature_set, expected_execution_cost) in [ ( FeatureSet::default(), @@ -1024,11 +970,6 @@ mod tests { ] { let (programs_execution_cost, _loaded_accounts_data_size_cost, _data_bytes_cost) = CostModel::get_transaction_cost(&transaction, &feature_set); -======= - // transaction has one builtin instruction, and one ComputeBudget::compute_unit_limit - let expected_cost = solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS - + solana_compute_budget_program::DEFAULT_COMPUTE_UNITS; ->>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768)) assert_eq!(expected_execution_cost, programs_execution_cost); }