Skip to content

Conversation

@taratorio
Copy link
Member

@taratorio taratorio commented Sep 3, 2025

fixes #16973

The problem is that in the fork validator we always return consensus.ErrInvalidBlock when running the sync loop via StateStep fails:

if err := stages2.StateStep(ctx, chainReader, backend.engine, txc, stateSync, header, body, unwindPoint, headersChain, bodiesChain, config.ImportMode); err != nil {
	logger.Warn("Could not validate block", "err", err)
	return errors.Join(consensus.ErrInvalidBlock, err)
}

We already correctly mark the blocks as invalid (when they are indeed invalid) and always unwind with a BadBlock UnwindReason in those situations.

So we can make use of that and simply pass up the consensus.ErrInvalidBlock from the BadBlock UnwindReason up to the caller of the sync loop Run and RunNoInterupt functions. This way when we call Run from a fork choice update it can return consensus.ErrInvalidBlock correctly. Note that for the fork choice update code path we do not return an err from the sync loop run when we hit a bad block (we only unwind with a bad block reason) - because we run it with badBlockHalt: false.

For the StateStep flow - it runs the execution loop with badBlockHalt: true. That code path always returns the err so we need to make sure that all relevant error paths return ErrInvalidBlock when they should - then we can get rid of the the logic that always does errors.Join(consensus.ErrInvalidBlock, err) return for every error from StateStep.

Other parts (inside StateStep) that return consensus.ErrInvalidBlock are:

  • errors from engine.VerifyHeader (in addAndVerifyBlockStep) - as expected
  • errors from engine.VerifyUncles (in addAndVerifyBlockStep) - as expected

All other errors returned are operational errors and not consensus.ErrInvalidBlock errors.

@yperbasis yperbasis added this to the 3.2.0 milestone Sep 5, 2025
@taratorio taratorio changed the title [DO-NOT-MERGE] execution: more accurate bad block responses execution: more accurate bad block responses Sep 5, 2025
@taratorio taratorio enabled auto-merge (squash) September 9, 2025 10:55
@taratorio taratorio merged commit f026523 into main Sep 9, 2025
18 checks passed
@taratorio taratorio deleted the fix-bad-block-on-termination branch September 9, 2025 11:23
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.

Invalid payload validator error on teku

3 participants