Delete uptime command, report total credits in solana validators instead

(cherry picked from commit 4c0420b884)
This commit is contained in:
Michael Vines
2020-02-03 11:37:50 -07:00
parent 384f52a607
commit 521238f7d7
5 changed files with 89 additions and 271 deletions

View File

@ -241,7 +241,6 @@ SUBCOMMANDS:
stakes Show stake account information stakes Show stake account information
storage-account Show the contents of a storage account storage-account Show the contents of a storage account
transaction-count Get current transaction count transaction-count Get current transaction count
uptime Show the uptime of a validator, based on epoch voting history
validator-info Publish/get Validator info on Solana validator-info Publish/get Validator info on Solana
validators Show summary information about the current validators validators Show summary information about the current validators
vote-account Show the contents of a vote account vote-account Show the contents of a vote account
@ -254,7 +253,7 @@ SUBCOMMANDS:
#### solana-account #### solana-account
```text ```text
solana-account solana-account
Show the contents of an account Show the contents of an account
USAGE: USAGE:
@ -283,7 +282,7 @@ ARGS:
#### solana-address #### solana-address
```text ```text
solana-address solana-address
Get your public key Get your public key
USAGE: USAGE:
@ -307,7 +306,7 @@ OPTIONS:
#### solana-airdrop #### solana-airdrop
```text ```text
solana-airdrop solana-airdrop
Request lamports Request lamports
USAGE: USAGE:
@ -337,7 +336,7 @@ ARGS:
#### solana-authorize-nonce-account #### solana-authorize-nonce-account
```text ```text
solana-authorize-nonce-account solana-authorize-nonce-account
Assign account authority to a new entity Assign account authority to a new entity
USAGE: USAGE:
@ -373,7 +372,7 @@ ARGS:
#### solana-balance #### solana-balance
```text ```text
solana-balance solana-balance
Get your balance Get your balance
USAGE: USAGE:
@ -401,7 +400,7 @@ ARGS:
#### solana-block-production #### solana-block-production
```text ```text
solana-block-production solana-block-production
Show information about block production Show information about block production
USAGE: USAGE:
@ -428,7 +427,7 @@ OPTIONS:
#### solana-block-time #### solana-block-time
```text ```text
solana-block-time solana-block-time
Get estimated production time of a block Get estimated production time of a block
USAGE: USAGE:
@ -455,7 +454,7 @@ ARGS:
#### solana-cancel #### solana-cancel
```text ```text
solana-cancel solana-cancel
Cancel a transfer Cancel a transfer
USAGE: USAGE:
@ -482,7 +481,7 @@ ARGS:
#### solana-catchup #### solana-catchup
```text ```text
solana-catchup solana-catchup
Wait for a validator to catch up to the cluster Wait for a validator to catch up to the cluster
USAGE: USAGE:
@ -509,7 +508,7 @@ ARGS:
#### solana-claim-storage-reward #### solana-claim-storage-reward
```text ```text
solana-claim-storage-reward solana-claim-storage-reward
Redeem storage reward credits Redeem storage reward credits
USAGE: USAGE:
@ -537,7 +536,7 @@ ARGS:
#### solana-cluster-version #### solana-cluster-version
```text ```text
solana-cluster-version solana-cluster-version
Get the version of the cluster entrypoint Get the version of the cluster entrypoint
USAGE: USAGE:
@ -561,7 +560,7 @@ OPTIONS:
#### solana-config #### solana-config
```text ```text
solana-config solana-config
Solana command-line tool configuration settings Solana command-line tool configuration settings
USAGE: USAGE:
@ -590,7 +589,7 @@ SUBCOMMANDS:
#### solana-confirm #### solana-confirm
```text ```text
solana-confirm solana-confirm
Confirm transaction by signature Confirm transaction by signature
USAGE: USAGE:
@ -617,7 +616,7 @@ ARGS:
#### solana-create-address-with-seed #### solana-create-address-with-seed
```text ```text
solana-create-address-with-seed solana-create-address-with-seed
Generate a derived account address with a seed Generate a derived account address with a seed
USAGE: USAGE:
@ -641,13 +640,13 @@ OPTIONS:
ARGS: ARGS:
<SEED_STRING> The seed. Must not take more than 32 bytes to encode as utf-8 <SEED_STRING> The seed. Must not take more than 32 bytes to encode as utf-8
<PROGRAM_ID> The program_id that the address will ultimately be used for, <PROGRAM_ID> The program_id that the address will ultimately be used for,
or one of STAKE, VOTE, and STORAGE keywords or one of STAKE, VOTE, and STORAGE keywords
``` ```
#### solana-create-archiver-storage-account #### solana-create-archiver-storage-account
```text ```text
solana-create-archiver-storage-account solana-create-archiver-storage-account
Create an archiver storage account Create an archiver storage account
USAGE: USAGE:
@ -669,13 +668,13 @@ OPTIONS:
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
ARGS: ARGS:
<STORAGE ACCOUNT OWNER PUBKEY> <STORAGE ACCOUNT OWNER PUBKEY>
<STORAGE ACCOUNT> <STORAGE ACCOUNT>
``` ```
#### solana-create-nonce-account #### solana-create-nonce-account
```text ```text
solana-create-nonce-account solana-create-nonce-account
Create a nonce account Create a nonce account
USAGE: USAGE:
@ -705,7 +704,7 @@ ARGS:
#### solana-create-stake-account #### solana-create-stake-account
```text ```text
solana-create-stake-account solana-create-stake-account
Create a stake account Create a stake account
USAGE: USAGE:
@ -741,7 +740,7 @@ ARGS:
#### solana-create-validator-storage-account #### solana-create-validator-storage-account
```text ```text
solana-create-validator-storage-account solana-create-validator-storage-account
Create a validator storage account Create a validator storage account
USAGE: USAGE:
@ -763,13 +762,13 @@ OPTIONS:
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
ARGS: ARGS:
<STORAGE ACCOUNT OWNER PUBKEY> <STORAGE ACCOUNT OWNER PUBKEY>
<STORAGE ACCOUNT> <STORAGE ACCOUNT>
``` ```
#### solana-create-vote-account #### solana-create-vote-account
```text ```text
solana-create-vote-account solana-create-vote-account
Create a vote account Create a vote account
USAGE: USAGE:
@ -802,7 +801,7 @@ ARGS:
#### solana-deactivate-stake #### solana-deactivate-stake
```text ```text
solana-deactivate-stake solana-deactivate-stake
Deactivate the delegated stake from the stake account Deactivate the delegated stake from the stake account
USAGE: USAGE:
@ -827,9 +826,9 @@ OPTIONS:
-u, --url <URL> JSON RPC URL for the solana cluster -u, --url <URL> JSON RPC URL for the solana cluster
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
--nonce <PUBKEY> --nonce <PUBKEY>
Provide the nonce account to use when creating a nonced Provide the nonce account to use when creating a nonced
transaction. Nonced transactions are useful when a transaction transaction. Nonced transactions are useful when a transaction
requires a lengthy signing process. Learn more about nonced requires a lengthy signing process. Learn more about nonced
transactions at https://docs.solana.com/offline-signing/durable-nonce transactions at https://docs.solana.com/offline-signing/durable-nonce
--nonce-authority <KEYPAIR or PUBKEY> --nonce-authority <KEYPAIR or PUBKEY>
Provide the nonce authority keypair to use when signing a nonced transaction Provide the nonce authority keypair to use when signing a nonced transaction
@ -843,7 +842,7 @@ ARGS:
#### solana-delegate-stake #### solana-delegate-stake
```text ```text
solana-delegate-stake solana-delegate-stake
Delegate stake to a vote account Delegate stake to a vote account
USAGE: USAGE:
@ -868,9 +867,9 @@ OPTIONS:
-u, --url <URL> JSON RPC URL for the solana cluster -u, --url <URL> JSON RPC URL for the solana cluster
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
--nonce <PUBKEY> --nonce <PUBKEY>
Provide the nonce account to use when creating a nonced Provide the nonce account to use when creating a nonced
transaction. Nonced transactions are useful when a transaction transaction. Nonced transactions are useful when a transaction
requires a lengthy signing process. Learn more about nonced requires a lengthy signing process. Learn more about nonced
transactions at https://docs.solana.com/offline-signing/durable-nonce transactions at https://docs.solana.com/offline-signing/durable-nonce
--nonce-authority <KEYPAIR or PUBKEY> --nonce-authority <KEYPAIR or PUBKEY>
Provide the nonce authority keypair to use when signing a nonced transaction Provide the nonce authority keypair to use when signing a nonced transaction
@ -885,7 +884,7 @@ ARGS:
#### solana-deploy #### solana-deploy
```text ```text
solana-deploy solana-deploy
Deploy a program Deploy a program
USAGE: USAGE:
@ -912,7 +911,7 @@ ARGS:
#### solana-epoch-info #### solana-epoch-info
```text ```text
solana-epoch-info solana-epoch-info
Get information about the current epoch Get information about the current epoch
USAGE: USAGE:
@ -937,7 +936,7 @@ OPTIONS:
#### solana-fees #### solana-fees
```text ```text
solana-fees solana-fees
Display current cluster fees Display current cluster fees
USAGE: USAGE:
@ -961,7 +960,7 @@ OPTIONS:
#### solana-genesis-hash #### solana-genesis-hash
```text ```text
solana-genesis-hash solana-genesis-hash
Get the genesis hash Get the genesis hash
USAGE: USAGE:
@ -985,7 +984,7 @@ OPTIONS:
#### solana-gossip #### solana-gossip
```text ```text
solana-gossip solana-gossip
Show the current gossip network nodes Show the current gossip network nodes
USAGE: USAGE:
@ -1009,7 +1008,7 @@ OPTIONS:
#### solana-help #### solana-help
```text ```text
solana-help solana-help
Prints this message or the help of the given subcommand(s) Prints this message or the help of the given subcommand(s)
USAGE: USAGE:
@ -1021,7 +1020,7 @@ ARGS:
#### solana-new-nonce #### solana-new-nonce
```text ```text
solana-new-nonce solana-new-nonce
Generate a new nonce, rendering the existing nonce useless Generate a new nonce, rendering the existing nonce useless
USAGE: USAGE:
@ -1053,7 +1052,7 @@ ARGS:
#### solana-nonce #### solana-nonce
```text ```text
solana-nonce solana-nonce
Get the current nonce value Get the current nonce value
USAGE: USAGE:
@ -1080,7 +1079,7 @@ ARGS:
#### solana-nonce-account #### solana-nonce-account
```text ```text
solana-nonce-account solana-nonce-account
Show the contents of a nonce account Show the contents of a nonce account
USAGE: USAGE:
@ -1108,14 +1107,14 @@ ARGS:
#### solana-pay #### solana-pay
```text ```text
solana-pay solana-pay
Send a payment Send a payment
USAGE: USAGE:
solana pay [FLAGS] [OPTIONS] <TO PUBKEY> <AMOUNT> [--] [UNIT] solana pay [FLAGS] [OPTIONS] <TO PUBKEY> <AMOUNT> [--] [UNIT]
FLAGS: FLAGS:
--cancelable --cancelable
-h, --help Prints help information -h, --help Prints help information
--sign-only Sign the transaction offline --sign-only Sign the transaction offline
--skip-seed-phrase-validation Skip validation of seed phrases. Use this if your phrase does not use the BIP39 --skip-seed-phrase-validation Skip validation of seed phrases. Use this if your phrase does not use the BIP39
@ -1134,9 +1133,9 @@ OPTIONS:
-u, --url <URL> JSON RPC URL for the solana cluster -u, --url <URL> JSON RPC URL for the solana cluster
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
--nonce <PUBKEY> --nonce <PUBKEY>
Provide the nonce account to use when creating a nonced Provide the nonce account to use when creating a nonced
transaction. Nonced transactions are useful when a transaction transaction. Nonced transactions are useful when a transaction
requires a lengthy signing process. Learn more about nonced requires a lengthy signing process. Learn more about nonced
transactions at https://docs.solana.com/offline-signing/durable-nonce transactions at https://docs.solana.com/offline-signing/durable-nonce
--nonce-authority <KEYPAIR or PUBKEY> --nonce-authority <KEYPAIR or PUBKEY>
Provide the nonce authority keypair to use when signing a nonced transaction Provide the nonce authority keypair to use when signing a nonced transaction
@ -1154,7 +1153,7 @@ ARGS:
#### solana-ping #### solana-ping
```text ```text
solana-ping solana-ping
Submit transactions sequentially Submit transactions sequentially
USAGE: USAGE:
@ -1183,7 +1182,7 @@ OPTIONS:
#### solana-send-signature #### solana-send-signature
```text ```text
solana-send-signature solana-send-signature
Send a signature to authorize a transfer Send a signature to authorize a transfer
USAGE: USAGE:
@ -1211,7 +1210,7 @@ ARGS:
#### solana-send-timestamp #### solana-send-timestamp
```text ```text
solana-send-timestamp solana-send-timestamp
Send a timestamp to unlock a transfer Send a timestamp to unlock a transfer
USAGE: USAGE:
@ -1240,7 +1239,7 @@ ARGS:
#### solana-show-stake-account #### solana-show-stake-account
```text ```text
solana-show-stake-account solana-show-stake-account
Show the contents of a stake account Show the contents of a stake account
USAGE: USAGE:
@ -1268,7 +1267,7 @@ ARGS:
#### solana-slot #### solana-slot
```text ```text
solana-slot solana-slot
Get current slot Get current slot
USAGE: USAGE:
@ -1293,7 +1292,7 @@ OPTIONS:
#### solana-stake-authorize-staker #### solana-stake-authorize-staker
```text ```text
solana-stake-authorize-staker solana-stake-authorize-staker
Authorize a new stake signing keypair for the given stake account Authorize a new stake signing keypair for the given stake account
USAGE: USAGE:
@ -1318,9 +1317,9 @@ OPTIONS:
-u, --url <URL> JSON RPC URL for the solana cluster -u, --url <URL> JSON RPC URL for the solana cluster
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
--nonce <PUBKEY> --nonce <PUBKEY>
Provide the nonce account to use when creating a nonced Provide the nonce account to use when creating a nonced
transaction. Nonced transactions are useful when a transaction transaction. Nonced transactions are useful when a transaction
requires a lengthy signing process. Learn more about nonced requires a lengthy signing process. Learn more about nonced
transactions at https://docs.solana.com/offline-signing/durable-nonce transactions at https://docs.solana.com/offline-signing/durable-nonce
--nonce-authority <KEYPAIR or PUBKEY> --nonce-authority <KEYPAIR or PUBKEY>
Provide the nonce authority keypair to use when signing a nonced transaction Provide the nonce authority keypair to use when signing a nonced transaction
@ -1335,7 +1334,7 @@ ARGS:
#### solana-stake-authorize-withdrawer #### solana-stake-authorize-withdrawer
```text ```text
solana-stake-authorize-withdrawer solana-stake-authorize-withdrawer
Authorize a new withdraw signing keypair for the given stake account Authorize a new withdraw signing keypair for the given stake account
USAGE: USAGE:
@ -1360,9 +1359,9 @@ OPTIONS:
-u, --url <URL> JSON RPC URL for the solana cluster -u, --url <URL> JSON RPC URL for the solana cluster
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
--nonce <PUBKEY> --nonce <PUBKEY>
Provide the nonce account to use when creating a nonced Provide the nonce account to use when creating a nonced
transaction. Nonced transactions are useful when a transaction transaction. Nonced transactions are useful when a transaction
requires a lengthy signing process. Learn more about nonced requires a lengthy signing process. Learn more about nonced
transactions at https://docs.solana.com/offline-signing/durable-nonce transactions at https://docs.solana.com/offline-signing/durable-nonce
--nonce-authority <KEYPAIR or PUBKEY> --nonce-authority <KEYPAIR or PUBKEY>
Provide the nonce authority keypair to use when signing a nonced transaction Provide the nonce authority keypair to use when signing a nonced transaction
@ -1377,7 +1376,7 @@ ARGS:
#### solana-stake-history #### solana-stake-history
```text ```text
solana-stake-history solana-stake-history
Show the stake history Show the stake history
USAGE: USAGE:
@ -1402,7 +1401,7 @@ OPTIONS:
#### solana-stakes #### solana-stakes
```text ```text
solana-stakes solana-stakes
Show stake account information Show stake account information
USAGE: USAGE:
@ -1430,7 +1429,7 @@ ARGS:
#### solana-storage-account #### solana-storage-account
```text ```text
solana-storage-account solana-storage-account
Show the contents of a storage account Show the contents of a storage account
USAGE: USAGE:
@ -1457,7 +1456,7 @@ ARGS:
#### solana-transaction-count #### solana-transaction-count
```text ```text
solana-transaction-count solana-transaction-count
Get current transaction count Get current transaction count
USAGE: USAGE:
@ -1480,38 +1479,9 @@ OPTIONS:
-k, --keypair <PATH> /path/to/id.json -k, --keypair <PATH> /path/to/id.json
``` ```
#### solana-uptime
```text
solana-uptime
Show the uptime of a validator, based on epoch voting history
USAGE:
solana uptime [FLAGS] [OPTIONS] <VOTE ACCOUNT PUBKEY>
FLAGS:
--aggregate Aggregate uptime data across span
-h, --help Prints help information
--skip-seed-phrase-validation Skip validation of seed phrases. Use this if your phrase does not use the BIP39
official English word list
-V, --version Prints version information
-v, --verbose Show extra information header
OPTIONS:
--ask-seed-phrase <KEYPAIR NAME> Recover a keypair using a seed phrase and optional passphrase [possible
values: keypair]
-C, --config <PATH> Configuration file to use [default:
~/.config/solana/cli/config.yml]
-u, --url <URL> JSON RPC URL for the solana cluster
-k, --keypair <PATH> /path/to/id.json
--span <NUM OF EPOCHS> Number of recent epochs to examine
ARGS:
<VOTE ACCOUNT PUBKEY> Vote account pubkey
```
#### solana-validator-info #### solana-validator-info
```text ```text
solana-validator-info solana-validator-info
Publish/get Validator info on Solana Publish/get Validator info on Solana
USAGE: USAGE:
@ -1540,7 +1510,7 @@ SUBCOMMANDS:
#### solana-validators #### solana-validators
```text ```text
solana-validators solana-validators
Show summary information about the current validators Show summary information about the current validators
USAGE: USAGE:
@ -1565,7 +1535,7 @@ OPTIONS:
#### solana-vote-account #### solana-vote-account
```text ```text
solana-vote-account solana-vote-account
Show the contents of a vote account Show the contents of a vote account
USAGE: USAGE:
@ -1593,7 +1563,7 @@ ARGS:
#### solana-vote-authorize-voter #### solana-vote-authorize-voter
```text ```text
solana-vote-authorize-voter solana-vote-authorize-voter
Authorize a new vote signing keypair for the given vote account Authorize a new vote signing keypair for the given vote account
USAGE: USAGE:
@ -1621,7 +1591,7 @@ ARGS:
#### solana-vote-authorize-withdrawer #### solana-vote-authorize-withdrawer
```text ```text
solana-vote-authorize-withdrawer solana-vote-authorize-withdrawer
Authorize a new withdraw signing keypair for the given vote account Authorize a new withdraw signing keypair for the given vote account
USAGE: USAGE:
@ -1649,7 +1619,7 @@ ARGS:
#### solana-vote-update-validator #### solana-vote-update-validator
```text ```text
solana-vote-update-validator solana-vote-update-validator
Update the vote account's validator identity Update the vote account's validator identity
USAGE: USAGE:
@ -1678,7 +1648,7 @@ ARGS:
#### solana-withdraw-from-nonce-account #### solana-withdraw-from-nonce-account
```text ```text
solana-withdraw-from-nonce-account solana-withdraw-from-nonce-account
Withdraw lamports from the nonce account Withdraw lamports from the nonce account
USAGE: USAGE:
@ -1713,7 +1683,7 @@ ARGS:
#### solana-withdraw-stake #### solana-withdraw-stake
```text ```text
solana-withdraw-stake solana-withdraw-stake
Withdraw the unstaked lamports from the stake account Withdraw the unstaked lamports from the stake account
USAGE: USAGE:

View File

@ -83,7 +83,6 @@ To monitor your validator during its warmup period:
* View your vote account:`solana vote-account ~/validator-vote-keypair.json` This displays the current state of all the votes the validator has submitted to the network. * View your vote account:`solana vote-account ~/validator-vote-keypair.json` This displays the current state of all the votes the validator has submitted to the network.
* View your stake account, the delegation preference and details of your stake:`solana stake-account ~/validator-stake-keypair.json` * View your stake account, the delegation preference and details of your stake:`solana stake-account ~/validator-stake-keypair.json`
* `solana uptime ~/validator-vote-keypair.json` will display the voting history \(aka, uptime\) of your validator over recent Epochs
* `solana validators` displays the current active stake of all validators, including yours * `solana validators` displays the current active stake of all validators, including yours
* `solana stake-history ` shows the history of stake warming up and cooling down over recent epochs * `solana stake-history ` shows the history of stake warming up and cooling down over recent epochs
* Look for log messages on your validator indicating your next leader slot: `[2019-09-27T20:16:00.319721164Z INFO solana_core::replay_stage] <VALIDATOR_IDENTITY_PUBKEY> voted and reset PoH at tick height ####. My next leader slot is ####` * Look for log messages on your validator indicating your next leader slot: `[2019-09-27T20:16:00.319721164Z INFO solana_core::replay_stage] <VALIDATOR_IDENTITY_PUBKEY> voted and reset PoH at tick height ####. My next leader slot is ####`

View File

@ -343,11 +343,6 @@ pub enum CliCommand {
pubkey: Pubkey, pubkey: Pubkey,
use_lamports_unit: bool, use_lamports_unit: bool,
}, },
Uptime {
pubkey: Pubkey,
aggregate: bool,
span: Option<u64>,
},
VoteAuthorize { VoteAuthorize {
vote_account_pubkey: Pubkey, vote_account_pubkey: Pubkey,
new_authorized_pubkey: Pubkey, new_authorized_pubkey: Pubkey,
@ -539,7 +534,6 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
parse_vote_authorize(matches, VoteAuthorize::Withdrawer) parse_vote_authorize(matches, VoteAuthorize::Withdrawer)
} }
("vote-account", Some(matches)) => parse_vote_get_account_command(matches), ("vote-account", Some(matches)) => parse_vote_get_account_command(matches),
("uptime", Some(matches)) => parse_vote_uptime_command(matches),
// Wallet Commands // Wallet Commands
("address", Some(_matches)) => Ok(CliCommandInfo { ("address", Some(_matches)) => Ok(CliCommandInfo {
command: CliCommand::Address, command: CliCommand::Address,
@ -1609,11 +1603,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
&new_identity_pubkey, &new_identity_pubkey,
authorized_voter, authorized_voter,
), ),
CliCommand::Uptime {
pubkey: vote_account_pubkey,
aggregate,
span,
} => process_uptime(&rpc_client, config, &vote_account_pubkey, *aggregate, *span),
// Wallet Commands // Wallet Commands

View File

@ -14,7 +14,7 @@ use solana_sdk::{
account_utils::StateMut, account_utils::StateMut,
clock::{self, Slot}, clock::{self, Slot},
commitment_config::CommitmentConfig, commitment_config::CommitmentConfig,
epoch_schedule::{Epoch, EpochSchedule}, epoch_schedule::Epoch,
hash::Hash, hash::Hash,
pubkey::Pubkey, pubkey::Pubkey,
signature::{Keypair, KeypairUtil}, signature::{Keypair, KeypairUtil},
@ -321,20 +321,6 @@ fn new_spinner_progress_bar() -> ProgressBar {
progress_bar progress_bar
} }
/// Aggregate epoch credit stats and return (total credits, total slots, total epochs)
pub fn aggregate_epoch_credits(
epoch_credits: &[(Epoch, u64, u64)],
epoch_schedule: &EpochSchedule,
) -> (u64, u64, u64) {
epoch_credits
.iter()
.fold((0, 0, 0), |acc, (epoch, credits, prev_credits)| {
let credits_earned = credits - prev_credits;
let slots_in_epoch = epoch_schedule.get_slots_in_epoch(*epoch);
(acc.0 + credits_earned, acc.1 + slots_in_epoch, acc.2 + 1)
})
}
pub fn process_catchup(rpc_client: &RpcClient, node_pubkey: &Pubkey) -> ProcessResult { pub fn process_catchup(rpc_client: &RpcClient, node_pubkey: &Pubkey) -> ProcessResult {
let cluster_nodes = rpc_client.get_cluster_nodes()?; let cluster_nodes = rpc_client.get_cluster_nodes()?;
@ -900,7 +886,7 @@ pub fn process_show_stakes(
} }
pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool) -> ProcessResult { pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool) -> ProcessResult {
let epoch_schedule = rpc_client.get_epoch_schedule()?; let epoch_info = rpc_client.get_epoch_info()?;
let vote_accounts = rpc_client.get_vote_accounts()?; let vote_accounts = rpc_client.get_vote_accounts()?;
let total_active_stake = vote_accounts let total_active_stake = vote_accounts
.current .current
@ -949,7 +935,7 @@ pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool)
"Commission", "Commission",
"Last Vote", "Last Vote",
"Root Block", "Root Block",
"Uptime", "Credits",
"Active Stake", "Active Stake",
)) ))
.bold() .bold()
@ -957,7 +943,7 @@ pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool)
fn print_vote_account( fn print_vote_account(
vote_account: RpcVoteAccountInfo, vote_account: RpcVoteAccountInfo,
epoch_schedule: &EpochSchedule, current_epoch: Epoch,
total_active_stake: f64, total_active_stake: f64,
use_lamports_unit: bool, use_lamports_unit: bool,
delinquent: bool, delinquent: bool,
@ -970,17 +956,6 @@ pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool)
} }
} }
fn uptime(epoch_credits: Vec<(Epoch, u64, u64)>, epoch_schedule: &EpochSchedule) -> String {
let (total_credits, total_slots, _) =
aggregate_epoch_credits(&epoch_credits, &epoch_schedule);
if total_slots > 0 {
let total_uptime = 100_f64 * total_credits as f64 / total_slots as f64;
format!("{:.2}%", total_uptime)
} else {
"-".into()
}
}
println!( println!(
"{} {:<44} {:<44} {:>9}% {:>8} {:>10} {:>7} {}", "{} {:<44} {:<44} {:>9}% {:>8} {:>10} {:>7} {}",
if delinquent { if delinquent {
@ -993,7 +968,15 @@ pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool)
vote_account.commission, vote_account.commission,
non_zero_or_dash(vote_account.last_vote), non_zero_or_dash(vote_account.last_vote),
non_zero_or_dash(vote_account.root_slot), non_zero_or_dash(vote_account.root_slot),
uptime(vote_account.epoch_credits, epoch_schedule), vote_account
.epoch_credits
.iter()
.find_map(|(epoch, credits, _)| if *epoch == current_epoch {
Some(*credits)
} else {
None
})
.unwrap_or(0),
if vote_account.activated_stake > 0 { if vote_account.activated_stake > 0 {
format!( format!(
"{} ({:.2}%)", "{} ({:.2}%)",
@ -1009,7 +992,7 @@ pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool)
for vote_account in vote_accounts.current.into_iter() { for vote_account in vote_accounts.current.into_iter() {
print_vote_account( print_vote_account(
vote_account, vote_account,
&epoch_schedule, epoch_info.epoch,
total_active_stake, total_active_stake,
use_lamports_unit, use_lamports_unit,
false, false,
@ -1018,7 +1001,7 @@ pub fn process_show_validators(rpc_client: &RpcClient, use_lamports_unit: bool)
for vote_account in vote_accounts.delinquent.into_iter() { for vote_account in vote_accounts.delinquent.into_iter() {
print_vote_account( print_vote_account(
vote_account, vote_account,
&epoch_schedule, epoch_info.epoch,
total_active_stake, total_active_stake,
use_lamports_unit, use_lamports_unit,
true, true,

View File

@ -1,10 +1,6 @@
use crate::{ use crate::cli::{
cli::{ build_balance_message, check_account_for_fee, check_unique_pubkeys,
build_balance_message, check_account_for_fee, check_unique_pubkeys, log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult,
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
ProcessResult,
},
cluster_query::aggregate_epoch_credits,
}; };
use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}; use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand};
use solana_clap_utils::{input_parsers::*, input_validators::*}; use solana_clap_utils::{input_parsers::*, input_validators::*};
@ -176,31 +172,6 @@ impl VoteSubCommands for App<'_, '_> {
.help("Display balance in lamports instead of SOL"), .help("Display balance in lamports instead of SOL"),
), ),
) )
.subcommand(
SubCommand::with_name("uptime")
.about("Show the uptime of a validator, based on epoch voting history")
.arg(
Arg::with_name("vote_account_pubkey")
.index(1)
.value_name("VOTE ACCOUNT PUBKEY")
.takes_value(true)
.required(true)
.validator(is_pubkey_or_keypair)
.help("Vote account pubkey"),
)
.arg(
Arg::with_name("span")
.long("span")
.value_name("NUM OF EPOCHS")
.takes_value(true)
.help("Number of recent epochs to examine"),
)
.arg(
Arg::with_name("aggregate")
.long("aggregate")
.help("Aggregate uptime data across span"),
),
)
} }
} }
@ -271,24 +242,6 @@ pub fn parse_vote_get_account_command(
}) })
} }
pub fn parse_vote_uptime_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let vote_account_pubkey = pubkey_of(matches, "vote_account_pubkey").unwrap();
let aggregate = matches.is_present("aggregate");
let span = if matches.is_present("span") {
Some(value_t_or_exit!(matches, "span", u64))
} else {
None
};
Ok(CliCommandInfo {
command: CliCommand::Uptime {
pubkey: vote_account_pubkey,
aggregate,
span,
},
require_keypair: false,
})
}
pub fn process_create_vote_account( pub fn process_create_vote_account(
rpc_client: &RpcClient, rpc_client: &RpcClient,
config: &CliConfig, config: &CliConfig,
@ -517,60 +470,6 @@ pub fn process_show_vote_account(
Ok("".to_string()) Ok("".to_string())
} }
pub fn process_uptime(
rpc_client: &RpcClient,
_config: &CliConfig,
vote_account_pubkey: &Pubkey,
aggregate: bool,
span: Option<u64>,
) -> ProcessResult {
let (_vote_account, vote_state) = get_vote_account(rpc_client, vote_account_pubkey)?;
let epoch_schedule = rpc_client.get_epoch_schedule()?;
println!("validator identity: {}", vote_state.node_pubkey);
println!("authorized voter: {}", vote_state.authorized_voter);
if !vote_state.votes.is_empty() {
println!("uptime:");
let epoch_credits: Vec<(u64, u64, u64)> = if let Some(x) = span {
vote_state
.epoch_credits()
.iter()
.rev()
.take(x as usize)
.cloned()
.collect()
} else {
vote_state.epoch_credits().iter().rev().cloned().collect()
};
if aggregate {
let (total_credits, total_slots, epochs) =
aggregate_epoch_credits(&epoch_credits, &epoch_schedule);
if total_slots > 0 {
let total_uptime = 100_f64 * total_credits as f64 / total_slots as f64;
println!("{:.2}% over {} epochs", total_uptime, epochs);
} else {
println!("Insufficient voting history available");
}
} else {
for (epoch, credits, prev_credits) in epoch_credits {
let credits_earned = credits - prev_credits;
let slots_in_epoch = epoch_schedule.get_slots_in_epoch(epoch);
let uptime = credits_earned as f64 / slots_in_epoch as f64;
println!("- epoch: {} {:.2}% uptime", epoch, uptime * 100_f64,);
}
}
if let Some(x) = span {
if x > vote_state.epoch_credits().len() as u64 {
println!("(span longer than available epochs)");
}
}
}
Ok("".to_string())
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@ -741,27 +640,5 @@ mod tests {
require_keypair: true require_keypair: true
} }
); );
// Test Uptime Subcommand
let pubkey = Pubkey::new_rand();
let matches = test_commands.clone().get_matches_from(vec![
"test",
"uptime",
&pubkey.to_string(),
"--span",
"4",
"--aggregate",
]);
assert_eq!(
parse_command(&matches).unwrap(),
CliCommandInfo {
command: CliCommand::Uptime {
pubkey,
aggregate: true,
span: Some(4)
},
require_keypair: false
}
);
} }
} }