Optional Cli parameter to add additional-fee to solana ping (#23513)
* Optional Cli parameter to add additional-fee to solana ping Co-authored-by: Tyera Eulberg <teulberg@gmail.com> Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com> * Update cli/src/cluster_query.rs correct the help message for arg Co-authored-by: Tyera Eulberg <teulberg@gmail.com> Co-authored-by: Tyera Eulberg <teulberg@gmail.com> Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
This commit is contained in:
parent
7933c7fc24
commit
e790d0fc53
|
@ -88,6 +88,7 @@ pub enum CliCommand {
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
blockhash: Option<Hash>,
|
blockhash: Option<Hash>,
|
||||||
print_timestamp: bool,
|
print_timestamp: bool,
|
||||||
|
additional_fee: Option<u32>,
|
||||||
},
|
},
|
||||||
Rent {
|
Rent {
|
||||||
data_length: usize,
|
data_length: usize,
|
||||||
|
@ -977,6 +978,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||||
timeout,
|
timeout,
|
||||||
blockhash,
|
blockhash,
|
||||||
print_timestamp,
|
print_timestamp,
|
||||||
|
additional_fee,
|
||||||
} => process_ping(
|
} => process_ping(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
config,
|
config,
|
||||||
|
@ -985,6 +987,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||||
timeout,
|
timeout,
|
||||||
blockhash,
|
blockhash,
|
||||||
*print_timestamp,
|
*print_timestamp,
|
||||||
|
additional_fee,
|
||||||
),
|
),
|
||||||
CliCommand::Rent {
|
CliCommand::Rent {
|
||||||
data_length,
|
data_length,
|
||||||
|
|
|
@ -33,12 +33,14 @@ use {
|
||||||
rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
|
rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
|
||||||
rpc_response::SlotInfo,
|
rpc_response::SlotInfo,
|
||||||
},
|
},
|
||||||
|
solana_program_runtime::compute_budget::ComputeBudget,
|
||||||
solana_remote_wallet::remote_wallet::RemoteWalletManager,
|
solana_remote_wallet::remote_wallet::RemoteWalletManager,
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::from_account,
|
account::from_account,
|
||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
clock::{self, Clock, Slot},
|
clock::{self, Clock, Slot},
|
||||||
commitment_config::CommitmentConfig,
|
commitment_config::CommitmentConfig,
|
||||||
|
compute_budget::ComputeBudgetInstruction,
|
||||||
epoch_schedule::Epoch,
|
epoch_schedule::Epoch,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
message::Message,
|
message::Message,
|
||||||
|
@ -269,6 +271,13 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
||||||
.default_value("15")
|
.default_value("15")
|
||||||
.help("Wait up to timeout seconds for transaction confirmation"),
|
.help("Wait up to timeout seconds for transaction confirmation"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("additional_fee")
|
||||||
|
.long("additional-fee")
|
||||||
|
.value_name("NUMBER")
|
||||||
|
.takes_value(true)
|
||||||
|
.help("Request additional-fee for transaction"),
|
||||||
|
)
|
||||||
.arg(blockhash_arg()),
|
.arg(blockhash_arg()),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
|
@ -513,6 +522,7 @@ pub fn parse_cluster_ping(
|
||||||
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
|
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
|
||||||
let blockhash = value_of(matches, BLOCKHASH_ARG.name);
|
let blockhash = value_of(matches, BLOCKHASH_ARG.name);
|
||||||
let print_timestamp = matches.is_present("print_timestamp");
|
let print_timestamp = matches.is_present("print_timestamp");
|
||||||
|
let additional_fee = value_of(matches, "additional_fee");
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::Ping {
|
command: CliCommand::Ping {
|
||||||
interval,
|
interval,
|
||||||
|
@ -520,6 +530,7 @@ pub fn parse_cluster_ping(
|
||||||
timeout,
|
timeout,
|
||||||
blockhash,
|
blockhash,
|
||||||
print_timestamp,
|
print_timestamp,
|
||||||
|
additional_fee,
|
||||||
},
|
},
|
||||||
signers: vec![default_signer.signer_from_path(matches, wallet_manager)?],
|
signers: vec![default_signer.signer_from_path(matches, wallet_manager)?],
|
||||||
})
|
})
|
||||||
|
@ -1350,6 +1361,7 @@ pub fn process_ping(
|
||||||
timeout: &Duration,
|
timeout: &Duration,
|
||||||
fixed_blockhash: &Option<Hash>,
|
fixed_blockhash: &Option<Hash>,
|
||||||
print_timestamp: bool,
|
print_timestamp: bool,
|
||||||
|
additional_fee: &Option<u32>,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let (signal_sender, signal_receiver) = unbounded();
|
let (signal_sender, signal_receiver) = unbounded();
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
|
@ -1374,6 +1386,7 @@ pub fn process_ping(
|
||||||
blockhash_from_cluster = true;
|
blockhash_from_cluster = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
'mainloop: for seq in 0..count.unwrap_or(std::u64::MAX) {
|
'mainloop: for seq in 0..count.unwrap_or(std::u64::MAX) {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
if fixed_blockhash.is_none() && now.duration_since(blockhash_acquired).as_secs() > 60 {
|
if fixed_blockhash.is_none() && now.duration_since(blockhash_acquired).as_secs() > 60 {
|
||||||
|
@ -1388,8 +1401,18 @@ pub fn process_ping(
|
||||||
lamports += 1;
|
lamports += 1;
|
||||||
|
|
||||||
let build_message = |lamports| {
|
let build_message = |lamports| {
|
||||||
let ix = system_instruction::transfer(&config.signers[0].pubkey(), &to, lamports);
|
let mut ixs = vec![system_instruction::transfer(
|
||||||
Message::new(&[ix], Some(&config.signers[0].pubkey()))
|
&config.signers[0].pubkey(),
|
||||||
|
&to,
|
||||||
|
lamports,
|
||||||
|
)];
|
||||||
|
if let Some(additional_fee) = additional_fee {
|
||||||
|
ixs.push(ComputeBudgetInstruction::request_units(
|
||||||
|
ComputeBudget::new(false).max_units as u32,
|
||||||
|
*additional_fee,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Message::new(&ixs, Some(&config.signers[0].pubkey()))
|
||||||
};
|
};
|
||||||
let (message, _) = resolve_spend_tx_and_check_account_balance(
|
let (message, _) = resolve_spend_tx_and_check_account_balance(
|
||||||
rpc_client,
|
rpc_client,
|
||||||
|
@ -2312,6 +2335,7 @@ mod tests {
|
||||||
Hash::from_str("4CCNp28j6AhGq7PkjPDP4wbQWBS8LLbQin2xV5n8frKX").unwrap()
|
Hash::from_str("4CCNp28j6AhGq7PkjPDP4wbQWBS8LLbQin2xV5n8frKX").unwrap()
|
||||||
),
|
),
|
||||||
print_timestamp: true,
|
print_timestamp: true,
|
||||||
|
additional_fee: None,
|
||||||
},
|
},
|
||||||
signers: vec![default_keypair.into()],
|
signers: vec![default_keypair.into()],
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue