Skip to content

Check the bad block manager when receiving a new block from the network#10212

Open
daniellehrner wants to merge 5 commits intobesu-eth:mainfrom
daniellehrner:fix/avoid_bad_ancestor_endless_loop
Open

Check the bad block manager when receiving a new block from the network#10212
daniellehrner wants to merge 5 commits intobesu-eth:mainfrom
daniellehrner:fix/avoid_bad_ancestor_endless_loop

Conversation

@daniellehrner
Copy link
Copy Markdown
Contributor

PR description

When we get a fcu request and need to sync missing blocks from our peers, we currently are not checking if any of those blocks is already in the bad block manager. This leads to an endless loop where we try to import an invalid block every few milliseconds.

This PR adds this check and marks all following blocks on this specific forks as invalid as well. Like this we can respond with INVALID when the next fcu request is received and correctly signal to the CL that we consider this fork invalid.

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests
  • hive tests: Engine or other RPCs modified?

Copilot AI review requested due to automatic review settings April 10, 2026 07:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds safeguards to avoid repeatedly attempting to import blocks already marked as bad, preventing sync loops and enabling correct INVALID signaling for poisoned forks.

Changes:

  • Short-circuit new block and new block hash handling when the block hash is already in BadBlockManager.
  • Add a defensive short-circuit at the start of importOrSavePendingBlock for known-bad blocks.
  • Add unit tests around block propagation skipping, plus an integration test covering engine_forkchoiceUpdated behavior with bad ancestors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java Adds known-bad-block checks in network handlers and import path to avoid reprocessing invalid blocks.
ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/AbstractBlockPropagationManagerTest.java Adds tests asserting known-bad blocks are skipped before entering the import/request pipeline.
ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedBadAncestorIntegrationTest.java Adds end-to-end test verifying bad-ancestor propagation yields INVALID with correct latestValidHash.

@daniellehrner daniellehrner force-pushed the fix/avoid_bad_ancestor_endless_loop branch from e5fc0fd to 7e6a33e Compare April 10, 2026 08:40
…rk. This allows to mark a whole fork invalid and signaling this to the CL at the next fcu

Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
@daniellehrner daniellehrner force-pushed the fix/avoid_bad_ancestor_endless_loop branch from 7e6a33e to ca65d08 Compare April 10, 2026 08:41
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
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