Skip to content

Commit 3deac72

Browse files
authored
minimize solana-sdk usage in svm/src (#4172)
* minimize solana-sdk usage in svm/src * add back type aliases * missing import
1 parent ee31e31 commit 3deac72

16 files changed

+270
-182
lines changed

Cargo.lock

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

programs/sbf/Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

svm/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,42 @@ percentage = { workspace = true }
1717
qualifier_attr = { workspace = true, optional = true }
1818
serde = { workspace = true, features = ["rc"] }
1919
serde_derive = { workspace = true }
20+
solana-account = { workspace = true }
2021
solana-bpf-loader-program = { workspace = true }
22+
solana-clock = { workspace = true }
2123
solana-compute-budget = { workspace = true }
2224
solana-compute-budget-instruction = { workspace = true }
2325
solana-feature-set = { workspace = true }
2426
solana-fee = { workspace = true }
27+
solana-fee-structure = { workspace = true }
2528
solana-frozen-abi = { workspace = true, optional = true, features = [
2629
"frozen-abi",
2730
] }
2831
solana-frozen-abi-macro = { workspace = true, optional = true, features = [
2932
"frozen-abi",
3033
] }
34+
solana-hash = { workspace = true }
35+
solana-instruction = { workspace = true, features = ["std"] }
36+
solana-instructions-sysvar = { workspace = true }
3137
solana-loader-v4-program = { workspace = true }
3238
solana-log-collector = { workspace = true }
3339
solana-measure = { workspace = true }
40+
solana-message = { workspace = true }
41+
solana-nonce = { workspace = true }
42+
solana-precompiles = { workspace = true }
43+
solana-program = { workspace = true, default-features = false }
3444
solana-program-runtime = { workspace = true }
45+
solana-pubkey = { workspace = true }
46+
solana-rent = { workspace = true }
47+
solana-rent-debits = { workspace = true }
3548
solana-sdk = { workspace = true }
49+
solana-sdk-ids = { workspace = true }
3650
solana-svm-rent-collector = { workspace = true }
3751
solana-svm-transaction = { workspace = true }
3852
solana-system-program = { workspace = true }
3953
solana-timings = { workspace = true }
54+
solana-transaction-context = { workspace = true }
55+
solana-transaction-error = { workspace = true }
4056
solana-type-overrides = { workspace = true }
4157
thiserror = { workspace = true }
4258

@@ -54,15 +70,30 @@ openssl = { workspace = true }
5470
prost = { workspace = true }
5571
rand0-7 = { workspace = true }
5672
shuttle = { workspace = true }
73+
solana-clock = { workspace = true }
74+
solana-compute-budget-interface = { workspace = true }
5775
solana-compute-budget-program = { workspace = true }
5876
solana-ed25519-program = { workspace = true }
77+
solana-epoch-schedule = { workspace = true }
78+
solana-fee-calculator = { workspace = true }
79+
solana-keypair = { workspace = true }
5980
solana-logger = { workspace = true }
81+
solana-native-token = { workspace = true }
82+
solana-pubkey = { workspace = true }
83+
solana-rent = { workspace = true }
84+
solana-reserved-account-keys = { workspace = true }
6085
solana-sbpf = { workspace = true }
6186
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
87+
solana-secp256k1-program = { workspace = true }
6288
solana-secp256r1-program = { workspace = true, features = ["openssl-vendored"] }
89+
solana-signature = { workspace = true }
90+
solana-signer = { workspace = true }
6391
# See order-crates-for-publishing.py for using this unusual `path = "."`
6492
solana-svm = { path = ".", features = ["dev-context-only-utils"] }
6593
solana-svm-conformance = { workspace = true }
94+
solana-system-transaction = { workspace = true }
95+
solana-sysvar = { workspace = true }
96+
solana-transaction = { workspace = true }
6697
test-case = { workspace = true }
6798

6899
[package.metadata.docs.rs]

svm/examples/Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

svm/src/account_loader.rs

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ use {
88
transaction_processing_callback::{AccountState, TransactionProcessingCallback},
99
},
1010
ahash::{AHashMap, AHashSet},
11+
solana_account::{
12+
Account, AccountSharedData, ReadableAccount, WritableAccount, PROGRAM_OWNERS,
13+
},
1114
solana_compute_budget::compute_budget_limits::ComputeBudgetLimits,
1215
solana_feature_set::{self as feature_set, FeatureSet},
16+
solana_fee_structure::FeeDetails,
17+
solana_instruction::{BorrowedAccountMeta, BorrowedInstruction},
18+
solana_instructions_sysvar::construct_instructions_data,
19+
solana_nonce::state::State as NonceState,
1320
solana_program_runtime::loaded_programs::ProgramCacheForTxBatch,
14-
solana_sdk::{
15-
account::{Account, AccountSharedData, ReadableAccount, WritableAccount, PROGRAM_OWNERS},
16-
fee::FeeDetails,
21+
solana_pubkey::Pubkey,
22+
solana_rent::RentDue,
23+
solana_rent_debits::RentDebits,
24+
solana_sdk::rent_collector::{CollectedInfo, RENT_EXEMPT_RENT_EPOCH},
25+
solana_sdk_ids::{
1726
native_loader,
18-
nonce::State as NonceState,
19-
pubkey::Pubkey,
20-
rent::RentDue,
21-
rent_collector::{CollectedInfo, RENT_EXEMPT_RENT_EPOCH},
22-
rent_debits::RentDebits,
23-
sysvar::{
24-
self,
25-
instructions::{construct_instructions_data, BorrowedAccountMeta, BorrowedInstruction},
26-
slot_history,
27-
},
28-
transaction::{Result, TransactionError},
29-
transaction_context::{IndexOfAccount, TransactionAccount},
27+
sysvar::{self, slot_history},
3028
},
3129
solana_svm_rent_collector::svm_rent_collector::SVMRentCollector,
3230
solana_svm_transaction::svm_message::SVMMessage,
3331
solana_system_program::{get_system_account_kind, SystemAccountKind},
32+
solana_transaction_context::{IndexOfAccount, TransactionAccount},
33+
solana_transaction_error::{TransactionError, TransactionResult as Result},
3434
std::{
3535
collections::HashMap,
3636
num::{NonZeroU32, Saturating},
@@ -580,7 +580,7 @@ fn load_transaction_account<CB: TransactionProcessingCallback>(
580580
) -> LoadedTransactionAccount {
581581
let usage_pattern = AccountUsagePattern::new(message, account_index);
582582

583-
let loaded_account = if solana_sdk::sysvar::instructions::check_id(account_key) {
583+
let loaded_account = if solana_sdk_ids::sysvar::instructions::check_id(account_key) {
584584
// Since the instructions sysvar is constructed by the SVM and modified
585585
// for each transaction instruction, it cannot be loaded.
586586
LoadedTransactionAccount {
@@ -697,38 +697,40 @@ mod tests {
697697
transaction_account_state_info::TransactionAccountStateInfo,
698698
transaction_processing_callback::TransactionProcessingCallback,
699699
},
700-
nonce::state::Versions as NonceVersions,
700+
solana_account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
701701
solana_compute_budget::{compute_budget::ComputeBudget, compute_budget_limits},
702+
solana_epoch_schedule::EpochSchedule,
702703
solana_feature_set::FeatureSet,
704+
solana_hash::Hash,
705+
solana_instruction::{AccountMeta, Instruction},
706+
solana_keypair::Keypair,
707+
solana_message::{
708+
compiled_instruction::CompiledInstruction,
709+
v0::{LoadedAddresses, LoadedMessage},
710+
LegacyMessage, Message, MessageHeader, SanitizedMessage,
711+
},
712+
solana_native_token::{sol_to_lamports, LAMPORTS_PER_SOL},
713+
solana_nonce::{self as nonce, versions::Versions as NonceVersions},
714+
solana_program::bpf_loader_upgradeable::UpgradeableLoaderState,
703715
solana_program_runtime::loaded_programs::{
704716
ProgramCacheEntry, ProgramCacheEntryOwner, ProgramCacheEntryType,
705717
ProgramCacheForTxBatch,
706718
},
719+
solana_pubkey::Pubkey,
720+
solana_rent::Rent,
721+
solana_rent_debits::RentDebits,
722+
solana_reserved_account_keys::ReservedAccountKeys,
707723
solana_sbpf::program::BuiltinProgram,
708-
solana_sdk::{
709-
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
710-
bpf_loader,
711-
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
712-
epoch_schedule::EpochSchedule,
713-
hash::Hash,
714-
instruction::{AccountMeta, CompiledInstruction, Instruction},
715-
message::{
716-
v0::{LoadedAddresses, LoadedMessage},
717-
LegacyMessage, Message, MessageHeader, SanitizedMessage,
718-
},
719-
native_loader,
720-
native_token::{sol_to_lamports, LAMPORTS_PER_SOL},
721-
nonce,
722-
pubkey::Pubkey,
723-
rent::Rent,
724-
rent_collector::{RentCollector, RENT_EXEMPT_RENT_EPOCH},
725-
rent_debits::RentDebits,
726-
reserved_account_keys::ReservedAccountKeys,
727-
signature::{Keypair, Signature, Signer},
728-
system_program, system_transaction, sysvar,
729-
transaction::{Result, SanitizedTransaction, Transaction, TransactionError},
730-
transaction_context::{TransactionAccount, TransactionContext},
724+
solana_sdk::rent_collector::{RentCollector, RENT_EXEMPT_RENT_EPOCH},
725+
solana_sdk_ids::{
726+
bpf_loader, bpf_loader_upgradeable, native_loader, system_program, sysvar,
731727
},
728+
solana_signature::Signature,
729+
solana_signer::Signer,
730+
solana_system_transaction::transfer,
731+
solana_transaction::{sanitized::SanitizedTransaction, Transaction},
732+
solana_transaction_context::{TransactionAccount, TransactionContext},
733+
solana_transaction_error::{TransactionError, TransactionResult as Result},
732734
std::{borrow::Cow, cell::RefCell, collections::HashMap, fs::File, io::Read, sync::Arc},
733735
};
734736

@@ -1134,12 +1136,12 @@ mod tests {
11341136
#[test]
11351137
fn test_instructions() {
11361138
solana_logger::setup();
1137-
let instructions_key = solana_sdk::sysvar::instructions::id();
1139+
let instructions_key = solana_sdk_ids::sysvar::instructions::id();
11381140
let keypair = Keypair::new();
11391141
let instructions = vec![CompiledInstruction::new(1, &(), vec![0, 1])];
11401142
let tx = Transaction::new_with_compiled_instructions(
11411143
&[&keypair],
1142-
&[solana_sdk::pubkey::new_rand(), instructions_key],
1144+
&[solana_pubkey::new_rand(), instructions_key],
11431145
Hash::default(),
11441146
vec![native_loader::id()],
11451147
instructions,
@@ -1364,7 +1366,7 @@ mod tests {
13641366
#[test]
13651367
fn test_construct_instructions_account() {
13661368
let loaded_message = LoadedMessage {
1367-
message: Cow::Owned(solana_sdk::message::v0::Message::default()),
1369+
message: Cow::Owned(solana_message::v0::Message::default()),
13681370
loaded_addresses: Cow::Owned(LoadedAddresses::default()),
13691371
is_writable_account_cache: vec![false],
13701372
};
@@ -2095,7 +2097,7 @@ mod tests {
20952097
.insert(recipient, AccountSharedData::default());
20962098
let mut account_loader = (&bank).into();
20972099

2098-
let tx = system_transaction::transfer(
2100+
let tx = transfer(
20992101
&mint_keypair,
21002102
&recipient,
21012103
sol_to_lamports(1.),
@@ -2471,7 +2473,7 @@ mod tests {
24712473
let program1 = program1_keypair.pubkey();
24722474
let program2 = Pubkey::new_unique();
24732475
let programdata2 = Pubkey::new_unique();
2474-
use solana_sdk::account_utils::StateMut;
2476+
use solana_account::state_traits::StateMut;
24752477

24762478
let program2_size = std::mem::size_of::<UpgradeableLoaderState>() as u32;
24772479
let mut program2_account = AccountSharedData::default();

svm/src/account_overrides.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use {
2-
solana_sdk::{account::AccountSharedData, pubkey::Pubkey, sysvar},
2+
solana_account::AccountSharedData, solana_pubkey::Pubkey, solana_sdk_ids::sysvar,
33
std::collections::HashMap,
44
};
55

@@ -36,8 +36,8 @@ impl AccountOverrides {
3636
#[cfg(test)]
3737
mod test {
3838
use {
39-
crate::account_overrides::AccountOverrides,
40-
solana_sdk::{account::AccountSharedData, pubkey::Pubkey, sysvar},
39+
crate::account_overrides::AccountOverrides, solana_account::AccountSharedData,
40+
solana_pubkey::Pubkey, solana_sdk_ids::sysvar,
4141
};
4242

4343
#[test]

0 commit comments

Comments
 (0)