Persistent tower (#10718)
* Save/restore Tower * Avoid unwrap() * Rebase cleanups * Forcibly pass test * Correct reconcilation of votes after validator resume * d b g * Add more tests * fsync and fix test * Add test * Fix fmt * Debug * Fix tests... * save * Clarify error message and code cleaning around it * Move most of code out of tower save hot codepath * Proper comment for the lack of fsync on tower * Clean up * Clean up * Simpler type alias * Manage tower-restored ancestor slots without banks * Add comment * Extract long code blocks... * Add comment * Simplify returned tuple... * Tweak too aggresive log * Fix typo... * Add test * Update comment * Improve test to require non-empty stray restored slots * Measure tower save and dump all tower contents * Log adjust and add threshold related assertions * cleanup adjust * Properly lower stray restored slots priority... * Rust fmt * Fix test.... * Clarify comments a bit and add TowerError::TooNew * Further clean-up arround TowerError * Truly create ancestors by excluding last vote slot * Add comment for stray_restored_slots * Add comment for stray_restored_slots * Use BTreeSet * Consider root_slot into post-replay adjustment * Tweak logging * Add test for stray_restored_ancestors * Reorder some code * Better names for unit tests * Add frozen_abi to SavedTower * Fold long lines * Tweak stray ancestors and too old slot history * Re-adjust error conditon of too old slot history * Test normal ancestors is checked before stray ones * Fix conflict, update tests, adjust behavior a bit * Fix test * Address review comments * Last touch! * Immediately after creating cleaning pr * Revert stray slots * Revert comment... * Report error as metrics * Revert not to panic! and ignore unfixable test... * Normalize lockouts.root_slot more strictly * Add comments for panic! and more assertions * Proper initialize root without vote account * Clarify code and comments based on review feedback * Fix rebase * Further simplify based on assured tower root * Reorder code for more readability Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@ -20,6 +20,13 @@ impl<'a> AncestorIterator<'a> {
|
||||
blockstore,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_inclusive(start_slot: Slot, blockstore: &'a Blockstore) -> Self {
|
||||
Self {
|
||||
current: blockstore.meta(start_slot).unwrap().map(|_| start_slot),
|
||||
blockstore,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<'a> Iterator for AncestorIterator<'a> {
|
||||
type Item = Slot;
|
||||
@ -111,4 +118,33 @@ mod tests {
|
||||
vec![2, 1, 0]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ancestor_iterator_inclusive() {
|
||||
let blockstore_path = get_tmp_ledger_path!();
|
||||
let blockstore = Blockstore::open(&blockstore_path).unwrap();
|
||||
|
||||
let (shreds, _) = make_slot_entries(0, 0, 42);
|
||||
blockstore.insert_shreds(shreds, None, false).unwrap();
|
||||
let (shreds, _) = make_slot_entries(1, 0, 42);
|
||||
blockstore.insert_shreds(shreds, None, false).unwrap();
|
||||
let (shreds, _) = make_slot_entries(2, 1, 42);
|
||||
blockstore.insert_shreds(shreds, None, false).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
AncestorIterator::new(2, &blockstore).collect::<Vec<Slot>>(),
|
||||
vec![1, 0]
|
||||
);
|
||||
// existing start_slot
|
||||
assert_eq!(
|
||||
AncestorIterator::new_inclusive(2, &blockstore).collect::<Vec<Slot>>(),
|
||||
vec![2, 1, 0]
|
||||
);
|
||||
|
||||
// non-existing start_slot
|
||||
assert_eq!(
|
||||
AncestorIterator::new_inclusive(3, &blockstore).collect::<Vec<Slot>>(),
|
||||
vec![] as Vec<Slot>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user