Skip to content

Conversation

@eserilev
Copy link
Member

@eserilev eserilev commented Jun 11, 2024

Issue Addressed

Which issue # does this PR address?

Partially #3651

Proposed Changes

This doc details how a LightClientBootstrap object can be stored in chunks so that it can then be served later on without any expensive computations/db queries
https://hackmd.io/@dapplion/BkxPbc6eQT

To summarize

  • LightClientHeader can be constructed by fetching the full block. Blocks are already stored by root and are available forever. Fetching a single block by root isn't that expensive of a db query
  • We'll start storing SyncCommitteeBranch in the db, keyed off the block root
  • SyncCommittee will also be stored in the db, keyed off the sync committee period.
    • If were fetching a LightClientBootstrap from the current finalized period, we can construct the SyncCommittee from the current state, since fetching the current beacon state is cheap
    • else we fetch the SyncCommittee from the db.

Additional Info

This PR builds off of #5545.
#5545 should be merged before this PR

@eserilev eserilev added the work-in-progress PR is a work-in-progress label Jun 11, 2024
@eserilev
Copy link
Member Author

This PR is in a good spot for another review. The pruning logic has been simplified, the bootstrap tests are passing and I've done a bit of tweaking to the test infra to make light client testing a bit easier in general. I am planning on writing some specific tests related to the pruning logic. I'm also planning on running a mainnet node with light client enabled and compare I/O + disk usage vs a node w/ light client disabled. If its a negligible difference it'd be cool to just enable light clients by default

}

if epoch_boundary_blocks.contains(&block_root) {
non_checkpoint_block_roots.remove(&block_root);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Much cleaner <3

The intended logic is:

no skipped slot

  • Slot 2/1 root C : Add C to non_checkpoint_block_roots
  • Slot 2/0 root B : Add B to epoch_boundary_blocks
  • Slot 1/31 root A : Add A to non_checkpoint_block_roots

slot 31 skipped

  • Slot 2/1 root C : Add C to non_checkpoint_block_roots
  • Slot 2/0 root A : Add A to epoch_boundary_blocks
  • Slot 1/31 root A : Add A to non_checkpoint_block_roots, remove A from non_checkpoint_block_roots

slot 0 skipped

  • Slot 2/1 root B : Add B to non_checkpoint_block_roots
  • Slot 2/0 root B : Add B to epoch_boundary_blocks, remove B from non_checkpoint_block_roots
  • Slot 1/31 root A : Add A to non_checkpoint_block_roots

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.

Good to go! Thank you @eserilev for driving this 🙏

Approve PR now,
Sync and store with no delay,
Light shines on the chain.

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

@mergify queue

@michaelsproul michaelsproul added the v6.0.0 New major release for hierarchical state diffs label Sep 9, 2024
@mergify
Copy link

mergify bot commented Sep 9, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at a94b12b

mergify bot added a commit that referenced this pull request Sep 9, 2024
@mergify mergify bot merged commit a94b12b into sigp:unstable Sep 10, 2024
chong-he pushed a commit to chong-he/lighthouse that referenced this pull request Nov 26, 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

* fetch bootstrap without always querying for state

* storing bootstrap parts in db

* mroe code cleanup

* test

* prune sync committee branches from dropped chains

* 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

* resovle merge conflict

* add electra bootstrap logic, add logic to cache current sync committee

* add latest sync committe branch cache

* 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

* merge conflict

* add better error messaging

* resolve merge conflicts

* remove lc update from basicsim

* rename sync comittte variable and fix persist condition

* refactor get_light_client_update logic

* add better comments, return helpful error messages over http and rpc

* pruning canonical non checkpoint slots

* fix test

* rerun test

* update pruning logic, add tests

* fix tests

* fix imports

* fmt

* refactor db code

* Refactor db method

* Refactor db method

* add additional comments

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

* fix merge

* linting

* merge conflict

* prevent overflow

* enable lc server for http api tests

* fix tests

* remove prints

* remove warning

* revert change
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. v6.0.0 New major release for hierarchical state diffs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants