Skip to content

cl/phase1/stages: fix EL backfill slot/block unit mix#21570

Merged
domiwei merged 2 commits into
mainfrom
awskii/caplin-el-backfill-units
Jun 2, 2026
Merged

cl/phase1/stages: fix EL backfill slot/block unit mix#21570
domiwei merged 2 commits into
mainfrom
awskii/caplin-el-backfill-units

Conversation

@awskii

@awskii awskii commented Jun 2, 2026

Copy link
Copy Markdown
Member

Problem

destinationSlotForEL is a beacon slot, but the snapshot-gap path stored an EL block number (frozenBlocksInEL-1) in it. Post-merge the block number exceeds the slot, so the finished-gate (slot <= destinationSlotForEL) and the wait loop (Progress() > destinationSlotForEL) misfire: the EL history backfill reports finished at the chain tip and downloads nothing. The tip-to-head gap never fills, and the block collector loops:

[BlockCollector] Failed to insert blocks err="parent's total difficulty not found with hash 275c70ad... and height 25224521: <nil>"

Hits any behind-node restart where HasGapInSnapshots is true.

Fix

Track the gap floor as a separate EL block number compared against EL block progress (currEth1Progress), not the beacon slot. Decision extracted to elBackfillFinished with a unit test for the gap and no-gap paths.

destinationSlotForEL is a beacon slot, but the snapshot-gap path stored an EL
block number (frozenBlocksInEL-1) in it. Post-merge the block number exceeds the
slot, so the finished-gate tripped at the chain tip and the EL history backfill
stalled, leaving the tip-to-head gap unfilled. The block collector then loops on
"parent's total difficulty not found".

Track the gap floor as a separate EL block number, compared against EL block
progress rather than the beacon slot.
@awskii awskii requested a review from domiwei as a code owner June 2, 2026 01:53
@awskii awskii added the Caplin Caplin: Consensus Layer, Beacon API label Jun 2, 2026
@awskii awskii requested a review from Copilot June 2, 2026 02:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a unit mismatch in the Caplin history download stage where a beacon-slot floor (destinationSlotForEL) was incorrectly overwritten with an EL block number in the snapshot-gap path, causing EL history backfill to report “finished” at the chain tip and download nothing after behind-node restarts.

Changes:

  • Introduces elBackfillFinished(...) to decide EL-backfill completion using the correct unit (beacon slot vs EL block number for snapshot gaps).
  • Tracks snapshot-gap completion with a dedicated destinationBlockForEL (EL block floor) instead of reusing destinationSlotForEL.
  • Adds unit tests covering both snapshot-gap and no-gap completion behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cl/phase1/stages/stage_history_download.go Separates beacon-slot and EL-block backfill floors and centralizes completion logic in elBackfillFinished.
cl/phase1/stages/stage_history_download_test.go Adds tests ensuring snapshot-gap completion uses EL block progress and no-gap completion uses the beacon-slot floor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@domiwei domiwei added this pull request to the merge queue Jun 2, 2026
Merged via the queue into main with commit a5a464c Jun 2, 2026
91 checks passed
@domiwei domiwei deleted the awskii/caplin-el-backfill-units branch June 2, 2026 12:15
@awskii awskii added this to the 3.5.0 milestone Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Caplin Caplin: Consensus Layer, Beacon API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants