Fix Bellatrix Helpers to Work With Both Blinded and Full Blocks #11019
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What does this PR do? Why is it needed?
As part of #11010, we noticed there are several helper functions in the codebase and uses of
ExecutionPayload
that ignore blinded beacon blocks. For example, Optimistic Sync has a critical helper function that checks if a block is execution enabled. This function only works on full, Bellatrix beacon blocks and fails on blinded ones. This PR audits all uses of execution payloads in the codebase and ensures everything is updated to work with blinded beacon blocks as well.In some previous code review from #11010, it was noted how we should differentiate between blocks that have an execution payload and those that have an execution payload header. For example, let's say we want to write a function that takes in a beacon block and tells us the
BlockHash
of the execution payload contained within. Here's how we do it today:This only works if the block has an
ExecutionPayload
field. However, Bellatrix blinded beacon blocks haveExecutionPayloadHeader
which should work just fine. We have a few options available to get both full Bellatrix and blinded Bellatrix blocks to work with this function.Option A: Duplication
The first option is to duplicate our code like this:
Option B: Use block versioning schemes
Option C: Use type assertions
Option D: Turn the execution payload field of a block body into an interface
Option E: Use the Golang Error Pattern
Our goals are:
We argue options A, B, C do not meet these goals because they require significant maintenance, awareness of future block versions, and can manifest bugs at runtime rather than in CI / development pipelines.
We suggest Option D because it is
database/sql
package from the standard library is a good exampleWe also say that Option E is a solid direction, as it helps keep things clean. However, this introduces a lot more error checks and dealing with interfaces in our consensus-types package.
Which issues(s) does this PR fix?
Part of #10589