Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove solana-sdk from program-runtime #3924

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Cargo.lock

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

29 changes: 25 additions & 4 deletions program-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,46 @@ 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",
] }
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]
Expand All @@ -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
64 changes: 29 additions & 35 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,33 @@ 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},
memory_region::MemoryMapping,
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,
Expand Down Expand Up @@ -66,7 +62,7 @@ macro_rules! declare_process_instruction {
) -> std::result::Result<u64, Box<dyn std::error::Error>> {
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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions program-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
15 changes: 7 additions & 8 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -1311,7 +1309,7 @@ impl<FG: ForkGraph> ProgramCache<FG> {
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);
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion program-runtime/src/stable_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down
24 changes: 13 additions & 11 deletions program-runtime/src/sysvar_cache.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down
17 changes: 16 additions & 1 deletion programs/sbf/Cargo.lock

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

Loading
Loading