Search in sources :

Example 1 with BFTHeader

use of com.radixdlt.hotstuff.BFTHeader in project radixdlt by radixdlt.

the class BFTEventReducerTest method when_previous_vote_exists_for_this_view__then_dont_vote.

@Test
public void when_previous_vote_exists_for_this_view__then_dont_vote() {
    BFTInsertUpdate bftUpdate = mock(BFTInsertUpdate.class);
    BFTHeader header = mock(BFTHeader.class);
    when(bftUpdate.getHeader()).thenReturn(header);
    when(header.getView()).thenReturn(View.of(3));
    ViewUpdate viewUpdate = ViewUpdate.create(View.of(3), mock(HighQC.class), mock(BFTNode.class), this.self);
    this.bftEventReducer.processViewUpdate(viewUpdate);
    verify(this.pacemaker, times(1)).processViewUpdate(any());
    when(safetyRules.getLastVote(View.of(3))).thenReturn(Optional.of(mock(Vote.class)));
    this.bftEventReducer.processBFTUpdate(bftUpdate);
    verifyNoMoreInteractions(this.voteDispatcher);
    verifyNoMoreInteractions(this.noVoteEventDispatcher);
}
Also used : HighQC(com.radixdlt.hotstuff.HighQC) BFTHeader(com.radixdlt.hotstuff.BFTHeader) Test(org.junit.Test)

Example 2 with BFTHeader

use of com.radixdlt.hotstuff.BFTHeader in project radixdlt by radixdlt.

the class VerifiedVertexStoreStateCreationTest method creating_vertex_store_with_root_not_committed_should_fail.

@Test
public void creating_vertex_store_with_root_not_committed_should_fail() {
    BFTHeader genesisHeader = new BFTHeader(View.of(0), genesisHash, mock(LedgerHeader.class));
    VoteData voteData = new VoteData(genesisHeader, genesisHeader, null);
    QuorumCertificate badRootQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    assertThatThrownBy(() -> VerifiedVertexStoreState.create(HighQC.from(badRootQC), genesisVertex, Optional.empty(), hasher)).isInstanceOf(IllegalStateException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) BFTHeader(com.radixdlt.hotstuff.BFTHeader) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VoteData(com.radixdlt.hotstuff.VoteData) Test(org.junit.Test)

Example 3 with BFTHeader

use of com.radixdlt.hotstuff.BFTHeader in project radixdlt by radixdlt.

the class VerifiedVertexStoreStateCreationTest method creating_vertex_store_with_committed_qc_not_matching_vertex_should_fail.

@Test
public void creating_vertex_store_with_committed_qc_not_matching_vertex_should_fail() {
    BFTHeader genesisHeader = new BFTHeader(View.of(0), genesisHash, mock(LedgerHeader.class));
    BFTHeader otherHeader = new BFTHeader(View.of(0), HashUtils.random256(), mock(LedgerHeader.class));
    VoteData voteData = new VoteData(genesisHeader, genesisHeader, otherHeader);
    QuorumCertificate badRootQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    assertThatThrownBy(() -> VerifiedVertexStoreState.create(HighQC.from(badRootQC), genesisVertex, Optional.empty(), hasher)).isInstanceOf(IllegalStateException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) BFTHeader(com.radixdlt.hotstuff.BFTHeader) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VoteData(com.radixdlt.hotstuff.VoteData) Test(org.junit.Test)

Example 4 with BFTHeader

use of com.radixdlt.hotstuff.BFTHeader in project radixdlt by radixdlt.

the class SafetyRules method constructVoteData.

private static VoteData constructVoteData(VerifiedVertex proposedVertex, BFTHeader proposedHeader) {
    final BFTHeader parent = proposedVertex.getParentHeader();
    // Add a vertex to commit if creating a quorum for the proposed vertex would
    // create three consecutive qcs.
    final BFTHeader toCommit;
    if (proposedVertex.touchesGenesis() || !proposedVertex.hasDirectParent() || !proposedVertex.parentHasDirectParent()) {
        toCommit = null;
    } else {
        toCommit = proposedVertex.getGrandParentHeader();
    }
    return new VoteData(proposedHeader, parent, toCommit);
}
Also used : BFTHeader(com.radixdlt.hotstuff.BFTHeader) VoteData(com.radixdlt.hotstuff.VoteData)

Example 5 with BFTHeader

use of com.radixdlt.hotstuff.BFTHeader in project radixdlt by radixdlt.

the class UnverifiedVertexSerializeTest method get.

private static UnverifiedVertex get() {
    View view = View.of(1234567891L);
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    BFTHeader header = new BFTHeader(view, HashUtils.random256(), ledgerHeader);
    BFTHeader parent = new BFTHeader(View.of(1234567890L), HashUtils.random256(), ledgerHeader);
    VoteData voteData = new VoteData(header, parent, null);
    QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    var txn = Txn.create(new byte[] { 0, 1, 2, 3 });
    return UnverifiedVertex.create(qc, view, List.of(txn), BFTNode.random());
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTHeader(com.radixdlt.hotstuff.BFTHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) View(com.radixdlt.hotstuff.bft.View) VoteData(com.radixdlt.hotstuff.VoteData)

Aggregations

BFTHeader (com.radixdlt.hotstuff.BFTHeader)22 Test (org.junit.Test)12 View (com.radixdlt.hotstuff.bft.View)11 VoteData (com.radixdlt.hotstuff.VoteData)10 HighQC (com.radixdlt.hotstuff.HighQC)9 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)9 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)9 TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)8 Vote (com.radixdlt.hotstuff.Vote)8 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)8 HashCode (com.google.common.hash.HashCode)5 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)4 Builder (com.radixdlt.hotstuff.safety.SafetyState.Builder)4 PreparedVertex (com.radixdlt.hotstuff.bft.PreparedVertex)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Inject (com.google.inject.Inject)1 Hasher (com.radixdlt.crypto.Hasher)1 EventDispatcher (com.radixdlt.environment.EventDispatcher)1 TestInvariantError (com.radixdlt.harness.simulation.TestInvariant.TestInvariantError)1