fix-polygon-null-blockNumber
🐛 Bug Fixes
Polygon pending transactions incorrectly marked as confirmed
Goal: Prevent Polygon transactions still pending on-chain from being marked as confirmed in the database, which caused proof records to appear valid while their transaction was never mined.
Solution: Add an explicit tx.blockNumber null check in PolygonService#verifyTransaction before calling getBlock(). Previously, getBlock(null) returned the latest block, and latestBlock - null + 1 coerced null to 0 in JavaScript arithmetic, producing a confirmations count larger than minConfirmations and bypassing the guard entirely.
Files Modified:
src/services/polygon/polygon.service.ts- Guardtx.blockNumberbeforegetBlock()and confirmation arithmetic
Polygon transactions dropped from mempool now marked as failed
Goal: Proofs whose Polygon transaction was permanently dropped from the mempool (not found on-chain) were left in pending forever, causing an infinite retry loop.
Solution: Introduce TransactionDroppedError thrown when provider.getTransaction() returns null. verifyProofs() now returns { verified, failed } and the caller marks failed proofs with status: 'failed' via the new generic DatabaseService.failProofs<PS>(). The WithStatus type is extended with 'failed'. OTS and Chainpoint can reuse failProofs() without any additional database changes.
Files Modified:
src/services/polygon/polygon.service.ts-TransactionDroppedErrorclass, updatedverifyProofs()return typesrc/database/database.service.ts- GenericfailProofs<PS extends ProofSystem>()methodsrc/database/database.types.ts-WithStatusextended with'failed'src/app.service.ts- Destructure{ verified, failed }fromverifyProofs(), callfailProofs()for dropped TXs