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

@@ -394,7 +394,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
Ok(Some((bootstrap, _))) => Ok(Arc::new(bootstrap)),
Ok(None) => Err((
RPCResponseErrorCode::ResourceUnavailable,
"Bootstrap not available",
"Bootstrap not available".to_string(),
)),
Err(e) => {
error!(self.log, "Error getting LightClientBootstrap instance";
@@ -404,7 +404,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
);
Err((
RPCResponseErrorCode::ResourceUnavailable,
"Bootstrap not available",
format!("{:?}", e),
))
}
},
@@ -429,7 +429,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
Some(update) => Ok(Arc::new(update)),
None => Err((
RPCResponseErrorCode::ResourceUnavailable,
"Latest optimistic update not available",
"Latest optimistic update not available".to_string(),
)),
},
Response::LightClientOptimisticUpdate,
@@ -453,7 +453,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
Some(update) => Ok(Arc::new(update)),
None => Err((
RPCResponseErrorCode::ResourceUnavailable,
"Latest finality update not available",
"Latest finality update not available".to_string(),
)),
},
Response::LightClientFinalityUpdate,
@@ -1081,7 +1081,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
&self,
peer_id: PeerId,
request_id: PeerRequestId,
result: Result<R, (RPCResponseErrorCode, &'static str)>,
result: Result<R, (RPCResponseErrorCode, String)>,
into_response: F,
) {
match result {
@@ -1096,7 +1096,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
});
}
Err((error_code, reason)) => {
self.send_error_response(peer_id, error_code, reason.into(), request_id);
self.send_error_response(peer_id, error_code, reason, request_id);
}
}
}