Skip to content

Commit

Permalink
remove solana-sdk from compute-budget-instruction (solana-labs#4319)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey authored Jan 10, 2025
1 parent cb9451c commit b70cac3
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 123 deletions.
14 changes: 13 additions & 1 deletion Cargo.lock

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

16 changes: 14 additions & 2 deletions compute-budget-instruction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ edition = { workspace = true }

[dependencies]
log = { workspace = true }
solana-borsh = { workspace = true }
solana-builtins-default-costs = { workspace = true }
solana-compute-budget = { workspace = true }
solana-compute-budget-interface = { workspace = true }
solana-feature-set = { workspace = true }
solana-instruction = { workspace = true }
solana-packet = { workspace = true }
solana-pubkey = { workspace = true }
solana-sdk = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-svm-transaction = { workspace = true }
solana-transaction-error = { workspace = true }
thiserror = { workspace = true }

[lib]
Expand All @@ -26,8 +32,14 @@ name = "solana_compute_budget_instruction"
bincode = { workspace = true }
criterion = { workspace = true }
rand = { workspace = true }
solana-builtins-default-costs = { workspace = true, features = ["dev-context-only-utils"] }
solana-builtins-default-costs = { workspace = true, features = ["dev-context-only-utils"] }
solana-hash = { workspace = true }
solana-keypair = { workspace = true }
solana-message = { workspace = true }
solana-program = { workspace = true }
solana-signer = { workspace = true }
solana-system-interface = { workspace = true }
solana-transaction = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
use {
criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput},
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
solana_sdk::{
compute_budget::ComputeBudgetInstruction,
feature_set::FeatureSet,
instruction::Instruction,
message::Message,
pubkey::Pubkey,
signature::Keypair,
signer::Signer,
system_instruction::{self},
transaction::{SanitizedTransaction, Transaction},
},
solana_compute_budget_interface::ComputeBudgetInstruction,
solana_feature_set::FeatureSet,
solana_instruction::Instruction,
solana_keypair::Keypair,
solana_message::Message,
solana_pubkey::Pubkey,
solana_signer::Signer,
solana_svm_transaction::svm_message::SVMMessage,
solana_system_interface::instruction::transfer,
solana_transaction::{sanitized::SanitizedTransaction, Transaction},
};

const NUM_TRANSACTIONS_PER_ITER: usize = 1024;
Expand Down Expand Up @@ -110,14 +108,18 @@ fn bench_process_compute_budget_instructions_builtins(c: &mut Criterion) {
.throughput(Throughput::Elements(NUM_TRANSACTIONS_PER_ITER as u64))
.bench_function("4 dummy builtins", |bencher| {
let ixs = vec![
Instruction::new_with_bincode(solana_sdk::bpf_loader::id(), &(), vec![]),
Instruction::new_with_bincode(solana_sdk::secp256k1_program::id(), &(), vec![]),
Instruction::new_with_bincode(solana_sdk_ids::bpf_loader::id(), &(), vec![]),
Instruction::new_with_bincode(
solana_sdk::address_lookup_table::program::id(),
solana_sdk_ids::secp256k1_program::id(),
&(),
vec![],
),
Instruction::new_with_bincode(solana_sdk::loader_v4::id(), &(), vec![]),
Instruction::new_with_bincode(
solana_sdk_ids::address_lookup_table::id(),
&(),
vec![],
),
Instruction::new_with_bincode(solana_sdk_ids::loader_v4::id(), &(), vec![]),
];
let tx = build_sanitized_transaction(&Keypair::new(), &ixs);
bencher.iter(|| {
Expand Down Expand Up @@ -156,11 +158,7 @@ fn bench_process_compute_budget_instructions_mixed(c: &mut Criterion) {
ComputeBudgetInstruction::set_compute_unit_limit(u32::MAX),
ComputeBudgetInstruction::set_compute_unit_price(u64::MAX),
ComputeBudgetInstruction::set_loaded_accounts_data_size_limit(u32::MAX),
system_instruction::transfer(
&payer_keypair.pubkey(),
&Pubkey::new_unique(),
1,
),
transfer(&payer_keypair.pubkey(), &Pubkey::new_unique(), 1),
]);
let tx = build_sanitized_transaction(&payer_keypair, &ixs);

Expand Down
17 changes: 9 additions & 8 deletions compute-budget-instruction/src/builtin_programs_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use {
solana_builtins_default_costs::{
get_builtin_migration_feature_index, BuiltinMigrationFeatureIndex, MAYBE_BUILTIN_KEY,
},
solana_sdk::{packet::PACKET_DATA_SIZE, pubkey::Pubkey},
solana_packet::PACKET_DATA_SIZE,
solana_pubkey::Pubkey,
};

// The maximum number of pubkeys that a packet can contain.
Expand Down Expand Up @@ -64,7 +65,7 @@ impl BuiltinProgramsFilter {
mod test {
use {
super::*, solana_builtins_default_costs::get_migration_feature_position,
solana_sdk::feature_set,
solana_feature_set as feature_set,
};

const DUMMY_PROGRAM_ID: &str = "dummmy1111111111111111111111111111111111111";
Expand All @@ -90,36 +91,36 @@ mod test {
// lookup same `index` will return cached data, will not lookup `program_id`
// again
assert_eq!(
test_store.get_program_kind(index, &solana_sdk::loader_v4::id()),
test_store.get_program_kind(index, &solana_sdk_ids::loader_v4::id()),
ProgramKind::NotBuiltin
);

// not-migrating builtin
index += 1;
assert_eq!(
test_store.get_program_kind(index, &solana_sdk::loader_v4::id()),
test_store.get_program_kind(index, &solana_sdk_ids::loader_v4::id()),
ProgramKind::Builtin,
);

// compute-budget
index += 1;
assert_eq!(
test_store.get_program_kind(index, &solana_sdk::compute_budget::id()),
test_store.get_program_kind(index, &solana_sdk_ids::compute_budget::id()),
ProgramKind::Builtin,
);

// migrating builtins
for (migrating_builtin_pubkey, migration_feature_id) in [
(
solana_sdk::stake::program::id(),
solana_sdk_ids::stake::id(),
feature_set::migrate_stake_program_to_core_bpf::id(),
),
(
solana_sdk::config::program::id(),
solana_sdk_ids::config::id(),
feature_set::migrate_config_program_to_core_bpf::id(),
),
(
solana_sdk::address_lookup_table::program::id(),
solana_sdk_ids::address_lookup_table::id(),
feature_set::migrate_address_lookup_table_program_to_core_bpf::id(),
),
] {
Expand Down
Loading

0 comments on commit b70cac3

Please sign in to comment.