use of com.radixdlt.hotstuff.bft.BFTNode in project radixdlt by radixdlt.
the class RadixEngineStateComputerTest method getExternalModule.
private Module getExternalModule() {
return new AbstractModule() {
@Override
public void configure() {
var validatorSet = BFTValidatorSet.from(registeredNodes.stream().map(ECKeyPair::getPublicKey).map(BFTNode::create).map(n -> BFTValidator.from(n, UInt256.ONE)));
bind(ProposerElection.class).toInstance(new WeightedRotatingLeaders(validatorSet));
bind(Serialization.class).toInstance(serialization);
bind(Hasher.class).toInstance(Sha256Hasher.withDefaultSerialization());
bind(new TypeLiteral<EngineStore<LedgerAndBFTProof>>() {
}).toInstance(engineStore);
bind(PersistentVertexStore.class).toInstance(mock(PersistentVertexStore.class));
install(MempoolConfig.asModule(10, 10));
install(new MainnetForksModule());
install(new RadixEngineForksLatestOnlyModule());
install(new ForksModule());
// HACK
bind(CommittedReader.class).toInstance(new NoOpCommittedReader());
bind(ForksEpochStore.class).toInstance(new NoOpForksEpochStore());
bind(LedgerAccumulator.class).to(SimpleLedgerAccumulatorAndVerifier.class);
bind(new TypeLiteral<EventDispatcher<MempoolAddSuccess>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<InvalidProposedTxn>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<TxnsRemovedFromMempool>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<REOutput>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<MempoolRelayTrigger>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<LedgerUpdate>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(SystemCounters.class).to(SystemCountersImpl.class);
}
};
}
use of com.radixdlt.hotstuff.bft.BFTNode 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);
}
use of com.radixdlt.hotstuff.bft.BFTNode in project radixdlt by radixdlt.
the class PacemakerState method updateView.
@Override
public void updateView(View nextView) {
if (nextView.lte(this.currentView)) {
return;
}
final BFTNode leader = this.proposerElection.getProposer(nextView);
final BFTNode nextLeader = this.proposerElection.getProposer(nextView.next());
this.currentView = nextView;
viewUpdateSender.dispatch(ViewUpdate.create(this.currentView, this.highQC, leader, nextLeader));
}
use of com.radixdlt.hotstuff.bft.BFTNode 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())));
}
use of com.radixdlt.hotstuff.bft.BFTNode in project radixdlt by radixdlt.
the class PacemakerTest method when_local_timeout__then_resend_previous_vote.
@Test
public void when_local_timeout__then_resend_previous_vote() {
View view = View.of(0);
Vote lastVote = mock(Vote.class);
Vote lastVoteWithTimeout = mock(Vote.class);
ImmutableSet<BFTNode> validators = rmock(ImmutableSet.class);
when(this.safetyRules.getLastVote(view)).thenReturn(Optional.of(lastVote));
when(this.safetyRules.timeoutVote(lastVote)).thenReturn(lastVoteWithTimeout);
when(this.validatorSet.nodes()).thenReturn(validators);
ViewUpdate viewUpdate = ViewUpdate.create(View.of(0), mock(HighQC.class), mock(BFTNode.class), mock(BFTNode.class));
this.pacemaker.processLocalTimeout(ScheduledLocalTimeout.create(viewUpdate, 0L));
verify(this.voteDispatcher, times(1)).dispatch(eq(validators), eq(lastVoteWithTimeout));
verifyNoMoreInteractions(this.vertexStore);
verify(this.safetyRules, times(1)).getLastVote(view);
verify(this.safetyRules, times(1)).timeoutVote(lastVote);
verifyNoMoreInteractions(this.safetyRules);
}
Aggregations