-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
+36
−10
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3122,7 +3122,7 @@ fn test_optimistic_confirmation_violation_without_tower() { | |
// `A` should not be able to generate a switching proof. | ||
// | ||
fn do_test_optimistic_confirmation_violation_with_or_without_tower(with_tower: bool) { | ||
solana_logger::setup_with("debug"); | ||
solana_logger::setup_with("info"); | ||
|
||
// First set up the cluster with 4 nodes | ||
let slots_per_epoch = 2048; | ||
|
@@ -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 | ||
// it's going to be deleting its ledger, so may create versions of slots it's already created, but | ||
// on a different fork. | ||
let validator_to_slots = vec![ | ||
// Ensure validator b is leader for slots <= `next_slot_on_a` | ||
(validator_b_pubkey, next_slot_on_a as usize + 1), | ||
(validator_c_pubkey, next_slot_on_a as usize + 1), | ||
(validator_c_pubkey, DEFAULT_SLOTS_PER_EPOCH as usize), | ||
]; | ||
// Trick C into not producing any blocks, in case it takes too long to kill it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
let c_validator_to_slots = vec![(validator_b_pubkey, DEFAULT_SLOTS_PER_EPOCH as usize)]; | ||
|
||
let c_leader_schedule = create_custom_leader_schedule(c_validator_to_slots.into_iter()); | ||
let leader_schedule = create_custom_leader_schedule(validator_to_slots.into_iter()); | ||
for slot in 0..=next_slot_on_a { | ||
assert_eq!(leader_schedule[slot], validator_b_pubkey); | ||
} | ||
|
||
default_config.fixed_leader_schedule = Some(FixedSchedule { | ||
leader_schedule: Arc::new(leader_schedule), | ||
leader_schedule: Arc::new(leader_schedule.clone()), | ||
}); | ||
let mut validator_configs = | ||
make_identical_validator_configs(&default_config, node_stakes.len()); | ||
|
||
// Disable voting on validators C, and D | ||
validator_configs[2].voting_disabled = true; | ||
validator_configs[3].voting_disabled = true; | ||
// C should not produce any blocks at this time | ||
validator_configs[2].fixed_leader_schedule = Some(FixedSchedule { | ||
leader_schedule: Arc::new(c_leader_schedule), | ||
}); | ||
|
||
let mut config = ClusterConfig { | ||
cluster_lamports: DEFAULT_CLUSTER_LAMPORTS + node_stakes.iter().sum::<u64>(), | ||
|
@@ -3336,17 +3343,36 @@ fn do_test_optimistic_confirmation_violation_with_or_without_tower(with_tower: b | |
// Run validator C only to make it produce and vote on its own fork. | ||
info!("Restart validator C again!!!"); | ||
validator_c_info.config.voting_disabled = false; | ||
// C should now produce blocks | ||
validator_c_info.config.fixed_leader_schedule = Some(FixedSchedule { | ||
leader_schedule: Arc::new(leader_schedule), | ||
}); | ||
cluster.restart_node( | ||
&validator_c_pubkey, | ||
validator_c_info, | ||
SocketAddrSpace::Unspecified, | ||
); | ||
|
||
let mut votes_on_c_fork = std::collections::BTreeSet::new(); // S4 and S5 | ||
for _ in 0..100 { | ||
let mut last_vote = 0; | ||
let now = Instant::now(); | ||
loop { | ||
let elapsed = now.elapsed(); | ||
assert!( | ||
elapsed <= Duration::from_secs(30), | ||
"C failed to create a fork past {} in {} second,s | ||
last_vote {}, | ||
votes_on_c_fork: {:?}", | ||
base_slot, | ||
elapsed.as_secs(), | ||
last_vote, | ||
votes_on_c_fork, | ||
); | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
{ | ||
last_vote = latest_vote; | ||
if last_vote != base_slot { | ||
votes_on_c_fork.insert(last_vote); | ||
// Collect 4 votes | ||
|
@@ -3357,7 +3383,7 @@ fn do_test_optimistic_confirmation_violation_with_or_without_tower(with_tower: b | |
} | ||
} | ||
assert!(!votes_on_c_fork.is_empty()); | ||
info!("collected validator C's votes: {:?}", votes_on_c_fork); | ||
info!("Collected validator C's votes: {:?}", votes_on_c_fork); | ||
|
||
// Step 4: | ||
// verify whether there was violation or not | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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