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

[WIP] Optimise no-op builder #3

Merged
merged 2 commits into from
Sep 13, 2022

Conversation

michaelsproul
Copy link
Contributor

This PR updates the empty-payload builder so that it can build payloads without receiving a prior validator registration.

For blockdreamer I need a builder that will return a dummy payload at every slot as quickly as possible. Bypassing the registration step is essential, as blockdreamer never has the ability to sign as the true proposer.

I've added a flag --default-fee-recipient which specifies a fee recipient to be used in when the registration is missing.

@michaelsproul
Copy link
Contributor Author

The issue I'm having currently is that the call to get_params is taking way too long, around 2 seconds on Goerli. Most of this seems to be for loading the head state to get the prev_randao here:

https://github.com/realbigsean/lighthouse/blob/d35934df2c7cdcb692e6f1c09d9f387f5d9e8972/beacon_node/execution_layer/src/test_utils/mock_builder.rs#L359-L364

It seems like a huge pain to have to load a state to get the prev_randao, and I think we're probably not the only ones to notice this. I think it would be great to have a standard API on the beacon node like /eth/v1/beacon/states/{state_id}/randao/{epoch} to accelerate this. Then the process for dummy payload creation could be:

  • Fetch head beacon block: this determines block_number and parent_hash (if we want to check that). It gives us the state_root of the head.
  • Using state_root: fetch the randao mix for the current epoch. The state_root should match the head so this call should be fast.

Other/alternative avenues for optimisation:

  • Try SSZ requests in get_params rather than JSON (alternative)
  • Avoid transporting the exec payload by fetching a blinded block for the head. There's no endpoint for this, but I think it would be a good candidate for standardisation and early impl in Lighthouse.
  • Cache these parameters ahead of time (every slot?)
  • Cache these parameters between requests. For my purposes I'm likely to request the same dummy payload several times, once for each connected BN.

@michaelsproul
Copy link
Contributor Author

@michaelsproul michaelsproul changed the title [WIP] Build empty payloads without registration [WIP] Optimise no-op builder Sep 13, 2022
@michaelsproul
Copy link
Contributor Author

This is working well for my purposes, fetching data from the BN only takes ~5ms now.

It's a pretty big pile of hacks though, so I'm happy for this to remain as an open PR.

The version of Lighthouse I'm depending on has all of these changes merged into it:

@realbigsean
Copy link
Owner

It's a pretty big pile of hacks though, so I'm happy for this to remain as an open PR.

I think it's great! The hacks actually fit right in because mock-relay itself is a hack 😂

@realbigsean realbigsean merged commit 4a70e4e into realbigsean:main Sep 13, 2022
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