Repository navigation
feat(node,store): optionally store new blocks as zstd - #6851
Draft
MoonBoi9001 wants to merge 5 commits into
Draft
MoonBoi9001 wants to merge 5 commits into
MoonBoi9001 wants to merge 5 commits into
Conversation
MoonBoi9001
marked this pull request as ready for review
December 1, 2026 10:43
MoonBoi9001
marked this pull request as draft
December 1, 2026 10:57
MoonBoi9001
marked this pull request as ready for review
December 1, 2026 16:56
MoonBoi9001
force-pushed
the
mb9/compress-new-blocks
branch
from
December 1, 2026 17:24
aa7c42e to
fcf2265
Compare
MoonBoi9001
marked this pull request as draft
December 1, 2026 17:48
This was referenced Dec 2, 2026
The block store took each chain's network, shard and cache size as a tuple that callers unpacked by position; a named struct makes each field explicit and leaves room for more.
Blocks were turned into what gets stored while holding a database connection. Do that before taking one, so that slower steps such as compression can be added there.
A chain can be set up to compress new blocks with zstd, off by default. Add the column for them when the first block is compressed, and store blocks uncompressed until that works. Shared storage ignores the setting.
Nothing could turn on zstd compression for the blocks that get cached. Add block_compression to the configuration, for all chains or for a single chain.
What we know about a blocks table's column for compressed blocks, and when we last looked for it or tried to add it, sat behind 3 separate locks. It is now 1 enum behind 1 lock, and writers get a named answer about whether they can compress instead of an Option<bool>.
MoonBoi9001
force-pushed
the
mb9/compress-new-blocks
branch
from
December 2, 2026 17:20
fcf2265 to
13c9197
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Adds a
block_compressionsetting, for all chains or a single chain, that stores new blocks in the block cache as zstd. It is off by default and leaves existing blocks alone; #6853 converts existing blocks.Motivation
#6850 has the measurements: zstd at level 1 stores blocks in 48% to 60% less space than pglz across 8 chains and makes 19-block lookups 13% to 23% faster. With those readers in place, this is the switch that starts writing compressed blocks.
Summary
block_compression = "zstd:<level>"under[chains]or on one chain;"none", the default, keeps today's behaviour.data_zstdcolumn is added the first time a chain writes a compressed block rather than by a migration, since adding it needs a brief exclusive lock on a large, busy table. graph-node waits at most 2 seconds for that lock; if it can't get it, it stores blocks uncompressed and tries again after 1 minute, doubling the wait up to 1 hour. Several nodes trying at once is harmless thanks toadd column if not exists.blockstable.Warning
Upgrade every node before turning the setting on, since older versions fetch a compressed block from the chain's provider each time they need it.