lamports -> lamports() (#16920)
This commit is contained in:
parent
59e19828ea
commit
ca7b36ad8f
|
@ -1558,7 +1558,7 @@ pub fn rewrite_stakes(
|
||||||
let meta_status = meta.rewrite_rent_exempt_reserve(rent, stake_account.data().len());
|
let meta_status = meta.rewrite_rent_exempt_reserve(rent, stake_account.data().len());
|
||||||
let stake_status = stake
|
let stake_status = stake
|
||||||
.delegation
|
.delegation
|
||||||
.rewrite_stake(stake_account.lamports, meta.rent_exempt_reserve);
|
.rewrite_stake(stake_account.lamports(), meta.rent_exempt_reserve);
|
||||||
|
|
||||||
if meta_status.is_none() && stake_status.is_none() {
|
if meta_status.is_none() && stake_status.is_none() {
|
||||||
return Err(InstructionError::InvalidAccountData);
|
return Err(InstructionError::InvalidAccountData);
|
||||||
|
|
|
@ -266,7 +266,7 @@ impl Accounts {
|
||||||
if payer_index != 0 {
|
if payer_index != 0 {
|
||||||
warn!("Payer index should be 0! {:?}", tx);
|
warn!("Payer index should be 0! {:?}", tx);
|
||||||
}
|
}
|
||||||
if accounts[payer_index].lamports == 0 {
|
if accounts[payer_index].lamports() == 0 {
|
||||||
error_counters.account_not_found += 1;
|
error_counters.account_not_found += 1;
|
||||||
Err(TransactionError::AccountNotFound)
|
Err(TransactionError::AccountNotFound)
|
||||||
} else {
|
} else {
|
||||||
|
@ -283,7 +283,7 @@ impl Accounts {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if accounts[payer_index].lamports < fee + min_balance {
|
if accounts[payer_index].lamports() < fee + min_balance {
|
||||||
error_counters.insufficient_funds += 1;
|
error_counters.insufficient_funds += 1;
|
||||||
Err(TransactionError::InsufficientFundsForFee)
|
Err(TransactionError::InsufficientFundsForFee)
|
||||||
} else {
|
} else {
|
||||||
|
@ -574,7 +574,7 @@ impl Accounts {
|
||||||
ancestors,
|
ancestors,
|
||||||
|collector: &mut BinaryHeap<Reverse<(u64, Pubkey)>>, option| {
|
|collector: &mut BinaryHeap<Reverse<(u64, Pubkey)>>, option| {
|
||||||
if let Some((pubkey, account, _slot)) = option {
|
if let Some((pubkey, account, _slot)) = option {
|
||||||
if account.lamports == 0 {
|
if account.lamports() == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let contains_address = filter_by_address.contains(pubkey);
|
let contains_address = filter_by_address.contains(pubkey);
|
||||||
|
@ -589,12 +589,12 @@ impl Accounts {
|
||||||
let Reverse(entry) = collector
|
let Reverse(entry) = collector
|
||||||
.peek()
|
.peek()
|
||||||
.expect("BinaryHeap::peek should succeed when len > 0");
|
.expect("BinaryHeap::peek should succeed when len > 0");
|
||||||
if *entry >= (account.lamports, *pubkey) {
|
if *entry >= (account.lamports(), *pubkey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collector.pop();
|
collector.pop();
|
||||||
}
|
}
|
||||||
collector.push(Reverse((account.lamports, *pubkey)));
|
collector.push(Reverse((account.lamports(), *pubkey)));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -651,7 +651,7 @@ impl Accounts {
|
||||||
filter: F,
|
filter: F,
|
||||||
) {
|
) {
|
||||||
if let Some(mapped_account_tuple) = some_account_tuple
|
if let Some(mapped_account_tuple) = some_account_tuple
|
||||||
.filter(|(_, account, _)| Self::is_loadable(account.lamports) && filter(account))
|
.filter(|(_, account, _)| Self::is_loadable(account.lamports()) && filter(account))
|
||||||
.map(|(pubkey, account, _slot)| (*pubkey, account))
|
.map(|(pubkey, account, _slot)| (*pubkey, account))
|
||||||
{
|
{
|
||||||
collector.push(mapped_account_tuple)
|
collector.push(mapped_account_tuple)
|
||||||
|
@ -708,8 +708,8 @@ impl Accounts {
|
||||||
self.accounts_db.scan_accounts(
|
self.accounts_db.scan_accounts(
|
||||||
ancestors,
|
ancestors,
|
||||||
|collector: &mut Vec<(Pubkey, AccountSharedData, Slot)>, some_account_tuple| {
|
|collector: &mut Vec<(Pubkey, AccountSharedData, Slot)>, some_account_tuple| {
|
||||||
if let Some((pubkey, account, slot)) =
|
if let Some((pubkey, account, slot)) = some_account_tuple
|
||||||
some_account_tuple.filter(|(_, account, _)| Self::is_loadable(account.lamports))
|
.filter(|(_, account, _)| Self::is_loadable(account.lamports()))
|
||||||
{
|
{
|
||||||
collector.push((*pubkey, account, slot))
|
collector.push((*pubkey, account, slot))
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ impl<'a> LoadedAccount<'a> {
|
||||||
pub fn lamports(&self) -> u64 {
|
pub fn lamports(&self) -> u64 {
|
||||||
match self {
|
match self {
|
||||||
LoadedAccount::Stored(stored_account_meta) => stored_account_meta.account_meta.lamports,
|
LoadedAccount::Stored(stored_account_meta) => stored_account_meta.account_meta.lamports,
|
||||||
LoadedAccount::Cached((_, cached_account)) => cached_account.account.lamports,
|
LoadedAccount::Cached((_, cached_account)) => cached_account.account.lamports(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4516,7 +4516,7 @@ impl AccountsDb {
|
||||||
{
|
{
|
||||||
let frozen_account_info = FrozenAccountInfo {
|
let frozen_account_info = FrozenAccountInfo {
|
||||||
hash: Self::hash_frozen_account_data(&account),
|
hash: Self::hash_frozen_account_data(&account),
|
||||||
lamports: account.lamports,
|
lamports: account.lamports(),
|
||||||
};
|
};
|
||||||
warn!(
|
warn!(
|
||||||
"Account {} is now frozen at lamports={}, hash={}",
|
"Account {} is now frozen at lamports={}, hash={}",
|
||||||
|
@ -4540,11 +4540,13 @@ impl AccountsDb {
|
||||||
}
|
}
|
||||||
for (account_pubkey, account) in accounts.iter() {
|
for (account_pubkey, account) in accounts.iter() {
|
||||||
if let Some(frozen_account_info) = self.frozen_accounts.get(*account_pubkey) {
|
if let Some(frozen_account_info) = self.frozen_accounts.get(*account_pubkey) {
|
||||||
if account.lamports < frozen_account_info.lamports {
|
if account.lamports() < frozen_account_info.lamports {
|
||||||
FROZEN_ACCOUNT_PANIC.store(true, Ordering::Relaxed);
|
FROZEN_ACCOUNT_PANIC.store(true, Ordering::Relaxed);
|
||||||
panic!(
|
panic!(
|
||||||
"Frozen account {} modified. Lamports decreased from {} to {}",
|
"Frozen account {} modified. Lamports decreased from {} to {}",
|
||||||
account_pubkey, frozen_account_info.lamports, account.lamports,
|
account_pubkey,
|
||||||
|
frozen_account_info.lamports,
|
||||||
|
account.lamports(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1378,7 +1378,7 @@ impl Bank {
|
||||||
old_account: &Option<AccountSharedData>,
|
old_account: &Option<AccountSharedData>,
|
||||||
) -> InheritableAccountFields {
|
) -> InheritableAccountFields {
|
||||||
(
|
(
|
||||||
old_account.as_ref().map(|a| a.lamports).unwrap_or(1),
|
old_account.as_ref().map(|a| a.lamports()).unwrap_or(1),
|
||||||
INITIAL_RENT_EPOCH,
|
INITIAL_RENT_EPOCH,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1854,7 +1854,7 @@ impl Bank {
|
||||||
// pay according to point value
|
// pay according to point value
|
||||||
for (vote_pubkey, (stake_group, vote_account)) in stake_delegation_accounts.iter_mut() {
|
for (vote_pubkey, (stake_group, vote_account)) in stake_delegation_accounts.iter_mut() {
|
||||||
let mut vote_account_changed = false;
|
let mut vote_account_changed = false;
|
||||||
let voters_account_pre_balance = vote_account.lamports;
|
let voters_account_pre_balance = vote_account.lamports();
|
||||||
|
|
||||||
for (stake_pubkey, stake_account) in stake_group.iter_mut() {
|
for (stake_pubkey, stake_account) in stake_group.iter_mut() {
|
||||||
// curry closure to add the contextual stake_pubkey
|
// curry closure to add the contextual stake_pubkey
|
||||||
|
@ -1884,7 +1884,7 @@ impl Bank {
|
||||||
RewardInfo {
|
RewardInfo {
|
||||||
reward_type: RewardType::Staking,
|
reward_type: RewardType::Staking,
|
||||||
lamports: stakers_reward as i64,
|
lamports: stakers_reward as i64,
|
||||||
post_balance: stake_account.lamports,
|
post_balance: stake_account.lamports(),
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -1897,7 +1897,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
|
|
||||||
if vote_account_changed {
|
if vote_account_changed {
|
||||||
let post_balance = vote_account.lamports;
|
let post_balance = vote_account.lamports();
|
||||||
let lamports = (post_balance - voters_account_pre_balance) as i64;
|
let lamports = (post_balance - voters_account_pre_balance) as i64;
|
||||||
if lamports != 0 {
|
if lamports != 0 {
|
||||||
rewards.push((
|
rewards.push((
|
||||||
|
@ -2209,7 +2209,7 @@ impl Bank {
|
||||||
// malicious account is pre-occupying at program_id
|
// malicious account is pre-occupying at program_id
|
||||||
// forcibly burn and purge it
|
// forcibly burn and purge it
|
||||||
|
|
||||||
self.capitalization.fetch_sub(account.lamports, Relaxed);
|
self.capitalization.fetch_sub(account.lamports(), Relaxed);
|
||||||
|
|
||||||
// Resetting account balance to 0 is needed to really purge from AccountsDb and
|
// Resetting account balance to 0 is needed to really purge from AccountsDb and
|
||||||
// flush the Stakes cache
|
// flush the Stakes cache
|
||||||
|
@ -3381,7 +3381,7 @@ impl Bank {
|
||||||
RewardInfo {
|
RewardInfo {
|
||||||
reward_type: RewardType::Rent,
|
reward_type: RewardType::Rent,
|
||||||
lamports: rent_to_be_paid as i64,
|
lamports: rent_to_be_paid as i64,
|
||||||
post_balance: account.lamports,
|
post_balance: account.lamports(),
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -3444,7 +3444,7 @@ impl Bank {
|
||||||
if let Some((account, _)) =
|
if let Some((account, _)) =
|
||||||
self.get_account_modified_since_parent_with_fixed_root(&incinerator::id())
|
self.get_account_modified_since_parent_with_fixed_root(&incinerator::id())
|
||||||
{
|
{
|
||||||
self.capitalization.fetch_sub(account.lamports, Relaxed);
|
self.capitalization.fetch_sub(account.lamports(), Relaxed);
|
||||||
self.store_account(&incinerator::id(), &AccountSharedData::default());
|
self.store_account(&incinerator::id(), &AccountSharedData::default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3931,7 +3931,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_balance(account: &AccountSharedData) -> u64 {
|
pub fn read_balance(account: &AccountSharedData) -> u64 {
|
||||||
account.lamports
|
account.lamports()
|
||||||
}
|
}
|
||||||
/// Each program would need to be able to introspect its own state
|
/// Each program would need to be able to introspect its own state
|
||||||
/// this is hard-coded to the Budget language
|
/// this is hard-coded to the Budget language
|
||||||
|
@ -4001,19 +4001,20 @@ impl Bank {
|
||||||
new_account: &AccountSharedData,
|
new_account: &AccountSharedData,
|
||||||
) {
|
) {
|
||||||
if let Some(old_account) = self.get_account_with_fixed_root(&pubkey) {
|
if let Some(old_account) = self.get_account_with_fixed_root(&pubkey) {
|
||||||
match new_account.lamports.cmp(&old_account.lamports) {
|
match new_account.lamports().cmp(&old_account.lamports()) {
|
||||||
std::cmp::Ordering::Greater => {
|
std::cmp::Ordering::Greater => {
|
||||||
self.capitalization
|
self.capitalization
|
||||||
.fetch_add(new_account.lamports - old_account.lamports, Relaxed);
|
.fetch_add(new_account.lamports() - old_account.lamports(), Relaxed);
|
||||||
}
|
}
|
||||||
std::cmp::Ordering::Less => {
|
std::cmp::Ordering::Less => {
|
||||||
self.capitalization
|
self.capitalization
|
||||||
.fetch_sub(old_account.lamports - new_account.lamports, Relaxed);
|
.fetch_sub(old_account.lamports() - new_account.lamports(), Relaxed);
|
||||||
}
|
}
|
||||||
std::cmp::Ordering::Equal => {}
|
std::cmp::Ordering::Equal => {}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.capitalization.fetch_add(new_account.lamports, Relaxed);
|
self.capitalization
|
||||||
|
.fetch_add(new_account.lamports(), Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.store_account(pubkey, new_account);
|
self.store_account(pubkey, new_account);
|
||||||
|
@ -4051,7 +4052,7 @@ impl Bank {
|
||||||
let mut account = self.get_account_with_fixed_root(pubkey).unwrap_or_default();
|
let mut account = self.get_account_with_fixed_root(pubkey).unwrap_or_default();
|
||||||
account.lamports += lamports;
|
account.lamports += lamports;
|
||||||
self.store_account(pubkey, &account);
|
self.store_account(pubkey, &account);
|
||||||
account.lamports
|
account.lamports()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn accounts(&self) -> Arc<Accounts> {
|
pub fn accounts(&self) -> Arc<Accounts> {
|
||||||
|
@ -4917,7 +4918,8 @@ impl Bank {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Burn lamports in the old token account
|
// Burn lamports in the old token account
|
||||||
self.capitalization.fetch_sub(old_account.lamports, Relaxed);
|
self.capitalization
|
||||||
|
.fetch_sub(old_account.lamports(), Relaxed);
|
||||||
|
|
||||||
// Transfer new token account to old token account
|
// Transfer new token account to old token account
|
||||||
self.store_account(&inline_spl_token_v2_0::id(), &new_account);
|
self.store_account(&inline_spl_token_v2_0::id(), &new_account);
|
||||||
|
@ -4963,7 +4965,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.capitalization
|
self.capitalization
|
||||||
.fetch_add(native_mint_account.lamports, Relaxed);
|
.fetch_add(native_mint_account.lamports(), Relaxed);
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4990,7 +4992,7 @@ impl Bank {
|
||||||
if purge_window_epoch {
|
if purge_window_epoch {
|
||||||
for reward_pubkey in self.rewards_pool_pubkeys.iter() {
|
for reward_pubkey in self.rewards_pool_pubkeys.iter() {
|
||||||
if let Some(mut reward_account) = self.get_account_with_fixed_root(&reward_pubkey) {
|
if let Some(mut reward_account) = self.get_account_with_fixed_root(&reward_pubkey) {
|
||||||
if reward_account.lamports == u64::MAX {
|
if reward_account.lamports() == u64::MAX {
|
||||||
reward_account.set_lamports(0);
|
reward_account.set_lamports(0);
|
||||||
self.store_account(&reward_pubkey, &reward_account);
|
self.store_account(&reward_pubkey, &reward_account);
|
||||||
// Adjust capitalization.... it has been wrapping, reducing the real capitalization by 1-lamport
|
// Adjust capitalization.... it has been wrapping, reducing the real capitalization by 1-lamport
|
||||||
|
|
|
@ -125,13 +125,13 @@ impl PreAccount {
|
||||||
|
|
||||||
// An account not assigned to the program cannot have its balance decrease.
|
// An account not assigned to the program cannot have its balance decrease.
|
||||||
if program_id != pre.owner() // line coverage used to get branch coverage
|
if program_id != pre.owner() // line coverage used to get branch coverage
|
||||||
&& pre.lamports() > post.lamports
|
&& pre.lamports() > post.lamports()
|
||||||
{
|
{
|
||||||
return Err(InstructionError::ExternalAccountLamportSpend);
|
return Err(InstructionError::ExternalAccountLamportSpend);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The balance of read-only and executable accounts may not change
|
// The balance of read-only and executable accounts may not change
|
||||||
let lamports_changed = pre.lamports() != post.lamports;
|
let lamports_changed = pre.lamports() != post.lamports();
|
||||||
if lamports_changed {
|
if lamports_changed {
|
||||||
if !is_writable {
|
if !is_writable {
|
||||||
return Err(InstructionError::ReadonlyLamportChange);
|
return Err(InstructionError::ReadonlyLamportChange);
|
||||||
|
@ -171,7 +171,7 @@ impl PreAccount {
|
||||||
// executable is one-way (false->true) and only the account owner may set it.
|
// executable is one-way (false->true) and only the account owner may set it.
|
||||||
let executable_changed = pre.executable() != post.executable();
|
let executable_changed = pre.executable() != post.executable();
|
||||||
if executable_changed {
|
if executable_changed {
|
||||||
if !rent.is_exempt(post.lamports, post.data().len()) {
|
if !rent.is_exempt(post.lamports(), post.data().len()) {
|
||||||
return Err(InstructionError::ExecutableAccountNotRentExempt);
|
return Err(InstructionError::ExecutableAccountNotRentExempt);
|
||||||
}
|
}
|
||||||
if !is_writable // line coverage used to get branch coverage
|
if !is_writable // line coverage used to get branch coverage
|
||||||
|
@ -220,7 +220,7 @@ impl PreAccount {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lamports(&self) -> u64 {
|
pub fn lamports(&self) -> u64 {
|
||||||
self.account.borrow().lamports
|
self.account.borrow().lamports()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_zeroed(buf: &[u8]) -> bool {
|
pub fn is_zeroed(buf: &[u8]) -> bool {
|
||||||
|
@ -1054,7 +1054,7 @@ impl MessageProcessor {
|
||||||
true,
|
true,
|
||||||
)?;
|
)?;
|
||||||
pre_sum += u128::from(pre_accounts[unique_index].lamports());
|
pre_sum += u128::from(pre_accounts[unique_index].lamports());
|
||||||
post_sum += u128::from(account.lamports);
|
post_sum += u128::from(account.lamports());
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
instruction.visit_each_account(&mut work)?;
|
instruction.visit_each_account(&mut work)?;
|
||||||
|
@ -1109,7 +1109,7 @@ impl MessageProcessor {
|
||||||
false,
|
false,
|
||||||
)?;
|
)?;
|
||||||
pre_sum += u128::from(pre_account.lamports());
|
pre_sum += u128::from(pre_account.lamports());
|
||||||
post_sum += u128::from(account.lamports);
|
post_sum += u128::from(account.lamports());
|
||||||
if is_writable && !account.executable() {
|
if is_writable && !account.executable() {
|
||||||
pre_account.update(&account);
|
pre_account.update(&account);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ impl RentCollector {
|
||||||
|
|
||||||
let (rent_due, exempt) =
|
let (rent_due, exempt) =
|
||||||
self.rent
|
self.rent
|
||||||
.due(account.lamports, account.data().len(), years_elapsed);
|
.due(account.lamports(), account.data().len(), years_elapsed);
|
||||||
|
|
||||||
if exempt || rent_due != 0 {
|
if exempt || rent_due != 0 {
|
||||||
if account.lamports() > rent_due {
|
if account.lamports() > rent_due {
|
||||||
|
@ -99,7 +99,7 @@ impl RentCollector {
|
||||||
account.lamports -= rent_due;
|
account.lamports -= rent_due;
|
||||||
rent_due
|
rent_due
|
||||||
} else {
|
} else {
|
||||||
let rent_charged = account.lamports;
|
let rent_charged = account.lamports();
|
||||||
*account = AccountSharedData::default();
|
*account = AccountSharedData::default();
|
||||||
rent_charged
|
rent_charged
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl Stakes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if account.lamports == 0 {
|
if account.lamports() == 0 {
|
||||||
// when account is removed (lamports == 0), remove it from Stakes as well
|
// when account is removed (lamports == 0), remove it from Stakes as well
|
||||||
// so that given `pubkey` can be used for any owner in the future, while not
|
// so that given `pubkey` can be used for any owner in the future, while not
|
||||||
// affecting Stakes.
|
// affecting Stakes.
|
||||||
|
|
Loading…
Reference in New Issue