mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
API for LightClientBootstrap, LightClientFinalityUpdate, LightClientOptimisticUpdate and light client events (#3954)
* rebase and add comment * conditional test * test * optimistic chould be working now * finality should be working now * try again * try again * clippy fix * add lc bootstrap beacon api * add lc optimistic/finality update to events * fmt * That error isn't occuring on my computer but I think this should fix it * Add missing test file * Update light client types to comply with Altair light client spec. * Fix test compilation * Support deserializing light client structures for the Bellatrix fork * Move `get_light_client_bootstrap` logic to `BeaconChain`. `LightClientBootstrap` API to return `ForkVersionedResponse`. * Misc fixes. - log cleanup - move http_api config mutation to `config::get_config` for consistency - fix light client API responses * Add light client bootstrap API test and fix existing ones. * Fix test for `light-client-server` http api config. * Appease clippy * Efficiency improvement when retrieving beacon state. --------- Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
@@ -1646,6 +1646,59 @@ impl ApiTester {
|
||||
self
|
||||
}
|
||||
|
||||
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,
|
||||
Err(e) => panic!("query failed incorrectly: {e:?}"),
|
||||
};
|
||||
|
||||
let expected = block.slot();
|
||||
assert_eq!(result.header.beacon.slot, expected);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_get_beacon_light_client_optimistic_update(self) -> Self {
|
||||
// get_beacon_light_client_optimistic_update returns Ok(None) on 404 NOT FOUND
|
||||
let result = match self
|
||||
.client
|
||||
.get_beacon_light_client_optimistic_update::<E>()
|
||||
.await
|
||||
{
|
||||
Ok(result) => result.map(|res| res.data),
|
||||
Err(e) => panic!("query failed incorrectly: {e:?}"),
|
||||
};
|
||||
|
||||
let expected = self.chain.latest_seen_optimistic_update.lock().clone();
|
||||
assert_eq!(result, expected);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_get_beacon_light_client_finality_update(self) -> Self {
|
||||
let result = match self
|
||||
.client
|
||||
.get_beacon_light_client_finality_update::<E>()
|
||||
.await
|
||||
{
|
||||
Ok(result) => result.map(|res| res.data),
|
||||
Err(e) => panic!("query failed incorrectly: {e:?}"),
|
||||
};
|
||||
|
||||
let expected = self.chain.latest_seen_finality_update.lock().clone();
|
||||
assert_eq!(result, expected);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_get_beacon_pool_attestations(self) -> Self {
|
||||
let result = self
|
||||
.client
|
||||
@@ -5701,6 +5754,42 @@ async fn node_get() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_light_client_bootstrap() {
|
||||
let config = ApiTesterConfig {
|
||||
spec: ForkName::Altair.make_genesis_spec(E::default_spec()),
|
||||
..<_>::default()
|
||||
};
|
||||
ApiTester::new_from_config(config)
|
||||
.await
|
||||
.test_get_beacon_light_client_bootstrap()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_light_client_optimistic_update() {
|
||||
let config = ApiTesterConfig {
|
||||
spec: ForkName::Altair.make_genesis_spec(E::default_spec()),
|
||||
..<_>::default()
|
||||
};
|
||||
ApiTester::new_from_config(config)
|
||||
.await
|
||||
.test_get_beacon_light_client_optimistic_update()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_light_client_finality_update() {
|
||||
let config = ApiTesterConfig {
|
||||
spec: ForkName::Altair.make_genesis_spec(E::default_spec()),
|
||||
..<_>::default()
|
||||
};
|
||||
ApiTester::new_from_config(config)
|
||||
.await
|
||||
.test_get_beacon_light_client_finality_update()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_validator_duties_early() {
|
||||
ApiTester::new()
|
||||
|
||||
Reference in New Issue
Block a user