parent
ef8eff69e4
commit
52da207f83
|
@ -370,11 +370,10 @@ fn get_bank_forks(
|
||||||
genesis_block: &GenesisBlock,
|
genesis_block: &GenesisBlock,
|
||||||
blocktree: &Blocktree,
|
blocktree: &Blocktree,
|
||||||
account_paths: Option<String>,
|
account_paths: Option<String>,
|
||||||
snapshot_config: Option<SnapshotConfig>,
|
snapshot_config: Option<&SnapshotConfig>,
|
||||||
verify_ledger: bool,
|
verify_ledger: bool,
|
||||||
dev_halt_at_slot: Option<Slot>,
|
dev_halt_at_slot: Option<Slot>,
|
||||||
) -> (BankForks, Vec<BankForksInfo>, LeaderScheduleCache) {
|
) -> (BankForks, Vec<BankForksInfo>, LeaderScheduleCache) {
|
||||||
let (mut bank_forks, bank_forks_info, leader_schedule_cache) = {
|
|
||||||
if let Some(snapshot_config) = snapshot_config.as_ref() {
|
if let Some(snapshot_config) = snapshot_config.as_ref() {
|
||||||
info!(
|
info!(
|
||||||
"Initializing snapshot path: {:?}",
|
"Initializing snapshot path: {:?}",
|
||||||
|
@ -384,9 +383,8 @@ fn get_bank_forks(
|
||||||
fs::create_dir_all(&snapshot_config.snapshot_path)
|
fs::create_dir_all(&snapshot_config.snapshot_path)
|
||||||
.expect("Couldn't create snapshot directory");
|
.expect("Couldn't create snapshot directory");
|
||||||
|
|
||||||
let tar = snapshot_utils::get_snapshot_tar_path(
|
let tar =
|
||||||
&snapshot_config.snapshot_package_output_path,
|
snapshot_utils::get_snapshot_tar_path(&snapshot_config.snapshot_package_output_path);
|
||||||
);
|
|
||||||
if tar.exists() {
|
if tar.exists() {
|
||||||
info!("Loading snapshot package: {:?}", tar);
|
info!("Loading snapshot package: {:?}", tar);
|
||||||
// Fail hard here if snapshot fails to load, don't silently continue
|
// Fail hard here if snapshot fails to load, don't silently continue
|
||||||
|
@ -422,13 +420,6 @@ fn get_bank_forks(
|
||||||
dev_halt_at_slot,
|
dev_halt_at_slot,
|
||||||
)
|
)
|
||||||
.expect("process_blocktree failed")
|
.expect("process_blocktree failed")
|
||||||
};
|
|
||||||
|
|
||||||
if snapshot_config.is_some() {
|
|
||||||
bank_forks.set_snapshot_config(snapshot_config.unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
(bank_forks, bank_forks_info, leader_schedule_cache)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
|
@ -504,15 +495,19 @@ pub fn new_banks_from_blocktree(
|
||||||
let (blocktree, ledger_signal_receiver, completed_slots_receiver) =
|
let (blocktree, ledger_signal_receiver, completed_slots_receiver) =
|
||||||
Blocktree::open_with_signal(blocktree_path).expect("Failed to open ledger database");
|
Blocktree::open_with_signal(blocktree_path).expect("Failed to open ledger database");
|
||||||
|
|
||||||
let (bank_forks, bank_forks_info, leader_schedule_cache) = get_bank_forks(
|
let (mut bank_forks, bank_forks_info, leader_schedule_cache) = get_bank_forks(
|
||||||
&genesis_block,
|
&genesis_block,
|
||||||
&blocktree,
|
&blocktree,
|
||||||
account_paths,
|
account_paths,
|
||||||
snapshot_config,
|
snapshot_config.as_ref(),
|
||||||
verify_ledger,
|
verify_ledger,
|
||||||
dev_halt_at_slot,
|
dev_halt_at_slot,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if snapshot_config.is_some() {
|
||||||
|
bank_forks.set_snapshot_config(snapshot_config.unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
genesis_blockhash,
|
genesis_blockhash,
|
||||||
bank_forks,
|
bank_forks,
|
||||||
|
|
|
@ -300,10 +300,11 @@ fn test_listener_startup() {
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn test_snapshots_restart_validity() {
|
fn test_snapshots_restart_validity() {
|
||||||
|
solana_logger::setup();
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new().unwrap();
|
||||||
let snapshot_path = temp_dir.path().join("bank_states");
|
let snapshot_path = temp_dir.path().join("bank_states");
|
||||||
let snapshot_package_output_path = temp_dir.path().join("tar");
|
let snapshot_package_output_path = temp_dir.path().join("tar");
|
||||||
let snapshot_interval_slots = 25;
|
let snapshot_interval_slots = 10;
|
||||||
|
|
||||||
// Create the snapshot directories
|
// Create the snapshot directories
|
||||||
fs::create_dir_all(&snapshot_path).expect("Failed to create snapshots bank state directory");
|
fs::create_dir_all(&snapshot_path).expect("Failed to create snapshots bank state directory");
|
||||||
|
@ -334,7 +335,8 @@ fn test_snapshots_restart_validity() {
|
||||||
let num_runs = 3;
|
let num_runs = 3;
|
||||||
let mut expected_balances = HashMap::new();
|
let mut expected_balances = HashMap::new();
|
||||||
let mut cluster = LocalCluster::new(&config);
|
let mut cluster = LocalCluster::new(&config);
|
||||||
for _ in 0..num_runs {
|
for i in 1..num_runs {
|
||||||
|
info!("run {}", i);
|
||||||
// Push transactions to one of the nodes and confirm that transactions were
|
// Push transactions to one of the nodes and confirm that transactions were
|
||||||
// forwarded to and processed.
|
// forwarded to and processed.
|
||||||
trace!("Sending transactions");
|
trace!("Sending transactions");
|
||||||
|
@ -356,12 +358,20 @@ fn test_snapshots_restart_validity() {
|
||||||
// Wait for a snapshot for a bank >= last_slot to be made so we know that the snapshot
|
// Wait for a snapshot for a bank >= last_slot to be made so we know that the snapshot
|
||||||
// must include the transactions just pushed
|
// must include the transactions just pushed
|
||||||
let tar = snapshot_utils::get_snapshot_tar_path(&snapshot_package_output_path);
|
let tar = snapshot_utils::get_snapshot_tar_path(&snapshot_package_output_path);
|
||||||
trace!("Waiting for tar to be generated");
|
trace!(
|
||||||
|
"Waiting for snapshot tar to be generated with slot > {}",
|
||||||
|
last_slot
|
||||||
|
);
|
||||||
loop {
|
loop {
|
||||||
if tar.exists() && snapshot_utils::bank_slot_from_archive(&tar).unwrap() >= last_slot {
|
if tar.exists() {
|
||||||
|
trace!("snapshot tar exists");
|
||||||
|
let slot = snapshot_utils::bank_slot_from_archive(&tar).unwrap();
|
||||||
|
if slot >= last_slot {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(100));
|
trace!("snapshot tar slot {} < last_slot {}", slot, last_slot);
|
||||||
|
}
|
||||||
|
sleep(Duration::from_millis(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new account paths since fullnode exit is not guaranteed to cleanup RPC threads,
|
// Create new account paths since fullnode exit is not guaranteed to cleanup RPC threads,
|
||||||
|
|
Loading…
Reference in New Issue