From 6f470f8a35dcd5f39be8cdc5f59c513e1ab00fec Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Sun, 18 Aug 2024 03:00:02 +0100 Subject: [PATCH] fix: return 404 error if no sync committee contribution is available (#6649) * fix: return 404 error if no sync committee contribution is available * Return 404 error if block not in fork choice --- packages/beacon-node/src/api/impl/validator/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/beacon-node/src/api/impl/validator/index.ts b/packages/beacon-node/src/api/impl/validator/index.ts index 9d692a4cc405..ca0fe1ac95a2 100644 --- a/packages/beacon-node/src/api/impl/validator/index.ts +++ b/packages/beacon-node/src/api/impl/validator/index.ts @@ -324,7 +324,7 @@ export function getValidatorApi( function notOnOptimisticBlockRoot(beaconBlockRoot: Root): void { const protoBeaconBlock = chain.forkChoice.getBlock(beaconBlockRoot); if (!protoBeaconBlock) { - throw new ApiError(400, `Block not in forkChoice, beaconBlockRoot=${toRootHex(beaconBlockRoot)}`); + throw new ApiError(404, `Block not in forkChoice, beaconBlockRoot=${toRootHex(beaconBlockRoot)}`); } if (protoBeaconBlock.executionStatus === ExecutionStatus.Syncing) @@ -336,7 +336,7 @@ export function getValidatorApi( function notOnOutOfRangeData(beaconBlockRoot: Root): void { const protoBeaconBlock = chain.forkChoice.getBlock(beaconBlockRoot); if (!protoBeaconBlock) { - throw new ApiError(400, `Block not in forkChoice, beaconBlockRoot=${toRootHex(beaconBlockRoot)}`); + throw new ApiError(404, `Block not in forkChoice, beaconBlockRoot=${toRootHex(beaconBlockRoot)}`); } if (protoBeaconBlock.dataAvailabilityStatus === DataAvailabilityStatus.OutOfRange) @@ -880,7 +880,12 @@ export function getValidatorApi( notOnOutOfRangeData(beaconBlockRoot); const contribution = chain.syncCommitteeMessagePool.getContribution(subcommitteeIndex, slot, beaconBlockRoot); - if (!contribution) throw new ApiError(500, "No contribution available"); + if (!contribution) { + throw new ApiError( + 404, + `No sync committee contribution for slot=${slot}, subnet=${subcommitteeIndex}, beaconBlockRoot=${toRootHex(beaconBlockRoot)}` + ); + } metrics?.production.producedSyncContributionParticipants.observe( contribution.aggregationBits.getTrueBitIndexes().length