use of com.radixdlt.consensus.bft.VerifiedVertex 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.bft.VerifiedVertex 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.bft.VerifiedVertex in project radixdlt by radixdlt.
the class ConsensusModuleTest method setup.
@Before
public void setup() {
var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
var genesis = UnverifiedVertex.createGenesis(LedgerHeader.genesis(accumulatorState, null, 0));
var hashedGenesis = new VerifiedVertex(genesis, HashUtils.zero256());
var qc = QuorumCertificate.ofGenesis(hashedGenesis, LedgerHeader.genesis(accumulatorState, null, 0));
var validatorSet = BFTValidatorSet.from(Stream.of(BFTValidator.from(BFTNode.random(), UInt256.ONE)));
var vertexStoreState = VerifiedVertexStoreState.create(HighQC.from(qc), hashedGenesis, Optional.empty(), hasher);
var proposerElection = new WeightedRotatingLeaders(validatorSet);
this.bftConfiguration = new BFTConfiguration(proposerElection, validatorSet, vertexStoreState);
this.ecKeyPair = ECKeyPair.generateNew();
this.requestSender = rmock(RemoteEventDispatcher.class);
this.responseSender = rmock(RemoteEventDispatcher.class);
this.errorResponseSender = rmock(RemoteEventDispatcher.class);
Guice.createInjector(new ConsensusModule(), new CryptoModule(), getExternalModule()).injectMembers(this);
}
use of com.radixdlt.consensus.bft.VerifiedVertex 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.bft.VerifiedVertex 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);
}
Aggregations