-
-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(reqresp)!: support byte based handlers (#5417)
* Update reqresp to support only binary handler * Convert beacon-node reqresp to support only binary handlers * Update the beacon-reqresp and tests * Update the readme * Fix lint errors * Increase the genesis delay to fix slow startup of nodes * Fix the table reporter * Fix a type issue * Update the table reporter * Fix el log file name * Update the metadata response to support fork digest * Update context bytes for v1,v2 protocols * Update beacon metadata response * Add more test fixtures * Add protocol version to log for debugging * Update the metadata response format * Remove unncessary comments * Debug logger * Fix the sim log reporter * Revert the genesis slot delay * Fix e2e test types * Fix e2e tests * Update structure of handler * Update the beacon-node handlers * Fix linter errors * Fix readme file * Fix prettier warnings * Review PR * Fix lib import * Update readme example * Use Version enum * Simplify MetadataController * Add ReqResp interop test * Add INVALID_RESPONSE_SSZ * Review PR --------- Co-authored-by: dapplion <35266934+dapplion@users.noreply.github.com>
- Loading branch information
1 parent
342eb17
commit 6a6669f
Showing
76 changed files
with
1,423 additions
and
1,551 deletions.
There are no files selected for viewing
257 changes: 123 additions & 134 deletions
257
packages/beacon-node/src/network/reqresp/ReqRespBeaconNode.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
packages/beacon-node/src/network/reqresp/handlers/lightClientBootstrap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
packages/beacon-node/src/network/reqresp/handlers/lightClientFinalityUpdate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import {EncodedPayload, ResponseError, RespStatus, EncodedPayloadType} from "@lodestar/reqresp"; | ||
import {allForks} from "@lodestar/types"; | ||
import {ResponseOutgoing, RespStatus, ResponseError} from "@lodestar/reqresp"; | ||
import {IBeaconChain} from "../../../chain/index.js"; | ||
import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; | ||
|
||
export async function* onLightClientFinalityUpdate( | ||
chain: IBeaconChain | ||
): AsyncIterable<EncodedPayload<allForks.LightClientFinalityUpdate>> { | ||
const finalityUpdate = chain.lightClientServer.getFinalityUpdate(); | ||
if (finalityUpdate === null) { | ||
export async function* onLightClientFinalityUpdate(chain: IBeaconChain): AsyncIterable<ResponseOutgoing> { | ||
const update = chain.lightClientServer.getFinalityUpdate(); | ||
if (update === null) { | ||
throw new ResponseError(RespStatus.RESOURCE_UNAVAILABLE, "No latest finality update available"); | ||
} else { | ||
const fork = chain.config.getForkName(update.signatureSlot); | ||
const type = responseSszTypeByMethod[ReqRespMethod.LightClientFinalityUpdate](fork, 0); | ||
yield { | ||
type: EncodedPayloadType.ssz, | ||
data: finalityUpdate, | ||
data: type.serialize(update), | ||
fork, | ||
}; | ||
} | ||
} |
18 changes: 9 additions & 9 deletions
18
packages/beacon-node/src/network/reqresp/handlers/lightClientOptimisticUpdate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import {EncodedPayload, EncodedPayloadType, ResponseError, RespStatus} from "@lodestar/reqresp"; | ||
import {allForks} from "@lodestar/types"; | ||
import {ResponseOutgoing, ResponseError, RespStatus} from "@lodestar/reqresp"; | ||
import {IBeaconChain} from "../../../chain/index.js"; | ||
import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; | ||
|
||
export async function* onLightClientOptimisticUpdate( | ||
chain: IBeaconChain | ||
): AsyncIterable<EncodedPayload<allForks.LightClientOptimisticUpdate>> { | ||
const optimisticUpdate = chain.lightClientServer.getOptimisticUpdate(); | ||
if (optimisticUpdate === null) { | ||
export async function* onLightClientOptimisticUpdate(chain: IBeaconChain): AsyncIterable<ResponseOutgoing> { | ||
const update = chain.lightClientServer.getOptimisticUpdate(); | ||
if (update === null) { | ||
throw new ResponseError(RespStatus.RESOURCE_UNAVAILABLE, "No latest optimistic update available"); | ||
} else { | ||
const fork = chain.config.getForkName(update.signatureSlot); | ||
const type = responseSszTypeByMethod[ReqRespMethod.LightClientOptimisticUpdate](fork, 0); | ||
yield { | ||
type: EncodedPayloadType.ssz, | ||
data: optimisticUpdate, | ||
data: type.serialize(update), | ||
fork, | ||
}; | ||
} | ||
} |
16 changes: 10 additions & 6 deletions
16
packages/beacon-node/src/network/reqresp/handlers/lightClientUpdatesByRange.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
packages/beacon-node/src/network/reqresp/handlers/status.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import {EncodedPayload, EncodedPayloadType} from "@lodestar/reqresp"; | ||
import {phase0} from "@lodestar/types"; | ||
import {ResponseOutgoing} from "@lodestar/reqresp"; | ||
import {ssz} from "@lodestar/types"; | ||
import {ForkName} from "@lodestar/params"; | ||
import {IBeaconChain} from "../../../chain/index.js"; | ||
|
||
export async function* onStatus(chain: IBeaconChain): AsyncIterable<EncodedPayload<phase0.Status>> { | ||
yield {type: EncodedPayloadType.ssz, data: chain.getStatus()}; | ||
export async function* onStatus(chain: IBeaconChain): AsyncIterable<ResponseOutgoing> { | ||
const status = chain.getStatus(); | ||
yield { | ||
data: ssz.phase0.Status.serialize(status), | ||
// Status topic is fork-agnostic | ||
fork: ForkName.phase0, | ||
}; | ||
} |
Oops, something went wrong.