diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index fb0bb85d54990b..f77fdbb9616d06 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -2235,7 +2235,8 @@ fn main() { if let Some((pubkey, account, slot)) = some_account_tuple .filter(|(_, account, _)| Accounts::is_loadable(account.lamports())) { - if !include_sysvars && solana_sdk::sysvar::is_sysvar_id(pubkey) { + if !include_sysvars && solana_sdk::sysvar::check_id(account.owner()) + { return; } @@ -2613,7 +2614,7 @@ fn main() { for (pubkey, warped_account) in all_accounts { // Don't output sysvars; it's always updated but not related to // inflation. - if solana_sdk::sysvar::is_sysvar_id(&pubkey) { + if solana_sdk::sysvar::check_id(warped_account.owner()) { continue; } diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 574e0885a4ec22..23ca47e45b5915 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -4397,7 +4397,7 @@ fn test_bank_get_program_accounts() { assert!( genesis_accounts .iter() - .any(|(pubkey, _, _)| solana_sdk::sysvar::is_sysvar_id(pubkey)), + .any(|(_, account, _)| solana_sdk::sysvar::check_id(account.owner())), "no sysvars found" ); diff --git a/runtime/src/snapshot_minimizer.rs b/runtime/src/snapshot_minimizer.rs index 4e7d576f0b6c95..06beeb4f960a9a 100644 --- a/runtime/src/snapshot_minimizer.rs +++ b/runtime/src/snapshot_minimizer.rs @@ -21,7 +21,7 @@ use { bpf_loader_upgradeable::{self, UpgradeableLoaderState}, clock::Slot, pubkey::Pubkey, - sdk_ids, + reserved_account_keys::ReservedAccountKeys, }, std::{ collections::HashSet, @@ -127,9 +127,11 @@ impl<'a> SnapshotMinimizer<'a> { /// Used to get sdk accounts in `minimize` fn get_sdk_accounts(&self) { - sdk_ids::SDK_IDS.iter().for_each(|pubkey| { - self.minimized_account_set.insert(*pubkey); - }); + ReservedAccountKeys::active_and_inactive() + .iter() + .for_each(|pubkey| { + self.minimized_account_set.insert(*pubkey); + }) } /// Used to get rent collection accounts in `minimize` diff --git a/sdk/program/src/message/legacy.rs b/sdk/program/src/message/legacy.rs index 813055fd12e709..dbe14350c57988 100644 --- a/sdk/program/src/message/legacy.rs +++ b/sdk/program/src/message/legacy.rs @@ -58,6 +58,11 @@ lazy_static! { }; } +#[deprecated( + since = "1.18.0", + note = "please use solana_sdk::reserved_account_keys::ReservedAccountKeys instead" +)] +#[allow(deprecated)] pub fn is_builtin_key_or_sysvar(key: &Pubkey) -> bool { if MAYBE_BUILTIN_KEY_OR_SYSVAR[key.0[0] as usize] { return sysvar::is_sysvar_id(key) || BUILTIN_PROGRAMS_KEYS.contains(key); @@ -568,6 +573,7 @@ impl Message { /// instructions in this message. Since the dynamic set of reserved accounts /// isn't used here to demote write locks, this shouldn't be used in the /// runtime. + #[allow(deprecated)] pub fn is_maybe_writable(&self, i: usize) -> bool { (self.is_writable_index(i)) && !is_builtin_key_or_sysvar(&self.account_keys[i]) diff --git a/sdk/program/src/message/versions/v0/mod.rs b/sdk/program/src/message/versions/v0/mod.rs index 57f82c2703c0c7..caf35d43d9d1ee 100644 --- a/sdk/program/src/message/versions/v0/mod.rs +++ b/sdk/program/src/message/versions/v0/mod.rs @@ -9,6 +9,8 @@ //! [`v0`]: crate::message::v0 //! [future message format]: https://docs.solanalabs.com/proposals/versioned-transactions +#[allow(deprecated)] +use crate::message::legacy::is_builtin_key_or_sysvar; use crate::{ address_lookup_table_account::AddressLookupTableAccount, bpf_loader_upgradeable, @@ -16,7 +18,6 @@ use crate::{ instruction::{CompiledInstruction, Instruction}, message::{ compiled_keys::{CompileError, CompiledKeys}, - legacy::is_builtin_key_or_sysvar, AccountKeys, MessageHeader, MESSAGE_VERSION_PREFIX, }, pubkey::Pubkey, @@ -338,6 +339,7 @@ impl Message { /// writable. Before loading addresses and without the reserved account keys /// set, we can't demote write locks properly so this should not be used by /// the runtime. + #[allow(deprecated)] pub fn is_maybe_writable(&self, key_index: usize) -> bool { self.is_writable_index(key_index) && !{ diff --git a/sdk/program/src/sysvar/mod.rs b/sdk/program/src/sysvar/mod.rs index 4aabbce336619a..2f9ec6390c2b98 100644 --- a/sdk/program/src/sysvar/mod.rs +++ b/sdk/program/src/sysvar/mod.rs @@ -118,6 +118,10 @@ lazy_static! { } /// Returns `true` of the given `Pubkey` is a sysvar account. +#[deprecated( + since = "1.18.0", + note = "please check the account's owner or use solana_sdk::reserved_account_keys::ReservedAccountKeys instead" +)] pub fn is_sysvar_id(id: &Pubkey) -> bool { ALL_IDS.iter().any(|key| key == id) } diff --git a/storage-bigtable/src/lib.rs b/storage-bigtable/src/lib.rs index 85c714c635b5b4..e9c0f8c80217bc 100644 --- a/storage-bigtable/src/lib.rs +++ b/storage-bigtable/src/lib.rs @@ -10,8 +10,8 @@ use { deserialize_utils::default_on_eof, message::v0::LoadedAddresses, pubkey::Pubkey, + reserved_account_keys::ReservedAccountKeys, signature::Signature, - sysvar::is_sysvar_id, timing::AtomicInterval, transaction::{TransactionError, VersionedTransaction}, }, @@ -938,6 +938,7 @@ impl LedgerStorage { entries, } = confirmed_block; + let reserved_account_keys = ReservedAccountKeys::active_and_inactive(); let mut tx_cells = Vec::with_capacity(confirmed_block.transactions.len()); for (index, transaction_with_meta) in confirmed_block.transactions.iter().enumerate() { let VersionedTransactionWithStatusMeta { meta, transaction } = transaction_with_meta; @@ -947,7 +948,7 @@ impl LedgerStorage { let memo = extract_and_fmt_memos(transaction_with_meta); for address in transaction_with_meta.account_keys().iter() { - if !is_sysvar_id(address) { + if !reserved_account_keys.contains(address) { by_addr .entry(address) .or_default() @@ -1083,9 +1084,9 @@ impl LedgerStorage { let err = None; for address in transaction.message.account_keys.iter() { - if !is_sysvar_id(address) { - addresses.insert(address); - } + // Some of these addresses might be reserved keys but it's + // ok if we attempt to delete a row that doesn't exist + addresses.insert(address); } expected_tx_infos.insert( @@ -1100,9 +1101,9 @@ impl LedgerStorage { let err = meta.status.clone().err(); for address in tx_with_meta.account_keys().iter() { - if !is_sysvar_id(address) { - addresses.insert(address); - } + // Some of these addresses might be reserved keys but it's + // ok if we attempt to delete a row that doesn't exist + addresses.insert(address); } expected_tx_infos.insert(