remove LoadZeroLamports enum (#28204)
remove feature return_none_for_zero_lamport_accounts
This commit is contained in:
parent
8d3e924dd2
commit
39b37e2c6f
|
@ -4,7 +4,7 @@ use {
|
|||
account_rent_state::{check_rent_state_with_account, RentState},
|
||||
accounts_db::{
|
||||
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig,
|
||||
BankHashInfo, LoadHint, LoadZeroLamports, LoadedAccount, ScanStorageResult,
|
||||
BankHashInfo, LoadHint, LoadedAccount, ScanStorageResult,
|
||||
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
|
||||
},
|
||||
accounts_index::{
|
||||
|
@ -258,8 +258,6 @@ impl Accounts {
|
|||
feature_set: &FeatureSet,
|
||||
account_overrides: Option<&AccountOverrides>,
|
||||
) -> Result<LoadedTransaction> {
|
||||
let load_zero_lamports = LoadZeroLamports::None;
|
||||
|
||||
// Copy all the accounts
|
||||
let message = tx.message();
|
||||
// NOTE: this check will never fail because `tx` is sanitized
|
||||
|
@ -295,7 +293,7 @@ impl Accounts {
|
|||
(account_override.clone(), 0)
|
||||
} else {
|
||||
self.accounts_db
|
||||
.load_with_fixed_root(ancestors, key, load_zero_lamports)
|
||||
.load_with_fixed_root(ancestors, key)
|
||||
.map(|(mut account, _)| {
|
||||
if message.is_writable(i) {
|
||||
let rent_due = rent_collector
|
||||
|
@ -344,12 +342,9 @@ impl Accounts {
|
|||
programdata_address,
|
||||
}) = account.state()
|
||||
{
|
||||
if let Some((programdata_account, _)) =
|
||||
self.accounts_db.load_with_fixed_root(
|
||||
ancestors,
|
||||
&programdata_address,
|
||||
load_zero_lamports,
|
||||
)
|
||||
if let Some((programdata_account, _)) = self
|
||||
.accounts_db
|
||||
.load_with_fixed_root(ancestors, &programdata_address)
|
||||
{
|
||||
account_deps
|
||||
.push((programdata_address, programdata_account));
|
||||
|
@ -393,7 +388,6 @@ impl Accounts {
|
|||
&mut accounts,
|
||||
instruction.program_id_index as IndexOfAccount,
|
||||
error_counters,
|
||||
load_zero_lamports,
|
||||
)
|
||||
})
|
||||
.collect::<Result<Vec<Vec<IndexOfAccount>>>>()?;
|
||||
|
@ -465,7 +459,6 @@ impl Accounts {
|
|||
accounts: &mut Vec<TransactionAccount>,
|
||||
mut program_account_index: IndexOfAccount,
|
||||
error_counters: &mut TransactionErrorMetrics,
|
||||
load_zero_lamports: LoadZeroLamports,
|
||||
) -> Result<Vec<IndexOfAccount>> {
|
||||
let mut account_indices = Vec::new();
|
||||
let mut program_id = match accounts.get(program_account_index as usize) {
|
||||
|
@ -483,11 +476,10 @@ impl Accounts {
|
|||
}
|
||||
depth += 1;
|
||||
|
||||
program_account_index = match self.accounts_db.load_with_fixed_root(
|
||||
ancestors,
|
||||
&program_id,
|
||||
load_zero_lamports,
|
||||
) {
|
||||
program_account_index = match self
|
||||
.accounts_db
|
||||
.load_with_fixed_root(ancestors, &program_id)
|
||||
{
|
||||
Some((program_account, _)) => {
|
||||
let account_index = accounts.len() as IndexOfAccount;
|
||||
accounts.push((program_id, program_account));
|
||||
|
@ -513,11 +505,10 @@ impl Accounts {
|
|||
programdata_address,
|
||||
}) = program.state()
|
||||
{
|
||||
let programdata_account_index = match self.accounts_db.load_with_fixed_root(
|
||||
ancestors,
|
||||
&programdata_address,
|
||||
load_zero_lamports,
|
||||
) {
|
||||
let programdata_account_index = match self
|
||||
.accounts_db
|
||||
.load_with_fixed_root(ancestors, &programdata_address)
|
||||
{
|
||||
Some((programdata_account, _)) => {
|
||||
let account_index = accounts.len() as IndexOfAccount;
|
||||
accounts.push((programdata_address, programdata_account));
|
||||
|
@ -615,15 +606,10 @@ impl Accounts {
|
|||
ancestors: &Ancestors,
|
||||
address_table_lookup: &MessageAddressTableLookup,
|
||||
slot_hashes: &SlotHashes,
|
||||
load_zero_lamports: LoadZeroLamports,
|
||||
) -> std::result::Result<LoadedAddresses, AddressLookupError> {
|
||||
let table_account = self
|
||||
.accounts_db
|
||||
.load_with_fixed_root(
|
||||
ancestors,
|
||||
&address_table_lookup.account_key,
|
||||
load_zero_lamports,
|
||||
)
|
||||
.load_with_fixed_root(ancestors, &address_table_lookup.account_key)
|
||||
.map(|(account, _rent)| account)
|
||||
.ok_or(AddressLookupError::LookupTableAccountNotFound)?;
|
||||
|
||||
|
@ -2088,7 +2074,6 @@ mod tests {
|
|||
&ancestors,
|
||||
&address_table_lookup,
|
||||
&SlotHashes::default(),
|
||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
||||
),
|
||||
Err(AddressLookupError::LookupTableAccountNotFound),
|
||||
);
|
||||
|
@ -2121,7 +2106,6 @@ mod tests {
|
|||
&ancestors,
|
||||
&address_table_lookup,
|
||||
&SlotHashes::default(),
|
||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
||||
),
|
||||
Err(AddressLookupError::InvalidAccountOwner),
|
||||
);
|
||||
|
@ -2154,7 +2138,6 @@ mod tests {
|
|||
&ancestors,
|
||||
&address_table_lookup,
|
||||
&SlotHashes::default(),
|
||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
||||
),
|
||||
Err(AddressLookupError::InvalidAccountData),
|
||||
);
|
||||
|
@ -2199,7 +2182,6 @@ mod tests {
|
|||
&ancestors,
|
||||
&address_table_lookup,
|
||||
&SlotHashes::default(),
|
||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
||||
),
|
||||
Ok(LoadedAddresses {
|
||||
writable: vec![table_addresses[0]],
|
||||
|
@ -2514,7 +2496,6 @@ mod tests {
|
|||
&mut vec![(keypair.pubkey(), account)],
|
||||
0,
|
||||
&mut error_counters,
|
||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
||||
),
|
||||
Err(TransactionError::ProgramAccountNotFound)
|
||||
);
|
||||
|
|
|
@ -145,17 +145,6 @@ pub enum StoreReclaims {
|
|||
Ignore,
|
||||
}
|
||||
|
||||
/// specifies how to return zero lamport accounts
|
||||
/// This will only be useful until a feature activation occurs.
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum LoadZeroLamports {
|
||||
/// return None if loaded account has zero lamports
|
||||
None,
|
||||
/// return Some(account with zero lamports) if loaded account has zero lamports
|
||||
/// Today this is the default. With feature activation, this will no longer be possible.
|
||||
SomeWithZeroLamportAccount,
|
||||
}
|
||||
|
||||
// the current best way to add filler accounts is gradually.
|
||||
// In other scenarios, such as monitoring catchup with large # of accounts, it may be useful to be able to
|
||||
// add filler accounts at the beginning, so that code path remains but won't execute at the moment.
|
||||
|
@ -4693,19 +4682,14 @@ impl AccountsDb {
|
|||
self.do_load_with_populate_read_cache(ancestors, pubkey, None, LoadHint::Unspecified, true);
|
||||
}
|
||||
|
||||
/// note this returns None for accounts with zero lamports
|
||||
pub fn load_with_fixed_root(
|
||||
&self,
|
||||
ancestors: &Ancestors,
|
||||
pubkey: &Pubkey,
|
||||
load_zero_lamports: LoadZeroLamports,
|
||||
) -> Option<(AccountSharedData, Slot)> {
|
||||
self.load(ancestors, pubkey, LoadHint::FixedMaxRoot)
|
||||
.filter(|(account, _)| {
|
||||
matches!(
|
||||
load_zero_lamports,
|
||||
LoadZeroLamports::SomeWithZeroLamportAccount
|
||||
) || !account.is_zero_lamport()
|
||||
})
|
||||
.filter(|(account, _)| !account.is_zero_lamport())
|
||||
}
|
||||
|
||||
pub fn load_without_fixed_root(
|
||||
|
@ -13950,13 +13934,13 @@ pub mod tests {
|
|||
|
||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 0);
|
||||
let account = db
|
||||
.load_with_fixed_root(&Ancestors::default(), &account_key, LoadZeroLamports::None)
|
||||
.load_with_fixed_root(&Ancestors::default(), &account_key)
|
||||
.map(|(account, _)| account)
|
||||
.unwrap();
|
||||
assert_eq!(account.lamports(), 1);
|
||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
||||
let account = db
|
||||
.load_with_fixed_root(&Ancestors::default(), &account_key, LoadZeroLamports::None)
|
||||
.load_with_fixed_root(&Ancestors::default(), &account_key)
|
||||
.map(|(account, _)| account)
|
||||
.unwrap();
|
||||
assert_eq!(account.lamports(), 1);
|
||||
|
@ -13964,7 +13948,7 @@ pub mod tests {
|
|||
db.store_cached((2, &[(&account_key, &zero_lamport_account)][..]), None);
|
||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
||||
let account = db
|
||||
.load_with_fixed_root(&Ancestors::default(), &account_key, LoadZeroLamports::None)
|
||||
.load_with_fixed_root(&Ancestors::default(), &account_key)
|
||||
.map(|(account, _)| account);
|
||||
assert!(account.is_none());
|
||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use {
|
||||
super::Bank,
|
||||
crate::accounts_db::LoadZeroLamports,
|
||||
solana_address_lookup_table_program::error::AddressLookupError,
|
||||
solana_sdk::{
|
||||
message::v0::{LoadedAddresses, MessageAddressTableLookup},
|
||||
|
@ -17,8 +16,6 @@ impl AddressLoader for &Bank {
|
|||
return Err(TransactionError::UnsupportedVersion);
|
||||
}
|
||||
|
||||
let load_zero_lamports = LoadZeroLamports::None;
|
||||
|
||||
let slot_hashes = self
|
||||
.sysvar_cache
|
||||
.read()
|
||||
|
@ -33,7 +30,6 @@ impl AddressLoader for &Bank {
|
|||
&self.ancestors,
|
||||
address_table_lookup,
|
||||
&slot_hashes,
|
||||
load_zero_lamports,
|
||||
)
|
||||
})
|
||||
.collect::<Result<_, AddressLookupError>>()?)
|
||||
|
|
Loading…
Reference in New Issue