From 57abc370fa39e42e8fb84145a30395ddcf891692 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 15 Mar 2020 10:19:07 -0700 Subject: [PATCH] Quietly re-introduce legacy --voting-keypair/--identity-keypair args for v1.0.6 compatibility (cherry picked from commit 49706172f354c5fd559e2921b0a8f754ca63d977) --- validator/src/main.rs | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/validator/src/main.rs b/validator/src/main.rs index 779936faaa..d6fef40385 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -561,6 +561,7 @@ pub fn main() { Arg::with_name("identity") .short("i") .long("identity") + .alias("identity-keypair") // --identity-keypair is legacy for <= v1.0.6 users .value_name("PATH") .takes_value(true) .validator(is_keypair_or_ask_keyword) @@ -574,6 +575,15 @@ pub fn main() { .validator(is_keypair_or_ask_keyword) .help("Authorized voter keypair [default: value of --identity]"), ) + .arg( + Arg::with_name("deprecated_voting_keypair") + .long("voting-keypair") + .value_name("PATH") + .takes_value(true) + .hidden(true) // Don't document this argument, it's legacy for <= v1.0.6 users + .conflicts_with_all(&["authorized_voter", "vote_account"]) + .validator(is_keypair_or_ask_keyword), + ) .arg( Arg::with_name("vote_account") .long("vote-account") @@ -846,6 +856,10 @@ pub fn main() { let identity_keypair = Arc::new(keypair_of(&matches, "identity").unwrap_or_else(Keypair::new)); let authorized_voter = keypair_of(&matches, "authorized_voter") + .or_else(|| { + // Legacy v1.0.6 argument support + keypair_of(&matches, "deprecated_voting_keypair") + }) .map(Arc::new) .unwrap_or_else(|| identity_keypair.clone()); @@ -914,6 +928,19 @@ pub fn main() { ..ValidatorConfig::default() }; + let vote_account = pubkey_of(&matches, "vote_account").unwrap_or_else(|| { + if matches.is_present("deprecated_voting_keypair") { + // Legacy v1.0.6 behaviour of using `--voting-keypair` as `--vote-account` + keypair_of(&matches, "deprecated_voting_keypair") + .unwrap() + .pubkey() + } else { + warn!("--vote-account not specified, validator will not vote"); + validator_config.voting_disabled = true; + Keypair::new().pubkey() + } + }); + let dynamic_port_range = solana_net_utils::parse_port_range(matches.value_of("dynamic_port_range").unwrap()) .expect("invalid dynamic_port_range"); @@ -1026,12 +1053,6 @@ pub fn main() { info!("{} {}", crate_name!(), solana_clap_utils::version!()); info!("Starting validator with: {:#?}", std::env::args_os()); - let vote_account = pubkey_of(&matches, "vote_account").unwrap_or_else(|| { - warn!("--vote-account not specified, validator will not vote"); - validator_config.voting_disabled = true; - Keypair::new().pubkey() - }); - solana_metrics::set_host_id(identity_keypair.pubkey().to_string()); solana_metrics::set_panic_hook("validator");