Move slot cleanup to AccountsBackgroundService (#13911)
* Move bank drop to AccountsBackgroundService * Send to ABS on drop instead, protects against other places banks are dropped * Fix Abi * test Co-authored-by: Carl Lin <carl@solana.com>
This commit is contained in:
@ -249,6 +249,7 @@ mod tests {
|
||||
use super::*;
|
||||
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
|
||||
use solana_runtime::{
|
||||
accounts_background_service::ABSRequestSender,
|
||||
bank_forks::BankForks,
|
||||
genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs},
|
||||
};
|
||||
@ -539,7 +540,7 @@ mod tests {
|
||||
&working_bank,
|
||||
);
|
||||
for x in 0..root {
|
||||
bank_forks.set_root(x, &None, None);
|
||||
bank_forks.set_root(x, &ABSRequestSender::default(), None);
|
||||
}
|
||||
|
||||
// Add an additional bank/vote that will root slot 2
|
||||
@ -576,7 +577,11 @@ mod tests {
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
bank_forks.set_root(root, &None, Some(highest_confirmed_root));
|
||||
bank_forks.set_root(
|
||||
root,
|
||||
&ABSRequestSender::default(),
|
||||
Some(highest_confirmed_root),
|
||||
);
|
||||
let highest_confirmed_root_bank = bank_forks.get(highest_confirmed_root);
|
||||
assert!(highest_confirmed_root_bank.is_some());
|
||||
|
||||
@ -641,7 +646,11 @@ mod tests {
|
||||
.read()
|
||||
.unwrap()
|
||||
.highest_confirmed_root();
|
||||
bank_forks.set_root(root, &None, Some(highest_confirmed_root));
|
||||
bank_forks.set_root(
|
||||
root,
|
||||
&ABSRequestSender::default(),
|
||||
Some(highest_confirmed_root),
|
||||
);
|
||||
let highest_confirmed_root_bank = bank_forks.get(highest_confirmed_root);
|
||||
assert!(highest_confirmed_root_bank.is_some());
|
||||
}
|
||||
|
@ -1245,6 +1245,7 @@ pub mod test {
|
||||
};
|
||||
use solana_ledger::{blockstore::make_slot_entries, get_tmp_ledger_path};
|
||||
use solana_runtime::{
|
||||
accounts_background_service::ABSRequestSender,
|
||||
bank::Bank,
|
||||
bank_forks::BankForks,
|
||||
genesis_utils::{
|
||||
@ -1417,7 +1418,7 @@ pub mod test {
|
||||
new_root,
|
||||
&self.bank_forks,
|
||||
&mut self.progress,
|
||||
&None,
|
||||
&ABSRequestSender::default(),
|
||||
&mut PubkeyReferences::default(),
|
||||
None,
|
||||
&mut self.heaviest_subtree_fork_choice,
|
||||
|
@ -167,7 +167,9 @@ impl OptimisticallyConfirmedBankTracker {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
|
||||
use solana_runtime::commitment::BlockCommitmentCache;
|
||||
use solana_runtime::{
|
||||
accounts_background_service::ABSRequestSender, commitment::BlockCommitmentCache,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
#[test]
|
||||
@ -279,7 +281,10 @@ mod tests {
|
||||
let bank5 = bank_forks.read().unwrap().get(5).unwrap().clone();
|
||||
let bank7 = Bank::new_from_parent(&bank5, &Pubkey::default(), 7);
|
||||
bank_forks.write().unwrap().insert(bank7);
|
||||
bank_forks.write().unwrap().set_root(7, &None, None);
|
||||
bank_forks
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_root(7, &ABSRequestSender::default(), None);
|
||||
OptimisticallyConfirmedBankTracker::process_notification(
|
||||
BankNotification::OptimisticallyConfirmed(6),
|
||||
&bank_forks,
|
||||
|
@ -29,7 +29,7 @@ use solana_ledger::{
|
||||
use solana_measure::{measure::Measure, thread_mem_usage};
|
||||
use solana_metrics::inc_new_counter_info;
|
||||
use solana_runtime::{
|
||||
accounts_background_service::SnapshotRequestSender, bank::Bank, bank_forks::BankForks,
|
||||
accounts_background_service::ABSRequestSender, bank::Bank, bank_forks::BankForks,
|
||||
commitment::BlockCommitmentCache, vote_sender_types::ReplayVoteSender,
|
||||
};
|
||||
use solana_sdk::{
|
||||
@ -100,7 +100,7 @@ pub struct ReplayStageConfig {
|
||||
pub subscriptions: Arc<RpcSubscriptions>,
|
||||
pub leader_schedule_cache: Arc<LeaderScheduleCache>,
|
||||
pub latest_root_senders: Vec<Sender<Slot>>,
|
||||
pub snapshot_request_sender: Option<SnapshotRequestSender>,
|
||||
pub accounts_background_request_sender: ABSRequestSender,
|
||||
pub block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
||||
pub transaction_status_sender: Option<TransactionStatusSender>,
|
||||
pub rewards_recorder_sender: Option<RewardsRecorderSender>,
|
||||
@ -232,7 +232,7 @@ impl ReplayStage {
|
||||
subscriptions,
|
||||
leader_schedule_cache,
|
||||
latest_root_senders,
|
||||
snapshot_request_sender,
|
||||
accounts_background_request_sender,
|
||||
block_commitment_cache,
|
||||
transaction_status_sender,
|
||||
rewards_recorder_sender,
|
||||
@ -447,7 +447,7 @@ impl ReplayStage {
|
||||
&blockstore,
|
||||
&leader_schedule_cache,
|
||||
&lockouts_sender,
|
||||
&snapshot_request_sender,
|
||||
&accounts_background_request_sender,
|
||||
&latest_root_senders,
|
||||
&mut all_pubkeys,
|
||||
&subscriptions,
|
||||
@ -1039,7 +1039,7 @@ impl ReplayStage {
|
||||
blockstore: &Arc<Blockstore>,
|
||||
leader_schedule_cache: &Arc<LeaderScheduleCache>,
|
||||
lockouts_sender: &Sender<CommitmentAggregationData>,
|
||||
snapshot_request_sender: &Option<SnapshotRequestSender>,
|
||||
accounts_background_request_sender: &ABSRequestSender,
|
||||
latest_root_senders: &[Sender<Slot>],
|
||||
all_pubkeys: &mut PubkeyReferences,
|
||||
subscriptions: &Arc<RpcSubscriptions>,
|
||||
@ -1096,7 +1096,7 @@ impl ReplayStage {
|
||||
new_root,
|
||||
&bank_forks,
|
||||
progress,
|
||||
snapshot_request_sender,
|
||||
accounts_background_request_sender,
|
||||
all_pubkeys,
|
||||
highest_confirmed_root,
|
||||
heaviest_subtree_fork_choice,
|
||||
@ -1816,7 +1816,7 @@ impl ReplayStage {
|
||||
new_root: Slot,
|
||||
bank_forks: &RwLock<BankForks>,
|
||||
progress: &mut ProgressMap,
|
||||
snapshot_request_sender: &Option<SnapshotRequestSender>,
|
||||
accounts_background_request_sender: &ABSRequestSender,
|
||||
all_pubkeys: &mut PubkeyReferences,
|
||||
highest_confirmed_root: Option<Slot>,
|
||||
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
|
||||
@ -1824,7 +1824,7 @@ impl ReplayStage {
|
||||
let old_epoch = bank_forks.read().unwrap().root_bank().epoch();
|
||||
bank_forks.write().unwrap().set_root(
|
||||
new_root,
|
||||
snapshot_request_sender,
|
||||
accounts_background_request_sender,
|
||||
highest_confirmed_root,
|
||||
);
|
||||
let r_bank_forks = bank_forks.read().unwrap();
|
||||
@ -2002,6 +2002,7 @@ pub(crate) mod tests {
|
||||
},
|
||||
};
|
||||
use solana_runtime::{
|
||||
accounts_background_service::ABSRequestSender,
|
||||
commitment::BlockCommitment,
|
||||
genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs},
|
||||
};
|
||||
@ -2240,7 +2241,7 @@ pub(crate) mod tests {
|
||||
root,
|
||||
&bank_forks,
|
||||
&mut progress,
|
||||
&None,
|
||||
&ABSRequestSender::default(),
|
||||
&mut PubkeyReferences::default(),
|
||||
None,
|
||||
&mut heaviest_subtree_fork_choice,
|
||||
@ -2285,7 +2286,7 @@ pub(crate) mod tests {
|
||||
root,
|
||||
&bank_forks,
|
||||
&mut progress,
|
||||
&None,
|
||||
&ABSRequestSender::default(),
|
||||
&mut PubkeyReferences::default(),
|
||||
Some(confirmed_root),
|
||||
&mut heaviest_subtree_fork_choice,
|
||||
@ -3269,7 +3270,7 @@ pub(crate) mod tests {
|
||||
bank_forks.insert(Bank::new_from_parent(&bank0, &Pubkey::default(), 9));
|
||||
let bank9 = bank_forks.get(9).unwrap().clone();
|
||||
bank_forks.insert(Bank::new_from_parent(&bank9, &Pubkey::default(), 10));
|
||||
bank_forks.set_root(9, &None, None);
|
||||
bank_forks.set_root(9, &ABSRequestSender::default(), None);
|
||||
let total_epoch_stake = bank0.total_epoch_stake();
|
||||
|
||||
// Insert new ForkProgress for slot 10 and its
|
||||
@ -3361,7 +3362,7 @@ pub(crate) mod tests {
|
||||
.get_propagated_stats_mut(0)
|
||||
.unwrap()
|
||||
.is_leader_slot = true;
|
||||
bank_forks.set_root(0, &None, None);
|
||||
bank_forks.set_root(0, &ABSRequestSender::default(), None);
|
||||
let total_epoch_stake = bank_forks.root_bank().total_epoch_stake();
|
||||
|
||||
// Insert new ForkProgress representing a slot for all slots 1..=num_banks. Only
|
||||
@ -3442,7 +3443,7 @@ pub(crate) mod tests {
|
||||
.get_propagated_stats_mut(0)
|
||||
.unwrap()
|
||||
.is_leader_slot = true;
|
||||
bank_forks.set_root(0, &None, None);
|
||||
bank_forks.set_root(0, &ABSRequestSender::default(), None);
|
||||
|
||||
let total_epoch_stake = num_validators as u64 * stake_per_validator;
|
||||
|
||||
@ -3788,7 +3789,10 @@ pub(crate) mod tests {
|
||||
));
|
||||
|
||||
// Try to purge the root
|
||||
bank_forks.write().unwrap().set_root(3, &None, None);
|
||||
bank_forks
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_root(3, &ABSRequestSender::default(), None);
|
||||
let mut descendants = bank_forks.read().unwrap().descendants();
|
||||
let mut ancestors = bank_forks.read().unwrap().ancestors();
|
||||
let slot_3_descendants = descendants.get(&3).unwrap().clone();
|
||||
|
@ -2732,7 +2732,9 @@ pub mod tests {
|
||||
blockstore_processor::fill_blockstore_slot_with_ticks,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
};
|
||||
use solana_runtime::commitment::BlockCommitment;
|
||||
use solana_runtime::{
|
||||
accounts_background_service::ABSRequestSender, commitment::BlockCommitment,
|
||||
};
|
||||
use solana_sdk::{
|
||||
clock::MAX_RECENT_BLOCKHASHES,
|
||||
fee_calculator::DEFAULT_BURN_PERCENT,
|
||||
@ -2833,7 +2835,10 @@ pub mod tests {
|
||||
bank_forks.write().unwrap().insert(new_bank);
|
||||
|
||||
for root in roots.iter() {
|
||||
bank_forks.write().unwrap().set_root(*root, &None, Some(0));
|
||||
bank_forks
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_root(*root, &ABSRequestSender::default(), Some(0));
|
||||
let mut stakes = HashMap::new();
|
||||
stakes.insert(leader_vote_keypair.pubkey(), (1, Account::default()));
|
||||
let block_time = bank_forks
|
||||
|
@ -28,7 +28,10 @@ use solana_ledger::{
|
||||
leader_schedule_cache::LeaderScheduleCache,
|
||||
};
|
||||
use solana_runtime::{
|
||||
accounts_background_service::{AccountsBackgroundService, SnapshotRequestHandler},
|
||||
accounts_background_service::{
|
||||
ABSRequestHandler, ABSRequestSender, AccountsBackgroundService, SendDroppedBankCallback,
|
||||
SnapshotRequestHandler,
|
||||
},
|
||||
bank_forks::{BankForks, SnapshotConfig},
|
||||
commitment::BlockCommitmentCache,
|
||||
snapshot_package::AccountsPackageSender,
|
||||
@ -39,6 +42,7 @@ use solana_sdk::{
|
||||
signature::{Keypair, Signer},
|
||||
};
|
||||
use std::{
|
||||
boxed::Box,
|
||||
collections::HashSet,
|
||||
net::UdpSocket,
|
||||
sync::{
|
||||
@ -208,6 +212,22 @@ impl Tvu {
|
||||
.unwrap_or((None, None))
|
||||
};
|
||||
|
||||
let (pruned_banks_sender, pruned_banks_receiver) = unbounded();
|
||||
|
||||
// Before replay starts, set the callbacks in each of the banks in BankForks
|
||||
for bank in bank_forks.read().unwrap().banks.values() {
|
||||
bank.set_callback(Some(Box::new(SendDroppedBankCallback::new(
|
||||
pruned_banks_sender.clone(),
|
||||
))));
|
||||
}
|
||||
|
||||
let accounts_background_request_sender = ABSRequestSender::new(snapshot_request_sender);
|
||||
|
||||
let accounts_background_request_handler = ABSRequestHandler {
|
||||
snapshot_request_handler,
|
||||
pruned_banks_receiver,
|
||||
};
|
||||
|
||||
let replay_stage_config = ReplayStageConfig {
|
||||
my_pubkey: keypair.pubkey(),
|
||||
vote_account: *vote_account,
|
||||
@ -216,7 +236,7 @@ impl Tvu {
|
||||
subscriptions: subscriptions.clone(),
|
||||
leader_schedule_cache: leader_schedule_cache.clone(),
|
||||
latest_root_senders: vec![ledger_cleanup_slot_sender],
|
||||
snapshot_request_sender,
|
||||
accounts_background_request_sender,
|
||||
block_commitment_cache,
|
||||
transaction_status_sender,
|
||||
rewards_recorder_sender,
|
||||
@ -248,8 +268,11 @@ impl Tvu {
|
||||
)
|
||||
});
|
||||
|
||||
let accounts_background_service =
|
||||
AccountsBackgroundService::new(bank_forks.clone(), &exit, snapshot_request_handler);
|
||||
let accounts_background_service = AccountsBackgroundService::new(
|
||||
bank_forks.clone(),
|
||||
&exit,
|
||||
accounts_background_request_handler,
|
||||
);
|
||||
|
||||
Tvu {
|
||||
fetch_stage,
|
||||
|
Reference in New Issue
Block a user