From 17dd53d5e8bae9a03313276c7c62e63d361f616a Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 2 Apr 2021 20:49:42 -0700 Subject: [PATCH] Break up the UpdateValidatorListBalance instructions over multiple transactions --- stake-pool/cli/src/main.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stake-pool/cli/src/main.rs b/stake-pool/cli/src/main.rs index b9ebce572fb..7537b8e75bf 100644 --- a/stake-pool/cli/src/main.rs +++ b/stake-pool/cli/src/main.rs @@ -678,8 +678,9 @@ fn command_update(config: &Config, stake_pool_address: &Pubkey) -> CommandResult }) .collect(); - let mut instructions: Vec = vec![]; + println!("Updating stake pool..."); + let mut instructions: Vec = vec![]; for accounts_chunk in accounts_to_update.chunks(MAX_ACCOUNTS_TO_UPDATE) { instructions.push(spl_stake_pool::instruction::update_validator_list_balance( &spl_stake_pool::id(), @@ -688,20 +689,22 @@ fn command_update(config: &Config, stake_pool_address: &Pubkey) -> CommandResult )?); } - println!("Updating stake pool..."); instructions.push(spl_stake_pool::instruction::update_stake_pool_balance( &spl_stake_pool::id(), stake_pool_address, &stake_pool.validator_list, )?); - let mut transaction = - Transaction::new_with_payer(&instructions, Some(&config.fee_payer.pubkey())); + // TODO: A faster solution would be to send all the `update_validator_list_balance` instructions concurrently + for instruction in instructions { + let mut transaction = + Transaction::new_with_payer(&[instruction], Some(&config.fee_payer.pubkey())); - let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?; - check_fee_payer_balance(config, fee_calculator.calculate_fee(&transaction.message()))?; - transaction.sign(&[config.fee_payer.as_ref()], recent_blockhash); - send_transaction(&config, transaction)?; + let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?; + check_fee_payer_balance(config, fee_calculator.calculate_fee(&transaction.message()))?; + transaction.sign(&[config.fee_payer.as_ref()], recent_blockhash); + send_transaction(&config, transaction)?; + } Ok(()) }