Ejemplo n.º 1
0
        public async Task SetUp()
        {
            _dbProvider = await TestMemDbProvider.InitAsync();

            _timestamper          = new ManualTimestamper();
            _blockTree            = Substitute.For <IBlockTree>();
            _txPool               = Substitute.For <ITxPool>();
            _receiptStorage       = Substitute.For <IReceiptStorage>();
            _filterStore          = Substitute.For <IFilterStore>();
            _filterManager        = Substitute.For <IFilterManager>();
            _transactionProcessor = Substitute.For <ITransactionProcessor>();
            _ethereumEcdsa        = Substitute.For <IEthereumEcdsa>();
            _specProvider         = MainnetSpecProvider.Instance;

            ReadOnlyTxProcessingEnv processingEnv = new ReadOnlyTxProcessingEnv(
                new ReadOnlyDbProvider(_dbProvider, false),
                new TrieStore(_dbProvider.StateDb, LimboLogs.Instance).AsReadOnly(),
                new ReadOnlyBlockTree(_blockTree),
                _specProvider,
                LimboLogs.Instance);

            processingEnv.TransactionProcessor = _transactionProcessor;

            _blockchainBridge = new BlockchainBridge(
                processingEnv,
                _txPool,
                _receiptStorage,
                _filterStore,
                _filterManager,
                _ethereumEcdsa,
                _timestamper,
                Substitute.For <ILogFinder>(),
                false,
                false);
        }
Ejemplo n.º 2
0
        public async Task Initialize()
        {
            ISpecProvider specProvider = MainnetSpecProvider.Instance;
            ITxPool       txPool       = NullTxPool.Instance;
            IDbProvider   dbProvider   = await TestMemDbProvider.InitAsync();

            BlockTree blockTree = new BlockTree(
                dbProvider.BlocksDb,
                dbProvider.HeadersDb,
                dbProvider.BlockInfosDb,
                new ChainLevelInfoRepository(dbProvider.BlockInfosDb),
                specProvider,
                new BloomStorage(new BloomConfig(), dbProvider.HeadersDb, new InMemoryDictionaryFileStoreFactory()),
                new SyncConfig(),
                LimboLogs.Instance);

            _modulePool = new BoundedModulePool <IEthModule>(new EthModuleFactory(
                                                                 txPool,
                                                                 Substitute.For <ITxSender>(),
                                                                 NullWallet.Instance,
                                                                 blockTree,
                                                                 new JsonRpcConfig(),
                                                                 LimboLogs.Instance,
                                                                 Substitute.For <IStateReader>(),
                                                                 Substitute.For <IBlockchainBridgeFactory>()), 1, 1000);
        }
Ejemplo n.º 3
0
    public async Task Can_keep_returning_nulls_after_all_batches_were_prepared()
    {
        IDbProvider memDbProvider = await TestMemDbProvider.InitAsync();

        BlockTree blockTree = new(memDbProvider, new ChainLevelInfoRepository(memDbProvider.BlockInfosDb),
                                  MainnetSpecProvider.Instance, NullBloomStorage.Instance, LimboLogs.Instance);
        ISyncConfig syncConfig = new SyncConfig
        {
            FastSync             = true,
            FastBlocks           = true,
            PivotNumber          = "1000",
            PivotHash            = Keccak.Zero.ToString(),
            PivotTotalDifficulty = "1000"
        };
        PoSSwitcher poSSwitcher = new(new MergeConfig(), syncConfig, memDbProvider.MetadataDb, blockTree !,
                                      MainnetSpecProvider.Instance, LimboLogs.Instance);
        IBeaconPivot          pivot = PreparePivot(2000, syncConfig, blockTree);
        BeaconHeadersSyncFeed feed  = new(poSSwitcher, Substitute.For <ISyncModeSelector>(), blockTree,
                                          Substitute.For <ISyncPeerPool>(), syncConfig, Substitute.For <ISyncReport>(),
                                          pivot, new MergeConfig()
        {
            Enabled = true
        }, new NoopInvalidChainTracker(), LimboLogs.Instance);

        feed.InitializeFeed();
        for (int i = 0; i < 6; i++)
        {
            await feed.PrepareRequest();
        }

        HeadersSyncBatch?result = await feed.PrepareRequest();

        result.Should().BeNull();
    }
Ejemplo n.º 4
0
        public async Task Will_fail_if_launched_without_fast_blocks_enabled()
        {
            IDbProvider memDbProvider = await TestMemDbProvider.InitAsync();

            BlockTree blockTree = new(memDbProvider.BlocksDb, memDbProvider.HeadersDb, memDbProvider.BlockInfosDb, new ChainLevelInfoRepository(memDbProvider.BlockInfosDb), MainnetSpecProvider.Instance, NullBloomStorage.Instance, LimboLogs.Instance);

            Assert.Throws <InvalidOperationException>(() => new HeadersSyncFeed(blockTree, Substitute.For <ISyncPeerPool>(), new SyncConfig(), Substitute.For <ISyncReport>(), LimboLogs.Instance));
        }
Ejemplo n.º 5
0
        public async Task Can_prepare_3_requests_in_a_row()
        {
            IDbProvider memDbProvider = await TestMemDbProvider.InitAsync();

            BlockTree       blockTree = new(memDbProvider.BlocksDb, memDbProvider.HeadersDb, memDbProvider.BlockInfosDb, new ChainLevelInfoRepository(memDbProvider.BlockInfosDb), MainnetSpecProvider.Instance, NullBloomStorage.Instance, LimboLogs.Instance);
            HeadersSyncFeed feed      = new(blockTree, Substitute.For <ISyncPeerPool>(), new SyncConfig {
                FastSync = true, FastBlocks = true, PivotNumber = "1000", PivotHash = Keccak.Zero.ToString(), PivotTotalDifficulty = "1000"
            }, Substitute.For <ISyncReport>(), LimboLogs.Instance);
            HeadersSyncBatch batch1   = await feed.PrepareRequest();

            HeadersSyncBatch batch2 = await feed.PrepareRequest();

            HeadersSyncBatch batch3 = await feed.PrepareRequest();
        }
        private async Task SetupBeamProcessor(ISyncModeSelector syncModeSelector = null)
        {
            IDbProvider memDbProvider = await TestMemDbProvider.InitAsync();

            _beamBlockchainProcessor = new BeamBlockchainProcessor(
                new ReadOnlyDbProvider(memDbProvider, false),
                _blockTree,
                MainnetSpecProvider.Instance,
                LimboLogs.Instance,
                _validator,
                NullRecoveryStep.Instance,
                NoBlockRewards.Instance,
                _blockchainProcessingQueue,
                syncModeSelector ?? new StaticSelector(SyncMode.Beam)
                );
        }
        public async Task ProviderInitTests_BeamSyncDbProvider()
        {
            var syncModeSelector = Substitute.For <ISyncModeSelector>();
            var dbProvider       = await TestMemDbProvider.InitAsync();

            var         rocksDbFactory     = new RocksDbFactory(new DbConfig(), LimboLogs.Instance, Path.Combine(_folderWithDbs, "beam"));
            IDbProvider beamSyncDbProvider = new BeamSyncDbProvider(syncModeSelector, dbProvider, new SyncConfig(), LimboLogs.Instance);
            var         initializer        = new ConsumerNdmDbInitializer(beamSyncDbProvider, new NdmConfig(), rocksDbFactory, new MemDbFactory());

            initializer.Reset();
            await initializer.InitAsync();

            Assert.IsTrue(beamSyncDbProvider.GetDb <IDb>(ConsumerNdmDbNames.ConsumerDepositApprovals) is MemDb);
            Assert.IsTrue(beamSyncDbProvider.GetDb <IDb>(ConsumerNdmDbNames.ConsumerReceipts) is MemDb);
            Assert.IsTrue(beamSyncDbProvider.GetDb <IDb>(ConsumerNdmDbNames.ConsumerSessions) is MemDb);
            Assert.IsTrue(beamSyncDbProvider.GetDb <IDb>(ConsumerNdmDbNames.Deposits) is MemDb);
        }
Ejemplo n.º 8
0
        public async Task Can_keep_returning_nulls_after_all_batches_were_prepared()
        {
            IDbProvider memDbProvider = await TestMemDbProvider.InitAsync();

            BlockTree       blockTree = new(memDbProvider.BlocksDb, memDbProvider.HeadersDb, memDbProvider.BlockInfosDb, new ChainLevelInfoRepository(memDbProvider.BlockInfosDb), MainnetSpecProvider.Instance, NullBloomStorage.Instance, LimboLogs.Instance);
            HeadersSyncFeed feed      = new(blockTree, Substitute.For <ISyncPeerPool>(), new SyncConfig {
                FastSync = true, FastBlocks = true, PivotNumber = "1000", PivotHash = Keccak.Zero.ToString(), PivotTotalDifficulty = "1000"
            }, Substitute.For <ISyncReport>(), LimboLogs.Instance);

            for (int i = 0; i < 10; i++)
            {
                await feed.PrepareRequest();
            }

            var result = await feed.PrepareRequest();

            result.Should().BeNull();
        }
Ejemplo n.º 9
0
        public async Task Setup()
        {
            InMemoryReceiptStorage receiptStorage = new();
            _specProvider = new TestSpecProvider(London.Instance);
            _blockTree = Build.A.BlockTree().WithTransactions(receiptStorage, _specProvider).OfChainLength(10).TestObject;
            _dbProvider = await TestMemDbProvider.InitAsync();

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

            _proofRpcModule = moduleFactory.Create();
        }
        public async Task Setup()
        {
            _genesisBlock = Build.A.Block.WithNumber(0).TestObject;
            _blockTree    = Build.A.BlockTree(_genesisBlock).OfChainLength(1).TestObject;
            IDbProvider dbProvider = await TestMemDbProvider.InitAsync();

            _stateDb        = dbProvider.StateDb;
            _codeDb         = dbProvider.CodeDb;
            _receiptStorage = Substitute.For <IReceiptStorage>();
            SyncConfig quickConfig = new SyncConfig();

            quickConfig.FastSync = false;

            ITimerFactory timerFactory = Substitute.For <ITimerFactory>();
            var           stats        = new NodeStatsManager(timerFactory, LimboLogs.Instance);

            _pool = new SyncPeerPool(_blockTree, stats, 25, LimboLogs.Instance);
            SyncConfig           syncConfig = new SyncConfig();
            SyncProgressResolver resolver   = new SyncProgressResolver(
                _blockTree,
                _receiptStorage,
                _stateDb,
                dbProvider.BeamTempDb,
                new TrieStore(_stateDb, LimboLogs.Instance),
                syncConfig,
                LimboLogs.Instance);
            MultiSyncModeSelector syncModeSelector = new MultiSyncModeSelector(resolver, _pool, syncConfig, LimboLogs.Instance);

            _synchronizer = new Synchronizer(dbProvider, MainnetSpecProvider.Instance, _blockTree, _receiptStorage, Always.Valid, Always.Valid, _pool, stats, syncModeSelector, syncConfig, LimboLogs.Instance);
            _syncServer   = new SyncServer(
                _stateDb,
                _codeDb,
                _blockTree,
                _receiptStorage,
                Always.Valid,
                Always.Valid,
                _pool,
                syncModeSelector,
                quickConfig,
                new WitnessCollector(new MemDb(), LimboLogs.Instance),
                LimboLogs.Instance);
        }
Ejemplo n.º 11
0
        public async Task Initialize()
        {
            ISpecProvider specProvider = MainnetSpecProvider.Instance;
            ITxPool       txPool       = NullTxPool.Instance;
            IDbProvider   dbProvider   = await TestMemDbProvider.InitAsync();

            BlockTree blockTree = new(dbProvider.BlocksDb, dbProvider.HeadersDb, dbProvider.BlockInfosDb, new ChainLevelInfoRepository(dbProvider.BlockInfosDb), specProvider, NullBloomStorage.Instance, new SyncConfig(), LimboLogs.Instance);

            _factory = new EthModuleFactory(
                txPool,
                Substitute.For <ITxSender>(),
                NullWallet.Instance,
                blockTree,
                new JsonRpcConfig(),
                LimboLogs.Instance,
                Substitute.For <IStateReader>(),
                Substitute.For <IBlockchainBridgeFactory>(),
                Substitute.For <ISpecProvider>(),
                Substitute.For <IReceiptStorage>(),
                Substitute.For <IGasPriceOracle>(),
                Substitute.For <IEthSyncingInfo>());
        }
Ejemplo n.º 12
0
        protected virtual async Task <TestBlockchain> Build(ISpecProvider specProvider = null, UInt256?initialValues = null)
        {
            Timestamper    = new ManualTimestamper(new DateTime(2020, 2, 15, 12, 50, 30, DateTimeKind.Utc));
            JsonSerializer = new EthereumJsonSerializer();
            SpecProvider   = specProvider ?? MainnetSpecProvider.Instance;
            EthereumEcdsa  = new EthereumEcdsa(ChainId.Mainnet, LimboLogs.Instance);
            ITxStorage txStorage = new InMemoryTxStorage();

            DbProvider = await TestMemDbProvider.InitAsync();

            State = new StateProvider(StateDb, CodeDb, LimboLogs.Instance);
            State.CreateAccount(TestItem.AddressA, (initialValues ?? 1000.Ether()));
            State.CreateAccount(TestItem.AddressB, (initialValues ?? 1000.Ether()));
            State.CreateAccount(TestItem.AddressC, (initialValues ?? 1000.Ether()));
            byte[] code     = Bytes.FromHexString("0xabcd");
            Keccak codeHash = Keccak.Compute(code);

            State.UpdateCode(code);
            State.UpdateCodeHash(TestItem.AddressA, codeHash, SpecProvider.GenesisSpec);

            Storage = new StorageProvider(StateDb, State, LimboLogs.Instance);
            Storage.Set(new StorageCell(TestItem.AddressA, UInt256.One), Bytes.FromHexString("0xabcdef"));
            Storage.Commit();

            State.Commit(SpecProvider.GenesisSpec);
            State.CommitTree();

            TxPool = new TxPool.TxPool(
                txStorage,
                EthereumEcdsa,
                SpecProvider,
                new TxPoolConfig(),
                new StateProvider(StateDb, CodeDb, LimboLogs.Instance),
                LimboLogs.Instance);

            IDb blockDb     = new MemDb();
            IDb headerDb    = new MemDb();
            IDb blockInfoDb = new MemDb();

            BlockTree = new BlockTree(blockDb, headerDb, blockInfoDb, new ChainLevelInfoRepository(blockDb), SpecProvider, NullBloomStorage.Instance, LimboLogs.Instance);
            new OnChainTxWatcher(BlockTree, TxPool, SpecProvider, LimboLogs.Instance);

            ReceiptStorage = new InMemoryReceiptStorage();
            VirtualMachine virtualMachine = new VirtualMachine(State, Storage, new BlockhashProvider(BlockTree, LimboLogs.Instance), SpecProvider, LimboLogs.Instance);

            TxProcessor    = new TransactionProcessor(SpecProvider, State, Storage, virtualMachine, LimboLogs.Instance);
            BlockProcessor = CreateBlockProcessor();

            BlockchainProcessor chainProcessor = new BlockchainProcessor(BlockTree, BlockProcessor, new RecoverSignatures(EthereumEcdsa, TxPool, SpecProvider, LimboLogs.Instance), LimboLogs.Instance, Nethermind.Blockchain.Processing.BlockchainProcessor.Options.Default);

            BlockchainProcessor = chainProcessor;
            chainProcessor.Start();

            StateReader = new StateReader(StateDb, CodeDb, LimboLogs.Instance);
            TxPoolTxSource txPoolTxSource = CreateTxPoolTxSource();
            ISealer        sealer         = new NethDevSealEngine(TestItem.AddressD);

            BlockProducer = new TestBlockProducer(txPoolTxSource, chainProcessor, State, sealer, BlockTree, chainProcessor, Timestamper, LimboLogs.Instance);
            BlockProducer.Start();

            _resetEvent = new SemaphoreSlim(0);
            _suggestedBlockResetEvent = new ManualResetEvent(true);
            BlockTree.NewHeadBlock   += (s, e) =>
            {
                _resetEvent.Release(1);
            };
            BlockProducer.LastProducedBlockChanged += (s, e) =>
            {
                _suggestedBlockResetEvent.Set();
            };

            var genesis = GetGenesisBlock();

            BlockTree.SuggestBlock(genesis);
            await _resetEvent.WaitAsync();

            //if (!await _resetEvent.WaitAsync(1000))
            // {
            //     throw new InvalidOperationException("Failed to process genesis in 1s.");
            // }

            await AddBlocksOnStart();

            return(this);
        }
Ejemplo n.º 13
0
        public async Task Get_storage()
        {
            IDbProvider dbProvider = await TestMemDbProvider.InitAsync();

            /* all testing will be touching just a single storage cell */
            StorageCell storageCell = new StorageCell(_address1, UInt256.One);

            TrieStore       trieStore = new TrieStore(dbProvider.StateDb, Logger);
            StateProvider   state     = new StateProvider(trieStore, dbProvider.CodeDb, Logger);
            StorageProvider storage   = new StorageProvider(trieStore, state, Logger);

            /* to start with we need to create an account that we will be setting storage at */
            state.CreateAccount(storageCell.Address, UInt256.One);
            state.Commit(MuirGlacier.Instance);
            state.CommitTree(1);

            /* at this stage we have an account with empty storage at the address that we want to test */

            byte[] initialValue = new byte[] { 1, 2, 3 };
            storage.Set(storageCell, initialValue);
            storage.Commit();
            storage.CommitTrees(2);
            state.Commit(MuirGlacier.Instance);
            state.CommitTree(2);

            StateReader reader = new StateReader(
                new TrieStore(dbProvider.StateDb, LimboLogs.Instance), dbProvider.CodeDb, Logger);

            var account   = reader.GetAccount(state.StateRoot, _address1);
            var retrieved = reader.GetStorage(account.StorageRoot, storageCell.Index);

            retrieved.Should().BeEquivalentTo(initialValue);

            /* at this stage we set the value in storage to 1,2,3 at the tested storage cell */

            /* Now we are testing scenario where the storage is being changed by the block processor.
            *  To do that we create some different storage / state access stack that represents the processor.
            *  It is a different stack of objects than the one that is used by the blockchain bridge. */

            byte[] newValue = new byte[] { 1, 2, 3, 4, 5 };

            StateProvider processorStateProvider =
                new StateProvider(trieStore, new MemDb(), LimboLogs.Instance);

            processorStateProvider.StateRoot = state.StateRoot;

            StorageProvider processorStorageProvider =
                new StorageProvider(trieStore, processorStateProvider, LimboLogs.Instance);

            processorStorageProvider.Set(storageCell, newValue);
            processorStorageProvider.Commit();
            processorStorageProvider.CommitTrees(3);
            processorStateProvider.Commit(MuirGlacier.Instance);
            processorStateProvider.CommitTree(3);

            /* At this stage the DB should have the storage value updated to 5.
             * We will try to retrieve the value by taking the state root from the processor.*/

            retrieved =
                reader.GetStorage(processorStateProvider.GetStorageRoot(storageCell.Address), storageCell.Index);
            retrieved.Should().BeEquivalentTo(newValue);

            /* If it failed then it means that the blockchain bridge cached the previous call value */
        }
Ejemplo n.º 14
0
        private async Task Initialize(bool auRa = false)
        {
            IDbProvider dbProvider = await TestMemDbProvider.InitAsync();

            ISpecProvider specProvider = MainnetSpecProvider.Instance;

            _jsonRpcConfig = new JsonRpcConfig();
            IEthereumEcdsa ethereumEcdsa = new EthereumEcdsa(specProvider.ChainId, LimboLogs.Instance);
            ITxStorage     txStorage     = new InMemoryTxStorage();

            _stateDb       = new StateDb();
            _stateProvider = new StateProvider(dbProvider, LimboLogs.Instance);
            _stateProvider.CreateAccount(TestItem.AddressA, 1000.Ether());
            _stateProvider.CreateAccount(TestItem.AddressB, 1000.Ether());
            _stateProvider.CreateAccount(TestItem.AddressC, 1000.Ether());
            byte[] code     = Bytes.FromHexString("0xabcd");
            Keccak codeHash = Keccak.Compute(code);

            _stateProvider.UpdateCode(code);
            _stateProvider.UpdateCodeHash(TestItem.AddressA, codeHash, specProvider.GenesisSpec);

            IStorageProvider storageProvider = new StorageProvider(_stateDb, _stateProvider, LimboLogs.Instance);

            storageProvider.Set(new StorageCell(TestItem.AddressA, UInt256.One), Bytes.FromHexString("0xabcdef"));
            storageProvider.Commit();

            _stateProvider.Commit(specProvider.GenesisSpec);
            _stateProvider.CommitTree();

            ITxPool txPool = new TxPool.TxPool(txStorage, ethereumEcdsa, specProvider, new TxPoolConfig(), _stateProvider, LimboLogs.Instance);
            IChainLevelInfoRepository chainLevels = new ChainLevelInfoRepository(dbProvider);
            IBlockTree blockTree = new BlockTree(dbProvider, chainLevels, specProvider, NullBloomStorage.Instance, LimboLogs.Instance);

            IReceiptStorage      receiptStorage = new InMemoryReceiptStorage();
            VirtualMachine       virtualMachine = new VirtualMachine(_stateProvider, storageProvider, new BlockhashProvider(blockTree, LimboLogs.Instance), specProvider, LimboLogs.Instance);
            TransactionProcessor txProcessor    = new TransactionProcessor(specProvider, _stateProvider, storageProvider, virtualMachine, LimboLogs.Instance);
            IBlockProcessor      blockProcessor = new BlockProcessor(
                specProvider,
                Always.Valid,
                new RewardCalculator(specProvider),
                txProcessor,
                dbProvider.StateDb,
                dbProvider.CodeDb,
                _stateProvider,
                storageProvider,
                txPool,
                receiptStorage,
                LimboLogs.Instance);

            var signatureRecovery = new RecoverSignatures(ethereumEcdsa, txPool, specProvider, LimboLogs.Instance);
            BlockchainProcessor blockchainProcessor = new BlockchainProcessor(blockTree, blockProcessor, signatureRecovery, LimboLogs.Instance, BlockchainProcessor.Options.Default);

            blockchainProcessor.Start();

            ManualResetEventSlim resetEvent = new ManualResetEventSlim(false);

            blockTree.NewHeadBlock += (s, e) =>
            {
                Console.WriteLine(e.Block.Header.Hash);
                if (e.Block.Number == 9)
                {
                    resetEvent.Set();
                }
            };

            var genesisBlockBuilder = Build.A.Block.Genesis.WithStateRoot(new Keccak("0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f"));

            if (auRa)
            {
                genesisBlockBuilder.WithAura(0, new byte[65]);
            }

            Block genesis = genesisBlockBuilder.TestObject;

            blockTree.SuggestBlock(genesis);

            Block previousBlock = genesis;

            for (int i = 1; i < 10; i++)
            {
                List <Transaction> transactions = new List <Transaction>();
                for (int j = 0; j < i; j++)
                {
                    transactions.Add(Build.A.Transaction.WithNonce((UInt256)j).SignedAndResolved().TestObject);
                }

                BlockBuilder builder = Build.A.Block.WithNumber(i).WithParent(previousBlock).WithTransactions(transactions.ToArray()).WithStateRoot(new Keccak("0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f"));
                if (auRa)
                {
                    builder.WithAura(i, i.ToByteArray());
                }

                Block block = builder.TestObject;
                blockTree.SuggestBlock(block);
                previousBlock = block;
            }

            ReceiptsRecovery receiptsRecovery = new ReceiptsRecovery(new EthereumEcdsa(specProvider.ChainId, LimboLogs.Instance), specProvider);
            IReceiptFinder   receiptFinder    = new FullInfoReceiptFinder(receiptStorage, receiptsRecovery, blockTree);

            resetEvent.Wait(2000);
            _traceModule = new TraceModule(receiptFinder, new Tracer(_stateProvider, blockchainProcessor), blockTree, _jsonRpcConfig);
        }
        public async Task Setup()
        {
            _genesisBlock = Build.A.Block.WithNumber(0).TestObject;
            _blockTree    = Build.A.BlockTree(_genesisBlock).OfChainLength(1).TestObject;
            IDbProvider dbProvider = await TestMemDbProvider.InitAsync();

            _stateDb        = dbProvider.StateDb;
            _codeDb         = dbProvider.CodeDb;
            _receiptStorage = Substitute.For <IReceiptStorage>();
            SyncConfig quickConfig = new() { FastSync = false };

            ITimerFactory    timerFactory = Substitute.For <ITimerFactory>();
            NodeStatsManager stats        = new(timerFactory, LimboLogs.Instance);

            _pool = new SyncPeerPool(_blockTree, stats, new TotalDifficultyBetterPeerStrategy(LimboLogs.Instance), 25, LimboLogs.Instance);
            SyncConfig      syncConfig      = new();
            ProgressTracker progressTracker = new(_blockTree, dbProvider.StateDb, LimboLogs.Instance);
            SnapProvider    snapProvider    = new(progressTracker, dbProvider, LimboLogs.Instance);

            TrieStore            trieStore = new(_stateDb, LimboLogs.Instance);
            SyncProgressResolver resolver  = new(
                _blockTree,
                _receiptStorage,
                _stateDb,
                trieStore,
                progressTracker,
                syncConfig,
                LimboLogs.Instance);
            TotalDifficultyBetterPeerStrategy bestPeerStrategy = new(LimboLogs.Instance);
            MultiSyncModeSelector             syncModeSelector = new(resolver, _pool, syncConfig, No.BeaconSync, bestPeerStrategy, LimboLogs.Instance);
            Pivot                  pivot                  = new (syncConfig);
            SyncReport             syncReport             = new(_pool, stats, syncModeSelector, syncConfig, pivot, LimboLogs.Instance);
            BlockDownloaderFactory blockDownloaderFactory = new(
                MainnetSpecProvider.Instance,
                _blockTree,
                _receiptStorage,
                Always.Valid,
                Always.Valid,
                _pool,
                new TotalDifficultyBetterPeerStrategy(LimboLogs.Instance),
                syncReport,
                LimboLogs.Instance);

            _synchronizer = new Synchronizer(
                dbProvider,
                MainnetSpecProvider.Instance,
                _blockTree,
                _receiptStorage,
                _pool,
                stats,
                syncModeSelector,
                syncConfig,
                snapProvider,
                blockDownloaderFactory,
                pivot,
                syncReport,
                LimboLogs.Instance);
            _syncServer = new SyncServer(
                trieStore,
                _codeDb,
                _blockTree,
                _receiptStorage,
                Always.Valid,
                Always.Valid,
                _pool,
                syncModeSelector,
                quickConfig,
                new WitnessCollector(new MemDb(), LimboLogs.Instance),
                Policy.FullGossip,
                MainnetSpecProvider.Instance,
                LimboLogs.Instance);
        }