Skip to content

fix(lean): ignore far-future gossip blocks while backfill syncing - #1595

Open
dimka90 wants to merge 2 commits into
ReamLabs:masterfrom
dimka90:fix/lean-ignore-far-future-gossip-blocks
Open

dimka90 wants to merge 2 commits into
ReamLabs:masterfrom
dimka90:fix/lean-ignore-far-future-gossip-blocks

Conversation

@dimka90

@dimka90 dimka90 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

What was wrong?

Bug: while a node is backfill syncing, handle_syncing_process_block (crates/common/chain/lean/src/service.rs) stores every gossiped block in the pending-blocks table with no check on its slot. A block whose slot is far past the wall clock is stored like any other.

Problem: one such block keeps the node in Syncing for good.

  • Every node starts in SyncStatus::Syncing. Until it is Synced, the chain service doesn't tick the fork-choice store and ignores every gossiped attestation and aggregated attestation.
  • should_switch_to_synced refuses the handoff while the pending-blocks table is non-empty.
  • prune_stale_pending_blocks removes a pending block only once it is imported or finalization passes its slot. Finalization never reaches a slot like 2^40, and the forward-sync wall-clock purge only covers roots in a backfill queue. So the block is never removed.

Any peer can send this while a node is starting up or catching up. The block needs no valid parent, proposer, or signature. The node then never switches to Synced, so its fork choice stops following the network's votes for good.

How was it fixed?

  • handle_syncing_process_block ignores a gossiped block whose slot is more than one past the wall-clock slot, before storing it. This is the horizon block import already applies (Block too far in future, fork_choice/lean/src/store.rs) and the forward syncer uses (BlockAheadOfWallClock). It is leanSpec's BLOCK_TOO_FAR_IN_FUTURE rule. A legitimate block is never more than one slot ahead, so nothing real is dropped.

  • New test test_far_future_gossip_block_does_not_block_synced_handoff: it builds a syncing service, gossips a block at slot 2^40 with a made-up parent, runs prune_stale_pending_blocks, and checks that should_switch_to_synced can pass. The test is its own commit and fails on current master:

    panicked at crates/common/chain/lean/src/service.rs:3586:9:
    a block from a slot far past the wall clock must not block the Synced handoff
    

Checks run:

  • cargo test -p ream-chain-lean --no-default-features --features devnet5: 35 passed.
  • cargo clippy -p ream-chain-lean --all-targets --no-default-features --features devnet5 -- --deny warnings: passes.
  • cargo +nightly fmt --all -- --check: passes.

Only ream-chain-lean changed, so I did not run the full workspace make test.

To-Do

@dimka90

dimka90 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@KolbyML can you look into this?

This branch has not been deployed

No deployments
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