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;
}
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);
}
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);
}
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);
}
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());
}
Aggregations