Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fork race condition in optimistic violation tower tests #19192

Merged
merged 3 commits into from
Aug 27, 2021

Conversation

AshwinSekar
Copy link
Contributor

@AshwinSekar AshwinSekar commented Aug 11, 2021

Problem

The optimistic violation tower tests warmup by letting two validators run for a pre determined # of slots. Because of the stake weighting, this warmup fails if there is ever a fork.

Summary of Changes

Instead run only a single validator and manually create the ledger for the other validator. Then run the other validator in order for it to vote and create the correct tower. This achieves the same warmup result as the previous version while guaranteeing there will be no fork.

Fixes #19017

@stale
Copy link

stale bot commented Aug 21, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Aug 21, 2021
@AshwinSekar AshwinSekar removed the stale [bot only] Added to stale content; results in auto-close after a week. label Aug 22, 2021
@AshwinSekar
Copy link
Contributor Author

Not stale, this commit fixes the original issue however it exposed another flakiness in the test which i am currently trying to address.

Comment on lines 2802 to 2824
let b_blockstore = open_blockstore(&val_b_ledger_path);
let a_blockstore = open_blockstore(&val_a_ledger_path);

// Find latest vote in B, and wait for it to reach blockstore
let (b_last_vote, _) = last_vote_in_tower(&val_b_ledger_path, &validator_b_pubkey).unwrap();
while !b_blockstore.is_full(b_last_vote) {
sleep(Duration::from_millis(100));
}

// Now we copy these blocks to A
for slot in
std::iter::once(b_last_vote).chain(AncestorIterator::new(b_last_vote, &b_blockstore))
{
let slot_meta = b_blockstore.meta(slot).unwrap().unwrap();
assert!(slot_meta.is_full());

let shreds = b_blockstore.get_data_shreds_for_slot(slot, 0).unwrap();
a_blockstore.insert_shreds(shreds, None, false).unwrap();

let a_meta = a_blockstore.meta(slot).unwrap().unwrap();
assert!(a_meta.is_full());
assert_eq!(a_meta.last_index, slot_meta.last_index);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to extract this copying logic into a resuable function shared with the other test that does this same thing 😃

@codecov
Copy link

codecov bot commented Aug 25, 2021

Codecov Report

Merging #19192 (20d7537) into master (f4d2140) will decrease coverage by 0.0%.
The diff coverage is n/a.

❗ Current head 20d7537 differs from pull request most recent head 5d396d8. Consider uploading reports for the commit 5d396d8 to get more accurate results

@@            Coverage Diff            @@
##           master   #19192     +/-   ##
=========================================
- Coverage    82.7%    82.7%   -0.1%     
=========================================
  Files         459      459             
  Lines      130822   130822             
=========================================
- Hits       108306   108286     -20     
- Misses      22516    22536     +20     

@@ -2649,6 +2641,21 @@ fn last_vote_in_tower(tower_path: &Path, node_pubkey: &Pubkey) -> Option<(Slot,
restore_tower(tower_path, node_pubkey).map(|tower| tower.last_voted_slot_hash().unwrap())
}

// Fetches the last vote in the tower, blocking until it has also appeared in blockstore.
// Fails if tower is empty
fn last_vote_in_tower_wait(tower_path: &Path, node_pubkey: &Pubkey) -> Slot {
Copy link
Contributor

@carllin carllin Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to wait_for_last_vote_in_tower_to_land_in_ledger

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename tower_path -> ledger_path

carllin
carllin previously approved these changes Aug 26, 2021
Copy link
Contributor

@carllin carllin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with some minor nits

@mergify mergify bot dismissed carllin’s stale review August 27, 2021 04:36

Pull request has been modified.

@AshwinSekar AshwinSekar merged commit 73c1ea7 into solana-labs:master Aug 27, 2021
carllin pushed a commit that referenced this pull request Dec 7, 2021
* Fix fork race condition in optimistic violation tower tests

* clippy

* pr comments
mergify bot added a commit that referenced this pull request Dec 7, 2021
* Fix fork race condition in optimistic violation tower tests (#19192)

* Fix fork race condition in optimistic violation tower tests

* clippy

* pr comments

* Fixup flaky tests (#21617)

* Fixup flaky tests

* Fixup listeners

Co-authored-by: Ashwin Sekar <[email protected]>
Co-authored-by: carllin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimistic confirmation tests flakiness
2 participants