Ledger-tool recreate snapshot of starting snapshots
Co-authored-by: Carl Lin <carl@solana.com>
This commit is contained in:
@ -820,6 +820,7 @@ fn load_frozen_forks(
|
||||
)?;
|
||||
|
||||
let dev_halt_at_slot = opts.dev_halt_at_slot.unwrap_or(std::u64::MAX);
|
||||
if root_bank.slot() != dev_halt_at_slot {
|
||||
while !pending_slots.is_empty() {
|
||||
let (meta, bank, last_entry_hash) = pending_slots.pop().unwrap();
|
||||
let slot = bank.slot();
|
||||
@ -907,7 +908,8 @@ fn load_frozen_forks(
|
||||
}
|
||||
|
||||
// Filter out all non descendants of the new root
|
||||
pending_slots.retain(|(_, pending_bank, _)| pending_bank.ancestors.contains_key(root));
|
||||
pending_slots
|
||||
.retain(|(_, pending_bank, _)| pending_bank.ancestors.contains_key(root));
|
||||
initial_forks.retain(|_, fork_tip_bank| fork_tip_bank.ancestors.contains_key(root));
|
||||
all_banks.retain(|_, bank| bank.ancestors.contains_key(root));
|
||||
}
|
||||
@ -934,6 +936,7 @@ fn load_frozen_forks(
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(initial_forks.values().cloned().collect::<Vec<_>>())
|
||||
}
|
||||
@ -2607,6 +2610,37 @@ pub mod tests {
|
||||
assert_eq!(bank.process_transaction(&fail_tx), Ok(()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_halt_at_slot_starting_snapshot_root() {
|
||||
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(123);
|
||||
|
||||
// Create roots at slots 0, 1
|
||||
let forks = tr(0) / tr(1);
|
||||
let ledger_path = get_tmp_ledger_path!();
|
||||
let blockstore = Blockstore::open(&ledger_path).unwrap();
|
||||
blockstore.add_tree(
|
||||
forks,
|
||||
false,
|
||||
true,
|
||||
genesis_config.ticks_per_slot,
|
||||
genesis_config.hash(),
|
||||
);
|
||||
blockstore.set_roots(&[0, 1]).unwrap();
|
||||
|
||||
// Specify halting at slot 0
|
||||
let opts = ProcessOptions {
|
||||
poh_verify: true,
|
||||
dev_halt_at_slot: Some(0),
|
||||
..ProcessOptions::default()
|
||||
};
|
||||
let (bank_forks, _leader_schedule) =
|
||||
process_blockstore(&genesis_config, &blockstore, Vec::new(), opts).unwrap();
|
||||
|
||||
// Should be able to fetch slot 0 because we specified halting at slot 0, even
|
||||
// if there is a greater root at slot 1.
|
||||
assert!(bank_forks.get(0).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_blockstore_from_root() {
|
||||
let GenesisConfigInfo {
|
||||
|
Reference in New Issue
Block a user