Search in sources :

Example 1 with View

use of com.radixdlt.hotstuff.bft.View in project radixdlt by radixdlt.

the class HighQCTest method get.

private static HighQC 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);
    BFTHeader commit = new BFTHeader(View.of(1234567889L), HashUtils.random256(), ledgerHeader);
    VoteData voteData = new VoteData(header, parent, commit);
    QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    return HighQC.from(qc, qc, Optional.empty());
}
Also used : HashCode(com.google.common.hash.HashCode) View(com.radixdlt.hotstuff.bft.View)

Example 2 with View

use of com.radixdlt.hotstuff.bft.View 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.hotstuff.bft.BFTNode) View(com.radixdlt.hotstuff.bft.View) Proposal(com.radixdlt.hotstuff.Proposal)

Example 3 with View

use of com.radixdlt.hotstuff.bft.View in project radixdlt by radixdlt.

the class MovingWindowValidatorsTest method run.

private void run(int numNodes, int windowSize, long maxEpoch, View highView) {
    DeterministicTest bftTest = DeterministicTest.builder().numNodes(numNodes).messageMutator(mutator()).messageSelector(firstSelector()).epochNodeIndexesMapping(windowedEpochToNodesMapper(windowSize, numNodes)).buildWithEpochs(highView).runUntil(DeterministicTest.hasReachedEpochView(EpochView.of(maxEpoch, highView)));
    LinkedList<SystemCounters> testCounters = systemCounters(bftTest);
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_VERTEX_STORE_INDIRECT_PARENTS)).containsOnly(0L);
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_PACEMAKER_TIMEOUTS_SENT)).containsOnly(0L);
    long maxCount = maxProcessedFor(numNodes, windowSize, maxEpoch, highView.number());
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_COMMITTED_VERTICES)).allMatch(between(maxCount - maxEpoch, maxCount));
}
Also used : IntStream(java.util.stream.IntStream) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) EpochView(com.radixdlt.hotstuff.epoch.EpochView) SystemCounters(com.radixdlt.counters.SystemCounters) LongFunction(java.util.function.LongFunction) ScheduledLocalTimeout(com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Collectors(java.util.stream.Collectors) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) Epoched(com.radixdlt.hotstuff.epoch.Epoched) View(com.radixdlt.hotstuff.bft.View) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) MessageMutator(com.radixdlt.environment.deterministic.network.MessageMutator) ChannelId(com.radixdlt.environment.deterministic.network.ChannelId) LinkedList(java.util.LinkedList) CounterType(com.radixdlt.counters.SystemCounters.CounterType) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) SystemCounters(com.radixdlt.counters.SystemCounters)

Example 4 with View

use of com.radixdlt.hotstuff.bft.View in project radixdlt by radixdlt.

the class UnverifiedVertexSerializeTest method get.

private static UnverifiedVertex get() {
    View view = View.of(1234567891L);
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    BFTHeader header = new BFTHeader(view, HashUtils.random256(), 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 });
    return UnverifiedVertex.create(qc, view, List.of(txn), BFTNode.random());
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTHeader(com.radixdlt.hotstuff.BFTHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) View(com.radixdlt.hotstuff.bft.View) VoteData(com.radixdlt.hotstuff.VoteData)

Example 5 with View

use of com.radixdlt.hotstuff.bft.View in project radixdlt by radixdlt.

the class VoteDataSerializeTest method get.

private static VoteData get() {
    View view = View.of(1234567890L);
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    BFTHeader committed = new BFTHeader(view, HashUtils.random256(), ledgerHeader);
    BFTHeader parent = new BFTHeader(view.next(), HashUtils.random256(), ledgerHeader);
    BFTHeader proposed = new BFTHeader(view.next().next(), HashUtils.random256(), ledgerHeader);
    return new VoteData(proposed, parent, committed);
}
Also used : LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTHeader(com.radixdlt.hotstuff.BFTHeader) View(com.radixdlt.hotstuff.bft.View) VoteData(com.radixdlt.hotstuff.VoteData)

Aggregations

View (com.radixdlt.hotstuff.bft.View)24 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)11 Test (org.junit.Test)10 HighQC (com.radixdlt.hotstuff.HighQC)8 BFTHeader (com.radixdlt.hotstuff.BFTHeader)7 HashCode (com.google.common.hash.HashCode)6 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)6 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)5 Vote (com.radixdlt.hotstuff.Vote)5 ViewUpdate (com.radixdlt.hotstuff.bft.ViewUpdate)5 Proposal (com.radixdlt.hotstuff.Proposal)4 VoteData (com.radixdlt.hotstuff.VoteData)4 SystemCounters (com.radixdlt.counters.SystemCounters)3 EventDispatcher (com.radixdlt.environment.EventDispatcher)3 TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)3 BFTInsertUpdate (com.radixdlt.hotstuff.bft.BFTInsertUpdate)3 BFTValidatorSet (com.radixdlt.hotstuff.bft.BFTValidatorSet)3 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)3 ScheduledLocalTimeout (com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout)3 Before (org.junit.Before)3