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

Endpoint for state RANDAO mix #242

Merged
merged 3 commits into from
Oct 11, 2022
Merged

Conversation

michaelsproul
Copy link
Collaborator

Add an endpoint to fetch the RANDAO mix from a given state at some epoch.

The endpoint path is /eth/v1/beacon/states/{state_id}/randao.

With the merge the RANDAO mix has taken on increased significance, as it is embedded in execution payloads and available in the EVM.

Currently for tools that want to access the prev_randao from outside the beacon node for the purposes of payload construction or validation, they must load an entire beacon state using the debug endpoint. This is prohibitively slow for something that should be fast with the right API.

With this API, they can immediately get access to the correct prev_randao value using /eth/v1/beacon/states/head/randao prior to block construction (or can use the state_id corresponding to the parent block).

Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

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

should there be a bound on state accessor or is it fine/easy to do for any depth?

apis/beacon/states/randao.yaml Outdated Show resolved Hide resolved
@michaelsproul
Copy link
Collaborator Author

should there be a bound on state accessor or is it fine/easy to do for any depth?

Like the other state APIs it depends on the node's configuration & pruning settings. In Lighthouse's default config these queries will be fast close to the head, and unavailable for most historic states unless the user has opted into reconstructing and storing them (in which case they could be slow or fast).

@michaelsproul
Copy link
Collaborator Author

This is ready for review again

@riposteX
Copy link

riposteX commented Oct 6, 2022

Any chance you could also return the beacon node's current slot in the response?

Otherwise you may not be receiving the randao you're expecting.

dapplion
dapplion previously approved these changes Oct 7, 2022
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.

LGTM!

@michaelsproul
Copy link
Collaborator Author

michaelsproul commented Oct 10, 2022

@riposteX For consistency with the other state APIs I'd prefer to leave the slot out. If you want to be sure of the state from which you're drawing the RANDAO mix you can use the state_id to specify one. A good method for reliably getting the head's RANDAO mix is to listen for the head event on the SSE endpoint (https://ethereum.github.io/beacon-APIs/#/Events/eventstream), and then query for the RANDAO mix using the state root you get from there.

For block building there's also work to standardise a new event type with all the required information: #244.

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

@rolfyone rolfyone merged commit cc04d0e into ethereum:master Oct 11, 2022
@michaelsproul michaelsproul deleted the state-randao branch October 11, 2022 11:10
bors bot pushed a commit to sigp/lighthouse that referenced this pull request Nov 10, 2022
## Issue Addressed

ethereum/beacon-APIs#241
ethereum/beacon-APIs#242

## Proposed Changes

Implement two new endpoints for fetching blinded blocks and RANDAO mixes.


Co-authored-by: realbigsean <sean@sigmaprime.io>
bors bot pushed a commit to sigp/lighthouse that referenced this pull request Nov 11, 2022
## Issue Addressed

ethereum/beacon-APIs#241
ethereum/beacon-APIs#242

## Proposed Changes

Implement two new endpoints for fetching blinded blocks and RANDAO mixes.


Co-authored-by: realbigsean <sean@sigmaprime.io>
bors bot pushed a commit to sigp/lighthouse that referenced this pull request Nov 11, 2022
## Issue Addressed

ethereum/beacon-APIs#241
ethereum/beacon-APIs#242

## Proposed Changes

Implement two new endpoints for fetching blinded blocks and RANDAO mixes.


Co-authored-by: realbigsean <sean@sigmaprime.io>
macladson pushed a commit to macladson/lighthouse that referenced this pull request Jan 5, 2023
## Issue Addressed

ethereum/beacon-APIs#241
ethereum/beacon-APIs#242

## Proposed Changes

Implement two new endpoints for fetching blinded blocks and RANDAO mixes.


Co-authored-by: realbigsean <sean@sigmaprime.io>
Woodpile37 pushed a commit to Woodpile37/lighthouse that referenced this pull request Jan 6, 2024
## Issue Addressed

ethereum/beacon-APIs#241
ethereum/beacon-APIs#242

## Proposed Changes

Implement two new endpoints for fetching blinded blocks and RANDAO mixes.


Co-authored-by: realbigsean <sean@sigmaprime.io>
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.

7 participants