Search in sources :

Example 1 with EpochChange

use of com.radixdlt.hotstuff.epoch.EpochChange 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

ImmutableClassToInstanceMap (com.google.common.collect.ImmutableClassToInstanceMap)1 Inject (com.google.inject.Inject)1 Txn (com.radixdlt.atom.Txn)1 Hasher (com.radixdlt.crypto.Hasher)1 EventDispatcher (com.radixdlt.environment.EventDispatcher)1 BFTConfiguration (com.radixdlt.hotstuff.BFTConfiguration)1 HighQC (com.radixdlt.hotstuff.HighQC)1 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)1 LedgerProof (com.radixdlt.hotstuff.LedgerProof)1 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)1 UnverifiedVertex (com.radixdlt.hotstuff.UnverifiedVertex)1 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)1 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)1 VerifiedVertexStoreState (com.radixdlt.hotstuff.bft.VerifiedVertexStoreState)1 View (com.radixdlt.hotstuff.bft.View)1 EpochChange (com.radixdlt.hotstuff.epoch.EpochChange)1 WeightedRotatingLeaders (com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders)1 LedgerUpdate (com.radixdlt.ledger.LedgerUpdate)1 MockPrepared (com.radixdlt.ledger.MockPrepared)1 StateComputerLedger (com.radixdlt.ledger.StateComputerLedger)1