Search in sources :

Example 1 with PersistenceModule

use of com.radixdlt.store.PersistenceModule in project radixdlt by radixdlt.

the class RadixNodeModule method configure.

@Override
protected void configure() {
    if (this.networkId <= 0) {
        throw new IllegalStateException("Illegal networkId " + networkId);
    }
    var addressing = Addressing.ofNetworkId(networkId);
    bind(Addressing.class).toInstance(addressing);
    bindConstant().annotatedWith(NetworkId.class).to(networkId);
    bind(Txn.class).annotatedWith(Genesis.class).toInstance(loadGenesis(networkId));
    bind(RuntimeProperties.class).toInstance(properties);
    // Consensus configuration
    // These cannot be changed without introducing possibilities of
    // going out of sync with consensus.
    bindConstant().annotatedWith(BFTSyncPatienceMillis.class).to(properties.get("bft.sync.patience", 200));
    // Default values mean that pacemakers will sync if they are within 5 views of each other.
    // 5 consecutive failing views will take 1*(2^6)-1 seconds = 63 seconds.
    bindConstant().annotatedWith(PacemakerTimeout.class).to(3000L);
    bindConstant().annotatedWith(PacemakerRate.class).to(1.1);
    bindConstant().annotatedWith(PacemakerMaxExponent.class).to(0);
    // Mempool configuration
    var mempoolMaxSize = properties.get("mempool.maxSize", 10000);
    install(MempoolConfig.asModule(mempoolMaxSize, 5, 60000, 60000, 100));
    // Sync configuration
    final long syncPatience = properties.get("sync.patience", 5000L);
    bind(SyncConfig.class).toInstance(SyncConfig.of(syncPatience, 10, 3000L));
    // System (e.g. time, random)
    install(new SystemModule());
    install(new RxEnvironmentModule());
    install(new EventLoggerModule());
    install(new DispatcherModule());
    // Consensus
    install(new PersistedBFTKeyModule());
    install(new CryptoModule());
    install(new ConsensusModule());
    // Ledger
    install(new LedgerModule());
    install(new MempoolReceiverModule());
    // Mempool Relay
    install(new MempoolRelayerModule());
    // Sync
    install(new SyncServiceModule());
    // Epochs - Consensus
    install(new EpochsConsensusModule());
    // Epochs - Sync
    install(new EpochsSyncModule());
    // State Computer
    install(new ForksModule());
    if (properties.get("testing_forks.enable", false)) {
        String testingForksModuleName = properties.get("testing_forks.fork_config_name", "TestingForksModuleV1");
        if (testingForksModuleName.isBlank()) {
            testingForksModuleName = "TestingForksModuleV1";
        }
        log.info("Using testing forks module '{}'", testingForksModuleName);
        install(new TestingForksLoader().createTestingForksModuleConfigFromClassName(testingForksModuleName));
    } else {
        final var forksModule = FORKS_MODULE_BY_NETWORK_ID.getOrDefault(networkId, new GenericTestnetForksModule());
        log.info("Using a predefined forks module '{}'", forksModule.getClass().getSimpleName());
        install(forksModule);
    }
    if (properties.get("overwrite_forks.enable", false)) {
        log.info("Enabling fork overwrites from properties");
        install(new ForkOverwritesFromPropertiesModule());
    }
    install(new RadixEngineStateComputerModule());
    install(new RadixEngineModule());
    install(new RadixEngineStoreModule());
    // Checkpoints
    install(new RadixEngineCheckpointModule());
    // Storage
    install(new DatabasePropertiesModule());
    install(new PersistenceModule());
    install(new ConsensusRecoveryModule());
    install(new LedgerRecoveryModule());
    // System Info
    install(new SystemInfoModule());
    // Network
    install(new MessagingModule());
    install(new MessageCentralModule(properties));
    install(new HostIpModule(properties));
    install(new P2PModule(properties));
    install(new PeerDiscoveryModule());
    install(new PeerLivenessMonitorModule());
    // API
    var bindAddress = properties.get("api.bind.address", DEFAULT_BIND_ADDRESS);
    var port = properties.get("api.port", DEFAULT_CORE_PORT);
    var enableTransactions = properties.get("api.transactions.enable", false);
    var enableSign = properties.get("api.sign.enable", false);
    install(new ApiModule(bindAddress, port, enableTransactions, enableSign));
    // Substate Hash Accumulator
    boolean isUpdateEpochHashFileEnabled = properties.get(UPDATE_EPOCH_HASH_FILE_ENABLE_PROPERTY_NAME, false);
    boolean isVerifyEpochHashEnabled = properties.get(VERIFY_EPOCH_HASH_ENABLE_PROPERTY_NAME, false);
    if (isUpdateEpochHashFileEnabled || isVerifyEpochHashEnabled) {
        SubstateAccumulatorHashModule substateAccumulatorHashModule = new SubstateAccumulatorHashModule(isUpdateEpochHashFileEnabled, isVerifyEpochHashEnabled);
        log.info("Enabling Substate Hash Accumulator Module.");
        install(substateAccumulatorHashModule);
    }
}
Also used : RadixEngineModule(com.radixdlt.statecomputer.RadixEngineModule) ApiModule(com.radixdlt.api.ApiModule) GenericTestnetForksModule(com.radixdlt.statecomputer.forks.modules.GenericTestnetForksModule) MainnetForksModule(com.radixdlt.statecomputer.forks.modules.MainnetForksModule) ReleasenetForksModule(com.radixdlt.statecomputer.forks.modules.ReleasenetForksModule) StokenetForksModule(com.radixdlt.statecomputer.forks.modules.StokenetForksModule) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) RadixEngineStateComputerModule(com.radixdlt.statecomputer.RadixEngineStateComputerModule) SyncConfig(com.radixdlt.sync.SyncConfig) Addressing(com.radixdlt.networks.Addressing) MessageCentralModule(com.radixdlt.network.messaging.MessageCentralModule) PacemakerMaxExponent(com.radixdlt.hotstuff.bft.PacemakerMaxExponent) PacemakerRate(com.radixdlt.hotstuff.bft.PacemakerRate) GenericTestnetForksModule(com.radixdlt.statecomputer.forks.modules.GenericTestnetForksModule) SubstateAccumulatorHashModule(com.radixdlt.statecomputer.substatehash.SubstateAccumulatorHashModule) HostIpModule(com.radixdlt.network.hostip.HostIpModule) RuntimeProperties(com.radixdlt.properties.RuntimeProperties) PeerLivenessMonitorModule(com.radixdlt.network.p2p.PeerLivenessMonitorModule) BFTSyncPatienceMillis(com.radixdlt.hotstuff.sync.BFTSyncPatienceMillis) TestingForksLoader(com.radixdlt.statecomputer.forks.modules.testing.TestingForksLoader) PacemakerTimeout(com.radixdlt.hotstuff.bft.PacemakerTimeout) PersistenceModule(com.radixdlt.store.PersistenceModule) NetworkId(com.radixdlt.networks.NetworkId) RxEnvironmentModule(com.radixdlt.environment.rx.RxEnvironmentModule) DatabasePropertiesModule(com.radixdlt.store.DatabasePropertiesModule) MempoolRelayerModule(com.radixdlt.mempool.MempoolRelayerModule) MessagingModule(com.radixdlt.network.messaging.MessagingModule) ForkOverwritesFromPropertiesModule(com.radixdlt.statecomputer.forks.ForkOverwritesFromPropertiesModule) RadixEngineCheckpointModule(com.radixdlt.statecomputer.checkpoint.RadixEngineCheckpointModule) Genesis(com.radixdlt.statecomputer.checkpoint.Genesis) P2PModule(com.radixdlt.network.p2p.P2PModule) PeerDiscoveryModule(com.radixdlt.network.p2p.PeerDiscoveryModule) PersistedBFTKeyModule(com.radixdlt.keys.PersistedBFTKeyModule) MempoolReceiverModule(com.radixdlt.mempool.MempoolReceiverModule)

Example 2 with PersistenceModule

use of com.radixdlt.store.PersistenceModule in project radixdlt by radixdlt.

the class PersistedNodeForTestingModule method configure.

@Override
public void configure() {
    bind(Addressing.class).toInstance(Addressing.ofNetwork(Network.LOCALNET));
    bind(SyncConfig.class).toInstance(SyncConfig.of(500, 10, 3000, 10, Long.MAX_VALUE));
    bind(Integer.class).annotatedWith(BFTSyncPatienceMillis.class).toInstance(200);
    bind(Long.class).annotatedWith(PacemakerTimeout.class).toInstance(1000L);
    bind(Double.class).annotatedWith(PacemakerRate.class).toInstance(2.0);
    bind(Integer.class).annotatedWith(PacemakerMaxExponent.class).toInstance(6);
    bind(RateLimiter.class).annotatedWith(GetVerticesRequestRateLimit.class).toInstance(RateLimiter.create(Double.MAX_VALUE));
    bindConstant().annotatedWith(DatabaseCacheSize.class).to((long) (Runtime.getRuntime().maxMemory() * 0.125));
    // System
    bind(SystemCounters.class).to(SystemCountersImpl.class).in(Scopes.SINGLETON);
    bind(TimeSupplier.class).toInstance(System::currentTimeMillis);
    // P2P
    bind(PeerControl.class).toInstance(new NoOpPeerControl());
    install(new InMemoryBFTKeyModule());
    install(new CryptoModule());
    install(new FunctionalNodeModule());
    install(new RadixEngineStoreModule());
    install(new PersistenceModule());
    install(new ConsensusRecoveryModule());
    install(new LedgerRecoveryModule());
}
Also used : BFTSyncPatienceMillis(com.radixdlt.hotstuff.sync.BFTSyncPatienceMillis) InMemoryBFTKeyModule(com.radixdlt.keys.InMemoryBFTKeyModule) PacemakerTimeout(com.radixdlt.hotstuff.bft.PacemakerTimeout) NoOpPeerControl(com.radixdlt.network.p2p.NoOpPeerControl) SyncConfig(com.radixdlt.sync.SyncConfig) TimeSupplier(com.radixdlt.utils.TimeSupplier) PersistenceModule(com.radixdlt.store.PersistenceModule) Addressing(com.radixdlt.networks.Addressing) PacemakerMaxExponent(com.radixdlt.hotstuff.bft.PacemakerMaxExponent) FunctionalNodeModule(com.radixdlt.FunctionalNodeModule) PacemakerRate(com.radixdlt.hotstuff.bft.PacemakerRate) DatabaseCacheSize(com.radixdlt.store.DatabaseCacheSize) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) NoOpPeerControl(com.radixdlt.network.p2p.NoOpPeerControl) PeerControl(com.radixdlt.network.p2p.PeerControl)

Example 3 with PersistenceModule

use of com.radixdlt.store.PersistenceModule in project radixdlt by radixdlt.

the class PersistedNodeForTestingModule method configure.

@Override
public void configure() {
    bind(Addressing.class).toInstance(Addressing.ofNetwork(Network.LOCALNET));
    bind(SyncConfig.class).toInstance(SyncConfig.of(500, 10, 3000, 10, Long.MAX_VALUE));
    bind(Integer.class).annotatedWith(BFTSyncPatienceMillis.class).toInstance(200);
    bind(Long.class).annotatedWith(PacemakerTimeout.class).toInstance(1000L);
    bind(Double.class).annotatedWith(PacemakerRate.class).toInstance(2.0);
    bind(Integer.class).annotatedWith(PacemakerMaxExponent.class).toInstance(6);
    bind(RateLimiter.class).annotatedWith(GetVerticesRequestRateLimit.class).toInstance(RateLimiter.create(Double.MAX_VALUE));
    bindConstant().annotatedWith(DatabaseCacheSize.class).to((long) (Runtime.getRuntime().maxMemory() * 0.125));
    // System
    bind(SystemCounters.class).to(SystemCountersImpl.class).in(Scopes.SINGLETON);
    bind(TimeSupplier.class).toInstance(System::currentTimeMillis);
    // P2P
    bind(PeerControl.class).toInstance(new NoOpPeerControl());
    install(new InMemoryBFTKeyModule());
    install(new CryptoModule());
    install(new FunctionalNodeModule());
    install(new RadixEngineStoreModule());
    install(new PersistenceModule());
    install(new ConsensusRecoveryModule());
    install(new LedgerRecoveryModule());
}
Also used : BFTSyncPatienceMillis(com.radixdlt.consensus.sync.BFTSyncPatienceMillis) InMemoryBFTKeyModule(com.radixdlt.keys.InMemoryBFTKeyModule) PacemakerTimeout(com.radixdlt.consensus.bft.PacemakerTimeout) NoOpPeerControl(com.radixdlt.network.p2p.NoOpPeerControl) SyncConfig(com.radixdlt.sync.SyncConfig) TimeSupplier(com.radixdlt.utils.TimeSupplier) PersistenceModule(com.radixdlt.store.PersistenceModule) Addressing(com.radixdlt.networks.Addressing) PacemakerMaxExponent(com.radixdlt.consensus.bft.PacemakerMaxExponent) PacemakerRate(com.radixdlt.consensus.bft.PacemakerRate) DatabaseCacheSize(com.radixdlt.store.DatabaseCacheSize) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) NoOpPeerControl(com.radixdlt.network.p2p.NoOpPeerControl) PeerControl(com.radixdlt.network.p2p.PeerControl)

Aggregations

Addressing (com.radixdlt.networks.Addressing)3 PersistenceModule (com.radixdlt.store.PersistenceModule)3 SyncConfig (com.radixdlt.sync.SyncConfig)3 SystemCountersImpl (com.radixdlt.counters.SystemCountersImpl)2 PacemakerMaxExponent (com.radixdlt.hotstuff.bft.PacemakerMaxExponent)2 PacemakerRate (com.radixdlt.hotstuff.bft.PacemakerRate)2 PacemakerTimeout (com.radixdlt.hotstuff.bft.PacemakerTimeout)2 BFTSyncPatienceMillis (com.radixdlt.hotstuff.sync.BFTSyncPatienceMillis)2 InMemoryBFTKeyModule (com.radixdlt.keys.InMemoryBFTKeyModule)2 GetVerticesRequestRateLimit (com.radixdlt.middleware2.network.GetVerticesRequestRateLimit)2 NoOpPeerControl (com.radixdlt.network.p2p.NoOpPeerControl)2 PeerControl (com.radixdlt.network.p2p.PeerControl)2 DatabaseCacheSize (com.radixdlt.store.DatabaseCacheSize)2 FunctionalNodeModule (com.radixdlt.FunctionalNodeModule)1 ApiModule (com.radixdlt.api.ApiModule)1 PacemakerMaxExponent (com.radixdlt.consensus.bft.PacemakerMaxExponent)1 PacemakerRate (com.radixdlt.consensus.bft.PacemakerRate)1 PacemakerTimeout (com.radixdlt.consensus.bft.PacemakerTimeout)1 BFTSyncPatienceMillis (com.radixdlt.consensus.sync.BFTSyncPatienceMillis)1 RxEnvironmentModule (com.radixdlt.environment.rx.RxEnvironmentModule)1