Merkle shreds are Solana shreds whose signature covers a whole erasure batch instead of one packet. The leader hashes every shred in a batch into a Merkle tree and signs only the root. Each shred carries that signature plus a short proof, so a receiver can check any single shred on its own.
What are Merkle shreds?#
A leader cuts each block into shreds and groups them into erasure batches, which FEC sets describes in detail. In current Agave a batch is 32 data shreds plus 32 coding shreds. Every shred needs to prove that the scheduled leader produced it, otherwise any node on the path could inject fake data.
Older legacy shreds solved this the direct way. The leader signed each shred separately, over every byte after the signature field. That meant one signing operation per shred for the leader and one full signature check per shred for every receiver.
Merkle shreds change what gets signed. The leader builds a binary hash tree whose 64 leaves are the 64 shreds of the batch, then signs the tree's root once. The 64-byte signature at the front of each shred, described in the shred header, is that one signature, repeated in all 64 shreds.
How is the Merkle tree built?#
The Agave source defines the hashing precisely:
- Leaf. SHA-256 over a fixed prefix (a zero byte followed by
SOLANA_MERKLE_SHREDS_LEAF) and the shred's bytes from offset 64, right after the signature, up to the start of its Merkle proof. So the leaf covers the headers and the body. - Inner node. SHA-256 over a different prefix (a one byte followed by
SOLANA_MERKLE_SHREDS_NODE) and the first 20 bytes of each child hash. - Root. The last node of the tree, a full 32-byte hash. The leader signs it with the key the leader schedule names for the slot.
The two different prefixes stop an attacker from passing off an inner node as a leaf, a known weakness of plain Merkle trees. Agave follows the Certificate Transparency approach here.
Leaves are ordered by position in the batch. Data shreds come first, at their index minus the FEC set index. Coding shreds follow, at their position plus the number of data shreds.
What does a Merkle shred carry besides data?#
After the headers and the data or parity bytes, a shred holds:
- The chained Merkle root, 32 bytes: the root of the previous batch in the same slot.
- The Merkle proof: one 20-byte entry per tree level. A 64-leaf tree has 6 levels, so the proof is 120 bytes. The low four bits of the variant byte record this count.
- The retransmitter signature, 64 bytes, but only on the last batch of a slot.
These bytes reduce the room left for block data. With a proof of 6 entries, a 1,203-byte data shred has 963 bytes for entry data, or 899 bytes when it also reserves space for the retransmitter signature. That follows from the capacity formula in merkle.rs: payload size minus 88 header bytes, the 32-byte chained root, the proof, and the optional signature.
How does a receiver verify one shred?#
A node does not need the rest of the batch to check a shred:
- Read the slot from the header and look up its leader in the Solana leader schedule.
- Hash the shred's own bytes into its leaf.
- Walk up the tree with the proof, hashing the running value with each 20-byte sibling entry, to reach the root.
- Check the leader's signature against that root.
If any byte of the headers or body was changed, the computed root will differ and the signature fails. Agave also caches each (signature, leader, root) triple it has verified. Once the first shred of a batch passes, the other 63 match the cache and skip the signature math, leaving only the cheap hashing.
The shred header parsing guide shows where the signature and variant bytes sit if you want to read them yourself.
Why chain the roots and add a second signature?#
Chained roots link each batch to the one before it. Because the previous root is inside the leaf bytes, it is covered by the leader's signature. Agave's blockstore compares the chained root in a new batch with the root it already holds for the neighbouring batch. If they disagree, the leader has signed two different versions of the slot, and the node records a duplicate proof. Every Merkle variant accepted by Agave v4.4.1 is chained.
The retransmitter signature sits after the proof, outside the leaf hash, so adding it does not disturb the leader's signature. Only the last batch of a slot reserves space for it, and each node that forwards those shreds through Turbine signs them again with its own key.
What happens to signatures during recovery?#
When a node rebuilds missing shreds from a batch's coding shreds, it also rebuilds the Merkle tree. The same shreds produce the same root, so the recovered shreds simply reuse the leader's signature from the shreds that arrived. The Merkle proof itself is added after erasure coding, so it is recomputed rather than recovered.
Questions#
Does every shred in a batch have the same signature?#
Yes. All 64 shreds of a batch carry the leader's single signature over the batch root. What differs between them is the leaf data and the proof.
Why are proof entries 20 bytes and not 32?#
Agave truncates sibling hashes to 20 bytes in the proof to save room in each packet. The root that the leader signs is still a full 32-byte hash.
Can I verify a shred without the leader schedule?#
You can check that the proof is internally consistent, but not who signed it. Proving the shred came from the real leader needs that slot leader's public key, which comes from the schedule.
Sources#
- Agave v4.4.1 source: ledger/src/shred/merkle.rs (layout, signing, recovery) (checked 2026-11-17)
- Agave v4.4.1 source: ledger/src/shred/merkle_tree.rs (hash prefixes, 20-byte proof entries) (checked 2026-11-17)
- Agave v4.4.1 source: ledger/src/sigverify_shreds.rs (verification cache) (checked 2026-11-17)
- Agave v4.4.1 source: ledger/src/blockstore.rs (chained Merkle root checks) (checked 2026-11-17)
- Agave v2.0 branch source: ledger/src/shred/legacy.rs (per-shred signatures) (checked 2026-11-17)
- Agave master source: ledger/src/shred.rs (signature field documentation) (checked 2026-11-17)