Search in sources :

Example 1 with SystemCountersImpl

use of com.radixdlt.counters.SystemCountersImpl in project radixdlt by radixdlt.

the class BerkeleySafetyStateStoreTest method should_be_able_to_restore_committed_state.

@Test
public void should_be_able_to_restore_committed_state() {
    final var db = mock(Database.class);
    final var env = mock(Environment.class);
    final var dbEnv = mock(DatabaseEnvironment.class);
    final var tx = mock(com.sleepycat.je.Transaction.class);
    when(dbEnv.getEnvironment()).thenReturn(env);
    when(env.openDatabase(any(), any(), any())).thenReturn(db);
    final var store = new BerkeleySafetyStateStore(dbEnv, DefaultSerialization.getInstance(), new SystemCountersImpl());
    final var safetyState = new SafetyState(randomView(), Optional.of(randomVote()));
    when(env.beginTransaction(any(), any())).thenReturn(tx);
    when(db.put(any(), any(), any())).thenReturn(OperationStatus.SUCCESS);
    ArgumentCaptor<DatabaseEntry> entryCaptor = ArgumentCaptor.forClass(DatabaseEntry.class);
    store.commitState(safetyState);
    verify(db, times(1)).put(any(), any(), entryCaptor.capture());
    verify(tx, times(1)).commit();
    verifyNoMoreInteractions(tx);
    final var cursor = mock(Cursor.class);
    when(db.openCursor(any(), any())).thenReturn(cursor);
    when(cursor.getLast(any(), any(), any())).thenAnswer(invocation -> {
        DatabaseEntry entry = (DatabaseEntry) invocation.getArguments()[1];
        entry.setData(entryCaptor.getValue().getData());
        return OperationStatus.SUCCESS;
    });
    var state = store.get();
    assertTrue(state.isPresent());
    assertEquals(safetyState, state.get());
}
Also used : SafetyState(com.radixdlt.consensus.safety.SafetyState) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) DatabaseEntry(com.sleepycat.je.DatabaseEntry) Test(org.junit.Test)

Example 2 with SystemCountersImpl

use of com.radixdlt.counters.SystemCountersImpl in project radixdlt by radixdlt.

the class MessageCentralFuzzyTest method fuzzy_messaged_are_not_accepted.

@Test
@SuppressWarnings("unchecked")
public void fuzzy_messaged_are_not_accepted() throws Exception {
    var inboundMessages = PublishSubject.<InboundMessage>create();
    var config = mock(MessageCentralConfiguration.class);
    var peerControl = mock(PeerControl.class);
    var peerManager = mock(PeerManager.class);
    var queueFactory = mock(EventQueueFactory.class);
    when(config.messagingOutboundQueueMax(anyInt())).thenReturn(1);
    when(config.messagingTimeToLive(anyLong())).thenReturn(30_000L);
    when(peerManager.messages()).thenReturn(inboundMessages);
    when(queueFactory.createEventQueue(anyInt(), any(Comparator.class))).thenReturn(new SimplePriorityBlockingQueue<>(1, OutboundMessageEvent.comparator()));
    var messageCentral = new MessageCentralImpl(config, serialization, peerManager, Time::currentTimestamp, queueFactory, new SystemCountersImpl(), () -> peerControl);
    var counter = new AtomicLong(0);
    var disposable = messageCentral.messagesOf(Message.class).subscribe(nextItem -> counter.incrementAndGet(), error -> fail(error.getMessage()));
    // Insert single valid message to ensure whole pipeline is working properly
    emitSingleValidMessage(inboundMessages);
    // Insert batch of randomly generated messages
    emitFuzzyMessages(inboundMessages);
    disposable.dispose();
    // Ensure that only one (valid) message passed through
    assertEquals(1L, counter.get());
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) InboundMessage(com.radixdlt.network.messaging.InboundMessage) Message(org.radix.network.messaging.Message) PeerPingMessage(org.radix.network.messages.PeerPingMessage) MessageCentralImpl(com.radixdlt.network.messaging.MessageCentralImpl) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) InboundMessage(com.radixdlt.network.messaging.InboundMessage) Time(org.radix.time.Time) Comparator(java.util.Comparator) Test(org.junit.Test)

Example 3 with SystemCountersImpl

use of com.radixdlt.counters.SystemCountersImpl in project radixdlt by radixdlt.

the class EpochManagerTest method getExternalModule.

private Module getExternalModule() {
    BFTNode self = BFTNode.create(ecKeyPair.getPublicKey());
    return new AbstractModule() {

        @Override
        protected void configure() {
            bind(HashSigner.class).toInstance(ecKeyPair::sign);
            bind(BFTNode.class).annotatedWith(Self.class).toInstance(self);
            bind(new TypeLiteral<EventDispatcher<LocalTimeoutOccurrence>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTInsertUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTRebuildUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTHighQCUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<BFTCommittedUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<EpochLocalTimeoutOccurrence>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<EpochView>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<LocalSyncRequest>>() {
            }).toInstance(syncLedgerRequestSender);
            bind(new TypeLiteral<EventDispatcher<ViewQuorumReached>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<EpochViewUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<ViewUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<NoVote>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<LedgerUpdate>>() {
            }).toInstance(rmock(EventDispatcher.class));
            bind(new TypeLiteral<ScheduledEventDispatcher<GetVerticesRequest>>() {
            }).toInstance(timeoutScheduler);
            bind(new TypeLiteral<ScheduledEventDispatcher<ScheduledLocalTimeout>>() {
            }).toInstance(rmock(ScheduledEventDispatcher.class));
            bind(new TypeLiteral<ScheduledEventDispatcher<Epoched<ScheduledLocalTimeout>>>() {
            }).toInstance(rmock(ScheduledEventDispatcher.class));
            bind(new TypeLiteral<ScheduledEventDispatcher<VertexRequestTimeout>>() {
            }).toInstance(rmock(ScheduledEventDispatcher.class));
            bind(new TypeLiteral<RemoteEventDispatcher<Proposal>>() {
            }).toInstance(proposalDispatcher);
            bind(new TypeLiteral<RemoteEventDispatcher<Vote>>() {
            }).toInstance(voteDispatcher);
            bind(new TypeLiteral<RemoteEventDispatcher<GetVerticesRequest>>() {
            }).toInstance(rmock(RemoteEventDispatcher.class));
            bind(new TypeLiteral<RemoteEventDispatcher<GetVerticesResponse>>() {
            }).toInstance(rmock(RemoteEventDispatcher.class));
            bind(new TypeLiteral<RemoteEventDispatcher<GetVerticesErrorResponse>>() {
            }).toInstance(rmock(RemoteEventDispatcher.class));
            bind(new TypeLiteral<RemoteEventDispatcher<LedgerStatusUpdate>>() {
            }).toInstance(rmock(RemoteEventDispatcher.class));
            bind(PersistentSafetyStateStore.class).toInstance(mock(PersistentSafetyStateStore.class));
            bind(NextTxnsGenerator.class).toInstance(nextTxnsGenerator);
            bind(SystemCounters.class).toInstance(new SystemCountersImpl());
            bind(Mempool.class).toInstance(mempool);
            bind(StateComputer.class).toInstance(stateComputer);
            bind(PersistentVertexStore.class).toInstance(mock(PersistentVertexStore.class));
            bind(RateLimiter.class).annotatedWith(GetVerticesRequestRateLimit.class).toInstance(RateLimiter.create(Double.MAX_VALUE));
            bindConstant().annotatedWith(BFTSyncPatienceMillis.class).to(50);
            bindConstant().annotatedWith(PacemakerTimeout.class).to(10L);
            bindConstant().annotatedWith(PacemakerRate.class).to(2.0);
            bindConstant().annotatedWith(PacemakerMaxExponent.class).to(0);
            bind(TimeSupplier.class).toInstance(System::currentTimeMillis);
            bind(new TypeLiteral<Consumer<EpochViewUpdate>>() {
            }).toInstance(rmock(Consumer.class));
        }

        @Provides
        private ViewUpdate view(BFTConfiguration bftConfiguration) {
            HighQC highQC = bftConfiguration.getVertexStoreState().getHighQC();
            View view = highQC.highestQC().getView().next();
            return ViewUpdate.create(view, highQC, self, self);
        }

        @Provides
        BFTValidatorSet validatorSet() {
            return BFTValidatorSet.from(Stream.of(BFTValidator.from(self, UInt256.ONE)));
        }

        @Provides
        @LastProof
        LedgerProof verifiedLedgerHeaderAndProof(BFTValidatorSet validatorSet) {
            var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
            return LedgerProof.genesis(accumulatorState, validatorSet, 0);
        }

        @Provides
        @LastEpochProof
        LedgerProof lastEpochProof(BFTValidatorSet validatorSet) {
            var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
            return LedgerProof.genesis(accumulatorState, validatorSet, 0);
        }

        @Provides
        BFTConfiguration bftConfiguration(@Self BFTNode self, Hasher hasher, BFTValidatorSet validatorSet) {
            var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
            var unverifiedVertex = UnverifiedVertex.createGenesis(LedgerHeader.genesis(accumulatorState, validatorSet, 0));
            var verifiedVertex = new VerifiedVertex(unverifiedVertex, hasher.hash(unverifiedVertex));
            var qc = QuorumCertificate.ofGenesis(verifiedVertex, LedgerHeader.genesis(accumulatorState, validatorSet, 0));
            var proposerElection = new WeightedRotatingLeaders(validatorSet);
            return new BFTConfiguration(proposerElection, validatorSet, VerifiedVertexStoreState.create(HighQC.from(qc), verifiedVertex, Optional.empty(), hasher));
        }
    };
}
Also used : HighQC(com.radixdlt.consensus.HighQC) AccumulatorState(com.radixdlt.ledger.AccumulatorState) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) BFTCommittedUpdate(com.radixdlt.consensus.bft.BFTCommittedUpdate) VertexRequestTimeout(com.radixdlt.consensus.sync.VertexRequestTimeout) NextTxnsGenerator(com.radixdlt.consensus.liveness.NextTxnsGenerator) BFTInsertUpdate(com.radixdlt.consensus.bft.BFTInsertUpdate) PacemakerMaxExponent(com.radixdlt.consensus.bft.PacemakerMaxExponent) ViewUpdate(com.radixdlt.consensus.bft.ViewUpdate) VerifiedVertex(com.radixdlt.consensus.bft.VerifiedVertex) Consumer(java.util.function.Consumer) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) Mempool(com.radixdlt.mempool.Mempool) StateComputer(com.radixdlt.ledger.StateComputerLedger.StateComputer) BFTNode(com.radixdlt.consensus.bft.BFTNode) Vote(com.radixdlt.consensus.Vote) NoVote(com.radixdlt.consensus.bft.NoVote) GetVerticesResponse(com.radixdlt.consensus.sync.GetVerticesResponse) HashSigner(com.radixdlt.consensus.HashSigner) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) Hasher(com.radixdlt.crypto.Hasher) NoVote(com.radixdlt.consensus.bft.NoVote) Proposal(com.radixdlt.consensus.Proposal) LedgerStatusUpdate(com.radixdlt.sync.messages.remote.LedgerStatusUpdate) WeightedRotatingLeaders(com.radixdlt.consensus.liveness.WeightedRotatingLeaders) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) GetVerticesRequest(com.radixdlt.consensus.sync.GetVerticesRequest) LocalTimeoutOccurrence(com.radixdlt.consensus.liveness.LocalTimeoutOccurrence) EpochLocalTimeoutOccurrence(com.radixdlt.consensus.liveness.EpochLocalTimeoutOccurrence) Self(com.radixdlt.consensus.bft.Self) TimeSupplier(com.radixdlt.utils.TimeSupplier) PersistentVertexStore(com.radixdlt.consensus.bft.PersistentVertexStore) EpochLocalTimeoutOccurrence(com.radixdlt.consensus.liveness.EpochLocalTimeoutOccurrence) PacemakerRate(com.radixdlt.consensus.bft.PacemakerRate) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) EventDispatcher(com.radixdlt.environment.EventDispatcher) TypeLiteral(com.google.inject.TypeLiteral) BFTSyncPatienceMillis(com.radixdlt.consensus.sync.BFTSyncPatienceMillis) BFTRebuildUpdate(com.radixdlt.consensus.bft.BFTRebuildUpdate) GetVerticesErrorResponse(com.radixdlt.consensus.sync.GetVerticesErrorResponse) SystemCounters(com.radixdlt.counters.SystemCounters) PacemakerTimeout(com.radixdlt.consensus.bft.PacemakerTimeout) BFTValidatorSet(com.radixdlt.consensus.bft.BFTValidatorSet) View(com.radixdlt.consensus.bft.View) AbstractModule(com.google.inject.AbstractModule) BFTConfiguration(com.radixdlt.consensus.BFTConfiguration) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) ViewQuorumReached(com.radixdlt.consensus.bft.ViewQuorumReached) ScheduledLocalTimeout(com.radixdlt.consensus.liveness.ScheduledLocalTimeout) BFTHighQCUpdate(com.radixdlt.consensus.bft.BFTHighQCUpdate) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) PersistentSafetyStateStore(com.radixdlt.consensus.safety.PersistentSafetyStateStore)

Example 4 with SystemCountersImpl

use of com.radixdlt.counters.SystemCountersImpl in project radixdlt by radixdlt.

the class GenerateUniverses method main.

public static void main(String[] args) throws Exception {
    Security.insertProviderAt(new BouncyCastleProvider(), 1);
    Options options = new Options();
    options.addOption("h", "help", false, "Show usage information (this message)");
    options.addOption("p", "public-keys", true, "Specify validator keys");
    options.addOption("v", "validator-count", true, "Specify number of validators to generate");
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);
    if (!cmd.getArgList().isEmpty()) {
        System.err.println("Extra arguments: " + String.join(" ", cmd.getArgList()));
        usage(options);
        return;
    }
    if (cmd.hasOption('h')) {
        usage(options);
        return;
    }
    var validatorKeys = new HashSet<ECPublicKey>();
    if (cmd.getOptionValue("p") != null) {
        var hexKeys = cmd.getOptionValue("p").split(",");
        for (var hexKey : hexKeys) {
            validatorKeys.add(ECPublicKey.fromHex(hexKey));
        }
    }
    final int validatorsCount = cmd.getOptionValue("v") != null ? Integer.parseInt(cmd.getOptionValue("v")) : 0;
    var generatedValidatorKeys = PrivateKeys.numeric(6).limit(validatorsCount).toList();
    generatedValidatorKeys.stream().map(ECKeyPair::getPublicKey).forEach(validatorKeys::add);
    // Issuances to mnemomic account, keys 1-5, and 1st validator
    final var mnemomicKey = ECPublicKey.fromHex(mnemomicKeyHex);
    final ImmutableList.Builder<TokenIssuance> tokenIssuancesBuilder = ImmutableList.builder();
    tokenIssuancesBuilder.add(TokenIssuance.of(mnemomicKey, DEFAULT_ISSUANCE));
    PrivateKeys.numeric(1).limit(5).map(k -> TokenIssuance.of(k.getPublicKey(), DEFAULT_ISSUANCE)).forEach(tokenIssuancesBuilder::add);
    // Issue tokens to initial validators for now to support application services
    validatorKeys.forEach(pk -> tokenIssuancesBuilder.add(TokenIssuance.of(pk, DEFAULT_ISSUANCE)));
    // Stakes issued by mnemomic account
    var stakes = validatorKeys.stream().map(pk -> new StakeTokens(REAddr.ofPubKeyAccount(mnemomicKey), pk, DEFAULT_STAKE)).collect(Collectors.toSet());
    var timestamp = String.valueOf(Instant.now().getEpochSecond());
    var genesisProvider = Guice.createInjector(new AbstractModule() {

        @Provides
        @Singleton
        RERules reRules(Forks forks) {
            return forks.get(0);
        }

        @Override
        protected void configure() {
            install(new CryptoModule());
            install(new MainnetForkConfigsModule());
            install(new ForksModule());
            bind(new TypeLiteral<List<TxAction>>() {
            }).annotatedWith(Genesis.class).toInstance(List.of());
            bind(LedgerAccumulator.class).to(SimpleLedgerAccumulatorAndVerifier.class);
            bind(SystemCounters.class).toInstance(new SystemCountersImpl());
            bindConstant().annotatedWith(Genesis.class).to(timestamp);
            bind(new TypeLiteral<Set<StakeTokens>>() {
            }).annotatedWith(Genesis.class).toInstance(stakes);
            bind(new TypeLiteral<ImmutableList<TokenIssuance>>() {
            }).annotatedWith(Genesis.class).toInstance(tokenIssuancesBuilder.build());
            bind(new TypeLiteral<Set<ECPublicKey>>() {
            }).annotatedWith(Genesis.class).toInstance(validatorKeys);
            bindConstant().annotatedWith(MaxValidators.class).to(100);
            OptionalBinder.newOptionalBinder(binder(), Key.get(new TypeLiteral<List<TxAction>>() {
            }, Genesis.class));
        }
    }).getInstance(GenesisProvider.class);
    var genesis = genesisProvider.get().getTxns().get(0);
    IntStream.range(0, generatedValidatorKeys.size()).forEach(i -> {
        System.out.format("export RADIXDLT_VALIDATOR_%s_PRIVKEY=%s%n", i, Bytes.toBase64String(generatedValidatorKeys.get(i).getPrivateKey()));
        System.out.format("export RADIXDLT_VALIDATOR_%s_PUBKEY=%s%n", i, Addressing.ofNetwork(Network.LOCALNET).forNodes().of(generatedValidatorKeys.get(i).getPublicKey()));
    });
    if (validatorsCount > 0) {
        System.out.format("export RADIXDLT_GENESIS_TXN=%s%n", Bytes.toHexString(genesis.getPayload()));
    } else {
        try (var writer = new BufferedWriter(new FileWriter("genesis.json"))) {
            writer.write(new JSONObject().put("genesis", Bytes.toHexString(genesis.getPayload())).toString());
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) RERules(com.radixdlt.statecomputer.forks.RERules) SimpleLedgerAccumulatorAndVerifier(com.radixdlt.ledger.SimpleLedgerAccumulatorAndVerifier) TxAction(com.radixdlt.atom.TxAction) Key(com.google.inject.Key) MaxValidators(com.radixdlt.statecomputer.MaxValidators) Options(org.apache.commons.cli.Options) Security(java.security.Security) Forks(com.radixdlt.statecomputer.forks.Forks) HelpFormatter(org.apache.commons.cli.HelpFormatter) ECPublicKey(com.radixdlt.crypto.ECPublicKey) DefaultParser(org.apache.commons.cli.DefaultParser) HashSet(java.util.HashSet) JSONObject(org.json.JSONObject) ImmutableList(com.google.common.collect.ImmutableList) CryptoModule(com.radixdlt.CryptoModule) CommandLine(org.apache.commons.cli.CommandLine) UInt256(com.radixdlt.utils.UInt256) Genesis(com.radixdlt.statecomputer.checkpoint.Genesis) PrivateKeys(com.radixdlt.utils.PrivateKeys) SystemCounters(com.radixdlt.counters.SystemCounters) Addressing(com.radixdlt.networks.Addressing) Network(com.radixdlt.networks.Network) CommandLineParser(org.apache.commons.cli.CommandLineParser) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) GenesisProvider(com.radixdlt.statecomputer.checkpoint.GenesisProvider) Set(java.util.Set) REAddr(com.radixdlt.identifiers.REAddr) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) List(java.util.List) Provides(com.google.inject.Provides) ECKeyPair(com.radixdlt.crypto.ECKeyPair) Bytes(com.radixdlt.utils.Bytes) OptionalBinder(com.google.inject.multibindings.OptionalBinder) Guice(com.google.inject.Guice) Amount(com.radixdlt.application.tokens.Amount) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) TypeLiteral(com.google.inject.TypeLiteral) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) AbstractModule(com.google.inject.AbstractModule) Singleton(com.google.inject.Singleton) Options(org.apache.commons.cli.Options) HashSet(java.util.HashSet) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) FileWriter(java.io.FileWriter) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) BufferedWriter(java.io.BufferedWriter) TypeLiteral(com.google.inject.TypeLiteral) TxAction(com.radixdlt.atom.TxAction) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) CommandLineParser(org.apache.commons.cli.CommandLineParser) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) DefaultParser(org.apache.commons.cli.DefaultParser) HashSet(java.util.HashSet) Forks(com.radixdlt.statecomputer.forks.Forks) MaxValidators(com.radixdlt.statecomputer.MaxValidators) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) CryptoModule(com.radixdlt.CryptoModule) SystemCounters(com.radixdlt.counters.SystemCounters) AbstractModule(com.google.inject.AbstractModule) CommandLine(org.apache.commons.cli.CommandLine) JSONObject(org.json.JSONObject) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) Genesis(com.radixdlt.statecomputer.checkpoint.Genesis)

Example 5 with SystemCountersImpl

use of com.radixdlt.counters.SystemCountersImpl in project radixdlt by radixdlt.

the class MempoolRunnerTest method createModule.

@SuppressWarnings(// The mock method doesn't support type-safe generics due to type erasure
"unchecked")
public Module createModule() {
    return new AbstractModule() {

        @Override
        public void configure() {
            bind(BFTNode.class).annotatedWith(Self.class).toInstance(BFTNode.random());
            bind(LedgerProof.class).annotatedWith(LastProof.class).toInstance(mock(LedgerProof.class));
            bind(StateComputer.class).toInstance(stateComputer);
            bind(SystemCounters.class).toInstance(new SystemCountersImpl());
            bind(RxRemoteEnvironment.class).toInstance(new RxRemoteEnvironment() {

                @Override
                public <T> Flowable<RemoteEvent<T>> remoteEvents(Class<T> remoteEventClass) {
                    return Flowable.never();
                }
            });
            bind(LedgerAccumulator.class).toInstance(mock(LedgerAccumulator.class));
            bind(LedgerAccumulatorVerifier.class).toInstance(mock(LedgerAccumulatorVerifier.class));
            bind(new TypeLiteral<Comparator<LedgerProof>>() {
            }).toInstance(mock(Comparator.class));
            bind(Addressing.class).toInstance(Addressing.ofNetwork(Network.LOCALNET));
            bind(TimeSupplier.class).toInstance(System::currentTimeMillis);
            Multibinder.newSetBinder(binder(), StartProcessorOnRunner.class);
            install(MempoolConfig.asModule(100, 10));
            install(new MockedKeyModule());
            install(new MockedCryptoModule());
            install(new RxEnvironmentModule());
            install(new DispatcherModule());
            install(new MempoolReceiverModule());
            install(new EventLoggerModule());
        }
    };
}
Also used : MockedKeyModule(com.radixdlt.MockedKeyModule) Self(com.radixdlt.consensus.bft.Self) TimeSupplier(com.radixdlt.utils.TimeSupplier) Addressing(com.radixdlt.networks.Addressing) Comparator(java.util.Comparator) LedgerAccumulatorVerifier(com.radixdlt.ledger.LedgerAccumulatorVerifier) TypeLiteral(com.google.inject.TypeLiteral) LedgerProof(com.radixdlt.consensus.LedgerProof) StateComputer(com.radixdlt.ledger.StateComputerLedger.StateComputer) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) RxRemoteEnvironment(com.radixdlt.environment.rx.RxRemoteEnvironment) SystemCounters(com.radixdlt.counters.SystemCounters) MockedCryptoModule(com.radixdlt.MockedCryptoModule) RxEnvironmentModule(com.radixdlt.environment.rx.RxEnvironmentModule) AbstractModule(com.google.inject.AbstractModule) LastProof(com.radixdlt.store.LastProof) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) DispatcherModule(com.radixdlt.DispatcherModule) EventLoggerModule(com.radixdlt.EventLoggerModule) Flowable(io.reactivex.rxjava3.core.Flowable)

Aggregations

SystemCountersImpl (com.radixdlt.counters.SystemCountersImpl)6 AbstractModule (com.google.inject.AbstractModule)3 TypeLiteral (com.google.inject.TypeLiteral)3 SystemCounters (com.radixdlt.counters.SystemCounters)3 HighQC (com.radixdlt.consensus.HighQC)2 BFTNode (com.radixdlt.consensus.bft.BFTNode)2 Self (com.radixdlt.consensus.bft.Self)2 ViewUpdate (com.radixdlt.consensus.bft.ViewUpdate)2 LedgerAccumulator (com.radixdlt.ledger.LedgerAccumulator)2 StateComputer (com.radixdlt.ledger.StateComputerLedger.StateComputer)2 Addressing (com.radixdlt.networks.Addressing)2 TimeSupplier (com.radixdlt.utils.TimeSupplier)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 Guice (com.google.inject.Guice)1 Key (com.google.inject.Key)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 OptionalBinder (com.google.inject.multibindings.OptionalBinder)1 CryptoModule (com.radixdlt.CryptoModule)1