Skip to content

Commit

Permalink
Deprecate solana_program::sdk_ids module
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Apr 13, 2024
1 parent 09241ae commit 96aebf6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
10 changes: 5 additions & 5 deletions ledger/src/transaction_address_lookup_table_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use {
solana_sdk::{
address_lookup_table::{self, instruction::ProgramInstruction},
pubkey::Pubkey,
sdk_ids::SDK_IDS,
reserved_account_keys::ReservedAccountKeys,
transaction::SanitizedVersionedTransaction,
},
std::collections::HashSet,
};

lazy_static! {
static ref SDK_IDS_SET: HashSet<Pubkey> = SDK_IDS.iter().cloned().collect();
static ref RESERVED_IDS_SET: HashSet<Pubkey> = ReservedAccountKeys::new_all_activated().active;
}

pub struct ScannedLookupTableExtensions {
Expand All @@ -24,7 +24,7 @@ pub fn scan_transaction(
) -> ScannedLookupTableExtensions {
// Accumulate accounts from account lookup table extension instructions
let mut accounts = Vec::new();
let mut native_only = true;
let mut no_user_programs = true;
for (program_id, instruction) in transaction.get_message().program_instructions_iter() {
if address_lookup_table::program::check_id(program_id) {
if let Ok(ProgramInstruction::ExtendLookupTable { new_addresses }) =
Expand All @@ -33,12 +33,12 @@ pub fn scan_transaction(
accounts.extend(new_addresses);
}
} else {
native_only &= SDK_IDS_SET.contains(program_id);
no_user_programs &= RESERVED_IDS_SET.contains(program_id);
}
}

ScannedLookupTableExtensions {
possibly_incomplete: !native_only,
possibly_incomplete: !no_user_programs,
accounts,
}
}
26 changes: 6 additions & 20 deletions runtime/src/snapshot_minimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use {
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::Slot,
pubkey::Pubkey,
sdk_ids,
reserved_account_keys::ReservedAccountKeys,
},
std::{
collections::HashSet,
Expand Down Expand Up @@ -60,9 +60,8 @@ impl<'a> SnapshotMinimizer<'a> {

minimizer.add_accounts(Self::get_active_bank_features, "active bank features");
minimizer.add_accounts(Self::get_inactive_bank_features, "inactive bank features");
minimizer.add_accounts(Self::get_builtins, "builtin accounts");
minimizer.add_accounts(Self::get_static_runtime_accounts, "static runtime accounts");
minimizer.add_accounts(Self::get_sdk_accounts, "sdk accounts");
minimizer.add_accounts(Self::get_reserved_accounts, "reserved accounts");

minimizer.add_accounts(
Self::get_rent_collection_accounts,
Expand Down Expand Up @@ -109,31 +108,18 @@ impl<'a> SnapshotMinimizer<'a> {
});
}

/// Used to get builtin accounts in `minimize`
fn get_builtins(&self) {
self.bank
.get_transaction_processor()
.builtin_program_ids
.read()
.unwrap()
.iter()
.for_each(|program_id| {
self.minimized_account_set.insert(*program_id);
});
}

/// Used to get static runtime accounts in `minimize`
fn get_static_runtime_accounts(&self) {
static_ids::STATIC_IDS.iter().for_each(|pubkey| {
self.minimized_account_set.insert(*pubkey);
});
}

/// Used to get sdk accounts in `minimize`
fn get_sdk_accounts(&self) {
sdk_ids::SDK_IDS.iter().for_each(|pubkey| {
/// Used to get reserved accounts in `minimize`
fn get_reserved_accounts(&self) {
ReservedAccountKeys::all_keys_iter().for_each(|pubkey| {
self.minimized_account_set.insert(*pubkey);
});
})
}

/// Used to get rent collection accounts in `minimize`
Expand Down
4 changes: 4 additions & 0 deletions sdk/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ pub mod config {
}

/// A vector of Solana SDK IDs.
#[deprecated(
since = "2.0.0",
note = "Please use `solana_sdk::reserved_account_keys::ReservedAccountKeys` instead"
)]
pub mod sdk_ids {
use {
crate::{
Expand Down
10 changes: 5 additions & 5 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ extern crate self as solana_sdk;

#[cfg(feature = "full")]
pub use signer::signers;
// These solana_program imports could be *-imported, but that causes a bunch of
// confusing duplication in the docs due to a rustdoc bug. #26211
#[allow(deprecated)]
pub use solana_program::address_lookup_table_account;
#[cfg(not(target_os = "solana"))]
pub use solana_program::program_stubs;
// These solana_program imports could be *-imported, but that causes a bunch of
// confusing duplication in the docs due to a rustdoc bug. #26211
pub use solana_program::{
account_info, address_lookup_table, alt_bn128, big_mod_exp, blake3, borsh, borsh0_10, borsh0_9,
borsh1, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, clock, config,
Expand All @@ -51,11 +49,13 @@ pub use solana_program::{
fee_calculator, impl_sysvar_get, incinerator, instruction, keccak, lamports,
loader_instruction, loader_upgradeable_instruction, loader_v4, loader_v4_instruction, message,
msg, native_token, nonce, poseidon, program, program_error, program_memory, program_option,
program_pack, rent, sanitize, sdk_ids, secp256k1_program, secp256k1_recover, serde_varint,
program_pack, rent, sanitize, secp256k1_program, secp256k1_recover, serde_varint,
serialize_utils, short_vec, slot_hashes, slot_history, stable_layout, stake, stake_history,
syscalls, system_instruction, system_program, sysvar, unchecked_div_by_const, vote,
wasm_bindgen,
};
#[allow(deprecated)]
pub use solana_program::{address_lookup_table_account, sdk_ids};

pub mod account;
pub mod account_utils;
Expand Down

0 comments on commit 96aebf6

Please sign in to comment.