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},
|
account_rent_state::{check_rent_state_with_account, RentState},
|
||||||
accounts_db::{
|
accounts_db::{
|
||||||
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig,
|
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig,
|
||||||
BankHashInfo, LoadHint, LoadZeroLamports, LoadedAccount, ScanStorageResult,
|
BankHashInfo, LoadHint, LoadedAccount, ScanStorageResult,
|
||||||
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
|
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
|
||||||
},
|
},
|
||||||
accounts_index::{
|
accounts_index::{
|
||||||
|
@ -258,8 +258,6 @@ impl Accounts {
|
||||||
feature_set: &FeatureSet,
|
feature_set: &FeatureSet,
|
||||||
account_overrides: Option<&AccountOverrides>,
|
account_overrides: Option<&AccountOverrides>,
|
||||||
) -> Result<LoadedTransaction> {
|
) -> Result<LoadedTransaction> {
|
||||||
let load_zero_lamports = LoadZeroLamports::None;
|
|
||||||
|
|
||||||
// Copy all the accounts
|
// Copy all the accounts
|
||||||
let message = tx.message();
|
let message = tx.message();
|
||||||
// NOTE: this check will never fail because `tx` is sanitized
|
// NOTE: this check will never fail because `tx` is sanitized
|
||||||
|
@ -295,7 +293,7 @@ impl Accounts {
|
||||||
(account_override.clone(), 0)
|
(account_override.clone(), 0)
|
||||||
} else {
|
} else {
|
||||||
self.accounts_db
|
self.accounts_db
|
||||||
.load_with_fixed_root(ancestors, key, load_zero_lamports)
|
.load_with_fixed_root(ancestors, key)
|
||||||
.map(|(mut account, _)| {
|
.map(|(mut account, _)| {
|
||||||
if message.is_writable(i) {
|
if message.is_writable(i) {
|
||||||
let rent_due = rent_collector
|
let rent_due = rent_collector
|
||||||
|
@ -344,12 +342,9 @@ impl Accounts {
|
||||||
programdata_address,
|
programdata_address,
|
||||||
}) = account.state()
|
}) = account.state()
|
||||||
{
|
{
|
||||||
if let Some((programdata_account, _)) =
|
if let Some((programdata_account, _)) = self
|
||||||
self.accounts_db.load_with_fixed_root(
|
.accounts_db
|
||||||
ancestors,
|
.load_with_fixed_root(ancestors, &programdata_address)
|
||||||
&programdata_address,
|
|
||||||
load_zero_lamports,
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
account_deps
|
account_deps
|
||||||
.push((programdata_address, programdata_account));
|
.push((programdata_address, programdata_account));
|
||||||
|
@ -393,7 +388,6 @@ impl Accounts {
|
||||||
&mut accounts,
|
&mut accounts,
|
||||||
instruction.program_id_index as IndexOfAccount,
|
instruction.program_id_index as IndexOfAccount,
|
||||||
error_counters,
|
error_counters,
|
||||||
load_zero_lamports,
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<Vec<IndexOfAccount>>>>()?;
|
.collect::<Result<Vec<Vec<IndexOfAccount>>>>()?;
|
||||||
|
@ -465,7 +459,6 @@ impl Accounts {
|
||||||
accounts: &mut Vec<TransactionAccount>,
|
accounts: &mut Vec<TransactionAccount>,
|
||||||
mut program_account_index: IndexOfAccount,
|
mut program_account_index: IndexOfAccount,
|
||||||
error_counters: &mut TransactionErrorMetrics,
|
error_counters: &mut TransactionErrorMetrics,
|
||||||
load_zero_lamports: LoadZeroLamports,
|
|
||||||
) -> Result<Vec<IndexOfAccount>> {
|
) -> Result<Vec<IndexOfAccount>> {
|
||||||
let mut account_indices = Vec::new();
|
let mut account_indices = Vec::new();
|
||||||
let mut program_id = match accounts.get(program_account_index as usize) {
|
let mut program_id = match accounts.get(program_account_index as usize) {
|
||||||
|
@ -483,11 +476,10 @@ impl Accounts {
|
||||||
}
|
}
|
||||||
depth += 1;
|
depth += 1;
|
||||||
|
|
||||||
program_account_index = match self.accounts_db.load_with_fixed_root(
|
program_account_index = match self
|
||||||
ancestors,
|
.accounts_db
|
||||||
&program_id,
|
.load_with_fixed_root(ancestors, &program_id)
|
||||||
load_zero_lamports,
|
{
|
||||||
) {
|
|
||||||
Some((program_account, _)) => {
|
Some((program_account, _)) => {
|
||||||
let account_index = accounts.len() as IndexOfAccount;
|
let account_index = accounts.len() as IndexOfAccount;
|
||||||
accounts.push((program_id, program_account));
|
accounts.push((program_id, program_account));
|
||||||
|
@ -513,11 +505,10 @@ impl Accounts {
|
||||||
programdata_address,
|
programdata_address,
|
||||||
}) = program.state()
|
}) = program.state()
|
||||||
{
|
{
|
||||||
let programdata_account_index = match self.accounts_db.load_with_fixed_root(
|
let programdata_account_index = match self
|
||||||
ancestors,
|
.accounts_db
|
||||||
&programdata_address,
|
.load_with_fixed_root(ancestors, &programdata_address)
|
||||||
load_zero_lamports,
|
{
|
||||||
) {
|
|
||||||
Some((programdata_account, _)) => {
|
Some((programdata_account, _)) => {
|
||||||
let account_index = accounts.len() as IndexOfAccount;
|
let account_index = accounts.len() as IndexOfAccount;
|
||||||
accounts.push((programdata_address, programdata_account));
|
accounts.push((programdata_address, programdata_account));
|
||||||
|
@ -615,15 +606,10 @@ impl Accounts {
|
||||||
ancestors: &Ancestors,
|
ancestors: &Ancestors,
|
||||||
address_table_lookup: &MessageAddressTableLookup,
|
address_table_lookup: &MessageAddressTableLookup,
|
||||||
slot_hashes: &SlotHashes,
|
slot_hashes: &SlotHashes,
|
||||||
load_zero_lamports: LoadZeroLamports,
|
|
||||||
) -> std::result::Result<LoadedAddresses, AddressLookupError> {
|
) -> std::result::Result<LoadedAddresses, AddressLookupError> {
|
||||||
let table_account = self
|
let table_account = self
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.load_with_fixed_root(
|
.load_with_fixed_root(ancestors, &address_table_lookup.account_key)
|
||||||
ancestors,
|
|
||||||
&address_table_lookup.account_key,
|
|
||||||
load_zero_lamports,
|
|
||||||
)
|
|
||||||
.map(|(account, _rent)| account)
|
.map(|(account, _rent)| account)
|
||||||
.ok_or(AddressLookupError::LookupTableAccountNotFound)?;
|
.ok_or(AddressLookupError::LookupTableAccountNotFound)?;
|
||||||
|
|
||||||
|
@ -2088,7 +2074,6 @@ mod tests {
|
||||||
&ancestors,
|
&ancestors,
|
||||||
&address_table_lookup,
|
&address_table_lookup,
|
||||||
&SlotHashes::default(),
|
&SlotHashes::default(),
|
||||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
|
||||||
),
|
),
|
||||||
Err(AddressLookupError::LookupTableAccountNotFound),
|
Err(AddressLookupError::LookupTableAccountNotFound),
|
||||||
);
|
);
|
||||||
|
@ -2121,7 +2106,6 @@ mod tests {
|
||||||
&ancestors,
|
&ancestors,
|
||||||
&address_table_lookup,
|
&address_table_lookup,
|
||||||
&SlotHashes::default(),
|
&SlotHashes::default(),
|
||||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
|
||||||
),
|
),
|
||||||
Err(AddressLookupError::InvalidAccountOwner),
|
Err(AddressLookupError::InvalidAccountOwner),
|
||||||
);
|
);
|
||||||
|
@ -2154,7 +2138,6 @@ mod tests {
|
||||||
&ancestors,
|
&ancestors,
|
||||||
&address_table_lookup,
|
&address_table_lookup,
|
||||||
&SlotHashes::default(),
|
&SlotHashes::default(),
|
||||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
|
||||||
),
|
),
|
||||||
Err(AddressLookupError::InvalidAccountData),
|
Err(AddressLookupError::InvalidAccountData),
|
||||||
);
|
);
|
||||||
|
@ -2199,7 +2182,6 @@ mod tests {
|
||||||
&ancestors,
|
&ancestors,
|
||||||
&address_table_lookup,
|
&address_table_lookup,
|
||||||
&SlotHashes::default(),
|
&SlotHashes::default(),
|
||||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
|
||||||
),
|
),
|
||||||
Ok(LoadedAddresses {
|
Ok(LoadedAddresses {
|
||||||
writable: vec![table_addresses[0]],
|
writable: vec![table_addresses[0]],
|
||||||
|
@ -2514,7 +2496,6 @@ mod tests {
|
||||||
&mut vec![(keypair.pubkey(), account)],
|
&mut vec![(keypair.pubkey(), account)],
|
||||||
0,
|
0,
|
||||||
&mut error_counters,
|
&mut error_counters,
|
||||||
LoadZeroLamports::SomeWithZeroLamportAccount,
|
|
||||||
),
|
),
|
||||||
Err(TransactionError::ProgramAccountNotFound)
|
Err(TransactionError::ProgramAccountNotFound)
|
||||||
);
|
);
|
||||||
|
|
|
@ -145,17 +145,6 @@ pub enum StoreReclaims {
|
||||||
Ignore,
|
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.
|
// 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
|
// 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.
|
// 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);
|
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(
|
pub fn load_with_fixed_root(
|
||||||
&self,
|
&self,
|
||||||
ancestors: &Ancestors,
|
ancestors: &Ancestors,
|
||||||
pubkey: &Pubkey,
|
pubkey: &Pubkey,
|
||||||
load_zero_lamports: LoadZeroLamports,
|
|
||||||
) -> Option<(AccountSharedData, Slot)> {
|
) -> Option<(AccountSharedData, Slot)> {
|
||||||
self.load(ancestors, pubkey, LoadHint::FixedMaxRoot)
|
self.load(ancestors, pubkey, LoadHint::FixedMaxRoot)
|
||||||
.filter(|(account, _)| {
|
.filter(|(account, _)| !account.is_zero_lamport())
|
||||||
matches!(
|
|
||||||
load_zero_lamports,
|
|
||||||
LoadZeroLamports::SomeWithZeroLamportAccount
|
|
||||||
) || !account.is_zero_lamport()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_without_fixed_root(
|
pub fn load_without_fixed_root(
|
||||||
|
@ -13950,13 +13934,13 @@ pub mod tests {
|
||||||
|
|
||||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 0);
|
assert_eq!(db.read_only_accounts_cache.cache_len(), 0);
|
||||||
let account = db
|
let account = db
|
||||||
.load_with_fixed_root(&Ancestors::default(), &account_key, LoadZeroLamports::None)
|
.load_with_fixed_root(&Ancestors::default(), &account_key)
|
||||||
.map(|(account, _)| account)
|
.map(|(account, _)| account)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(account.lamports(), 1);
|
assert_eq!(account.lamports(), 1);
|
||||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
||||||
let account = db
|
let account = db
|
||||||
.load_with_fixed_root(&Ancestors::default(), &account_key, LoadZeroLamports::None)
|
.load_with_fixed_root(&Ancestors::default(), &account_key)
|
||||||
.map(|(account, _)| account)
|
.map(|(account, _)| account)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(account.lamports(), 1);
|
assert_eq!(account.lamports(), 1);
|
||||||
|
@ -13964,7 +13948,7 @@ pub mod tests {
|
||||||
db.store_cached((2, &[(&account_key, &zero_lamport_account)][..]), None);
|
db.store_cached((2, &[(&account_key, &zero_lamport_account)][..]), None);
|
||||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
||||||
let account = db
|
let account = db
|
||||||
.load_with_fixed_root(&Ancestors::default(), &account_key, LoadZeroLamports::None)
|
.load_with_fixed_root(&Ancestors::default(), &account_key)
|
||||||
.map(|(account, _)| account);
|
.map(|(account, _)| account);
|
||||||
assert!(account.is_none());
|
assert!(account.is_none());
|
||||||
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
assert_eq!(db.read_only_accounts_cache.cache_len(), 1);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use {
|
use {
|
||||||
super::Bank,
|
super::Bank,
|
||||||
crate::accounts_db::LoadZeroLamports,
|
|
||||||
solana_address_lookup_table_program::error::AddressLookupError,
|
solana_address_lookup_table_program::error::AddressLookupError,
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
message::v0::{LoadedAddresses, MessageAddressTableLookup},
|
message::v0::{LoadedAddresses, MessageAddressTableLookup},
|
||||||
|
@ -17,8 +16,6 @@ impl AddressLoader for &Bank {
|
||||||
return Err(TransactionError::UnsupportedVersion);
|
return Err(TransactionError::UnsupportedVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
let load_zero_lamports = LoadZeroLamports::None;
|
|
||||||
|
|
||||||
let slot_hashes = self
|
let slot_hashes = self
|
||||||
.sysvar_cache
|
.sysvar_cache
|
||||||
.read()
|
.read()
|
||||||
|
@ -33,7 +30,6 @@ impl AddressLoader for &Bank {
|
||||||
&self.ancestors,
|
&self.ancestors,
|
||||||
address_table_lookup,
|
address_table_lookup,
|
||||||
&slot_hashes,
|
&slot_hashes,
|
||||||
load_zero_lamports,
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Result<_, AddressLookupError>>()?)
|
.collect::<Result<_, AddressLookupError>>()?)
|
||||||
|
|
Loading…
Reference in New Issue