Search in sources :

Example 1 with Proposal

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));
}
Also used : ECDSASignature(com.radixdlt.crypto.ECDSASignature) Proposal(com.radixdlt.consensus.Proposal) Test(org.junit.Test)

Example 2 with 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());
}
Also used : TimestampedECDSASignatures(com.radixdlt.consensus.TimestampedECDSASignatures) LedgerHeader(com.radixdlt.consensus.LedgerHeader) BFTHeader(com.radixdlt.consensus.BFTHeader) BFTNode(com.radixdlt.consensus.bft.BFTNode) HashCode(com.google.common.hash.HashCode) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) View(com.radixdlt.consensus.bft.View) VoteData(com.radixdlt.consensus.VoteData) UnverifiedVertex(com.radixdlt.consensus.UnverifiedVertex) Proposal(com.radixdlt.consensus.Proposal)

Example 3 with Proposal

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;
}
Also used : BFTNode(com.radixdlt.consensus.bft.BFTNode) View(com.radixdlt.consensus.bft.View) Proposal(com.radixdlt.consensus.Proposal)

Example 4 with Proposal

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);
        });
    }
}
Also used : BFTNode(com.radixdlt.consensus.bft.BFTNode) Proposal(com.radixdlt.consensus.Proposal)

Example 5 with Proposal

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));
}
Also used : Builder(com.radixdlt.consensus.safety.SafetyState.Builder) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Proposal(com.radixdlt.consensus.Proposal)

Aggregations

Proposal (com.radixdlt.consensus.Proposal)11 BFTNode (com.radixdlt.consensus.bft.BFTNode)5 ECDSASignature (com.radixdlt.crypto.ECDSASignature)5 View (com.radixdlt.consensus.bft.View)4 Test (org.junit.Test)4 AbstractModule (com.google.inject.AbstractModule)2 TypeLiteral (com.google.inject.TypeLiteral)2 BFTConfiguration (com.radixdlt.consensus.BFTConfiguration)2 HashSigner (com.radixdlt.consensus.HashSigner)2 HighQC (com.radixdlt.consensus.HighQC)2 Vote (com.radixdlt.consensus.Vote)2 BFTCommittedUpdate (com.radixdlt.consensus.bft.BFTCommittedUpdate)2 BFTHighQCUpdate (com.radixdlt.consensus.bft.BFTHighQCUpdate)2 BFTInsertUpdate (com.radixdlt.consensus.bft.BFTInsertUpdate)2 BFTRebuildUpdate (com.radixdlt.consensus.bft.BFTRebuildUpdate)2 NoVote (com.radixdlt.consensus.bft.NoVote)2 PacemakerMaxExponent (com.radixdlt.consensus.bft.PacemakerMaxExponent)2 PacemakerRate (com.radixdlt.consensus.bft.PacemakerRate)2 PacemakerTimeout (com.radixdlt.consensus.bft.PacemakerTimeout)2 PersistentVertexStore (com.radixdlt.consensus.bft.PersistentVertexStore)2