Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions packages/api/src/beacon/routes/beacon/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,12 @@ export type Api = {
* Retrieves BlobSidecar included in requested block.
* @param blockId Block identifier.
* Can be one of: "head" (canonical head in node's view), "genesis", "finalized", \<slot\>, \<hex encoded blockRoot with 0x prefix\>.
* @param indices Array of indices for blob sidecars to request for in the specified block. Returns all blob sidecars in the block if not specified.
*/
getBlobSidecars(blockId: BlockId): Promise<
getBlobSidecars(
blockId: BlockId,
indices?: string[]
): Promise<
ApiClientResponse<{
[HttpStatusCode.OK]: {executionOptimistic: ExecutionOptimistic; data: deneb.BlobSidecars};
}>
Expand Down Expand Up @@ -270,7 +274,7 @@ export type ReqTypes = {
publishBlockV2: {body: unknown; query: {broadcast_validation?: string}};
publishBlindedBlock: {body: unknown};
publishBlindedBlockV2: {body: unknown; query: {broadcast_validation?: string}};
getBlobSidecars: BlockIdOnlyReq;
getBlobSidecars: {params: {block_id: string}; query: {indices?: string[]}};
};

export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api, ReqTypes> {
Expand Down Expand Up @@ -356,7 +360,16 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
query: {broadcast_validation: Schema.String},
},
},
getBlobSidecars: blockIdOnlyReq,
getBlobSidecars: {
writeReq: (block_id, indices = []) => ({
params: {block_id: String(block_id)},
query: {indices},
}),
parseReq: ({params, query}) => [params.block_id, query.indices],
schema: {
query: {indices: Schema.StringArray},
},
},
};
}

Expand Down
6 changes: 0 additions & 6 deletions packages/api/test/unit/beacon/oapiSpec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ const ignoredProperties: Record<string, IgnoredProperty> = {
*/
getHealth: {request: ["query.syncing_status"]},

/**
* https://github.com/ChainSafe/lodestar/issues/6185
* - must have required property 'query'
*/
getBlobSidecars: {request: ["query"]},

/*
https://github.com/ChainSafe/lodestar/issues/4638
/query - must have required property 'skip_randao_verification'
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/unit/beacon/testData/beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const testData: GenericServerTestCases<Api> = {
res: undefined,
},
getBlobSidecars: {
args: ["head"],
args: ["head", ["0"]],
res: {executionOptimistic: true, data: ssz.deneb.BlobSidecars.defaultValue()},
},

Expand Down
6 changes: 4 additions & 2 deletions packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export function getBeaconBlockApi({
await publishBlock(signedBlockOrContents, opts);
},

async getBlobSidecars(blockId) {
async getBlobSidecars(blockId, indices = []) {
const {block, executionOptimistic} = await resolveBlockId(chain, blockId);
const blockRoot = config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message);

Expand All @@ -418,9 +418,11 @@ export function getBeaconBlockApi({
if (!blobSidecars) {
throw Error(`blobSidecars not found in db for slot=${block.message.slot} root=${toHexString(blockRoot)}`);
}

const indicesSet = new Set(indices?.map((index) => parseInt(index)));
return {
executionOptimistic,
data: blobSidecars,
data: blobSidecars.filter(({index}) => indicesSet.has(index)),
};
},
};
Expand Down