Skip to content

Commit d31e27e

Browse files
committed
dont override the commitment level
1 parent 15ca3fc commit d31e27e

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

platforms/solana/src/platform.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,11 @@ export class SolanaPlatform<N extends Network> extends PlatformContext<
209209
rpc: Connection,
210210
commitment?: Commitment,
211211
): Promise<{ blockhash: string; lastValidBlockHeight: number }> {
212-
// Use finalized to prevent blockhash not found errors
213-
// Note: this may mean we have less time to submit transactions?
214-
return rpc.getLatestBlockhash(commitment ?? 'finalized');
212+
return rpc.getLatestBlockhash(commitment ?? rpc.commitment);
215213
}
216214

217215
static async getLatestBlock(rpc: Connection): Promise<number> {
218-
const { lastValidBlockHeight } = await this.latestBlock(rpc, 'confirmed');
216+
const { lastValidBlockHeight } = await this.latestBlock(rpc);
219217
return lastValidBlockHeight;
220218
}
221219

platforms/solana/src/testing/sendSigner.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
ComputeBudgetProgram,
23
Connection,
34
Keypair,
45
SendOptions,
@@ -26,6 +27,7 @@ export class SolanaSendSigner<
2627
private _keypair: Keypair,
2728
private _debug: boolean = false,
2829
private _sendOpts?: SendOptions,
30+
private _priotifyFeeAmount?: bigint,
2931
) {
3032
this._sendOpts = this._sendOpts ?? {
3133
preflightCommitment: this._rpc.commitment,
@@ -42,6 +44,7 @@ export class SolanaSendSigner<
4244

4345
// Handles retrying a Transaction if the error is deemed to be
4446
// recoverable. Currently handles:
47+
// - Transaction expired
4548
// - Blockhash not found
4649
// - Not enough bytes (storage account not seen yet)
4750
private retryable(e: any): boolean {
@@ -75,7 +78,6 @@ export class SolanaSendSigner<
7578
async signAndSend(tx: UnsignedTransaction[]): Promise<any[]> {
7679
let { blockhash, lastValidBlockHeight } = await SolanaPlatform.latestBlock(
7780
this._rpc,
78-
'finalized',
7981
);
8082

8183
const txids: string[] = [];
@@ -86,6 +88,13 @@ export class SolanaSendSigner<
8688
} = txn as SolanaUnsignedTransaction<N, C>;
8789
console.log(`Signing: ${description} for ${this.address()}`);
8890

91+
if (this._priotifyFeeAmount)
92+
transaction.add(
93+
ComputeBudgetProgram.setComputeUnitPrice({
94+
microLamports: this._priotifyFeeAmount,
95+
}),
96+
);
97+
8998
if (this._debug) logTxDetails(transaction);
9099

91100
// Try to send the transaction up to 5 times
@@ -103,9 +112,12 @@ export class SolanaSendSigner<
103112
} catch (e) {
104113
if (!this.retryable(e)) throw e;
105114

115+
// TODO: check that the previous one is expired before
116+
// re-signing
117+
106118
// If it is retryable, we should grab a new block hash
107119
({ blockhash, lastValidBlockHeight } =
108-
await SolanaPlatform.latestBlock(this._rpc, 'finalized'));
120+
await SolanaPlatform.latestBlock(this._rpc));
109121
}
110122
}
111123
}

platforms/solana/src/testing/signer.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ export class SolanaSigner<N extends Network, C extends SolanaChains = 'Solana'>
2727
}
2828

2929
async sign(tx: UnsignedTransaction[]): Promise<any[]> {
30-
const { blockhash } = await SolanaPlatform.latestBlock(
31-
this._rpc,
32-
'finalized',
33-
);
30+
const { blockhash } = await SolanaPlatform.latestBlock(this._rpc);
3431

3532
const signed = [];
3633
for (const txn of tx) {

0 commit comments

Comments
 (0)