Add flag to disable confirmation when performing voluntary exits (#2955)
## Issue Addressed Currently performing a voluntary exit prompts for manual confirmation. This prevents automation of exits. ## Proposed Changes Add the flag `--no-confirmation` to the account manager when performing voluntary exits to bypass this manual confirmation.
This commit is contained in:
parent
85d73d5443
commit
013a3cc3e0
@ -21,6 +21,7 @@ pub const KEYSTORE_FLAG: &str = "keystore";
|
|||||||
pub const PASSWORD_FILE_FLAG: &str = "password-file";
|
pub const PASSWORD_FILE_FLAG: &str = "password-file";
|
||||||
pub const BEACON_SERVER_FLAG: &str = "beacon-node";
|
pub const BEACON_SERVER_FLAG: &str = "beacon-node";
|
||||||
pub const NO_WAIT: &str = "no-wait";
|
pub const NO_WAIT: &str = "no-wait";
|
||||||
|
pub const NO_CONFIRMATION: &str = "no-confirmation";
|
||||||
pub const PASSWORD_PROMPT: &str = "Enter the keystore password";
|
pub const PASSWORD_PROMPT: &str = "Enter the keystore password";
|
||||||
|
|
||||||
pub const DEFAULT_BEACON_NODE: &str = "http://localhost:5052/";
|
pub const DEFAULT_BEACON_NODE: &str = "http://localhost:5052/";
|
||||||
@ -59,6 +60,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.long(NO_WAIT)
|
.long(NO_WAIT)
|
||||||
.help("Exits after publishing the voluntary exit without waiting for confirmation that the exit was included in the beacon chain")
|
.help("Exits after publishing the voluntary exit without waiting for confirmation that the exit was included in the beacon chain")
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name(NO_CONFIRMATION)
|
||||||
|
.long(NO_CONFIRMATION)
|
||||||
|
.help("Exits without prompting for confirmation that you understand the implications of a voluntary exit. This should be used with caution")
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(STDIN_INPUTS_FLAG)
|
Arg::with_name(STDIN_INPUTS_FLAG)
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
@ -75,6 +81,7 @@ pub fn cli_run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<
|
|||||||
|
|
||||||
let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG);
|
let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG);
|
||||||
let no_wait = matches.is_present(NO_WAIT);
|
let no_wait = matches.is_present(NO_WAIT);
|
||||||
|
let no_confirmation = matches.is_present(NO_CONFIRMATION);
|
||||||
|
|
||||||
let spec = env.eth2_config().spec.clone();
|
let spec = env.eth2_config().spec.clone();
|
||||||
let server_url: String = clap_utils::parse_required(matches, BEACON_SERVER_FLAG)?;
|
let server_url: String = clap_utils::parse_required(matches, BEACON_SERVER_FLAG)?;
|
||||||
@ -97,12 +104,14 @@ pub fn cli_run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<
|
|||||||
stdin_inputs,
|
stdin_inputs,
|
||||||
ð2_network_config,
|
ð2_network_config,
|
||||||
no_wait,
|
no_wait,
|
||||||
|
no_confirmation,
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the keypair and validator_index for every validator and calls `publish_voluntary_exit` on it.
|
/// Gets the keypair and validator_index for every validator and calls `publish_voluntary_exit` on it.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
async fn publish_voluntary_exit<E: EthSpec>(
|
async fn publish_voluntary_exit<E: EthSpec>(
|
||||||
keystore_path: &Path,
|
keystore_path: &Path,
|
||||||
password_file_path: Option<&PathBuf>,
|
password_file_path: Option<&PathBuf>,
|
||||||
@ -111,6 +120,7 @@ async fn publish_voluntary_exit<E: EthSpec>(
|
|||||||
stdin_inputs: bool,
|
stdin_inputs: bool,
|
||||||
eth2_network_config: &Eth2NetworkConfig,
|
eth2_network_config: &Eth2NetworkConfig,
|
||||||
no_wait: bool,
|
no_wait: bool,
|
||||||
|
no_confirmation: bool,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let genesis_data = get_geneisis_data(client).await?;
|
let genesis_data = get_geneisis_data(client).await?;
|
||||||
let testnet_genesis_root = eth2_network_config
|
let testnet_genesis_root = eth2_network_config
|
||||||
@ -149,15 +159,22 @@ async fn publish_voluntary_exit<E: EthSpec>(
|
|||||||
"Publishing a voluntary exit for validator: {} \n",
|
"Publishing a voluntary exit for validator: {} \n",
|
||||||
keypair.pk
|
keypair.pk
|
||||||
);
|
);
|
||||||
eprintln!("WARNING: THIS IS AN IRREVERSIBLE OPERATION\n");
|
if !no_confirmation {
|
||||||
eprintln!("{}\n", PROMPT);
|
eprintln!("WARNING: THIS IS AN IRREVERSIBLE OPERATION\n");
|
||||||
eprintln!(
|
eprintln!("{}\n", PROMPT);
|
||||||
"PLEASE VISIT {} TO MAKE SURE YOU UNDERSTAND THE IMPLICATIONS OF A VOLUNTARY EXIT.",
|
eprintln!(
|
||||||
WEBSITE_URL
|
"PLEASE VISIT {} TO MAKE SURE YOU UNDERSTAND THE IMPLICATIONS OF A VOLUNTARY EXIT.",
|
||||||
);
|
WEBSITE_URL
|
||||||
eprintln!("Enter the exit phrase from the above URL to confirm the voluntary exit: ");
|
);
|
||||||
|
eprintln!("Enter the exit phrase from the above URL to confirm the voluntary exit: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
let confirmation = if !no_confirmation {
|
||||||
|
account_utils::read_input_from_user(stdin_inputs)?
|
||||||
|
} else {
|
||||||
|
CONFIRMATION_PHRASE.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
let confirmation = account_utils::read_input_from_user(stdin_inputs)?;
|
|
||||||
if confirmation == CONFIRMATION_PHRASE {
|
if confirmation == CONFIRMATION_PHRASE {
|
||||||
// Sign and publish the voluntary exit to network
|
// Sign and publish the voluntary exit to network
|
||||||
let signed_voluntary_exit = voluntary_exit.sign(
|
let signed_voluntary_exit = voluntary_exit.sign(
|
||||||
|
Loading…
Reference in New Issue
Block a user