Add operating mode gating (#10332)

Co-authored-by: Carl <carl@solana.com>
This commit is contained in:
carllin 2020-05-30 00:03:19 -07:00 committed by GitHub
parent 19d11800bf
commit d9366776b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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(|_| ())