Skip to content

Commit

Permalink
rebase to mergify/bp/v2.1/pr-3799
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Jan 9, 2025
1 parent df063a8 commit 3d0bd25
Show file tree
Hide file tree
Showing 29 changed files with 832 additions and 376 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.

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

#[inline]
pub fn is_builtin_program(program_id: &Pubkey) -> bool {
BUILTIN_INSTRUCTION_COSTS.contains_key(program_id)
}
3 changes: 3 additions & 0 deletions compute-budget/src/compute_budget_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use {
/// default heap page cost = 0.5 * 15 ~= 8CU/page
pub const DEFAULT_HEAP_COST: u64 = 8;
pub const DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT: u32 = 200_000;
// SIMD-170 defines max CUs to be allocated for any builtin program instructions, that
// have not been migrated to sBPF programs.
pub const MAX_BUILTIN_ALLOCATION_COMPUTE_UNIT_LIMIT: u32 = 3_000;
pub const MAX_COMPUTE_UNIT_LIMIT: u32 = 1_400_000;
pub const MAX_HEAP_FRAME_BYTES: u32 = 256 * 1024;
pub const MIN_HEAP_FRAME_BYTES: u32 = HEAP_LENGTH as u32;
Expand Down
8 changes: 5 additions & 3 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,10 @@ impl Consumer {
.sanitized_transactions()
.iter()
.filter_map(|transaction| {
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)
})
Expand Down Expand Up @@ -758,6 +759,7 @@ impl Consumer {
let fee_payer = message.fee_payer();
let fee_budget_limits = FeeBudgetLimits::from(process_compute_budget_instructions(
SVMMessage::program_instructions_iter(message),
&bank.feature_set,
)?);
let fee = solana_fee::calculate_fee(
message,
Expand Down
8 changes: 8 additions & 0 deletions core/src/banking_stage/immutable_deserialized_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
solana_sanitize::SanitizeError,
solana_sdk::{
clock::Slot,
feature_set::FeatureSet,
hash::Hash,
message::{v0::LoadedAddresses, AddressLoaderError, Message, SimpleAddressLoader},
pubkey::Pubkey,
Expand Down Expand Up @@ -40,6 +41,12 @@ pub enum DeserializedPacketError {
FailedFilter(#[from] PacketFilterFailure),
}

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, Eq)]
pub struct ImmutableDeserializedPacket {
original_packet: Packet,
Expand Down Expand Up @@ -68,6 +75,7 @@ impl ImmutableDeserializedPacket {
.get_message()
.program_instructions_iter()
.map(|(pubkey, ix)| (pubkey, SVMInstruction::from(ix))),
&FEATURE_SET,
)
.map_err(|_| DeserializedPacketError::PrioritizationFailure)?;

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 Expand Up @@ -1094,7 +1095,7 @@ mod tests {
&Keypair::new(),
&Pubkey::new_unique(),
1,
i * 10,
i * 10_000,
bank.last_blockhash(),
)
})
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 3d0bd25

Please sign in to comment.