From 98a64562b8e9cd99a380219237d8761fad900662 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:45:08 +0000 Subject: [PATCH 1/6] improve(relayer): Track transaction submission time In order to better understand transaction submission delays, monitor and report on the time required for transaction submission to occur on each chain. --- src/relayer/Relayer.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/relayer/Relayer.ts b/src/relayer/Relayer.ts index 1495c68ddf..e1a7a61089 100644 --- a/src/relayer/Relayer.ts +++ b/src/relayer/Relayer.ts @@ -846,8 +846,13 @@ export class Relayer { multiCallerClient.clearTransactionQueue(chainId); return []; } + + const chain = getNetworkName(chainId); + const profiler = this.profiler.start(`${chain} transaction submission.`); pendingTxnReceipts[chainId] = multiCallerClient.executeTxnQueue(chainId, simulate); const txnReceipts = await pendingTxnReceipts[chainId]; + profiler.stop({ message: `Completed ${chain} transaction submission.`, txnReceipts }); + delete pendingTxnReceipts[chainId]; return txnReceipts.map(({ hash }) => hash); From 649b699f1e74e22437253ba45414798115883b8f Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:54:40 +0000 Subject: [PATCH 2/6] Add nTxns --- src/relayer/Relayer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/relayer/Relayer.ts b/src/relayer/Relayer.ts index e1a7a61089..852f3c85f5 100644 --- a/src/relayer/Relayer.ts +++ b/src/relayer/Relayer.ts @@ -851,7 +851,7 @@ export class Relayer { const profiler = this.profiler.start(`${chain} transaction submission.`); pendingTxnReceipts[chainId] = multiCallerClient.executeTxnQueue(chainId, simulate); const txnReceipts = await pendingTxnReceipts[chainId]; - profiler.stop({ message: `Completed ${chain} transaction submission.`, txnReceipts }); + profiler.stop({ message: `Completed ${chain} transaction submission.`, nTxns: txnReceipts.length, txnReceipts }); delete pendingTxnReceipts[chainId]; From 79d8536dc590a31249f6c8873c385461cd8bd021 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:00:05 +0000 Subject: [PATCH 3/6] Relocate & refactor --- src/clients/TransactionClient.ts | 16 ++++++++++------ src/relayer/Relayer.ts | 5 ----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/clients/TransactionClient.ts b/src/clients/TransactionClient.ts index acfa06bcf8..1b73eb1112 100644 --- a/src/clients/TransactionClient.ts +++ b/src/clients/TransactionClient.ts @@ -95,6 +95,7 @@ export class TransactionClient { } let response: TransactionResponse; + const start = performance.now(); try { response = await this._submit(txn, nonce); } catch (error) { @@ -102,6 +103,7 @@ export class TransactionClient { at: "TransactionClient#submit", message: `Transaction ${idx + 1} submission on ${networkName} failed or timed out.`, mrkdwn, + duration: Math.round(performance.now() - start), // @dev `error` _sometimes_ doesn't decode correctly (especially on Polygon), so fish for the reason. errorMessage: isError(error) ? (error as Error).message : undefined, error: stringifyThrownValue(error), @@ -110,17 +112,19 @@ export class TransactionClient { return txnResponses; } - nonce = response.nonce + 1; const blockExplorer = blockExplorerLink(response.hash, txn.chainId); mrkdwn += ` ${idx + 1}. ${txn.message || "No message"} (${blockExplorer}): ${txn.mrkdwn || "No markdown"}\n`; + this.logger.info({ + at: "TransactionClient#submit", + message: `Completed ${networkName} transaction submission! 🧙`, + duration: Math.round(performance.now() - start), + mrkdwn, + }); + + nonce = response.nonce + 1; txnResponses.push(response); } - this.logger.info({ - at: "TransactionClient#submit", - message: `Completed ${networkName} transaction submission! 🧙`, - mrkdwn, - }); return txnResponses; } diff --git a/src/relayer/Relayer.ts b/src/relayer/Relayer.ts index 852f3c85f5..1495c68ddf 100644 --- a/src/relayer/Relayer.ts +++ b/src/relayer/Relayer.ts @@ -846,13 +846,8 @@ export class Relayer { multiCallerClient.clearTransactionQueue(chainId); return []; } - - const chain = getNetworkName(chainId); - const profiler = this.profiler.start(`${chain} transaction submission.`); pendingTxnReceipts[chainId] = multiCallerClient.executeTxnQueue(chainId, simulate); const txnReceipts = await pendingTxnReceipts[chainId]; - profiler.stop({ message: `Completed ${chain} transaction submission.`, nTxns: txnReceipts.length, txnReceipts }); - delete pendingTxnReceipts[chainId]; return txnReceipts.map(({ hash }) => hash); From 5ef5ee21ff5deff5ae7667be80d367f745e32dd7 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:02:16 +0000 Subject: [PATCH 4/6] datadog & reformatting --- src/clients/TransactionClient.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/clients/TransactionClient.ts b/src/clients/TransactionClient.ts index 1b73eb1112..520a233d19 100644 --- a/src/clients/TransactionClient.ts +++ b/src/clients/TransactionClient.ts @@ -59,7 +59,7 @@ export class TransactionClient { } async submit(chainId: number, txns: AugmentedTransaction[]): Promise { - const networkName = getNetworkName(chainId); + const chain = getNetworkName(chainId); const txnResponses: TransactionResponse[] = []; this.logger.debug({ @@ -101,13 +101,15 @@ export class TransactionClient { } catch (error) { this.logger.info({ at: "TransactionClient#submit", - message: `Transaction ${idx + 1} submission on ${networkName} failed or timed out.`, + message: `Transaction ${idx + 1} submission on ${chain} failed or timed out.`, mrkdwn, - duration: Math.round(performance.now() - start), // @dev `error` _sometimes_ doesn't decode correctly (especially on Polygon), so fish for the reason. errorMessage: isError(error) ? (error as Error).message : undefined, error: stringifyThrownValue(error), notificationPath: "across-error", + chain, + duration: Math.round(performance.now() - start), + datadog: true, }); return txnResponses; } @@ -116,9 +118,11 @@ export class TransactionClient { mrkdwn += ` ${idx + 1}. ${txn.message || "No message"} (${blockExplorer}): ${txn.mrkdwn || "No markdown"}\n`; this.logger.info({ at: "TransactionClient#submit", - message: `Completed ${networkName} transaction submission! 🧙`, - duration: Math.round(performance.now() - start), + message: `Completed ${chain} transaction submission! 🧙`, mrkdwn, + duration: Math.round(performance.now() - start), + chain, + datadog: true, }); nonce = response.nonce + 1; From dd2d6bdcb5ece35311b5156072096cd439834e47 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Fri, 14 Feb 2025 11:45:24 +0100 Subject: [PATCH 5/6] Update src/clients/TransactionClient.ts --- src/clients/TransactionClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/TransactionClient.ts b/src/clients/TransactionClient.ts index 520a233d19..d3b0a4fb68 100644 --- a/src/clients/TransactionClient.ts +++ b/src/clients/TransactionClient.ts @@ -125,8 +125,8 @@ export class TransactionClient { datadog: true, }); - nonce = response.nonce + 1; txnResponses.push(response); + nonce = response.nonce + 1; } From 105194ea37856b65b95865ac5fb5705d096b118b Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:27:19 +0000 Subject: [PATCH 6/6] lint --- src/clients/TransactionClient.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/clients/TransactionClient.ts b/src/clients/TransactionClient.ts index d3b0a4fb68..123c55de40 100644 --- a/src/clients/TransactionClient.ts +++ b/src/clients/TransactionClient.ts @@ -129,7 +129,6 @@ export class TransactionClient { nonce = response.nonce + 1; } - return txnResponses; } }