Improve solana-test-validator output
This commit is contained in:
parent
cc2886c13c
commit
1c2ae15b1d
|
@ -338,6 +338,9 @@ impl TestValidator {
|
||||||
let tpu = node.info.tpu;
|
let tpu = node.info.tpu;
|
||||||
let gossip = node.info.gossip;
|
let gossip = node.info.gossip;
|
||||||
|
|
||||||
|
let mut rpc_config = config.rpc_config.clone();
|
||||||
|
rpc_config.identity_pubkey = validator_identity.pubkey();
|
||||||
|
|
||||||
let validator_config = ValidatorConfig {
|
let validator_config = ValidatorConfig {
|
||||||
rpc_addrs: Some((
|
rpc_addrs: Some((
|
||||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), node.info.rpc.port()),
|
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), node.info.rpc.port()),
|
||||||
|
@ -346,7 +349,7 @@ impl TestValidator {
|
||||||
node.info.rpc_pubsub.port(),
|
node.info.rpc_pubsub.port(),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
rpc_config: config.rpc_config.clone(),
|
rpc_config,
|
||||||
accounts_hash_interval_slots: 100,
|
accounts_hash_interval_slots: 100,
|
||||||
account_paths: vec![ledger_path.join("accounts")],
|
account_paths: vec![ledger_path.join("accounts")],
|
||||||
poh_verify: false, // Skip PoH verification of ledger on startup for speed
|
poh_verify: false, // Skip PoH verification of ledger on startup for speed
|
||||||
|
|
|
@ -11,7 +11,7 @@ use {
|
||||||
account::Account,
|
account::Account,
|
||||||
clock::{Slot, DEFAULT_TICKS_PER_SLOT, MS_PER_TICK},
|
clock::{Slot, DEFAULT_TICKS_PER_SLOT, MS_PER_TICK},
|
||||||
commitment_config::CommitmentConfig,
|
commitment_config::CommitmentConfig,
|
||||||
native_token::sol_to_lamports,
|
native_token::{sol_to_lamports, Sol},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
rpc_port,
|
rpc_port,
|
||||||
signature::{read_keypair_file, write_keypair_file, Keypair, Signer},
|
signature::{read_keypair_file, write_keypair_file, Keypair, Signer},
|
||||||
|
@ -25,7 +25,7 @@ use {
|
||||||
process::exit,
|
process::exit,
|
||||||
sync::mpsc::channel,
|
sync::mpsc::channel,
|
||||||
thread,
|
thread,
|
||||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -271,6 +271,8 @@ fn main() {
|
||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let validator_start = Instant::now();
|
||||||
|
|
||||||
let test_validator = {
|
let test_validator = {
|
||||||
let _progress_bar = if output == Output::Dashboard {
|
let _progress_bar = if output == Output::Dashboard {
|
||||||
println_name_value("Mint address:", &mint_address.to_string());
|
println_name_value("Mint address:", &mint_address.to_string());
|
||||||
|
@ -284,7 +286,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
TestValidatorGenesis::default()
|
TestValidatorGenesis::default()
|
||||||
.ledger_path(ledger_path)
|
.ledger_path(&ledger_path)
|
||||||
.add_account(
|
.add_account(
|
||||||
faucet_keypair.pubkey(),
|
faucet_keypair.pubkey(),
|
||||||
Account::new(faucet_lamports, 0, &system_program::id()),
|
Account::new(faucet_lamports, 0, &system_program::id()),
|
||||||
|
@ -311,6 +313,13 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if output == Output::Dashboard {
|
if output == Output::Dashboard {
|
||||||
|
let rpc_client = test_validator.rpc_client().0;
|
||||||
|
let identity = &rpc_client.get_identity().expect("get_identity");
|
||||||
|
println_name_value("Identity:", &identity.to_string());
|
||||||
|
println_name_value(
|
||||||
|
"Version:",
|
||||||
|
&rpc_client.get_version().expect("get_version").solana_core,
|
||||||
|
);
|
||||||
println_name_value("JSON RPC URL:", &test_validator.rpc_url());
|
println_name_value("JSON RPC URL:", &test_validator.rpc_url());
|
||||||
println_name_value(
|
println_name_value(
|
||||||
"JSON RPC PubSub Websocket:",
|
"JSON RPC PubSub Websocket:",
|
||||||
|
@ -326,31 +335,63 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let progress_bar = new_spinner_progress_bar();
|
let progress_bar = new_spinner_progress_bar();
|
||||||
let rpc_client = test_validator.rpc_client().0;
|
|
||||||
|
|
||||||
fn get_validator_stats(rpc_client: &RpcClient) -> client_error::Result<(Slot, Slot, u64)> {
|
fn get_validator_stats(
|
||||||
let max_slot = rpc_client.get_slot_with_commitment(CommitmentConfig::max())?;
|
rpc_client: &RpcClient,
|
||||||
let recent_slot = rpc_client.get_slot_with_commitment(CommitmentConfig::recent())?;
|
identity: &Pubkey,
|
||||||
|
) -> client_error::Result<(Slot, Slot, Slot, u64, Sol)> {
|
||||||
|
let processed_slot = rpc_client.get_slot_with_commitment(CommitmentConfig::recent())?;
|
||||||
|
let confirmed_slot =
|
||||||
|
rpc_client.get_slot_with_commitment(CommitmentConfig::single_gossip())?;
|
||||||
|
let finalized_slot = rpc_client.get_slot_with_commitment(CommitmentConfig::max())?;
|
||||||
let transaction_count =
|
let transaction_count =
|
||||||
rpc_client.get_transaction_count_with_commitment(CommitmentConfig::recent())?;
|
rpc_client.get_transaction_count_with_commitment(CommitmentConfig::recent())?;
|
||||||
Ok((recent_slot, max_slot, transaction_count))
|
let identity_balance = rpc_client
|
||||||
|
.get_balance_with_commitment(identity, CommitmentConfig::single_gossip())?
|
||||||
|
.value;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
processed_slot,
|
||||||
|
confirmed_slot,
|
||||||
|
finalized_slot,
|
||||||
|
transaction_count,
|
||||||
|
Sol(identity_balance),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match get_validator_stats(&rpc_client) {
|
let snapshot_slot =
|
||||||
Ok((recent_slot, max_slot, transaction_count)) => {
|
solana_runtime::snapshot_utils::get_highest_snapshot_archive_path(&ledger_path)
|
||||||
progress_bar.set_message(&format!(
|
.map(|(_, (slot, _, _))| slot)
|
||||||
"Recent slot: {} | Max confirmed slot: {} | Transaction count: {}",
|
.unwrap_or(0);
|
||||||
recent_slot, max_slot, transaction_count,
|
|
||||||
));
|
for _i in 0..10 {
|
||||||
}
|
match get_validator_stats(&rpc_client, &identity) {
|
||||||
Err(err) => {
|
Ok((
|
||||||
progress_bar.set_message(&format!("{}", err));
|
processed_slot,
|
||||||
|
confirmed_slot,
|
||||||
|
finalized_slot,
|
||||||
|
transaction_count,
|
||||||
|
identity_balance,
|
||||||
|
)) => {
|
||||||
|
let uptime = chrono::Duration::from_std(validator_start.elapsed()).unwrap();
|
||||||
|
progress_bar.set_message(&format!(
|
||||||
|
"{:02}:{:02}:{:02} | \
|
||||||
|
Processed Slot: {} | Confirmed Slot: {} | Finalized Slot: {} | Snapshot Slot: {} | \
|
||||||
|
Transactions: {} | {}",
|
||||||
|
uptime.num_hours(), uptime.num_minutes() % 60, uptime.num_seconds() % 60,
|
||||||
|
processed_slot, confirmed_slot, finalized_slot, snapshot_slot,
|
||||||
|
transaction_count, identity_balance
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
progress_bar.set_message(&format!("{}", err));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
thread::sleep(Duration::from_millis(
|
||||||
|
MS_PER_TICK * DEFAULT_TICKS_PER_SLOT / 2,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
thread::sleep(Duration::from_millis(
|
|
||||||
MS_PER_TICK * DEFAULT_TICKS_PER_SLOT / 2,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue