Add provider address to event data structs - #286
Open
AntiD2ta wants to merge 3 commits into
Open
Conversation
Allow consumers to identify which beacon node delivered each event.
AntiD2ta
force-pushed
the
add_event_provider
branch
from
March 25, 2026 16:58
880be93 to
d5ed32d
Compare
Bez625
requested changes
Mar 25, 2026
| // This is the universal mechanism for obtaining the provider address | ||
| // across all event types. Event structs owned by this package also | ||
| // carry the address directly in their Provider field. | ||
| func WithProvider(ctx context.Context, provider string) context.Context { |
Contributor
There was a problem hiding this comment.
I'm not a fan of the provider being passed in the context. I looked at vouch and I can only see us using head and block event handlers. I think let's limit this to updating the *Event structs to have the Provider field and set them where possible. Given we have explicit types at the callsite for these, we know if they have the Provider or not so it's type safe / requires no validation.
I think if we want this behaviour on the other handlers we should look to find reasons and upgrade them to returning *Event types that explicitly set the Provider.
Contributor
Author
|
Created #288 to address adding the Provider on consensus types event data structs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Provider stringfield to all owned event data structs:HeadEvent,BlockEvent,ChainReorgEvent,FinalizedCheckpointEvent,BlobSidecarEvent,BlockGossipEvent,PayloadAttributesEvent,DataColumnSidecarEvent, and the genericEventcontainerWithProvider/Providercontext helpers inapi/v1for universal provider extraction across all event typesNote that seven event types use
specstructs that model consensus data types (VersionedAttestation,AttesterSlashing, etc.) that should not carry aProviderfield.The context-based approach (
apiv1.WithProvider/apiv1.Provider) provides a universal mechanism that works for all 15 event types, while the struct field is a convenience for the 9 types we own.Example usage on Vouch
When the provider is available directly on the HeadEvent struct:
For event types that use external spec structs (e.g. attestations), where the struct can't carry the field, we can extract it from context instead:
The context mechanism (apiv1.Provider(ctx)) works for all 15 event types, so Vouch could use it universally if preferred. The struct field is a convenience for the 8 owned types.