Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Jan 13, 2025
1 parent 254aa60 commit 69fb25c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 65 deletions.
11 changes: 5 additions & 6 deletions builtins-default-costs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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::*;
Expand Down Expand Up @@ -201,5 +201,4 @@ mod test {
.is_none()
);
}
>>>>>>> d791c9a76 (Fix builtin default cost dependents on migration (#3768))
}
59 changes: 0 additions & 59 deletions cost-model/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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]
Expand Down Expand Up @@ -754,7 +742,6 @@ mod tests {
));

// expected cost for two system transfer instructions
<<<<<<< HEAD
for (feature_set, expected_execution_cost) in [
(
FeatureSet::default(),
Expand All @@ -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]
Expand Down Expand Up @@ -864,7 +842,6 @@ mod tests {
));

let expected_account_cost = WRITE_LOCK_UNITS * 2;
<<<<<<< HEAD
for (feature_set, expected_execution_cost) in [
(
FeatureSet::default(),
Expand All @@ -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]
Expand All @@ -929,7 +887,6 @@ mod tests {
));

let expected_account_cost = WRITE_LOCK_UNITS * 2;
<<<<<<< HEAD
for (feature_set, expected_execution_cost) in [
(
FeatureSet::default(),
Expand All @@ -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());
Expand Down Expand Up @@ -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(),
Expand All @@ -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);
}
Expand All @@ -1013,7 +960,6 @@ mod tests {
&[&mint_keypair],
start_hash,
));
<<<<<<< HEAD
for (feature_set, expected_execution_cost) in [
(
FeatureSet::default(),
Expand All @@ -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);
}
Expand Down

0 comments on commit 69fb25c

Please sign in to comment.