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

local-cluster: fix flaky optimistic_confirmation tests #35356

Merged
merged 2 commits into from
Feb 29, 2024

Conversation

AshwinSekar
Copy link
Contributor

@AshwinSekar AshwinSekar commented Feb 28, 2024

Problem

  • C can produce blocks before it is initially killed
  • This could cause duplicate blocks on C's restart with purge
  • This could also cause a block past the fork slot to get OC and repaired by A on restart
  • If A is slower to start than B, B could end up producing blocks in the second cycle of the leader schedule which might chain to C's leader slots / not be purged properly

Summary of Changes

Use a custom leader schedule such that C never produces blocks after restart and B only produces blocks up until the initial fork

Fixes #29221
Fixes #34102
Fixes #33669

@AshwinSekar AshwinSekar force-pushed the flaky-tests branch 2 times, most recently from a07a57a to e667cfb Compare February 28, 2024 20:18
@carllin
Copy link
Contributor

carllin commented Feb 29, 2024

This could also cause a block past the fork slot to get OC and repaired by A on restart

This makes sense, we thought all these blocks were truncated from the ledger by the blockstore purge from all the validators after they're shut down:

purge_slots_with_count(&blockstore, base_slot + 1, truncated_slots);

Is the culprit because validator D is still running and propagating the old version of the blocks from C? Isn't that still possible if C produces blocks past the fork slot on the test starting

Edit: Oh I see, we ensure C doesn't produce any blocks by giving it a different leader schedule on startup than everyone else.

sleep(Duration::from_millis(100));

if let Some((last_vote, _)) = last_vote_in_tower(&val_c_ledger_path, &validator_c_pubkey) {
if let Some((latest_vote, _)) = last_vote_in_tower(&val_c_ledger_path, &validator_c_pubkey)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: latest_vote -> newest_vote

@@ -3172,29 +3172,36 @@ fn do_test_optimistic_confirmation_violation_with_or_without_tower(with_tower: b
// below only for slots <= `next_slot_on_a`, validator A will not know how it's last vote chains
// to the other forks, and may violate switching proofs on restart.
let mut default_config = ValidatorConfig::default_for_test();
// Split leader schedule 50-50 between validators B and C, don't give validator A any slots because
// Ensure B can make leader blocks up till the fork slot, and give remaining to C, don't give validator A any slots because
Copy link
Contributor

@carllin carllin Feb 29, 2024

Choose a reason for hiding this comment

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

nit: and give the remaining slots to C

];
// Trick C into not producing any blocks, in case it takes too long to kill it
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: in case C takes a long time to kill

carllin
carllin previously approved these changes Feb 29, 2024
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.

Good catch! Just some nits

Copy link

codecov bot commented Feb 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.7%. Comparing base (6ee3bb9) to head (e8b716f).
Report is 21 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #35356    +/-   ##
========================================
  Coverage    81.7%    81.7%            
========================================
  Files         834      834            
  Lines      224299   224767   +468     
========================================
+ Hits       183361   183815   +454     
- Misses      40938    40952    +14     

@AshwinSekar AshwinSekar merged commit e8c87e8 into solana-labs:master Feb 29, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants