Search in sources :

Example 1 with UnverifiedVertex

use of com.radixdlt.hotstuff.UnverifiedVertex in project radixdlt by radixdlt.

the class MockedRecoveryModule method configuration.

@Provides
private BFTConfiguration configuration(@LastEpochProof LedgerProof proof, BFTValidatorSet validatorSet, Hasher hasher) {
    var accumulatorState = new AccumulatorState(0, genesisHash);
    UnverifiedVertex genesis = UnverifiedVertex.createGenesis(LedgerHeader.genesis(accumulatorState, validatorSet, 0));
    VerifiedVertex verifiedGenesis = new VerifiedVertex(genesis, genesisHash);
    LedgerHeader nextLedgerHeader = LedgerHeader.create(proof.getEpoch() + 1, View.genesis(), proof.getAccumulatorState(), proof.timestamp());
    var genesisQC = QuorumCertificate.ofGenesis(verifiedGenesis, nextLedgerHeader);
    var proposerElection = new WeightedRotatingLeaders(validatorSet);
    return new BFTConfiguration(proposerElection, validatorSet, VerifiedVertexStoreState.create(HighQC.from(genesisQC), verifiedGenesis, Optional.empty(), hasher));
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) AccumulatorState(com.radixdlt.ledger.AccumulatorState) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) WeightedRotatingLeaders(com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders) Provides(com.google.inject.Provides)

Example 2 with UnverifiedVertex

use of com.radixdlt.hotstuff.UnverifiedVertex 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.hotstuff.TimestampedECDSASignatures) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTHeader(com.radixdlt.hotstuff.BFTHeader) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) HashCode(com.google.common.hash.HashCode) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) View(com.radixdlt.hotstuff.bft.View) VoteData(com.radixdlt.hotstuff.VoteData) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) Proposal(com.radixdlt.hotstuff.Proposal)

Example 3 with UnverifiedVertex

use of com.radixdlt.hotstuff.UnverifiedVertex in project radixdlt by radixdlt.

the class GetVerticesResponseMessageTest method sensibleToString.

@Test
public void sensibleToString() {
    UnverifiedVertex genesisVertex = mock(UnverifiedVertex.class);
    GetVerticesResponseMessage msg1 = new GetVerticesResponseMessage(ImmutableList.of(genesisVertex));
    String s1 = msg1.toString();
    assertThat(s1).contains(GetVerticesResponseMessage.class.getSimpleName()).contains(genesisVertex.toString());
}
Also used : UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) Test(org.junit.Test)

Example 4 with UnverifiedVertex

use of com.radixdlt.hotstuff.UnverifiedVertex 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());
}
Also used : HighQC(com.radixdlt.hotstuff.HighQC) VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) PreparedVertex(com.radixdlt.hotstuff.bft.PreparedVertex) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) Txn(com.radixdlt.atom.Txn) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex)

Example 5 with UnverifiedVertex

use of com.radixdlt.hotstuff.UnverifiedVertex in project radixdlt by radixdlt.

the class MockedStateComputer method commit.

@Override
public void commit(VerifiedTxnsAndProof txnsAndProof, VerifiedVertexStoreState vertexStoreState) {
    var output = txnsAndProof.getProof().getNextValidatorSet().map(validatorSet -> {
        LedgerProof header = txnsAndProof.getProof();
        UnverifiedVertex genesisVertex = UnverifiedVertex.createGenesis(header.getRaw());
        VerifiedVertex verifiedGenesisVertex = new VerifiedVertex(genesisVertex, hasher.hash(genesisVertex));
        LedgerHeader nextLedgerHeader = LedgerHeader.create(header.getEpoch() + 1, View.genesis(), header.getAccumulatorState(), header.timestamp());
        QuorumCertificate genesisQC = QuorumCertificate.ofGenesis(verifiedGenesisVertex, nextLedgerHeader);
        final var initialState = VerifiedVertexStoreState.create(HighQC.from(genesisQC), verifiedGenesisVertex, Optional.empty(), hasher);
        var proposerElection = new WeightedRotatingLeaders(validatorSet);
        var bftConfiguration = new BFTConfiguration(proposerElection, validatorSet, initialState);
        return new EpochChange(header, bftConfiguration);
    }).map(e -> ImmutableClassToInstanceMap.<Object, EpochChange>of(EpochChange.class, e)).orElse(ImmutableClassToInstanceMap.of());
    var ledgerUpdate = new LedgerUpdate(txnsAndProof, output);
    ledgerUpdateDispatcher.dispatch(ledgerUpdate);
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) LedgerProof(com.radixdlt.hotstuff.LedgerProof) Inject(com.google.inject.Inject) WeightedRotatingLeaders(com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders) Hasher(com.radixdlt.crypto.Hasher) HighQC(com.radixdlt.hotstuff.HighQC) VerifiedVertexStoreState(com.radixdlt.hotstuff.bft.VerifiedVertexStoreState) MempoolAdd(com.radixdlt.mempool.MempoolAdd) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) View(com.radixdlt.hotstuff.bft.View) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) VerifiedTxnsAndProof(com.radixdlt.ledger.VerifiedTxnsAndProof) Map(java.util.Map) MockPrepared(com.radixdlt.ledger.MockPrepared) Nullable(javax.annotation.Nullable) EventDispatcher(com.radixdlt.environment.EventDispatcher) Txn(com.radixdlt.atom.Txn) VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) StateComputer(com.radixdlt.ledger.StateComputerLedger.StateComputer) EpochChange(com.radixdlt.hotstuff.epoch.EpochChange) Collectors(java.util.stream.Collectors) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) StateComputerLedger(com.radixdlt.ledger.StateComputerLedger) List(java.util.List) Optional(java.util.Optional) ImmutableClassToInstanceMap(com.google.common.collect.ImmutableClassToInstanceMap) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) EpochChange(com.radixdlt.hotstuff.epoch.EpochChange) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) LedgerProof(com.radixdlt.hotstuff.LedgerProof) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) WeightedRotatingLeaders(com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders)

Aggregations

UnverifiedVertex (com.radixdlt.hotstuff.UnverifiedVertex)9 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)6 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)6 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)5 Txn (com.radixdlt.atom.Txn)4 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)4 View (com.radixdlt.hotstuff.bft.View)4 Hasher (com.radixdlt.crypto.Hasher)3 BFTConfiguration (com.radixdlt.hotstuff.BFTConfiguration)3 HighQC (com.radixdlt.hotstuff.HighQC)3 LedgerProof (com.radixdlt.hotstuff.LedgerProof)3 Proposal (com.radixdlt.hotstuff.Proposal)3 WeightedRotatingLeaders (com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders)3 StateComputer (com.radixdlt.ledger.StateComputerLedger.StateComputer)3 List (java.util.List)3 Optional (java.util.Optional)3 Test (org.junit.Test)3 ImmutableClassToInstanceMap (com.google.common.collect.ImmutableClassToInstanceMap)2 Inject (com.google.inject.Inject)2 SystemCounters (com.radixdlt.counters.SystemCounters)2