From 19282ff977d1fa92984f8a27afc9d9ac7f825d69 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Tue, 30 Jan 2024 13:43:54 +0100 Subject: [PATCH] Apply changes from #6337 --- packages/api/src/beacon/routes/beacon/block.ts | 12 ++++++++---- .../beacon-node/src/api/impl/beacon/blocks/index.ts | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/api/src/beacon/routes/beacon/block.ts b/packages/api/src/beacon/routes/beacon/block.ts index bc00e920f6b7..322d76e82317 100644 --- a/packages/api/src/beacon/routes/beacon/block.ts +++ b/packages/api/src/beacon/routes/beacon/block.ts @@ -209,12 +209,12 @@ export type Endpoints = { * * param blockId Block identifier. * Can be one of: "head" (canonical head in node's view), "genesis", "finalized", \, \. - * @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. + * 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: Endpoint< "GET", - {blockId: BlockId}, - {params: {block_id: string}}, + {blockId: BlockId; indices?: number[]}, + {params: {block_id: string}; query: {indices?: number[]}}, deneb.BlobSidecars, ExecutionOptimisticMeta >; @@ -524,7 +524,11 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions ({params: {block_id: String(blockId)}, query: {indices}}), + parseReq: ({params, query}) => ({blockId: params.block_id, indices: query.indices}), + schema: {params: {block_id: Schema.StringRequired}, query: {indices: Schema.UintArray}}, + }, resp: { data: ssz.deneb.BlobSidecars, meta: ExecutionOptimisticCodec, diff --git a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts index f8f1fe071fb7..da4dde49a5ac 100644 --- a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts @@ -400,7 +400,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); @@ -414,7 +414,7 @@ export function getBeaconBlockApi({ } return { - data: blobSidecars, + data: indices ? blobSidecars.filter(({index}) => indices.includes(index)) : blobSidecars, meta: {executionOptimistic}, }; },