Replay
Replay forks any qledger-v1 rollup on QoreChain testnet from its real L1 inbox, re-executes every settled batch, and tells you whether each state root reproduces. A batch that does not reproduce is one the chain would let anyone challenge while its window is open.
How to use it
| Where | How | Batches per run |
|---|---|---|
| Console | Pick a rollup (the list holds qledger-v1 rollups with at least one batch, largest first; veil-pay-1 is preselected) and run. /console?view=replay&rollup=<id> starts the run on load. Click a row to see both roots. | 400 (the console asks for max=400) |
GET /api/replay | NDJSON stream, one event per line: start, one batch per batch, skip, done or error. Parameters rollup, max, fresh=1 (HTTP API). | max, 1 to 400, default 200 |
npm run qorva:replay -- <id> | scripts/replay-rollup.mts prints one line per batch and exits 1 if any root diverges. Defaults to veil-pay-1. | 400 (the engine's default) |
qorva replay <id...> | The packaged CLI with exit codes, JSON and GitHub annotations (Rollup CI). | all, unless --max N |
Reading the output
| Column | Meaning |
|---|---|
INBOX (a,b] | The inbox sequence range the batch consumed. |
DEP XFER WD REJ | Deposits, transfers, withdrawals, and entries the qledger-v1 rules turn into no-ops (bad encoding or bad ML-DSA-44 signature). Counted by classify() in replay-engine.ts. |
RANGE | ok if the range hashes to the batch's on-chain dataHash, BAD if not, n/a if the batch carries no dataHash. |
RESULT | MATCH if the replayed root equals the settled root and the range is not BAD; DIVERGE otherwise. |
Real output from the CLI, run on 2026-11-30 (from packages/qorva-cli/README.md, middle rows trimmed):
Replaying veil-pay-1 on qorechain-diana qledger-v1, based sequencing, 8 batches, creator qor1a5j8wjpxpqc6f7htyv92042nrt7gaegpezdhx4
BATCH INBOX ENTRIES DEP XFER WD REJ RANGE RESULT REPLAYED STATE ROOT
#0 (0,3] 3 1 1 0 1 ok MATCH 0x03a597edc1…8c32742e
#3 (5,11] 6 0 1 0 5 ok MATCH 0x658b7a896f…7b7cd8bb
#7 (19,21] 2 0 1 0 1 ok MATCH 0xf249de7967…b0a33e08
PASS veil-pay-1: 8/8 state roots reproduce, 0 diverge, 0 inbox mismatches, 0 skipped (0.8 s)How it is built
Everything lives in src/lib/replay-engine.ts, which the console, the API, the network board, the PQC hygiene score, the debugger, the watchtower module, the testnet sequencer and the CLI all import.
fetchWholeInbox(rest, rollupId)runs twosearchTxsqueries withmaxPages: 1000(up to 100,000 transactions each at the SDK's 100 per page; the SDK default is 50 pages). It flattens authzMsgExecrecursively and matches eachMsgPostRollupDatapayload to itsrdk_data_postedevent bypostedDataHashand poster. Deposits are re-encoded withencodeQledgerDeposit.replayRollup(rollupId, emit, { maxBatches })refuses non-qledger-v1 rollups, sorts batches, then for each one folds the accumulator, computesinboxRangeHash, runsexecuteQledgerand emits abatchevent with timings.- On an inbox gap or a missing inbox entry it emits
skipwith the reason and stops: later batches cannot be replayed from genesis without it. - The final ledger is kept in server memory as a fork (
getFork); the testnet sequencer uses it as the parent state of its next batch.
Why Qorva has its own inbox reader
While building Replay we found two problems in the SDK's fetchQledgerEntries (@qorechain/rdk 0.9.0). Both reproduce on the live testnet, and the drafts with repro scripts are in docs/upstream/ (not filed yet):
- Posts wrapped in authz MsgExec are not matched.
wicketgate-payinbox entry 43 makes the SDK throw "payload could not be matched"; withMsgExecflattened, all 76 batch ranges then on chain hashed to theirdataHash. - Old ranges cannot be re-read once the posted-data record is pruned (648,000 blocks on testnet).
veil-pay-1batch 0 fails with "the chain no longer holds the accumulator at 3". Checking each range against the batch's owndataHashkeeps old batches verifiable.