From 62eb4cc06899fbdeee30966800abffe89d7272ed Mon Sep 17 00:00:00 2001 From: Joe C Date: Sat, 1 Jun 2024 01:38:19 -0500 Subject: [PATCH] Add Compute Budget Crate (#1121) --- Cargo.lock | 26 ++++++++++++++++--- Cargo.toml | 2 ++ cli/Cargo.toml | 1 + cli/src/compute_budget.rs | 2 +- cli/src/program.rs | 3 ++- cli/src/program_v4.rs | 3 ++- compute-budget/Cargo.toml | 13 ++++++++++ .../src/compute_budget.rs | 8 +++--- .../src/compute_budget_processor.rs | 8 +++--- compute-budget/src/lib.rs | 5 ++++ .../src/prioritization_fee.rs | 0 core/Cargo.toml | 1 + core/src/banking_stage/consumer.rs | 5 ++-- .../scheduler_controller.rs | 2 +- cost-model/Cargo.toml | 3 +-- cost-model/src/cost_model.rs | 11 +++----- ledger-tool/Cargo.toml | 1 + program-runtime/Cargo.toml | 1 + program-runtime/src/invoke_context.rs | 6 ++--- program-runtime/src/lib.rs | 3 --- program-test/Cargo.toml | 1 + program-test/src/lib.rs | 5 ++-- programs/bpf_loader/Cargo.toml | 1 + programs/bpf_loader/src/syscalls/mod.rs | 4 +-- programs/loader-v4/Cargo.toml | 1 + programs/loader-v4/src/lib.rs | 2 +- programs/sbf/Cargo.lock | 19 ++++++++++++-- programs/sbf/Cargo.toml | 2 ++ programs/sbf/benches/bpf_loader.rs | 3 ++- programs/sbf/tests/programs.rs | 7 ++--- programs/stake/Cargo.toml | 1 + programs/system/Cargo.toml | 1 + programs/zk-token-proof-tests/Cargo.toml | 2 +- .../tests/process_transaction.rs | 2 +- runtime-transaction/Cargo.toml | 2 +- .../src/runtime_transaction.rs | 2 +- runtime/Cargo.toml | 1 + runtime/src/bank.rs | 2 +- runtime/src/bank/tests.rs | 8 +++--- runtime/src/compute_budget_details.rs | 10 +++---- svm/Cargo.toml | 1 + svm/src/account_loader.rs | 10 +++---- svm/src/message_processor.rs | 2 +- svm/src/runtime_config.rs | 2 +- svm/src/transaction_processor.rs | 2 +- svm/tests/conformance.rs | 2 +- svm/tests/integration_test.rs | 2 +- test-validator/Cargo.toml | 2 +- test-validator/src/lib.rs | 2 +- 49 files changed, 133 insertions(+), 72 deletions(-) create mode 100644 compute-budget/Cargo.toml rename {program-runtime => compute-budget}/src/compute_budget.rs (97%) rename {program-runtime => compute-budget}/src/compute_budget_processor.rs (98%) create mode 100644 compute-budget/src/lib.rs rename {program-runtime => compute-budget}/src/prioritization_fee.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 8d39238e60eafe..dd605232b38358 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,6 +167,7 @@ dependencies = [ "solana-bpf-loader-program", "solana-clap-utils", "solana-cli-output", + "solana-compute-budget", "solana-core", "solana-cost-model", "solana-entry", @@ -5592,6 +5593,7 @@ dependencies = [ "memoffset 0.9.0", "rand 0.8.5", "scopeguard", + "solana-compute-budget", "solana-measure", "solana-poseidon", "solana-program-runtime", @@ -5741,6 +5743,7 @@ dependencies = [ "solana-cli-config", "solana-cli-output", "solana-client", + "solana-compute-budget", "solana-config-program", "solana-faucet", "solana-loader-v4-program", @@ -5870,6 +5873,13 @@ dependencies = [ "tungstenite", ] +[[package]] +name = "solana-compute-budget" +version = "2.0.0" +dependencies = [ + "solana-sdk", +] + [[package]] name = "solana-compute-budget-program" version = "2.0.0" @@ -5954,6 +5964,7 @@ dependencies = [ "solana-accounts-db", "solana-bloom", "solana-client", + "solana-compute-budget", "solana-core", "solana-cost-model", "solana-entry", @@ -6011,6 +6022,7 @@ dependencies = [ "rustc_version 0.4.0", "solana-address-lookup-table-program", "solana-bpf-loader-program", + "solana-compute-budget", "solana-compute-budget-program", "solana-config-program", "solana-frozen-abi", @@ -6018,7 +6030,6 @@ dependencies = [ "solana-loader-v4-program", "solana-logger", "solana-metrics", - "solana-program-runtime", "solana-sdk", "solana-stake-program", "solana-system-program", @@ -6372,6 +6383,7 @@ version = "2.0.0" dependencies = [ "bincode", "log", + "solana-compute-budget", "solana-measure", "solana-program-runtime", "solana-sdk", @@ -6688,6 +6700,7 @@ dependencies = [ "rand 0.8.5", "rustc_version 0.4.0", "serde", + "solana-compute-budget", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-logger", @@ -6716,6 +6729,7 @@ dependencies = [ "solana-banks-interface", "solana-banks-server", "solana-bpf-loader-program", + "solana-compute-budget", "solana-inline-spl", "solana-logger", "solana-program-runtime", @@ -7015,6 +7029,7 @@ dependencies = [ "solana-address-lookup-table-program", "solana-bpf-loader-program", "solana-bucket-map", + "solana-compute-budget", "solana-compute-budget-program", "solana-config-program", "solana-cost-model", @@ -7057,8 +7072,8 @@ dependencies = [ "log", "rand 0.8.5", "rustc_version 0.4.0", + "solana-compute-budget", "solana-program", - "solana-program-runtime", "solana-sdk", "thiserror", ] @@ -7178,6 +7193,7 @@ dependencies = [ "log", "proptest", "rustc_version 0.4.0", + "solana-compute-budget", "solana-config-program", "solana-logger", "solana-program-runtime", @@ -7298,6 +7314,7 @@ dependencies = [ "serde", "serde_derive", "solana-bpf-loader-program", + "solana-compute-budget", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-loader-v4-program", @@ -7318,6 +7335,7 @@ dependencies = [ "log", "serde", "serde_derive", + "solana-compute-budget", "solana-logger", "solana-program-runtime", "solana-sdk", @@ -7336,13 +7354,13 @@ dependencies = [ "solana-accounts-db", "solana-cli-output", "solana-client", + "solana-compute-budget", "solana-core", "solana-geyser-plugin-manager", "solana-gossip", "solana-ledger", "solana-logger", "solana-net-utils", - "solana-program-runtime", "solana-program-test", "solana-rpc", "solana-rpc-client", @@ -7726,7 +7744,7 @@ version = "2.0.0" dependencies = [ "bytemuck", "curve25519-dalek", - "solana-program-runtime", + "solana-compute-budget", "solana-program-test", "solana-sdk", "solana-zk-token-sdk", diff --git a/Cargo.toml b/Cargo.toml index 271f3ab8793da7..e5b576de033bfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ members = [ "cli-output", "client", "client-test", + "compute-budget", "connection-cache", "core", "cost-model", @@ -328,6 +329,7 @@ solana-cli = { path = "cli", version = "=2.0.0" } solana-cli-config = { path = "cli-config", version = "=2.0.0" } solana-cli-output = { path = "cli-output", version = "=2.0.0" } solana-client = { path = "client", version = "=2.0.0" } +solana-compute-budget = { path = "compute-budget", version = "=2.0.0" } solana-compute-budget-program = { path = "programs/compute-budget", version = "=2.0.0" } solana-config-program = { path = "programs/config", version = "=2.0.0" } solana-connection-cache = { path = "connection-cache", version = "=2.0.0", default-features = false } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index b5e444ba81a00b..2cdf35ecb66d29 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -34,6 +34,7 @@ solana-clap-utils = { workspace = true } solana-cli-config = { workspace = true } solana-cli-output = { workspace = true } solana-client = { workspace = true } +solana-compute-budget = { workspace = true } solana-config-program = { workspace = true } solana-faucet = { workspace = true } solana-loader-v4-program = { workspace = true } diff --git a/cli/src/compute_budget.rs b/cli/src/compute_budget.rs index 799af38403ff45..bd6ffc4671c655 100644 --- a/cli/src/compute_budget.rs +++ b/cli/src/compute_budget.rs @@ -1,6 +1,6 @@ use { solana_client::rpc_config::RpcSimulateTransactionConfig, - solana_program_runtime::compute_budget_processor::MAX_COMPUTE_UNIT_LIMIT, + solana_compute_budget::compute_budget_processor::MAX_COMPUTE_UNIT_LIMIT, solana_rpc_client::rpc_client::RpcClient, solana_sdk::{ borsh1::try_from_slice_unchecked, diff --git a/cli/src/program.rs b/cli/src/program.rs index f499cf36d36c00..df4aa8731bdb69 100644 --- a/cli/src/program.rs +++ b/cli/src/program.rs @@ -38,7 +38,8 @@ use { }, tpu_client::{TpuClient, TpuClientConfig}, }, - solana_program_runtime::{compute_budget::ComputeBudget, invoke_context::InvokeContext}, + solana_compute_budget::compute_budget::ComputeBudget, + solana_program_runtime::invoke_context::InvokeContext, solana_rbpf::{elf::Executable, verifier::RequisiteVerifier}, solana_remote_wallet::remote_wallet::RemoteWalletManager, solana_rpc_client::rpc_client::RpcClient, diff --git a/cli/src/program_v4.rs b/cli/src/program_v4.rs index 7995107d203242..6e81de1f9ff3ae 100644 --- a/cli/src/program_v4.rs +++ b/cli/src/program_v4.rs @@ -23,7 +23,8 @@ use { }, tpu_client::{TpuClient, TpuClientConfig}, }, - solana_program_runtime::{compute_budget::ComputeBudget, invoke_context::InvokeContext}, + solana_compute_budget::compute_budget::ComputeBudget, + solana_program_runtime::invoke_context::InvokeContext, solana_rbpf::{elf::Executable, verifier::RequisiteVerifier}, solana_remote_wallet::remote_wallet::RemoteWalletManager, solana_rpc_client::rpc_client::RpcClient, diff --git a/compute-budget/Cargo.toml b/compute-budget/Cargo.toml new file mode 100644 index 00000000000000..e091c54e1ef136 --- /dev/null +++ b/compute-budget/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "solana-compute-budget" +description = "Solana compute budget" +documentation = "https://docs.rs/solana-compute-budget" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[dependencies] +solana-sdk = { workspace = true } diff --git a/program-runtime/src/compute_budget.rs b/compute-budget/src/compute_budget.rs similarity index 97% rename from program-runtime/src/compute_budget.rs rename to compute-budget/src/compute_budget.rs index 3d4d22facb850e..6b91affca4dd1c 100644 --- a/program-runtime/src/compute_budget.rs +++ b/compute-budget/src/compute_budget.rs @@ -1,5 +1,7 @@ use { - crate::compute_budget_processor::{self, process_compute_budget_instructions}, + crate::compute_budget_processor::{ + self, process_compute_budget_instructions, DEFAULT_HEAP_COST, + }, solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey, transaction::Result}, }; @@ -11,10 +13,6 @@ impl ::solana_frozen_abi::abi_example::AbiExample for ComputeBudget { } } -/// Roughly 0.5us/page, where page is 32K; given roughly 15CU/us, the -/// default heap page cost = 0.5 * 15 ~= 8CU/page -pub const DEFAULT_HEAP_COST: u64 = 8; - #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct ComputeBudget { /// Number of compute units that a transaction or individual instruction is diff --git a/program-runtime/src/compute_budget_processor.rs b/compute-budget/src/compute_budget_processor.rs similarity index 98% rename from program-runtime/src/compute_budget_processor.rs rename to compute-budget/src/compute_budget_processor.rs index f87bbcd6c17fd7..dc568f82f169bb 100644 --- a/program-runtime/src/compute_budget_processor.rs +++ b/compute-budget/src/compute_budget_processor.rs @@ -1,8 +1,5 @@ use { - crate::{ - compute_budget::DEFAULT_HEAP_COST, - prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType}, - }, + crate::prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType}, solana_sdk::{ borsh1::try_from_slice_unchecked, compute_budget::{self, ComputeBudgetInstruction}, @@ -15,6 +12,9 @@ use { }; const MAX_HEAP_FRAME_BYTES: u32 = 256 * 1024; +/// Roughly 0.5us/page, where page is 32K; given roughly 15CU/us, the +/// 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; pub const MAX_COMPUTE_UNIT_LIMIT: u32 = 1_400_000; diff --git a/compute-budget/src/lib.rs b/compute-budget/src/lib.rs new file mode 100644 index 00000000000000..8516457af572d5 --- /dev/null +++ b/compute-budget/src/lib.rs @@ -0,0 +1,5 @@ +//! Solana compute budget types and default configurations. + +pub mod compute_budget; +pub mod compute_budget_processor; +pub mod prioritization_fee; diff --git a/program-runtime/src/prioritization_fee.rs b/compute-budget/src/prioritization_fee.rs similarity index 100% rename from program-runtime/src/prioritization_fee.rs rename to compute-budget/src/prioritization_fee.rs diff --git a/core/Cargo.toml b/core/Cargo.toml index e7b95a014cd809..331c29850fea8d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -45,6 +45,7 @@ serde_derive = { workspace = true } solana-accounts-db = { workspace = true } solana-bloom = { workspace = true } solana-client = { workspace = true } +solana-compute-budget = { workspace = true } solana-cost-model = { workspace = true } solana-entry = { workspace = true } solana-frozen-abi = { workspace = true, optional = true } diff --git a/core/src/banking_stage/consumer.rs b/core/src/banking_stage/consumer.rs index bc965b781f1d4e..fbe47a901a964f 100644 --- a/core/src/banking_stage/consumer.rs +++ b/core/src/banking_stage/consumer.rs @@ -9,15 +9,14 @@ use { BankingStageStats, }, itertools::Itertools, + solana_compute_budget::compute_budget_processor::process_compute_budget_instructions, solana_ledger::token_balances::collect_token_balances, solana_measure::{measure::Measure, measure_us}, solana_poh::poh_recorder::{ BankStart, PohRecorderError, RecordTransactionsSummary, RecordTransactionsTimings, TransactionRecorder, }, - solana_program_runtime::{ - compute_budget_processor::process_compute_budget_instructions, timings::ExecuteTimings, - }, + solana_program_runtime::timings::ExecuteTimings, solana_runtime::{ bank::{Bank, LoadAndExecuteTransactionsOutput}, compute_budget_details::GetComputeBudgetDetails, diff --git a/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs b/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs index 2d3879843e38e9..57a52f58a5c1cc 100644 --- a/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs +++ b/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs @@ -22,9 +22,9 @@ use { ForwardOption, TOTAL_BUFFERED_PACKETS, }, crossbeam_channel::RecvTimeoutError, + solana_compute_budget::compute_budget_processor::process_compute_budget_instructions, solana_cost_model::cost_model::CostModel, solana_measure::measure_us, - solana_program_runtime::compute_budget_processor::process_compute_budget_instructions, solana_runtime::{bank::Bank, bank_forks::BankForks}, solana_sdk::{ self, diff --git a/cost-model/Cargo.toml b/cost-model/Cargo.toml index ca4c5c5e386919..281d0107b019a6 100644 --- a/cost-model/Cargo.toml +++ b/cost-model/Cargo.toml @@ -15,13 +15,13 @@ lazy_static = { workspace = true } log = { workspace = true } solana-address-lookup-table-program = { workspace = true } solana-bpf-loader-program = { workspace = true } +solana-compute-budget = { workspace = true } solana-compute-budget-program = { workspace = true } solana-config-program = { workspace = true } solana-frozen-abi = { workspace = true, optional = true } solana-frozen-abi-macro = { workspace = true, optional = true } solana-loader-v4-program = { workspace = true } solana-metrics = { workspace = true } -solana-program-runtime = { workspace = true } solana-sdk = { workspace = true } solana-stake-program = { workspace = true } solana-system-program = { workspace = true } @@ -48,7 +48,6 @@ rustc_version = { workspace = true } frozen-abi = [ "dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", - "solana-program-runtime/frozen-abi", "solana-sdk/frozen-abi", "solana-vote-program/frozen-abi", ] diff --git a/cost-model/src/cost_model.rs b/cost-model/src/cost_model.rs index fa12a7343bc7e0..561850089f8946 100644 --- a/cost-model/src/cost_model.rs +++ b/cost-model/src/cost_model.rs @@ -8,12 +8,9 @@ use { crate::{block_cost_limits::*, transaction_cost::*}, log::*, - solana_program_runtime::{ - compute_budget::DEFAULT_HEAP_COST, - compute_budget_processor::{ - process_compute_budget_instructions, DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT, - MAX_COMPUTE_UNIT_LIMIT, - }, + solana_compute_budget::compute_budget_processor::{ + process_compute_budget_instructions, DEFAULT_HEAP_COST, + DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT, MAX_COMPUTE_UNIT_LIMIT, }, solana_sdk::{ borsh1::try_from_slice_unchecked, @@ -571,7 +568,7 @@ mod tests { // default loaded_accounts_data_size_limit const DEFAULT_PAGE_COST: u64 = 8; let expected_loaded_accounts_data_size_cost = - solana_program_runtime::compute_budget_processor::MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES + solana_compute_budget::compute_budget_processor::MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES as u64 / ACCOUNT_DATA_COST_PAGE_SIZE * DEFAULT_PAGE_COST; diff --git a/ledger-tool/Cargo.toml b/ledger-tool/Cargo.toml index 27e1cf2238d753..351aa44462cf1e 100644 --- a/ledger-tool/Cargo.toml +++ b/ledger-tool/Cargo.toml @@ -31,6 +31,7 @@ solana-accounts-db = { workspace = true } solana-bpf-loader-program = { workspace = true } solana-clap-utils = { workspace = true } solana-cli-output = { workspace = true } +solana-compute-budget = { workspace = true } solana-core = { workspace = true } solana-cost-model = { workspace = true } solana-entry = { workspace = true } diff --git a/program-runtime/Cargo.toml b/program-runtime/Cargo.toml index 3bad1a75ee0da4..0ab97f843b6c87 100644 --- a/program-runtime/Cargo.toml +++ b/program-runtime/Cargo.toml @@ -22,6 +22,7 @@ num-traits = { workspace = true } percentage = { workspace = true } rand = { workspace = true } serde = { workspace = true } +solana-compute-budget = { workspace = true } solana-frozen-abi = { workspace = true, optional = true } solana-frozen-abi-macro = { workspace = true, optional = true } solana-measure = { workspace = true } diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index 9aa32a7dca9626..ace5e0de11475f 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -1,6 +1,5 @@ use { crate::{ - compute_budget::ComputeBudget, ic_msg, loaded_programs::{ ProgramCacheEntry, ProgramCacheEntryType, ProgramCacheForTxBatch, @@ -11,6 +10,7 @@ use { sysvar_cache::SysvarCache, timings::{ExecuteDetailsTimings, ExecuteTimings}, }, + solana_compute_budget::compute_budget::ComputeBudget, solana_measure::measure::Measure, solana_rbpf::{ ebpf::MM_HEAP_START, @@ -670,13 +670,13 @@ macro_rules! with_mock_invoke_context { $transaction_accounts:expr $(,)? ) => { use { + solana_compute_budget::compute_budget::ComputeBudget, solana_sdk::{ account::ReadableAccount, feature_set::FeatureSet, hash::Hash, sysvar::rent::Rent, transaction_context::TransactionContext, }, std::sync::Arc, $crate::{ - compute_budget::ComputeBudget, invoke_context::{EnvironmentConfig, InvokeContext}, loaded_programs::ProgramCacheForTxBatch, log_collector::LogCollector, @@ -806,8 +806,8 @@ pub fn mock_process_instruction { fn with_max_compute_unit_limit(mut self) -> Self { self.push( solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_limit( - solana_program_runtime::compute_budget_processor::MAX_COMPUTE_UNIT_LIMIT, + solana_compute_budget::compute_budget_processor::MAX_COMPUTE_UNIT_LIMIT, ), ); self diff --git a/runtime-transaction/Cargo.toml b/runtime-transaction/Cargo.toml index 947da05cc169c2..f6c89438c1ede3 100644 --- a/runtime-transaction/Cargo.toml +++ b/runtime-transaction/Cargo.toml @@ -11,7 +11,7 @@ edition = { workspace = true } [dependencies] log = { workspace = true } -solana-program-runtime = { workspace = true } +solana-compute-budget = { workspace = true } solana-sdk = { workspace = true } thiserror = { workspace = true } diff --git a/runtime-transaction/src/runtime_transaction.rs b/runtime-transaction/src/runtime_transaction.rs index d7fa7da0fbb3f9..625ec28fdb22d8 100644 --- a/runtime-transaction/src/runtime_transaction.rs +++ b/runtime-transaction/src/runtime_transaction.rs @@ -11,7 +11,7 @@ //! with its dynamic metadata loaded. use { crate::transaction_meta::{DynamicMeta, StaticMeta, TransactionMeta}, - solana_program_runtime::compute_budget_processor::{ + solana_compute_budget::compute_budget_processor::{ process_compute_budget_instructions, ComputeBudgetLimits, }, solana_sdk::{ diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index ab3e4d28ce50b0..d36eab44428ffa 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -50,6 +50,7 @@ solana-accounts-db = { workspace = true } solana-address-lookup-table-program = { workspace = true } solana-bpf-loader-program = { workspace = true } solana-bucket-map = { workspace = true } +solana-compute-budget = { workspace = true } solana-compute-budget-program = { workspace = true } solana-config-program = { workspace = true } solana-cost-model = { workspace = true } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index ecee9f9de3be8e..d2218a89ea4d7c 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -89,12 +89,12 @@ use { storable_accounts::StorableAccounts, }, solana_bpf_loader_program::syscalls::create_program_runtime_environment_v1, + solana_compute_budget::compute_budget_processor::process_compute_budget_instructions, solana_cost_model::cost_tracker::CostTracker, solana_loader_v4_program::create_program_runtime_environment_v2, solana_measure::{measure, measure::Measure, measure_us}, solana_perf::perf_libs, solana_program_runtime::{ - compute_budget_processor::process_compute_budget_instructions, invoke_context::BuiltinFunctionWithContext, loaded_programs::{ ProgramCache, ProgramCacheEntry, ProgramCacheEntryOwner, ProgramCacheEntryType, diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index a4e538b128b6dc..ef00d541fd132b 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -33,14 +33,16 @@ use { accounts_partition::{self, PartitionIndex, RentPayingAccountsByPartition}, ancestors::Ancestors, }, + solana_compute_budget::{ + compute_budget::ComputeBudget, + compute_budget_processor::{self, MAX_COMPUTE_UNIT_LIMIT}, + prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType}, + }, solana_inline_spl::token, solana_logger, solana_program_runtime::{ - compute_budget::ComputeBudget, - compute_budget_processor::{self, MAX_COMPUTE_UNIT_LIMIT}, declare_process_instruction, loaded_programs::{ProgramCacheEntry, ProgramCacheEntryType, ProgramCacheForTxBatch}, - prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType}, timings::ExecuteTimings, }, solana_sdk::{ diff --git a/runtime/src/compute_budget_details.rs b/runtime/src/compute_budget_details.rs index 72b10a11b33bcc..c14aa24c063538 100644 --- a/runtime/src/compute_budget_details.rs +++ b/runtime/src/compute_budget_details.rs @@ -1,5 +1,5 @@ use { - solana_program_runtime::compute_budget_processor::process_compute_budget_instructions, + solana_compute_budget::compute_budget_processor::process_compute_budget_instructions, solana_sdk::{ instruction::CompiledInstruction, pubkey::Pubkey, @@ -89,7 +89,7 @@ mod tests { Some(ComputeBudgetDetails { compute_unit_price: 0, compute_unit_limit: - solana_program_runtime::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT + solana_compute_budget::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT as u64, }) ); @@ -101,7 +101,7 @@ mod tests { Some(ComputeBudgetDetails { compute_unit_price: 0, compute_unit_limit: - solana_program_runtime::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT + solana_compute_budget::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT as u64, }) ); @@ -163,7 +163,7 @@ mod tests { Some(ComputeBudgetDetails { compute_unit_price: requested_price, compute_unit_limit: - solana_program_runtime::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT + solana_compute_budget::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT as u64, }) ); @@ -175,7 +175,7 @@ mod tests { Some(ComputeBudgetDetails { compute_unit_price: requested_price, compute_unit_limit: - solana_program_runtime::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT + solana_compute_budget::compute_budget_processor::DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT as u64, }) ); diff --git a/svm/Cargo.toml b/svm/Cargo.toml index b5962c0f214349..11d47aa8eb45e9 100644 --- a/svm/Cargo.toml +++ b/svm/Cargo.toml @@ -16,6 +16,7 @@ percentage = { workspace = true } serde = { workspace = true, features = ["rc"] } serde_derive = { workspace = true } solana-bpf-loader-program = { workspace = true } +solana-compute-budget = { workspace = true } solana-frozen-abi = { workspace = true, optional = true } solana-frozen-abi-macro = { workspace = true, optional = true } solana-loader-v4-program = { workspace = true } diff --git a/svm/src/account_loader.rs b/svm/src/account_loader.rs index c97941d2f2aeff..73b57fc99f37d4 100644 --- a/svm/src/account_loader.rs +++ b/svm/src/account_loader.rs @@ -7,10 +7,8 @@ use { transaction_processing_callback::TransactionProcessingCallback, }, itertools::Itertools, - solana_program_runtime::{ - compute_budget_processor::process_compute_budget_instructions, - loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch}, - }, + solana_compute_budget::compute_budget_processor::process_compute_budget_instructions, + solana_program_runtime::loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch}, solana_sdk::{ account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, feature_set::{ @@ -483,12 +481,12 @@ mod tests { transaction_processing_callback::TransactionProcessingCallback, }, nonce::state::Versions as NonceVersions, - solana_program_runtime::{ + solana_compute_budget::{ compute_budget::ComputeBudget, compute_budget_processor, - loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch}, prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType}, }, + solana_program_runtime::loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch}, solana_sdk::{ account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, bpf_loader_upgradeable, diff --git a/svm/src/message_processor.rs b/svm/src/message_processor.rs index 40c7c778282c89..7b366e82304975 100644 --- a/svm/src/message_processor.rs +++ b/svm/src/message_processor.rs @@ -145,8 +145,8 @@ impl MessageProcessor { mod tests { use { super::*, + solana_compute_budget::compute_budget::ComputeBudget, solana_program_runtime::{ - compute_budget::ComputeBudget, declare_process_instruction, invoke_context::EnvironmentConfig, loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch}, diff --git a/svm/src/runtime_config.rs b/svm/src/runtime_config.rs index 4c56c1b67b607d..7e063bc30e5b5d 100644 --- a/svm/src/runtime_config.rs +++ b/svm/src/runtime_config.rs @@ -1,4 +1,4 @@ -use solana_program_runtime::compute_budget::ComputeBudget; +use solana_compute_budget::compute_budget::ComputeBudget; #[cfg(all(RUSTC_WITH_SPECIALIZATION, feature = "frozen-abi"))] impl ::solana_frozen_abi::abi_example::AbiExample for RuntimeConfig { diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 04b4f76afde80b..98ce311624e422 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -15,10 +15,10 @@ use { log::debug, percentage::Percentage, solana_bpf_loader_program::syscalls::create_program_runtime_environment_v1, + solana_compute_budget::compute_budget::ComputeBudget, solana_loader_v4_program::create_program_runtime_environment_v2, solana_measure::measure::Measure, solana_program_runtime::{ - compute_budget::ComputeBudget, invoke_context::{EnvironmentConfig, InvokeContext}, loaded_programs::{ ForkGraph, ProgramCache, ProgramCacheEntry, ProgramCacheForTxBatch, diff --git a/svm/tests/conformance.rs b/svm/tests/conformance.rs index 8d8675d6728793..c4cacf9d13ca20 100644 --- a/svm/tests/conformance.rs +++ b/svm/tests/conformance.rs @@ -7,8 +7,8 @@ use { lazy_static::lazy_static, prost::Message, solana_bpf_loader_program::syscalls::create_program_runtime_environment_v1, + solana_compute_budget::compute_budget::ComputeBudget, solana_program_runtime::{ - compute_budget::ComputeBudget, loaded_programs::{ProgramCache, ProgramCacheEntry, ProgramRuntimeEnvironments}, solana_rbpf::{ program::{BuiltinProgram, FunctionRegistry}, diff --git a/svm/tests/integration_test.rs b/svm/tests/integration_test.rs index 433b8040a8a218..d4a0aa871b341d 100644 --- a/svm/tests/integration_test.rs +++ b/svm/tests/integration_test.rs @@ -6,8 +6,8 @@ use { SyscallAbort, SyscallGetClockSysvar, SyscallInvokeSignedRust, SyscallLog, SyscallMemcpy, SyscallMemset, SyscallSetReturnData, }, + solana_compute_budget::compute_budget::ComputeBudget, solana_program_runtime::{ - compute_budget::ComputeBudget, invoke_context::InvokeContext, loaded_programs::{ BlockRelation, ForkGraph, ProgramCache, ProgramCacheEntry, ProgramRuntimeEnvironments, diff --git a/test-validator/Cargo.toml b/test-validator/Cargo.toml index 60f299d01e58a0..0068ddbfb2bf0a 100644 --- a/test-validator/Cargo.toml +++ b/test-validator/Cargo.toml @@ -19,13 +19,13 @@ serde_json = { workspace = true } solana-accounts-db = { workspace = true } solana-cli-output = { workspace = true } solana-client = { workspace = true } +solana-compute-budget = { workspace = true } solana-core = { workspace = true } solana-geyser-plugin-manager = { workspace = true } solana-gossip = { workspace = true } solana-ledger = { workspace = true } solana-logger = { workspace = true } solana-net-utils = { workspace = true } -solana-program-runtime = { workspace = true } solana-program-test = { workspace = true } solana-rpc = { workspace = true } solana-rpc-client = { workspace = true } diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index 90edff8d36ff7c..1394244028f5b9 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -10,6 +10,7 @@ use { }, solana_cli_output::CliAccount, solana_client::rpc_request::MAX_MULTIPLE_ACCOUNTS, + solana_compute_budget::compute_budget::ComputeBudget, solana_core::{ admin_rpc_post_init::AdminRpcRequestMetadataPostInit, consensus::tower_storage::TowerStorage, @@ -29,7 +30,6 @@ use { create_new_tmp_ledger, }, solana_net_utils::PortRange, - solana_program_runtime::compute_budget::ComputeBudget, solana_rpc::{rpc::JsonRpcConfig, rpc_pubsub_service::PubSubConfig}, solana_rpc_client::{nonblocking, rpc_client::RpcClient}, solana_runtime::{