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

Commit 17dd53d

Browse files
committed
Break up the UpdateValidatorListBalance instructions over multiple transactions
1 parent 8f325dc commit 17dd53d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

stake-pool/cli/src/main.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,9 @@ fn command_update(config: &Config, stake_pool_address: &Pubkey) -> CommandResult
678678
})
679679
.collect();
680680

681-
let mut instructions: Vec<Instruction> = vec![];
681+
println!("Updating stake pool...");
682682

683+
let mut instructions: Vec<Instruction> = vec![];
683684
for accounts_chunk in accounts_to_update.chunks(MAX_ACCOUNTS_TO_UPDATE) {
684685
instructions.push(spl_stake_pool::instruction::update_validator_list_balance(
685686
&spl_stake_pool::id(),
@@ -688,20 +689,22 @@ fn command_update(config: &Config, stake_pool_address: &Pubkey) -> CommandResult
688689
)?);
689690
}
690691

691-
println!("Updating stake pool...");
692692
instructions.push(spl_stake_pool::instruction::update_stake_pool_balance(
693693
&spl_stake_pool::id(),
694694
stake_pool_address,
695695
&stake_pool.validator_list,
696696
)?);
697697

698-
let mut transaction =
699-
Transaction::new_with_payer(&instructions, Some(&config.fee_payer.pubkey()));
698+
// TODO: A faster solution would be to send all the `update_validator_list_balance` instructions concurrently
699+
for instruction in instructions {
700+
let mut transaction =
701+
Transaction::new_with_payer(&[instruction], Some(&config.fee_payer.pubkey()));
700702

701-
let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?;
702-
check_fee_payer_balance(config, fee_calculator.calculate_fee(&transaction.message()))?;
703-
transaction.sign(&[config.fee_payer.as_ref()], recent_blockhash);
704-
send_transaction(&config, transaction)?;
703+
let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?;
704+
check_fee_payer_balance(config, fee_calculator.calculate_fee(&transaction.message()))?;
705+
transaction.sign(&[config.fee_payer.as_ref()], recent_blockhash);
706+
send_transaction(&config, transaction)?;
707+
}
705708
Ok(())
706709
}
707710

0 commit comments

Comments
 (0)