Skip to content

Commit

Permalink
fix: return 404 error if no sync committee contribution is available (#…
Browse files Browse the repository at this point in the history
…6649)

* fix: return 404 error if no sync committee contribution is available

* Return 404 error if block not in fork choice
  • Loading branch information
nflaig authored Aug 18, 2024
1 parent 550c349 commit 6f470f8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f470f8

Please sign in to comment.