Repository navigation
Conversation
…nfirmed or orphaned
- Confirm txs with upsertTransaction (via a persistChronikTransaction helper shared with syncBlockTransactions) instead of a raw updateMany, so prices, caches and payment summaries follow the tx to its block timestamp, and mark the client payments it pays as CONFIRMED, as the TX_CONFIRMED handler does. - Move the chronik lookup into ChronikBlockchainClient.recheckUnconfirmedTransaction, which returns confirmed / orphaned / unconfirmed; MultiBlockchainClient waits for startup and rejects unknown networks. - Add isChronikTxNotFoundError: the old /not found in the index|404/ match also hit any error for a txid containing "404" and would have orphaned it. Use it in the TX_CONFIRMED handler too. - Fetch one entry per tx (hash, network, first seen), oldest first, at most UNCONFIRMED_TX_CHECK_MAX_PER_RUN per run and only txs older than UNCONFIRMED_TX_CHECK_MIN_AGE_SECONDS, instead of every row of the last week: a backlog is worked through over several runs and older stuck txs are no longer skipped forever. Lookups stay sequential. - Replace the confirmed-only index with (confirmed, orphaned, timestamp), which serves the job's query and order, in a migration dated after master's latest. - Unit tests for the job, the chronik recheck, the not-found matcher and the DB query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019G564i2sNiHJYQR95m8zGq
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 56 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to #889
Description
Adds a periodic job (every 30 minutes) that rechecks txs stored as unconfirmed, so they end up either confirmed or orphaned even when the chronik websocket missed the
TX_CONFIRMED/TX_REMOVED_FROM_MEMPOOLmessage (disconnects, restarts, etc.).For each tx it looks the txid up on chronik:
upsertTransaction), soconfirmedand the timestamp (moved to the block's) are updated together with prices, caches and payment summaries, the tx is broadcast, and the client payments it pays are markedCONFIRMED;orphaned, as master'sTX_CONFIRMEDhandler already does;This is #1102 (by Klakurka) rebased onto
master, with his two commits kept as they were (conflicts resolved against the newer job infra), plus a follow-up commit that:upsertTransactioninstead of a rawupdateMany, which left caches and payment summaries pointing at the old (first-seen) timestamp;ChronikBlockchainClient.recheckUnconfirmedTransaction(shares apersistChronikTransactionhelper withsyncBlockTransactions);isChronikTxNotFoundError: the previous/not found in the index|404/check matched any error whose message contained a txid with404in it (e.g. a 500 for/tx/ab404…) and would have orphaned that tx. TheTX_CONFIRMEDhandler uses it too now;confirmed-only index with(confirmed, orphaned, timestamp), which matches the job's filter and order, in a migration dated after master's latest one.Test plan
make github-test-unit: 19 suites, 420 tests pass. New tests cover:verifyUnconfirmedTransactions: cutoff and cap passed to the query, each tx rechecked on its own network one at a time, outcomes counted, a failed lookup doesn't stop the run, warning for txs over a day in the mempool;recheckUnconfirmedTransaction: confirmed (upserted, client payments confirmed), still in mempool (untouched), not found (orphaned), other chronik errors (thrown, untouched);MultiBlockchainClientroutes by network;isChronikTxNotFoundError, including txids containing404;TX_CONFIRMEDorphaning only on a real not-found;fetchUnconfirmedTransactionsToRecheckquery and per-tx dedupe.prisma migrate diffbetween master's schema and this one produces exactly the SQL in the new migration.tsc --noEmit: no new errors in the changed files (only the pre-existingredisBullMQ/Decimalones).confirmed = falsewith a timestamp over 30 minutes old and wait for the next run (or lowerUNCONFIRMED_TX_CHECK_INTERVAL); it should be confirmed again at its block timestamp. A made-up txid should be marked orphaned.Remarks
master(fix: Make sure txs are eventually marked as confirmed or orphaned #1102 targetsfeat/orphaned-transactions, whose orphaned column is already on master). If this one is preferred, fix: Make sure txs are eventually marked as confirmed or orphaned #1102 can be closed.Transaction, which is a large table; MySQL builds it in place, but it may take a while on deploy.TX_REMOVED_FROM_MEMPOOLstill deletes the unconfirmed rows, while a not-found on recheck (or onTX_CONFIRMED) marks them orphaned; this keeps master's existing behavior for each path.orphanedisn't read by any query yet, so orphaned txs still show up wherever unconfirmed txs do.Generated by Claude Code