-
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
payload attribute computations in event handler #14963
base: develop
Are you sure you want to change the base?
Conversation
…py path unit test for code coverage
} | ||
}() | ||
if lr == nil { | ||
log.Warn("event stream skipping a nil lazy event reader callback") |
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.
log.Warn("event stream skipping a nil lazy event reader callback") | |
log.Warn("Event stream skipping a nil lazy event reader callback") |
r := lr() | ||
if r == nil { | ||
log.Warn("event stream skipping a nil event reader") |
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.
log.Warn("event stream skipping a nil event reader") | |
log.Warn("Event stream skipping a nil event reader") |
// all of the checked fields empty, so the logical short circuit should hit immediately. | ||
func needsFill(ev payloadattribute.EventData) bool { | ||
return ev.HeadState == nil || ev.HeadState.IsNil() || | ||
ev.HeadState.LatestBlockHeader() == nil || ev.HeadState.LatestBlockHeader() == nil || |
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.
ev.HeadState.LatestBlockHeader() == nil
is checked twice
attr, err := s.computePayloadAttributes(ctx, ev) | ||
ev.HeadState, err = s.HeadFetcher.HeadState(ctx) | ||
if err != nil { | ||
return ev, errors.Wrap(err, "Could not get head state") |
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.
return ev, errors.Wrap(err, "Could not get head state") | |
return ev, errors.Wrap(err, "could not get head state") |
|
||
ev.HeadBlock, err = s.HeadFetcher.HeadBlock(ctx) | ||
if err != nil { | ||
return ev, errors.Wrap(err, "Could not look up head block") |
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.
return ev, errors.Wrap(err, "Could not look up head block") | |
return ev, errors.Wrap(err, "could not look up head block") |
} | ||
ev.HeadRoot, err = ev.HeadBlock.Block().HashTreeRoot() | ||
if err != nil { | ||
return ev, errors.Wrap(err, "Could not compute head block root") |
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.
return ev, errors.Wrap(err, "Could not compute head block root") | |
return ev, errors.Wrap(err, "could not compute head block root") |
|
||
hsr, err := ev.HeadState.LatestBlockHeader().HashTreeRoot() | ||
if err != nil { | ||
return ev, errors.Wrap(err, "Could not compute latest block header root") |
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.
return ev, errors.Wrap(err, "Could not compute latest block header root") | |
return ev, errors.Wrap(err, "could not compute latest block header root") |
if err != nil { | ||
return ev, errors.Wrap(err, "Could not compute payload attributes") | ||
return ev, errors.Wrap(err, "Could not run process blocks on head state into the proposal slot epoch") |
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.
return ev, errors.Wrap(err, "Could not run process blocks on head state into the proposal slot epoch") | |
return ev, errors.Wrap(err, "could not run process blocks on head state into the proposal slot epoch") |
|
||
payload, err := ev.HeadBlock.Block().Body().Execution() | ||
if err != nil { | ||
return ev, errors.Wrap(err, "Could not get execution payload for head block") |
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.
return ev, errors.Wrap(err, "Could not get execution payload for head block") | |
return ev, errors.Wrap(err, "could not get execution payload for head block") |
// the fcu args have differing amounts of completeness based on the code path, | ||
// and there is work we only want to do if a client is actually listening to the events beacon api endpoint. | ||
// temporary solution: just fire a blank event and fill in the details in the api handler. |
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.
Removing the cfg
parameter means that in case of firing from notifyForkchoiceUpdate
you have to do extra work in the handler, since you need to recompute what you already have available. What about leaving the parameter and filling event data only when cfg != nil
? You can then pass nil as the value in lateBlockTasks
.
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
This fixes the payload attribute event bugs referenced here:
#14644 (comment)
Other notes for review
Further testing is required, particularly if head is far behind, process_slots can timeout and trigger errors in the event stream response, which may need additional handling.
Acknowledgements