From d9366776b25262ac6b8a8f65cebaf8d279400d68 Mon Sep 17 00:00:00 2001 From: carllin Date: Sat, 30 May 2020 00:03:19 -0700 Subject: [PATCH] Add operating mode gating (#10332) Co-authored-by: Carl --- core/src/replay_stage.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index e79f523176..b8d81735ab 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -29,6 +29,7 @@ use solana_metrics::inc_new_counter_info; use solana_runtime::bank::Bank; use solana_sdk::{ clock::{Slot, NUM_CONSECUTIVE_LEADER_SLOTS}, + genesis_config::OperatingMode, hash::Hash, pubkey::Pubkey, signature::{Keypair, Signer}, @@ -55,7 +56,6 @@ use std::{ pub const MAX_ENTRY_RECV_PER_ITER: usize = 512; pub const SUPERMINORITY_THRESHOLD: f64 = 1f64 / 3f64; pub const MAX_UNCONFIRMED_SLOTS: usize = 5; -pub const UNLOCK_SWITCH_VOTE_SLOT: Slot = 5_000_000; #[derive(PartialEq, Debug)] pub(crate) enum HeaviestForkFailures { @@ -997,7 +997,7 @@ impl ReplayStage { let node_keypair = cluster_info.keypair.clone(); // Send our last few votes along with the new one - let vote_ix = if bank.slot() > UNLOCK_SWITCH_VOTE_SLOT { + let vote_ix = if bank.slot() > Self::get_unlock_switch_vote_slot(bank.operating_mode()) { switch_fork_decision .to_vote_instruction( vote, @@ -1804,6 +1804,14 @@ impl ReplayStage { } } + pub fn get_unlock_switch_vote_slot(operating_mode: OperatingMode) -> Slot { + match operating_mode { + OperatingMode::Development => std::u64::MAX / 2, + OperatingMode::Stable => std::u64::MAX / 2, + OperatingMode::Preview => std::u64::MAX / 2, + } + } + pub fn join(self) -> thread::Result<()> { self.commitment_service.join()?; self.t_replay.join().map(|_| ())