-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor getLocalPayloadAndBlobs
with New Helper getParentBlockHash
#12951
Conversation
1b7f0ed
to
f0077cc
Compare
func getParentBlockHashPostCapella(st state.BeaconState) ([]byte, error) { | ||
header, err := st.LatestExecutionPayloadHeader() | ||
if err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only errors that can ever be returned by LatestExecutionPayloadHeader()
is either errNotSupported+funcname
or ErrNilObjectWrapped
as there are two instances of the same call it may be better to add some additional information as to whether the failure is when retrieving the hash post Capella or below post merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
t, err := slots.ToTime(st.GenesisTime(), slot) | ||
if err != nil { | ||
return nil, nil, false, err | ||
} | ||
var attr payloadattribute.Attributer | ||
switch st.Version() { | ||
case version.Deneb: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side note, there don't appear to be any tests covering this case here.
807f063
to
5a25e9f
Compare
5a25e9f
to
fbb9680
Compare
Description
This pull request aims to improve the maintainability and readability of the
getLocalPayloadAndBlobs
function. The refactor introduces a new helper function,getParentBlockHash
, which streamlines the logic for fetching the parent block hash based on various conditions. This change aligns with the consensus spec as outlined in PR #3350.Key Changes
getParentBlockHash
to encapsulate the logic for obtaining the parent block hash.IsMergeTransitionComplete
check and fetches the parent block hash directly fromst.LatestExecutionPayloadHeader()
.activationEpochNotReached
andgetTerminalBlockHashIfExists
when necessary.