Search in sources :

Example 1 with EpochViewUpdate

use of com.radixdlt.hotstuff.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.hotstuff.epoch.EpochViewUpdate) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage)

Example 2 with EpochViewUpdate

use of com.radixdlt.hotstuff.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) 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) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) DatabaseLocation(com.radixdlt.store.DatabaseLocation) MempoolConfig(com.radixdlt.mempool.MempoolConfig) SingleNodeAndPeersDeterministicNetworkModule(com.radixdlt.modules.SingleNodeAndPeersDeterministicNetworkModule) BFTInsertUpdate(com.radixdlt.hotstuff.bft.BFTInsertUpdate) PrivateKeys(com.radixdlt.utils.PrivateKeys) ScheduledLocalTimeout(com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout) Set(java.util.Set) Test(org.junit.Test) ViewUpdate(com.radixdlt.hotstuff.bft.ViewUpdate) DeterministicProcessor(com.radixdlt.environment.deterministic.DeterministicProcessor) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) Injector(com.google.inject.Injector) EpochViewUpdate(com.radixdlt.hotstuff.epoch.EpochViewUpdate) Epoched(com.radixdlt.hotstuff.epoch.Epoched) Rule(org.junit.Rule) MainnetForksModule(com.radixdlt.statecomputer.forks.modules.MainnetForksModule) Condition(org.assertj.core.api.Condition) Guice(com.google.inject.Guice) Amount(com.radixdlt.application.tokens.Amount) TypeLiteral(com.google.inject.TypeLiteral) TemporaryFolder(org.junit.rules.TemporaryFolder) AbstractModule(com.google.inject.AbstractModule) EpochViewUpdate(com.radixdlt.hotstuff.epoch.EpochViewUpdate) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) Epoched(com.radixdlt.hotstuff.epoch.Epoched) BFTInsertUpdate(com.radixdlt.hotstuff.bft.BFTInsertUpdate) Test(org.junit.Test)

Example 3 with EpochViewUpdate

use of com.radixdlt.hotstuff.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 : BFTHighQCUpdate(com.radixdlt.hotstuff.bft.BFTHighQCUpdate) VertexStoreFactory(com.radixdlt.hotstuff.epoch.VertexStoreFactory) PacemakerFactory(com.radixdlt.hotstuff.liveness.PacemakerFactory) Hasher(com.radixdlt.crypto.Hasher) Random(java.util.Random) EpochLocalTimeoutOccurrence(com.radixdlt.hotstuff.liveness.EpochLocalTimeoutOccurrence) EventProcessor(com.radixdlt.environment.EventProcessor) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) Ledger(com.radixdlt.hotstuff.Ledger) GetVerticesErrorResponse(com.radixdlt.hotstuff.sync.GetVerticesErrorResponse) BFTRebuildUpdate(com.radixdlt.hotstuff.bft.BFTRebuildUpdate) BFTSyncPatienceMillis(com.radixdlt.hotstuff.sync.BFTSyncPatienceMillis) BFTInsertUpdate(com.radixdlt.hotstuff.bft.BFTInsertUpdate) SystemCounters(com.radixdlt.counters.SystemCounters) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet) RemoteEventProcessorOnRunner(com.radixdlt.environment.RemoteEventProcessorOnRunner) Vote(com.radixdlt.hotstuff.Vote) NextTxnsGenerator(com.radixdlt.hotstuff.liveness.NextTxnsGenerator) ViewUpdate(com.radixdlt.hotstuff.bft.ViewUpdate) Multibinder(com.google.inject.multibindings.Multibinder) EpochChange(com.radixdlt.hotstuff.epoch.EpochChange) Runners(com.radixdlt.environment.Runners) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) Epoched(com.radixdlt.hotstuff.epoch.Epoched) PacemakerState(com.radixdlt.hotstuff.liveness.PacemakerState) ProcessOnDispatch(com.radixdlt.environment.ProcessOnDispatch) TypeLiteral(com.google.inject.TypeLiteral) Proposal(com.radixdlt.hotstuff.Proposal) StartProcessorOnRunner(com.radixdlt.environment.StartProcessorOnRunner) BFTCommittedUpdate(com.radixdlt.hotstuff.bft.BFTCommittedUpdate) VertexStoreBFTSyncRequestProcessor(com.radixdlt.hotstuff.sync.VertexStoreBFTSyncRequestProcessor) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) LedgerProof(com.radixdlt.hotstuff.LedgerProof) EventProcessorOnRunner(com.radixdlt.environment.EventProcessorOnRunner) GetVerticesResponse(com.radixdlt.hotstuff.sync.GetVerticesResponse) RateLimiter(com.google.common.util.concurrent.RateLimiter) LocalEvents(com.radixdlt.environment.LocalEvents) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) VertexStore(com.radixdlt.hotstuff.bft.VertexStore) LastEpochProof(com.radixdlt.store.LastEpochProof) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) Pacemaker(com.radixdlt.hotstuff.liveness.Pacemaker) BFTSync(com.radixdlt.hotstuff.sync.BFTSync) TimeSupplier(com.radixdlt.utils.TimeSupplier) EventDispatcher(com.radixdlt.environment.EventDispatcher) PacemakerStateFactory(com.radixdlt.hotstuff.liveness.PacemakerStateFactory) ScheduledLocalTimeout(com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout) BFTSyncRequestProcessorFactory(com.radixdlt.hotstuff.epoch.BFTSyncRequestProcessorFactory) Scopes(com.google.inject.Scopes) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) EpochViewUpdate(com.radixdlt.hotstuff.epoch.EpochViewUpdate) VertexRequestTimeout(com.radixdlt.hotstuff.sync.VertexRequestTimeout) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) BFTSyncFactory(com.radixdlt.hotstuff.epoch.BFTSyncFactory) Provides(com.google.inject.Provides) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) EpochManager(com.radixdlt.hotstuff.epoch.EpochManager) LocalTimeoutOccurrence(com.radixdlt.hotstuff.liveness.LocalTimeoutOccurrence) Self(com.radixdlt.hotstuff.bft.Self) Comparator(java.util.Comparator) AbstractModule(com.google.inject.AbstractModule) EpochViewUpdate(com.radixdlt.hotstuff.epoch.EpochViewUpdate) PacemakerState(com.radixdlt.hotstuff.liveness.PacemakerState) Provides(com.google.inject.Provides)

Aggregations

EpochViewUpdate (com.radixdlt.hotstuff.epoch.EpochViewUpdate)3 AbstractModule (com.google.inject.AbstractModule)2 TypeLiteral (com.google.inject.TypeLiteral)2 ControlledMessage (com.radixdlt.environment.deterministic.network.ControlledMessage)2 BFTInsertUpdate (com.radixdlt.hotstuff.bft.BFTInsertUpdate)2 ViewUpdate (com.radixdlt.hotstuff.bft.ViewUpdate)2 Epoched (com.radixdlt.hotstuff.epoch.Epoched)2 ScheduledLocalTimeout (com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout)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 Amount (com.radixdlt.application.tokens.Amount)1 SystemCounters (com.radixdlt.counters.SystemCounters)1 Hasher (com.radixdlt.crypto.Hasher)1 EventDispatcher (com.radixdlt.environment.EventDispatcher)1