Search in sources :

Example 11 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class VoteDataSerializeTest method get.

private static VoteData get() {
    View view = View.of(1234567890L);
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    BFTHeader committed = new BFTHeader(view, HashUtils.random256(), ledgerHeader);
    BFTHeader parent = new BFTHeader(view.next(), HashUtils.random256(), ledgerHeader);
    BFTHeader proposed = new BFTHeader(view.next().next(), HashUtils.random256(), ledgerHeader);
    return new VoteData(proposed, parent, committed);
}
Also used : LedgerHeader(com.radixdlt.consensus.LedgerHeader) BFTHeader(com.radixdlt.consensus.BFTHeader) View(com.radixdlt.consensus.bft.View) VoteData(com.radixdlt.consensus.VoteData)

Example 12 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class MovingWindowValidatorsTest method run.

private void run(int numNodes, int windowSize, long maxEpoch, View highView) {
    DeterministicTest bftTest = DeterministicTest.builder().numNodes(numNodes).messageMutator(mutator()).messageSelector(firstSelector()).epochNodeIndexesMapping(windowedEpochToNodesMapper(windowSize, numNodes)).buildWithEpochs(highView).runUntil(DeterministicTest.hasReachedEpochView(EpochView.of(maxEpoch, highView)));
    LinkedList<SystemCounters> testCounters = systemCounters(bftTest);
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_VERTEX_STORE_INDIRECT_PARENTS)).containsOnly(0L);
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_PACEMAKER_TIMEOUTS_SENT)).containsOnly(0L);
    long maxCount = maxProcessedFor(numNodes, windowSize, maxEpoch, highView.number());
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_COMMITTED_VERTICES)).allMatch(between(maxCount - maxEpoch, maxCount));
}
Also used : IntStream(java.util.stream.IntStream) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) ScheduledLocalTimeout(com.radixdlt.consensus.liveness.ScheduledLocalTimeout) SystemCounters(com.radixdlt.counters.SystemCounters) Epoched(com.radixdlt.consensus.epoch.Epoched) LongFunction(java.util.function.LongFunction) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Collectors(java.util.stream.Collectors) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) EpochView(com.radixdlt.consensus.epoch.EpochView) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) MessageMutator(com.radixdlt.environment.deterministic.network.MessageMutator) ChannelId(com.radixdlt.environment.deterministic.network.ChannelId) LinkedList(java.util.LinkedList) CounterType(com.radixdlt.counters.SystemCounters.CounterType) View(com.radixdlt.consensus.bft.View) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) SystemCounters(com.radixdlt.counters.SystemCounters)

Example 13 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class FProposalsPerViewDropper method test.

@Override
public boolean test(SimulationNetwork.MessageInTransit msg) {
    if (msg.getContent() instanceof Proposal) {
        final Proposal proposal = (Proposal) msg.getContent();
        final View view = proposal.getVertex().getView();
        final Set<BFTNode> nodesToDrop = proposalToDrop.computeIfAbsent(view, v -> {
            final List<BFTNode> nodes = Lists.newArrayList(validatorSet);
            if (random != null) {
                Collections.shuffle(nodes, random);
            }
            return ImmutableSet.copyOf(nodes.subList(0, faultySize));
        });
        if (proposalCount.merge(view, 1, Integer::sum).equals(validatorSet.size())) {
            proposalToDrop.remove(view);
            proposalCount.remove(view);
        }
        return nodesToDrop.contains(msg.getReceiver());
    }
    return false;
}
Also used : BFTNode(com.radixdlt.consensus.bft.BFTNode) View(com.radixdlt.consensus.bft.View) Proposal(com.radixdlt.consensus.Proposal)

Example 14 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class Pacemaker method processViewUpdate.

/**
 * Processes a local view update message *
 */
public void processViewUpdate(ViewUpdate viewUpdate) {
    log.trace("View Update: {}", viewUpdate);
    final View previousView = this.latestViewUpdate.getCurrentView();
    if (viewUpdate.getCurrentView().lte(previousView)) {
        return;
    }
    this.latestViewUpdate = viewUpdate;
    this.systemCounters.set(CounterType.BFT_PACEMAKER_ROUND, viewUpdate.getCurrentView().number());
    this.startView();
}
Also used : View(com.radixdlt.consensus.bft.View)

Example 15 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class ConsensusModuleTest method getExternalModule.

private Module getExternalModule() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            bind(Ledger.class).toInstance(mock(Ledger.class));
            bind(new TypeLiteral<EventDispatcher<LocalTimeoutOccurrence>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<ViewUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTInsertUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTRebuildUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTHighQCUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTCommittedUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<LocalSyncRequest>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<ScheduledEventDispatcher<GetVerticesRequest>>() {
            }).toInstance(rmock(ScheduledEventDispatcher.class));
            bind(new TypeLiteral<ScheduledEventDispatcher<ScheduledLocalTimeout>>() {
            }).toInstance(rmock(ScheduledEventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<ViewQuorumReached>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<RemoteEventDispatcher<Vote>>() {
            }).toInstance(rmock(RemoteEventDispatcher.class));
            bind(new TypeLiteral<RemoteEventDispatcher<Proposal>>() {
            }).toInstance(rmock(RemoteEventDispatcher.class));
            bind(new TypeLiteral<RemoteEventDispatcher<GetVerticesRequest>>() {
            }).toInstance(requestSender);
            bind(new TypeLiteral<RemoteEventDispatcher<GetVerticesResponse>>() {
            }).toInstance(responseSender);
            bind(new TypeLiteral<RemoteEventDispatcher<GetVerticesErrorResponse>>() {
            }).toInstance(errorResponseSender);
            bind(new TypeLiteral<EventDispatcher<NoVote>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<ScheduledEventDispatcher<View>>() {
            }).toInstance(rmock(ScheduledEventDispatcher.class));
            bind(new TypeLiteral<ScheduledEventDispatcher<VertexRequestTimeout>>() {
            }).toInstance(rmock(ScheduledEventDispatcher.class));
            bind(PersistentVertexStore.class).toInstance(mock(PersistentVertexStore.class));
            bind(PersistentSafetyStateStore.class).toInstance(mock(PersistentSafetyStateStore.class));
            bind(NextTxnsGenerator.class).toInstance(mock(NextTxnsGenerator.class));
            bind(SystemCounters.class).toInstance(mock(SystemCounters.class));
            bind(TimeSupplier.class).toInstance(mock(TimeSupplier.class));
            bind(BFTConfiguration.class).toInstance(bftConfiguration);
            LedgerProof proof = mock(LedgerProof.class);
            when(proof.getView()).thenReturn(View.genesis());
            bind(LedgerProof.class).annotatedWith(LastProof.class).toInstance(proof);
            bind(RateLimiter.class).annotatedWith(GetVerticesRequestRateLimit.class).toInstance(RateLimiter.create(Double.MAX_VALUE));
            bindConstant().annotatedWith(BFTSyncPatienceMillis.class).to(200);
            bindConstant().annotatedWith(PacemakerTimeout.class).to(1000L);
            bindConstant().annotatedWith(PacemakerRate.class).to(2.0);
            bindConstant().annotatedWith(PacemakerMaxExponent.class).to(6);
            ECKeyPair ecKeyPair = ECKeyPair.generateNew();
            bind(HashSigner.class).toInstance(ecKeyPair::sign);
        }

        @Provides
        ViewUpdate viewUpdate(@Self BFTNode node) {
            return ViewUpdate.create(View.of(1), mock(HighQC.class), node, node);
        }

        @Provides
        @Self
        private BFTNode bftNode() {
            return BFTNode.create(ecKeyPair.getPublicKey());
        }
    };
}
Also used : HighQC(com.radixdlt.consensus.HighQC) GetVerticesRequest(com.radixdlt.consensus.sync.GetVerticesRequest) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) LocalTimeoutOccurrence(com.radixdlt.consensus.liveness.LocalTimeoutOccurrence) BFTCommittedUpdate(com.radixdlt.consensus.bft.BFTCommittedUpdate) VertexRequestTimeout(com.radixdlt.consensus.sync.VertexRequestTimeout) TimeSupplier(com.radixdlt.utils.TimeSupplier) Self(com.radixdlt.consensus.bft.Self) PersistentVertexStore(com.radixdlt.consensus.bft.PersistentVertexStore) NextTxnsGenerator(com.radixdlt.consensus.liveness.NextTxnsGenerator) BFTInsertUpdate(com.radixdlt.consensus.bft.BFTInsertUpdate) PacemakerMaxExponent(com.radixdlt.consensus.bft.PacemakerMaxExponent) ViewUpdate(com.radixdlt.consensus.bft.ViewUpdate) PacemakerRate(com.radixdlt.consensus.bft.PacemakerRate) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) EventDispatcher(com.radixdlt.environment.EventDispatcher) TypeLiteral(com.google.inject.TypeLiteral) LedgerProof(com.radixdlt.consensus.LedgerProof) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) BFTNode(com.radixdlt.consensus.bft.BFTNode) Vote(com.radixdlt.consensus.Vote) NoVote(com.radixdlt.consensus.bft.NoVote) BFTSyncPatienceMillis(com.radixdlt.consensus.sync.BFTSyncPatienceMillis) GetVerticesResponse(com.radixdlt.consensus.sync.GetVerticesResponse) BFTRebuildUpdate(com.radixdlt.consensus.bft.BFTRebuildUpdate) GetVerticesErrorResponse(com.radixdlt.consensus.sync.GetVerticesErrorResponse) Ledger(com.radixdlt.consensus.Ledger) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) ECKeyPair(com.radixdlt.crypto.ECKeyPair) HashSigner(com.radixdlt.consensus.HashSigner) SystemCounters(com.radixdlt.counters.SystemCounters) PacemakerTimeout(com.radixdlt.consensus.bft.PacemakerTimeout) View(com.radixdlt.consensus.bft.View) AbstractModule(com.google.inject.AbstractModule) LastProof(com.radixdlt.store.LastProof) NoVote(com.radixdlt.consensus.bft.NoVote) BFTConfiguration(com.radixdlt.consensus.BFTConfiguration) ViewQuorumReached(com.radixdlt.consensus.bft.ViewQuorumReached) ScheduledLocalTimeout(com.radixdlt.consensus.liveness.ScheduledLocalTimeout) BFTHighQCUpdate(com.radixdlt.consensus.bft.BFTHighQCUpdate) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) PersistentSafetyStateStore(com.radixdlt.consensus.safety.PersistentSafetyStateStore) Proposal(com.radixdlt.consensus.Proposal)

Aggregations

View (com.radixdlt.consensus.bft.View)24 BFTNode (com.radixdlt.consensus.bft.BFTNode)11 Test (org.junit.Test)10 HighQC (com.radixdlt.consensus.HighQC)8 BFTHeader (com.radixdlt.consensus.BFTHeader)7 HashCode (com.google.common.hash.HashCode)6 LedgerHeader (com.radixdlt.consensus.LedgerHeader)5 QuorumCertificate (com.radixdlt.consensus.QuorumCertificate)5 Vote (com.radixdlt.consensus.Vote)5 ViewUpdate (com.radixdlt.consensus.bft.ViewUpdate)5 Proposal (com.radixdlt.consensus.Proposal)4 VoteData (com.radixdlt.consensus.VoteData)4 TimestampedECDSASignatures (com.radixdlt.consensus.TimestampedECDSASignatures)3 BFTInsertUpdate (com.radixdlt.consensus.bft.BFTInsertUpdate)3 VerifiedVertex (com.radixdlt.consensus.bft.VerifiedVertex)3 ScheduledLocalTimeout (com.radixdlt.consensus.liveness.ScheduledLocalTimeout)3 SystemCounters (com.radixdlt.counters.SystemCounters)3 EventDispatcher (com.radixdlt.environment.EventDispatcher)3 Before (org.junit.Before)3 AbstractModule (com.google.inject.AbstractModule)2