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

SSE for payload attributes #305

Merged
merged 3 commits into from
Feb 28, 2023

Conversation

michaelsproul
Copy link
Collaborator

Closes #244.

Define a new server sent event (SSE) for payload attributes.

The difficult part of specifying this event was deciding on an encoding for the payload attributes. Payload attributes presently only exist in the execution-specs repo where they are always encoded with camelCase idents and big-endian hex integers. We have two options for encoding them here:

  1. Use the execution-apis encoding and break consistency with the rest of beacon-apis.
  2. Define a new encoding for payload attributes here in order to maintain consistency.

There are pros and cons in favour of each approach. Option (1) potentially minimises the number of encodings that clients need to maintain for the payload attributes data structure, which could be good for implementation complexity. On the other hand, the break in consistency might make it hard for implementations to use a different encoding for just these fields. After discussions with @rolfyone we came to the conclusion that the consistency of option (2) is preferable, and not difficult to implement in either Lighthouse or Teku. We would like feedback from other CL devs about their preference as well.

The way the events are currently specified is quite loose, so I've added some extra descriptive text to convey the choice of encoding as clearly as possible. Perhaps in future it would be good to clean up the events API so that the returned events are given full schemas in their own right.

@rolfyone
Copy link
Collaborator

Looks good, didn't mark approved, will let others take a look first so any discussions can happen...

apis/eventstream/index.yaml Outdated Show resolved Hide resolved
Copy link
Collaborator

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Is the node expected to emit this event for the blocks its connected validators want to propose or for every slot?

What should suggested_fee_recipient be set too? If the previous question is true then the response should be agnostic of who is connected to the bn so spec it to set to 0 address always

@michaelsproul
Copy link
Collaborator Author

michaelsproul commented Feb 25, 2023

@dapplion In my PoC implementation I've added a flag to cause payload attributes to be sent with every fcU. Without that flag Lighthouse would just send payload attributes for the blocks it is proposing. I don't think it matters what the fee recipient is set to as the builders should be ignoring that anyway. IMO the BNs driving block builders should probably be distinct from the ones used by validators but if someone did want to do this they could configure their real fee recipient in their BN config and use that for everything. In other words I think it would be overkill and less flexible to mandate setting it to 0.

g11tech
g11tech previously approved these changes Feb 25, 2023
Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

@dapplion it should be pretty easy to add this event in the proposed (ssz json format) for on prepareNextSlot which we run in last 1/3 part of the slot to usually send a block building fcU (for next slot)
Adding a flag as suggested by @michaelsproul sounds reasonable. 👍

mcdee
mcdee previously approved these changes Feb 25, 2023
Copy link
Member

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

looking good!

Comment on lines +104 to +110
- `proposal_slot`: the slot at which a block using these payload attributes may be
built.
- `parent_block_root`: the beacon block root of the parent block to be built upon.
- `parent_block_number`: the execution block number of the parent block.
- `parent_block_hash`: the execution block hash of the parent block.
- `proposer_index`: the validator index of the proposer at `proposal_slot` on
the chain identified by `parent_block_root`.
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason we have all of this data, instead of just the minimum required data?

following the lead of the builder APIs, we can uniquely identify a proposal with the tuple (proposal_slot, proposer_index, parent_block_hash)

which suggests we can drop parent_block_root and parent_block_number

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ralexstokes I figured the block number is useful for stateless dummy builders that just return empty payloads. We use such a builder to run blockprint. It wouldn't be hard to track the block number but it would require separately looking up data from a CL/EL.

The parent block root is potentially interesting to differentiate the case where an identical payload ends up in two competing beacon blocks. Although arguably this case shouldn't be differentiated because the EL state is identical. Another reason to keep it is that it grounds the data in something CL-related, so if the receiver wants to look up more info from the beacon API they have a concrete reference point (a slot is ambiguous, and a payload hash isn't natively understood).

Copy link
Member

Choose a reason for hiding this comment

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

makes sense, if everyone else thinks they pull their own weight then lets leave them in

@dapplion
Copy link
Collaborator

@dapplion In my PoC implementation I've added a flag to cause payload attributes to be sent with every fcU. Without that flag Lighthouse would just send payload attributes for the blocks it is proposing. I don't think it matters what the fee recipient is set to as the builders should be ignoring that anyway. IMO the BNs driving block builders should probably be distinct from the ones used by validators but if someone did want to do this they could configure their real fee recipient in their BN config and use that for everything. In other words I think it would be overkill and less flexible to mandate setting it to 0.

Sounds reasonable to me. Please could you mention that in the spec?

@michaelsproul
Copy link
Collaborator Author

Thanks @dapplion, added a comment just now in cb15cac

Copy link
Collaborator

@rolfyone rolfyone left a comment

Choose a reason for hiding this comment

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

LGTM, and looks like general approval...

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.

SSE subscription for newPayload event to trigger block building
7 participants