From 9aca72bda93f85a7a118bb0434dc6b360634328e Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Wed, 3 Jan 2024 14:56:47 -0500 Subject: [PATCH] dont override the commitment level --- platforms/solana/src/platform.ts | 6 ++---- platforms/solana/src/testing/sendSigner.ts | 11 ++++++++++- platforms/solana/src/testing/signer.ts | 5 +---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/platforms/solana/src/platform.ts b/platforms/solana/src/platform.ts index 1d28eab4a4..e950ca7ce5 100644 --- a/platforms/solana/src/platform.ts +++ b/platforms/solana/src/platform.ts @@ -209,13 +209,11 @@ export class SolanaPlatform extends PlatformContext< rpc: Connection, commitment?: Commitment, ): Promise<{ blockhash: string; lastValidBlockHeight: number }> { - // Use finalized to prevent blockhash not found errors - // Note: this may mean we have less time to submit transactions? - return rpc.getLatestBlockhash(commitment ?? 'finalized'); + return rpc.getLatestBlockhash(commitment ?? rpc.commitment); } static async getLatestBlock(rpc: Connection): Promise { - const { lastValidBlockHeight } = await this.latestBlock(rpc, 'confirmed'); + const { lastValidBlockHeight } = await this.latestBlock(rpc); return lastValidBlockHeight; } diff --git a/platforms/solana/src/testing/sendSigner.ts b/platforms/solana/src/testing/sendSigner.ts index bbcd9c45a8..d95c14ce5e 100644 --- a/platforms/solana/src/testing/sendSigner.ts +++ b/platforms/solana/src/testing/sendSigner.ts @@ -1,4 +1,5 @@ import { + ComputeBudgetProgram, Connection, Keypair, SendOptions, @@ -26,6 +27,7 @@ export class SolanaSendSigner< private _keypair: Keypair, private _debug: boolean = false, private _sendOpts?: SendOptions, + private _priotifyFeeAmount?: bigint, ) { this._sendOpts = this._sendOpts ?? { preflightCommitment: this._rpc.commitment, @@ -42,6 +44,7 @@ export class SolanaSendSigner< // Handles retrying a Transaction if the error is deemed to be // recoverable. Currently handles: + // - Transaction expired // - Blockhash not found // - Not enough bytes (storage account not seen yet) private retryable(e: any): boolean { @@ -75,7 +78,6 @@ export class SolanaSendSigner< async signAndSend(tx: UnsignedTransaction[]): Promise { let { blockhash, lastValidBlockHeight } = await SolanaPlatform.latestBlock( this._rpc, - 'finalized', ); const txids: string[] = []; @@ -86,6 +88,13 @@ export class SolanaSendSigner< } = txn as SolanaUnsignedTransaction; console.log(`Signing: ${description} for ${this.address()}`); + if (this._priotifyFeeAmount) + transaction.add( + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: this._priotifyFeeAmount, + }), + ); + if (this._debug) logTxDetails(transaction); // Try to send the transaction up to 5 times diff --git a/platforms/solana/src/testing/signer.ts b/platforms/solana/src/testing/signer.ts index fcc15fd266..ddca70694b 100644 --- a/platforms/solana/src/testing/signer.ts +++ b/platforms/solana/src/testing/signer.ts @@ -27,10 +27,7 @@ export class SolanaSigner } async sign(tx: UnsignedTransaction[]): Promise { - const { blockhash } = await SolanaPlatform.latestBlock( - this._rpc, - 'finalized', - ); + const { blockhash } = await SolanaPlatform.latestBlock(this._rpc); const signed = []; for (const txn of tx) {