Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit f3bd048

Browse files
authored
token-cli: Add confirm-tx timeout to RPC client (#7484)
#### Problem As noticed with #7456, a transaction with a nonced blockhash fails to confirm even though it works. This might be because of the confirmation logic in the RPC client, which looks for the provided blockhash: https://github.com/anza-xyz/agave/blob/b46c87ea538a1508ed4ae36f8dbf6c75dd57c883/rpc-client/src/nonblocking/rpc_client.rs#L1090 #### Summary of changes Specify a default transaction confirmation timeout.
1 parent 920ab31 commit f3bd048

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

token/cli/src/config.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use {
2626
},
2727
token::ComputeUnitLimit,
2828
},
29-
std::{process::exit, rc::Rc, str::FromStr, sync::Arc},
29+
std::{process::exit, rc::Rc, str::FromStr, sync::Arc, time::Duration},
3030
};
3131

3232
type SignersOf = Vec<(Arc<dyn Signer>, Pubkey)>;
@@ -55,6 +55,9 @@ pub(crate) struct MintInfo {
5555
pub decimals: u8,
5656
}
5757

58+
const DEFAULT_RPC_TIMEOUT: Duration = Duration::from_secs(30);
59+
const DEFAULT_CONFIRM_TX_TIMEOUT: Duration = Duration::from_secs(5);
60+
5861
pub struct Config<'a> {
5962
pub default_signer: Option<Arc<dyn Signer>>,
6063
pub rpc_client: Arc<RpcClient>,
@@ -97,9 +100,11 @@ impl<'a> Config<'a> {
97100
.unwrap_or(&cli_config.json_rpc_url),
98101
);
99102
let websocket_url = solana_cli_config::Config::compute_websocket_url(&json_rpc_url);
100-
let rpc_client = Arc::new(RpcClient::new_with_commitment(
103+
let rpc_client = Arc::new(RpcClient::new_with_timeouts_and_commitment(
101104
json_rpc_url,
105+
DEFAULT_RPC_TIMEOUT,
102106
CommitmentConfig::confirmed(),
107+
DEFAULT_CONFIRM_TX_TIMEOUT,
103108
));
104109
let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
105110
let program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>> = if sign_only {

0 commit comments

Comments
 (0)