Persist light client bootstrap (#5915)

* 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
This commit is contained in:
Eitan Seri-Levi
2024-09-09 17:27:49 -07:00
committed by GitHub
parent 51091a40fa
commit a94b12b4d5
19 changed files with 733 additions and 238 deletions

View File

@@ -153,7 +153,7 @@ impl ApiTester {
if !SKIPPED_SLOTS.contains(&slot) {
harness
.extend_chain(
.extend_chain_with_light_client_data(
1,
BlockStrategy::OnCanonicalHead,
AttestationStrategy::AllValidators,
@@ -1926,6 +1926,7 @@ impl ApiTester {
)
.unwrap();
assert_eq!(1, expected.len());
assert_eq!(result.clone().unwrap().len(), expected.len());
self
}
@@ -1933,19 +1934,26 @@ impl ApiTester {
pub async fn test_get_beacon_light_client_bootstrap(self) -> Self {
let block_id = BlockId(CoreBlockId::Finalized);
let (block_root, _, _) = block_id.root(&self.chain).unwrap();
let (block, _, _) = block_id.full_block(&self.chain).await.unwrap();
let result = match self
.client
.get_light_client_bootstrap::<E>(block_root)
.await
{
Ok(result) => result.unwrap().data,
Ok(result) => result,
Err(e) => panic!("query failed incorrectly: {e:?}"),
};
let expected = block.slot();
assert_eq!(result.get_slot(), expected);
assert!(result.is_some());
let expected = self
.chain
.light_client_server_cache
.get_light_client_bootstrap(&self.chain.store, &block_root, 1u64, &self.chain.spec);
assert!(expected.is_ok());
assert_eq!(result.unwrap().data, expected.unwrap().unwrap().0);
self
}