A hash is not a node: trie references of 36 bytes instead of 208
TL;DR
In the Merkle Patricia trie, a branch node can point to up to 16 children by their hash. When Cinder decoded a branch, each child that was only a hash got a full trie node of 208 bytes. So one branch with 16 children made 17 full nodes, about 3.8 KiB. A profile of 2026-10-22 counted about 109 000 such objects per block in the state root, for about 9 500 decoded nodes. We split the node type. Every node now starts with a common part of 36 bytes (type, flags, hash), and a hash reference is only that part. We ran an interleaved A/B on 1 074 mainnet blocks with release-type builds. A block took 0.923 of the time of the base (95% interval 0.919 to 0.927), 3.7 ms less. The work arena of a block is 37% smaller by mean. The peak memory of the process is 23 to 25% smaller. The change is on main for the next release. It is a desktop replay result, not a live one yet.
Some speed-ups come from a smarter algorithm. This one came from counting objects. On 2026-10-22 we profiled the state root of Cinder on a cold window of mainnet blocks, on one core. One number did not look right: about 109 000 trie node objects per block in the state root, and about 31 500 in execution, for about 9 500 decoded nodes. That is more than ten objects for each decoded node.
This post explains where the extra objects came from, the change we made, the one design that we threw away on the way, and what the change gave on 1 074 mainnet blocks.
Why a trie has children that are only a hash
Ethereum keeps its state in Merkle Patricia tries. A branch node has up to 16 children. In the encoded node, a child is usually not the child itself, but the keccak-256 hash of the child. To compute a new state root, a client decodes the nodes on the paths that changed. It does not need the other children: for them, the hash is all it needs.
So most children of a decoded branch stay what they are in the encoding: a 32-byte hash. A walk that goes down one of them reads that child from the database, decodes it, and replaces the hash with the node.
The cost: 17 full nodes for one branch
In Cinder, every child got the same node type, a full trie node of 208 bytes, with room for a path, a value, an encoding and 16 children. A child that was only a hash used the hash field and left the rest empty. A decoded branch with 16 hash children thus made 17 full nodes: about 3.8 KiB of the arena, measured with alignment. The arena is the per-block work memory of the trie code.
The change: a common part, and a full node around it
A hash reference got the same 208-byte node as a decoded node. Now it gets 36 bytes.
| Row | Before (0.9.5) | After (#272) |
|---|---|---|
| A child that is only a hash (40 bytes in the arena, with alignment) | 208 bytes | 36 bytes |
cn_tnode_tis now the part that every node has: type, flags and hash, 36 bytes (40 in the arena). A reference by hash is only this part.- The full node type has this part as its first member, then the path, value, encoding and children. Only one accessor gives a full node, and it asserts that the node is not a hash reference. So the compiler and the debug build check that each reader tests the type first.
- A walk that resolves a reference puts the decoded node in the slot of its parent. It does not change the reference node.
- The hash of a reference is the stored hash. The code does not hash it again.
- All tries use this code: the state root, the witness backend, the
streaming root, the writer,
eth_getProofand the parallel sub-tries.
Two decisions on the way
No free of a single node. A resolved reference stays in the arena until the arena is reset at the end of the block, as all nodes did before. We could have given its memory back at once. We did not. If no single node is ever freed, no pointer can point to freed memory after a reorg or an undo, which is where such bugs like to hide. 36 bytes per reference is a small price for that.
One type with a short block: rejected. The scratch version of the
change used one node type and allocated a short block for a reference.
It worked, but the sanitizer did not accept it:
UBSan (-fsanitize=object-size) reports a short block of a larger type
as an access to an object that is too small. The final change has two
types, so a reference is a real object of its own size, and a full node
is never shorter than its type.
The result on 1 074 mainnet blocks
A block took 0.923 of the time of the base, 3.7 ms less. The A/A control gave 0.999.
| Row | A: main at 0.9.5 | B: compact references |
|---|---|---|
| Time per block, minimum over 4 rounds (mean of the blocks) | 48.7 ms | 45.0 ms |
| Time per block, mean over 4 rounds | 57.5 ms | 53.4 ms |
| Time per block | A | B | B/A | 95% interval |
|---|---|---|---|---|
| minimum over 4 rounds | 48.71 ms | 44.97 ms | 0.923 | 0.919 to 0.927 |
| mean over 4 rounds | 57.51 ms | 53.37 ms | 0.928 | 0.921 to 0.935 |
| A/A control (A2/A), minimum | 0.999 | 0.994 to 1.004 |
The A/A ratio of the means is 0.8% from 1. That is the noise of this computer under load. The change is 7.7%, well clear of it. Each of the 4 rounds alone gave B/A 0.921 to 0.933.
The work memory of a block is 37% smaller by the mean of the blocks. The peak memory of the process is 0.75 to 0.77 of the base.
| Row | A: main at 0.9.5 | B: compact references |
|---|---|---|
| Work arena at the end of a block, mean of blocks | 57.8 MB | 36.3 MB |
| Work arena at the end of a block, largest block | 132.5 MB | 73.2 MB |
| Memory | A | B | B/A |
|---|---|---|---|
| work arena at the end of a block, mean of blocks | 57.8 MB | 36.3 MB | 0.627 |
| work arena at the end of a block, largest block | 132.5 MB | 73.2 MB | 0.552 |
| peak RSS of a process of 12 blocks, mean of groups | 177.8 MiB | 137.2 MiB | 0.772 |
| peak RSS of a process of 12 blocks, largest group | 212.3 MiB | 159.5 MiB | 0.751 |
A note on the peak memory, because two numbers are around. By the mean of the groups, the peak memory is 0.772 of the base: 23% less. On the largest group it is 0.751: 25% less. The changelog gives 25%. Both ratios are in the record, and the table gives both.
How we checked that the roots did not change
A change to trie nodes must not change one byte of a state root. The checks:
- The 1 074 mainnet blocks: every block equal to mainnet (8 blocks have an incomplete witness, as with the base). The 30 blocks of the workload that took our lead on 2026-10-19: all equal. Both with the release build and with the PGO and ThinLTO build.
- The Engine API tests with a database (Osaka), with a check of each streamed root: 17 569 passed, 0 failed, 0 streamed roots wrong.
- The block tests with a database and a chain (Osaka): 17 550 passed, 0 failed, 0 streamed roots wrong.
- A test build that gave each reference its own memory block of 36 bytes, so that AddressSanitizer reports each read past the end of a short node. All unit test programs and the Engine API tests passed with no report.
- ThreadSanitizer on the trie, state root, witness, engine and execution tests: 0 reports. Two fork tests of the engine fail, and one database test stops in its setup. Both are a known, open issue, and the database test stops in the same way on main.
- A new unit test: a resolved branch with 16 references must take 1 KiB or less of the arena. The base takes 3.8 KiB, and the test fails on it.
An independent review then read the change with the assertions turned on in a release build, and found nothing.
What this does not show
- A live node. This is a replay of fixture blocks on a desktop, one core, with other load. The 3.7 ms is a replay number. The live gain can be larger or smaller: a live node has warm caches, other blocks and other work at the same time. An A/B on the measurement server is the next measurement.
- A release. The change is on main and comes with the next release. 0.9.5 does not have it.
- The next step. A branch still decodes all its children when a walk reaches it. Decoding a child only when a walk goes into it is the next idea. It is an idea, not a result, and we have not measured it.
Updated 2026-10-24: we measured it. Two versions did not make a block faster, and we rejected the change. The data is in An estimate of 3.9% and a result in the noise.
The internals pages describe the state root and the trie. To run Cinder on your own blocks, ask for access at getcinder.dev/access.