use of com.radixdlt.consensus.Proposal in project radixdlt by radixdlt.
the class BFTEventVerifierTest method when_process_correct_proposal_then_should_be_forwarded.
@Test
public void when_process_correct_proposal_then_should_be_forwarded() {
Proposal proposal = mock(Proposal.class);
BFTNode author = mock(BFTNode.class);
when(proposal.getAuthor()).thenReturn(author);
when(proposal.getSignature()).thenReturn(mock(ECDSASignature.class));
when(validatorSet.containsNode(eq(author))).thenReturn(true);
when(verifier.verify(any(), any(), any())).thenReturn(true);
eventVerifier.processProposal(proposal);
verify(forwardTo, times(1)).processProposal(eq(proposal));
}
use of com.radixdlt.consensus.Proposal in project radixdlt by radixdlt.
the class ProposalSerializeTest method get.
private static Proposal get() {
View view = View.of(1234567891L);
HashCode id = HashUtils.random256();
LedgerHeader ledgerHeader = LedgerHeaderMock.get();
BFTHeader header = new BFTHeader(view, id, ledgerHeader);
BFTHeader parent = new BFTHeader(View.of(1234567890L), HashUtils.random256(), ledgerHeader);
VoteData voteData = new VoteData(header, parent, null);
QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
var txn = Txn.create(new byte[] { 0, 1, 2, 3 });
// add a particle to ensure atom is valid and has at least one shard
BFTNode author = BFTNode.create(ECKeyPair.generateNew().getPublicKey());
UnverifiedVertex vertex = UnverifiedVertex.create(qc, view, List.of(txn), author);
return new Proposal(vertex, qc, ECDSASignature.zeroSignature(), Optional.empty());
}
use of com.radixdlt.consensus.Proposal 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.Proposal in project radixdlt by radixdlt.
the class Pacemaker method startView.
private void startView() {
this.isViewTimedOut = false;
this.timeoutVoteVertexId = Optional.empty();
long timeout = timeoutCalculator.timeout(latestViewUpdate.uncommittedViewsCount());
ScheduledLocalTimeout scheduledLocalTimeout = ScheduledLocalTimeout.create(latestViewUpdate, timeout);
this.timeoutSender.dispatch(scheduledLocalTimeout, timeout);
final BFTNode currentViewProposer = latestViewUpdate.getLeader();
if (this.self.equals(currentViewProposer)) {
Optional<Proposal> proposalMaybe = generateProposal(latestViewUpdate.getCurrentView());
proposalMaybe.ifPresent(proposal -> {
log.trace("Broadcasting proposal: {}", proposal);
this.proposalDispatcher.dispatch(this.validatorSet.nodes(), proposal);
this.counters.increment(CounterType.BFT_PACEMAKER_PROPOSALS_SENT);
});
}
}
use of com.radixdlt.consensus.Proposal in project radixdlt by radixdlt.
the class SafetyRules method signProposal.
/**
* Create a signed proposal from a vertex
*
* @param proposedVertex vertex to sign
* @param highestCommittedQC highest known committed QC
* @param highestTC highest known TC
* @return signed proposal object for consensus
*/
public Optional<Proposal> signProposal(VerifiedVertex proposedVertex, QuorumCertificate highestCommittedQC, Optional<TimeoutCertificate> highestTC) {
final Builder safetyStateBuilder = this.state.toBuilder();
if (!checkLocked(proposedVertex, safetyStateBuilder)) {
return Optional.empty();
}
this.state = safetyStateBuilder.build();
final ECDSASignature signature = this.signer.sign(proposedVertex.getId());
return Optional.of(new Proposal(proposedVertex.toSerializable(), highestCommittedQC, signature, highestTC));
}
Aggregations