Cli: default to single gossip (#14673)

* Init cli RpcClient with chosen commitment; default to single_gossip

* Fill in missing client methods

* Cli tests: make RpcClient commitment specific

* Simply rpc_client calls, using configured commitment

* Check validator vote account with single-gossip commitment
This commit is contained in:
Tyera Eulberg
2021-01-19 15:33:03 -07:00
committed by GitHub
parent fba4e51171
commit 4964b0fe61
16 changed files with 179 additions and 384 deletions

View File

@@ -271,6 +271,7 @@ impl ProgramSubCommands for App<'_, '_> {
.required(true)
.help("Public key of the account to query")
)
.arg(commitment_arg_with_default("singleGossip")),
)
)
}
@@ -856,9 +857,7 @@ fn process_set_authority(
};
trace!("Set a new authority");
let (blockhash, _, _) = rpc_client
.get_recent_blockhash_with_commitment(config.commitment)?
.value;
let (blockhash, _) = rpc_client.get_recent_blockhash()?;
let mut tx = if let Some(pubkey) = program_pubkey {
Transaction::new_unsigned(Message::new(
@@ -1349,9 +1348,7 @@ fn check_payer(
balance_needed: u64,
messages: &[&Message],
) -> Result<(), Box<dyn std::error::Error>> {
let (_, fee_calculator, _) = rpc_client
.get_recent_blockhash_with_commitment(config.commitment)?
.value;
let (_, fee_calculator) = rpc_client.get_recent_blockhash()?;
// Does the payer have enough?
check_account_for_spend_multiple_fees_with_commitment(
@@ -1379,9 +1376,7 @@ fn send_deploy_messages(
if let Some(message) = initial_message {
if let Some(initial_signer) = initial_signer {
trace!("Preparing the required accounts");
let (blockhash, _, _) = rpc_client
.get_recent_blockhash_with_commitment(config.commitment)?
.value;
let (blockhash, _) = rpc_client.get_recent_blockhash()?;
let mut initial_transaction = Transaction::new_unsigned(message.clone());
// Most of the initial_transaction combinations require both the fee-payer and new program
@@ -1393,11 +1388,7 @@ fn send_deploy_messages(
} else {
initial_transaction.try_sign(&[payer_signer], blockhash)?;
}
let result = rpc_client.send_and_confirm_transaction_with_spinner_and_config(
&initial_transaction,
config.commitment,
config.send_transaction_config,
);
let result = rpc_client.send_and_confirm_transaction_with_spinner(&initial_transaction);
log_instruction_custom_error::<SystemError>(result, &config)
.map_err(|err| format!("Account allocation failed: {}", err))?;
} else {
@@ -1432,9 +1423,7 @@ fn send_deploy_messages(
if let Some(message) = final_message {
if let Some(final_signer) = final_signer {
trace!("Deploying program");
let (blockhash, _, _) = rpc_client
.get_recent_blockhash_with_commitment(config.commitment)?
.value;
let (blockhash, _) = rpc_client.get_recent_blockhash()?;
let mut final_tx = Transaction::new_unsigned(message.clone());
final_tx.try_sign(&[payer_signer, final_signer], blockhash)?;
@@ -1513,10 +1502,9 @@ fn send_and_confirm_transactions_with_spinner<T: Signers>(
let mut status_retries = 15;
progress_bar.set_message("Finding leader node...");
let epoch_info = rpc_client.get_epoch_info_with_commitment(commitment)?;
let epoch_info = rpc_client.get_epoch_info()?;
if epoch_info.epoch > leader_schedule_epoch || leader_schedule.is_none() {
leader_schedule = rpc_client
.get_leader_schedule_with_commitment(Some(epoch_info.absolute_slot), commitment)?;
leader_schedule = rpc_client.get_leader_schedule(Some(epoch_info.absolute_slot))?;
leader_schedule_epoch = epoch_info.epoch;
}
let tpu_address = get_leader_tpu(
@@ -1598,7 +1586,7 @@ fn send_and_confirm_transactions_with_spinner<T: Signers>(
return Ok(());
}
let slot = rpc_client.get_slot_with_commitment(commitment)?;
let slot = rpc_client.get_slot()?;
if slot > last_valid_slot {
break;
}