diff --git a/packages/api/src/beacon/routes/events.ts b/packages/api/src/beacon/routes/events.ts index 4216b80b114a..f22b34a5ff30 100644 --- a/packages/api/src/beacon/routes/events.ts +++ b/packages/api/src/beacon/routes/events.ts @@ -5,7 +5,7 @@ import {RouteDef, TypeJson} from "../../utils/index.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes -export type LightclientHeaderUpdate = { +export type LightclientOptimisticHeaderUpdate = { syncAggregate: altair.SyncAggregate; attestedHeader: phase0.BeaconBlockHeader; }; @@ -63,7 +63,7 @@ export type EventData = { newHeadState: RootHex; epoch: Epoch; }; - [EventType.lightclientOptimisticUpdate]: LightclientHeaderUpdate; + [EventType.lightclientOptimisticUpdate]: LightclientOptimisticHeaderUpdate; [EventType.lightclientFinalizedUpdate]: LightclientFinalizedUpdate; }; diff --git a/packages/api/src/beacon/routes/lightclient.ts b/packages/api/src/beacon/routes/lightclient.ts index 143f46c6819b..a177757de4d3 100644 --- a/packages/api/src/beacon/routes/lightclient.ts +++ b/packages/api/src/beacon/routes/lightclient.ts @@ -14,10 +14,10 @@ import { ReqEmpty, } from "../../utils/index.js"; import {queryParseProofPathsArr, querySerializeProofPathsArr} from "../../utils/serdes.js"; -import {LightclientHeaderUpdate, LightclientFinalizedUpdate} from "./events.js"; +import {LightclientOptimisticHeaderUpdate, LightclientFinalizedUpdate} from "./events.js"; -// Re-export for convenience when importing routes.lightclient.LightclientHeaderUpdate -export {LightclientHeaderUpdate, LightclientFinalizedUpdate}; +// Re-export for convenience when importing routes.lightclient.LightclientOptimisticHeaderUpdate +export {LightclientOptimisticHeaderUpdate, LightclientFinalizedUpdate}; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes @@ -46,7 +46,7 @@ export type Api = { * Returns the latest optimistic head update available. Clients should use the SSE type `light_client_optimistic_update` * unless to get the very first head update after syncing, or if SSE are not supported by the server. */ - getOptimisticUpdate(): Promise<{data: LightclientHeaderUpdate}>; + getOptimisticUpdate(): Promise<{data: LightclientOptimisticHeaderUpdate}>; getFinalityUpdate(): Promise<{data: LightclientFinalizedUpdate}>; /** * Fetch a bootstrapping state with a proof to a trusted block root. diff --git a/packages/light-client/src/index.ts b/packages/light-client/src/index.ts index cb105820a851..f22beb5fd7bf 100644 --- a/packages/light-client/src/index.ts +++ b/packages/light-client/src/index.ts @@ -376,7 +376,7 @@ export class Lightclient { * Processes new optimistic header updates in only known synced sync periods. * This headerUpdate may update the head if there's enough participation. */ - private processOptimisticUpdate(headerUpdate: routes.events.LightclientHeaderUpdate): void { + private processOptimisticUpdate(headerUpdate: routes.events.LightclientOptimisticHeaderUpdate): void { const {attestedHeader: header, syncAggregate} = headerUpdate; // Prevent registering updates for slots to far ahead diff --git a/packages/light-client/test/lightclientApiServer.ts b/packages/light-client/test/lightclientApiServer.ts index ab33855e2ad0..a52f5d589b7b 100644 --- a/packages/light-client/test/lightclientApiServer.ts +++ b/packages/light-client/test/lightclientApiServer.ts @@ -43,7 +43,7 @@ export class LightclientServerApi implements routes.lightclient.Api { readonly states = new Map(); readonly updates = new Map(); readonly snapshots = new Map(); - latestHeadUpdate: routes.lightclient.LightclientHeaderUpdate | null = null; + latestHeadUpdate: routes.lightclient.LightclientOptimisticHeaderUpdate | null = null; finalized: routes.lightclient.LightclientFinalizedUpdate | null = null; async getStateProof(stateId: string, paths: JsonPath[]): Promise<{data: Proof}> { @@ -63,7 +63,7 @@ export class LightclientServerApi implements routes.lightclient.Api { return {data: updates}; } - async getOptimisticUpdate(): Promise<{data: routes.lightclient.LightclientHeaderUpdate}> { + async getOptimisticUpdate(): Promise<{data: routes.lightclient.LightclientOptimisticHeaderUpdate}> { if (!this.latestHeadUpdate) throw Error("No latest head update"); return {data: this.latestHeadUpdate}; } diff --git a/packages/light-client/test/unit/sync.test.ts b/packages/light-client/test/unit/sync.test.ts index 6019aca8474a..3f2acbdf53e3 100644 --- a/packages/light-client/test/unit/sync.test.ts +++ b/packages/light-client/test/unit/sync.test.ts @@ -67,6 +67,7 @@ describe("Lightclient sync", () => { // So the first call to getLatestHeadUpdate() doesn't error, store the latest snapshot as latest header update lightclientServerApi.latestHeadUpdate = committeeUpdateToLatestHeadUpdate(lastInMap(lightclientServerApi.updates)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment lightclientServerApi.finalized = committeeUpdateToLatestFinalizedHeadUpdate( lastInMap(lightclientServerApi.updates) ); @@ -130,7 +131,7 @@ describe("Lightclient sync", () => { bodyRoot: SOME_HASH, }; - const headUpdate: routes.lightclient.LightclientHeaderUpdate = { + const headUpdate: routes.lightclient.LightclientOptimisticHeaderUpdate = { attestedHeader: header, syncAggregate: syncCommittee.signHeader(config, header), }; diff --git a/packages/light-client/test/utils.ts b/packages/light-client/test/utils.ts index a57bdc6ae21e..02cc9586fc50 100644 --- a/packages/light-client/test/utils.ts +++ b/packages/light-client/test/utils.ts @@ -255,7 +255,7 @@ export function computeMerkleBranch( export function committeeUpdateToLatestHeadUpdate( committeeUpdate: altair.LightClientUpdate -): routes.lightclient.LightclientHeaderUpdate { +): routes.lightclient.LightclientOptimisticHeaderUpdate { return { attestedHeader: committeeUpdate.attestedHeader, syncAggregate: { diff --git a/packages/lodestar/src/chain/emitter.ts b/packages/lodestar/src/chain/emitter.ts index 73f4bd3b9557..82abe2457987 100644 --- a/packages/lodestar/src/chain/emitter.ts +++ b/packages/lodestar/src/chain/emitter.ts @@ -124,7 +124,7 @@ export interface IChainEvents { [ChainEvent.forkChoiceJustified]: (checkpoint: CheckpointWithHex) => void; [ChainEvent.forkChoiceFinalized]: (checkpoint: CheckpointWithHex) => void; - [ChainEvent.lightclientOptimisticUpdate]: (headerUpdate: routes.events.LightclientHeaderUpdate) => void; + [ChainEvent.lightclientOptimisticUpdate]: (optimisticUpdate: routes.events.LightclientOptimisticHeaderUpdate) => void; [ChainEvent.lightclientFinalizedUpdate]: (finalizedUpdate: routes.events.LightclientFinalizedUpdate) => void; } diff --git a/packages/lodestar/src/chain/lightClient/index.ts b/packages/lodestar/src/chain/lightClient/index.ts index bb8e8f8b3dbd..094b7106a15e 100644 --- a/packages/lodestar/src/chain/lightClient/index.ts +++ b/packages/lodestar/src/chain/lightClient/index.ts @@ -166,7 +166,7 @@ export class LightClientServer { */ private readonly prevHeadData = new Map(); private checkpointHeaders = new Map(); - private latestHeadUpdate: routes.lightclient.LightclientHeaderUpdate | null = null; + private latestHeadUpdate: routes.lightclient.LightclientOptimisticHeaderUpdate | null = null; private readonly zero: Pick; private finalized: routes.lightclient.LightclientFinalizedUpdate | null = null; @@ -302,7 +302,7 @@ export class LightClientServer { * API ROUTE to poll LightclientHeaderUpdate. * Clients should use the SSE type `light_client_optimistic_update` if available */ - async getOptimisticUpdate(): Promise { + async getOptimisticUpdate(): Promise { if (this.latestHeadUpdate === null) { throw Error("No latest header update available"); } @@ -452,7 +452,7 @@ export class LightClientServer { throw new Error("attested data period different than signature period"); } - const headerUpdate: routes.lightclient.LightclientHeaderUpdate = { + const headerUpdate: routes.lightclient.LightclientOptimisticHeaderUpdate = { attestedHeader: attestedData.attestedHeader, syncAggregate, };