Skip to content
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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open

Conversation

kasey
Copy link
Contributor

@kasey kasey commented Feb 19, 2025

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

@kasey kasey requested a review from a team as a code owner February 19, 2025 21:54
@james-prysm james-prysm changed the title WIP: payload attribute computations in event handler payload attribute computations in event handler Mar 3, 2025
@james-prysm james-prysm added API Api related tasks Bug Something isn't working labels Mar 3, 2025
// 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 ||
Copy link
Contributor

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

Comment on lines +177 to +179
// 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.
Copy link
Contributor

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.

Copy link
Contributor Author

@kasey kasey Mar 5, 2025

Choose a reason for hiding this comment

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

Doing it this way sidesteps several issues:

  • these code paths are already complex and error prone. let's minimize the amount of edge cases that could be coming in from callers that this function needs to anticipate.
  • timing concerns that could arise from the node passing into the next slot while the event waits in queue
  • concerns around head state being mutated / needing to make a copy
  • doing needless work when nothing is actually listening to the event. we have learned that most nodes in the wild are not subscribed to events, so it makes sense to defer all processing until we know the feed has a listener (in the event handler).

kasey and others added 3 commits March 5, 2025 15:20
Radek's PR suggestion to fix error/log capitalization.

Co-authored-by: Radosław Kapka <[email protected]>
@kasey kasey enabled auto-merge March 5, 2025 21:44
@kasey kasey disabled auto-merge March 5, 2025 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants