From c7710fdd249f55cde71f444fb3fc0f7e3bf742d7 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 5 Aug 2019 13:17:03 -0700 Subject: [PATCH] Add wallet get-slot command and document how to use it (#5424) * Add wallet get-slot command and document how to use it * , --- book/src/testnet-participation.md | 20 ++++++++++++++++++++ wallet/src/wallet.rs | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/book/src/testnet-participation.md b/book/src/testnet-participation.md index 6d5e8c6445..510f431c20 100644 --- a/book/src/testnet-participation.md +++ b/book/src/testnet-participation.md @@ -238,6 +238,26 @@ The vote pubkey for the validator can also be found by running: $ solana-keygen pubkey ~/validator-vote-keypair.json ``` +#### Has my validator caught up? +After your validator boots, it may take some time to catch up with the cluster. +Use the `get-slot` wallet command to view the current slot that the cluster is +processing: +```bash +$ solana-wallet get-slot +``` + +The current slot that your validator is processing can then been seen with: +```bash +$ solana-wallet --url http://127.0.0.1:8899 get-slot +``` + +Until your validator has caught up, it will not be able to vote successfully and +stake cannot be delegated to it. + +Also if you find the cluster's slot advancing faster than yours, you will likely +never catch up. This typically implies some kind of networking issue between +your validator and the rest of the cluster. + #### Validator Metrics Metrics are available for local monitoring of your validator. diff --git a/wallet/src/wallet.rs b/wallet/src/wallet.rs index 2612f2b198..baf83408d4 100644 --- a/wallet/src/wallet.rs +++ b/wallet/src/wallet.rs @@ -61,6 +61,7 @@ pub enum WalletCommand { ClaimStorageReward(Pubkey, Pubkey), ShowStorageAccount(Pubkey), Deploy(String), + GetSlot, GetTransactionCount, // Pay(lamports, to, timestamp, timestamp_pubkey, witness(es), cancelable) Pay( @@ -303,6 +304,7 @@ pub fn parse_command( .unwrap() .to_string(), )), + ("get-slot", Some(_matches)) => Ok(WalletCommand::GetSlot), ("get-transaction-count", Some(_matches)) => Ok(WalletCommand::GetTransactionCount), ("pay", Some(pay_matches)) => { let lamports = pay_matches.value_of("lamports").unwrap().parse()?; @@ -982,6 +984,11 @@ fn process_cancel(rpc_client: &RpcClient, config: &WalletConfig, pubkey: &Pubkey Ok(signature_str.to_string()) } +fn process_get_slot(rpc_client: &RpcClient) -> ProcessResult { + let slot = rpc_client.get_slot()?; + Ok(slot.to_string()) +} + fn process_get_transaction_count(rpc_client: &RpcClient) -> ProcessResult { let transaction_count = rpc_client.get_transaction_count()?; Ok(transaction_count.to_string()) @@ -1182,6 +1189,7 @@ pub fn process_command(config: &WalletConfig) -> ProcessResult { process_deploy(&rpc_client, config, program_location) } + WalletCommand::GetSlot => process_get_slot(&rpc_client), WalletCommand::GetTransactionCount => process_get_transaction_count(&rpc_client), // If client has positive balance, pay lamports to another address @@ -1678,6 +1686,10 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, ' .help("/path/to/program.o"), ), // TODO: Add "loader" argument; current default is bpf_loader ) + .subcommand( + SubCommand::with_name("get-slot") + .about("Get current slot"), + ) .subcommand( SubCommand::with_name("get-transaction-count") .about("Get current transaction count"), @@ -2163,6 +2175,9 @@ mod tests { let signature = process_command(&config); assert_eq!(signature.unwrap(), SIGNATURE.to_string()); + config.command = WalletCommand::GetSlot; + assert_eq!(process_command(&config).unwrap(), "0"); + config.command = WalletCommand::GetTransactionCount; assert_eq!(process_command(&config).unwrap(), "1234"); @@ -2270,6 +2285,9 @@ mod tests { config.command = WalletCommand::AuthorizeVoter(bob_pubkey, Keypair::new(), bob_pubkey); assert!(process_command(&config).is_err()); + config.command = WalletCommand::GetSlot; + assert!(process_command(&config).is_err()); + config.command = WalletCommand::GetTransactionCount; assert!(process_command(&config).is_err());