Skip to content

Implement head v2 events for validator clients - #11130

Open
Matilda-Clerke wants to merge 4 commits into
Consensys-Incorporated:masterfrom
Matilda-Clerke:implement-head-v2-events-for-validator-clients
Open

Implement head v2 events for validator clients#11130
Matilda-Clerke wants to merge 4 commits into
Consensys-Incorporated:masterfrom
Matilda-Clerke:implement-head-v2-events-for-validator-clients

Conversation

@Matilda-Clerke

@Matilda-Clerke Matilda-Clerke commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

PR Description

Allow validator clients to listen to head_v2 events to address a Cursor bot comment in #11127


Note

Medium Risk
Changes validator head-event handling and timing triggers; subscribing to both head and head_v2 could duplicate duty signals if the beacon node emits both for the same head.

Overview
Validator clients now subscribe to head_v2 on the beacon node events stream alongside the existing head topic, and handle incoming head_v2 payloads.

A new HeadV2Event type deserializes the v2 JSON (including payload_status and the other v2 fields). handleHeadV2Event drives the same ValidatorTimingChannel updates as headonHeadUpdate and optional early attestation via onAttestationCreationDue—using slot, duty roots, and block root only.

Subscription URL expectations in EventSourceBeaconChainEventAdapterTest are updated so both head topics appear in the topics query parameter.

Reviewed by Cursor Bugbot for commit 15407c0. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 0369dfd. Configure here.

Builder::executionOptimistic)
.withField(
"payload_status", STRING_TYPE, HeadV2Event::payloadStatus, Builder::payloadStatus)
.build();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Head_v2 schema mismatch

High Severity

HeadV2Event.TYPE_DEFINITION does not match the wire format Teku emits for head_v2. The beacon node sends a versioned envelope (version + data) with current_epoch_dependent_root and next_epoch_dependent_root, but the client expects a flat payload using the legacy previous_duty_dependent_root / current_duty_dependent_root names. Every head_v2 message fails deserialization and is counted as an invalid event, so the new subscription never drives duty updates.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0369dfd. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

our head event structure may not be consistent on both sides of the wire by the sounds of this


final List<EventType> eventTypes = new ArrayList<>();
eventTypes.add(EventType.head);
eventTypes.add(EventType.head_v2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dual head event subscription

Medium Severity

The event stream subscribes to both head and head_v2. Beacon nodes emit both for the same head update during the transition, so a working head_v2 parser would invoke onHeadUpdate and onAttestationCreationDue twice per slot. Other clients prefer head_v2 with a fallback to head rather than listening to both at once.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0369dfd. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

im not sure how hard a fallback would be - if you subscribe and head_v2 isnt present, im not sure we'd know (except never seeing it) - maybe worth digging into...

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.

2 participants