Nit, short name (bp #12195) (#12732)

* Nit, short name (#12195)

(cherry picked from commit daba17a95c)

# Conflicts:
#	runtime/src/bank.rs

* fix conflicts

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-10-08 20:03:15 +00:00
committed by GitHub
parent b74fbdf7eb
commit 765dd1b775

View File

@ -74,7 +74,7 @@ use std::{
ptr, ptr,
rc::Rc, rc::Rc,
sync::{ sync::{
atomic::{AtomicBool, AtomicU64, Ordering}, atomic::{AtomicBool, AtomicU64, Ordering::Relaxed},
LockResult, RwLockWriteGuard, {Arc, RwLock, RwLockReadGuard}, LockResult, RwLockWriteGuard, {Arc, RwLock, RwLockReadGuard},
}, },
}; };
@ -237,10 +237,7 @@ impl Clone for CachedExecutors {
for (key, (count, executor)) in self.executors.iter() { for (key, (count, executor)) in self.executors.iter() {
executors.insert( executors.insert(
*key, *key,
( (AtomicU64::new(count.load(Relaxed)), executor.clone()),
AtomicU64::new(count.load(Ordering::Relaxed)),
executor.clone(),
),
); );
} }
Self { Self {
@ -258,7 +255,7 @@ impl CachedExecutors {
} }
fn get(&self, pubkey: &Pubkey) -> Option<Arc<dyn Executor>> { fn get(&self, pubkey: &Pubkey) -> Option<Arc<dyn Executor>> {
self.executors.get(pubkey).map(|(count, executor)| { self.executors.get(pubkey).map(|(count, executor)| {
count.fetch_add(1, Ordering::Relaxed); count.fetch_add(1, Relaxed);
executor.clone() executor.clone()
}) })
} }
@ -269,7 +266,7 @@ impl CachedExecutors {
let default_key = Pubkey::default(); let default_key = Pubkey::default();
let mut least_key = &default_key; let mut least_key = &default_key;
for (key, (count, _)) in self.executors.iter() { for (key, (count, _)) in self.executors.iter() {
let count = count.load(Ordering::Relaxed); let count = count.load(Relaxed);
if count < least { if count < least {
least = count; least = count;
least_key = key; least_key = key;
@ -729,18 +726,16 @@ impl Bank {
ancestors: HashMap::new(), ancestors: HashMap::new(),
hash: RwLock::new(Hash::default()), hash: RwLock::new(Hash::default()),
is_delta: AtomicBool::new(false), is_delta: AtomicBool::new(false),
tick_height: AtomicU64::new(parent.tick_height.load(Ordering::Relaxed)), tick_height: AtomicU64::new(parent.tick_height.load(Relaxed)),
signature_count: AtomicU64::new(0), signature_count: AtomicU64::new(0),
message_processor: parent.message_processor.clone(), message_processor: parent.message_processor.clone(),
feature_builtins: parent.feature_builtins.clone(), feature_builtins: parent.feature_builtins.clone(),
hard_forks: parent.hard_forks.clone(), hard_forks: parent.hard_forks.clone(),
last_vote_sync: AtomicU64::new(parent.last_vote_sync.load(Ordering::Relaxed)), last_vote_sync: AtomicU64::new(parent.last_vote_sync.load(Relaxed)),
rewards: None, rewards: None,
skip_drop: AtomicBool::new(false), skip_drop: AtomicBool::new(false),
cluster_type: parent.cluster_type, cluster_type: parent.cluster_type,
lazy_rent_collection: AtomicBool::new( lazy_rent_collection: AtomicBool::new(parent.lazy_rent_collection.load(Relaxed)),
parent.lazy_rent_collection.load(Ordering::Relaxed),
),
rewards_pool_pubkeys: parent.rewards_pool_pubkeys.clone(), rewards_pool_pubkeys: parent.rewards_pool_pubkeys.clone(),
cached_executors: RwLock::new((*parent.cached_executors.read().unwrap()).clone()), cached_executors: RwLock::new((*parent.cached_executors.read().unwrap()).clone()),
transaction_debug_keys: parent.transaction_debug_keys.clone(), transaction_debug_keys: parent.transaction_debug_keys.clone(),
@ -786,8 +781,7 @@ impl Bank {
let mut new = Bank::new_from_parent(parent, collector_id, slot); let mut new = Bank::new_from_parent(parent, collector_id, slot);
new.apply_feature_activations(true); new.apply_feature_activations(true);
new.update_epoch_stakes(new.epoch_schedule().get_epoch(slot)); new.update_epoch_stakes(new.epoch_schedule().get_epoch(slot));
new.tick_height new.tick_height.store(new.max_tick_height(), Relaxed);
.store(new.max_tick_height(), Ordering::Relaxed);
new.freeze(); new.freeze();
new new
} }
@ -897,10 +891,10 @@ impl Bank {
parent_hash: self.parent_hash, parent_hash: self.parent_hash,
parent_slot: self.parent_slot, parent_slot: self.parent_slot,
hard_forks: &*self.hard_forks, hard_forks: &*self.hard_forks,
transaction_count: self.transaction_count.load(Ordering::Relaxed), transaction_count: self.transaction_count.load(Relaxed),
tick_height: self.tick_height.load(Ordering::Relaxed), tick_height: self.tick_height.load(Relaxed),
signature_count: self.signature_count.load(Ordering::Relaxed), signature_count: self.signature_count.load(Relaxed),
capitalization: self.capitalization.load(Ordering::Relaxed), capitalization: self.capitalization.load(Relaxed),
max_tick_height: self.max_tick_height, max_tick_height: self.max_tick_height,
hashes_per_tick: self.hashes_per_tick, hashes_per_tick: self.hashes_per_tick,
ticks_per_slot: self.ticks_per_slot, ticks_per_slot: self.ticks_per_slot,
@ -912,16 +906,16 @@ impl Bank {
epoch: self.epoch, epoch: self.epoch,
block_height: self.block_height, block_height: self.block_height,
collector_id: self.collector_id, collector_id: self.collector_id,
collector_fees: self.collector_fees.load(Ordering::Relaxed), collector_fees: self.collector_fees.load(Relaxed),
fee_calculator: self.fee_calculator.clone(), fee_calculator: self.fee_calculator.clone(),
fee_rate_governor: self.fee_rate_governor.clone(), fee_rate_governor: self.fee_rate_governor.clone(),
collected_rent: self.collected_rent.load(Ordering::Relaxed), collected_rent: self.collected_rent.load(Relaxed),
rent_collector: self.rent_collector.clone(), rent_collector: self.rent_collector.clone(),
epoch_schedule: self.epoch_schedule, epoch_schedule: self.epoch_schedule,
inflation: *self.inflation.read().unwrap(), inflation: *self.inflation.read().unwrap(),
stakes: &self.stakes, stakes: &self.stakes,
epoch_stakes: &self.epoch_stakes, epoch_stakes: &self.epoch_stakes,
is_delta: self.is_delta.load(Ordering::Relaxed), is_delta: self.is_delta.load(Relaxed),
} }
} }
@ -1169,7 +1163,7 @@ impl Bank {
); );
self.capitalization self.capitalization
.fetch_add(validator_rewards_paid, Ordering::Relaxed); .fetch_add(validator_rewards_paid, Relaxed);
let active_stake = if let Some(stake_history_entry) = let active_stake = if let Some(stake_history_entry) =
self.stakes.read().unwrap().history().get(&prev_epoch) self.stakes.read().unwrap().history().get(&prev_epoch)
@ -1328,7 +1322,7 @@ impl Bank {
// still being stake-weighted. // still being stake-weighted.
// Ref: distribute_rent_to_validators // Ref: distribute_rent_to_validators
fn collect_fees(&self) { fn collect_fees(&self) {
let collector_fees = self.collector_fees.load(Ordering::Relaxed) as u64; let collector_fees = self.collector_fees.load(Relaxed) as u64;
if collector_fees != 0 { if collector_fees != 0 {
let (unburned, burned) = self.fee_rate_governor.burn(collector_fees); let (unburned, burned) = self.fee_rate_governor.burn(collector_fees);
@ -1338,7 +1332,7 @@ impl Bank {
unburned, collector_fees, burned unburned, collector_fees, burned
); );
self.deposit(&self.collector_id, unburned); self.deposit(&self.collector_id, unburned);
self.capitalization.fetch_sub(burned, Ordering::Relaxed); self.capitalization.fetch_sub(burned, Relaxed);
} }
} }
@ -1440,8 +1434,7 @@ impl Bank {
panic!("{} repeated in genesis config", pubkey); panic!("{} repeated in genesis config", pubkey);
} }
self.store_account(pubkey, account); self.store_account(pubkey, account);
self.capitalization self.capitalization.fetch_add(account.lamports, Relaxed);
.fetch_add(account.lamports, Ordering::Relaxed);
} }
for (pubkey, account) in genesis_config.rewards_pools.iter() { for (pubkey, account) in genesis_config.rewards_pools.iter() {
@ -1499,8 +1492,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 self.capitalization.fetch_sub(account.lamports, Relaxed);
.fetch_sub(account.lamports, Ordering::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
@ -1640,7 +1632,7 @@ impl Bank {
// not attempt to freeze after observing the last tick and before blockhash is // not attempt to freeze after observing the last tick and before blockhash is
// updated // updated
let mut w_blockhash_queue = self.blockhash_queue.write().unwrap(); let mut w_blockhash_queue = self.blockhash_queue.write().unwrap();
let current_tick_height = self.tick_height.fetch_add(1, Ordering::Relaxed) as u64; let current_tick_height = self.tick_height.fetch_add(1, Relaxed) as u64;
if self.is_block_boundary(current_tick_height + 1) { if self.is_block_boundary(current_tick_height + 1) {
w_blockhash_queue.register_hash(hash, &self.fee_calculator); w_blockhash_queue.register_hash(hash, &self.fee_calculator);
if self.fix_recent_blockhashes_sysvar_delay() { if self.fix_recent_blockhashes_sysvar_delay() {
@ -2323,7 +2315,7 @@ impl Bank {
}) })
.collect(); .collect();
self.collector_fees.fetch_add(fees, Ordering::Relaxed); self.collector_fees.fetch_add(fees, Relaxed);
results results
} }
@ -2351,7 +2343,7 @@ impl Bank {
.iter() .iter()
.any(|(res, _hash_age_kind)| Self::can_commit(res)) .any(|(res, _hash_age_kind)| Self::can_commit(res))
{ {
self.is_delta.store(true, Ordering::Relaxed); self.is_delta.store(true, Relaxed);
} }
let mut write_time = Measure::start("write_time"); let mut write_time = Measure::start("write_time");
@ -2432,7 +2424,7 @@ impl Bank {
if validator_stakes.is_empty() { if validator_stakes.is_empty() {
// some tests bank.freezes() with bad staking state // some tests bank.freezes() with bad staking state
self.capitalization self.capitalization
.fetch_sub(rent_to_be_distributed, Ordering::Relaxed); .fetch_sub(rent_to_be_distributed, Relaxed);
return; return;
} }
#[cfg(not(test))] #[cfg(not(test))]
@ -2489,13 +2481,12 @@ impl Bank {
"There was leftover from rent distribution: {}", "There was leftover from rent distribution: {}",
leftover_lamports leftover_lamports
); );
self.capitalization self.capitalization.fetch_sub(leftover_lamports, Relaxed);
.fetch_sub(leftover_lamports, Ordering::Relaxed);
} }
} }
fn distribute_rent(&self) { fn distribute_rent(&self) {
let total_rent_collected = self.collected_rent.load(Ordering::Relaxed); let total_rent_collected = self.collected_rent.load(Relaxed);
let (burned_portion, rent_to_be_distributed) = self let (burned_portion, rent_to_be_distributed) = self
.rent_collector .rent_collector
@ -2506,8 +2497,7 @@ impl Bank {
"distributed rent: {} (rounded from: {}, burned: {})", "distributed rent: {} (rounded from: {}, burned: {})",
rent_to_be_distributed, total_rent_collected, burned_portion rent_to_be_distributed, total_rent_collected, burned_portion
); );
self.capitalization self.capitalization.fetch_sub(burned_portion, Relaxed);
.fetch_sub(burned_portion, Ordering::Relaxed);
if rent_to_be_distributed == 0 { if rent_to_be_distributed == 0 {
return; return;
@ -2533,14 +2523,12 @@ impl Bank {
collected_rent += acc.2; collected_rent += acc.2;
} }
self.collected_rent self.collected_rent.fetch_add(collected_rent, Relaxed);
.fetch_add(collected_rent, Ordering::Relaxed);
} }
fn run_incinerator(&self) { fn run_incinerator(&self) {
if let Some((account, _)) = self.get_account_modified_since_parent(&incinerator::id()) { if let Some((account, _)) = self.get_account_modified_since_parent(&incinerator::id()) {
self.capitalization self.capitalization.fetch_sub(account.lamports, Relaxed);
.fetch_sub(account.lamports, Ordering::Relaxed);
self.store_account(&incinerator::id(), &Account::default()); self.store_account(&incinerator::id(), &Account::default());
} }
} }
@ -2559,7 +2547,7 @@ impl Bank {
} }
fn enable_eager_rent_collection(&self) -> bool { fn enable_eager_rent_collection(&self) -> bool {
if self.lazy_rent_collection.load(Ordering::Relaxed) { if self.lazy_rent_collection.load(Relaxed) {
return false; return false;
} }
@ -2605,7 +2593,7 @@ impl Bank {
// even if collected rent is 0 (= not updated). // even if collected rent is 0 (= not updated).
self.store_account(&pubkey, &account); self.store_account(&pubkey, &account);
} }
self.collected_rent.fetch_add(rent, Ordering::Relaxed); self.collected_rent.fetch_add(rent, Relaxed);
datapoint_info!("collect_rent_eagerly", ("accounts", account_count, i64)); datapoint_info!("collect_rent_eagerly", ("accounts", account_count, i64));
} }
@ -3023,19 +3011,14 @@ impl Bank {
fn add_account_and_update_capitalization(&self, pubkey: &Pubkey, new_account: &Account) { fn add_account_and_update_capitalization(&self, pubkey: &Pubkey, new_account: &Account) {
if let Some(old_account) = self.get_account(&pubkey) { if let Some(old_account) = self.get_account(&pubkey) {
if new_account.lamports > old_account.lamports { if new_account.lamports > old_account.lamports {
self.capitalization.fetch_add( self.capitalization
new_account.lamports - old_account.lamports, .fetch_add(new_account.lamports - old_account.lamports, Relaxed);
Ordering::Relaxed,
);
} else { } else {
self.capitalization.fetch_sub( self.capitalization
old_account.lamports - new_account.lamports, .fetch_sub(old_account.lamports - new_account.lamports, Relaxed);
Ordering::Relaxed,
);
} }
} else { } else {
self.capitalization self.capitalization.fetch_add(new_account.lamports, Relaxed);
.fetch_add(new_account.lamports, Ordering::Relaxed);
} }
self.store_account(pubkey, new_account); self.store_account(pubkey, new_account);
@ -3082,7 +3065,7 @@ impl Bank {
self.collected_rent.fetch_add( self.collected_rent.fetch_add(
self.rent_collector self.rent_collector
.collect_from_existing_account(pubkey, &mut account), .collect_from_existing_account(pubkey, &mut account),
Ordering::Relaxed, Relaxed,
); );
} }
@ -3197,21 +3180,19 @@ impl Bank {
} }
pub fn transaction_count(&self) -> u64 { pub fn transaction_count(&self) -> u64 {
self.transaction_count.load(Ordering::Relaxed) self.transaction_count.load(Relaxed)
} }
fn increment_transaction_count(&self, tx_count: u64) { fn increment_transaction_count(&self, tx_count: u64) {
self.transaction_count self.transaction_count.fetch_add(tx_count, Relaxed);
.fetch_add(tx_count, Ordering::Relaxed);
} }
pub fn signature_count(&self) -> u64 { pub fn signature_count(&self) -> u64 {
self.signature_count.load(Ordering::Relaxed) self.signature_count.load(Relaxed)
} }
fn increment_signature_count(&self, signature_count: u64) { fn increment_signature_count(&self, signature_count: u64) {
self.signature_count self.signature_count.fetch_add(signature_count, Relaxed);
.fetch_add(signature_count, Ordering::Relaxed);
} }
pub fn get_signature_status_processed_since_parent( pub fn get_signature_status_processed_since_parent(
@ -3342,7 +3323,7 @@ impl Bank {
pub fn set_capitalization(&self) -> u64 { pub fn set_capitalization(&self) -> u64 {
let old = self.capitalization(); let old = self.capitalization();
self.capitalization self.capitalization
.store(self.calculate_capitalization(), Ordering::Relaxed); .store(self.calculate_capitalization(), Relaxed);
old old
} }
@ -3386,7 +3367,7 @@ impl Bank {
/// Return the number of ticks since genesis. /// Return the number of ticks since genesis.
pub fn tick_height(&self) -> u64 { pub fn tick_height(&self) -> u64 {
self.tick_height.load(Ordering::Relaxed) self.tick_height.load(Relaxed)
} }
/// Return the inflation parameters of the Bank /// Return the inflation parameters of the Bank
@ -3396,7 +3377,7 @@ impl Bank {
/// Return the total capitalization of the Bank /// Return the total capitalization of the Bank
pub fn capitalization(&self) -> u64 { pub fn capitalization(&self) -> u64 {
self.capitalization.load(Ordering::Relaxed) self.capitalization.load(Relaxed)
} }
/// Return this bank's max_tick_height /// Return this bank's max_tick_height
@ -3556,7 +3537,7 @@ impl Bank {
} }
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
!self.is_delta.load(Ordering::Relaxed) !self.is_delta.load(Relaxed)
} }
pub fn add_builtin_program( pub fn add_builtin_program(
@ -3609,13 +3590,10 @@ impl Bank {
assert_eq!(self.ticks_per_slot, dbank.ticks_per_slot); assert_eq!(self.ticks_per_slot, dbank.ticks_per_slot);
assert_eq!(self.parent_hash, dbank.parent_hash); assert_eq!(self.parent_hash, dbank.parent_hash);
assert_eq!( assert_eq!(
self.tick_height.load(Ordering::Relaxed), self.tick_height.load(Relaxed),
dbank.tick_height.load(Ordering::Relaxed) dbank.tick_height.load(Relaxed)
);
assert_eq!(
self.is_delta.load(Ordering::Relaxed),
dbank.is_delta.load(Ordering::Relaxed)
); );
assert_eq!(self.is_delta.load(Relaxed), dbank.is_delta.load(Relaxed));
{ {
let bh = self.hash.read().unwrap(); let bh = self.hash.read().unwrap();
@ -3771,8 +3749,7 @@ impl Bank {
fn apply_spl_token_v2_multisig_fix(&mut self) { fn apply_spl_token_v2_multisig_fix(&mut self) {
if let Some(mut account) = self.get_account(&inline_spl_token_v2_0::id()) { if let Some(mut account) = self.get_account(&inline_spl_token_v2_0::id()) {
self.capitalization self.capitalization.fetch_sub(account.lamports, Relaxed);
.fetch_sub(account.lamports, Ordering::Relaxed);
account.lamports = 0; account.lamports = 0;
self.store_account(&inline_spl_token_v2_0::id(), &account); self.store_account(&inline_spl_token_v2_0::id(), &account);
self.remove_executor(&inline_spl_token_v2_0::id()); self.remove_executor(&inline_spl_token_v2_0::id());
@ -3810,7 +3787,7 @@ impl Bank {
} }
} else { } else {
self.capitalization self.capitalization
.fetch_add(native_mint_account.lamports, Ordering::Relaxed); .fetch_add(native_mint_account.lamports, Relaxed);
true true
}; };
@ -3841,7 +3818,7 @@ impl Bank {
reward_account.lamports = 0; reward_account.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
self.capitalization.fetch_add(1, Ordering::Relaxed); self.capitalization.fetch_add(1, Relaxed);
info!( info!(
"purged rewards pool accont: {}, new capitalization: {}", "purged rewards pool accont: {}, new capitalization: {}",
reward_pubkey, reward_pubkey,
@ -3866,7 +3843,7 @@ impl Bank {
impl Drop for Bank { impl Drop for Bank {
fn drop(&mut self) { fn drop(&mut self) {
// For root slots this is a noop // For root slots this is a noop
if !self.skip_drop.load(Ordering::Relaxed) { if !self.skip_drop.load(Relaxed) {
self.rc.accounts.purge_slot(self.slot()); self.rc.accounts.purge_slot(self.slot());
} }
} }
@ -4502,14 +4479,11 @@ mod tests {
assert_eq!(bank.get_balance(&payee.pubkey()), 159); assert_eq!(bank.get_balance(&payee.pubkey()), 159);
total_rent_deducted += 70 + 21; total_rent_deducted += 70 + 21;
let previous_capitalization = bank.capitalization.load(Ordering::Relaxed); let previous_capitalization = bank.capitalization.load(Relaxed);
bank.freeze(); bank.freeze();
assert_eq!( assert_eq!(bank.collected_rent.load(Relaxed), total_rent_deducted);
bank.collected_rent.load(Ordering::Relaxed),
total_rent_deducted
);
let burned_portion = let burned_portion =
total_rent_deducted * u64::from(bank.rent_collector.rent.burn_percent) / 100; total_rent_deducted * u64::from(bank.rent_collector.rent.burn_percent) / 100;
@ -4558,7 +4532,7 @@ mod tests {
validator_3_portion + 42 validator_3_portion + 42
); );
let current_capitalization = bank.capitalization.load(Ordering::Relaxed); let current_capitalization = bank.capitalization.load(Relaxed);
assert_eq!( assert_eq!(
previous_capitalization - current_capitalization, previous_capitalization - current_capitalization,
@ -4669,9 +4643,7 @@ mod tests {
let root_bank = Bank::new(&genesis_config); let root_bank = Bank::new(&genesis_config);
// until we completely transition to the eager rent collection, // until we completely transition to the eager rent collection,
// we must ensure lazy rent collection doens't get broken! // we must ensure lazy rent collection doens't get broken!
root_bank root_bank.lazy_rent_collection.store(true, Relaxed);
.lazy_rent_collection
.store(true, Ordering::Relaxed);
let root_bank = Arc::new(root_bank); let root_bank = Arc::new(root_bank);
let bank = create_child_bank_for_rent_test(&root_bank, &genesis_config, mock_program_id); let bank = create_child_bank_for_rent_test(&root_bank, &genesis_config, mock_program_id);
@ -4820,7 +4792,7 @@ mod tests {
assert_eq!(bank.get_balance(&keypairs[13].pubkey()), 14); assert_eq!(bank.get_balance(&keypairs[13].pubkey()), 14);
// Bank's collected rent should be sum of rent collected from all accounts // Bank's collected rent should be sum of rent collected from all accounts
assert_eq!(bank.collected_rent.load(Ordering::Relaxed), rent_collected); assert_eq!(bank.collected_rent.load(Relaxed), rent_collected);
} }
#[test] #[test]
@ -5443,7 +5415,7 @@ mod tests {
bank = Arc::new(Bank::new_from_parent(&bank, &Pubkey::default(), some_slot)); bank = Arc::new(Bank::new_from_parent(&bank, &Pubkey::default(), some_slot));
assert_eq!(bank.collected_rent.load(Ordering::Relaxed), 0); assert_eq!(bank.collected_rent.load(Relaxed), 0);
assert_eq!( assert_eq!(
bank.get_account(&rent_due_pubkey).unwrap().lamports, bank.get_account(&rent_due_pubkey).unwrap().lamports,
little_lamports little_lamports
@ -5465,10 +5437,7 @@ mod tests {
bank.collect_rent_in_partition((0, 0, 1)); // all range bank.collect_rent_in_partition((0, 0, 1)); // all range
// unrelated 1-lamport account exists // unrelated 1-lamport account exists
assert_eq!( assert_eq!(bank.collected_rent.load(Relaxed), rent_collected + 1);
bank.collected_rent.load(Ordering::Relaxed),
rent_collected + 1
);
assert_eq!( assert_eq!(
bank.get_account(&rent_due_pubkey).unwrap().lamports, bank.get_account(&rent_due_pubkey).unwrap().lamports,
little_lamports - rent_collected little_lamports - rent_collected
@ -5587,7 +5556,7 @@ mod tests {
// enable lazy rent collection because this test depends on rent-due accounts // enable lazy rent collection because this test depends on rent-due accounts
// not being eagerly-collected for exact rewards calculation // not being eagerly-collected for exact rewards calculation
bank.lazy_rent_collection.store(true, Ordering::Relaxed); bank.lazy_rent_collection.store(true, Relaxed);
assert_eq!(bank.capitalization(), 42 * 1_000_000_000); assert_eq!(bank.capitalization(), 42 * 1_000_000_000);
assert_eq!(bank.rewards, None); assert_eq!(bank.rewards, None);
@ -5704,7 +5673,7 @@ mod tests {
// enable lazy rent collection because this test depends on rent-due accounts // enable lazy rent collection because this test depends on rent-due accounts
// not being eagerly-collected for exact rewards calculation // not being eagerly-collected for exact rewards calculation
bank.lazy_rent_collection.store(true, Ordering::Relaxed); bank.lazy_rent_collection.store(true, Relaxed);
assert_eq!(bank.capitalization(), 42 * 1_000_000_000); assert_eq!(bank.capitalization(), 42 * 1_000_000_000);
assert_eq!(bank.rewards, None); assert_eq!(bank.rewards, None);
@ -7086,15 +7055,15 @@ mod tests {
let tx_transfer_mint_to_1 = let tx_transfer_mint_to_1 =
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_config.hash()); system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_config.hash());
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(())); assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
assert_eq!(bank.is_delta.load(Ordering::Relaxed), true); assert_eq!(bank.is_delta.load(Relaxed), true);
let bank1 = new_from_parent(&bank); let bank1 = new_from_parent(&bank);
let hash1 = bank1.hash_internal_state(); let hash1 = bank1.hash_internal_state();
assert_eq!(bank1.is_delta.load(Ordering::Relaxed), false); assert_eq!(bank1.is_delta.load(Relaxed), false);
assert_ne!(hash1, bank.hash()); assert_ne!(hash1, bank.hash());
// ticks don't make a bank into a delta or change its state unless a block boundary is crossed // ticks don't make a bank into a delta or change its state unless a block boundary is crossed
bank1.register_tick(&Hash::default()); bank1.register_tick(&Hash::default());
assert_eq!(bank1.is_delta.load(Ordering::Relaxed), false); assert_eq!(bank1.is_delta.load(Relaxed), false);
assert_eq!(bank1.hash_internal_state(), hash1); assert_eq!(bank1.hash_internal_state(), hash1);
} }
@ -7288,7 +7257,7 @@ mod tests {
fn test_is_delta_with_no_committables() { fn test_is_delta_with_no_committables() {
let (genesis_config, mint_keypair) = create_genesis_config(8000); let (genesis_config, mint_keypair) = create_genesis_config(8000);
let bank = Bank::new(&genesis_config); let bank = Bank::new(&genesis_config);
bank.is_delta.store(false, Ordering::Relaxed); bank.is_delta.store(false, Relaxed);
let keypair1 = Keypair::new(); let keypair1 = Keypair::new();
let keypair2 = Keypair::new(); let keypair2 = Keypair::new();
@ -7304,7 +7273,7 @@ mod tests {
); );
// Check the bank is_delta is still false // Check the bank is_delta is still false
assert!(!bank.is_delta.load(Ordering::Relaxed)); assert!(!bank.is_delta.load(Relaxed));
// Should fail with InstructionError, but InstructionErrors are committable, // Should fail with InstructionError, but InstructionErrors are committable,
// so is_delta should be true // so is_delta should be true
@ -7316,14 +7285,14 @@ mod tests {
)) ))
); );
assert!(bank.is_delta.load(Ordering::Relaxed)); assert!(bank.is_delta.load(Relaxed));
} }
#[test] #[test]
fn test_bank_get_program_accounts() { fn test_bank_get_program_accounts() {
let (genesis_config, mint_keypair) = create_genesis_config(500); let (genesis_config, mint_keypair) = create_genesis_config(500);
let parent = Arc::new(Bank::new(&genesis_config)); let parent = Arc::new(Bank::new(&genesis_config));
parent.lazy_rent_collection.store(true, Ordering::Relaxed); parent.lazy_rent_collection.store(true, Relaxed);
let genesis_accounts: Vec<_> = parent.get_all_accounts_with_modified_slots(); let genesis_accounts: Vec<_> = parent.get_all_accounts_with_modified_slots();
assert!( assert!(
@ -7528,10 +7497,8 @@ mod tests {
let ((vote_id, vote_account), (stake_id, stake_account)) = let ((vote_id, vote_account), (stake_id, stake_account)) =
crate::stakes::tests::create_staked_node_accounts(1_0000); crate::stakes::tests::create_staked_node_accounts(1_0000);
bank.capitalization.fetch_add( bank.capitalization
vote_account.lamports + stake_account.lamports, .fetch_add(vote_account.lamports + stake_account.lamports, Relaxed);
Ordering::Relaxed,
);
bank.store_account(&vote_id, &vote_account); bank.store_account(&vote_id, &vote_account);
bank.store_account(&stake_id, &stake_account); bank.store_account(&stake_id, &stake_account);
assert!(!bank.stakes.read().unwrap().vote_accounts().is_empty()); assert!(!bank.stakes.read().unwrap().vote_accounts().is_empty());
@ -7589,12 +7556,12 @@ mod tests {
fn test_bank_inherit_last_vote_sync() { fn test_bank_inherit_last_vote_sync() {
let (genesis_config, _) = create_genesis_config(500); let (genesis_config, _) = create_genesis_config(500);
let bank0 = Arc::new(Bank::new(&genesis_config)); let bank0 = Arc::new(Bank::new(&genesis_config));
let last_ts = bank0.last_vote_sync.load(Ordering::Relaxed); let last_ts = bank0.last_vote_sync.load(Relaxed);
assert_eq!(last_ts, 0); assert_eq!(last_ts, 0);
bank0.last_vote_sync.store(1, Ordering::Relaxed); bank0.last_vote_sync.store(1, Relaxed);
let bank1 = let bank1 =
Bank::new_from_parent(&bank0, &Pubkey::default(), bank0.get_slots_in_epoch(0) - 1); Bank::new_from_parent(&bank0, &Pubkey::default(), bank0.get_slots_in_epoch(0) - 1);
let last_ts = bank1.last_vote_sync.load(Ordering::Relaxed); let last_ts = bank1.last_vote_sync.load(Relaxed);
assert_eq!(last_ts, 1); assert_eq!(last_ts, 1);
} }
@ -8697,7 +8664,7 @@ mod tests {
let pubkey2 = Pubkey::new_rand(); let pubkey2 = Pubkey::new_rand();
let mut bank = Arc::new(Bank::new(&genesis_config)); let mut bank = Arc::new(Bank::new(&genesis_config));
bank.lazy_rent_collection.store(true, Ordering::Relaxed); bank.lazy_rent_collection.store(true, Relaxed);
assert_eq!(bank.process_stale_slot_with_budget(0, 0), 0); assert_eq!(bank.process_stale_slot_with_budget(0, 0), 0);
assert_eq!(bank.process_stale_slot_with_budget(133, 0), 133); assert_eq!(bank.process_stale_slot_with_budget(133, 0), 133);
@ -9042,7 +9009,7 @@ mod tests {
let bank0 = Bank::new(&genesis_config); let bank0 = Bank::new(&genesis_config);
// because capitalization has been reset with bogus capitalization calculation allowing overflows, // because capitalization has been reset with bogus capitalization calculation allowing overflows,
// deliberately substract 1 lamport to simulate it // deliberately substract 1 lamport to simulate it
bank0.capitalization.fetch_sub(1, Ordering::Relaxed); bank0.capitalization.fetch_sub(1, Relaxed);
let bank0 = Arc::new(bank0); let bank0 = Arc::new(bank0);
assert_eq!(bank0.get_balance(&reward_pubkey), u64::MAX,); assert_eq!(bank0.get_balance(&reward_pubkey), u64::MAX,);