use of com.radixdlt.consensus.QuorumCertificate in project radixdlt by radixdlt.
the class Pacemaker method generateProposal.
private Optional<Proposal> generateProposal(View view) {
final HighQC highQC = this.latestViewUpdate.getHighQC();
final QuorumCertificate highestQC = highQC.highestQC();
final List<Txn> nextTxns;
// TODO: Remove isEndOfEpoch knowledge from consensus
if (highestQC.getProposed().getLedgerHeader().isEndOfEpoch()) {
nextTxns = List.of();
} else {
final List<PreparedVertex> preparedVertices = vertexStore.getPathFromRoot(highestQC.getProposed().getVertexId());
nextTxns = nextTxnsGenerator.generateNextTxns(view, preparedVertices);
systemCounters.add(SystemCounters.CounterType.BFT_PACEMAKER_PROPOSED_TRANSACTIONS, nextTxns.size());
}
final UnverifiedVertex proposedVertex = UnverifiedVertex.create(highestQC, view, nextTxns, self);
final VerifiedVertex verifiedVertex = new VerifiedVertex(proposedVertex, hasher.hash(proposedVertex));
return safetyRules.signProposal(verifiedVertex, highQC.highestCommittedQC(), highQC.highestTC());
}
use of com.radixdlt.consensus.QuorumCertificate 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
BFTNode bftNode = BFTNode.random();
QuorumCertificate parent = vertexStore.highQC().highestQC();
Pair<QuorumCertificate, VerifiedVertex> nextVertex = createNextVertex(parent, bftNode);
HighQC unsyncedHighQC = HighQC.from(nextVertex.getFirst(), nextVertex.getFirst(), Optional.empty());
bftSync.syncToQC(unsyncedHighQC, bftNode);
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(bftNode), argThat(r -> r.getCount() == 1 && r.getVertexId().equals(nextVertex.getSecond().getId())));
}
use of com.radixdlt.consensus.QuorumCertificate 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, bftNode);
Pair<QuorumCertificate, VerifiedVertex> nextNextVertex = createNextVertex(nextVertex.getFirst(), bftNode);
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.consensus.QuorumCertificate in project radixdlt by radixdlt.
the class ConsensusModuleTest method createNextVertex.
private Pair<QuorumCertificate, VerifiedVertex> createNextVertex(QuorumCertificate parent, BFTNode bftNode, Txn txn) {
var unverifiedVertex = UnverifiedVertex.create(parent, View.of(1), List.of(txn), bftNode);
var hash = hasher.hash(unverifiedVertex);
var verifiedVertex = new VerifiedVertex(unverifiedVertex, hash);
var next = new BFTHeader(View.of(1), verifiedVertex.getId(), LedgerHeader.create(1, View.of(1), new AccumulatorState(1, HashUtils.zero256()), 1));
var voteData = new VoteData(next, parent.getProposed(), parent.getParent());
var unsyncedQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures(Map.of(bftNode, TimestampedECDSASignature.from(1, zeroSignature()))));
return Pair.of(unsyncedQC, verifiedVertex);
}
use of com.radixdlt.consensus.QuorumCertificate in project radixdlt by radixdlt.
the class VertexStoreTest method adding_a_qc_which_has_not_been_inserted_should_return_false.
@Test
public void adding_a_qc_which_has_not_been_inserted_should_return_false() {
// Arrange
this.nextVertex.get();
// Act
QuorumCertificate qc = this.nextVertex.get().getQC();
boolean success = sut.addQC(qc);
// Assert
assertThat(success).isFalse();
}
Aggregations