Skip to content

Commit 72d03a1

Browse files
committed
Revert "Revert "Allow validators to reset to the slot which matches their last voted slot (backport solana-labs#28172) (solana-labs#28187)""
This reverts commit 2e25fbc.
1 parent 49f54d9 commit 72d03a1

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

core/src/heaviest_subtree_fork_choice.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -940,18 +940,6 @@ impl HeaviestSubtreeForkChoice {
940940
}
941941
}
942942
}
943-
let heaviest_slot_hash_on_same_voted_fork =
944-
heaviest_slot_hash_on_same_voted_fork.unwrap();
945-
946-
if heaviest_slot_hash_on_same_voted_fork == last_voted_slot_hash {
947-
info!(
948-
"heaviest_slot_on_same_voted_fork: {:?}, last_voted_slot_hash: {:?}",
949-
heaviest_slot_hash_on_same_voted_fork, last_voted_slot_hash
950-
);
951-
None
952-
} else {
953-
Some(heaviest_slot_hash_on_same_voted_fork)
954-
}
955943
})
956944
}
957945

@@ -3035,9 +3023,10 @@ mod test {
30353023

30363024
// After marking the last vote in the tower as invalid, `heaviest_slot_on_same_voted_fork()`
30373025
// should disregard all descendants of that invalid vote
3038-
assert!(heaviest_subtree_fork_choice
3039-
.heaviest_slot_on_same_voted_fork(&tower)
3040-
.is_none());
3026+
assert_eq!(
3027+
heaviest_subtree_fork_choice.heaviest_slot_on_same_voted_fork(&tower),
3028+
None
3029+
);
30413030

30423031
// Adding another descendant to the invalid candidate won't
30433032
// update the best slot, even if it contains votes

core/src/replay_stage.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,9 +2980,18 @@ impl ReplayStage {
29802980
);
29812981
}
29822982

2983-
// Given a heaviest bank, `heaviest_bank` and the next votable bank
2984-
// `heaviest_bank_on_same_voted_fork` as the validator's last vote, return
2985-
// a bank to vote on, a bank to reset to,
2983+
/// Given a `heaviest_bank` and a `heaviest_bank_on_same_voted_fork`, return
2984+
/// a bank to vote on, a bank to reset to, and a list of switch failure
2985+
/// reasons.
2986+
///
2987+
/// If `heaviest_bank_on_same_voted_fork` is `None` due to that fork no
2988+
/// longer being valid to vote on, it's possible that a validator will not
2989+
/// be able to reset away from the invalid fork that they last voted on. To
2990+
/// resolve this scenario, validators need to wait until they can create a
2991+
/// switch proof for another fork or until the invalid fork is be marked
2992+
/// valid again if it was confirmed by the cluster.
2993+
/// Until this is resolved, leaders will build each of their
2994+
/// blocks from the last reset bank on the invalid fork.
29862995
pub fn select_vote_and_reset_forks(
29872996
heaviest_bank: &Arc<Bank>,
29882997
// Should only be None if there was no previous vote
@@ -5925,7 +5934,7 @@ pub(crate) mod tests {
59255934
&mut vote_simulator.latest_validator_votes_for_frozen_banks,
59265935
);
59275936
assert!(vote_fork.is_none());
5928-
assert_eq!(reset_fork.unwrap(), 3);
5937+
assert_eq!(reset_fork, Some(3));
59295938

59305939
// Now mark 2, an ancestor of 4, as duplicate
59315940
blockstore.store_duplicate_slot(2, vec![], vec![]).unwrap();
@@ -7026,7 +7035,6 @@ pub(crate) mod tests {
70267035
);
70277036
let (heaviest_bank, heaviest_bank_on_same_fork) = heaviest_subtree_fork_choice
70287037
.select_forks(&frozen_banks, tower, progress, ancestors, bank_forks);
7029-
assert!(heaviest_bank_on_same_fork.is_none());
70307038
let SelectVoteAndResetForkResult {
70317039
vote_bank,
70327040
reset_bank,

0 commit comments

Comments
 (0)