Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Conversation

@avalonche
Copy link
Contributor

@avalonche avalonche commented Mar 23, 2023

📝 Summary

ethereum/beacon-APIs#305 Beacon API has introduced SSE subscriptions for payload attributes such that block building can be triggered from this event stream instead of a custom block trigger in the flashbots prysm fork.

📚 References



beaconClient := NewBeaconClient(cfg.BeaconEndpoint, cfg.SlotsInEpoch, cfg.SecondsInSlot)
var beaconClient IBeaconClient
if cfg.BeaconEndpoint != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make sense to run the builder service without a beacon configured?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that would break backwards compatibility. This allows the optionality to use the our old method of prysm block building during testing by not subscribing to the SSE endpoint.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why though?
The old code seems to always construct a beacon client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the old code would construct the beacon client with an empty url and only fail if the local relay is used.


// SubscribeToPayloadAttributesEvents subscribes to payload attributes events to validate fields such as prevrandao and withdrawals
func (b *BeaconClient) SubscribeToPayloadAttributesEvents(payloadAttrC chan types.BuilderPayloadAttributes) {
payloadAttributesResp := &struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This got to be put somewhere as a regular structure :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add in attestant types!


for {
client := sse.NewClient(eventsURL)
err := client.SubscribeRaw(func(msg *sse.Event) {
Copy link
Collaborator

@Ruteri Ruteri Mar 24, 2023

Choose a reason for hiding this comment

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

Would it be better if the callback was a standalone function?

@avalonche avalonche changed the base branch from capella-1.11.5 to main March 30, 2023 15:26
avalonche and others added 2 commits April 4, 2023 04:04
* Add handling multiple beacon clients

* Initialize stop channel in builder.Builder

* fix withdrawals array pointer

* Build on a single head (#59)

* Build on a single head

* Forcibly stop building process for old sse events

---------

Co-authored-by: avalonche <[email protected]>
if b.slotCtxCancel != nil {
b.slotCtxCancel()
}
// Forcibly cancel previous building job, build on top of reorgable blocks as this is the behaviour relays expect.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain why "buidling on multiple tips" is no longer necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is, it just doesn't work with how relays are set up. This will come back shortly after Capella.

@avalonche avalonche merged commit d3b034a into main Apr 10, 2023
@avalonche avalonche deleted the sse-subscription branch April 10, 2023 17:25
@aaroua5 aaroua5 mentioned this pull request Jun 23, 2023
avalonche added a commit that referenced this pull request Jul 6, 2023
* Add SSE subscription to builder

* withdrawals marshalling

* add stop channel

* pr comments

* Add handling multiple beacon clients (#57)

* Add handling multiple beacon clients

* Initialize stop channel in builder.Builder

* fix withdrawals array pointer

* Build on a single head (#59)

* Build on a single head

* Forcibly stop building process for old sse events

---------

Co-authored-by: avalonche <[email protected]>

* linting

---------

Co-authored-by: Mateusz Morusiewicz <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants