From ac36954af041f03ec0aa321092921776dc13f76e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 1 Feb 2022 00:40:14 +0000 Subject: [PATCH] Update ping to transfer to self, with rotating amount (backport #22657) (#22853) * Update ping to transfer to self, with rotating amount (#22657) * Update ping to transfer to self, with rotating amount * Remove balance check (cherry picked from commit 90689585efbf0fbab707e2201af7a4f91d03f4bc) # Conflicts: # cli/src/cluster_query.rs * Fix api diff Co-authored-by: Tyera Eulberg Co-authored-by: Tyera Eulberg --- cli/src/cli.rs | 3 --- cli/src/cluster_query.rs | 28 ++++++---------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 0bea8252a9..f684fb8954 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -83,7 +83,6 @@ pub enum CliCommand { filter: RpcTransactionLogsFilter, }, Ping { - lamports: u64, interval: Duration, count: Option, timeout: Duration, @@ -963,7 +962,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult { CliCommand::LiveSlots => process_live_slots(config), CliCommand::Logs { filter } => process_logs(config, filter), CliCommand::Ping { - lamports, interval, count, timeout, @@ -972,7 +970,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult { } => process_ping( &rpc_client, config, - *lamports, interval, count, timeout, diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 6064b52028..557e806cdd 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -43,13 +43,13 @@ use { message::Message, native_token::lamports_to_sol, nonce::State as NonceState, - pubkey::{self, Pubkey}, + pubkey::Pubkey, rent::Rent, rpc_port::DEFAULT_RPC_PORT_STR, signature::Signature, slot_history, stake::{self, state::StakeState}, - system_instruction, system_program, + system_instruction, sysvar::{ self, slot_history::SlotHistory, @@ -261,15 +261,6 @@ impl ClusterQuerySubCommands for App<'_, '_> { .takes_value(false) .help("Print timestamp (unix time + microseconds as in gettimeofday) before each line"), ) - .arg( - Arg::with_name("lamports") - .long("lamports") - .value_name("NUMBER") - .takes_value(true) - .default_value("1") - .validator(is_amount) - .help("Number of lamports to transfer for each transaction"), - ) .arg( Arg::with_name("timeout") .short("t") @@ -514,7 +505,6 @@ pub fn parse_cluster_ping( default_signer: &DefaultSigner, wallet_manager: &mut Option>, ) -> Result { - let lamports = value_t_or_exit!(matches, "lamports", u64); let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64)); let count = if matches.is_present("count") { Some(value_t_or_exit!(matches, "count", u64)) @@ -526,7 +516,6 @@ pub fn parse_cluster_ping( let print_timestamp = matches.is_present("print_timestamp"); Ok(CliCommandInfo { command: CliCommand::Ping { - lamports, interval, count, timeout, @@ -1357,7 +1346,6 @@ pub fn process_get_transaction_count(rpc_client: &RpcClient, _config: &CliConfig pub fn process_ping( rpc_client: &RpcClient, config: &CliConfig, - lamports: u64, interval: &Duration, count: &Option, timeout: &Duration, @@ -1378,7 +1366,7 @@ pub fn process_ping( let mut confirmation_time: VecDeque = VecDeque::with_capacity(1024); let (mut blockhash, mut fee_calculator) = rpc_client.get_recent_blockhash()?; - let mut blockhash_transaction_count = 0; + let mut lamports = 0; let mut blockhash_acquired = Instant::now(); if let Some(fixed_blockhash) = fixed_blockhash { let blockhash_origin = if *fixed_blockhash != Hash::default() { @@ -1399,15 +1387,12 @@ pub fn process_ping( let (new_blockhash, new_fee_calculator) = rpc_client.get_new_blockhash(&blockhash)?; blockhash = new_blockhash; fee_calculator = new_fee_calculator; - blockhash_transaction_count = 0; + lamports = 0; blockhash_acquired = Instant::now(); } - let seed = - &format!("{}{}", blockhash_transaction_count, blockhash)[0..pubkey::MAX_SEED_LEN]; - let to = Pubkey::create_with_seed(&config.signers[0].pubkey(), seed, &system_program::id()) - .unwrap(); - blockhash_transaction_count += 1; + let to = config.signers[0].pubkey(); + lamports += 1; let build_message = |lamports| { let ix = system_instruction::transfer(&config.signers[0].pubkey(), &to, lamports); @@ -2305,7 +2290,6 @@ mod tests { parse_command(&test_ping, &default_signer, &mut None).unwrap(), CliCommandInfo { command: CliCommand::Ping { - lamports: 1, interval: Duration::from_secs(1), count: Some(2), timeout: Duration::from_secs(3),