Skip to content

Commit

Permalink
fix: revert BlobSidecarsByRoot/Range version bump (#7347)
Browse files Browse the repository at this point in the history
* fix: revert BlobSidecarsByRoot/Range version bump

* Remove version check from handler

* Remove unused imports
  • Loading branch information
nflaig authored Jan 10, 2025
1 parent 4d271ff commit 8e423e7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 37 deletions.
17 changes: 3 additions & 14 deletions packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {PeerId} from "@libp2p/interface";
import {routes} from "@lodestar/api";
import {BeaconConfig} from "@lodestar/config";
import {LoggerNode} from "@lodestar/logger/node";
import {ForkSeq, isForkPostElectra} from "@lodestar/params";
import {ForkSeq} from "@lodestar/params";
import {ResponseIncoming} from "@lodestar/reqresp";
import {computeStartSlotAtEpoch, computeTimeAtSlot} from "@lodestar/state-transition";
import {
Expand Down Expand Up @@ -504,27 +504,16 @@ export class Network implements INetwork {
): Promise<deneb.BlobSidecar[]> {
const fork = this.config.getForkName(request.startSlot);
return collectMaxResponseTyped(
this.sendReqRespRequest(
peerId,
ReqRespMethod.BlobSidecarsByRange,
[isForkPostElectra(fork) ? Version.V2 : Version.V1],
request
),
this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRange, [Version.V1], request),
// request's count represent the slots, so the actual max count received could be slots * blobs per slot
request.count * this.config.getMaxBlobsPerBlock(fork),
responseSszTypeByMethod[ReqRespMethod.BlobSidecarsByRange]
);
}

async sendBlobSidecarsByRoot(peerId: PeerIdStr, request: BlobSidecarsByRootRequest): Promise<deneb.BlobSidecar[]> {
const fork = this.config.getForkName(this.clock.currentSlot);
return collectMaxResponseTyped(
this.sendReqRespRequest(
peerId,
ReqRespMethod.BlobSidecarsByRoot,
[isForkPostElectra(fork) ? Version.V2 : Version.V1],
request
),
this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRoot, [Version.V1], request),
request.length,
responseSszTypeByMethod[ReqRespMethod.BlobSidecarsByRoot]
);
Expand Down
8 changes: 0 additions & 8 deletions packages/beacon-node/src/network/reqresp/ReqRespBeaconNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,12 @@ export class ReqRespBeaconNode extends ReqResp {
}

if (ForkSeq[fork] >= ForkSeq.deneb) {
// TODO Electra: Consider deprecating BlobSidecarsByRootV1 and BlobSidecarsByRangeV1 at fork boundary or after Electra is stable
protocolsAtFork.push(
[protocols.BlobSidecarsByRoot(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRoot)],
[protocols.BlobSidecarsByRange(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRange)]
);
}

if (ForkSeq[fork] >= ForkSeq.electra) {
protocolsAtFork.push(
[protocols.BlobSidecarsByRootV2(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRoot)],
[protocols.BlobSidecarsByRangeV2(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRange)]
);
}

return protocolsAtFork;
}

Expand Down
5 changes: 2 additions & 3 deletions packages/beacon-node/src/network/reqresp/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {ForkName} from "@lodestar/params";
import {ProtocolHandler} from "@lodestar/reqresp";
import {ssz} from "@lodestar/types";
import {IBeaconChain} from "../../../chain/index.js";
import {IBeaconDb} from "../../../db/index.js";
import {BlobSidecarsByRootRequestType} from "../../../util/types.js";
import {GetReqRespHandlerFn, ReqRespMethod, Version} from "../types.js";
import {GetReqRespHandlerFn, ReqRespMethod} from "../types.js";
import {onBeaconBlocksByRange} from "./beaconBlocksByRange.js";
import {onBeaconBlocksByRoot} from "./beaconBlocksByRoot.js";
import {onBlobSidecarsByRange} from "./blobSidecarsByRange.js";
Expand Down Expand Up @@ -39,7 +38,7 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
return onBeaconBlocksByRoot(body, chain, db);
},
[ReqRespMethod.BlobSidecarsByRoot]: (req) => {
const fork = req.version === Version.V2 ? ForkName.electra : ForkName.deneb;
const fork = chain.config.getForkName(chain.clock.currentSlot);
const body = BlobSidecarsByRootRequestType(fork, chain.config).deserialize(req.data);
return onBlobSidecarsByRoot(body, chain, db);
},
Expand Down
12 changes: 0 additions & 12 deletions packages/beacon-node/src/network/reqresp/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,12 @@ export const BlobSidecarsByRange = toProtocol({
contextBytesType: ContextBytesType.ForkDigest,
});

export const BlobSidecarsByRangeV2 = toProtocol({
method: ReqRespMethod.BlobSidecarsByRange,
version: Version.V2,
contextBytesType: ContextBytesType.ForkDigest,
});

export const BlobSidecarsByRoot = toProtocol({
method: ReqRespMethod.BlobSidecarsByRoot,
version: Version.V1,
contextBytesType: ContextBytesType.ForkDigest,
});

export const BlobSidecarsByRootV2 = toProtocol({
method: ReqRespMethod.BlobSidecarsByRoot,
version: Version.V2,
contextBytesType: ContextBytesType.ForkDigest,
});

export const LightClientBootstrap = toProtocol({
method: ReqRespMethod.LightClientBootstrap,
version: Version.V1,
Expand Down

0 comments on commit 8e423e7

Please sign in to comment.