Ejemplo n.º 1
0
    private BlockDownloader CreateMergeBlockDownloader(Context ctx)
    {
        IBlockTree blockTree        = Substitute.For <IBlockTree>();
        MemDb      metadataDb       = new MemDb();
        var        testSpecProvider = new TestSpecProvider(London.Instance);

        testSpecProvider.TerminalTotalDifficulty = 0;
        PoSSwitcher posSwitcher = new(new MergeConfig()
        {
            Enabled = true, TerminalTotalDifficulty = "0"
        }, new SyncConfig(), metadataDb, blockTree,
                                      testSpecProvider, LimboLogs.Instance);
        BeaconPivot            beaconPivot    = new(new SyncConfig(), metadataDb, blockTree, LimboLogs.Instance);
        InMemoryReceiptStorage receiptStorage = new();

        BlockCacheService blockCacheService = new();

        return(new MergeBlockDownloader(
                   posSwitcher,
                   beaconPivot,
                   ctx.Feed,
                   ctx.PeerPool,
                   ctx.BlockTree,
                   Always.Valid,
                   Always.Valid,
                   NullSyncReport.Instance,
                   receiptStorage,
                   testSpecProvider,
                   CreateMergePeerChoiceStrategy(posSwitcher, beaconPivot),
                   new ChainLevelHelper(blockTree, beaconPivot, new SyncConfig(), LimboLogs.Instance),
                   Substitute.For <ISyncProgressResolver>(),
                   LimboLogs.Instance));
    }
Ejemplo n.º 2
0
        public static Task <TestAccountAbstractionRpcBlockchain> CreateChain(IReleaseSpec?releaseSpec = null, UInt256?initialBaseFeePerGas = null)
        {
            TestAccountAbstractionRpcBlockchain testMevRpcBlockchain = new(initialBaseFeePerGas);
            TestSpecProvider testSpecProvider = releaseSpec is not null ? new TestSpecProvider(releaseSpec) : new TestSpecProvider(London.Instance);

            testSpecProvider.ChainId = 1;
            return(TestRpcBlockchain.ForTest(testMevRpcBlockchain).Build(testSpecProvider));
        }
        public static Task <TestMevRpcBlockchain> CreateChain(int maxMergedBundles, IReleaseSpec?releaseSpec = null, UInt256?initialBaseFeePerGas = null, Address[]?relayAddresses = null)
        {
            TestMevRpcBlockchain testMevRpcBlockchain = new(maxMergedBundles, initialBaseFeePerGas, relayAddresses);
            TestSpecProvider     testSpecProvider     = releaseSpec is not null ? new TestSpecProvider(releaseSpec) : new TestSpecProvider(Berlin.Instance);

            testSpecProvider.ChainId = 1;
            return(TestRpcBlockchain.ForTest(testMevRpcBlockchain).Build(testSpecProvider));
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
            public ScenarioBuilder WithBlockTrees(int notSyncedTreeSize, int syncedTreeSize = -1, bool moveBlocksToMainChain = true, UInt256?ttd = null)
            {
                TestSpecProvider testSpecProvider = new TestSpecProvider(London.Instance);

                if (ttd != null)
                {
                    testSpecProvider.TerminalTotalDifficulty = ttd;
                }
                NotSyncedTreeBuilder = Build.A.BlockTree().OfChainLength(notSyncedTreeSize);
                NotSyncedTree        = new(
                    NotSyncedTreeBuilder.BlocksDb,
                    NotSyncedTreeBuilder.HeadersDb,
                    NotSyncedTreeBuilder.BlockInfoDb,
                    NotSyncedTreeBuilder.MetadataDb,
                    NotSyncedTreeBuilder.ChainLevelInfoRepository,
                    testSpecProvider,
                    NullBloomStorage.Instance,
                    new SyncConfig(),
                    LimboLogs.Instance);

                if (syncedTreeSize > 0)
                {
                    _syncedTreeBuilder = Build.A.BlockTree().OfChainLength(syncedTreeSize);
                    SyncedTree         = new(
                        _syncedTreeBuilder.BlocksDb,
                        _syncedTreeBuilder.HeadersDb,
                        _syncedTreeBuilder.BlockInfoDb,
                        _syncedTreeBuilder.MetadataDb,
                        _syncedTreeBuilder.ChainLevelInfoRepository,
                        testSpecProvider,
                        NullBloomStorage.Instance,
                        new SyncConfig(),
                        LimboLogs.Instance);
                }

                _beaconPivot = new BeaconPivot(new SyncConfig(), new MemDb(), SyncedTree, LimboLogs.Instance);

                _chainLevelHelper = new ChainLevelHelper(NotSyncedTree, _beaconPivot, new SyncConfig(), LimboLogs.Instance);
                if (moveBlocksToMainChain)
                {
                    NotSyncedTree.NewBestSuggestedBlock += OnNewBestSuggestedBlock;
                }
                return(this);
            }