Skip to content

Commit

Permalink
Partial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 committed Dec 17, 2024
1 parent e6984f4 commit 6b48588
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export class Network implements INetwork {

async sendBlobSidecarsByRoot(peerId: PeerIdStr, request: BlobSidecarsByRootRequest): Promise<deneb.BlobSidecar[]> {
return collectMaxResponseTyped(
this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRoot, [Version.V1], request),
this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRoot, [Version.V1], request), // TODO
request.length,
responseSszTypeByMethod[ReqRespMethod.BlobSidecarsByRoot]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/network/reqresp/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/network/reqresp/rateLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const rateLimitQuotas: (config: ChainConfig) => Record<ReqRespMethod, Inb
},
[ReqRespMethod.BlobSidecarsByRoot]: {
// Rationale: quota of BeaconBlocksByRoot * MAX_BLOBS_PER_BLOCK
byPeer: {quota: config.MAX_REQUEST_BLOB_SIDECARS, quotaTimeMs: 10_000},
byPeer: {quota: config.MAX_REQUEST_BLOB_SIDECARS, quotaTimeMs: 10_000}, // TODO
getRequestCount: getRequestCountFn(config, ReqRespMethod.BlobSidecarsByRoot, (req) => req.length),
},
[ReqRespMethod.LightClientBootstrap]: {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/network/reqresp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions packages/beacon-node/src/util/types.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,6 +15,6 @@ export const signedBLSToExecutionChangeVersionedType = new ContainerType(
);
export type SignedBLSToExecutionChangeVersioned = ValueOf<typeof signedBLSToExecutionChangeVersionedType>;

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<ReturnType<typeof BlobSidecarsByRootRequestType>>;

0 comments on commit 6b48588

Please sign in to comment.