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

Commit 317c375

Browse files
committed
Add compute budget instructions
1 parent b124c5a commit 317c375

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

stake-pool/cli/src/main.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use {
3737
solana_remote_wallet::remote_wallet::RemoteWalletManager,
3838
solana_sdk::{
3939
commitment_config::CommitmentConfig,
40+
compute_budget::ComputeBudgetInstruction,
4041
hash::Hash,
4142
message::Message,
4243
native_token::{self, Sol},
@@ -193,8 +194,26 @@ fn checked_transaction_with_signers_and_additional_fee<T: Signers>(
193194
additional_fee: u64,
194195
) -> Result<Transaction, Error> {
195196
let recent_blockhash = get_latest_blockhash(&config.rpc_client)?;
197+
let mut instructions = instructions.to_vec();
198+
if let Some(compute_unit_price) = config.compute_unit_price {
199+
instructions.push(ComputeBudgetInstruction::set_compute_unit_price(
200+
compute_unit_price,
201+
));
202+
}
203+
if let Some(compute_unit_limit) = config.compute_unit_limit {
204+
instructions.push(ComputeBudgetInstruction::set_compute_unit_limit(
205+
compute_unit_limit,
206+
));
207+
} else {
208+
add_compute_unit_limit_from_simulation(
209+
&config.rpc_client,
210+
&mut instructions,
211+
&config.fee_payer.pubkey(),
212+
&recent_blockhash,
213+
)?;
214+
}
196215
let message = Message::new_with_blockhash(
197-
instructions,
216+
&instructions,
198217
Some(&config.fee_payer.pubkey()),
199218
&recent_blockhash,
200219
);

0 commit comments

Comments
 (0)