From 7f24c6eacd0519a0dc47a07504039140e158dabc Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Wed, 12 Jul 2023 12:45:15 +0200 Subject: [PATCH] Track participants of produced aggregates --- .../src/api/impl/validator/index.ts | 8 +++++++ .../chain/produceBlock/produceBlockBody.ts | 7 +++--- .../src/metrics/metrics/lodestar.ts | 24 +++++++++++++++++++ 3 files changed, 36 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 def416fc963a..face5456394f 100644 --- a/packages/beacon-node/src/api/impl/validator/index.ts +++ b/packages/beacon-node/src/api/impl/validator/index.ts @@ -374,6 +374,11 @@ export function getValidatorApi({ const contribution = chain.syncCommitteeMessagePool.getContribution(subcommitteeIndex, slot, beaconBlockRoot); if (!contribution) throw new ApiError(500, "No contribution available"); + + metrics?.production.producedSyncContributionParticipants.observe( + contribution.aggregationBits.getTrueBitIndexes().length + ); + return {data: contribution}; }, @@ -538,6 +543,9 @@ export function getValidatorApi({ await waitForSlot(slot); // Must never request for a future slot > currentSlot + const aggregate = chain.attestationPool.getAggregate(slot, attestationDataRoot); + metrics?.production.producedAggregateParticipants.observe(aggregate.aggregationBits.getTrueBitIndexes().length); + return { data: chain.attestationPool.getAggregate(slot, attestationDataRoot), }; diff --git a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts index e8a76ffc64b1..04b5760a4a71 100644 --- a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts +++ b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts @@ -130,10 +130,11 @@ export async function produceBlockBody( const blockEpoch = computeEpochAtSlot(blockSlot); if (blockEpoch >= this.config.ALTAIR_FORK_EPOCH) { - (blockBody as altair.BeaconBlockBody).syncAggregate = this.syncContributionAndProofPool.getAggregate( - parentSlot, - parentBlockRoot + const syncAggregate = this.syncContributionAndProofPool.getAggregate(parentSlot, parentBlockRoot); + this.metrics?.production.producedSyncAggregateParticipants.observe( + syncAggregate.syncCommitteeBits.getTrueBitIndexes().length ); + (blockBody as altair.BeaconBlockBody).syncAggregate = syncAggregate; } const fork = currentState.config.getForkName(blockSlot); diff --git a/packages/beacon-node/src/metrics/metrics/lodestar.ts b/packages/beacon-node/src/metrics/metrics/lodestar.ts index fb2d540abb45..439b5c563094 100644 --- a/packages/beacon-node/src/metrics/metrics/lodestar.ts +++ b/packages/beacon-node/src/metrics/metrics/lodestar.ts @@ -221,6 +221,30 @@ export function createLodestarMetrics( }), }, + production: { + producedAggregateParticipants: register.histogram({ + name: "lodestar_produced_aggregate_participants", + help: "API impl produced aggregates histogram of participatns", + // We care more about tracking low quality aggregates with low participation + // Max committee sizes are: 0.5e6 vc: 244, 1e6 vc: 488 + buckets: [1, 5, 20, 50, 100, 200, 400], + }), + producedSyncContributionParticipants: register.histogram({ + name: "lodestar_produced_sync_contribution_participants", + help: "API impl produced sync contribution histogram of participatns", + // We care more about tracking low quality aggregates with low participation + // Max committee sizes fixed to 512/4 = 128 + buckets: [1, 5, 20, 50, 128], + }), + producedSyncAggregateParticipants: register.histogram({ + name: "lodestar_produced_sync_aggregate_participants", + help: "API impl produced sync aggregate histogram of participatns", + // We care more about tracking low quality aggregates with low participation + // Max committee sizes fixed to 512 + buckets: [1, 5, 20, 50, 100, 200, 512], + }), + }, + // Beacon state transition metrics epochTransitionTime: register.histogram({