Components

What was built between 5 June and 18 November 2026: 1,067 commits, ~276,000 lines of Rust, and 4,212 tests.

1,067commits in the window
276klines of Rust
4,212tests
14components with no rskj counterpart

The organising constraint

Rustock must agree with rskj bit for bit, because a disagreement is a chain fork rather than a bug. That is why so many of these components are either a port of a specific rskj class or an instrument for proving equivalence with one.

Components marked extended existed in outline before this window; the rest are new. Components marked rustock-only have no rskj counterpart at all. If you know rskj and want the file that answers to a class you already know, the rskj → rustock map pairs the two codebases package by package.

The parts that exist only here

Several components are not ports of anything. They exist because Rustock is a second implementation and has to prove it agrees with the first — and a few of them are simply things rskj never needed to build.

Supply conservation

Per block and per transaction, a check that execution did not create rBTC from nothing. The worst failure this node could have, and otherwise invisible: state roots would agree with an rskj carrying the same bug.

No rskj equivalent

Whole-chain replay

Re-executes all of mainnet block by block, comparing each state root against the header. Turns "we believe this matches rskj" into a measurement.

No rskj equivalent

Coherence invariants

Eight stated relations over the node's position markers, checked after every commit — and four of them now repaired automatically rather than only reported.

No rskj equivalent

The Φ progress watchdog

A progress measure with an escalation ladder, for the node that believes it is syncing and is not.

No rskj equivalent

Block pruning

rskj keeps every block forever. Rustock can delete headers, bodies, receipts and index entries below a retention floor.

No rskj equivalent

rskj database import

Reads a running rskj node's RocksDB and converts it to Rustock's layout — the reason every other component could be tested against real mainnet data rather than fixtures.

No rskj equivalent

Segmented trie tooling

Splits the trie into self-contained chunks that can be distributed and read independently, with tooling to build, verify and repair them.

No rskj equivalent

Bridge event index

Peg activity queryable by height and type, rather than by re-scanning every receipt in the chain.

No rskj equivalent

Read-only diagnostics

Seventy-one command-line tools, most of which open the database with no lock and no WAL replay — so they can be pointed at a production store while it is running, or wedged.

No rskj equivalent

Foundations

rskj database import rustock-only

Reads a running rskj node's RocksDB — unitrie state, blocks, receipts — and converts it into Rustock's own column-family layout, resuming if interrupted.

Without it a new node would have to execute 9.2 million blocks from genesis before it could do anything. With it, the node starts from mainnet state, which is what made every other component testable against real data rather than fixtures.

Whole-chain replay rustock-only

Re-executes the entire mainnet history block by block and compares each resulting state root against the one in the header.

This is the instrument the rest of the work depends on. It does not add a feature; it turns "we believe this matches rskj" into a measurement, and it found consensus bugs in the Bridge that no unit test would have — including ones where Rustock and rskj agreed for millions of blocks and then diverged at a single transaction.

Consensus

The two-way peg — Bridge precompile extended

The contract at 0x…01000006 that moves BTC to and from RSK: peg-in registration with partial Merkle proofs, peg-out queueing and BTC transaction building, federation governance and migration, the BTC header chain, the lock whitelist, locking cap, and the fee market for peg-outs.

It is the largest and most consensus-critical component, and the one where rskj's behaviour is least like anything documented — bitcoinj byte orders, Java HashMap iteration order deciding which peg-out is paid, and a dozen frozen bugs that have to be reproduced exactly because the chain's history depends on them.

All 70 methods in the table now have a dispatch arm. Twenty-two of them used to fall through a catch-all that answered with empty bytes — which decodes as zero, or as the empty string, rather than failing. A federator client asking getStateForBtcReleaseClient got a plausible-looking nothing. A test over the dispatch source now fails when a row is added without an arm, so "unimplemented" has to be written down rather than left as a silent gap.

The union bridge extended

Seven further Bridge methods, enabled at reed810 (RSKIP-502). A selector the Bridge does not know fails in exactly the way a malformed call does, so the gap never named itself: testnet #7,625,612 looked like a wrong status flag and #7,629,709 like a transaction burning twice the block's gas. Both were this.

Two details decided it and neither is in the RSKIPs, so both were read off the chain. The union cells are keyed by keccak of the name, where the older Bridge cells right-align the ASCII — and every value is RLP, so a boolean false is the empty string rather than a zero byte. Read raw, the stored contract address yields nothing, the address falls back to the zero constant, and every authorized call is then rejected as unauthorized.

Authorization is also checked against the immediate caller rather than the transaction sender. It has to be: a contract never originates a transaction, so an authorization keyed to the sender would leave the union bridge contract unable to authorize itself.

RSKIP-529's base and super events arrived later, in the rskj-parity work.

Merged mining

Builds block templates, serves the mnr_* RPC that mining software speaks, validates and imports submitted solutions, selects uncles, and handles the Bitcoin coinbase, Merkle proof and RSKIP110 fork-detection data.

Without it the node can follow the chain but never contribute to it. Merged mining is how RSK inherits Bitcoin's hashpower, so this is the difference between an observer and a participant.

Block validity rules

The eight rules rskj applies to every incoming block before executing it — transaction gas-price bounds, the REMASC transaction, uncle constraints, extra-data limits, fork-detection data — that Rustock did not have.

These are the rules that reject a block. Whole-chain replay cannot exercise them, because mainnet contains no invalid block: the only way to have them is to write them from rskj's source and test them directly.

Versioned block headers (RSKIP-351)

A V1 or V2 header carries a compressed RLP([version, hash]) in its logs-bloom slot, and that hash commits to an extension body Rustock parsed but had no model of. Translated from rskj's BlockHeaderExtension hierarchy, with three byte-level decisions pinned by tests rather than left to the reader: the hash commits to keccak256(logs_bloom) and not to the bloom, which is what lets a peer verify a header without being sent 256 bytes; V2 inserts its base event before V1's edges, because the subclass adds its own field and then calls super; and the edges are packed little-endian before being RLP-encoded, where RLP is big-endian everywhere else.

Transaction sublists (RSKIP-144)

A Rootstock block can be partitioned into sublists intended for parallel execution, and the header's txExecutionSublistsEdges say where each one ends. A miner chooses those edges, so consensus has to bound them: an edge past the end of the transaction list, or out of order, partitions a block in a way no other node reproduces. Ported from rskj's ValidTxExecutionSublistsEdgesRule with its twelve-case test suite.

The bound itself is the first place the specification and the implementation disagree. RSKIP-144 specifies four execution threads; rskj's constant is two. Rustock follows the code, because three edges is precisely the case where the document's reading accepts a block rskj rejects.

The other half is receipts. A split block accumulates cumulativeGasUsed per sublist rather than across the block — a rule that appears in no RSKIP at all. Testnet #7,690,876 is where it surfaced, and it surfaced cleanly: the state root matched exactly and the receipts root did not. It is also a lesson about activation heights. RSKIP-144 turns on at reed810, but the edges field is emitted empty on every header from there until #7,690,876 — so 100,002 verified blocks had the rule enabled and not one of them exercised it. "Above the activation height" and "uses the feature" are different ranges.

Two further consensus conditions followed. A key in one sublist's write set and another's read or write set invalidates the block — read against read is fine, because only a write makes an ordering observable. That is a rule a validator applies, not one it may assume the miner established: where sublists conflict, the sequential interleaving is the parallel result sometimes and not others, so two clients would agree by luck. And rskj bars REMASC and Bridge calls from a parallel sublist outright, failing the sublist and so the block; reaching the precompile is what counts, not what came of the call, so a Bridge call that reverts still bars the transaction.

Parallel execution

The sublists now run on their own threads. run_sublist executes one contiguous run of a block's transactions in the block's own transaction indices rather than sublist-relative ones — the Bridge reads the index, the tracer selects on it and the collision tracker attributes by it, so a rebased index would be wrong in three places at once.

Each sublist's changes go into the trie as that sublist's own commit, in sublist order. The trie is the merge, which is what rskj does and what makes the sequential sublist's starting state well defined — there is no reconciliation of several journals into one, which is where this would otherwise have become delicate.

What made the sublists mergeable at all was moving the gas fee. Under RSKIP-144 rskj postpones it and credits the block's whole total to REMASC immediately before the REMASC transaction runs. Crediting per transaction instead has every sublist writing REMASC's account cell, and those writes would have to be summed rather than merged. The end state is identical either way; what differs is what an earlier transaction sees if it reads REMASC's balance, and that is consensus.

How it is verified. 3,812 block verifications on testnet, six ranges spanning the chain from the reed810 activation to the head, each replayed at one thread and at two, every block compared against rskj's own state rather than against the other thread count — a shared mistake would agree with itself. Zero divergences. Plus a block whose sublists share a sender, the race the rule exists to forbid, caught as a write-write collision when the sublists really do run apart.

--execution-threads defaults to 1 and is clamped at 2, because rskj's TX_EXECUTION_THREADS caps a block at two parallel sublists. Sender recovery was moved onto the same scheduler and onto libsecp256k1 — 247.9µs to 58.8µs per recovery, measured over three hundred real mainnet transactions — but it stays on the calling thread below sixteen transactions, which is every block mainnet currently produces.

The miner side

A port of rskj's ParallelizeTransactionHandler. The partition a miner chooses is not consensus — a validator only checks that the sublists do not collide — but matching it means Rustock's blocks are partitioned the way the network's other miner would partition them, and it means rskj's own tests can be the oracle.

The template builder used to emit no partition at all, so nothing Rustock mined could ever run in parallel. It now executes the selected transactions once, learns what each touched, places them with the ported partitioner and rebuilds the block in sublist order. rskj reorders its receipts from that single pass rather than re-executing, relying on a collision-free partition reaching the same state either way — which is true, and is exactly the theorem the validator exists to check rather than assume, so the block that gets published is the one that was executed.

The signature cache

The same transaction has its sender recovered several times over its life: once when the pool admits it, again when the block carrying it executes, again on every RPC render, and again on each re-execution after a reorg. The arithmetic is identical every time, and it is the most expensive thing the node does per transaction.

The obvious cache is the wrong one. A Mutex<HashMap> consulted once per transaction would serialise the exact region parallel recovery exists to parallelise — and would do it invisibly: the work still happens, one thread at a time, with no error and nothing in the logs. So the lock is never taken from a worker. A block is looked up once before the threads start, the misses are recovered in parallel with no cache access at all, and the results are written back once after the threads join: two acquisitions per block rather than one per transaction. The cache deliberately offers no single-transaction lookup, because offering one would invite calling it from inside the parallel region.

It is keyed by transaction hash, which is sound only if that hash separates every pair of transactions that could recover to different senders — in particular two differing only in v, since v selects both the signing hash and the recovery id. The property was already true; it is now written down and pinned by a test, because a cache keyed on a hash should not rest on an unstated invariant.

Two tiers, which is what rskj's two caches are for. The sizes suggest capacity tuning; the real reason is eviction isolation. Pool entries are long-lived — a transaction waits an unknown number of blocks to be mined — while a peer's block traffic is validated once, bursty and chosen by someone else. One shared map lets the second evict the first, and the pool-to-execution hop then misses every time: the cache still works, it just silently stops paying.

Testnet

Mainnet replayed clean for 9.3 million blocks while testnet died at block #1. The causes turned out to be almost entirely per-chain configuration that had been defined and then never selected — which is why each one looked implemented.

  • Block #1 — RSKIP-97. Rustock computed activation as number >= orchid. That is only the default: testnet.conf sets rskip97 = -1, so on testnet the ten-minute difficulty drop is permanent. Mainnet does not override it, so >= orchid was accidentally right there and nothing surfaced it.
  • Genesis — RSKIP-126. rskj seeds the precompile storage roots from two places, the block executor and the genesis loader, because genesis is constructed rather than executed. Rustock had only the first, which is right for mainnet, where wasabi100 is an ordinary block at #1,591,000, and silently wrong for testnet, where it is height 0. With nothing seeding them, Rustock's testnet genesis reduced to its allocation — and that allocation was mainnet's, so the two chains agreed on a state root they must not share.
  • Block #60 — REMASC. rskj's remasc.json is per-network: maturity 4,000 on mainnet, 50 on testnet. The executor selected Bridge constants by chain and then hardcoded the mainnet REMASC config on the line above. Mainnet's maturity meant no payout was attempted before block 4,000, which is why the preceding 59 testnet blocks agreed.
  • #7,139,903 — the federation UTXO cell. rskj picks the cell by network and activation; after RSKIP-293 testnet spends from a post-hop cell while mainnet always uses the general one. Rustock had all three key constants and used only the first, so a pegout batch built from the wrong inputs produced a different transaction, hash and outpoint values — seven leaves, from one wrong cell.
  • #7,610,038 — the base-event recovery window. Between vetiver900 and #7,800,000, testnet rskj accepts a V2 header that is one RLP element short and substitutes an empty base event. The decoder read that single trailing element as the base event, so the edges were taken for it. Edges are emitted on every versioned header even when empty; the base event is the field that can be absent. Checked by sweeping 275 headers across the V2 range against the hashes rskj stores them under.

What remains is the replay itself: Rustock now gets past every divergence found so far, but a continuous genesis-to-tip testnet replay has not been completed.

Supply conservation rustock-only

Checks, per block and per transaction, that execution did not create rBTC from nothing, and rejects the block if it did.

RSK's supply is bounded by the BTC locked in the peg. A bug that mints rBTC is the worst failure this node could have, and it would otherwise be invisible — state roots would agree with an rskj that had the same bug, and nothing else looks at the total.

Holding the node to rskj, line by line

A second implementation can pass every test it wrote for itself and still disagree with the first one. The parity sweep went looking for those disagreements deliberately rather than waiting for a replay to surface them, and found them in quantity.

The shape of what it found says something about where a second client actually goes wrong. Uncles judged by a trunk header's rules instead of rskj's uncle rules. Fork-detection counts summed as a Rust integer where rskj sums them as a Java int and lets it overflow. Expected block time worked out in the wrong arithmetic. A Bitcoin hash held to the wrong target. Partial Merkle trees read as a general implementation reads them rather than as bitcoinj-thin does. Bridge arguments decoded in the wrong order, so a peg-in was validated against the wrong thing. None of these is exotic; every one of them forks the chain.

It also closed a category rather than a bug: a pass over everything a stranger can send — peers, snapshot chunks, blocks, RPC, precompiles — so that nothing reaching the node from outside can panic it. A client that aborts on a malformed message is a client that can be stopped from across the network.

The same work brought Windows and macOS up alongside Linux, which is why all three now build and test in CI. Thread stack sizes, file locking, CPU-time measurement and the permission bits on an env file each needed a path per operating system.

This was contributed from outside the project — who built what.

State and storage

FlatDB — a trie store that stores no keys

A port of rskj's co.rsk.flatdb branch, and the one structural change to how trie nodes are held. RocksDB is a general key/value store being asked to do something very specific; FlatDB is built for the specific thing. It holds data whose key is the hash of its value, and every decision in it follows from that plus three facts about the workload: no deletions, no range queries, no mutation.

The consequence worth the port is that the index stores no key bytes at all — a table of 8-byte slots over an append-only heap. A probe resolves a collision by fetching the candidate record and recomputing H(value), which means every successful short-record read is also a verification of the bytes against their own address. A corrupted record cannot come back looking correct, which is not a property the store it replaces has.

The precondition was checked rather than assumed, because the whole design rests on it: converting the real mainnet store copied 25,371,307 nodes across three epochs with none skipped, where the converter skips any entry whose key is not its value's digest. On disk a flush is three ordered steps — heap, index, then checkpoint — and only the checkpoint makes a batch real, so a crash between steps loses the batch rather than half of it.

What it is worth is 1.76× serially on real mainnet state. That is the honest figure and it is lower than the one the synthetic fixture gave; block execution issues dependent reads and cannot batch them, so the serial column is the one execution lives in. --trie-engine flatdb selects it and the default stays rocksdb, for one precise reason: it has not yet run on a real chain. The research note has the measurements, including the three results that repetition took back.

Unitrie storage and epoch garbage collection

RSK's single trie for accounts, code and storage, plus a mark-and-sweep collector that works over rotating epochs rather than the whole store.

State grows without bound otherwise: every historical state is retained, while only a recent window is reachable. The epoch design lets the collector mark from one deep root and sweep whole epochs, which is what makes the collection affordable on a 130 GB store.

One root turned out not to be enough. A node that serves snapshots must also keep the checkpoint it offers, which sits 10,000–15,000 blocks back — three to four times deeper than the burial depth, and so not reachable from the collection root. Measured, the margin was not there: ~3,900 blocks fill a 1 GB epoch, so with four epochs the sweep horizon is ~12,000 blocks against a checkpoint up to 15,000 old. The collector now takes pinned roots.

Marking the checkpoint instead is not an alternative: two states at different heights share most of their nodes but neither contains the other, so dropping the collection root would sweep what the node executes on — a failure this store has actually suffered. The live set has to be the union, and the union is nearly free, because a key is queued only when it is new: measured on mainnet, pinning two checkpoints added 0.58% of the live set and 1.3% of the mark.

The collection root is walked first, and that ordering is load-bearing rather than incidental. A missing entry means opposite things for the two kinds of root — under the collection root the live set is incomplete and the sweep would destroy reachable state, so the cycle aborts; under a pin it means that checkpoint is already half-collected, which is reported and does not stop anything. A pin that could abort a cycle would stop the collector permanently the first time a checkpoint slipped, turning one broken thing into two.

Segmented trie tooling rustock-only

Splits the trie into self-contained chunks that can be distributed and read independently, with tooling to build, verify and repair them.

Useful for analysis and distribution — and the exercise that established a precise limit worth knowing: the chunks are self-contained for Rustock's own read set, and a foreign client with a different access pattern will hit missing nodes.

Block pruning rustock-only

Deletes headers, bodies, receipts and transaction-index entries below a retention floor, in one batch per block so the store is never half-pruned.

Full history is not needed to follow the chain, and disk is the binding constraint on a node that also holds a 130 GB trie.

Bridge event index rustock-only

Indexes the events the Bridge emits — peg-ins, peg-out requests, releases, federation changes — so peg activity can be queried by height and type rather than by re-scanning receipts.

Peg activity is the thing operators most need to see, and it is the part hardest to reconstruct after the fact.

Sync and reliability

The position layer, coherence invariants and the Φ watchdog

Three storage pointers — head, executed head, canonical index — unified behind a single transition type that writes them in one batch; eight stated invariants (I1–I8) checked continuously; and a progress measure Φ that detects a node that believes it is syncing and is not.

Nearly every outage in this node's history was two of those three pointers disagreeing, and they used to be written from a dozen places. The redesign makes the incoherent states unrepresentable rather than merely unlikely, and the rollback decision is a pure function simulated over thousands of generated chains and forks.

Four of the eight invariants are now repaired, not only reported — and that change was earned rather than designed. The module was built to make disagreements loud; on 24 September 2026 a one-block sibling fork at the tip left execution on the losing side and I5 named it correctly every thirty-five seconds for twelve minutes while nothing consumed the report. An invariant that is only ever printed is a diagnostic. In production the repair now fires several times an hour on ordinary tip forks, almost always one block deep — and the violation is never logged at all, because it is fixed before it is old enough to be worth reporting.

Snapshot sync

Joining the network by downloading the state instead of executing every transaction into it. Both sides: serving snapshots to peers, and using one to catch up.

What is given up is the re-execution of history, not the verification of it. The header chain to the snapshot point is verified under the same proof-of-work rules a full sync applies, and every chunk of state is proved against that chain's state root as it arrives.