Search in sources :

Example 6 with BFTNode

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

the class LocalSyncServiceTest method when_status_timeout_with_no_responses__then_should_reschedule_another_check.

@Test
public void when_status_timeout_with_no_responses__then_should_reschedule_another_check() {
    final LedgerProof currentHeader = createHeaderAtStateVersion(10L);
    final BFTNode waiting1 = createPeer();
    setupPeersView(waiting1);
    final var syncState = SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of(waiting1));
    this.setupSyncServiceWithState(syncState);
    this.localSyncService.syncCheckReceiveStatusTimeoutEventProcessor().process(SyncCheckReceiveStatusTimeout.create());
    verifyNoMoreInteractions(syncRequestDispatcher);
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Example 7 with BFTNode

use of com.radixdlt.hotstuff.bft.BFTNode 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 8 with BFTNode

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

the class MessageCentralValidatorSync method responses.

public Flowable<RemoteEvent<GetVerticesResponse>> responses() {
    return this.createFlowable(GetVerticesResponseMessage.class, (src, msg) -> {
        BFTNode node = BFTNode.create(src.getPublicKey());
        // TODO: Move hasher to a more appropriate place
        ImmutableList<VerifiedVertex> hashedVertices = msg.getVertices().stream().map(v -> new VerifiedVertex(v, hasher.hash(v))).collect(ImmutableList.toImmutableList());
        return RemoteEvent.create(node, new GetVerticesResponse(hashedVertices));
    });
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) Flowable(io.reactivex.rxjava3.core.Flowable) Message(org.radix.network.messaging.Message) Inject(com.google.inject.Inject) BiFunction(java.util.function.BiFunction) Hasher(com.radixdlt.crypto.Hasher) VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) GetVerticesResponse(com.radixdlt.hotstuff.sync.GetVerticesResponse) RemoteEvent(com.radixdlt.environment.rx.RemoteEvent) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) Objects(java.util.Objects) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) ImmutableList(com.google.common.collect.ImmutableList) NodeId(com.radixdlt.network.p2p.NodeId) BackpressureStrategy(io.reactivex.rxjava3.core.BackpressureStrategy) MessageCentral(com.radixdlt.network.messaging.MessageCentral) GetVerticesErrorResponse(com.radixdlt.hotstuff.sync.GetVerticesErrorResponse) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) GetVerticesResponse(com.radixdlt.hotstuff.sync.GetVerticesResponse)

Example 9 with BFTNode

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

the class VoteSerializeTest method get.

private static Vote 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);
    BFTNode author = BFTNode.create(ECKeyPair.generateNew().getPublicKey());
    QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    HighQC highQC = HighQC.from(qc, qc, Optional.empty());
    return new Vote(author, voteData, 123456L, ECDSASignature.zeroSignature(), highQC, Optional.empty());
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) HighQC(com.radixdlt.hotstuff.HighQC) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTHeader(com.radixdlt.hotstuff.BFTHeader) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) Vote(com.radixdlt.hotstuff.Vote) HashCode(com.google.common.hash.HashCode) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) View(com.radixdlt.hotstuff.bft.View) VoteData(com.radixdlt.hotstuff.VoteData)

Example 10 with BFTNode

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

Aggregations

BFTNode (com.radixdlt.hotstuff.bft.BFTNode)40 Test (org.junit.Test)22 View (com.radixdlt.hotstuff.bft.View)14 LedgerProof (com.radixdlt.hotstuff.LedgerProof)9 BFTValidatorSet (com.radixdlt.hotstuff.bft.BFTValidatorSet)9 HashCode (com.google.common.hash.HashCode)8 ECKeyPair (com.radixdlt.crypto.ECKeyPair)8 HighQC (com.radixdlt.hotstuff.HighQC)8 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)8 Vote (com.radixdlt.hotstuff.Vote)7 ImmutableList (com.google.common.collect.ImmutableList)6 AbstractModule (com.google.inject.AbstractModule)6 TypeLiteral (com.google.inject.TypeLiteral)6 BFTHeader (com.radixdlt.hotstuff.BFTHeader)6 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)6 Proposal (com.radixdlt.hotstuff.Proposal)5 TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)5 BFTCommittedUpdate (com.radixdlt.hotstuff.bft.BFTCommittedUpdate)5 Self (com.radixdlt.hotstuff.bft.Self)5 Inject (com.google.inject.Inject)4