Skip to content

🤖 [claude] Derive Firehose finality from the block's Parlia attestation (fixes wrong LIB on fork blocks) - #5

Merged
Johnaverse merged 1 commit into
release/develop-fhfrom
fix/firehose-deterministic-finality
Sep 9, 2026
Merged

Johnaverse merged 1 commit into
release/develop-fhfrom
fix/firehose-deterministic-finality

Conversation

@Johnaverse

Copy link
Copy Markdown
Collaborator

Summary

Root-cause fix for the finality signal reported by Phantom (bsc mainnet block 120653740, 2026-09-08 08:24 UTC) and for two related production symptoms.

Defect. reth-firehose stamped every traced block with the node's canonical finalized head at execution time (canonical_in_memory_state().get_finalized_num_hash() in the engine payload validator; provider().finalized_block_num_hash() in the ExEx runner). That is node state — it depends on which Parlia votes this node had received — and it is not necessarily an ancestor of a side-chain block being traced. On BSC fast finality (head−1…3) this produced:

  • Fork block marked final downstream: fork block 120653743 (e3d67571) was emitted with LIB 120653740; on its own ancestry that height is 2c97928d, which Phantom's forkdb then finalized and locked onto the dead branch.
  • Readers disagree on LIB for identical blocks (129 of 263 recent pairs differ between x91 and x827), so the merger sees two canonical names for one block and files one as "forked" — ~50k such files in bsc-sf-v5-forked-blocks.
  • LIB stepping backwards within one reader (e.g. x91: 120772186→LIB …184, 120772187→LIB …183), the same behaviour the geth-era tracer clamped.

Fix.

  • pinax-network/bnb-reth firehose/develop @ 73cdbc6 (tag bnb-bf76323c-fh3.1-2): new ChainTracingConfig::finalized_for_block resolver; mapper::finalized_ref_for_block() uses it exclusively when set (a None result emits no finalized ref — fireeth falls back to block − 200 — never node state); both engine call sites and the ExEx runner switched. Chains without the hook and the staged-sync path are unchanged.
  • This repo: firehose_finalized_for_block() in main.rs reads the Parlia snapshot of the emitted block and returns its attestation's finalized checkpoint (Snapshot::get_finalized_number() = vote_data.source, the same rule parlia_getFinalizedNumber exposes) with the matching hash. Deterministic per block, identical on every node, on the block's own ancestry by construction.
  • Pins → bnb-bf76323c-fh3.1-2; Cargo.lock same crate set, new commit. CHANGELOG for dev-049d306-fh3.1-2.

Compiled only by CI (no local toolchain) — expect this PR's checks to be the first build.

Test plan

  • CI green (incl. Docker build) — compiles both layers
  • Tag dev-049d306-fh3.1-2, bump eosn-sf-bsc4-test, deploy on bsc-sfdm40 (test mode)
  • Once live: x40 one-block names carry LIB = attestation source (head−2 steady state); no LIB regressions; test-mode diff shows only the known size deltas
  • File upstream to StreamingFast with the evidence

🤖 Created by Claude Code Fable 5.1 (effort: high)

🤖 Generated with Claude Code

https://claude.ai/code/session_01YHvxpuVpZfzefJgwgqjAzn

Register ChainTracingConfig::finalized_for_block (pinax-network/bnb-reth tag
bnb-bf76323c-fh3.1-2) with a resolver that reads the Parlia snapshot of the
emitted block and returns its attestation's finalized checkpoint
(Snapshot::get_finalized_number, i.e. vote_data.source), the same rule
parlia_getFinalizedNumber exposes. Every node derives the same value for the
same block and it lies on the block's own ancestry.

Before, the finalized ref was this node's canonical finalized head at
execution time: node state that produced readers disagreeing on the LIB of
identical blocks (merger "forked" duplicates), LIB regressions within one
reader, and fork-branch block 120653743 (e3d67571) carrying canonical
finalized 120653740 so a downstream forkdb finalized the fork's 2c97928d
(2026-09-08 08:24 UTC, reported by Phantom).

Cargo.lock: same reth crate set, new bnb-reth commit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YHvxpuVpZfzefJgwgqjAzn
@Johnaverse
Johnaverse merged commit 92dd3e2 into release/develop-fh Sep 9, 2026
10 checks passed
@Johnaverse
Johnaverse deleted the fix/firehose-deterministic-finality branch September 9, 2026 00:13
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.

1 participant