Skip to content

Commit

Permalink
Log attestation's journey published by local validators
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Dec 17, 2021
1 parent f40f42b commit bcf5b1e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/lodestar/src/api/impl/beacon/pool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ export function getBeaconPoolApi({
network.gossip.publishBeaconAttestation(attestation, subnet),
chain.attestationPool.add(attestation),
]);

const attestingIndex = indexedAttestation.attestingIndices[0];
if (metrics?.hasLocalValidator(attestingIndex)) {
const {slot, index} = attestation.data;
logger.verbose("Local validator published attestation", {
attestingIndex,
slot,
index,
subnet,
});
}
} catch (e) {
errors.push(e as Error);
logger.error(
Expand Down
10 changes: 10 additions & 0 deletions packages/lodestar/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,16 @@ export function getValidatorApi({chain, config, logger, metrics, network, sync}:
signedAggregateAndProof,
indexedAttestation
);
for (const validatorIndex of indexedAttestation.attestingIndices) {
if (metrics?.hasLocalValidator(validatorIndex)) {
const {slot, index} = indexedAttestation.data;
logger.verbose("Local validator attestation is included in api AggregatedAndProof and published", {
validatorIndex,
slot,
index,
});
}
}

await Promise.all([
chain.aggregatedAttestationPool.add(
Expand Down
5 changes: 5 additions & 0 deletions packages/lodestar/src/metrics/validatorMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum OpSource {

export interface IValidatorMonitor {
registerLocalValidator(index: number): void;
hasLocalValidator(index: number): boolean;
registerValidatorStatuses(currentEpoch: Epoch, statuses: allForks.IAttesterStatus[], balances?: number[]): void;
registerBeaconBlock(src: OpSource, seenTimestampSec: Seconds, block: allForks.BeaconBlock): void;
registerUnaggregatedAttestation(
Expand Down Expand Up @@ -175,6 +176,10 @@ export function createValidatorMonitor(
}
},

hasLocalValidator(index) {
return validators.has(index);
},

registerValidatorStatuses(currentEpoch, statuses, balances) {
// Prevent registering status for the same epoch twice. processEpoch() may be ran more than once for the same epoch.
if (currentEpoch <= lastRegisteredStatusEpoch) {
Expand Down
10 changes: 10 additions & 0 deletions packages/lodestar/src/network/gossip/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ export function getGossipHandlers(modules: ValidatorFnsModules): GossipHandlers
signedAggregateAndProof,
indexedAttestation
);
for (const validatorIndex of indexedAttestation.attestingIndices) {
if (metrics?.hasLocalValidator(validatorIndex)) {
const {slot, index} = indexedAttestation.data;
logger.verbose("Local validator attestation is included in gossip AggregatedAndProof", {
validatorIndex,
slot,
index,
});
}
}

// TODO: Add DoS resistant pending attestation pool
// switch (e.type.code) {
Expand Down

0 comments on commit bcf5b1e

Please sign in to comment.