-
Notifications
You must be signed in to change notification settings - Fork 252
chore: find reverted gmp transactions in live mode #12311
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
Merged
+782
−979
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d7fdf80
chore: remove scanning axelarscan and support for MULTICALL_EXECUTED
rabi-siddique ac7093b
chore: listen for reverted gmp transactions via alchemy_minedTransact…
rabi-siddique 349be8f
test: add tests for revert cases
rabi-siddique 4e94d28
chore: extract receipt fetching and tx simulation to helper functions
rabi-siddique a38134c
refactor: rename WatcherResult.found to settled
rabi-siddique 32fd37a
chore: validate sourceAddress to filter spurious executions
rabi-siddique 3dd08bf
fix: distinguish successful and reverted GMP transactions
rabi-siddique 997315d
chore: remove axelarscan-utils.ts and @axelarjs/api
rabi-siddique File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,11 +28,7 @@ import type { | |
| UsdcAddresses, | ||
| } from './support.ts'; | ||
| import { lookBackCctp, watchCctpTransfer } from './watchers/cctp-watcher.ts'; | ||
| import { | ||
| lookBackGmp, | ||
| WATCH_GMP_ABORTED, | ||
| watchGmp, | ||
| } from './watchers/gmp-watcher.ts'; | ||
| import { lookBackGmp, watchGmp } from './watchers/gmp-watcher.ts'; | ||
| import { | ||
| watchSmartWalletTx, | ||
| lookBackSmartWalletTx, | ||
|
|
@@ -42,7 +38,8 @@ import type { YdsNotifier } from './yds-notifier.ts'; | |
| export type EvmChain = keyof typeof AxelarChain; | ||
|
|
||
| export type WatcherResult = { | ||
| found: boolean; | ||
| settled: boolean; | ||
| success?: boolean; | ||
| txHash?: string; | ||
| }; | ||
|
|
||
|
|
@@ -152,7 +149,7 @@ const cctpMonitor: PendingTxMonitor<CctpTx, EvmContext> = { | |
| txId, | ||
| }); | ||
| void liveResultP.then(result => { | ||
| if (result.found) { | ||
| if (result.settled) { | ||
| log(`${logPrefix} Live mode completed`); | ||
| abortController.abort(); | ||
| } | ||
|
|
@@ -173,7 +170,7 @@ const cctpMonitor: PendingTxMonitor<CctpTx, EvmContext> = { | |
| txId, | ||
| }); | ||
|
|
||
| if (transferResult.found) { | ||
| if (transferResult.settled) { | ||
| // Found in lookback, cancel live mode | ||
| const reason = `${logPrefix} Lookback found transaction`; | ||
| log(reason); | ||
|
|
@@ -191,11 +188,13 @@ const cctpMonitor: PendingTxMonitor<CctpTx, EvmContext> = { | |
| return; | ||
| } | ||
|
|
||
| await resolvePendingTx({ | ||
| signingSmartWalletKit: ctx.signingSmartWalletKit, | ||
| txId, | ||
| status: transferResult?.found ? TxStatus.SUCCESS : TxStatus.FAILED, | ||
| }); | ||
| transferResult.settled && | ||
| (await resolvePendingTx({ | ||
| signingSmartWalletKit: ctx.signingSmartWalletKit, | ||
| txId, | ||
| status: | ||
| transferResult.success !== false ? TxStatus.SUCCESS : TxStatus.FAILED, | ||
| })); | ||
|
|
||
| if (transferResult?.txHash) { | ||
| await ctx.ydsNotifier?.notifySettlement(txId, transferResult.txHash); | ||
|
|
@@ -209,7 +208,7 @@ const gmpMonitor: PendingTxMonitor<GmpTx, EvmContext> = { | |
| watch: async (ctx, tx, log, opts) => { | ||
| await null; | ||
|
|
||
| const { txId, destinationAddress } = tx; | ||
| const { txId, destinationAddress, sourceAddress } = tx; | ||
| const logPrefix = `[${txId}]`; | ||
|
|
||
| if (opts.signal?.aborted) { | ||
|
|
@@ -219,6 +218,8 @@ const gmpMonitor: PendingTxMonitor<GmpTx, EvmContext> = { | |
|
|
||
| // Parse destinationAddress format: 'eip155:42161:0x126cf3AC9ea12794Ff50f56727C7C66E26D9C092' | ||
| assert(destinationAddress, `${logPrefix} Missing destinationAddress`); | ||
| assert(sourceAddress, `${logPrefix} Missing sourceAddress`); | ||
|
|
||
| const { namespace, reference, accountAddress } = | ||
| parseAccountId(destinationAddress); | ||
| const caipId: CaipChainId = `${namespace}:${reference}`; | ||
|
|
@@ -227,10 +228,14 @@ const gmpMonitor: PendingTxMonitor<GmpTx, EvmContext> = { | |
|
|
||
| const provider = ctx.evmProviders[caipId] as WebSocketProvider; | ||
|
|
||
| // Extract the address portion from sourceAddress (format: 'cosmos:agoric-3:agoric1...') | ||
| const lcaAddress = parseAccountId(sourceAddress).accountAddress; | ||
|
|
||
| const watchArgs = { | ||
| provider, | ||
| contractAddress: accountAddress as `0x${string}`, | ||
| txId, | ||
| expectedSourceAddress: lcaAddress, | ||
| log: (msg, ...args) => log(`${logPrefix} ${msg}`, ...args), | ||
| }; | ||
|
|
||
|
|
@@ -243,8 +248,6 @@ const gmpMonitor: PendingTxMonitor<GmpTx, EvmContext> = { | |
| signal: opts.signal, | ||
| kvStore: ctx.kvStore, | ||
| makeAbortController: ctx.makeAbortController, | ||
| axelarApiUrl: ctx.axelarApiUrl, | ||
| fetch: ctx.fetch, | ||
| }); | ||
| } else { | ||
| // Lookback mode with concurrent live watching | ||
|
|
@@ -260,31 +263,18 @@ const gmpMonitor: PendingTxMonitor<GmpTx, EvmContext> = { | |
| signal: abortController.signal, | ||
| kvStore: ctx.kvStore, | ||
| makeAbortController: ctx.makeAbortController, | ||
| axelarApiUrl: ctx.axelarApiUrl, | ||
| fetch: ctx.fetch, | ||
| }); | ||
|
|
||
| // Attach handler to abort lookback if live mode completes first with | ||
| // a definitive result. This handler does NOT resolve the transaction - | ||
| // resolution happens once at the end to prevent duplicate resolutions. | ||
| void liveResultP | ||
| .then(result => { | ||
| // Abort lookback only if live mode has a definitive answer: | ||
| // - Transaction found successfully (result.found === true) | ||
| // - Transaction found but failed (result.rejectionReason present) | ||
| // If neither (just timed out), let lookback continue - it might find it. | ||
| if (result.found || result.rejectionReason) { | ||
| const reason = `${logPrefix} Live mode completed`; | ||
| log(reason); | ||
| abortController.abort(reason); | ||
| } | ||
| }) | ||
| .catch(error => { | ||
| // If lookback aborted live mode, no action needed | ||
| if (error !== WATCH_GMP_ABORTED) { | ||
| throw error; | ||
| } | ||
| }); | ||
| void liveResultP.then(result => { | ||
| if (result.settled) { | ||
| const reason = `${logPrefix} Live mode completed`; | ||
| log(reason); | ||
| abortController.abort(reason); | ||
| } | ||
|
Comment on lines
+272
to
+276
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about handling tx not |
||
| }); | ||
|
|
||
| await null; | ||
| // Wait for at least one block to ensure overlap between lookback and live mode | ||
|
|
@@ -302,7 +292,7 @@ const gmpMonitor: PendingTxMonitor<GmpTx, EvmContext> = { | |
| }); | ||
|
|
||
| // Determine which result to use based on what completed successfully | ||
| if (lookBackResult.found) { | ||
| if (lookBackResult.settled) { | ||
| // Found in lookback, cancel live mode | ||
| transferResult = lookBackResult; | ||
| const reason = `${logPrefix} Lookback found transaction`; | ||
|
|
@@ -321,14 +311,13 @@ const gmpMonitor: PendingTxMonitor<GmpTx, EvmContext> = { | |
| return; | ||
| } | ||
|
|
||
| await resolvePendingTx({ | ||
| signingSmartWalletKit: ctx.signingSmartWalletKit, | ||
| txId, | ||
| status: transferResult?.found ? TxStatus.SUCCESS : TxStatus.FAILED, | ||
| ...(transferResult?.rejectionReason | ||
| ? { rejectionReason: transferResult.rejectionReason } | ||
| : {}), | ||
| }); | ||
| transferResult.settled && | ||
| (await resolvePendingTx({ | ||
| signingSmartWalletKit: ctx.signingSmartWalletKit, | ||
| txId, | ||
| status: | ||
| transferResult.success !== false ? TxStatus.SUCCESS : TxStatus.FAILED, | ||
| })); | ||
|
|
||
| if (transferResult?.txHash) { | ||
| await ctx.ydsNotifier?.notifySettlement(txId, transferResult.txHash); | ||
|
|
@@ -396,7 +385,7 @@ const makeAccountMonitor: PendingTxMonitor<MakeAccountTx, EvmContext> = { | |
| txId, | ||
| }); | ||
| void liveResultP.then(result => { | ||
| if (result.found) { | ||
| if (result.settled) { | ||
| log(`${logPrefix} Live mode completed`); | ||
| abortController.abort(); | ||
| } | ||
|
|
@@ -416,7 +405,7 @@ const makeAccountMonitor: PendingTxMonitor<MakeAccountTx, EvmContext> = { | |
| signal: abortController.signal, | ||
| }); | ||
|
|
||
| if (walletResult.found) { | ||
| if (walletResult.settled) { | ||
| log(`${logPrefix} Lookback found wallet creation`); | ||
| abortController.abort(); | ||
| } else { | ||
|
|
@@ -431,11 +420,13 @@ const makeAccountMonitor: PendingTxMonitor<MakeAccountTx, EvmContext> = { | |
| return; | ||
| } | ||
|
|
||
| await resolvePendingTx({ | ||
| signingSmartWalletKit: ctx.signingSmartWalletKit, | ||
| txId, | ||
| status: walletResult?.found ? TxStatus.SUCCESS : TxStatus.FAILED, | ||
| }); | ||
| walletResult.settled && | ||
| (await resolvePendingTx({ | ||
| signingSmartWalletKit: ctx.signingSmartWalletKit, | ||
| txId, | ||
| status: | ||
| walletResult.success !== false ? TxStatus.SUCCESS : TxStatus.FAILED, | ||
| })); | ||
|
|
||
| if (walletResult?.txHash) { | ||
| await ctx.ydsNotifier?.notifySettlement(txId, walletResult.txHash); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.