Skip to content

Commit 5e0a101

Browse files
committed
fix: reduce refresh vote interval
this change results in validators refreshing their votes faster than before to improve fork resolution time in some special cases where the votes don't land.
1 parent 855c268 commit 5e0a101

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/src/replay_stage.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ use {
6161
vote_sender_types::ReplayVoteSender,
6262
},
6363
solana_sdk::{
64-
clock::{BankId, Slot, MAX_PROCESSING_AGE, NUM_CONSECUTIVE_LEADER_SLOTS},
64+
clock::{BankId, Slot, NUM_CONSECUTIVE_LEADER_SLOTS, SLOT_MS},
6565
feature_set,
6666
genesis_config::ClusterType,
6767
hash::Hash,
@@ -90,7 +90,8 @@ pub const MAX_UNCONFIRMED_SLOTS: usize = 5;
9090
pub const DUPLICATE_LIVENESS_THRESHOLD: f64 = 0.1;
9191
pub const DUPLICATE_THRESHOLD: f64 = 1.0 - SWITCH_FORK_THRESHOLD - DUPLICATE_LIVENESS_THRESHOLD;
9292
const MAX_VOTE_SIGNATURES: usize = 200;
93-
const MAX_VOTE_REFRESH_INTERVAL_MILLIS: usize = 5000;
93+
const VOTE_EXPIRATION_NUM_SLOTS: usize = 8;
94+
const MAX_VOTE_REFRESH_INTERVAL_MILLIS: usize = SLOT_MS as usize * VOTE_EXPIRATION_NUM_SLOTS;
9495
// Expect this number to be small enough to minimize thread pool overhead while large enough
9596
// to be able to replay all active forks at the same time in most cases.
9697
const MAX_CONCURRENT_FORKS_TO_REPLAY: usize = 4;
@@ -2150,9 +2151,9 @@ impl ReplayStage {
21502151
}
21512152
if my_latest_landed_vote >= last_voted_slot
21522153
|| heaviest_bank_on_same_fork
2153-
.is_hash_valid_for_age(&tower.last_vote_tx_blockhash(), MAX_PROCESSING_AGE)
2154+
.is_hash_valid_for_age(&tower.last_vote_tx_blockhash(), VOTE_EXPIRATION_NUM_SLOTS)
21542155
|| {
2155-
// In order to avoid voting on multiple forks all past MAX_PROCESSING_AGE that don't
2156+
// In order to avoid voting on multiple forks all past VOTE_EXPIRATION_NUM_SLOTS that don't
21562157
// include the last voted blockhash
21572158
last_vote_refresh_time
21582159
.last_refresh_time
@@ -6663,7 +6664,7 @@ pub(crate) mod tests {
66636664
// Create a bank where the last vote transaction will have expired
66646665
let expired_bank = {
66656666
let mut parent_bank = bank2.clone();
6666-
for _ in 0..MAX_PROCESSING_AGE {
6667+
for _ in 0..VOTE_EXPIRATION_NUM_SLOTS {
66676668
parent_bank = Arc::new(Bank::new_from_parent(
66686669
&parent_bank,
66696670
&Pubkey::default(),

0 commit comments

Comments
 (0)