Search in sources :

Example 6 with ValidationState

use of com.radixdlt.hotstuff.bft.ValidationState in project radixdlt by radixdlt.

the class RemoteSyncResponseValidatorSetVerifierTest method when_process_bad_validator_set__then_sends_invalid.

@Test
public void when_process_bad_validator_set__then_sends_invalid() {
    ValidationState validationState = mock(ValidationState.class);
    when(validatorSet.newValidationState()).thenReturn(validationState);
    when(validationState.complete()).thenReturn(false);
    assertFalse(validatorSetVerifier.verifyValidatorSet(SyncResponse.create(commandsAndProof)));
}
Also used : ValidationState(com.radixdlt.hotstuff.bft.ValidationState) Test(org.junit.Test)

Example 7 with ValidationState

use of com.radixdlt.hotstuff.bft.ValidationState in project radixdlt by radixdlt.

the class PendingVotes method processVoteForTC.

private Optional<TimeoutCertificate> processVoteForTC(Vote vote, BFTValidatorSet validatorSet) {
    if (!vote.isTimeout()) {
        // TC can't be formed if vote is not timed out
        return Optional.empty();
    }
    final ECDSASignature timeoutSignature = vote.getTimeoutSignature().orElseThrow();
    final VoteTimeout voteTimeout = VoteTimeout.of(vote);
    final HashCode voteTimeoutHash = this.hasher.hash(voteTimeout);
    final BFTNode node = vote.getAuthor();
    final ValidationState validationState = this.timeoutVoteState.computeIfAbsent(voteTimeoutHash, k -> validatorSet.newValidationState());
    final boolean signatureAdded = validationState.addSignature(node, vote.getTimestamp(), timeoutSignature);
    if (signatureAdded && validationState.complete()) {
        return Optional.of(new TimeoutCertificate(voteTimeout.getEpoch(), voteTimeout.getView(), validationState.signatures()));
    } else {
        return Optional.empty();
    }
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) ValidationState(com.radixdlt.hotstuff.bft.ValidationState) HashCode(com.google.common.hash.HashCode) ECDSASignature(com.radixdlt.crypto.ECDSASignature) VoteTimeout(com.radixdlt.hotstuff.liveness.VoteTimeout)

Aggregations

ValidationState (com.radixdlt.hotstuff.bft.ValidationState)7 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)5 Test (org.junit.Test)5 BFTValidatorSet (com.radixdlt.hotstuff.bft.BFTValidatorSet)3 HashCode (com.google.common.hash.HashCode)2 ECDSASignature (com.radixdlt.crypto.ECDSASignature)1 VoteProcessingResult (com.radixdlt.hotstuff.bft.VoteProcessingResult)1 VoteTimeout (com.radixdlt.hotstuff.liveness.VoteTimeout)1