blockstore_processor now accepts an Arc<Rwlock<BankForks>>
This commit is contained in:
parent
0e2e0c8b7d
commit
c6f3da4879
|
@ -491,7 +491,7 @@ impl Validator {
|
||||||
|
|
||||||
let (
|
let (
|
||||||
genesis_config,
|
genesis_config,
|
||||||
mut bank_forks,
|
bank_forks,
|
||||||
blockstore,
|
blockstore,
|
||||||
ledger_signal_receiver,
|
ledger_signal_receiver,
|
||||||
completed_slots_receiver,
|
completed_slots_receiver,
|
||||||
|
@ -522,7 +522,7 @@ impl Validator {
|
||||||
let pending_accounts_package = PendingAccountsPackage::default();
|
let pending_accounts_package = PendingAccountsPackage::default();
|
||||||
let last_full_snapshot_slot = process_blockstore(
|
let last_full_snapshot_slot = process_blockstore(
|
||||||
&blockstore,
|
&blockstore,
|
||||||
&mut bank_forks,
|
&bank_forks,
|
||||||
&leader_schedule_cache,
|
&leader_schedule_cache,
|
||||||
&blockstore_process_options,
|
&blockstore_process_options,
|
||||||
transaction_status_sender.as_ref(),
|
transaction_status_sender.as_ref(),
|
||||||
|
@ -535,7 +535,8 @@ impl Validator {
|
||||||
let last_full_snapshot_slot =
|
let last_full_snapshot_slot =
|
||||||
last_full_snapshot_slot.or_else(|| starting_snapshot_hashes.map(|x| x.full.hash.0));
|
last_full_snapshot_slot.or_else(|| starting_snapshot_hashes.map(|x| x.full.hash.0));
|
||||||
|
|
||||||
maybe_warp_slot(config, ledger_path, &mut bank_forks, &leader_schedule_cache);
|
maybe_warp_slot(config, ledger_path, &bank_forks, &leader_schedule_cache);
|
||||||
|
|
||||||
let tower = {
|
let tower = {
|
||||||
let restored_tower = Tower::restore(config.tower_storage.as_ref(), &id);
|
let restored_tower = Tower::restore(config.tower_storage.as_ref(), &id);
|
||||||
if let Ok(tower) = &restored_tower {
|
if let Ok(tower) = &restored_tower {
|
||||||
|
@ -545,7 +546,13 @@ impl Validator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
post_process_restored_tower(restored_tower, &id, vote_account, config, &bank_forks)
|
post_process_restored_tower(
|
||||||
|
restored_tower,
|
||||||
|
&id,
|
||||||
|
vote_account,
|
||||||
|
config,
|
||||||
|
&bank_forks.read().unwrap(),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
info!("Tower state: {:?}", tower);
|
info!("Tower state: {:?}", tower);
|
||||||
|
|
||||||
|
@ -559,7 +566,6 @@ impl Validator {
|
||||||
}
|
}
|
||||||
|
|
||||||
let leader_schedule_cache = Arc::new(leader_schedule_cache);
|
let leader_schedule_cache = Arc::new(leader_schedule_cache);
|
||||||
let bank_forks = Arc::new(RwLock::new(bank_forks));
|
|
||||||
|
|
||||||
let sample_performance_service =
|
let sample_performance_service =
|
||||||
if config.rpc_addrs.is_some() && config.rpc_config.enable_rpc_transaction_history {
|
if config.rpc_addrs.is_some() && config.rpc_config.enable_rpc_transaction_history {
|
||||||
|
@ -1321,7 +1327,7 @@ fn load_blockstore(
|
||||||
poh_timing_point_sender: Option<PohTimingSender>,
|
poh_timing_point_sender: Option<PohTimingSender>,
|
||||||
) -> (
|
) -> (
|
||||||
GenesisConfig,
|
GenesisConfig,
|
||||||
BankForks,
|
Arc<RwLock<BankForks>>,
|
||||||
Arc<Blockstore>,
|
Arc<Blockstore>,
|
||||||
Receiver<bool>,
|
Receiver<bool>,
|
||||||
CompletedSlotsReceiver,
|
CompletedSlotsReceiver,
|
||||||
|
@ -1409,26 +1415,24 @@ fn load_blockstore(
|
||||||
TransactionHistoryServices::default()
|
TransactionHistoryServices::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let (
|
let (bank_forks, mut leader_schedule_cache, starting_snapshot_hashes, pruned_banks_receiver) =
|
||||||
mut bank_forks,
|
bank_forks_utils::load_bank_forks(
|
||||||
mut leader_schedule_cache,
|
&genesis_config,
|
||||||
starting_snapshot_hashes,
|
&blockstore,
|
||||||
pruned_banks_receiver,
|
config.account_paths.clone(),
|
||||||
) = bank_forks_utils::load_bank_forks(
|
config.account_shrink_paths.clone(),
|
||||||
&genesis_config,
|
config.snapshot_config.as_ref(),
|
||||||
&blockstore,
|
&process_options,
|
||||||
config.account_paths.clone(),
|
transaction_history_services
|
||||||
config.account_shrink_paths.clone(),
|
.cache_block_meta_sender
|
||||||
config.snapshot_config.as_ref(),
|
.as_ref(),
|
||||||
&process_options,
|
accounts_update_notifier,
|
||||||
transaction_history_services
|
);
|
||||||
.cache_block_meta_sender
|
|
||||||
.as_ref(),
|
|
||||||
accounts_update_notifier,
|
|
||||||
);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let hard_forks: Vec<_> = bank_forks
|
let hard_forks: Vec<_> = bank_forks
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
.working_bank()
|
.working_bank()
|
||||||
.hard_forks()
|
.hard_forks()
|
||||||
.read()
|
.read()
|
||||||
|
@ -1442,12 +1446,15 @@ fn load_blockstore(
|
||||||
}
|
}
|
||||||
|
|
||||||
leader_schedule_cache.set_fixed_leader_schedule(config.fixed_leader_schedule.clone());
|
leader_schedule_cache.set_fixed_leader_schedule(config.fixed_leader_schedule.clone());
|
||||||
bank_forks.set_snapshot_config(config.snapshot_config.clone());
|
{
|
||||||
bank_forks.set_accounts_hash_interval_slots(config.accounts_hash_interval_slots);
|
let mut bank_forks = bank_forks.write().unwrap();
|
||||||
if let Some(ref shrink_paths) = config.account_shrink_paths {
|
bank_forks.set_snapshot_config(config.snapshot_config.clone());
|
||||||
bank_forks
|
bank_forks.set_accounts_hash_interval_slots(config.accounts_hash_interval_slots);
|
||||||
.working_bank()
|
if let Some(ref shrink_paths) = config.account_shrink_paths {
|
||||||
.set_shrink_paths(shrink_paths.clone());
|
bank_forks
|
||||||
|
.working_bank()
|
||||||
|
.set_shrink_paths(shrink_paths.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
|
@ -1468,7 +1475,7 @@ fn load_blockstore(
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn process_blockstore(
|
fn process_blockstore(
|
||||||
blockstore: &Blockstore,
|
blockstore: &Blockstore,
|
||||||
bank_forks: &mut BankForks,
|
bank_forks: &RwLock<BankForks>,
|
||||||
leader_schedule_cache: &LeaderScheduleCache,
|
leader_schedule_cache: &LeaderScheduleCache,
|
||||||
process_options: &blockstore_processor::ProcessOptions,
|
process_options: &blockstore_processor::ProcessOptions,
|
||||||
transaction_status_sender: Option<&TransactionStatusSender>,
|
transaction_status_sender: Option<&TransactionStatusSender>,
|
||||||
|
@ -1502,7 +1509,7 @@ fn process_blockstore(
|
||||||
fn maybe_warp_slot(
|
fn maybe_warp_slot(
|
||||||
config: &ValidatorConfig,
|
config: &ValidatorConfig,
|
||||||
ledger_path: &Path,
|
ledger_path: &Path,
|
||||||
bank_forks: &mut BankForks,
|
bank_forks: &RwLock<BankForks>,
|
||||||
leader_schedule_cache: &LeaderScheduleCache,
|
leader_schedule_cache: &LeaderScheduleCache,
|
||||||
) {
|
) {
|
||||||
if let Some(warp_slot) = config.warp_slot {
|
if let Some(warp_slot) = config.warp_slot {
|
||||||
|
@ -1511,6 +1518,8 @@ fn maybe_warp_slot(
|
||||||
abort();
|
abort();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mut bank_forks = bank_forks.write().unwrap();
|
||||||
|
|
||||||
let working_bank = bank_forks.working_bank();
|
let working_bank = bank_forks.working_bank();
|
||||||
|
|
||||||
if warp_slot <= working_bank.slot() {
|
if warp_slot <= working_bank.slot() {
|
||||||
|
@ -1523,8 +1532,9 @@ fn maybe_warp_slot(
|
||||||
}
|
}
|
||||||
info!("warping to slot {}", warp_slot);
|
info!("warping to slot {}", warp_slot);
|
||||||
|
|
||||||
|
let root_bank = bank_forks.root_bank();
|
||||||
bank_forks.insert(Bank::warp_from_parent(
|
bank_forks.insert(Bank::warp_from_parent(
|
||||||
&bank_forks.root_bank(),
|
&root_bank,
|
||||||
&Pubkey::default(),
|
&Pubkey::default(),
|
||||||
warp_slot,
|
warp_slot,
|
||||||
));
|
));
|
||||||
|
|
|
@ -729,7 +729,7 @@ fn load_bank_forks(
|
||||||
blockstore: &Blockstore,
|
blockstore: &Blockstore,
|
||||||
process_options: ProcessOptions,
|
process_options: ProcessOptions,
|
||||||
snapshot_archive_path: Option<PathBuf>,
|
snapshot_archive_path: Option<PathBuf>,
|
||||||
) -> Result<(BankForks, Option<StartingSnapshotHashes>), BlockstoreProcessorError> {
|
) -> Result<(Arc<RwLock<BankForks>>, Option<StartingSnapshotHashes>), BlockstoreProcessorError> {
|
||||||
let bank_snapshots_dir = blockstore
|
let bank_snapshots_dir = blockstore
|
||||||
.ledger_path()
|
.ledger_path()
|
||||||
.join(if blockstore.is_primary_access() {
|
.join(if blockstore.is_primary_access() {
|
||||||
|
@ -1812,7 +1812,15 @@ fn main() {
|
||||||
"{}",
|
"{}",
|
||||||
compute_shred_version(
|
compute_shred_version(
|
||||||
&genesis_config.hash(),
|
&genesis_config.hash(),
|
||||||
Some(&bank_forks.working_bank().hard_forks().read().unwrap())
|
Some(
|
||||||
|
&bank_forks
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.working_bank()
|
||||||
|
.hard_forks()
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1888,7 +1896,7 @@ fn main() {
|
||||||
snapshot_archive_path,
|
snapshot_archive_path,
|
||||||
) {
|
) {
|
||||||
Ok((bank_forks, ..)) => {
|
Ok((bank_forks, ..)) => {
|
||||||
println!("{}", &bank_forks.working_bank().hash());
|
println!("{}", &bank_forks.read().unwrap().working_bank().hash());
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Failed to load ledger: {:?}", err);
|
eprintln!("Failed to load ledger: {:?}", err);
|
||||||
|
@ -2143,7 +2151,7 @@ fn main() {
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
if print_accounts_stats {
|
if print_accounts_stats {
|
||||||
let working_bank = bank_forks.working_bank();
|
let working_bank = bank_forks.read().unwrap().working_bank();
|
||||||
working_bank.print_accounts_stats();
|
working_bank.print_accounts_stats();
|
||||||
}
|
}
|
||||||
exit_signal.store(true, Ordering::Relaxed);
|
exit_signal.store(true, Ordering::Relaxed);
|
||||||
|
@ -2176,8 +2184,10 @@ fn main() {
|
||||||
snapshot_archive_path,
|
snapshot_archive_path,
|
||||||
) {
|
) {
|
||||||
Ok((bank_forks, ..)) => {
|
Ok((bank_forks, ..)) => {
|
||||||
let dot =
|
let dot = graph_forks(
|
||||||
graph_forks(&bank_forks, arg_matches.is_present("include_all_votes"));
|
&bank_forks.read().unwrap(),
|
||||||
|
arg_matches.is_present("include_all_votes"),
|
||||||
|
);
|
||||||
|
|
||||||
let extension = Path::new(&output_file).extension();
|
let extension = Path::new(&output_file).extension();
|
||||||
let result = if extension == Some(OsStr::new("pdf")) {
|
let result = if extension == Some(OsStr::new("pdf")) {
|
||||||
|
@ -2295,6 +2305,8 @@ fn main() {
|
||||||
) {
|
) {
|
||||||
Ok((bank_forks, starting_snapshot_hashes)) => {
|
Ok((bank_forks, starting_snapshot_hashes)) => {
|
||||||
let mut bank = bank_forks
|
let mut bank = bank_forks
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
.get(snapshot_slot)
|
.get(snapshot_slot)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
eprintln!("Error: Slot {} is not available", snapshot_slot);
|
eprintln!("Error: Slot {} is not available", snapshot_slot);
|
||||||
|
@ -2610,7 +2622,7 @@ fn main() {
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let bank = bank_forks.working_bank();
|
let bank = bank_forks.read().unwrap().working_bank();
|
||||||
let mut measure = Measure::start("getting accounts");
|
let mut measure = Measure::start("getting accounts");
|
||||||
let accounts: BTreeMap<_, _> = bank
|
let accounts: BTreeMap<_, _> = bank
|
||||||
.get_all_accounts_with_modified_slots()
|
.get_all_accounts_with_modified_slots()
|
||||||
|
@ -2671,6 +2683,7 @@ fn main() {
|
||||||
snapshot_archive_path,
|
snapshot_archive_path,
|
||||||
) {
|
) {
|
||||||
Ok((bank_forks, ..)) => {
|
Ok((bank_forks, ..)) => {
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
let slot = bank_forks.working_bank().slot();
|
let slot = bank_forks.working_bank().slot();
|
||||||
let bank = bank_forks.get(slot).unwrap_or_else(|| {
|
let bank = bank_forks.get(slot).unwrap_or_else(|| {
|
||||||
eprintln!("Error: Slot {} is not available", slot);
|
eprintln!("Error: Slot {} is not available", slot);
|
||||||
|
|
|
@ -20,12 +20,17 @@ use {
|
||||||
snapshot_utils,
|
snapshot_utils,
|
||||||
},
|
},
|
||||||
solana_sdk::genesis_config::GenesisConfig,
|
solana_sdk::genesis_config::GenesisConfig,
|
||||||
std::{fs, path::PathBuf, process, result},
|
std::{
|
||||||
|
fs,
|
||||||
|
path::PathBuf,
|
||||||
|
process, result,
|
||||||
|
sync::{Arc, RwLock},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type LoadResult = result::Result<
|
pub type LoadResult = result::Result<
|
||||||
(
|
(
|
||||||
BankForks,
|
Arc<RwLock<BankForks>>,
|
||||||
LeaderScheduleCache,
|
LeaderScheduleCache,
|
||||||
Option<StartingSnapshotHashes>,
|
Option<StartingSnapshotHashes>,
|
||||||
),
|
),
|
||||||
|
@ -52,7 +57,7 @@ pub fn load(
|
||||||
pending_accounts_package: PendingAccountsPackage,
|
pending_accounts_package: PendingAccountsPackage,
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
) -> LoadResult {
|
) -> LoadResult {
|
||||||
let (mut bank_forks, leader_schedule_cache, starting_snapshot_hashes, pruned_banks_receiver) =
|
let (bank_forks, leader_schedule_cache, starting_snapshot_hashes, pruned_banks_receiver) =
|
||||||
load_bank_forks(
|
load_bank_forks(
|
||||||
genesis_config,
|
genesis_config,
|
||||||
blockstore,
|
blockstore,
|
||||||
|
@ -66,7 +71,7 @@ pub fn load(
|
||||||
|
|
||||||
blockstore_processor::process_blockstore_from_root(
|
blockstore_processor::process_blockstore_from_root(
|
||||||
blockstore,
|
blockstore,
|
||||||
&mut bank_forks,
|
&bank_forks,
|
||||||
&leader_schedule_cache,
|
&leader_schedule_cache,
|
||||||
&process_options,
|
&process_options,
|
||||||
transaction_status_sender,
|
transaction_status_sender,
|
||||||
|
@ -89,7 +94,7 @@ pub fn load_bank_forks(
|
||||||
cache_block_meta_sender: Option<&CacheBlockMetaSender>,
|
cache_block_meta_sender: Option<&CacheBlockMetaSender>,
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
) -> (
|
) -> (
|
||||||
BankForks,
|
Arc<RwLock<BankForks>>,
|
||||||
LeaderScheduleCache,
|
LeaderScheduleCache,
|
||||||
Option<StartingSnapshotHashes>,
|
Option<StartingSnapshotHashes>,
|
||||||
DroppedSlotsReceiver,
|
DroppedSlotsReceiver,
|
||||||
|
@ -160,23 +165,27 @@ pub fn load_bank_forks(
|
||||||
// There should only be one bank, the root bank in BankForks. Thus all banks added to
|
// There should only be one bank, the root bank in BankForks. Thus all banks added to
|
||||||
// BankForks from now on will be descended from the root bank and thus will inherit
|
// BankForks from now on will be descended from the root bank and thus will inherit
|
||||||
// the bank drop callback.
|
// the bank drop callback.
|
||||||
assert_eq!(bank_forks.banks().len(), 1);
|
assert_eq!(bank_forks.read().unwrap().banks().len(), 1);
|
||||||
let (pruned_banks_sender, pruned_banks_receiver) = bounded(MAX_DROP_BANK_SIGNAL_QUEUE_SIZE);
|
let (pruned_banks_sender, pruned_banks_receiver) = bounded(MAX_DROP_BANK_SIGNAL_QUEUE_SIZE);
|
||||||
let root_bank = bank_forks.root_bank();
|
|
||||||
let callback = root_bank
|
|
||||||
.rc
|
|
||||||
.accounts
|
|
||||||
.accounts_db
|
|
||||||
.create_drop_bank_callback(pruned_banks_sender);
|
|
||||||
root_bank.set_callback(Some(Box::new(callback)));
|
|
||||||
|
|
||||||
let mut leader_schedule_cache = LeaderScheduleCache::new_from_bank(&root_bank);
|
let leader_schedule_cache = {
|
||||||
if process_options.full_leader_cache {
|
let root_bank = bank_forks.read().unwrap().root_bank();
|
||||||
leader_schedule_cache.set_max_schedules(std::usize::MAX);
|
let callback = root_bank
|
||||||
}
|
.rc
|
||||||
|
.accounts
|
||||||
|
.accounts_db
|
||||||
|
.create_drop_bank_callback(pruned_banks_sender);
|
||||||
|
root_bank.set_callback(Some(Box::new(callback)));
|
||||||
|
|
||||||
|
let mut leader_schedule_cache = LeaderScheduleCache::new_from_bank(&root_bank);
|
||||||
|
if process_options.full_leader_cache {
|
||||||
|
leader_schedule_cache.set_max_schedules(std::usize::MAX);
|
||||||
|
}
|
||||||
|
leader_schedule_cache
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(ref new_hard_forks) = process_options.new_hard_forks {
|
if let Some(ref new_hard_forks) = process_options.new_hard_forks {
|
||||||
let root_bank = bank_forks.root_bank();
|
let root_bank = bank_forks.read().unwrap().root_bank();
|
||||||
let hard_forks = root_bank.hard_forks();
|
let hard_forks = root_bank.hard_forks();
|
||||||
|
|
||||||
for hard_fork_slot in new_hard_forks.iter() {
|
for hard_fork_slot in new_hard_forks.iter() {
|
||||||
|
@ -207,7 +216,7 @@ fn bank_forks_from_snapshot(
|
||||||
snapshot_config: &SnapshotConfig,
|
snapshot_config: &SnapshotConfig,
|
||||||
process_options: &ProcessOptions,
|
process_options: &ProcessOptions,
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
) -> (BankForks, Option<StartingSnapshotHashes>) {
|
) -> (Arc<RwLock<BankForks>>, Option<StartingSnapshotHashes>) {
|
||||||
// Fail hard here if snapshot fails to load, don't silently continue
|
// Fail hard here if snapshot fails to load, don't silently continue
|
||||||
if account_paths.is_empty() {
|
if account_paths.is_empty() {
|
||||||
error!("Account paths not present when booting from snapshot");
|
error!("Account paths not present when booting from snapshot");
|
||||||
|
@ -264,7 +273,7 @@ fn bank_forks_from_snapshot(
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
BankForks::new(deserialized_bank),
|
Arc::new(RwLock::new(BankForks::new(deserialized_bank))),
|
||||||
Some(starting_snapshot_hashes),
|
Some(starting_snapshot_hashes),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,8 +567,8 @@ pub fn test_process_blockstore(
|
||||||
genesis_config: &GenesisConfig,
|
genesis_config: &GenesisConfig,
|
||||||
blockstore: &Blockstore,
|
blockstore: &Blockstore,
|
||||||
opts: ProcessOptions,
|
opts: ProcessOptions,
|
||||||
) -> (BankForks, LeaderScheduleCache) {
|
) -> (Arc<RwLock<BankForks>>, LeaderScheduleCache) {
|
||||||
let (mut bank_forks, leader_schedule_cache, .., pruned_banks_receiver) =
|
let (bank_forks, leader_schedule_cache, .., pruned_banks_receiver) =
|
||||||
crate::bank_forks_utils::load_bank_forks(
|
crate::bank_forks_utils::load_bank_forks(
|
||||||
genesis_config,
|
genesis_config,
|
||||||
blockstore,
|
blockstore,
|
||||||
|
@ -581,7 +581,7 @@ pub fn test_process_blockstore(
|
||||||
);
|
);
|
||||||
process_blockstore_from_root(
|
process_blockstore_from_root(
|
||||||
blockstore,
|
blockstore,
|
||||||
&mut bank_forks,
|
&bank_forks,
|
||||||
&leader_schedule_cache,
|
&leader_schedule_cache,
|
||||||
&opts,
|
&opts,
|
||||||
None,
|
None,
|
||||||
|
@ -601,7 +601,7 @@ pub(crate) fn process_blockstore_for_bank_0(
|
||||||
opts: &ProcessOptions,
|
opts: &ProcessOptions,
|
||||||
cache_block_meta_sender: Option<&CacheBlockMetaSender>,
|
cache_block_meta_sender: Option<&CacheBlockMetaSender>,
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
) -> BankForks {
|
) -> Arc<RwLock<BankForks>> {
|
||||||
// Setup bank for slot 0
|
// Setup bank for slot 0
|
||||||
let mut bank0 = Bank::new_with_paths(
|
let mut bank0 = Bank::new_with_paths(
|
||||||
genesis_config,
|
genesis_config,
|
||||||
|
@ -616,11 +616,11 @@ pub(crate) fn process_blockstore_for_bank_0(
|
||||||
accounts_update_notifier,
|
accounts_update_notifier,
|
||||||
);
|
);
|
||||||
bank0.set_compute_budget(opts.runtime_config.compute_budget);
|
bank0.set_compute_budget(opts.runtime_config.compute_budget);
|
||||||
let bank_forks = BankForks::new(bank0);
|
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank0)));
|
||||||
|
|
||||||
info!("processing ledger for slot 0...");
|
info!("processing ledger for slot 0...");
|
||||||
process_bank_0(
|
process_bank_0(
|
||||||
&bank_forks.root_bank(),
|
&bank_forks.read().unwrap().root_bank(),
|
||||||
blockstore,
|
blockstore,
|
||||||
opts,
|
opts,
|
||||||
&VerifyRecyclers::default(),
|
&VerifyRecyclers::default(),
|
||||||
|
@ -633,7 +633,7 @@ pub(crate) fn process_blockstore_for_bank_0(
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn process_blockstore_from_root(
|
pub fn process_blockstore_from_root(
|
||||||
blockstore: &Blockstore,
|
blockstore: &Blockstore,
|
||||||
bank_forks: &mut BankForks,
|
bank_forks: &RwLock<BankForks>,
|
||||||
leader_schedule_cache: &LeaderScheduleCache,
|
leader_schedule_cache: &LeaderScheduleCache,
|
||||||
opts: &ProcessOptions,
|
opts: &ProcessOptions,
|
||||||
transaction_status_sender: Option<&TransactionStatusSender>,
|
transaction_status_sender: Option<&TransactionStatusSender>,
|
||||||
|
@ -652,8 +652,8 @@ pub fn process_blockstore_from_root(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starting slot must be a root, and thus has no parents
|
// Starting slot must be a root, and thus has no parents
|
||||||
assert_eq!(bank_forks.banks().len(), 1);
|
assert_eq!(bank_forks.read().unwrap().banks().len(), 1);
|
||||||
let bank = bank_forks.root_bank();
|
let bank = bank_forks.read().unwrap().root_bank();
|
||||||
assert!(bank.parent().is_none());
|
assert!(bank.parent().is_none());
|
||||||
|
|
||||||
let start_slot = bank.slot();
|
let start_slot = bank.slot();
|
||||||
|
@ -716,11 +716,15 @@ pub fn process_blockstore_from_root(
|
||||||
// In that case, we're most likely restored from the last good snapshot and replayed up to this root.
|
// In that case, we're most likely restored from the last good snapshot and replayed up to this root.
|
||||||
// So again check here for the bad capitalization to avoid to continue until the next snapshot creation.
|
// So again check here for the bad capitalization to avoid to continue until the next snapshot creation.
|
||||||
if !bank_forks
|
if !bank_forks
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
.root_bank()
|
.root_bank()
|
||||||
.calculate_and_verify_capitalization(debug_verify)
|
.calculate_and_verify_capitalization(debug_verify)
|
||||||
{
|
{
|
||||||
return Err(
|
return Err(
|
||||||
BlockstoreProcessorError::RootBankWithMismatchedCapitalization(bank_forks.root()),
|
BlockstoreProcessorError::RootBankWithMismatchedCapitalization(
|
||||||
|
bank_forks.read().unwrap().root(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
time_cap.stop();
|
time_cap.stop();
|
||||||
|
@ -728,26 +732,33 @@ pub fn process_blockstore_from_root(
|
||||||
datapoint_info!(
|
datapoint_info!(
|
||||||
"process_blockstore_from_root",
|
"process_blockstore_from_root",
|
||||||
("total_time_us", processing_time.as_micros(), i64),
|
("total_time_us", processing_time.as_micros(), i64),
|
||||||
("frozen_banks", bank_forks.frozen_banks().len(), i64),
|
(
|
||||||
("slot", bank_forks.root(), i64),
|
"frozen_banks",
|
||||||
("forks", bank_forks.banks().len(), i64),
|
bank_forks.read().unwrap().frozen_banks().len(),
|
||||||
|
i64
|
||||||
|
),
|
||||||
|
("slot", bank_forks.read().unwrap().root(), i64),
|
||||||
|
("forks", bank_forks.read().unwrap().banks().len(), i64),
|
||||||
("calculate_capitalization_us", time_cap.as_us(), i64),
|
("calculate_capitalization_us", time_cap.as_us(), i64),
|
||||||
);
|
);
|
||||||
|
|
||||||
info!("ledger processing timing: {:?}", timing);
|
info!("ledger processing timing: {:?}", timing);
|
||||||
let mut bank_slots = bank_forks.banks().keys().collect::<Vec<_>>();
|
{
|
||||||
bank_slots.sort_unstable();
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
let mut bank_slots = bank_forks.banks().keys().collect::<Vec<_>>();
|
||||||
|
bank_slots.sort_unstable();
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"ledger processed in {}. root slot is {}, {} bank{}: {}",
|
"ledger processed in {}. root slot is {}, {} bank{}: {}",
|
||||||
HumanTime::from(chrono::Duration::from_std(processing_time).unwrap())
|
HumanTime::from(chrono::Duration::from_std(processing_time).unwrap())
|
||||||
.to_text_en(Accuracy::Precise, Tense::Present),
|
.to_text_en(Accuracy::Precise, Tense::Present),
|
||||||
bank_forks.root(),
|
bank_forks.root(),
|
||||||
bank_slots.len(),
|
bank_slots.len(),
|
||||||
if bank_slots.len() > 1 { "s" } else { "" },
|
if bank_slots.len() > 1 { "s" } else { "" },
|
||||||
bank_slots.iter().map(|slot| slot.to_string()).join(", "),
|
bank_slots.iter().map(|slot| slot.to_string()).join(", "),
|
||||||
);
|
);
|
||||||
assert!(bank_forks.active_banks().is_empty());
|
assert!(bank_forks.active_banks().is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
Ok(last_full_snapshot_slot)
|
Ok(last_full_snapshot_slot)
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1150,7 @@ fn process_next_slots(
|
||||||
// given `meta` and return a vector of frozen bank forks
|
// given `meta` and return a vector of frozen bank forks
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn load_frozen_forks(
|
fn load_frozen_forks(
|
||||||
bank_forks: &mut BankForks,
|
bank_forks: &RwLock<BankForks>,
|
||||||
start_slot: Slot,
|
start_slot: Slot,
|
||||||
start_slot_meta: &SlotMeta,
|
start_slot_meta: &SlotMeta,
|
||||||
blockstore: &Blockstore,
|
blockstore: &Blockstore,
|
||||||
|
@ -1161,7 +1172,7 @@ fn load_frozen_forks(
|
||||||
let mut slots_elapsed = 0;
|
let mut slots_elapsed = 0;
|
||||||
let mut txs = 0;
|
let mut txs = 0;
|
||||||
let blockstore_max_root = blockstore.max_root();
|
let blockstore_max_root = blockstore.max_root();
|
||||||
let mut root = bank_forks.root();
|
let mut root = bank_forks.read().unwrap().root();
|
||||||
let max_root = std::cmp::max(root, blockstore_max_root);
|
let max_root = std::cmp::max(root, blockstore_max_root);
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
|
@ -1170,7 +1181,7 @@ fn load_frozen_forks(
|
||||||
);
|
);
|
||||||
|
|
||||||
process_next_slots(
|
process_next_slots(
|
||||||
bank_forks.get(start_slot).unwrap(),
|
bank_forks.read().unwrap().get(start_slot).unwrap(),
|
||||||
start_slot_meta,
|
start_slot_meta,
|
||||||
blockstore,
|
blockstore,
|
||||||
leader_schedule_cache,
|
leader_schedule_cache,
|
||||||
|
@ -1181,7 +1192,7 @@ fn load_frozen_forks(
|
||||||
.runtime_config
|
.runtime_config
|
||||||
.dev_halt_at_slot
|
.dev_halt_at_slot
|
||||||
.unwrap_or(std::u64::MAX);
|
.unwrap_or(std::u64::MAX);
|
||||||
if bank_forks.root() != dev_halt_at_slot {
|
if bank_forks.read().unwrap().root() != dev_halt_at_slot {
|
||||||
while !pending_slots.is_empty() {
|
while !pending_slots.is_empty() {
|
||||||
timing.details.per_program_timings.clear();
|
timing.details.per_program_timings.clear();
|
||||||
let (meta, bank, last_entry_hash) = pending_slots.pop().unwrap();
|
let (meta, bank, last_entry_hash) = pending_slots.pop().unwrap();
|
||||||
|
@ -1203,7 +1214,7 @@ fn load_frozen_forks(
|
||||||
|
|
||||||
let mut progress = ConfirmationProgress::new(last_entry_hash);
|
let mut progress = ConfirmationProgress::new(last_entry_hash);
|
||||||
|
|
||||||
let bank = bank_forks.insert(bank);
|
let bank = bank_forks.write().unwrap().insert(bank);
|
||||||
if process_single_slot(
|
if process_single_slot(
|
||||||
blockstore,
|
blockstore,
|
||||||
&bank,
|
&bank,
|
||||||
|
@ -1217,7 +1228,7 @@ fn load_frozen_forks(
|
||||||
)
|
)
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
assert!(bank_forks.remove(bank.slot()).is_some());
|
assert!(bank_forks.write().unwrap().remove(bank.slot()).is_some());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
txs += progress.num_txs;
|
txs += progress.num_txs;
|
||||||
|
@ -1230,7 +1241,7 @@ fn load_frozen_forks(
|
||||||
// If we've reached the last known root in blockstore, start looking
|
// If we've reached the last known root in blockstore, start looking
|
||||||
// for newer cluster confirmed roots
|
// for newer cluster confirmed roots
|
||||||
let new_root_bank = {
|
let new_root_bank = {
|
||||||
if bank_forks.root() >= max_root {
|
if bank_forks.read().unwrap().root() >= max_root {
|
||||||
supermajority_root_from_vote_accounts(
|
supermajority_root_from_vote_accounts(
|
||||||
bank.slot(),
|
bank.slot(),
|
||||||
bank.total_epoch_stake(),
|
bank.total_epoch_stake(),
|
||||||
|
@ -1281,7 +1292,7 @@ fn load_frozen_forks(
|
||||||
root = new_root_bank.slot();
|
root = new_root_bank.slot();
|
||||||
|
|
||||||
leader_schedule_cache.set_root(new_root_bank);
|
leader_schedule_cache.set_root(new_root_bank);
|
||||||
let _ = bank_forks.set_root(
|
let _ = bank_forks.write().unwrap().set_root(
|
||||||
root,
|
root,
|
||||||
&solana_runtime::accounts_background_service::AbsRequestSender::default(),
|
&solana_runtime::accounts_background_service::AbsRequestSender::default(),
|
||||||
None,
|
None,
|
||||||
|
@ -1621,7 +1632,6 @@ pub mod tests {
|
||||||
vote_transaction,
|
vote_transaction,
|
||||||
},
|
},
|
||||||
std::{collections::BTreeSet, sync::RwLock},
|
std::{collections::BTreeSet, sync::RwLock},
|
||||||
tempfile::TempDir,
|
|
||||||
trees::tr,
|
trees::tr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1665,7 +1675,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]);
|
assert_eq!(frozen_bank_slots(&bank_forks.read().unwrap()), vec![0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1707,7 +1717,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]);
|
assert_eq!(frozen_bank_slots(&bank_forks.read().unwrap()), vec![0]);
|
||||||
|
|
||||||
// Write slot 2 fully
|
// Write slot 2 fully
|
||||||
let _last_slot2_entry_hash =
|
let _last_slot2_entry_hash =
|
||||||
|
@ -1723,9 +1733,9 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
// One valid fork, one bad fork. process_blockstore() should only return the valid fork
|
// One valid fork, one bad fork. process_blockstore() should only return the valid fork
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 2]);
|
assert_eq!(frozen_bank_slots(&bank_forks.read().unwrap()), vec![0, 2]);
|
||||||
assert_eq!(bank_forks.working_bank().slot(), 2);
|
assert_eq!(bank_forks.read().unwrap().working_bank().slot(), 2);
|
||||||
assert_eq!(bank_forks.root(), 0);
|
assert_eq!(bank_forks.read().unwrap().root(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1775,7 +1785,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]);
|
assert_eq!(frozen_bank_slots(&bank_forks.read().unwrap()), vec![0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1840,7 +1850,7 @@ pub mod tests {
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]); // slot 1 isn't "full", we stop at slot zero
|
assert_eq!(frozen_bank_slots(&bank_forks.read().unwrap()), vec![0]); // slot 1 isn't "full", we stop at slot zero
|
||||||
|
|
||||||
/* Add a complete slot such that the store looks like:
|
/* Add a complete slot such that the store looks like:
|
||||||
|
|
||||||
|
@ -1860,7 +1870,7 @@ pub mod tests {
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
|
||||||
// slot 1 isn't "full", we stop at slot zero
|
// slot 1 isn't "full", we stop at slot zero
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 3]);
|
assert_eq!(frozen_bank_slots(&bank_forks.read().unwrap()), vec![0, 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1924,6 +1934,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
// One fork, other one is ignored b/c not a descendant of the root
|
// One fork, other one is ignored b/c not a descendant of the root
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![4]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![4]);
|
||||||
|
@ -2002,6 +2013,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![1, 2, 3, 4]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![1, 2, 3, 4]);
|
||||||
assert_eq!(bank_forks.working_bank().slot(), 4);
|
assert_eq!(bank_forks.working_bank().slot(), 4);
|
||||||
|
@ -2058,6 +2070,7 @@ pub mod tests {
|
||||||
|
|
||||||
let (bank_forks, ..) =
|
let (bank_forks, ..) =
|
||||||
test_process_blockstore(&genesis_config, &blockstore, ProcessOptions::default());
|
test_process_blockstore(&genesis_config, &blockstore, ProcessOptions::default());
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 1, 3]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 1, 3]);
|
||||||
assert_eq!(bank_forks.working_bank().slot(), 3);
|
assert_eq!(bank_forks.working_bank().slot(), 3);
|
||||||
|
@ -2102,6 +2115,7 @@ pub mod tests {
|
||||||
|
|
||||||
let (bank_forks, ..) =
|
let (bank_forks, ..) =
|
||||||
test_process_blockstore(&genesis_config, &blockstore, ProcessOptions::default());
|
test_process_blockstore(&genesis_config, &blockstore, ProcessOptions::default());
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
// Should see the parent of the dead child
|
// Should see the parent of the dead child
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 1, 2, 3]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 1, 2, 3]);
|
||||||
|
@ -2149,6 +2163,7 @@ pub mod tests {
|
||||||
blockstore.set_dead_slot(2).unwrap();
|
blockstore.set_dead_slot(2).unwrap();
|
||||||
let (bank_forks, ..) =
|
let (bank_forks, ..) =
|
||||||
test_process_blockstore(&genesis_config, &blockstore, ProcessOptions::default());
|
test_process_blockstore(&genesis_config, &blockstore, ProcessOptions::default());
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
// Should see only the parent of the dead children
|
// Should see only the parent of the dead children
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]);
|
||||||
|
@ -2199,6 +2214,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
// There is one fork, head is last_slot + 1
|
// There is one fork, head is last_slot + 1
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![last_slot + 1]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![last_slot + 1]);
|
||||||
|
@ -2342,6 +2358,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 1]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![0, 1]);
|
||||||
assert_eq!(bank_forks.root(), 0);
|
assert_eq!(bank_forks.root(), 0);
|
||||||
|
@ -2371,6 +2388,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![0]);
|
||||||
let bank = bank_forks[0].clone();
|
let bank = bank_forks[0].clone();
|
||||||
|
@ -3124,6 +3142,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
// Should be able to fetch slot 0 because we specified halting at slot 0, even
|
// Should be able to fetch slot 0 because we specified halting at slot 0, even
|
||||||
// if there is a greater root at slot 1.
|
// if there is a greater root at slot 1.
|
||||||
|
@ -3198,9 +3217,10 @@ pub mod tests {
|
||||||
|
|
||||||
// Test process_blockstore_from_root() from slot 1 onwards
|
// Test process_blockstore_from_root() from slot 1 onwards
|
||||||
let (_pruned_banks_sender, pruned_banks_receiver) = crossbeam_channel::unbounded();
|
let (_pruned_banks_sender, pruned_banks_receiver) = crossbeam_channel::unbounded();
|
||||||
|
let bank_forks = RwLock::new(bank_forks);
|
||||||
process_blockstore_from_root(
|
process_blockstore_from_root(
|
||||||
&blockstore,
|
&blockstore,
|
||||||
&mut bank_forks,
|
&bank_forks,
|
||||||
&leader_schedule_cache,
|
&leader_schedule_cache,
|
||||||
&opts,
|
&opts,
|
||||||
None,
|
None,
|
||||||
|
@ -3211,6 +3231,8 @@ pub mod tests {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(frozen_bank_slots(&bank_forks), vec![5, 6]);
|
assert_eq!(frozen_bank_slots(&bank_forks), vec![5, 6]);
|
||||||
assert_eq!(bank_forks.working_bank().slot(), 6);
|
assert_eq!(bank_forks.working_bank().slot(), 6);
|
||||||
assert_eq!(bank_forks.root(), 5);
|
assert_eq!(bank_forks.root(), 5);
|
||||||
|
@ -3298,7 +3320,7 @@ pub mod tests {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let bank_snapshots_tempdir = TempDir::new().unwrap();
|
let bank_snapshots_tempdir = tempfile::TempDir::new().unwrap();
|
||||||
let snapshot_config = SnapshotConfig {
|
let snapshot_config = SnapshotConfig {
|
||||||
full_snapshot_archive_interval_slots: FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
full_snapshot_archive_interval_slots: FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
|
||||||
bank_snapshots_dir: bank_snapshots_tempdir.path().to_path_buf(),
|
bank_snapshots_dir: bank_snapshots_tempdir.path().to_path_buf(),
|
||||||
|
@ -3311,7 +3333,7 @@ pub mod tests {
|
||||||
let (_pruned_banks_sender, pruned_banks_receiver) = crossbeam_channel::unbounded();
|
let (_pruned_banks_sender, pruned_banks_receiver) = crossbeam_channel::unbounded();
|
||||||
process_blockstore_from_root(
|
process_blockstore_from_root(
|
||||||
&blockstore,
|
&blockstore,
|
||||||
&mut bank_forks,
|
&RwLock::new(bank_forks),
|
||||||
&leader_schedule_cache,
|
&leader_schedule_cache,
|
||||||
&opts,
|
&opts,
|
||||||
None,
|
None,
|
||||||
|
@ -3760,6 +3782,7 @@ pub mod tests {
|
||||||
..ProcessOptions::default()
|
..ProcessOptions::default()
|
||||||
};
|
};
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts.clone());
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts.clone());
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
// prepare to add votes
|
// prepare to add votes
|
||||||
let last_vote_bank_hash = bank_forks.get(last_main_fork_slot - 1).unwrap().hash();
|
let last_vote_bank_hash = bank_forks.get(last_main_fork_slot - 1).unwrap().hash();
|
||||||
|
@ -3791,6 +3814,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts.clone());
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts.clone());
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(bank_forks.root(), expected_root_slot);
|
assert_eq!(bank_forks.root(), expected_root_slot);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -3845,6 +3869,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
let (bank_forks, ..) = test_process_blockstore(&genesis_config, &blockstore, opts);
|
||||||
|
let bank_forks = bank_forks.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(bank_forks.root(), really_expected_root_slot);
|
assert_eq!(bank_forks.root(), really_expected_root_slot);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue