Skip to content

Commit d627a49

Browse files
authored
feat: add ending condition to proposer_server (#1430)
* Checkpoint * Checkpoint * Continue * Revert * Revert * Revert * Update proposer * Clean * Lint * nit * Refactor crank-executor * Small refactor * Go * Go * Move comment
1 parent 299dec1 commit d627a49

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

governance/xc_admin/packages/xc_admin_common/src/propose.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
3737
export const MAX_EXECUTOR_PAYLOAD_SIZE =
3838
PACKET_DATA_SIZE_WITH_ROOM_FOR_COMPUTE_BUDGET - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal
3939
export const MAX_INSTRUCTIONS_PER_PROPOSAL = 256 - 1;
40+
export const TIMEOUT = 10;
41+
export const MAX_RETRY_SEND = 70;
4042

4143
type SquadInstruction = {
4244
instruction: TransactionInstruction;
@@ -394,18 +396,25 @@ export class MultisigVault {
394396

395397
for (const [index, tx] of transactions.entries()) {
396398
console.log("Trying transaction: ", index, " of ", transactions.length);
397-
let retry = true;
398-
while (true)
399+
400+
let retries = 0;
401+
while (retries < TIMEOUT) {
399402
try {
400403
await sendTransactions(
401404
[{ tx, signers: [] }],
402405
provider.connection,
403-
this.squad.wallet as NodeWallet
406+
this.squad.wallet as NodeWallet,
407+
MAX_RETRY_SEND
404408
);
405409
break;
406410
} catch (e) {
407411
console.log(e);
412+
retries++;
408413
}
414+
}
415+
if (retries === TIMEOUT) {
416+
throw new Error("Too many retries");
417+
}
409418
}
410419
}
411420
}

target_chains/solana/sdk/js/solana_utils/src/transaction.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,18 @@ export async function sendTransactions(
370370
connection: Connection,
371371
wallet: Wallet,
372372
maxRetries?: number
373-
) {
373+
): Promise<string[]> {
374374
const blockhashResult = await connection.getLatestBlockhashAndContext({
375375
commitment: "confirmed",
376376
});
377377

378+
const signatures: string[] = [];
379+
378380
// Signing logic for versioned transactions is different from legacy transactions
379381
for (const transaction of transactions) {
380-
const { signers } = transaction;
382+
const signers = transaction.signers;
381383
let tx = transaction.tx;
384+
382385
if (isVersionedTransaction(tx)) {
383386
if (signers) {
384387
tx.sign(signers);
@@ -402,14 +405,14 @@ export async function sendTransactions(
402405
let confirmedTx = null;
403406
let retryCount = 0;
404407

405-
try {
406-
// Get the signature of the transaction with different logic for versioned transactions
407-
const txSignature = bs58.encode(
408-
isVersionedTransaction(tx)
409-
? tx.signatures?.[0] || new Uint8Array()
410-
: tx.signature ?? new Uint8Array()
411-
);
408+
// Get the signature of the transaction with different logic for versioned transactions
409+
const txSignature = bs58.encode(
410+
isVersionedTransaction(tx)
411+
? tx.signatures?.[0] || new Uint8Array()
412+
: tx.signature ?? new Uint8Array()
413+
);
412414

415+
try {
413416
const confirmTransactionPromise = connection.confirmTransaction(
414417
{
415418
signature: txSignature,
@@ -461,5 +464,9 @@ export async function sendTransactions(
461464
if (!confirmedTx) {
462465
throw new Error("Failed to land the transaction");
463466
}
467+
468+
signatures.push(txSignature);
464469
}
470+
471+
return signatures;
465472
}

0 commit comments

Comments
 (0)