Skip to content

Commit

Permalink
Fix solana compute budget limit
Browse files Browse the repository at this point in the history
  • Loading branch information
DogLooksGood committed Oct 10, 2023
1 parent 508e4a7 commit 6e2e175
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions js/sdk-core/src/app-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ export class AppClient {
await this.#client.attachGame();
const sub = this.#connection.subscribeEvents();
const gameAccount = await this.__getGameAccount();
const gameContext = new GameContext(gameAccount);
gameContext.applyCheckpoint(gameContext.checkpointAccessVersion, gameContext.settleVersion);
this.#gameContext = new GameContext(gameAccount);
this.#gameContext.applyCheckpoint(gameAccount.checkpointAccessVersion, this.#gameContext.settleVersion);
await this.#connection.connect(new SubscribeEventParams({ settleVersion: this.#gameContext.settleVersion }));
await this.__initializeState(gameAccount);

Expand Down Expand Up @@ -320,7 +320,7 @@ export class AppClient {
try {
const gameAccount = await this.__getGameAccount();
this.#gameContext = new GameContext(gameAccount);
gameContext.applyCheckpoint(gameAccount.checkpointAccessVersion, this.#gameContext.settleVersion);
this.#gameContext.applyCheckpoint(gameAccount.checkpointAccessVersion, this.#gameContext.settleVersion);
await this.#connection.connect(new SubscribeEventParams({ settleVersion: this.#gameContext.settleVersion }));
await this.__initializeState(gameAccount);
} finally {
Expand Down
5 changes: 4 additions & 1 deletion transport/src/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use solana_sdk::signature::Keypair;
use solana_sdk::signer::Signer;
use solana_sdk::system_instruction::{self, create_account_with_seed, transfer};
use solana_sdk::transaction::Transaction;
use solana_sdk::compute_budget::ComputeBudgetInstruction;
use solana_sdk::{commitment_config::CommitmentConfig, program_pack::Pack};
use solana_sdk::{
hash::Hash,
Expand Down Expand Up @@ -580,9 +581,11 @@ impl TransportT for SolanaTransport {

info!("Solana transport send settlement: {:?}", params);

let set_cu_limit_ix = ComputeBudgetInstruction::set_compute_unit_limit(1200000);

let settle_ix = Instruction::new_with_borsh(self.program_id.clone(), &params, accounts);

let message = Message::new(&[settle_ix], Some(&payer.pubkey()));
let message = Message::new(&[set_cu_limit_ix, settle_ix], Some(&payer.pubkey()));
let mut tx = Transaction::new_unsigned(message);
let blockhash = self.get_blockhash()?;
tx.sign(&[payer], blockhash);
Expand Down

0 comments on commit 6e2e175

Please sign in to comment.