Skip to main content

Polygon RBF, Verification Hardening, and NR Alerting

Version: 1.0.0 Date: 2026-07-15

Goal: Operate Polygon proofs reliably in production — correct verification states, recover stuck mempool TX via RBF, and alert on long-pending transactions in New Relic.

New feature — RBF replay

Solution: POST /polygon/replay fetches the original TX, queries Polygon Gas Station for fast fee, resubmits with same nonce (Replace-By-Fee). Protected by global HMAC AuthGuard.

Request:

{ "txHash": "0xabc..." }

Response:

{ "newTxHash": "0xdef...", "updatedProofs": 2 }

Post-replay consistency:

  • Rewrite local proof files with new transactionHash
  • Update MongoDB polygon proof records (type: polygon filter)
  • OTel span Replay-polygon with bcyip:transaction.replay.newHash

Bug fixes — verification

False confirmed (null blockNumber):

  • Guard tx.blockNumber before getBlock()getBlock(null) returned latest block; null coerced to 0 in arithmetic → bypassed minConfirmations

Dropped mempool TX:

  • TransactionDroppedError when getTransaction() returns null
  • verifyProofs() returns { verified, failed }; caller runs failProofs() + polygonService.cleanup()

New Relic false positives:

  • Pending TX: return null, do not triggerSpanError
  • Dropped TX: transaction.dropped span event, not error
  • Guard undefined transactionHash (no 0xundefined RPC)

Improvement — OTel for alerting

Attributes on #verifyTransaction span:

  • bcyip:transaction.statuspending | confirming | confirmed | dropped
  • bcyip:transaction.hash

NRQL (pending > 2h):

FROM Span SELECT count(*)
WHERE name = '#verifyTransaction'
AND bcyip.transaction.status = 'pending'
SINCE 2 hours ago
FACET bcyip:transaction.hash

Files Modified:

  • src/services/polygon/polygon.service.ts - RBF, verification, OTel attributes
  • src/database/database.service.ts - getPolygonPendingProofsByTxHash(), updatePolygonTransactionHash(), failProofs()
  • src/database/database.types.ts - ForgeTask.REPLAY, WithStatus + failed
  • src/app.service.ts - replayPolygon(), verify cleanup
  • src/app.controller.ts - POST /polygon/replay

Release fragment: feat-polygon-rbf-monitoring