--wait-for-supermajority now requires a SLOT

This commit is contained in:
Michael Vines 2020-03-02 11:47:58 -07:00
parent d677e83ed4
commit 13551885c2
5 changed files with 23 additions and 15 deletions

View File

@ -1,6 +1,7 @@
use crate::keypair::{parse_keypair_path, KeypairUrl, ASK_KEYWORD}; use crate::keypair::{parse_keypair_path, KeypairUrl, ASK_KEYWORD};
use chrono::DateTime; use chrono::DateTime;
use solana_sdk::{ use solana_sdk::{
clock::Slot,
hash::Hash, hash::Hash,
pubkey::Pubkey, pubkey::Pubkey,
signature::{read_keypair_file, Signature}, signature::{read_keypair_file, Signature},
@ -93,6 +94,12 @@ pub fn is_url(string: String) -> Result<(), String> {
} }
} }
pub fn is_slot(slot: String) -> Result<(), String> {
slot.parse::<Slot>()
.map(|_| ())
.map_err(|e| format!("{:?}", e))
}
pub fn is_port(port: String) -> Result<(), String> { pub fn is_port(port: String) -> Result<(), String> {
port.parse::<u16>() port.parse::<u16>()
.map(|_| ()) .map(|_| ())

View File

@ -72,7 +72,7 @@ pub struct ValidatorConfig {
pub broadcast_stage_type: BroadcastStageType, pub broadcast_stage_type: BroadcastStageType,
pub enable_partition: Option<Arc<AtomicBool>>, pub enable_partition: Option<Arc<AtomicBool>>,
pub fixed_leader_schedule: Option<FixedSchedule>, pub fixed_leader_schedule: Option<FixedSchedule>,
pub wait_for_supermajority: bool, pub wait_for_supermajority: Option<Slot>,
pub new_hard_forks: Option<Vec<Slot>>, pub new_hard_forks: Option<Vec<Slot>>,
pub trusted_validators: Option<HashSet<Pubkey>>, // None = trust all pub trusted_validators: Option<HashSet<Pubkey>>, // None = trust all
} }
@ -95,7 +95,7 @@ impl Default for ValidatorConfig {
broadcast_stage_type: BroadcastStageType::Standard, broadcast_stage_type: BroadcastStageType::Standard,
enable_partition: None, enable_partition: None,
fixed_leader_schedule: None, fixed_leader_schedule: None,
wait_for_supermajority: false, wait_for_supermajority: None,
new_hard_forks: None, new_hard_forks: None,
trusted_validators: None, trusted_validators: None,
} }
@ -631,7 +631,7 @@ fn wait_for_supermajority(
bank: &Arc<Bank>, bank: &Arc<Bank>,
cluster_info: &Arc<RwLock<ClusterInfo>>, cluster_info: &Arc<RwLock<ClusterInfo>>,
) { ) {
if !config.wait_for_supermajority { if config.wait_for_supermajority != Some(bank.slot()) {
return; return;
} }

View File

@ -4,6 +4,7 @@ use clap::{
}; };
use histogram; use histogram;
use serde_json::json; use serde_json::json;
use solana_clap_utils::input_validators::is_slot;
use solana_ledger::{ use solana_ledger::{
bank_forks::{BankForks, SnapshotConfig}, bank_forks::{BankForks, SnapshotConfig},
bank_forks_utils, bank_forks_utils,
@ -576,11 +577,13 @@ fn main() {
let halt_at_slot_arg = Arg::with_name("halt_at_slot") let halt_at_slot_arg = Arg::with_name("halt_at_slot")
.long("halt-at-slot") .long("halt-at-slot")
.value_name("SLOT") .value_name("SLOT")
.validator(is_slot)
.takes_value(true) .takes_value(true)
.help("Halt processing at the given slot"); .help("Halt processing at the given slot");
let hard_forks_arg = Arg::with_name("hard_forks") let hard_forks_arg = Arg::with_name("hard_forks")
.long("hard-fork") .long("hard-fork")
.value_name("SLOT") .value_name("SLOT")
.validator(is_slot)
.multiple(true) .multiple(true)
.takes_value(true) .takes_value(true)
.help("Add a hard fork at this slot"); .help("Add a hard fork at this slot");
@ -609,6 +612,7 @@ fn main() {
Arg::with_name("slots") Arg::with_name("slots")
.index(1) .index(1)
.value_name("SLOTS") .value_name("SLOTS")
.validator(is_slot)
.takes_value(true) .takes_value(true)
.multiple(true) .multiple(true)
.required(true) .required(true)
@ -685,6 +689,7 @@ fn main() {
Arg::with_name("snapshot_slot") Arg::with_name("snapshot_slot")
.index(1) .index(1)
.value_name("SLOT") .value_name("SLOT")
.validator(is_slot)
.takes_value(true) .takes_value(true)
.help("Slot at which to create the snapshot"), .help("Slot at which to create the snapshot"),
) )

View File

@ -158,7 +158,7 @@ fn test_validator_exit_2() {
let num_nodes = 2; let num_nodes = 2;
let mut validator_config = ValidatorConfig::default(); let mut validator_config = ValidatorConfig::default();
validator_config.rpc_config.enable_validator_exit = true; validator_config.rpc_config.enable_validator_exit = true;
validator_config.wait_for_supermajority = true; validator_config.wait_for_supermajority = Some(0);
let config = ClusterConfig { let config = ClusterConfig {
cluster_lamports: 10_000, cluster_lamports: 10_000,

View File

@ -8,7 +8,7 @@ use log::*;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_clap_utils::{ use solana_clap_utils::{
input_parsers::pubkey_of, input_parsers::pubkey_of,
input_validators::{is_keypair, is_pubkey, is_pubkey_or_keypair}, input_validators::{is_keypair, is_pubkey, is_pubkey_or_keypair, is_slot},
keypair::{ keypair::{
self, keypair_input, KeypairWithSource, ASK_SEED_PHRASE_ARG, self, keypair_input, KeypairWithSource, ASK_SEED_PHRASE_ARG,
SKIP_SEED_PHRASE_VALIDATION_ARG, SKIP_SEED_PHRASE_VALIDATION_ARG,
@ -664,6 +664,7 @@ pub fn main() {
Arg::with_name("dev_halt_at_slot") Arg::with_name("dev_halt_at_slot")
.long("dev-halt-at-slot") .long("dev-halt-at-slot")
.value_name("SLOT") .value_name("SLOT")
.validator(is_slot)
.takes_value(true) .takes_value(true)
.help("Halt the validator when it reaches the given slot"), .help("Halt the validator when it reaches the given slot"),
) )
@ -796,22 +797,17 @@ pub fn main() {
.help("Redirect logging to the specified file, '-' for standard error"), .help("Redirect logging to the specified file, '-' for standard error"),
) )
.arg( .arg(
Arg::with_name("no_wait_for_supermajority")
.long("no-wait-for-supermajority")
.takes_value(false)
.help("After processing the ledger, do not wait until a supermajority of stake is visible on gossip before starting PoH"),
)
.arg(
// Legacy flag that is now enabled by default. Remove this flag a couple months after the 0.23.0
// release
Arg::with_name("wait_for_supermajority") Arg::with_name("wait_for_supermajority")
.long("wait-for-supermajority") .long("wait-for-supermajority")
.hidden(true) .value_name("SLOT")
.validator(is_slot)
.help("After processing the ledger and the next slot is SLOT, wait until a supermajority of stake is visible on gossip before starting PoH"),
) )
.arg( .arg(
Arg::with_name("hard_forks") Arg::with_name("hard_forks")
.long("hard-fork") .long("hard-fork")
.value_name("SLOT") .value_name("SLOT")
.validator(is_slot)
.multiple(true) .multiple(true)
.takes_value(true) .takes_value(true)
.help("Add a hard fork at this slot"), .help("Add a hard fork at this slot"),
@ -915,7 +911,7 @@ pub fn main() {
.ok() .ok()
.map(|rpc_port| (rpc_port, rpc_port + 1)), .map(|rpc_port| (rpc_port, rpc_port + 1)),
voting_disabled: matches.is_present("no_voting"), voting_disabled: matches.is_present("no_voting"),
wait_for_supermajority: !matches.is_present("no_wait_for_supermajority"), wait_for_supermajority: value_t!(matches, "wait_for_supermajority", Slot).ok(),
trusted_validators, trusted_validators,
..ValidatorConfig::default() ..ValidatorConfig::default()
}; };