From 6b485889d173c8bc065f1b8bf3539ae9cfdb216b Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Mon, 16 Dec 2024 22:25:30 -0800 Subject: [PATCH] Partial commit --- packages/beacon-node/src/network/network.ts | 2 +- .../src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts | 4 ++-- packages/beacon-node/src/network/reqresp/handlers/index.ts | 4 ++-- packages/beacon-node/src/network/reqresp/rateLimit.ts | 2 +- packages/beacon-node/src/network/reqresp/types.ts | 2 +- packages/beacon-node/src/util/types.ts | 5 +++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/beacon-node/src/network/network.ts b/packages/beacon-node/src/network/network.ts index 2faf2371e5c7..56fcde7630aa 100644 --- a/packages/beacon-node/src/network/network.ts +++ b/packages/beacon-node/src/network/network.ts @@ -511,7 +511,7 @@ export class Network implements INetwork { async sendBlobSidecarsByRoot(peerId: PeerIdStr, request: BlobSidecarsByRootRequest): Promise { return collectMaxResponseTyped( - this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRoot, [Version.V1], request), + this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRoot, [Version.V1], request), // TODO request.length, responseSszTypeByMethod[ReqRespMethod.BlobSidecarsByRoot] ); diff --git a/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts b/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts index 3bbe00bfc56b..00a2744b44d1 100644 --- a/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts +++ b/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts @@ -52,7 +52,7 @@ export async function beaconBlocksMaybeBlobsByRoot( let allBlobSidecars: deneb.BlobSidecar[]; if (blobIdentifiers.length > 0) { - allBlobSidecars = await network.sendBlobSidecarsByRoot(peerId, blobIdentifiers); + allBlobSidecars = await network.sendBlobSidecarsByRoot(peerId, blobIdentifiers); // TODO } else { allBlobSidecars = []; } @@ -228,7 +228,7 @@ export async function unavailableBeaconBlobsByRoot( } if (networkReqIdentifiers.length > 0) { - networkResBlobSidecars = await network.sendBlobSidecarsByRoot(peerId, networkReqIdentifiers); + networkResBlobSidecars = await network.sendBlobSidecarsByRoot(peerId, networkReqIdentifiers); // TODO metrics?.blockInputFetchStats.dataPromiseBlobsFinallyAvailableFromNetwork.inc(networkResBlobSidecars.length); if (blockTriedBefore) { metrics?.blockInputFetchStats.dataPromiseBlobsRetriedAvailableFromNetwork.inc(networkResBlobSidecars.length); diff --git a/packages/beacon-node/src/network/reqresp/handlers/index.ts b/packages/beacon-node/src/network/reqresp/handlers/index.ts index 83f6620dbbd4..8567915c7fb2 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/index.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/index.ts @@ -38,8 +38,8 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh return onBeaconBlocksByRoot(body, chain, db); }, [ReqRespMethod.BlobSidecarsByRoot]: (req) => { - const body = BlobSidecarsByRootRequestType(chain.config).deserialize(req.data); - return onBlobSidecarsByRoot(body, chain, db); + const body = BlobSidecarsByRootRequestType(fork, chain.config).deserialize(req.data); + return onBlobSidecarsByRoot(body, chain, db) }, [ReqRespMethod.BlobSidecarsByRange]: (req) => { const body = ssz.deneb.BlobSidecarsByRangeRequest.deserialize(req.data); diff --git a/packages/beacon-node/src/network/reqresp/rateLimit.ts b/packages/beacon-node/src/network/reqresp/rateLimit.ts index 771d01f6c339..a875d332b52f 100644 --- a/packages/beacon-node/src/network/reqresp/rateLimit.ts +++ b/packages/beacon-node/src/network/reqresp/rateLimit.ts @@ -39,7 +39,7 @@ export const rateLimitQuotas: (config: ChainConfig) => Record req.length), }, [ReqRespMethod.LightClientBootstrap]: { diff --git a/packages/beacon-node/src/network/reqresp/types.ts b/packages/beacon-node/src/network/reqresp/types.ts index b7c18ebdfeb5..f2178ce7a035 100644 --- a/packages/beacon-node/src/network/reqresp/types.ts +++ b/packages/beacon-node/src/network/reqresp/types.ts @@ -80,7 +80,7 @@ export const requestSszTypeByMethod: (config: ChainConfig) => { [ReqRespMethod.BeaconBlocksByRange]: ssz.phase0.BeaconBlocksByRangeRequest, [ReqRespMethod.BeaconBlocksByRoot]: ssz.phase0.BeaconBlocksByRootRequest, [ReqRespMethod.BlobSidecarsByRange]: ssz.deneb.BlobSidecarsByRangeRequest, - [ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequestType(config), + [ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequestType(fork, config), [ReqRespMethod.LightClientBootstrap]: ssz.Root, [ReqRespMethod.LightClientUpdatesByRange]: ssz.altair.LightClientUpdatesByRange, [ReqRespMethod.LightClientFinalityUpdate]: null, diff --git a/packages/beacon-node/src/util/types.ts b/packages/beacon-node/src/util/types.ts index 5b9c7a784277..d022125991d8 100644 --- a/packages/beacon-node/src/util/types.ts +++ b/packages/beacon-node/src/util/types.ts @@ -1,5 +1,6 @@ import {ContainerType, ListCompositeType, ValueOf} from "@chainsafe/ssz"; import {ChainConfig} from "@lodestar/config"; +import { ForkName, isForkPostElectra } from "@lodestar/params"; import {ssz} from "@lodestar/types"; // Misc SSZ types used only in the beacon-node package, no need to upstream to types @@ -14,6 +15,6 @@ export const signedBLSToExecutionChangeVersionedType = new ContainerType( ); export type SignedBLSToExecutionChangeVersioned = ValueOf; -export const BlobSidecarsByRootRequestType = (config: ChainConfig) => - new ListCompositeType(ssz.deneb.BlobIdentifier, config.MAX_REQUEST_BLOB_SIDECARS); +export const BlobSidecarsByRootRequestType = (fork: ForkName, config: ChainConfig) => + new ListCompositeType(ssz.deneb.BlobIdentifier, isForkPostElectra(fork) ? config.MAX_REQUEST_BLOB_SIDECARS_ELECTRA : config.MAX_REQUEST_BLOB_SIDECARS); // TODO export type BlobSidecarsByRootRequest = ValueOf>;