drift-labs/protocol-v2

Duplicate transaction sent in FastSingleTxSender and RetryTxSender

Opened this issue · 2 comments

FastSingleTxSender should send the transaction only once.

class FastSingleTxSender {
	async sendRawTransaction(
		rawTransaction: Buffer | Uint8Array,
		opts: ConfirmOptions
	): Promise<TxSigAndSlot> {
		let txid: TransactionSignature;
		try {
			txid = await this.connection.sendRawTransaction(rawTransaction, opts);
			this.sendToAdditionalConnections(rawTransaction, opts);
		} catch (e) {
			console.error(e);
			throw e;
		}

		this.connection.sendRawTransaction(rawTransaction, opts).catch((e) => {
			console.error(e);
		});
		this.sendToAdditionalConnections(rawTransaction, opts);
...
}

In RetryTxSender, there is no handling for This transaction has already been processed error, so it happens every time

SendTransactionError: failed to send transaction: Transaction simulation failed: This transaction has already been processed
    at Connection.sendEncodedTransaction (drift/js/node_modules/.pnpm/@solana+web3.js@1.90.0/node_modules/@solana/web3.js/src/connection.ts:5921:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Connection.sendRawTransaction (drift/js/node_modules/.pnpm/@solana+web3.js@1.90.0/node_modules/@solana/web3.js/src/connection.ts:5880:20) {
  logs: []
}

do you have a custom blockhashRefreshInterval set? i've noticed that happening when blockhash isn't updated frequently enough, we could increase the default

Hi, I noticed that if I use a RPC other than helium, it will happen. If I use helium, it's working fine