Architecture

Nine crates, one pipeline: bytes arrive from a peer, become a header, become a block, become state, and become an answer to an RPC query.

The crates

A Cargo workspace. Dependencies point one way — core and trie know nothing about the network, and networking knows nothing about execution.

CrateLinesResponsibility
cli28.4kEntry point, argument parsing, genesis bootstrap, wiring every service together — and 71 diagnostic tools under examples/
core19.9kBase types — Header, Block, Transaction, Receipt — consensus rules, validation, chain config, activation heights, the typed chain-event channel
trie10.5kRSK Unitrie: nodes, paths, account encoding, key mapping, and the snapshot traversal and chunk proof
execution113.0kEVM executor, block processor, every RSK precompile, the BTC–RSK Bridge, REMASC, merged mining, supply conservation, the tracer
storage18.7kRocksDB persistence behind a write cache, the position layer, epoch GC, block pruning, the rskj importer
networking11.4kP2P: RLPx, discovery, sessions, peer management, peer scoring and bans, the snap wire messages
sync45.4kSync state machine, header and body pipeline, snapshot sync on both sides, coherence invariants, the Φ watchdog, transaction pool and rate limiter, gas price tracker, transaction relay
rpc20.0kaxum JSON-RPC server, the WebSocket transport and eth_subscribe, and the debug/trace namespaces
alerts4.8kTwo-way-peg monitoring, node-health alarms, and the shared email transport
flatdb3.4kAn append-only trie store behind the same seam as RocksDB: mmap'd heap, keyless open-addressed index, CRC'd checkpoint. Faster serially on real state, and not yet the mainnet default

Around 276,000 lines in all. Nearly half the codebase is execution, and most of that is the Bridge. That ratio is the honest shape of an RSK client: the EVM is a solved problem with a good Rust implementation, and the peg is not.

How big is that, really

Against the three other clients a Rootstock or Ethereum node is usually measured by. Counted the same way on all four: production code only, with tests excluded everywhere — Go's _test.go files, Java's src/test/java, and Rust's inline #[cfg(test)] modules, which are 28–30% of both Rust trees and would otherwise flatter them badly.

ClientLanguageOwn code+ EVMTotal
rethRust308,16536,285344,450
gethGo272,696—272,696
RustockRust173,28836,285209,573
rskjJava130,837—130,837

Why the EVM column. rskj and geth carry their virtual machines inside the tree — rskj in org.ethereum.vm, geth in core/vm — so their totals already include one. Rustock and reth both depend on revm, which is a separate project neither of them owns. Adding it is what makes the four comparable; leaving it out would credit the two Rust clients with an EVM they did not write but do not have to.

Read this for scale, not for merit. The four are not the same program four times. reth and geth implement Ethereum: blob transactions, proof of stake, the Engine API, an explorer namespace Rustock has none of. Rustock and rskj implement Rootstock: a Bitcoin SPV header chain, merged mining, and a two-way peg Bridge that has no Ethereum counterpart at all. A line count says nothing about maturity either — rskj has secured a live chain for nine years and Rustock is a prototype, and no column here shows that.

The 276,000 above counts everything in this repository including inline tests, which is the figure the rest of this site uses; the table strips tests from all four so the comparison is a fair one. rskj at a7c0a94, geth 1.17.7, reth 2.5.2, revm 36 — and reth resolves a later revm than Rustock does, so its EVM column is an approximation rather than a measurement.

The pipeline

        peers
          │  RLPx frames, chunked at 32 KB
          ▼
   ┌─────────────┐   headers    ┌──────────────┐
   │ networking  │─────────────▶│    sync      │  skeleton → chunks → bodies
   │  discovery  │◀─────────────│   tracker    │  4 requests in flight per peer
   │  sessions   │   requests   └──────┬───────┘
   └─────────────┘                     │ blocks, in order
          ▲                            ▼
          │                     ┌──────────────┐
          │  relay              │  execution   │  REVM + precompiles + Bridge
          │                     │  processor   │  one journal per block
   ┌──────┴──────┐              └──────┬───────┘
   │   tx pool   │                     │ EvmState
   └─────────────┘                     ▼
                                ┌──────────────┐    ┌──────────────┐
                                │    trie      │───▶│   storage    │  RocksDB,
                                │  (Unitrie)   │    │ 7 col.family │  7 column families
                                └──────┬───────┘    └──────┬───────┘
                                       │  state root       │
                                       ▼                   ▼
                                  compare with        ┌──────────┐
                                  block header        │   rpc    │
                                                      └──────────┘

Every block ends with the same question: does the recomputed state root equal the one in the header? If it does not, the node stops rather than building on state it cannot justify. Nearly every entry in the compatibility catalogue was found by that comparison failing at a specific mainnet height.

Networking

Rustock speaks the RSK variant of devp2p, which is close enough to Ethereum's that the differences are easy to miss and fatal when missed.

  • RLPx — full encrypted transport, inbound and outbound handshakes.
  • Multi-frame messages. Standard Ethereum clients send each P2P message as one frame regardless of size. rskj splits anything over 32 KB into multiple frames sharing a contextId, each with its own header and MAC. A client that does not reassemble them never receives a large body response — it just sees the sync stall.
  • Kademlia discovery over UDP, with peer exchange and a node table persisted across restarts so a cold start is not a cold network.
  • Serving peers. Rustock answers BlockHeadersRequest, BlockHashRequest, SkeletonRequest and BodyRequest — it contributes to the network rather than only consuming it.
  • Transaction relay. Transactions from peers are validated, admitted to the pool and rebroadcast to every other connected peer.

Sync

The high-level shape matches rskj's skeleton sync — find a connection point, pull a skeleton of every Nth header, download the in-between chunks, then bodies, then execute. The difference is how much of that runs at once.

Multi-peer parallel header download

Header chunks are spread across every connected peer, with up to four chunk requests in flight per peer. A PeerChunkTracker assigns chunks, records which peer holds which, buffers out-of-order responses and drains them back into strict order before they touch the store. Responses are matched to chunks by content, not by arrival order, so reordering across peers is safe, and fill_pipeline tops every peer up to capacity each round. rskj downloads header chunks from one peer, one request at a time.

Overlapped bodies and execution