Search in sources :

Example 11 with HighQC

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

the class MockedRecoveryModule method view.

@Provides
private ViewUpdate view(BFTConfiguration configuration, ProposerElection proposerElection) {
    HighQC highQC = configuration.getVertexStoreState().getHighQC();
    View view = highQC.highestQC().getView().next();
    final BFTNode leader = proposerElection.getProposer(view);
    final BFTNode nextLeader = proposerElection.getProposer(view.next());
    return ViewUpdate.create(view, highQC, leader, nextLeader);
}
Also used : HighQC(com.radixdlt.hotstuff.HighQC) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) View(com.radixdlt.hotstuff.bft.View) Provides(com.google.inject.Provides)

Example 12 with HighQC

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

the class ConsensusModuleTest method on_sync_request_timeout_should_retry.

@Test
public void on_sync_request_timeout_should_retry() {
    // Arrange
    QuorumCertificate parent = vertexStore.highQC().highestQC();
    Pair<QuorumCertificate, VerifiedVertex> nextVertex = createNextVertex(parent, validatorKeyPair);
    HighQC unsyncedHighQC = HighQC.from(nextVertex.getFirst(), nextVertex.getFirst(), Optional.empty());
    bftSync.syncToQC(unsyncedHighQC, validatorBftNode);
    GetVerticesRequest request = new GetVerticesRequest(nextVertex.getSecond().getId(), 1);
    VertexRequestTimeout timeout = VertexRequestTimeout.create(request);
    // Act
    // FIXME: Remove when rate limit on send removed
    nothrowSleep(100);
    bftSync.vertexRequestTimeoutEventProcessor().process(timeout);
    // Assert
    verify(requestSender, times(2)).dispatch(eq(validatorBftNode), argThat(r -> r.getCount() == 1 && r.getVertexId().equals(nextVertex.getSecond().getId())));
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) HighQC(com.radixdlt.hotstuff.HighQC) Module(com.google.inject.Module) BFTHighQCUpdate(com.radixdlt.hotstuff.bft.BFTHighQCUpdate) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Inject(com.google.inject.Inject) PersistentSafetyStateStore(com.radixdlt.hotstuff.safety.PersistentSafetyStateStore) Hasher(com.radixdlt.crypto.Hasher) HighQC(com.radixdlt.hotstuff.HighQC) VerifiedVertexStoreState(com.radixdlt.hotstuff.bft.VerifiedVertexStoreState) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) Ledger(com.radixdlt.hotstuff.Ledger) Map(java.util.Map) PersistentVertexStore(com.radixdlt.hotstuff.bft.PersistentVertexStore) PacemakerTimeout(com.radixdlt.hotstuff.bft.PacemakerTimeout) GetVerticesErrorResponse(com.radixdlt.hotstuff.sync.GetVerticesErrorResponse) BFTRebuildUpdate(com.radixdlt.hotstuff.bft.BFTRebuildUpdate) HashUtils(com.radixdlt.crypto.HashUtils) BFTSyncPatienceMillis(com.radixdlt.hotstuff.sync.BFTSyncPatienceMillis) BFTInsertUpdate(com.radixdlt.hotstuff.bft.BFTInsertUpdate) SystemCounters(com.radixdlt.counters.SystemCounters) Vote(com.radixdlt.hotstuff.Vote) NextTxnsGenerator(com.radixdlt.hotstuff.liveness.NextTxnsGenerator) VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) ViewUpdate(com.radixdlt.hotstuff.bft.ViewUpdate) TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) PacemakerRate(com.radixdlt.hotstuff.bft.PacemakerRate) List(java.util.List) Stream(java.util.stream.Stream) PacemakerMaxExponent(com.radixdlt.hotstuff.bft.PacemakerMaxExponent) Optional(java.util.Optional) TypeLiteral(com.google.inject.TypeLiteral) Proposal(com.radixdlt.hotstuff.Proposal) ViewQuorumReached(com.radixdlt.hotstuff.bft.ViewQuorumReached) Mockito.mock(org.mockito.Mockito.mock) BFTCommittedUpdate(com.radixdlt.hotstuff.bft.BFTCommittedUpdate) BFTValidatorSet(com.radixdlt.hotstuff.bft.BFTValidatorSet) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) LedgerProof(com.radixdlt.hotstuff.LedgerProof) WeightedRotatingLeaders(com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders) Sha256Hasher(com.radixdlt.hotstuff.Sha256Hasher) GetVerticesResponse(com.radixdlt.hotstuff.sync.GetVerticesResponse) RateLimiter(com.google.common.util.concurrent.RateLimiter) TypedMocks.rmock(com.radixdlt.utils.TypedMocks.rmock) HashSigner(com.radixdlt.hotstuff.HashSigner) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) VertexStore(com.radixdlt.hotstuff.bft.VertexStore) View(com.radixdlt.hotstuff.bft.View) ImmutableList(com.google.common.collect.ImmutableList) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) AccumulatorState(com.radixdlt.ledger.AccumulatorState) UInt256(com.radixdlt.utils.UInt256) Before(org.junit.Before) BFTSync(com.radixdlt.hotstuff.sync.BFTSync) BFTHeader(com.radixdlt.hotstuff.BFTHeader) TimeSupplier(com.radixdlt.utils.TimeSupplier) EventDispatcher(com.radixdlt.environment.EventDispatcher) ScheduledLocalTimeout(com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout) NoVote(com.radixdlt.hotstuff.bft.NoVote) Txn(com.radixdlt.atom.Txn) VoteData(com.radixdlt.hotstuff.VoteData) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) VertexRequestTimeout(com.radixdlt.hotstuff.sync.VertexRequestTimeout) Provides(com.google.inject.Provides) ECKeyPair(com.radixdlt.crypto.ECKeyPair) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) TimestampedECDSASignature(com.radixdlt.hotstuff.TimestampedECDSASignature) BFTValidator(com.radixdlt.hotstuff.bft.BFTValidator) LocalTimeoutOccurrence(com.radixdlt.hotstuff.liveness.LocalTimeoutOccurrence) Guice(com.google.inject.Guice) Self(com.radixdlt.hotstuff.bft.Self) Pair(com.radixdlt.utils.Pair) LastProof(com.radixdlt.store.LastProof) AbstractModule(com.google.inject.AbstractModule) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VertexRequestTimeout(com.radixdlt.hotstuff.sync.VertexRequestTimeout) Test(org.junit.Test)

Example 13 with HighQC

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

the class ConsensusModuleTest method on_synced_to_vertex_should_request_for_parent.

@Test
public void on_synced_to_vertex_should_request_for_parent() {
    // Arrange
    BFTNode bftNode = BFTNode.random();
    QuorumCertificate parent = vertexStore.highQC().highestQC();
    Pair<QuorumCertificate, VerifiedVertex> nextVertex = createNextVertex(parent, validatorKeyPair);
    Pair<QuorumCertificate, VerifiedVertex> nextNextVertex = createNextVertex(nextVertex.getFirst(), validatorKeyPair);
    HighQC unsyncedHighQC = HighQC.from(nextNextVertex.getFirst(), nextNextVertex.getFirst(), Optional.empty());
    bftSync.syncToQC(unsyncedHighQC, bftNode);
    // Act
    // FIXME: Remove when rate limit on send removed
    nothrowSleep(100);
    GetVerticesResponse response = new GetVerticesResponse(ImmutableList.of(nextNextVertex.getSecond()));
    bftSync.responseProcessor().process(bftNode, response);
    // Assert
    verify(requestSender, times(1)).dispatch(eq(bftNode), argThat(r -> r.getCount() == 1 && r.getVertexId().equals(nextVertex.getSecond().getId())));
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) HighQC(com.radixdlt.hotstuff.HighQC) Module(com.google.inject.Module) BFTHighQCUpdate(com.radixdlt.hotstuff.bft.BFTHighQCUpdate) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Inject(com.google.inject.Inject) PersistentSafetyStateStore(com.radixdlt.hotstuff.safety.PersistentSafetyStateStore) Hasher(com.radixdlt.crypto.Hasher) HighQC(com.radixdlt.hotstuff.HighQC) VerifiedVertexStoreState(com.radixdlt.hotstuff.bft.VerifiedVertexStoreState) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) Ledger(com.radixdlt.hotstuff.Ledger) Map(java.util.Map) PersistentVertexStore(com.radixdlt.hotstuff.bft.PersistentVertexStore) PacemakerTimeout(com.radixdlt.hotstuff.bft.PacemakerTimeout) GetVerticesErrorResponse(com.radixdlt.hotstuff.sync.GetVerticesErrorResponse) BFTRebuildUpdate(com.radixdlt.hotstuff.bft.BFTRebuildUpdate) HashUtils(com.radixdlt.crypto.HashUtils) BFTSyncPatienceMillis(com.radixdlt.hotstuff.sync.BFTSyncPatienceMillis) BFTInsertUpdate(com.radixdlt.hotstuff.bft.BFTInsertUpdate) SystemCounters(com.radixdlt.counters.SystemCounters) Vote(com.radixdlt.hotstuff.Vote) NextTxnsGenerator(com.radixdlt.hotstuff.liveness.NextTxnsGenerator) VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) ViewUpdate(com.radixdlt.hotstuff.bft.ViewUpdate) TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) PacemakerRate(com.radixdlt.hotstuff.bft.PacemakerRate) List(java.util.List) Stream(java.util.stream.Stream) PacemakerMaxExponent(com.radixdlt.hotstuff.bft.PacemakerMaxExponent) Optional(java.util.Optional) TypeLiteral(com.google.inject.TypeLiteral) Proposal(com.radixdlt.hotstuff.Proposal) ViewQuorumReached(com.radixdlt.hotstuff.bft.ViewQuorumReached) Mockito.mock(org.mockito.Mockito.mock) BFTCommittedUpdate(com.radixdlt.hotstuff.bft.BFTCommittedUpdate) BFTValidatorSet(com.radixdlt.hotstuff.bft.BFTValidatorSet) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) LedgerProof(com.radixdlt.hotstuff.LedgerProof) WeightedRotatingLeaders(com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders) Sha256Hasher(com.radixdlt.hotstuff.Sha256Hasher) GetVerticesResponse(com.radixdlt.hotstuff.sync.GetVerticesResponse) RateLimiter(com.google.common.util.concurrent.RateLimiter) TypedMocks.rmock(com.radixdlt.utils.TypedMocks.rmock) HashSigner(com.radixdlt.hotstuff.HashSigner) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) VertexStore(com.radixdlt.hotstuff.bft.VertexStore) View(com.radixdlt.hotstuff.bft.View) ImmutableList(com.google.common.collect.ImmutableList) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) AccumulatorState(com.radixdlt.ledger.AccumulatorState) UInt256(com.radixdlt.utils.UInt256) Before(org.junit.Before) BFTSync(com.radixdlt.hotstuff.sync.BFTSync) BFTHeader(com.radixdlt.hotstuff.BFTHeader) TimeSupplier(com.radixdlt.utils.TimeSupplier) EventDispatcher(com.radixdlt.environment.EventDispatcher) ScheduledLocalTimeout(com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout) NoVote(com.radixdlt.hotstuff.bft.NoVote) Txn(com.radixdlt.atom.Txn) VoteData(com.radixdlt.hotstuff.VoteData) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) VertexRequestTimeout(com.radixdlt.hotstuff.sync.VertexRequestTimeout) Provides(com.google.inject.Provides) ECKeyPair(com.radixdlt.crypto.ECKeyPair) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) TimestampedECDSASignature(com.radixdlt.hotstuff.TimestampedECDSASignature) BFTValidator(com.radixdlt.hotstuff.bft.BFTValidator) LocalTimeoutOccurrence(com.radixdlt.hotstuff.liveness.LocalTimeoutOccurrence) Guice(com.google.inject.Guice) Self(com.radixdlt.hotstuff.bft.Self) Pair(com.radixdlt.utils.Pair) LastProof(com.radixdlt.store.LastProof) AbstractModule(com.google.inject.AbstractModule) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) GetVerticesResponse(com.radixdlt.hotstuff.sync.GetVerticesResponse) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) Test(org.junit.Test)

Example 14 with HighQC

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

the class PacemakerStateTest method when_process_qc_for_wrong_view__then_ignored.

@Test
public void when_process_qc_for_wrong_view__then_ignored() {
    HighQC highQC = mock(HighQC.class);
    when(highQC.getHighestView()).thenReturn(View.of(1));
    // Move ahead for a bit so we can send in a QC for a lower view
    this.pacemakerState.processQC(highQCFor(View.of(0)));
    this.pacemakerState.processQC(highQCFor(View.of(1)));
    this.pacemakerState.processQC(highQCFor(View.of(2)));
    verify(viewUpdateSender, times(1)).dispatch(argThat(v -> v.getCurrentView().equals(View.of(1))));
    verify(viewUpdateSender, times(1)).dispatch(argThat(v -> v.getCurrentView().equals(View.of(2))));
    verify(viewUpdateSender, times(1)).dispatch(argThat(v -> v.getCurrentView().equals(View.of(3))));
    this.pacemakerState.processQC(highQC);
    verifyNoMoreInteractions(viewUpdateSender);
}
Also used : HighQC(com.radixdlt.hotstuff.HighQC) TypedMocks.rmock(com.radixdlt.utils.TypedMocks.rmock) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) Mockito(org.mockito.Mockito) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) View(com.radixdlt.hotstuff.bft.View) EventDispatcher(com.radixdlt.environment.EventDispatcher) Mockito.times(org.mockito.Mockito.times) HighQC(com.radixdlt.hotstuff.HighQC) Test(org.junit.Test) ViewUpdate(com.radixdlt.hotstuff.bft.ViewUpdate) Before(org.junit.Before) Test(org.junit.Test)

Example 15 with HighQC

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

the class PacemakerStateTest method highQCFor.

private HighQC highQCFor(View view) {
    HighQC highQC = mock(HighQC.class);
    QuorumCertificate hqc = mock(QuorumCertificate.class);
    QuorumCertificate cqc = mock(QuorumCertificate.class);
    when(hqc.getView()).thenReturn(view);
    when(cqc.getView()).thenReturn(View.of(0));
    when(highQC.highestQC()).thenReturn(hqc);
    when(highQC.highestCommittedQC()).thenReturn(cqc);
    when(highQC.getHighestView()).thenReturn(view);
    return highQC;
}
Also used : HighQC(com.radixdlt.hotstuff.HighQC) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate)

Aggregations

HighQC (com.radixdlt.hotstuff.HighQC)16 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)14 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)11 View (com.radixdlt.hotstuff.bft.View)9 Test (org.junit.Test)9 ViewUpdate (com.radixdlt.hotstuff.bft.ViewUpdate)8 EventDispatcher (com.radixdlt.environment.EventDispatcher)6 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)6 Vote (com.radixdlt.hotstuff.Vote)6 Before (org.junit.Before)6 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)5 TypedMocks.rmock (com.radixdlt.utils.TypedMocks.rmock)5 Mockito.times (org.mockito.Mockito.times)5 BFTHeader (com.radixdlt.hotstuff.BFTHeader)4 AbstractModule (com.google.inject.AbstractModule)3 Provides (com.google.inject.Provides)3 TypeLiteral (com.google.inject.TypeLiteral)3 Txn (com.radixdlt.atom.Txn)3 SystemCounters (com.radixdlt.counters.SystemCounters)3 Hasher (com.radixdlt.crypto.Hasher)3