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

Persist light client updates #5545

Merged
merged 56 commits into from
Aug 9, 2024

Conversation

eserilev
Copy link
Collaborator

@eserilev eserilev commented Apr 9, 2024

Issue Addressed

Partially #3651

Proposed Changes

This PR aims to persist light client updates. Once persisted, this will allow lighthouse nodes to serve them over RPC.

@eserilev eserilev added light-client work-in-progress PR is a work-in-progress labels Apr 9, 2024
@eserilev eserilev added the ready-for-review The code is ready for review label May 27, 2024
@eserilev eserilev marked this pull request as ready for review May 27, 2024 18:03
@jimmygchen jimmygchen removed the work-in-progress PR is a work-in-progress label May 28, 2024
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.

Overall looks good! Two points:

We should run the specs tests for the is_better_update function, see here https://github.com/ethereum/consensus-specs/blob/dev/tests/formats/light_client/update_ranking.md

The function under which updates are computed only gets triggered for recent blocks. See

// Do not trigger light_client server update producer for old blocks, to extra work
// during sync.
if self.config.enable_light_client_server
&& block_delay_total < self.slot_clock.slot_duration() * 32
{

Now that the LC server computes recent updates AND full updates, the latter should include historical updates. Therefore we should be producing updates during forward range sync. Also for backfill sync, but that's a feature for another PR :)

beacon_node/beacon_chain/src/light_client_server_cache.rs Outdated Show resolved Hide resolved
beacon_node/beacon_chain/src/light_client_server_cache.rs Outdated Show resolved Hide resolved
beacon_node/beacon_chain/src/light_client_server_cache.rs Outdated Show resolved Hide resolved
@eserilev eserilev added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels May 30, 2024
@dapplion
Copy link
Collaborator

Same CI failures

FAIL [   4.186s] beacon_chain::beacon_chain_tests store_tests::light_client_updates_test
FAIL [   1.187s] ef_tests::tests light_client_update

And the basic simulator

@eserilev
Copy link
Collaborator Author

eserilev commented Aug 1, 2024

Since the fork epoch boundaries in basic-sim aren't multiples of 256, the light client periods dont align with the fork boundaries. We end up getting some BeaconStateError::IncorrectStateVariant when constructing light client updates

I've gotten the basic-sim tests to pass by moving the light client update logic to the bottom of recompute_and_cache_updates. This prevents the light client update stuff from affecting optimistic and finality update

I've also completely removed any checks related to light client updates in basic-sim. I've kept the test vectors related to optimistic and finality updates. I think we have enough light client update test coverage in other places to live with this for now...

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.

Pushed a commit with:

  • Clean up two info statements likely there from debugging
  • Remove pub where possible
  • A few cosmetic nits

PR is good to go and passing tests :)

@jimmygchen jimmygchen added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Aug 9, 2024
Copy link
Member

@jimmygchen jimmygchen left a comment

Choose a reason for hiding this comment

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

LGTM too!

@jimmygchen
Copy link
Member

@mergify queue

Copy link

mergify bot commented Aug 9, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 3913ea4

@mergify mergify bot merged commit 3913ea4 into sigp:unstable Aug 9, 2024
28 checks passed
AgeManning pushed a commit to AgeManning/lighthouse that referenced this pull request Sep 3, 2024
* persist light client updates

* update beacon chain to serve light client updates

* resolve todos

* cache best update

* extend cache parts

* is better light client update

* resolve merge conflict

* initial api changes

* add lc update db column

* fmt

* added tests

* add sim

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into persist-light-client-updates

* fix some weird issues with the simulator

* tests

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into persist-light-client-updates

* test changes

* merge conflict

* testing

* started work on ef tests and some code clean up

* update tests

* linting

* noop pre altair, were still failing on electra though

* allow for zeroed light client header

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into persist-light-client-updates

* merge unstable

* remove unwraps

* remove unwraps

* Update light_client_update.rs

* merge unstable

* move functionality to helper methods

* refactor is best update fn

* refactor is best update fn

* improve organization of light client server cache logic

* fork diget calc, and only spawn as many blcoks as we need for the lc update test

* fetch lc update from the cache if it exists

* fmt

* Fix beacon_chain tests

* Add debug code to update ranking_order ef test

* Fix compare code

* merge conflicts

* fix test

* Merge branch 'persist-light-client-updates' of https://github.com/eserilev/lighthouse into persist-light-client-updates

* Use blinded blocks for light client proofs

* fix ef test

* merge conflicts

* fix lc update check

* Lint

* resolve merge conflict

* Merge branch 'persist-light-client-updates' of https://github.com/eserilev/lighthouse into persist-light-client-updates

* revert basic sim

* small fix

* revert sim

* Review PR

* resolve merge conflicts

* Merge branch 'unstable' into persist-light-client-updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
light-client ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants