feat: export up to the latest finalized block by default - #14
Merged
Conversation
With --end=0 the exporter previously resolved the end via eth_blockNumber (chain head). Blocks near the head can still be reorged, and a snapshot holding logs from an orphaned block cannot be repaired by a later resumed export, poisoning every following iteration. The end block now resolves once via the finalized tag; an explicit --end still overrides it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q7Linc1WFpVVE4mEj6xmjG
martinconic
approved these changes
Aug 28, 2026
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.
Summary
With
--end=0the exporter resolved the end block viaeth_blockNumber— the raw chain head. Blocks near the head can still be reorged, and a snapshot holding logs from an orphaned block cannot be repaired later: a resumed export (#11) is append-only and its cursor dedup is positional, so a reorged tail silently poisons every following iteration. Bee itself never syncs closer than 4 blocks from the tip (tailSizeinpkg/postage/listener); the exporter was more aggressive than Bee.--end=0now resolves the end once via thefinalizedblock tag and uses that concrete number for all chunked queries (resolving the tag per-request would drift across load-balanced backends). An explicit--endstill overrides it.Verified against the default endpoint:
eth_getBlockByNumber("finalized")onrpc.gnosis.gateway.fmreturns a block ~32 blocks (~160 s, two 16-slot epochs) behindlatest— a negligible lag for snapshot purposes, in exchange for every exported block being immutable.Changes
ethclientwrapper: newFinalizedBlockNumbermethod —HeaderByNumberwith thefinalizedtag, behind the same rate limit and transient-error retry as the other calls.eventfetcher:--end=0usesFinalizedBlockNumberinstead ofBlockNumber.["finalized", false]and parses the header number;GetLogschunk queries end at the finalized block, not atlatest(these two packages had no behavioral tests before).--endhelp text and README (also drops the stale(default 39810670)from the flags listing).Testing
go test -race -count=1 ./...— all passmake lint— 0 issues🤖 Generated with Claude Code
https://claude.ai/code/session_01Q7Linc1WFpVVE4mEj6xmjG