Search in sources :

Example 1 with NodeSyncingException

use of tech.pegasys.teku.validator.api.NodeSyncingException in project teku by ConsenSys.

the class ValidatorApiHandler method createBlock.

private Optional<BeaconBlock> createBlock(final UInt64 slot, final BLSSignature randaoReveal, final Optional<Bytes32> graffiti, final Optional<BeaconState> maybeBlockSlotState) throws StateTransitionException {
    if (maybeBlockSlotState.isEmpty()) {
        return Optional.empty();
    }
    final BeaconState blockSlotState = maybeBlockSlotState.get();
    final Bytes32 parentRoot = spec.getBlockRootAtSlot(blockSlotState, slot.minus(1));
    if (combinedChainDataClient.isOptimisticBlock(parentRoot)) {
        LOG.warn("Unable to produce block at slot {} because parent has optimistically validated payload", slot);
        throw new NodeSyncingException();
    }
    return Optional.of(blockFactory.createUnsignedBlock(blockSlotState, slot, randaoReveal, graffiti));
}
Also used : NodeSyncingException(tech.pegasys.teku.validator.api.NodeSyncingException) Bytes32(org.apache.tuweni.bytes.Bytes32) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 2 with NodeSyncingException

use of tech.pegasys.teku.validator.api.NodeSyncingException in project teku by ConsenSys.

the class DutyResultTest method shouldCombineNodeSyncingResults.

@Test
void shouldCombineNodeSyncingResults() {
    final DutyResult combined = DutyResult.forError(new NodeSyncingException()).combine(DutyResult.forError(new NodeSyncingException())).combine(DutyResult.forError(new NodeSyncingException()));
    combined.report(TYPE, SLOT, validatorLogger);
    verify(validatorLogger).dutySkippedWhileSyncing(TYPE, SLOT, 3);
    verifyNoMoreInteractions(validatorLogger);
}
Also used : NodeSyncingException(tech.pegasys.teku.validator.api.NodeSyncingException) Test(org.junit.jupiter.api.Test)

Example 3 with NodeSyncingException

use of tech.pegasys.teku.validator.api.NodeSyncingException in project teku by ConsenSys.

the class DutyResultTest method shouldCombineSafeFutureResults.

@Test
void shouldCombineSafeFutureResults() {
    final Bytes32 root1 = dataStructureUtil.randomBytes32();
    final Bytes32 root2 = dataStructureUtil.randomBytes32();
    final Exception exception1 = new RuntimeException("Nope");
    final Exception exception2 = new IllegalArgumentException("Oops");
    final SafeFuture<DutyResult> combinedFuture = DutyResult.combine(List.of(SafeFuture.completedFuture(DutyResult.success(root1)), SafeFuture.completedFuture(DutyResult.forError(validatorKey, exception1)), SafeFuture.failedFuture(exception2), SafeFuture.completedFuture(DutyResult.forError(validatorKey, new NodeSyncingException())), SafeFuture.failedFuture(new NodeSyncingException()), SafeFuture.completedFuture(DutyResult.success(root2))));
    assertThat(combinedFuture).isCompleted();
    combinedFuture.join().report(TYPE, SLOT, validatorLogger);
    verify(validatorLogger).dutyCompleted(TYPE, SLOT, 2, Set.of(root1, root2));
    verify(validatorLogger).dutyFailed(TYPE, SLOT, validatorId, exception1);
    verify(validatorLogger).dutyFailed(TYPE, SLOT, Set.of(), exception2);
    verify(validatorLogger).dutySkippedWhileSyncing(TYPE, SLOT, 2);
    verifyNoMoreInteractions(validatorLogger);
}
Also used : NodeSyncingException(tech.pegasys.teku.validator.api.NodeSyncingException) Bytes32(org.apache.tuweni.bytes.Bytes32) NodeSyncingException(tech.pegasys.teku.validator.api.NodeSyncingException) Test(org.junit.jupiter.api.Test)

Example 4 with NodeSyncingException

use of tech.pegasys.teku.validator.api.NodeSyncingException in project teku by ConsenSys.

the class DutyResultTest method shouldCombineMixedResults.

@Test
void shouldCombineMixedResults() {
    final Bytes32 root1 = dataStructureUtil.randomBytes32();
    final Bytes32 root2 = dataStructureUtil.randomBytes32();
    final Exception exception1 = new RuntimeException("Nope");
    final Exception exception2 = new IllegalArgumentException("Oops");
    final DutyResult combined = DutyResult.success(root1).combine(DutyResult.forError(validatorKey, exception1)).combine(DutyResult.forError(validatorKey, new NodeSyncingException())).combine(DutyResult.forError(validatorKey, exception2)).combine(DutyResult.forError(validatorKey, new NodeSyncingException())).combine(DutyResult.success(root2)).combine(DutyResult.success(root1));
    combined.report(TYPE, SLOT, validatorLogger);
    verify(validatorLogger).dutyCompleted(TYPE, SLOT, 3, Set.of(root1, root2));
    verify(validatorLogger).dutySkippedWhileSyncing(TYPE, SLOT, 2);
    verify(validatorLogger).dutyFailed(TYPE, SLOT, validatorId, exception1);
    verify(validatorLogger).dutyFailed(TYPE, SLOT, validatorId, exception2);
    verifyNoMoreInteractions(validatorLogger);
}
Also used : NodeSyncingException(tech.pegasys.teku.validator.api.NodeSyncingException) Bytes32(org.apache.tuweni.bytes.Bytes32) NodeSyncingException(tech.pegasys.teku.validator.api.NodeSyncingException) Test(org.junit.jupiter.api.Test)

Aggregations

NodeSyncingException (tech.pegasys.teku.validator.api.NodeSyncingException)4 Bytes32 (org.apache.tuweni.bytes.Bytes32)3 Test (org.junit.jupiter.api.Test)3 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)1