Skip to content

fix(lean): bound block slot before the state transition in on_block - #1501

Merged
Kayden-ML merged 1 commit into
ReamLabs:masterfrom
zemse:fix/lean-block-slot-upper-bound
Jul 7, 2026
Merged

fix(lean): bound block slot before the state transition in on_block#1501
Kayden-ML merged 1 commit into
ReamLabs:masterfrom
zemse:fix/lean-block-slot-upper-bound

Conversation

@zemse

@zemse zemse commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What was wrong?

Based on leanEthereum/leanSpec#1182

Proposer for a block is slot % num_validators. So a malicious proposer can sign a valid lean block at high slot number where block.slot % num_validators == validator_index.

The on_block has no upper bound on the block.slot and when such a malicious block is imported, the following while loop runs for a huge number of iterations.

while self.slot < target_slot {

While it rejects later in process_block_header however honest validator has already burned CPU on high number of iterations due to the malicious block.

How was it fixed?

Two guards are added in the on_block so that such a malicious block is rejected before it gets into state_transition call.

  • Parent-gap cap: reject block.slot − parent.slot > MAX_HISTORICAL_BLOCK_HASHES i.e. 2^18.
  • Clock horizon: reject block.slot > current_slot + 1, keeping far-future blocks out of the store.

To-Do

@Kayden-ML

Copy link
Copy Markdown
Contributor

@zemse can you rebase your pr

@zemse
zemse force-pushed the fix/lean-block-slot-upper-bound branch from 0ba8cab to d70e86c Compare July 7, 2026 05:42
@zemse

zemse commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Just rebased over latest master

@Kayden-ML Kayden-ML 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.

Looks good 👍

@Kayden-ML
Kayden-ML added this pull request to the merge queue Jul 7, 2026
Merged via the queue into ReamLabs:master with commit f236620 Jul 7, 2026
29 of 60 checks passed
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