fix(blocks): clamp tail chunk to reorg buffer max instead of dropping it#255
Open
AuburyEssentian wants to merge 1 commit intoparadigmxyz:mainfrom
Open
fix(blocks): clamp tail chunk to reorg buffer max instead of dropping it#255AuburyEssentian wants to merge 1 commit intoparadigmxyz:mainfrom
AuburyEssentian wants to merge 1 commit intoparadigmxyz:mainfrom
Conversation
When --reorg-buffer N is set, apply_reorg_buffer previously filtered out any chunk whose max block exceeded latest_block - N. This silently dropped the partial tail chunk (e.g. blocks 20030000-20030787 when only up to 20029999 is safe), causing cryo to never collect those trailing blocks. Fix: replace the filter_map that drops whole chunks with clamp_chunk_to_max, which truncates Range chunks to max_allowed and filters Numbers vectors, preserving all safe blocks within a chunk. Fixes paradigmxyz#193
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.
Problem
Fixes #193.
When
--reorg-buffer Nis set,apply_reorg_bufferusedfilter_mapto drop any chunk whosemax_value()exceededlatest_block - N. This silently discarded the partial tail chunk — e.g. if the last full chunk boundary was block 20,029,999 but the reorg-safe ceiling was 20,030,779, the 780-block tail chunkRange(20030000, 20030787)was dropped entirely rather than trimmed toRange(20030000, 20030779).The result: cryo with
--reorg-bufferalways rounds the max collected block down to the last full chunk boundary, losing up tochunk_size - 1blocks.Fix
Replace the
filter_mappredicate with aclamp_chunk_to_maxhelper that:Range(start, end)chunks: returnsSome(Range(start, end.min(max_allowed)))ifstart <= max_allowed, elseNone.Numbers(ns)chunks: filters out block numbers> max_allowed, returningNoneonly if the entire list is beyond the buffer.This preserves every safe block in the tail chunk rather than discarding it.
Before / After