Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(relayer): Track transaction submission time #2093

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/clients/TransactionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class TransactionClient {
}

async submit(chainId: number, txns: AugmentedTransaction[]): Promise<TransactionResponse[]> {
const networkName = getNetworkName(chainId);
const chain = getNetworkName(chainId);
const txnResponses: TransactionResponse[] = [];

this.logger.debug({
Expand Down Expand Up @@ -95,32 +95,40 @@ export class TransactionClient {
}

let response: TransactionResponse;
const start = performance.now();
try {
response = await this._submit(txn, nonce);
} 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,
// @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;
}

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 ${chain} transaction submission! 🧙`,
mrkdwn,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mrkdwn should be set on each loop, rather than being appended-to.

Copy link
Contributor

@bmzig bmzig Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm misunderstanding this, but won't this log just be emitted for every transaction we submit? So if we have two transactions: [txn1, txn2] then this will log twice, the first log being:

completed [chain] transaction submission
... txn1 details

on the first iteration of the loop and then

completed [chain] transaction submission
... txn1 details
... txn2 details

on the second iteration? (Since we are still doing mkdwn +=)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly - this is not what we want. I left the comment to earmark the change but haven't implemented it yet 👍

duration: Math.round(performance.now() - start),
chain,
datadog: true,
});

nonce = response.nonce + 1;
txnResponses.push(response);
}

this.logger.info({
at: "TransactionClient#submit",
message: `Completed ${networkName} transaction submission! 🧙`,
mrkdwn,
});

return txnResponses;
}
Expand Down