Skip to content

Commit

Permalink
Ensure beaconBlocksMaybeBlobsByRange is same epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion authored and g11tech committed Feb 19, 2023
1 parent aafcdf7 commit 8911f75
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ export async function beaconBlocksMaybeBlobsByRange(
request: phase0.BeaconBlocksByRangeRequest,
currentEpoch: Epoch
): Promise<BlockInput[]> {
// TODO Deneb: Assumes all blocks in the same epoch
// TODO Deneb: Ensure all blocks are in the same epoch
// Code below assumes the request is in the same epoch
// Range sync satisfies this condition, but double check here for sanity
const startEpoch = computeEpochAtSlot(request.startSlot);
const endEpoch = computeEpochAtSlot(request.startSlot + request.count);
if (startEpoch !== endEpoch) {
throw Error(`BeaconBlocksByRangeRequest must be in the same epoch ${startEpoch} != ${endEpoch}`);
}

// Note: Assumes all blocks in the same epoch
if (config.getForkSeq(request.startSlot) < ForkSeq.deneb) {
const blocks = await reqResp.beaconBlocksByRange(peerId, request);
return blocks.map((block) => getBlockInput.preDeneb(config, block));
Expand Down

0 comments on commit 8911f75

Please sign in to comment.