Search in sources :

Example 31 with BFTNode

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

the class SimulationNodes method createBFTModule.

private Module createBFTModule(ECKeyPair self) {
    Module module = Modules.combine(new AbstractModule() {

        @Provides
        @Self
        private BFTNode self() {
            return BFTNode.create(self.getPublicKey());
        }

        @Provides
        @Self
        private ECPublicKey key() {
            return self.getPublicKey();
        }

        @Provides
        private ECKeyPair keyPair() {
            return self;
        }

        @Provides
        @LocalSigner
        HashSigner hashSigner() {
            return self::sign;
        }
    }, new NodeNetworkMessagesModule(underlyingNetwork), baseModule);
    // can break network behavior if incorrect modules are used
    if (overrideModules.containsKey(self.getPublicKey())) {
        final var nodeOverrideModules = overrideModules.get(self.getPublicKey());
        module = Modules.override(module).with(nodeOverrideModules);
    }
    return module;
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) ECPublicKey(com.radixdlt.crypto.ECPublicKey) LocalSigner(com.radixdlt.qualifier.LocalSigner) NodeNetworkMessagesModule(com.radixdlt.harness.simulation.NodeNetworkMessagesModule) ECKeyPair(com.radixdlt.crypto.ECKeyPair) HashSigner(com.radixdlt.hotstuff.HashSigner) Self(com.radixdlt.hotstuff.bft.Self) Module(com.google.inject.Module) NodeNetworkMessagesModule(com.radixdlt.harness.simulation.NodeNetworkMessagesModule) AbstractModule(com.google.inject.AbstractModule) Provides(com.google.inject.Provides) AbstractModule(com.google.inject.AbstractModule)

Example 32 with BFTNode

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

the class BFTValidatorSetNodeSelector method nextNode.

@Override
public Single<BFTNode> nextNode(RunningNetwork network) {
    BFTConfiguration config = network.bftConfiguration();
    ImmutableList<BFTNode> validators = config.getValidatorSet().nodes().asList();
    int validatorSetSize = validators.size();
    BFTNode node = validators.get(random.nextInt(validatorSetSize));
    return Single.just(node);
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration)

Example 33 with BFTNode

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

the class LocalSyncServiceTest method when_duplicate_status_response_received__then_should_be_ignored.

@Test
public void when_duplicate_status_response_received__then_should_be_ignored() {
    final LedgerProof currentHeader = mock(LedgerProof.class);
    final LedgerProof statusHeader = mock(LedgerProof.class);
    final BFTNode expectedPeer = createPeer();
    final BFTNode alreadyReceivedPeer = createPeer();
    final var syncState = SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of(expectedPeer)).withStatusResponse(alreadyReceivedPeer, StatusResponse.create(statusHeader));
    this.setupSyncServiceWithState(syncState);
    this.localSyncService.statusResponseEventProcessor().process(alreadyReceivedPeer, StatusResponse.create(statusHeader));
    verifyNoMoreInteractions(peersView);
    verifyNoMoreInteractions(statusRequestDispatcher);
    verifyNoMoreInteractions(syncRequestDispatcher);
    verifyNoMoreInteractions(syncRequestTimeoutDispatcher);
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Example 34 with BFTNode

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

the class LocalSyncServiceTest method when_unexpected_status_response_received__then_should_be_ignored.

@Test
public void when_unexpected_status_response_received__then_should_be_ignored() {
    final LedgerProof currentHeader = mock(LedgerProof.class);
    final LedgerProof statusHeader = mock(LedgerProof.class);
    final BFTNode expectedPeer = createPeer();
    final BFTNode unexpectedPeer = createPeer();
    this.setupSyncServiceWithState(SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of(expectedPeer)));
    this.localSyncService.statusResponseEventProcessor().process(unexpectedPeer, StatusResponse.create(statusHeader));
    verifyNoMoreInteractions(peersView);
    verifyNoMoreInteractions(statusRequestDispatcher);
    verifyNoMoreInteractions(syncRequestDispatcher);
    verifyNoMoreInteractions(syncRequestTimeoutDispatcher);
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Example 35 with BFTNode

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

the class LocalSyncServiceTest method when_all_status_responses_received__then_should_start_sync.

@Test
public void when_all_status_responses_received__then_should_start_sync() {
    final LedgerProof currentHeader = createHeaderAtStateVersion(10L);
    final LedgerProof statusHeader1 = createHeaderAtStateVersion(2L);
    final LedgerProof statusHeader2 = createHeaderAtStateVersion(20L);
    final LedgerProof statusHeader3 = createHeaderAtStateVersion(15L);
    final BFTNode waiting1 = createPeer();
    final BFTNode waiting2 = createPeer();
    final BFTNode waiting3 = createPeer();
    final var syncState = SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of(waiting1, waiting2, waiting3));
    this.setupSyncServiceWithState(syncState);
    setupPeersView(waiting2);
    this.localSyncService.statusResponseEventProcessor().process(waiting1, StatusResponse.create(statusHeader1));
    this.localSyncService.statusResponseEventProcessor().process(waiting2, StatusResponse.create(statusHeader2));
    this.localSyncService.statusResponseEventProcessor().process(waiting3, StatusResponse.create(statusHeader3));
    verify(syncRequestDispatcher, times(1)).dispatch(eq(waiting2), any());
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

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