Пример #1
0
        public void Setup()
        {
            InMemoryReceiptStorage receiptStorage = new InMemoryReceiptStorage();

            _specProvider = new TestSpecProvider(Homestead.Instance);
            _blockTree    = Build.A.BlockTree().WithTransactions(receiptStorage, _specProvider).OfChainLength(10).TestObject;
            _dbProvider   = new MemDbProvider();
            ProofModuleFactory moduleFactory = new ProofModuleFactory(
                _dbProvider,
                _blockTree,
                new CompositeBlockPreprocessorStep(new RecoverSignatures(new EthereumEcdsa(ChainId.Mainnet, LimboLogs.Instance), NullTxPool.Instance, _specProvider, LimboLogs.Instance)),
                receiptStorage,
                _specProvider,
                LimboLogs.Instance);

            _proofModule = moduleFactory.Create();
        }
Пример #2
0
        public virtual Task Execute()
        {
            if (_context.RpcModuleProvider == null)
            {
                throw new StepDependencyException(nameof(_context.RpcModuleProvider));
            }

            ILogger        logger        = _context.LogManager.GetClassLogger();
            IJsonRpcConfig jsonRpcConfig = _context.Config <IJsonRpcConfig>();

            if (!jsonRpcConfig.Enabled)
            {
                return(Task.CompletedTask);
            }

            // the following line needs to be called in order to make sure that the CLI library is referenced from runner and built alongside
            if (logger.IsDebug)
            {
                logger.Debug($"Resolving CLI ({nameof(CliModuleLoader)})");
            }

            IInitConfig    initConfig = _context.Config <IInitConfig>();
            INdmConfig     ndmConfig  = _context.Config <INdmConfig>();
            IJsonRpcConfig rpcConfig  = _context.Config <IJsonRpcConfig>();

            if (ndmConfig.Enabled && !(_context.NdmInitializer is null) && ndmConfig.ProxyEnabled)
            {
                EthModuleProxyFactory proxyFactory = new EthModuleProxyFactory(_context.EthJsonRpcClientProxy, _context.Wallet);
                _context.RpcModuleProvider.Register(new SingletonModulePool <IEthModule>(proxyFactory, true));
                if (logger.IsInfo)
                {
                    logger.Info("Enabled JSON RPC Proxy for NDM.");
                }
            }
            else
            {
                EthModuleFactory ethModuleFactory = new EthModuleFactory(_context.DbProvider, _context.TxPool, _context.Wallet, _context.BlockTree,
                                                                         _context.EthereumEcdsa, _context.MainBlockProcessor, _context.ReceiptStorage, _context.SpecProvider, rpcConfig, _context.BloomStorage, _context.LogManager);
                _context.RpcModuleProvider.Register(new BoundedModulePool <IEthModule>(8, ethModuleFactory));
            }

            ProofModuleFactory proofModuleFactory = new ProofModuleFactory(_context.DbProvider, _context.BlockTree, _context.RecoveryStep, _context.ReceiptStorage, _context.SpecProvider, _context.LogManager);

            _context.RpcModuleProvider.Register(new BoundedModulePool <IProofModule>(2, proofModuleFactory));

            DebugModuleFactory debugModuleFactory = new DebugModuleFactory(_context.DbProvider, _context.BlockTree, _context.BlockValidator, _context.RecoveryStep, _context.RewardCalculatorSource, _context.ReceiptStorage, _context.ConfigProvider, _context.SpecProvider, _context.LogManager);

            _context.RpcModuleProvider.Register(new BoundedModulePool <IDebugModule>(8, debugModuleFactory));

            TraceModuleFactory traceModuleFactory = new TraceModuleFactory(_context.DbProvider, _context.BlockTree, _context.RecoveryStep, _context.RewardCalculatorSource, _context.ReceiptStorage, _context.SpecProvider, _context.LogManager);

            _context.RpcModuleProvider.Register(new BoundedModulePool <ITraceModule>(8, traceModuleFactory));

            if (initConfig.EnableUnsecuredDevWallet)
            {
                PersonalBridge personalBridge = new PersonalBridge(_context.EthereumEcdsa, _context.Wallet);
                PersonalModule personalModule = new PersonalModule(personalBridge, _context.LogManager);
                _context.RpcModuleProvider.Register(new SingletonModulePool <IPersonalModule>(personalModule, true));
            }

            AdminModule adminModule = new AdminModule(_context.PeerManager, _context.StaticNodesManager);

            _context.RpcModuleProvider.Register(new SingletonModulePool <IAdminModule>(adminModule, true));

            TxPoolModule txPoolModule = new TxPoolModule(_context.LogManager, _context.TxPoolInfoProvider);

            _context.RpcModuleProvider.Register(new SingletonModulePool <ITxPoolModule>(txPoolModule, true));

            NetModule netModule = new NetModule(_context.LogManager, new NetBridge(_context.Enode, _context.SyncServer, _context.PeerManager));

            _context.RpcModuleProvider.Register(new SingletonModulePool <INetModule>(netModule, true));

            ParityModule parityModule = new ParityModule(_context.EthereumEcdsa, _context.TxPool, _context.BlockTree, _context.ReceiptStorage, _context.LogManager);

            _context.RpcModuleProvider.Register(new SingletonModulePool <IParityModule>(parityModule, true));

            SubsystemStateChanged?.Invoke(this, new SubsystemStateEventArgs(EthereumSubsystemState.Running));
            return(Task.CompletedTask);
        }
        public void Get_receipt_when_block_has_few_receipts(bool withHeader, string expectedResult)
        {
            IReceiptFinder _receiptFinder = Substitute.For <IReceiptFinder>();

            LogEntry[] logEntries = new[] { Build.A.LogEntry.TestObject, Build.A.LogEntry.TestObject };

            TxReceipt receipt1 = new TxReceipt()
            {
                Bloom           = new Bloom(logEntries),
                Index           = 0,
                Recipient       = TestItem.AddressA,
                Sender          = TestItem.AddressB,
                BlockHash       = _blockTree.FindBlock(1).Hash,
                BlockNumber     = 1,
                ContractAddress = TestItem.AddressC,
                GasUsed         = 1000,
                TxHash          = _blockTree.FindBlock(1).Transactions[0].Hash,
                StatusCode      = 0,
                GasUsedTotal    = 2000,
                Logs            = logEntries
            };

            TxReceipt receipt2 = new TxReceipt()
            {
                Bloom           = new Bloom(logEntries),
                Index           = 1,
                Recipient       = TestItem.AddressC,
                Sender          = TestItem.AddressD,
                BlockHash       = _blockTree.FindBlock(1).Hash,
                BlockNumber     = 1,
                ContractAddress = TestItem.AddressC,
                GasUsed         = 1000,
                TxHash          = _blockTree.FindBlock(1).Transactions[1].Hash,
                StatusCode      = 0,
                GasUsedTotal    = 2000,
                Logs            = logEntries
            };

            Block  block  = _blockTree.FindBlock(1);
            Keccak txHash = _blockTree.FindBlock(1).Transactions[1].Hash;

            TxReceipt[] receipts = { receipt1, receipt2 };
            _receiptFinder.Get(Arg.Any <Block>()).Returns(receipts);
            _receiptFinder.Get(Arg.Any <Keccak>()).Returns(receipts);
            _receiptFinder.FindBlockHash(Arg.Any <Keccak>()).Returns(_blockTree.FindBlock(1).Hash);

            ProofModuleFactory moduleFactory = new ProofModuleFactory(
                _dbProvider,
                _blockTree,
                new TrieStore(_dbProvider.StateDb, LimboLogs.Instance).AsReadOnly(),
                new CompositeBlockPreprocessorStep(new RecoverSignatures(new EthereumEcdsa(ChainId.Mainnet, LimboLogs.Instance), NullTxPool.Instance, _specProvider, LimboLogs.Instance)),
                _receiptFinder,
                _specProvider,
                LimboLogs.Instance);

            _proofRpcModule = moduleFactory.Create();
            ReceiptWithProof receiptWithProof = _proofRpcModule.proof_getTransactionReceipt(txHash, withHeader).Data;

            if (withHeader)
            {
                Assert.NotNull(receiptWithProof.BlockHeader);
            }
            else
            {
                Assert.Null(receiptWithProof.BlockHeader);
            }

            string response = RpcTest.TestSerializedRequest(_proofRpcModule, "proof_getTransactionReceipt", $"{txHash}", $"{withHeader}");

            Assert.AreEqual(expectedResult, response);
        }
Пример #4
0
        public virtual Task Execute(CancellationToken cancellationToken)
        {
            if (_api.RpcModuleProvider == null)
            {
                throw new StepDependencyException(nameof(_api.RpcModuleProvider));
            }
            if (_api.TxPool == null)
            {
                throw new StepDependencyException(nameof(_api.TxPool));
            }
            if (_api.BlockTree == null)
            {
                throw new StepDependencyException(nameof(_api.BlockTree));
            }
            if (_api.Wallet == null)
            {
                throw new StepDependencyException(nameof(_api.Wallet));
            }
            if (_api.SpecProvider == null)
            {
                throw new StepDependencyException(nameof(_api.SpecProvider));
            }
            if (_api.TxSender == null)
            {
                throw new StepDependencyException(nameof(_api.TxSender));
            }

            ILogger        logger        = _api.LogManager.GetClassLogger();
            IJsonRpcConfig jsonRpcConfig = _api.Config <IJsonRpcConfig>();

            if (!jsonRpcConfig.Enabled)
            {
                return(Task.CompletedTask);
            }

            // the following line needs to be called in order to make sure that the CLI library is referenced from runner and built alongside
            if (logger.IsDebug)
            {
                logger.Debug($"Resolving CLI ({nameof(CliModuleLoader)})");
            }

            IInitConfig     initConfig     = _api.Config <IInitConfig>();
            INdmConfig      ndmConfig      = _api.Config <INdmConfig>();
            IJsonRpcConfig  rpcConfig      = _api.Config <IJsonRpcConfig>();
            IBaselineConfig baselineConfig = _api.Config <IBaselineConfig>();
            IVaultConfig    vaultConfig    = _api.Config <IVaultConfig>();
            INetworkConfig  networkConfig  = _api.Config <INetworkConfig>();

            if (ndmConfig.Enabled && !(_api.NdmInitializer is null) && ndmConfig.ProxyEnabled)
            {
                EthModuleProxyFactory proxyFactory = new EthModuleProxyFactory(_api.EthJsonRpcClientProxy, _api.Wallet);
                _api.RpcModuleProvider.Register(new SingletonModulePool <IEthModule>(proxyFactory, true));
                if (logger.IsInfo)
                {
                    logger.Info("Enabled JSON RPC Proxy for NDM.");
                }
            }
            else
            {
                EthModuleFactory ethModuleFactory = new EthModuleFactory(
                    _api.DbProvider,
                    _api.TxPool,
                    _api.TxSender,
                    _api.Wallet,
                    _api.BlockTree,
                    _api.EthereumEcdsa,
                    _api.MainBlockProcessor,
                    _api.ReceiptFinder,
                    _api.SpecProvider,
                    rpcConfig,
                    _api.BloomStorage,
                    _api.LogManager,
                    initConfig.IsMining);
                _api.RpcModuleProvider.Register(new BoundedModulePool <IEthModule>(8, ethModuleFactory));
            }

            ProofModuleFactory proofModuleFactory = new ProofModuleFactory(_api.DbProvider, _api.BlockTree, _api.RecoveryStep, _api.ReceiptFinder, _api.SpecProvider, _api.LogManager);

            _api.RpcModuleProvider.Register(new BoundedModulePool <IProofModule>(2, proofModuleFactory));

            DebugModuleFactory debugModuleFactory = new DebugModuleFactory(
                _api.DbProvider,
                _api.BlockTree,
                rpcConfig,
                _api.BlockValidator,
                _api.RecoveryStep,
                _api.RewardCalculatorSource,
                _api.ReceiptStorage,
                new ReceiptMigration(_api),
                _api.ConfigProvider,
                _api.SpecProvider,
                _api.LogManager);

            _api.RpcModuleProvider.Register(new BoundedModulePool <IDebugModule>(8, debugModuleFactory));

            TraceModuleFactory traceModuleFactory = new TraceModuleFactory(_api.DbProvider, _api.BlockTree, rpcConfig, _api.RecoveryStep, _api.RewardCalculatorSource, _api.ReceiptStorage, _api.SpecProvider, _api.LogManager);

            _api.RpcModuleProvider.Register(new BoundedModulePool <ITraceModule>(8, traceModuleFactory));

            PersonalModule personalModule = new PersonalModule(
                _api.EthereumEcdsa,
                _api.Wallet,
                _api.LogManager);

            _api.RpcModuleProvider.Register(new SingletonModulePool <IPersonalModule>(personalModule, true));

            AdminModule adminModule = new AdminModule(_api.BlockTree, networkConfig, _api.PeerManager, _api.StaticNodesManager, _api.Enode, initConfig.BaseDbPath);

            _api.RpcModuleProvider.Register(new SingletonModulePool <IAdminModule>(adminModule, true));

            LogFinder logFinder = new LogFinder(
                _api.BlockTree,
                _api.ReceiptFinder,
                _api.BloomStorage,
                _api.LogManager,
                new ReceiptsRecovery(), 1024);

            if (baselineConfig.Enabled)
            {
                IDbProvider  dbProvider  = _api.DbProvider !;
                IStateReader stateReader = new StateReader(dbProvider.StateDb, dbProvider.CodeDb, _api.LogManager);

                BaselineModuleFactory baselineModuleFactory = new BaselineModuleFactory(
                    _api.TxSender,
                    stateReader,
                    logFinder,
                    _api.BlockTree,
                    _api.AbiEncoder,
                    _api.FileSystem,
                    _api.LogManager);

                _api.RpcModuleProvider.Register(new SingletonModulePool <IBaselineModule>(baselineModuleFactory, true));
                if (logger?.IsInfo ?? false)
                {
                    logger !.Info($"Baseline RPC Module has been enabled");
                }
            }

            TxPoolModule txPoolModule = new TxPoolModule(_api.BlockTree, _api.TxPoolInfoProvider, _api.LogManager);

            _api.RpcModuleProvider.Register(new SingletonModulePool <ITxPoolModule>(txPoolModule, true));


            if (vaultConfig.Enabled)
            {
                VaultService vaultService = new VaultService(vaultConfig, _api.LogManager);
                VaultModule  vaultModule  = new VaultModule(vaultService, _api.LogManager);
                _api.RpcModuleProvider.Register(new SingletonModulePool <IVaultModule>(vaultModule, true));
                if (logger?.IsInfo ?? false)
                {
                    logger !.Info($"Vault RPC Module has been enabled");
                }
            }

            NetModule netModule = new NetModule(_api.LogManager, new NetBridge(_api.Enode, _api.SyncServer));

            _api.RpcModuleProvider.Register(new SingletonModulePool <INetModule>(netModule, true));

            ParityModule parityModule = new ParityModule(
                _api.EthereumEcdsa,
                _api.TxPool,
                _api.BlockTree,
                _api.ReceiptFinder,
                _api.Enode,
                _api.EngineSignerStore,
                _api.KeyStore,
                _api.LogManager);

            _api.RpcModuleProvider.Register(new SingletonModulePool <IParityModule>(parityModule, true));

            return(Task.CompletedTask);
        }
Пример #5
0
        public virtual Task Execute(CancellationToken cancellationToken)
        {
            if (_context.RpcModuleProvider == null)
            {
                throw new StepDependencyException(nameof(_context.RpcModuleProvider));
            }
            if (_context.TxPool == null)
            {
                throw new StepDependencyException(nameof(_context.TxPool));
            }
            if (_context.BlockTree == null)
            {
                throw new StepDependencyException(nameof(_context.BlockTree));
            }
            if (_context.Wallet == null)
            {
                throw new StepDependencyException(nameof(_context.Wallet));
            }
            if (_context.SpecProvider == null)
            {
                throw new StepDependencyException(nameof(_context.SpecProvider));
            }

            ILogger        logger        = _context.LogManager.GetClassLogger();
            IJsonRpcConfig jsonRpcConfig = _context.Config <IJsonRpcConfig>();

            if (!jsonRpcConfig.Enabled)
            {
                return(Task.CompletedTask);
            }

            // the following line needs to be called in order to make sure that the CLI library is referenced from runner and built alongside
            if (logger.IsDebug)
            {
                logger.Debug($"Resolving CLI ({nameof(CliModuleLoader)})");
            }

            IInitConfig     initConfig     = _context.Config <IInitConfig>();
            INdmConfig      ndmConfig      = _context.Config <INdmConfig>();
            IJsonRpcConfig  rpcConfig      = _context.Config <IJsonRpcConfig>();
            IBaselineConfig baselineConfig = _context.Config <IBaselineConfig>();
            INetworkConfig  networkConfig  = _context.Config <INetworkConfig>();

            if (ndmConfig.Enabled && !(_context.NdmInitializer is null) && ndmConfig.ProxyEnabled)
            {
                EthModuleProxyFactory proxyFactory = new EthModuleProxyFactory(_context.EthJsonRpcClientProxy, _context.Wallet);
                _context.RpcModuleProvider.Register(new SingletonModulePool <IEthModule>(proxyFactory, true));
                if (logger.IsInfo)
                {
                    logger.Info("Enabled JSON RPC Proxy for NDM.");
                }
            }
            else
            {
                EthModuleFactory ethModuleFactory = new EthModuleFactory(_context.DbProvider, _context.TxPool, _context.Wallet, rpcConfig, _context.BlockTree,
                                                                         _context.EthereumEcdsa, _context.MainBlockProcessor, _context.ReceiptFinder, _context.SpecProvider, rpcConfig, _context.BloomStorage, _context.LogManager, initConfig.IsMining);
                _context.RpcModuleProvider.Register(new BoundedModulePool <IEthModule>(8, ethModuleFactory));
            }

            ProofModuleFactory proofModuleFactory = new ProofModuleFactory(_context.DbProvider, _context.BlockTree, _context.RecoveryStep, _context.ReceiptFinder, _context.SpecProvider, _context.LogManager);

            _context.RpcModuleProvider.Register(new BoundedModulePool <IProofModule>(2, proofModuleFactory));

            DebugModuleFactory debugModuleFactory = new DebugModuleFactory(_context.DbProvider, _context.BlockTree, rpcConfig, _context.BlockValidator, _context.RecoveryStep, _context.RewardCalculatorSource, _context.ReceiptStorage, _context.ConfigProvider, _context.SpecProvider, _context.LogManager);

            _context.RpcModuleProvider.Register(new BoundedModulePool <IDebugModule>(8, debugModuleFactory));

            TraceModuleFactory traceModuleFactory = new TraceModuleFactory(_context.DbProvider, _context.BlockTree, rpcConfig, _context.RecoveryStep, _context.RewardCalculatorSource, _context.ReceiptStorage, _context.SpecProvider, _context.LogManager);

            _context.RpcModuleProvider.Register(new BoundedModulePool <ITraceModule>(8, traceModuleFactory));

            PersonalBridge personalBridge = new PersonalBridge(_context.EthereumEcdsa, _context.Wallet);
            PersonalModule personalModule = new PersonalModule(personalBridge, _context.LogManager);

            _context.RpcModuleProvider.Register(new SingletonModulePool <IPersonalModule>(personalModule, true));

            AdminModule adminModule = new AdminModule(_context.BlockTree, networkConfig, _context.PeerManager, _context.StaticNodesManager, _context.Enode, initConfig.BaseDbPath);

            _context.RpcModuleProvider.Register(new SingletonModulePool <IAdminModule>(adminModule, true));

            LogFinder logFinder = new LogFinder(
                _context.BlockTree,
                _context.ReceiptFinder,
                _context.BloomStorage,
                _context.LogManager,
                new ReceiptsRecovery(), 1024);

            if (baselineConfig.Enabled)
            {
                BaselineModuleFactory baselineModuleFactory = new BaselineModuleFactory(
                    _context.TxPool,
                    logFinder,
                    _context.BlockTree,
                    _context.AbiEncoder,
                    _context.Wallet,
                    _context.SpecProvider,
                    _context.FileSystem,
                    _context.LogManager);

                _context.RpcModuleProvider.Register(new SingletonModulePool <IBaselineModule>(baselineModuleFactory, true));
                if (logger?.IsInfo ?? false)
                {
                    logger !.Info($"Baseline RPC Module has been enabled");
                }
            }

            // commented out because of temporary strange build issues on the build server
            // IDepositConfig depositConfig = _context.Config<IDepositConfig>();
            // if (depositConfig.DepositContractAddress != null)
            // {
            //     TxPoolBridge txPoolBridge = new TxPoolBridge(
            //         _context.TxPool, new WalletTxSigner(_context.Wallet, _context.SpecProvider.ChainId), _context.Timestamper);
            //     DepositModule depositModule = new DepositModule(txPoolBridge, logFinder, depositConfig, _context.LogManager);
            //     _context.RpcModuleProvider.Register(new SingletonModulePool<IDepositModule>(depositModule, true));
            // }

            TxPoolModule txPoolModule = new TxPoolModule(_context.BlockTree, _context.TxPoolInfoProvider, _context.LogManager);

            _context.RpcModuleProvider.Register(new SingletonModulePool <ITxPoolModule>(txPoolModule, true));

            NetModule netModule = new NetModule(_context.LogManager, new NetBridge(_context.Enode, _context.SyncServer));

            _context.RpcModuleProvider.Register(new SingletonModulePool <INetModule>(netModule, true));

            ParityModule parityModule = new ParityModule(
                _context.EthereumEcdsa,
                _context.TxPool,
                _context.BlockTree,
                _context.ReceiptFinder,
                _context.Enode,
                _context.Signer,
                _context.KeyStore,
                _context.LogManager);

            _context.RpcModuleProvider.Register(new SingletonModulePool <IParityModule>(parityModule, true));

            return(Task.CompletedTask);
        }
Пример #6
0
        public virtual async Task Execute(CancellationToken cancellationToken)
        {
            if (_api.BlockTree == null)
            {
                throw new StepDependencyException(nameof(_api.BlockTree));
            }
            if (_api.ReceiptFinder == null)
            {
                throw new StepDependencyException(nameof(_api.ReceiptFinder));
            }
            if (_api.BloomStorage == null)
            {
                throw new StepDependencyException(nameof(_api.BloomStorage));
            }
            if (_api.LogManager == null)
            {
                throw new StepDependencyException(nameof(_api.LogManager));
            }

            IJsonRpcConfig jsonRpcConfig = _api.Config <IJsonRpcConfig>();

            if (!jsonRpcConfig.Enabled)
            {
                return;
            }

            if (_api.RpcModuleProvider == null)
            {
                throw new StepDependencyException(nameof(_api.RpcModuleProvider));
            }
            if (_api.FileSystem == null)
            {
                throw new StepDependencyException(nameof(_api.FileSystem));
            }
            if (_api.TxPool == null)
            {
                throw new StepDependencyException(nameof(_api.TxPool));
            }
            if (_api.Wallet == null)
            {
                throw new StepDependencyException(nameof(_api.Wallet));
            }
            if (_api.SpecProvider == null)
            {
                throw new StepDependencyException(nameof(_api.SpecProvider));
            }
            if (_api.TxSender == null)
            {
                throw new StepDependencyException(nameof(_api.TxSender));
            }
            if (_api.StateReader == null)
            {
                throw new StepDependencyException(nameof(_api.StateReader));
            }

            if (jsonRpcConfig.Enabled)
            {
                _api.RpcModuleProvider = new RpcModuleProvider(_api.FileSystem, jsonRpcConfig, _api.LogManager);
            }
            else
            {
                _api.RpcModuleProvider ??= NullModuleProvider.Instance;
            }

            // the following line needs to be called in order to make sure that the CLI library is referenced from runner and built alongside
            ILogger logger = _api.LogManager.GetClassLogger();

            IInitConfig    initConfig    = _api.Config <IInitConfig>();
            IJsonRpcConfig rpcConfig     = _api.Config <IJsonRpcConfig>();
            INetworkConfig networkConfig = _api.Config <INetworkConfig>();

            // lets add threads to support parallel eth_getLogs
            ThreadPool.GetMinThreads(out var workerThreads, out var completionPortThreads);
            ThreadPool.SetMinThreads(workerThreads + Environment.ProcessorCount, completionPortThreads + Environment.ProcessorCount);

            EthModuleFactory ethModuleFactory = new EthModuleFactory(
                _api.TxPool,
                _api.TxSender,
                _api.Wallet,
                _api.BlockTree,
                _api.Config <IJsonRpcConfig>(),
                _api.LogManager,
                _api.StateReader,
                _api);

            _api.RpcModuleProvider.Register(new BoundedModulePool <IEthModule>(ethModuleFactory, _cpuCount, rpcConfig.Timeout));

            if (_api.DbProvider == null)
            {
                throw new StepDependencyException(nameof(_api.DbProvider));
            }
            if (_api.BlockPreprocessor == null)
            {
                throw new StepDependencyException(nameof(_api.BlockPreprocessor));
            }
            if (_api.BlockValidator == null)
            {
                throw new StepDependencyException(nameof(_api.BlockValidator));
            }
            if (_api.RewardCalculatorSource == null)
            {
                throw new StepDependencyException(nameof(_api.RewardCalculatorSource));
            }

            ProofModuleFactory proofModuleFactory = new ProofModuleFactory(_api.DbProvider, _api.BlockTree, _api.BlockPreprocessor, _api.ReceiptFinder, _api.SpecProvider, _api.LogManager);

            _api.RpcModuleProvider.Register(new BoundedModulePool <IProofModule>(proofModuleFactory, 2, rpcConfig.Timeout));

            DebugModuleFactory debugModuleFactory = new DebugModuleFactory(
                _api.DbProvider,
                _api.BlockTree,
                rpcConfig,
                _api.BlockValidator,
                _api.BlockPreprocessor,
                _api.RewardCalculatorSource,
                _api.ReceiptStorage,
                new ReceiptMigration(_api),
                _api.ConfigProvider,
                _api.SpecProvider,
                _api.LogManager);

            _api.RpcModuleProvider.Register(new BoundedModulePool <IDebugModule>(debugModuleFactory, _cpuCount, rpcConfig.Timeout));

            TraceModuleFactory traceModuleFactory = new TraceModuleFactory(
                _api.DbProvider,
                _api.BlockTree,
                rpcConfig,
                _api.BlockPreprocessor,
                _api.RewardCalculatorSource,
                _api.ReceiptStorage,
                _api.SpecProvider,
                _api.LogManager);

            _api.RpcModuleProvider.Register(new BoundedModulePool <ITraceModule>(traceModuleFactory, _cpuCount, rpcConfig.Timeout));

            if (_api.EthereumEcdsa == null)
            {
                throw new StepDependencyException(nameof(_api.EthereumEcdsa));
            }
            if (_api.Wallet == null)
            {
                throw new StepDependencyException(nameof(_api.Wallet));
            }

            PersonalModule personalModule = new PersonalModule(
                _api.EthereumEcdsa,
                _api.Wallet,
                _api.LogManager);

            _api.RpcModuleProvider.Register(new SingletonModulePool <IPersonalModule>(personalModule, true));

            if (_api.PeerManager == null)
            {
                throw new StepDependencyException(nameof(_api.PeerManager));
            }
            if (_api.StaticNodesManager == null)
            {
                throw new StepDependencyException(nameof(_api.StaticNodesManager));
            }
            if (_api.Enode == null)
            {
                throw new StepDependencyException(nameof(_api.Enode));
            }

            AdminModule adminModule = new AdminModule(
                _api.BlockTree,
                networkConfig,
                _api.PeerManager,
                _api.StaticNodesManager,
                _api.Enode,
                initConfig.BaseDbPath);

            _api.RpcModuleProvider.Register(new SingletonModulePool <IAdminModule>(adminModule, true));

            if (_api.TxPoolInfoProvider == null)
            {
                throw new StepDependencyException(nameof(_api.TxPoolInfoProvider));
            }

            TxPoolModule txPoolModule = new TxPoolModule(_api.BlockTree, _api.TxPoolInfoProvider, _api.LogManager);

            _api.RpcModuleProvider.Register(new SingletonModulePool <ITxPoolModule>(txPoolModule, true));

            if (_api.SyncServer == null)
            {
                throw new StepDependencyException(nameof(_api.SyncServer));
            }
            if (_api.EngineSignerStore == null)
            {
                throw new StepDependencyException(nameof(_api.EngineSignerStore));
            }

            NetModule netModule = new NetModule(_api.LogManager, new NetBridge(_api.Enode, _api.SyncServer));

            _api.RpcModuleProvider.Register(new SingletonModulePool <INetModule>(netModule, true));

            ParityModule parityModule = new ParityModule(
                _api.EthereumEcdsa,
                _api.TxPool,
                _api.BlockTree,
                _api.ReceiptFinder,
                _api.Enode,
                _api.EngineSignerStore,
                _api.KeyStore,
                _api.LogManager);

            _api.RpcModuleProvider.Register(new SingletonModulePool <IParityModule>(parityModule, true));

            Web3Module web3Module = new Web3Module(_api.LogManager);

            _api.RpcModuleProvider.Register(new SingletonModulePool <IWeb3Module>(web3Module, true));

            foreach (INethermindPlugin plugin in _api.Plugins)
            {
                await plugin.InitRpcModules();
            }

            if (logger.IsDebug)
            {
                logger.Debug($"RPC modules  : {string.Join(", ", _api.RpcModuleProvider.Enabled.OrderBy(x => x))}");
            }
            ThisNodeInfo.AddInfo("RPC modules  :", $"{string.Join(", ", _api.RpcModuleProvider.Enabled.OrderBy(x => x))}");
        }