diff --git a/Cargo.lock b/Cargo.lock index f363dbfc0e5cc8..6755758427954f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8001,16 +8001,31 @@ dependencies = [ "percentage", "rand 0.8.5", "serde", + "solana-account", + "solana-clock", "solana-compute-budget", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-feature-set", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-hash", + "solana-instruction", + "solana-last-restart-slot", "solana-log-collector", "solana-logger", "solana-measure", "solana-metrics", - "solana-sdk", + "solana-precompiles", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-slot-hashes", + "solana-stable-layout", + "solana-sysvar", + "solana-sysvar-id", "solana-timings", + "solana-transaction-context", "solana-type-overrides", "solana_rbpf", "test-case", diff --git a/program-runtime/Cargo.toml b/program-runtime/Cargo.toml index b3a6228cee1be7..0cb6a7207b6af8 100644 --- a/program-runtime/Cargo.toml +++ b/program-runtime/Cargo.toml @@ -21,7 +21,11 @@ num-traits = { workspace = true } percentage = { workspace = true } rand = { workspace = true } serde = { workspace = true } +solana-account = { workspace = true, features = ["bincode"] } +solana-clock = { workspace = true } solana-compute-budget = { workspace = true } +solana-epoch-rewards = { workspace = true } +solana-epoch-schedule = { workspace = true } solana-feature-set = { workspace = true } solana-frozen-abi = { workspace = true, optional = true, features = [ "frozen-abi", @@ -29,19 +33,34 @@ solana-frozen-abi = { workspace = true, optional = true, features = [ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } +solana-hash = { workspace = true } +solana-instruction = { workspace = true } +solana-last-restart-slot = { workspace = true } solana-log-collector = { workspace = true } solana-measure = { workspace = true } solana-metrics = { workspace = true } -solana-sdk = { workspace = true } +solana-precompiles = { workspace = true } +solana-pubkey = { workspace = true } +solana-rent = { workspace = true } +solana-sdk-ids = { workspace = true } +solana-slot-hashes = { workspace = true } +solana-stable-layout = { workspace = true } +solana-sysvar = { workspace = true } +solana-sysvar-id = { workspace = true } solana-timings = { workspace = true } +solana-transaction-context = { workspace = true } solana-type-overrides = { workspace = true } solana_rbpf = { workspace = true } thiserror = { workspace = true } [dev-dependencies] assert_matches = { workspace = true } +solana-instruction = { workspace = true, features = ["bincode"] } solana-logger = { workspace = true } -solana-sdk = { workspace = true, features = ["dev-context-only-utils"] } +solana-pubkey = { workspace = true, features = ["rand"] } +solana-transaction-context = { workspace = true, features = [ + "dev-context-only-utils", +] } test-case = { workspace = true } [lib] @@ -56,9 +75,11 @@ frozen-abi = [ "dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "solana-compute-budget/frozen-abi", - "solana-sdk/frozen-abi", ] -shuttle-test = ["solana-type-overrides/shuttle-test", "solana_rbpf/shuttle-test"] +shuttle-test = [ + "solana-type-overrides/shuttle-test", + "solana_rbpf/shuttle-test", +] [lints] workspace = true diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index 43ac22cc26290d..db6486a6194dd6 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -7,13 +7,20 @@ use { stable_log, sysvar_cache::SysvarCache, }, + solana_account::{create_account_shared_data_for_test, AccountSharedData}, + solana_clock::Slot, solana_compute_budget::compute_budget::ComputeBudget, + solana_epoch_schedule::EpochSchedule, solana_feature_set::{ lift_cpi_caller_restriction, move_precompile_verification_to_svm, remove_accounts_executable_flag_checks, FeatureSet, }, + solana_hash::Hash, + solana_instruction::{error::InstructionError, AccountMeta}, solana_log_collector::{ic_msg, LogCollector}, solana_measure::measure::Measure, + solana_precompiles::Precompile, + solana_pubkey::Pubkey, solana_rbpf::{ ebpf::MM_HEAP_START, error::{EbpfError, ProgramResult}, @@ -21,23 +28,12 @@ use { program::{BuiltinFunction, SBPFVersion}, vm::{Config, ContextObject, EbpfVm}, }, - solana_sdk::{ - account::{create_account_shared_data_for_test, AccountSharedData}, - bpf_loader_deprecated, - clock::Slot, - epoch_schedule::EpochSchedule, - hash::Hash, - instruction::{AccountMeta, InstructionError}, - native_loader, - precompiles::Precompile, - pubkey::Pubkey, - stable_layout::stable_instruction::StableInstruction, - sysvar, - transaction_context::{ - IndexOfAccount, InstructionAccount, TransactionAccount, TransactionContext, - }, - }, + solana_sdk_ids::{bpf_loader_deprecated, native_loader, sysvar}, + solana_stable_layout::stable_instruction::StableInstruction, solana_timings::{ExecuteDetailsTimings, ExecuteTimings}, + solana_transaction_context::{ + IndexOfAccount, InstructionAccount, TransactionAccount, TransactionContext, + }, solana_type_overrides::sync::{atomic::Ordering, Arc}, std::{ alloc::Layout, @@ -66,7 +62,7 @@ macro_rules! declare_process_instruction { ) -> std::result::Result> { fn process_instruction_inner( $invoke_context: &mut $crate::invoke_context::InvokeContext, - ) -> std::result::Result<(), solana_sdk::instruction::InstructionError> + ) -> std::result::Result<(), $crate::__private::InstructionError> $inner let consumption_result = if $cu_to_consume > 0 @@ -299,7 +295,7 @@ impl<'a> InvokeContext<'a> { } /// Current height of the invocation stack, top level instructions are height - /// `solana_sdk::instruction::TRANSACTION_LEVEL_STACK_HEIGHT` + /// `solana_instruction::TRANSACTION_LEVEL_STACK_HEIGHT` pub fn get_stack_height(&self) -> usize { self.transaction_context .get_instruction_context_stack_height() @@ -723,12 +719,9 @@ macro_rules! with_mock_invoke_context { solana_compute_budget::compute_budget::ComputeBudget, solana_feature_set::FeatureSet, solana_log_collector::LogCollector, - solana_sdk::{ - account::ReadableAccount, hash::Hash, sysvar::rent::Rent, - transaction_context::TransactionContext, - }, solana_type_overrides::sync::Arc, $crate::{ + __private::{Hash, ReadableAccount, Rent, TransactionContext}, invoke_context::{EnvironmentConfig, InvokeContext}, loaded_programs::ProgramCacheForTxBatch, sysvar_cache::SysvarCache, @@ -860,8 +853,10 @@ mod tests { use { super::*, serde::{Deserialize, Serialize}, + solana_account::WritableAccount, solana_compute_budget::compute_budget_limits, - solana_sdk::{account::WritableAccount, instruction::Instruction, rent::Rent}, + solana_instruction::Instruction, + solana_rent::Rent, }; #[derive(Debug, Serialize, Deserialize)] @@ -993,9 +988,9 @@ mod tests { let mut transaction_accounts = vec![]; let mut instruction_accounts = vec![]; for index in 0..one_more_than_max_depth { - invoke_stack.push(solana_sdk::pubkey::new_rand()); + invoke_stack.push(solana_pubkey::new_rand()); transaction_accounts.push(( - solana_sdk::pubkey::new_rand(), + solana_pubkey::new_rand(), AccountSharedData::new(index as u64, 1, invoke_stack.get(index).unwrap()), )); instruction_accounts.push(InstructionAccount { @@ -1009,7 +1004,7 @@ mod tests { for (index, program_id) in invoke_stack.iter().enumerate() { transaction_accounts.push(( *program_id, - AccountSharedData::new(1, 1, &solana_sdk::pubkey::Pubkey::default()), + AccountSharedData::new(1, 1, &solana_pubkey::Pubkey::default()), )); instruction_accounts.push(InstructionAccount { index_in_transaction: index as IndexOfAccount, @@ -1059,19 +1054,19 @@ mod tests { #[test] fn test_process_instruction() { - let callee_program_id = solana_sdk::pubkey::new_rand(); + let callee_program_id = solana_pubkey::new_rand(); let owned_account = AccountSharedData::new(42, 1, &callee_program_id); - let not_owned_account = AccountSharedData::new(84, 1, &solana_sdk::pubkey::new_rand()); - let readonly_account = AccountSharedData::new(168, 1, &solana_sdk::pubkey::new_rand()); + let not_owned_account = AccountSharedData::new(84, 1, &solana_pubkey::new_rand()); + let readonly_account = AccountSharedData::new(168, 1, &solana_pubkey::new_rand()); let loader_account = AccountSharedData::new(0, 1, &native_loader::id()); let mut program_account = AccountSharedData::new(1, 1, &native_loader::id()); program_account.set_executable(true); let transaction_accounts = vec![ - (solana_sdk::pubkey::new_rand(), owned_account), - (solana_sdk::pubkey::new_rand(), not_owned_account), - (solana_sdk::pubkey::new_rand(), readonly_account), + (solana_pubkey::new_rand(), owned_account), + (solana_pubkey::new_rand(), not_owned_account), + (solana_pubkey::new_rand(), readonly_account), (callee_program_id, program_account), - (solana_sdk::pubkey::new_rand(), loader_account), + (solana_pubkey::new_rand(), loader_account), ]; let metas = vec![ AccountMeta::new(transaction_accounts.first().unwrap().0, false), @@ -1183,8 +1178,7 @@ mod tests { #[test] fn test_invoke_context_compute_budget() { - let transaction_accounts = - vec![(solana_sdk::pubkey::new_rand(), AccountSharedData::default())]; + let transaction_accounts = vec![(solana_pubkey::new_rand(), AccountSharedData::default())]; with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts); invoke_context.compute_budget = ComputeBudget::new( diff --git a/program-runtime/src/lib.rs b/program-runtime/src/lib.rs index 3a690d1d0824e9..974ecee64f94d4 100644 --- a/program-runtime/src/lib.rs +++ b/program-runtime/src/lib.rs @@ -11,3 +11,11 @@ pub mod loaded_programs; pub mod mem_pool; pub mod stable_log; pub mod sysvar_cache; +// re-exports for macros +pub mod __private { + pub use { + solana_account::ReadableAccount, solana_hash::Hash, + solana_instruction::error::InstructionError, solana_rent::Rent, + solana_transaction_context::TransactionContext, + }; +} diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index 30ff66f9253bdf..9e11477ea897bb 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -2,19 +2,17 @@ use { crate::invoke_context::{BuiltinFunctionWithContext, InvokeContext}, log::{debug, error, log_enabled, trace}, percentage::PercentageInteger, + solana_clock::{Epoch, Slot}, solana_measure::measure::Measure, + solana_pubkey::Pubkey, solana_rbpf::{ elf::Executable, program::{BuiltinProgram, FunctionRegistry}, verifier::RequisiteVerifier, vm::Config, }, - solana_sdk::{ - bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, - clock::{Epoch, Slot}, - loader_v4, native_loader, - pubkey::Pubkey, - saturating_add_assign, + solana_sdk_ids::{ + bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, loader_v4, native_loader, }, solana_timings::ExecuteDetailsTimings, solana_type_overrides::{ @@ -1311,7 +1309,7 @@ impl ProgramCache { self.stats .evictions .entry(*program) - .and_modify(|c| saturating_add_assign!(*c, 1)) + .and_modify(|c| *c = c.saturating_add(1)) .or_insert(1); *candidate = Arc::new(unloaded); } @@ -1370,8 +1368,9 @@ mod tests { }, assert_matches::assert_matches, percentage::Percentage, + solana_clock::Slot, + solana_pubkey::Pubkey, solana_rbpf::{elf::Executable, program::BuiltinProgram}, - solana_sdk::{clock::Slot, pubkey::Pubkey}, std::{ fs::File, io::Read, diff --git a/program-runtime/src/stable_log.rs b/program-runtime/src/stable_log.rs index 134c7f4f883f59..777247f29e3db0 100644 --- a/program-runtime/src/stable_log.rs +++ b/program-runtime/src/stable_log.rs @@ -6,7 +6,7 @@ use { base64::{prelude::BASE64_STANDARD, Engine}, itertools::Itertools, solana_log_collector::{ic_logger_msg, LogCollector}, - solana_sdk::pubkey::Pubkey, + solana_pubkey::Pubkey, std::{cell::RefCell, rc::Rc}, }; diff --git a/program-runtime/src/sysvar_cache.rs b/program-runtime/src/sysvar_cache.rs index 76496ce9ed69b4..da8746088d0f16 100644 --- a/program-runtime/src/sysvar_cache.rs +++ b/program-runtime/src/sysvar_cache.rs @@ -1,18 +1,20 @@ #[allow(deprecated)] -use solana_sdk::sysvar::{fees::Fees, recent_blockhashes::RecentBlockhashes}; +use solana_sysvar::{fees::Fees, recent_blockhashes::RecentBlockhashes}; use { crate::invoke_context::InvokeContext, serde::de::DeserializeOwned, - solana_sdk::{ - instruction::InstructionError, - pubkey::Pubkey, - sysvar::{ - self, clock::Clock, epoch_rewards::EpochRewards, epoch_schedule::EpochSchedule, - last_restart_slot::LastRestartSlot, rent::Rent, slot_hashes::SlotHashes, - stake_history::StakeHistory, Sysvar, SysvarId, - }, - transaction_context::{IndexOfAccount, InstructionContext, TransactionContext}, - }, + solana_clock::Clock, + solana_epoch_rewards::EpochRewards, + solana_epoch_schedule::EpochSchedule, + solana_instruction::error::InstructionError, + solana_last_restart_slot::LastRestartSlot, + solana_pubkey::Pubkey, + solana_rent::Rent, + solana_sdk_ids::sysvar, + solana_slot_hashes::SlotHashes, + solana_sysvar::{stake_history::StakeHistory, Sysvar}, + solana_sysvar_id::SysvarId, + solana_transaction_context::{IndexOfAccount, InstructionContext, TransactionContext}, solana_type_overrides::sync::Arc, }; diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index c070a768ae951a..872079f4dd9245 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -6303,13 +6303,28 @@ dependencies = [ "percentage", "rand 0.8.5", "serde", + "solana-account", + "solana-clock", "solana-compute-budget", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-feature-set", + "solana-hash", + "solana-instruction", + "solana-last-restart-slot", "solana-log-collector", "solana-measure", "solana-metrics", - "solana-sdk", + "solana-precompiles", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-slot-hashes", + "solana-stable-layout", + "solana-sysvar", + "solana-sysvar-id", "solana-timings", + "solana-transaction-context", "solana-type-overrides", "solana_rbpf", "thiserror 2.0.4", diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 7083e81f14ee3b..e8260c3a279114 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -6123,13 +6123,28 @@ dependencies = [ "percentage", "rand 0.8.5", "serde", + "solana-account", + "solana-clock", "solana-compute-budget", + "solana-epoch-rewards", + "solana-epoch-schedule", "solana-feature-set", + "solana-hash", + "solana-instruction", + "solana-last-restart-slot", "solana-log-collector", "solana-measure", "solana-metrics", - "solana-sdk", + "solana-precompiles", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-slot-hashes", + "solana-stable-layout", + "solana-sysvar", + "solana-sysvar-id", "solana-timings", + "solana-transaction-context", "solana-type-overrides", "solana_rbpf", "thiserror 2.0.4",