Search in sources :

Example 1 with EpochViewUpdate

use of com.radixdlt.consensus.epoch.EpochViewUpdate in project radixdlt by radixdlt.

the class PacemakerTest method on_view_timeout_quorum_pacemaker_should_move_to_next_view.

@Test
public void on_view_timeout_quorum_pacemaker_should_move_to_next_view() {
    // Arrange
    createRunner().injectMembers(this);
    processor.start();
    ControlledMessage timeoutMsg = network.nextMessage(e -> Epoched.isInstance(e.message(), ScheduledLocalTimeout.class)).value();
    processor.handleMessage(timeoutMsg.origin(), timeoutMsg.message(), new TypeLiteral<Epoched<ScheduledLocalTimeout>>() {
    });
    ControlledMessage bftUpdateMsg = network.nextMessage(e -> e.message() instanceof BFTInsertUpdate).value();
    processor.handleMessage(bftUpdateMsg.origin(), bftUpdateMsg.message(), null);
    // Act
    ControlledMessage viewTimeout = network.nextMessage(e -> (e.message() instanceof Vote) && ((Vote) e.message()).isTimeout()).value();
    processor.handleMessage(viewTimeout.origin(), viewTimeout.message(), null);
    // Assert
    assertThat(network.allMessages()).haveExactly(1, new Condition<>(msg -> msg.message() instanceof EpochViewUpdate, "A remote view timeout has been emitted"));
    EpochViewUpdate nextEpochViewUpdate = network.allMessages().stream().filter(msg -> msg.message() instanceof EpochViewUpdate).map(ControlledMessage::message).map(EpochViewUpdate.class::cast).findAny().orElseThrow();
    assertThat(nextEpochViewUpdate.getViewUpdate().getCurrentView()).isEqualTo(initialViewUpdate.getCurrentView().next());
}
Also used : ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) ScheduledLocalTimeout(com.radixdlt.consensus.liveness.ScheduledLocalTimeout) Epoched(com.radixdlt.consensus.epoch.Epoched) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Inject(com.google.inject.Inject) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) EpochViewUpdate(com.radixdlt.consensus.epoch.EpochViewUpdate) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) DatabaseLocation(com.radixdlt.store.DatabaseLocation) MempoolConfig(com.radixdlt.mempool.MempoolConfig) ViewUpdate(com.radixdlt.consensus.bft.ViewUpdate) PrivateKeys(com.radixdlt.utils.PrivateKeys) Set(java.util.Set) BFTInsertUpdate(com.radixdlt.consensus.bft.BFTInsertUpdate) Test(org.junit.Test) DeterministicProcessor(com.radixdlt.environment.deterministic.DeterministicProcessor) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) Injector(com.google.inject.Injector) Rule(org.junit.Rule) SingleNodeAndPeersDeterministicNetworkModule(com.radixdlt.SingleNodeAndPeersDeterministicNetworkModule) Condition(org.assertj.core.api.Condition) Guice(com.google.inject.Guice) Amount(com.radixdlt.application.tokens.Amount) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) TypeLiteral(com.google.inject.TypeLiteral) TemporaryFolder(org.junit.rules.TemporaryFolder) AbstractModule(com.google.inject.AbstractModule) EpochViewUpdate(com.radixdlt.consensus.epoch.EpochViewUpdate) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) Epoched(com.radixdlt.consensus.epoch.Epoched) BFTInsertUpdate(com.radixdlt.consensus.bft.BFTInsertUpdate) Test(org.junit.Test)

Example 2 with EpochViewUpdate

use of com.radixdlt.consensus.epoch.EpochViewUpdate in project radixdlt by radixdlt.

the class MempoolFillAndEmptyTest method fillAndEmptyMempool.

private void fillAndEmptyMempool() {
    while (systemCounters.get(SystemCounters.CounterType.MEMPOOL_CURRENT_SIZE) < 1000) {
        ControlledMessage msg = network.nextMessage().value();
        processor.handleMessage(msg.origin(), msg.message(), msg.typeLiteral());
        if (msg.message() instanceof EpochViewUpdate) {
            scheduledMempoolFillEventDispatcher.dispatch(ScheduledMempoolFill.create());
        }
    }
    for (int i = 0; i < 10000; i++) {
        ControlledMessage msg = network.nextMessage().value();
        processor.handleMessage(msg.origin(), msg.message(), msg.typeLiteral());
        if (systemCounters.get(SystemCounters.CounterType.MEMPOOL_CURRENT_SIZE) == 0) {
            break;
        }
    }
    assertThat(systemCounters.get(SystemCounters.CounterType.MEMPOOL_CURRENT_SIZE)).isZero();
}
Also used : EpochViewUpdate(com.radixdlt.consensus.epoch.EpochViewUpdate) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage)

Example 3 with EpochViewUpdate

use of com.radixdlt.consensus.epoch.EpochViewUpdate in project radixdlt by radixdlt.

the class EpochsConsensusModule method pacemakerStateFactory.

@Provides
private PacemakerStateFactory pacemakerStateFactory(EventDispatcher<EpochViewUpdate> epochViewUpdateEventDispatcher) {
    return (initialView, epoch, proposerElection) -> new PacemakerState(initialView, proposerElection, viewUpdate -> {
        EpochViewUpdate epochViewUpdate = new EpochViewUpdate(epoch, viewUpdate);
        epochViewUpdateEventDispatcher.dispatch(epochViewUpdate);
    });
}
Also used : VertexStoreBFTSyncRequestProcessor(com.radixdlt.consensus.sync.VertexStoreBFTSyncRequestProcessor) ScheduledLocalTimeout(com.radixdlt.consensus.liveness.ScheduledLocalTimeout) GetVerticesRequest(com.radixdlt.consensus.sync.GetVerticesRequest) Hasher(com.radixdlt.crypto.Hasher) Random(java.util.Random) BFTCommittedUpdate(com.radixdlt.consensus.bft.BFTCommittedUpdate) EventProcessor(com.radixdlt.environment.EventProcessor) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) VertexRequestTimeout(com.radixdlt.consensus.sync.VertexRequestTimeout) LedgerProof(com.radixdlt.consensus.LedgerProof) SystemCounters(com.radixdlt.counters.SystemCounters) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet) BFTSyncFactory(com.radixdlt.consensus.epoch.BFTSyncFactory) RemoteEventProcessorOnRunner(com.radixdlt.environment.RemoteEventProcessorOnRunner) PacemakerState(com.radixdlt.consensus.liveness.PacemakerState) BFTSyncRequestProcessorFactory(com.radixdlt.consensus.epoch.BFTSyncRequestProcessorFactory) Multibinder(com.google.inject.multibindings.Multibinder) Runners(com.radixdlt.environment.Runners) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) BFTRebuildUpdate(com.radixdlt.consensus.bft.BFTRebuildUpdate) VertexStoreFactory(com.radixdlt.consensus.epoch.VertexStoreFactory) LedgerHeader(com.radixdlt.consensus.LedgerHeader) BFTHighQCUpdate(com.radixdlt.consensus.bft.BFTHighQCUpdate) ProcessOnDispatch(com.radixdlt.environment.ProcessOnDispatch) TypeLiteral(com.google.inject.TypeLiteral) BFTSyncPatienceMillis(com.radixdlt.consensus.sync.BFTSyncPatienceMillis) StartProcessorOnRunner(com.radixdlt.environment.StartProcessorOnRunner) EpochManager(com.radixdlt.consensus.epoch.EpochManager) Epoched(com.radixdlt.consensus.epoch.Epoched) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) EventProcessorOnRunner(com.radixdlt.environment.EventProcessorOnRunner) Proposal(com.radixdlt.consensus.Proposal) LocalTimeoutOccurrence(com.radixdlt.consensus.liveness.LocalTimeoutOccurrence) NextTxnsGenerator(com.radixdlt.consensus.liveness.NextTxnsGenerator) BFTSync(com.radixdlt.consensus.sync.BFTSync) RateLimiter(com.google.common.util.concurrent.RateLimiter) EpochViewUpdate(com.radixdlt.consensus.epoch.EpochViewUpdate) LocalEvents(com.radixdlt.environment.LocalEvents) VertexStore(com.radixdlt.consensus.bft.VertexStore) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) Vote(com.radixdlt.consensus.Vote) Pacemaker(com.radixdlt.consensus.liveness.Pacemaker) LastEpochProof(com.radixdlt.store.LastEpochProof) BFTConfiguration(com.radixdlt.consensus.BFTConfiguration) Ledger(com.radixdlt.consensus.Ledger) ViewUpdate(com.radixdlt.consensus.bft.ViewUpdate) PacemakerStateFactory(com.radixdlt.consensus.liveness.PacemakerStateFactory) TimeSupplier(com.radixdlt.utils.TimeSupplier) EventDispatcher(com.radixdlt.environment.EventDispatcher) BFTInsertUpdate(com.radixdlt.consensus.bft.BFTInsertUpdate) PacemakerFactory(com.radixdlt.consensus.liveness.PacemakerFactory) Scopes(com.google.inject.Scopes) EpochChange(com.radixdlt.consensus.epoch.EpochChange) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) Provides(com.google.inject.Provides) Self(com.radixdlt.consensus.bft.Self) BFTNode(com.radixdlt.consensus.bft.BFTNode) EpochLocalTimeoutOccurrence(com.radixdlt.consensus.liveness.EpochLocalTimeoutOccurrence) Comparator(java.util.Comparator) GetVerticesErrorResponse(com.radixdlt.consensus.sync.GetVerticesErrorResponse) GetVerticesResponse(com.radixdlt.consensus.sync.GetVerticesResponse) AbstractModule(com.google.inject.AbstractModule) EpochViewUpdate(com.radixdlt.consensus.epoch.EpochViewUpdate) PacemakerState(com.radixdlt.consensus.liveness.PacemakerState) Provides(com.google.inject.Provides)

Aggregations

EpochViewUpdate (com.radixdlt.consensus.epoch.EpochViewUpdate)3 AbstractModule (com.google.inject.AbstractModule)2 TypeLiteral (com.google.inject.TypeLiteral)2 BFTInsertUpdate (com.radixdlt.consensus.bft.BFTInsertUpdate)2 ViewUpdate (com.radixdlt.consensus.bft.ViewUpdate)2 Epoched (com.radixdlt.consensus.epoch.Epoched)2 ScheduledLocalTimeout (com.radixdlt.consensus.liveness.ScheduledLocalTimeout)2 ControlledMessage (com.radixdlt.environment.deterministic.network.ControlledMessage)2 RateLimiter (com.google.common.util.concurrent.RateLimiter)1 Guice (com.google.inject.Guice)1 Inject (com.google.inject.Inject)1 Injector (com.google.inject.Injector)1 Provides (com.google.inject.Provides)1 Scopes (com.google.inject.Scopes)1 Multibinder (com.google.inject.multibindings.Multibinder)1 ProvidesIntoSet (com.google.inject.multibindings.ProvidesIntoSet)1 SingleNodeAndPeersDeterministicNetworkModule (com.radixdlt.SingleNodeAndPeersDeterministicNetworkModule)1 Amount (com.radixdlt.application.tokens.Amount)1 BFTConfiguration (com.radixdlt.consensus.BFTConfiguration)1 Ledger (com.radixdlt.consensus.Ledger)1