Polygon Verification & RBF
Overview
Forge verifies Polygon proofs by checking on-chain transaction status and confirmation depth. Includes operational tooling for Replace-By-Fee (RBF) when transactions are stuck in the mempool, and New Relic observability for long-pending TX.
Verification flow
Status values on #verifyTransaction OTel span (bcyip:transaction.status):
| Status | Meaning |
|---|---|
pending | TX in mempool, no block yet |
confirming | Mined, waiting for minConfirmations |
confirmed | Enough confirmations |
dropped | TX gone from mempool |
Critical guards (1.0.0)
blockNumbernull check — never callgetBlock(null)(was returning latest block → false confirmed)TransactionDroppedError— mempool drop →status: failed, proof file cleanup- Pending is not an error —
#verifyTransactionreturnsnull, no NR error span
RBF replay API
Unsticks a Polygon transaction with insufficient gas by resubmitting with the same nonce and higher fee.
POST /polygon/replay
Authorization: Bearer <HMAC-rotating-token>
Content-Type: application/json
{ "txHash": "0x..." }
Auth: global AuthGuard — Bearer token is SHA-256 of Forge-{SEED}-{ceil(now/10s)} (current or previous 10s window). Same scheme as other Forge admin routes.
Response:
{
"newTxHash": "0x...",
"updatedProofs": 2
}
Server-side flow:
- Fetch original TX (nonce, data, gasLimit)
- Query Polygon Gas Station for
fastmax fee - Broadcast replacement TX (same nonce)
- Rewrite local proof files (
proofs/<uuid>) with new hash - Update MongoDB polygon proofs (
type: polygonfilter) atomically
New Relic alerting
NRQL for TX pending > 2 hours:
FROM Span SELECT count(*)
WHERE name = '#verifyTransaction'
AND bcyip.transaction.status = 'pending'
SINCE 2 hours ago
FACET bcyip:transaction.hash
Ops: Retool dashboard + manual RBF button calling POST /polygon/replay.
Configuration
| Env var | Role |
|---|---|
POLYGON_RCP_URL | JSON-RPC endpoint |
POLYGON_PRIVATE_KEY | Signing key for anchor/replay |
POLYGON_CONTRACT_ADDRESS | Anchor contract |
POLYGON_MIN_CONFIRMATIONS | Required confirmations |
SEED | HMAC auth seed |
Key files
src/services/polygon/polygon.service.ts— verify, replay, OTel attributessrc/app.service.ts—replayPolygon(),verifyPolygon()src/app.controller.ts—POST /polygon/replaysrc/database/database.service.ts—failProofs(), hash update helpersscripts/check-polygon-pending.mjs— audit script (repo)