diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/performance/DefaultPerformanceTracker.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/performance/DefaultPerformanceTracker.java index 8031f4f0a30..c981b8a6f52 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/performance/DefaultPerformanceTracker.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/performance/DefaultPerformanceTracker.java @@ -147,10 +147,10 @@ public void onSlot(final UInt64 slot) { } SafeFuture.allOf(reportingTasks.toArray(SafeFuture[]::new)) - .handleException(LOG::error) + .handleException(error -> LOG.error("Failed to report performance metrics", error)) .alwaysRun( () -> { - if (reportingTasks.size() > 0) { + if (!reportingTasks.isEmpty()) { timingsSettableGauge.set(System.currentTimeMillis() - startTime); } }) @@ -307,10 +307,10 @@ private AttestationPerformance calculateAttestationPerformance( // data hash to inclusion slot to aggregation bitlist final Map> slotAndBitlistsByAttestationDataHash = new HashMap<>(); - for (Map.Entry> entry : attestationsIncludedOnChain.entrySet()) { - final Optional committeesSize = - Optional.of(spec.getBeaconCommitteesSize(state, entry.getKey())); - for (Attestation attestation : entry.getValue()) { + for (final Map.Entry> entry : + attestationsIncludedOnChain.entrySet()) { + for (final Attestation attestation : entry.getValue()) { + final Optional committeesSize = getCommitteesSize(attestation, state); final Bytes32 attestationDataHash = attestation.getData().hashTreeRoot(); final NavigableMap slotToBitlists = slotAndBitlistsByAttestationDataHash.computeIfAbsent( @@ -325,7 +325,7 @@ private AttestationPerformance calculateAttestationPerformance( } } - for (Attestation sentAttestation : producedAttestations) { + for (final Attestation sentAttestation : producedAttestations) { final Bytes32 sentAttestationDataHash = sentAttestation.getData().hashTreeRoot(); final UInt64 sentAttestationSlot = sentAttestation.getData().getSlot(); if (!slotAndBitlistsByAttestationDataHash.containsKey(sentAttestationDataHash)) { @@ -359,7 +359,7 @@ private AttestationPerformance calculateAttestationPerformance( // IntSummaryStatistics returns Integer.MIN and MAX when the summarized integer list // is empty. final int numberOfProducedAttestations = producedAttestations.size(); - return producedAttestations.size() > 0 + return numberOfProducedAttestations > 0 ? new AttestationPerformance( analyzedEpoch, validatorTracker.getNumberOfValidatorsForEpoch(analyzedEpoch), @@ -374,6 +374,14 @@ private AttestationPerformance calculateAttestationPerformance( analyzedEpoch, validatorTracker.getNumberOfValidatorsForEpoch(analyzedEpoch)); } + private Optional getCommitteesSize( + final Attestation attestation, final BeaconState state) { + if (!attestation.requiresCommitteeBits()) { + return Optional.empty(); + } + return Optional.of(spec.getBeaconCommitteesSize(state, attestation.getData().getSlot())); + } + private SafeFuture> getBlocksInEpochs( final UInt64 startEpochInclusive, final UInt64 endEpochExclusive) { final UInt64 epochStartSlot = spec.computeStartSlotAtEpoch(startEpochInclusive); diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java index 23b2e985449..67066491072 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java @@ -125,7 +125,7 @@ private SafeFuture validateBlock( if (!blockContainerAndMetaData.consensusBlockValue().isZero()) { LOG.info( - "Received block for slot {}, block rewards {} ETH, execution payload value {} ETH", + "Validator client received block for slot {}, block rewards {} ETH, execution payload value {} ETH", slot, weiToEth(blockContainerAndMetaData.consensusBlockValue()), weiToEth(blockContainerAndMetaData.executionPayloadValue()));