parent
f27f91bed7
commit
056bfcede7
|
@ -2778,7 +2778,7 @@ fn main() {
|
||||||
for (pubkey, warped_account) in all_accounts {
|
for (pubkey, warped_account) in all_accounts {
|
||||||
// Don't output sysvars; it's always updated but not related to
|
// Don't output sysvars; it's always updated but not related to
|
||||||
// inflation.
|
// inflation.
|
||||||
if solana_sdk::sysvar::is_sysvar_id(&pubkey) {
|
if solana_sdk::sysvar::check_id(warped_account.owner()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -643,9 +643,9 @@ struct AccountsScanner {
|
||||||
|
|
||||||
impl AccountsScanner {
|
impl AccountsScanner {
|
||||||
/// Returns true if this account should be included in the output
|
/// Returns true if this account should be included in the output
|
||||||
fn should_process_account(&self, account: &AccountSharedData, pubkey: &Pubkey) -> bool {
|
fn should_process_account(&self, account: &AccountSharedData) -> bool {
|
||||||
solana_accounts_db::accounts::Accounts::is_loadable(account.lamports())
|
solana_accounts_db::accounts::Accounts::is_loadable(account.lamports())
|
||||||
&& (self.config.include_sysvars || !solana_sdk::sysvar::is_sysvar_id(pubkey))
|
&& (self.config.include_sysvars || !solana_sdk::sysvar::check_id(account.owner()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_output_account<S>(
|
fn maybe_output_account<S>(
|
||||||
|
@ -688,8 +688,8 @@ impl AccountsScanner {
|
||||||
};
|
};
|
||||||
|
|
||||||
let scan_func = |account_tuple: Option<(&Pubkey, AccountSharedData, Slot)>| {
|
let scan_func = |account_tuple: Option<(&Pubkey, AccountSharedData, Slot)>| {
|
||||||
if let Some((pubkey, account, slot)) = account_tuple
|
if let Some((pubkey, account, slot)) =
|
||||||
.filter(|(pubkey, account, _)| self.should_process_account(account, pubkey))
|
account_tuple.filter(|(_, account, _)| self.should_process_account(account))
|
||||||
{
|
{
|
||||||
total_accounts_stats.accumulate_account(pubkey, &account, rent_collector);
|
total_accounts_stats.accumulate_account(pubkey, &account, rent_collector);
|
||||||
self.maybe_output_account(
|
self.maybe_output_account(
|
||||||
|
@ -710,7 +710,7 @@ impl AccountsScanner {
|
||||||
if let Some((account, slot)) = self
|
if let Some((account, slot)) = self
|
||||||
.bank
|
.bank
|
||||||
.get_account_modified_slot_with_fixed_root(pubkey)
|
.get_account_modified_slot_with_fixed_root(pubkey)
|
||||||
.filter(|(account, _)| self.should_process_account(account, pubkey))
|
.filter(|(account, _)| self.should_process_account(account))
|
||||||
{
|
{
|
||||||
total_accounts_stats.accumulate_account(pubkey, &account, rent_collector);
|
total_accounts_stats.accumulate_account(pubkey, &account, rent_collector);
|
||||||
self.maybe_output_account(
|
self.maybe_output_account(
|
||||||
|
@ -727,7 +727,7 @@ impl AccountsScanner {
|
||||||
.get_program_accounts(program_pubkey, &ScanConfig::default())
|
.get_program_accounts(program_pubkey, &ScanConfig::default())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(pubkey, account)| self.should_process_account(account, pubkey))
|
.filter(|(_, account)| self.should_process_account(account))
|
||||||
.for_each(|(pubkey, account)| {
|
.for_each(|(pubkey, account)| {
|
||||||
total_accounts_stats.accumulate_account(pubkey, account, rent_collector);
|
total_accounts_stats.accumulate_account(pubkey, account, rent_collector);
|
||||||
self.maybe_output_account(
|
self.maybe_output_account(
|
||||||
|
|
|
@ -4366,7 +4366,7 @@ fn test_bank_get_program_accounts() {
|
||||||
assert!(
|
assert!(
|
||||||
genesis_accounts
|
genesis_accounts
|
||||||
.iter()
|
.iter()
|
||||||
.any(|(pubkey, _, _)| solana_sdk::sysvar::is_sysvar_id(pubkey)),
|
.any(|(_, account, _)| solana_sdk::sysvar::check_id(account.owner())),
|
||||||
"no sysvars found"
|
"no sysvars found"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ lazy_static! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn is_builtin_key_or_sysvar(key: &Pubkey) -> bool {
|
pub fn is_builtin_key_or_sysvar(key: &Pubkey) -> bool {
|
||||||
if MAYBE_BUILTIN_KEY_OR_SYSVAR[key.0[0] as usize] {
|
if MAYBE_BUILTIN_KEY_OR_SYSVAR[key.0[0] as usize] {
|
||||||
return sysvar::is_sysvar_id(key) || BUILTIN_PROGRAMS_KEYS.contains(key);
|
return sysvar::is_sysvar_id(key) || BUILTIN_PROGRAMS_KEYS.contains(key);
|
||||||
|
|
|
@ -118,6 +118,10 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` of the given `Pubkey` is a sysvar account.
|
/// Returns `true` of the given `Pubkey` is a sysvar account.
|
||||||
|
#[deprecated(
|
||||||
|
since = "2.0.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 {
|
pub fn is_sysvar_id(id: &Pubkey) -> bool {
|
||||||
ALL_IDS.iter().any(|key| key == id)
|
ALL_IDS.iter().any(|key| key == id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ use {
|
||||||
deserialize_utils::default_on_eof,
|
deserialize_utils::default_on_eof,
|
||||||
message::v0::LoadedAddresses,
|
message::v0::LoadedAddresses,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
|
reserved_account_keys::ReservedAccountKeys,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
sysvar::is_sysvar_id,
|
|
||||||
timing::AtomicInterval,
|
timing::AtomicInterval,
|
||||||
transaction::{TransactionError, VersionedTransaction},
|
transaction::{TransactionError, VersionedTransaction},
|
||||||
},
|
},
|
||||||
|
@ -938,6 +938,7 @@ impl LedgerStorage {
|
||||||
entries,
|
entries,
|
||||||
} = confirmed_block;
|
} = confirmed_block;
|
||||||
|
|
||||||
|
let reserved_account_keys = ReservedAccountKeys::new_all_activated();
|
||||||
let mut tx_cells = Vec::with_capacity(confirmed_block.transactions.len());
|
let mut tx_cells = Vec::with_capacity(confirmed_block.transactions.len());
|
||||||
for (index, transaction_with_meta) in confirmed_block.transactions.iter().enumerate() {
|
for (index, transaction_with_meta) in confirmed_block.transactions.iter().enumerate() {
|
||||||
let VersionedTransactionWithStatusMeta { meta, transaction } = transaction_with_meta;
|
let VersionedTransactionWithStatusMeta { meta, transaction } = transaction_with_meta;
|
||||||
|
@ -947,7 +948,11 @@ impl LedgerStorage {
|
||||||
let memo = extract_and_fmt_memos(transaction_with_meta);
|
let memo = extract_and_fmt_memos(transaction_with_meta);
|
||||||
|
|
||||||
for address in transaction_with_meta.account_keys().iter() {
|
for address in transaction_with_meta.account_keys().iter() {
|
||||||
if !is_sysvar_id(address) {
|
// Historical note that previously only a set of sysvar ids were
|
||||||
|
// skipped from being uploaded. Now we skip uploaded for the set
|
||||||
|
// of all reserved account keys which will continue to grow in
|
||||||
|
// the future.
|
||||||
|
if !reserved_account_keys.is_reserved(address) {
|
||||||
by_addr
|
by_addr
|
||||||
.entry(address)
|
.entry(address)
|
||||||
.or_default()
|
.or_default()
|
||||||
|
@ -1083,10 +1088,14 @@ impl LedgerStorage {
|
||||||
let err = None;
|
let err = None;
|
||||||
|
|
||||||
for address in transaction.message.account_keys.iter() {
|
for address in transaction.message.account_keys.iter() {
|
||||||
if !is_sysvar_id(address) {
|
// We could skip deleting addresses that are known
|
||||||
|
// reserved keys but it's hard to be sure whether we
|
||||||
|
// previously uploaded rows for reserved keys or not. So
|
||||||
|
// to ensure everything is deleted properly, we attempt
|
||||||
|
// to delete rows for all addresses even if they might
|
||||||
|
// not have been uploaded.
|
||||||
addresses.insert(address);
|
addresses.insert(address);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
expected_tx_infos.insert(
|
expected_tx_infos.insert(
|
||||||
signature.to_string(),
|
signature.to_string(),
|
||||||
|
@ -1100,10 +1109,14 @@ impl LedgerStorage {
|
||||||
let err = meta.status.clone().err();
|
let err = meta.status.clone().err();
|
||||||
|
|
||||||
for address in tx_with_meta.account_keys().iter() {
|
for address in tx_with_meta.account_keys().iter() {
|
||||||
if !is_sysvar_id(address) {
|
// We could skip deleting addresses that are known
|
||||||
|
// reserved keys but it's hard to be sure whether we
|
||||||
|
// previously uploaded rows for reserved keys or not. So
|
||||||
|
// to ensure everything is deleted properly, we attempt
|
||||||
|
// to delete rows for all addresses even if they might
|
||||||
|
// not have been uploaded.
|
||||||
addresses.insert(address);
|
addresses.insert(address);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
expected_tx_infos.insert(
|
expected_tx_infos.insert(
|
||||||
signature.to_string(),
|
signature.to_string(),
|
||||||
|
|
Loading…
Reference in New Issue