Skip to content

feat: export up to the latest finalized block by default - #14

Merged
gacevicljubisa merged 1 commit into
mainfrom
feat/finalized-end-block
Aug 28, 2026
Merged

feat: export up to the latest finalized block by default#14
gacevicljubisa merged 1 commit into
mainfrom
feat/finalized-end-block

Conversation

@gacevicljubisa

Copy link
Copy Markdown
Member

Summary

With --end=0 the exporter resolved the end block via eth_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 (tailSize in pkg/postage/listener); the exporter was more aggressive than Bee.

--end=0 now resolves the end once via the finalized block tag and uses that concrete number for all chunked queries (resolving the tag per-request would drift across load-balanced backends). An explicit --end still overrides it.

Verified against the default endpoint: eth_getBlockByNumber("finalized") on rpc.gnosis.gateway.fm returns a block ~32 blocks (~160 s, two 16-slot epochs) behind latest — a negligible lag for snapshot purposes, in exchange for every exported block being immutable.

Changes

  • ethclientwrapper: new FinalizedBlockNumber method — HeaderByNumber with the finalized tag, behind the same rate limit and transient-error retry as the other calls.
  • eventfetcher: --end=0 uses FinalizedBlockNumber instead of BlockNumber.
  • Tests against a fake JSON-RPC server: the wrapper sends ["finalized", false] and parses the header number; GetLogs chunk queries end at the finalized block, not at latest (these two packages had no behavioral tests before).
  • Docs: --end help text and README (also drops the stale (default 39810670) from the flags listing).

Testing

  • go test -race -count=1 ./... — all pass
  • make lint — 0 issues

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q7Linc1WFpVVE4mEj6xmjG

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
@gacevicljubisa
gacevicljubisa merged commit c48bff7 into main Aug 28, 2026
3 checks passed
@gacevicljubisa
gacevicljubisa deleted the feat/finalized-end-block branch August 28, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants