Cinder

The write that our latency windows did not show

TL;DR

Cinder answered engine_newPayload in 97 ms on average and still fell 400 blocks behind. This post is about the work that the latency number did not count, and how it moved out of the way.

2026-10-07. Measured on the desktop against reth 2.0, before testing moved to a dedicated server. The numbers are kept as they were measured.

For a while we compared Cinder with reth on one number: how long engine_newPayload takes, the call in which the consensus client hands the execution client a new block. In one 30-minute window Cinder took 97 ms on average and reth took 215 ms. It looked like a clear win.

In the same window Cinder answered 83 calls. Reth answered 149. Cinder was 400 blocks (80 minutes) behind the chain, and the gap grew. This post is about the work that our latency number did not count, and about how we moved it out of the way.

Where the time went

After Cinder answered a forkchoice update (the call in which the consensus client names the new head), its engine loop wrote every finished block to the database (MDBX), one block per transaction:

  1. the undo record of the block (the reverse diff, so that a reorg can step back: a reorg is a change of the head to another branch of the chain),
  2. a second state root over the database, to check what goes to disk,
  3. a durable commit: a write that waits until the data is safe on the disk.

The answer to newPayload came before this work, so our latency number did not include it. But the next request waited behind the write.

write after the answer: mean / median / p90
11 runs of the node 4.2 to 6.6 s / 1.4 to 7.6 s / 10.5 to 13.2 s

The p90 is the time that 90% of the writes stayed under.

In the slowest runs, one write in ten took longer than the 12 seconds between two blocks.

Rowlowest of the 11 runshighest of the 11 runs
Mean4.2 s6.6 s
Median1.4 s7.6 s
p9010.5 s13.2 s
Time of the block write after the engine_newPayload answer, in seconds, one commit per block on the engine loop. Each pair of bars is the range over 11 runs of the node. A new block comes every 12 s, so a p90 near or above 12 s means that the node falls behind. Desktop, reth 2.0, until 2026-10-02. Record: docs/results/2026-09-latency.md.

A block arrives every 12 seconds. The median write fits. The p90 does not. A node that sometimes needs 13.2 seconds for 12 seconds of chain cannot catch up.

Why so slow? One minute of /proc/<pid>/io showed 841 MB written for 12 blocks: about 70 MB per block, for a few hundred kilobytes of state change. MDBX is a copy-on-write B-tree. Each commit copies every page it touches and every branch page above it, then syncs. A block touches pages all over the state, so each commit rewrites a large part of the tree’s upper levels.

The design: a writer thread with batches

Reth writes in the background, in batches. We did the same.

The hard part is not the thread. It is everything that reads the database while the writer changes it.

One snapshot per view

A block executes on many threads at once: execution, prewarming, trie prefetch, sender recovery. Each thread reads the database through its own read transaction. Before the writer, nothing committed while a block executed, so all those transactions saw the same snapshot. With the writer, a commit can land between the first thread’s read and the last one’s.

So a view now opens all its read transactions at once and retries until they share one transaction ID. Cost: 13.8 µs per block view of 72 transactions, against 0.6 µs before.

The cache must not run ahead of the snapshot

Cinder keeps a cross-block cache of accounts and storage. The first version updated it when the writer committed. A block that was still executing on the old snapshot then read an account’s new storage root from the cache and tried to open a storage trie that its snapshot did not contain: a trie node hash mismatch. The EEST suite found it. Now the writer hands its cache updates back, and the engine thread applies them when it publishes the batch. At that moment no block is executing.

Byte-for-byte the same database

A batch must give the same database as one commit per block. A test runner option writes every test both ways and compares all 13 tables entry by entry. The tests found one real bug here. Suppose one block in a batch sets a contract’s code and a later block in the same batch replaces it, as EIP-7702 delegations do. A batch that wrote only the final state lost the first code. Now each block’s code goes into the batch.

Results

one commit per block on the engine loop writer thread
wait of the next request behind a write 0.4 to 14 s 4 ms mean, 7 ms p90 (2026-10-02, 150 blocks)
catching up after a stop fell 400 blocks behind 380 blocks in about 12 minutes (2026-10-02, the writer alone, batches up to 16 blocks)
INVALID answers 0 0

The reorg we did not test

Soon after the writer went live, mainnet block 26109905 came in two versions: a one-block reorg. The first version became the head and went to the writer. The writer was still busy with the previous batch (the first write after a restart is cold and took 60 seconds). The second version arrived, executed as valid on the same parent, and the consensus client switched the head to it.

When the batch was published, the writer had written the first version. The branch of the second version no longer connected to the database head, so the node dropped it as dead. From then on, every payload was SYNCING: the answer that tells the consensus client that the node cannot judge the block yet. The node stood on that block for two days. It never answered INVALID, so nothing looked wrong in the error counts.

Our review had covered a fork that arrives during a write. It had not covered a forkchoice switch to a sibling that executed before the handover.

The fix has two parts:

The test for it is deterministic: a helper thread holds MDBX’s write lock, so the writer stops at exactly the two moments that matter. The test failed before the fix and passes after it. We recovered the live node without a resync: we replayed the second version from its slot, which made it pending, and the next forkchoice update unwound the first.

What came next

The writer made the node keep up, but it moved a cost. A block now often arrives before its parent is written, and such a block had to replay its unwritten ancestors to compute its state root: +15 to 19 ms. The next step was to keep each block’s changed trie nodes in memory, so that a block on an unwritten parent computes its root like a block on the database head. That made catching up 1.8 times faster (352 blocks in 10 minutes against 197). It is the subject of another post.

What we take from it

Updated 2026-10-23: the writer wait of 4 ms mean (7 ms p90) is from 150 blocks on 2026-10-02. A later desktop window on 2026-10-05 gave 5 ms mean (7 ms p90), and other posts use that run. The 380 blocks in about 12 minutes ran with the writer alone and batches of up to 16 blocks. The 197 blocks in 10 minutes of the state-root post ran with a limit of 4 unwritten blocks and the replay path. The setups are different, so the two rates do not show a slowdown.