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);
}
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));
}
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;
}
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();
}
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());
}
};
}
Aggregations