Skip to content

Commit

Permalink
fix cherry-pick conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Dec 11, 2024
1 parent bbb80bc commit f1d1130
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 216 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 0 additions & 58 deletions builtins-default-costs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,66 +54,8 @@ lazy_static! {
temp_table
};
}
<<<<<<< HEAD
=======

pub fn get_builtin_instruction_cost<'a>(
program_id: &'a Pubkey,
feature_set: &'a FeatureSet,
) -> Option<u64> {
BUILTIN_INSTRUCTION_COSTS
.get(program_id)
.filter(
// Returns true if builtin program id has no core_bpf_migration_feature or feature is not activated;
// otherwise returns false because it's not considered as builtin
|builtin_cost| -> bool {
builtin_cost
.core_bpf_migration_feature
.map(|feature_id| !feature_set.is_active(&feature_id))
.unwrap_or(true)
},
)
.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::*;

#[test]
fn test_get_builtin_instruction_cost() {
// use native cost if no migration planned
assert_eq!(
Some(solana_compute_budget_program::DEFAULT_COMPUTE_UNITS),
get_builtin_instruction_cost(&compute_budget::id(), &FeatureSet::all_enabled())
);

// use native cost if migration is planned but not activated
assert_eq!(
Some(solana_stake_program::stake_instruction::DEFAULT_COMPUTE_UNITS),
get_builtin_instruction_cost(&solana_stake_program::id(), &FeatureSet::default())
);

// None if migration is planned and activated, in which case, it's no longer builtin
assert!(get_builtin_instruction_cost(
&solana_stake_program::id(),
&FeatureSet::all_enabled()
)
.is_none());

// None if not builtin
assert!(
get_builtin_instruction_cost(&Pubkey::new_unique(), &FeatureSet::default()).is_none()
);
assert!(
get_builtin_instruction_cost(&Pubkey::new_unique(), &FeatureSet::all_enabled())
.is_none()
);
}
}
>>>>>>> 3e9af14f3a (Fix reserve minimal compute units for builtins (#3799))
19 changes: 4 additions & 15 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,19 +574,12 @@ impl Consumer {
.sanitized_transactions()
.iter()
.filter_map(|transaction| {
<<<<<<< HEAD
process_compute_budget_instructions(SVMMessage::program_instructions_iter(
transaction,
))
process_compute_budget_instructions(
SVMMessage::program_instructions_iter(transaction),
&bank.feature_set,
)
.ok()
.map(|limits| limits.compute_unit_price)
=======
transaction
.compute_budget_instruction_details()
.sanitize_and_convert_to_compute_budget_limits(&bank.feature_set)
.ok()
.map(|limits| limits.compute_unit_price)
>>>>>>> 3e9af14f3a (Fix reserve minimal compute units for builtins (#3799))
})
.minmax();
let (min_prioritization_fees, max_prioritization_fees) =
Expand Down Expand Up @@ -765,12 +758,8 @@ impl Consumer {
) -> Result<(), TransactionError> {
let fee_payer = message.fee_payer();
let fee_budget_limits = FeeBudgetLimits::from(process_compute_budget_instructions(
<<<<<<< HEAD
SVMMessage::program_instructions_iter(message),
=======
message.program_instructions_iter(),
&bank.feature_set,
>>>>>>> 3e9af14f3a (Fix reserve minimal compute units for builtins (#3799))
)?);
let fee = solana_fee::calculate_fee(
message,
Expand Down
6 changes: 1 addition & 5 deletions core/src/banking_stage/immutable_deserialized_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,13 @@ pub enum DeserializedPacketError {
FailedFilter(#[from] PacketFilterFailure),
}

<<<<<<< HEAD
#[derive(Debug, Eq)]
=======
lazy_static::lazy_static! {
// Make a dummy feature_set with all features enabled to
// fetch compute_unit_price and compute_unit_limit for legacy leader.
static ref FEATURE_SET: FeatureSet = FeatureSet::all_enabled();
}

#[derive(Debug)]
>>>>>>> 3e9af14f3a (Fix reserve minimal compute units for builtins (#3799))
#[derive(Debug, Eq)]
pub struct ImmutableDeserializedPacket {
original_packet: Packet,
transaction: SanitizedVersionedTransaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,12 @@ impl<T: LikeClusterInfo> SchedulerController<T> {
.is_ok()
})
.filter_map(|(packet, tx, deactivation_slot)| {
process_compute_budget_instructions(SVMMessage::program_instructions_iter(&tx))
.map(|compute_budget| {
(packet, tx, deactivation_slot, compute_budget.into())
})
.ok()
process_compute_budget_instructions(
SVMMessage::program_instructions_iter(&tx),
&working_bank.feature_set,
)
.map(|compute_budget| (packet, tx, deactivation_slot, compute_budget.into()))
.ok()
})
.for_each(|(packet, tx, deactivation_slot, fee_budget_limits)| {
arc_packets.push(packet);
Expand Down
1 change: 1 addition & 0 deletions cost-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ name = "solana_cost_model"
itertools = { workspace = true }
rand = "0.8.5"
# See order-crates-for-publishing.py for using this unusual `path = "."`
solana-compute-budget-program = { workspace = true }
solana-cost-model = { path = ".", features = ["dev-context-only-utils"] }
solana-logger = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
Expand Down
Loading

0 comments on commit f1d1130

Please sign in to comment.