Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Bank::ensure_no_storage_rewards_pool() #26468

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7366,7 +7366,6 @@ impl Bank {
);
self.reconfigure_token2_native_mint();
}
self.ensure_no_storage_rewards_pool();

if new_feature_activations.contains(&feature_set::cap_accounts_data_len::id()) {
const ACCOUNTS_DATA_LEN: u64 = 50_000_000_000;
Expand Down Expand Up @@ -7531,36 +7530,6 @@ impl Bank {
}
}

fn ensure_no_storage_rewards_pool(&mut self) {
let purge_window_epoch = match self.cluster_type() {
ClusterType::Development => false,
// never do this for devnet; we're pristine here. :)
ClusterType::Devnet => false,
// schedule to remove at testnet/tds
ClusterType::Testnet => self.epoch() == 93,
// never do this for stable; we're pristine here. :)
ClusterType::MainnetBeta => false,
};
Comment on lines -7535 to -7543
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Testnet is now well past epoch 93, purge_window_epoch will always be false, and thus this function practically does nothing.


if purge_window_epoch {
for reward_pubkey in self.rewards_pool_pubkeys.iter() {
if let Some(mut reward_account) = self.get_account_with_fixed_root(reward_pubkey) {
if reward_account.lamports() == u64::MAX {
reward_account.set_lamports(0);
self.store_account(reward_pubkey, &reward_account);
// Adjust capitalization.... it has been wrapping, reducing the real capitalization by 1-lamport
self.capitalization.fetch_add(1, Relaxed);
info!(
"purged rewards pool account: {}, new capitalization: {}",
reward_pubkey,
self.capitalization()
);
}
};
}
}
}

/// Get all the accounts for this bank and calculate stats
pub fn get_total_accounts_stats(&self) -> ScanResult<TotalAccountsStats> {
let accounts = self.get_all_accounts_with_modified_slots()?;
Expand Down Expand Up @@ -14966,57 +14935,6 @@ pub(crate) mod tests {
assert_eq!(native_mint_account.owner(), &inline_spl_token::id());
}

#[test]
fn test_ensure_no_storage_rewards_pool() {
solana_logger::setup();

let mut genesis_config =
create_genesis_config_with_leader(5, &solana_sdk::pubkey::new_rand(), 0).genesis_config;

// Testnet - Storage rewards pool is purged at epoch 93
// Also this is with bad capitalization
genesis_config.cluster_type = ClusterType::Testnet;
genesis_config.inflation = Inflation::default();
let reward_pubkey = solana_sdk::pubkey::new_rand();
genesis_config.rewards_pools.insert(
reward_pubkey,
Account::new(u64::MAX, 0, &solana_sdk::pubkey::new_rand()),
);
let bank0 = Bank::new_for_tests(&genesis_config);
// because capitalization has been reset with bogus capitalization calculation allowing overflows,
// deliberately substract 1 lamport to simulate it
bank0.capitalization.fetch_sub(1, Relaxed);
let bank0 = Arc::new(bank0);
assert_eq!(bank0.get_balance(&reward_pubkey), u64::MAX,);

let bank1 = Bank::new_from_parent(
&bank0,
&Pubkey::default(),
genesis_config.epoch_schedule.get_first_slot_in_epoch(93),
);

// assert that everything gets in order....
assert!(bank1.get_account(&reward_pubkey).is_none());
let sysvar_and_builtin_program_delta = 1;
assert_eq!(
bank0.capitalization() + 1 + 1_000_000_000 + sysvar_and_builtin_program_delta,
bank1.capitalization()
);
assert_eq!(bank1.capitalization(), bank1.calculate_capitalization(true));

// Depending on RUSTFLAGS, this test exposes rust's checked math behavior or not...
// So do some convolted setup; anyway this test itself will just be temporary
let bank0 = std::panic::AssertUnwindSafe(bank0);
let overflowing_capitalization =
std::panic::catch_unwind(|| bank0.calculate_capitalization(true));
if let Ok(overflowing_capitalization) = overflowing_capitalization {
info!("asserting overflowing capitalization for bank0");
assert_eq!(overflowing_capitalization, bank0.capitalization());
} else {
info!("NOT-asserting overflowing capitalization for bank0");
}
}

#[derive(Debug)]
struct TestExecutor {}
impl Executor for TestExecutor {
Expand Down