protected LoopBlockProducerBase( ITxSource txSource, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, IStateProvider stateProvider, ITimestamper timestamper, IGasLimitCalculator gasLimitCalculator, ISpecProvider specProvider, ILogManager logManager, string name) : base( txSource, processor, sealer, blockTree, blockProcessingQueue, stateProvider, gasLimitCalculator, timestamper, specProvider, logManager) { _name = name; }
public MinedBlockProducer(ITxSource txSource, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, IStateProvider stateProvider, IGasLimitCalculator gasLimitCalculator, ITimestamper timestamper, ISpecProvider specProvider, ILogManager logManager, IDifficultyCalculator difficultyCalculator) : base( txSource, processor, sealer, blockTree, blockProcessingQueue, stateProvider, gasLimitCalculator, timestamper, specProvider, logManager) { _difficultyCalculator = difficultyCalculator ?? throw new ArgumentNullException(nameof(difficultyCalculator)); }
public CliqueBlockProducer(ITransactionPool transactionPool, IBlockchainProcessor blockchainProcessor, IBlockTree blockTree, ITimestamp timestamp, ICryptoRandom cryptoRandom, IStateProvider stateProvider, ISnapshotManager snapshotManager, ISealer cliqueSealer, Address address, ICliqueConfig config, ILogManager logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _transactionPool = transactionPool ?? throw new ArgumentNullException(nameof(transactionPool)); _processor = blockchainProcessor ?? throw new ArgumentNullException(nameof(blockchainProcessor)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _timestamp = timestamp ?? throw new ArgumentNullException(nameof(timestamp)); _cryptoRandom = cryptoRandom ?? throw new ArgumentNullException(nameof(cryptoRandom)); _sealer = cliqueSealer ?? throw new ArgumentNullException(nameof(cliqueSealer)); _snapshotManager = snapshotManager ?? throw new ArgumentNullException(nameof(snapshotManager)); _config = config ?? throw new ArgumentNullException(nameof(config)); _address = address ?? throw new ArgumentNullException(nameof(address)); _timer.AutoReset = false; _timer.Elapsed += TimerOnElapsed; _timer.Interval = 100; _timer.Start(); }
public CliqueBlockProducer(IPendingTxSelector pendingTxSelector, IBlockchainProcessor blockchainProcessor, IStateProvider stateProvider, IBlockTree blockTree, ITimestamper timestamper, ICryptoRandom cryptoRandom, ISnapshotManager snapshotManager, ISealer cliqueSealer, Address address, ICliqueConfig config, ILogManager logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _pendingTxSelector = pendingTxSelector ?? throw new ArgumentNullException(nameof(pendingTxSelector)); _processor = blockchainProcessor ?? throw new ArgumentNullException(nameof(blockchainProcessor)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); _cryptoRandom = cryptoRandom ?? throw new ArgumentNullException(nameof(cryptoRandom)); _sealer = cliqueSealer ?? throw new ArgumentNullException(nameof(cliqueSealer)); _snapshotManager = snapshotManager ?? throw new ArgumentNullException(nameof(snapshotManager)); _config = config ?? throw new ArgumentNullException(nameof(config)); _address = address ?? throw new ArgumentNullException(nameof(address)); _wiggle = new WiggleRandomizer(_cryptoRandom, _snapshotManager); _timer.AutoReset = false; _timer.Elapsed += TimerOnElapsed; _timer.Interval = 100; _timer.Start(); }
public AuRaBlockProducer(ITxSource txSource, IBlockchainProcessor processor, IBlockProductionTrigger blockProductionTrigger, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, ITimestamper timestamper, IAuRaStepCalculator auRaStepCalculator, IReportingValidator reportingValidator, IAuraConfig config, IGasLimitCalculator gasLimitCalculator, ISpecProvider specProvider, ILogManager logManager) : base( txSource, processor, sealer, blockTree, blockProductionTrigger, stateProvider, gasLimitCalculator, timestamper, specProvider, logManager, new AuraDifficultyCalculator(auRaStepCalculator)) { _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _reportingValidator = reportingValidator ?? throw new ArgumentNullException(nameof(reportingValidator)); _config = config ?? throw new ArgumentNullException(nameof(config)); }
public TestAuraProducer(ITxSource transactionSource, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, ITimestamper timestamper, ILogManager logManager, IAuRaStepCalculator auRaStepCalculator, IReportingValidator reportingValidator, IAuraConfig config, ISpecProvider specProvider) : base( transactionSource, processor, stateProvider, sealer, blockTree, blockProcessingQueue, timestamper, auRaStepCalculator, reportingValidator, config, FollowOtherMiners.Instance, specProvider, logManager) { }
public void SetUp() { _stepDelay = TimeSpan.FromMilliseconds(20); _pendingTxSelector = Substitute.For <IPendingTxSelector>(); _blockchainProcessor = Substitute.For <IBlockchainProcessor>(); _sealer = Substitute.For <ISealer>(); _blockTree = Substitute.For <IBlockTree>(); _blockProcessingQueue = Substitute.For <IBlockProcessingQueue>(); _stateProvider = Substitute.For <IStateProvider>(); _timestamper = Substitute.For <ITimestamper>(); _auRaStepCalculator = Substitute.For <IAuRaStepCalculator>(); _auraConfig = Substitute.For <IAuraConfig>(); _nodeAddress = TestItem.AddressA; _auRaBlockProducer = new AuRaBlockProducer( _pendingTxSelector, _blockchainProcessor, _stateProvider, _sealer, _blockTree, _blockProcessingQueue, _timestamper, LimboLogs.Instance, _auRaStepCalculator, _auraConfig, _nodeAddress); _auraConfig.ForceSealing.Returns(true); _pendingTxSelector.SelectTransactions(Arg.Any <long>()).Returns(Array.Empty <Transaction>()); _sealer.CanSeal(Arg.Any <long>(), Arg.Any <Keccak>()).Returns(true); _sealer.SealBlock(Arg.Any <Block>(), Arg.Any <CancellationToken>()).Returns(c => Task.FromResult(c.Arg <Block>())); _blockProcessingQueue.IsEmpty.Returns(true); _auRaStepCalculator.TimeToNextStep.Returns(_stepDelay); _blockTree.BestKnownNumber.Returns(1); _blockTree.Head.Returns(Build.A.BlockHeader.WithAura(10, Bytes.Empty).TestObject); _blockchainProcessor.Process(Arg.Any <Block>(), ProcessingOptions.ProducingBlock, Arg.Any <IBlockTracer>()).Returns(c => c.Arg <Block>()); }
public CliqueBlockProducer( ITxSource txSource, IBlockchainProcessor blockchainProcessor, IStateProvider stateProvider, IBlockTree blockTree, ITimestamper timestamper, ICryptoRandom cryptoRandom, ISnapshotManager snapshotManager, ISealer cliqueSealer, IGasLimitCalculator gasLimitCalculator, ISpecProvider?specProvider, ICliqueConfig config, ILogManager logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _txSource = txSource ?? throw new ArgumentNullException(nameof(txSource)); _processor = blockchainProcessor ?? throw new ArgumentNullException(nameof(blockchainProcessor)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); _cryptoRandom = cryptoRandom ?? throw new ArgumentNullException(nameof(cryptoRandom)); _sealer = cliqueSealer ?? throw new ArgumentNullException(nameof(cliqueSealer)); _gasLimitCalculator = gasLimitCalculator ?? throw new ArgumentNullException(nameof(gasLimitCalculator)); _specProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); _snapshotManager = snapshotManager ?? throw new ArgumentNullException(nameof(snapshotManager)); _config = config ?? throw new ArgumentNullException(nameof(config)); _wiggle = new WiggleRandomizer(_cryptoRandom, _snapshotManager); _timer.AutoReset = false; _timer.Elapsed += TimerOnElapsed; _timer.Interval = 100; _timer.Start(); }
public AuRaBlockProducer(ITxSource txSource, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, ITimestamper timestamper, IAuRaStepCalculator auRaStepCalculator, IReportingValidator reportingValidator, IAuraConfig config, IGasLimitCalculator gasLimitCalculator, ISpecProvider specProvider, ILogManager logManager) : base( new ValidatedTxSource(txSource, logManager), processor, sealer, blockTree, blockProcessingQueue, stateProvider, timestamper, gasLimitCalculator, specProvider, logManager, "AuRa") { _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _reportingValidator = reportingValidator ?? throw new ArgumentNullException(nameof(reportingValidator)); _config = config ?? throw new ArgumentNullException(nameof(config)); _canProduce = _config.AllowAuRaPrivateChains ? 1 : 0; }
protected BaseLoopBlockProducer( ITxSource txSource, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, IStateProvider stateProvider, ITimestamper timestamper, ILogManager logManager, string name) : base(txSource, processor, sealer, blockTree, blockProcessingQueue, stateProvider, timestamper, logManager) { _name = name; }
public MinedBlockProducer( IPendingTxSelector pendingTxSelector, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, IStateProvider stateProvider, ITimestamper timestamper, ILogManager logManager, IDifficultyCalculator difficultyCalculator) : base(pendingTxSelector, processor, sealer, blockTree, blockProcessingQueue, stateProvider, timestamper, logManager) { _difficultyCalculator = difficultyCalculator ?? throw new ArgumentNullException(nameof(difficultyCalculator)); }
public MinedBlockProducer( IDifficultyCalculator difficultyCalculator, ITxPool txPool, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, ITimestamp timestamp, ILogManager logManager) { _difficultyCalculator = difficultyCalculator ?? throw new ArgumentNullException(nameof(difficultyCalculator)); _txPool = txPool ?? throw new ArgumentNullException(nameof(txPool)); _processor = processor ?? throw new ArgumentNullException(nameof(processor)); _sealer = sealer ?? throw new ArgumentNullException(nameof(sealer)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _timestamp = timestamp; _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); }
public AuRaBlockProducer(IPendingTxSelector pendingTxSelector, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, ITimestamper timestamper, ILogManager logManager, IAuRaStepCalculator auRaStepCalculator, IAuraConfig config, Address nodeAddress) : base(pendingTxSelector, processor, sealer, blockTree, blockProcessingQueue, stateProvider, timestamper, logManager, "AuRa") { _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _config = config ?? throw new ArgumentNullException(nameof(config)); _nodeAddress = nodeAddress ?? throw new ArgumentNullException(nameof(nodeAddress)); }
protected BaseBlockProducer( ITxSource txSource, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, IStateProvider stateProvider, ITimestamper timestamper, ILogManager logManager) { _txSource = txSource ?? throw new ArgumentNullException(nameof(txSource)); Processor = processor ?? throw new ArgumentNullException(nameof(processor)); _sealer = sealer ?? throw new ArgumentNullException(nameof(sealer)); BlockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); BlockProcessingQueue = blockProcessingQueue ?? throw new ArgumentNullException(nameof(blockProcessingQueue)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); Logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); }
public AuRaBlockProducer( ITxSource txSource, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, ITimestamper timestamper, ILogManager logManager, IAuRaStepCalculator auRaStepCalculator, IAuraConfig config, Address nodeAddress, IGasLimitOverride gasLimitOverride = null) : base(txSource, processor, sealer, blockTree, blockProcessingQueue, stateProvider, timestamper, logManager, "AuRa") { _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _config = config ?? throw new ArgumentNullException(nameof(config)); CanProduce = _config.AllowAuRaPrivateChains; _nodeAddress = nodeAddress ?? throw new ArgumentNullException(nameof(nodeAddress)); _gasLimitOverride = gasLimitOverride; }
public AuRaBlockProducer(ITxPool txPool, IBlockchainProcessor blockchainProcessor, IBlockTree blockTree, ITimestamper timestamper, IAuRaStepCalculator auRaStepCalculator, Address nodeAddress, ISealer sealer, IStateProvider stateProvider, IAuraConfig config, ILogManager logManager) { _txPool = txPool ?? throw new ArgumentNullException(nameof(txPool)); _processor = blockchainProcessor ?? throw new ArgumentNullException(nameof(blockchainProcessor)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _nodeAddress = nodeAddress ?? throw new ArgumentNullException(nameof(nodeAddress)); _sealer = sealer ?? throw new ArgumentNullException(nameof(sealer)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _config = config ?? throw new ArgumentNullException(nameof(config)); _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); }
public TestBlockProducer( ITxSource transactionSource, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, ITimestamper timestamper, ILogManager logManager) : base( transactionSource, processor, sealer, blockTree, blockProcessingQueue, stateProvider, timestamper, FollowOtherMiners.Instance, logManager, "test producer") { }
public MinedBlockProducer(ITxSource txSource, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProductionTrigger blockProductionTrigger, IStateProvider stateProvider, IGasLimitCalculator gasLimitCalculator, ITimestamper timestamper, ISpecProvider specProvider, ILogManager logManager) : base( txSource, processor, sealer, blockTree, blockProductionTrigger, stateProvider, gasLimitCalculator, timestamper, specProvider, logManager, new EthashDifficultyCalculator(specProvider)) { }
protected BlockProducerBase( ITxSource?txSource, IBlockchainProcessor?processor, ISealer?sealer, IBlockTree?blockTree, IBlockProcessingQueue?blockProcessingQueue, IStateProvider?stateProvider, IGasLimitCalculator?gasLimitCalculator, ITimestamper?timestamper, ISpecProvider?specProvider, ILogManager?logManager) { _txSource = txSource ?? throw new ArgumentNullException(nameof(txSource)); Processor = processor ?? throw new ArgumentNullException(nameof(processor)); _sealer = sealer ?? throw new ArgumentNullException(nameof(sealer)); BlockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); BlockProcessingQueue = blockProcessingQueue ?? throw new ArgumentNullException(nameof(blockProcessingQueue)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _gasLimitCalculator = gasLimitCalculator ?? throw new ArgumentNullException(nameof(gasLimitCalculator)); _timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); _spec = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); Logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); }
public TestBlockProducer( ITxSource txSource, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProductionTrigger blockProductionTrigger, ITimestamper timestamper, ISpecProvider specProvider, ILogManager logManager) : base( txSource, processor, sealer, blockTree, blockProductionTrigger, stateProvider, new FollowOtherMiners(specProvider), timestamper, specProvider, logManager, ConstantDifficulty.One) { }
protected override ITestBlockProducer CreateTestBlockProducer(TxPoolTxSource txPoolTxSource, BlockchainProcessor chainProcessor, IStateProvider producerStateProvider, ISealer sealer) { return((ITestBlockProducer) new Eth2TestBlockProducerFactory().Create( BlockTree, DbProvider, ReadOnlyTrieStore, new RecoverSignatures(new EthereumEcdsa(SpecProvider.ChainId, LogManager), TxPool, SpecProvider, LogManager), TxPool, new BlockValidator( new TxValidator(SpecProvider.ChainId), new HeaderValidator(BlockTree, new Eth2SealEngine(Signer), SpecProvider, LogManager), Always.Valid, SpecProvider, LogManager), NoBlockRewards.Instance, ReceiptStorage, BlockProcessingQueue, SpecProvider, Signer, new MiningConfig(), LogManager)); }
new protected async Task StartRunners(IConfigProvider configProvider) { InitRlp(); _configProvider = configProvider; _initConfig = _configProvider.GetConfig <IInitConfig>(); _logManager = new NLogManager(_initConfig.LogFileName, _initConfig.LogDirectory); _logger = _logManager.GetClassLogger(); _networkHelper = new NetworkHelper(_logger); SetupKeyStore(); LoadChainSpec(); IDbConfig dbConfig = _configProvider.GetConfig <IDbConfig>(); _dbProvider = new RocksDbProvider(_initConfig.BaseDbPath, dbConfig, _logManager, _initConfig.StoreTraces, _initConfig.StoreReceipts); var stateProvider = new StateProvider( _dbProvider.StateDb, _dbProvider.CodeDb, _logManager); _stateProvider = stateProvider; /* blockchain processing */ if (_chainSpec.ChainId == RopstenSpecProvider.Instance.ChainId) { _specProvider = RopstenSpecProvider.Instance; } else if (_chainSpec.ChainId == MainNetSpecProvider.Instance.ChainId) { _specProvider = MainNetSpecProvider.Instance; } else if (_chainSpec.ChainId == RinkebySpecProvider.Instance.ChainId) { _specProvider = RinkebySpecProvider.Instance; } else if (_chainSpec.ChainId == GoerliSpecProvider.Instance.ChainId) { _specProvider = GoerliSpecProvider.Instance; } else { _specProvider = new SingleReleaseSpecProvider(Latest.Release, _chainSpec.ChainId); } _ethereumEcdsa = new EthereumEcdsa(_specProvider, _logManager); _txPool = new TxPool( new PersistentTransactionStorage(_dbProvider.PendingTxsDb, _specProvider), new PendingTransactionThresholdValidator(_initConfig.ObsoletePendingTransactionInterval, _initConfig.RemovePendingTransactionInterval), new Timestamp(), _ethereumEcdsa, _specProvider, _logManager, _initConfig.RemovePendingTransactionInterval, _initConfig.PeerNotificationThreshold); _receiptStorage = new PersistentReceiptStorage(_dbProvider.ReceiptsDb, _specProvider); _blockTree = new BlockTree( _dbProvider.BlocksDb, _dbProvider.HeadersDb, _dbProvider.BlockInfosDb, _specProvider, _txPool, _logManager); _recoveryStep = new TxSignaturesRecoveryStep(_ethereumEcdsa, _txPool, _logManager); CliqueConfig cliqueConfig = null; _snapshotManager = null; switch (_chainSpec.SealEngineType) { case SealEngineType.None: _sealer = NullSealEngine.Instance; _sealValidator = NullSealEngine.Instance; _rewardCalculator = NoBlockRewards.Instance; break; case SealEngineType.Clique: _rewardCalculator = NoBlockRewards.Instance; cliqueConfig = new CliqueConfig(); cliqueConfig.BlockPeriod = _chainSpec.Clique.Period; cliqueConfig.Epoch = _chainSpec.Clique.Epoch; _snapshotManager = new SnapshotManager(cliqueConfig, _dbProvider.BlocksDb, _blockTree, _ethereumEcdsa, _logManager); _sealValidator = new CliqueSealValidator(cliqueConfig, _snapshotManager, _logManager); _recoveryStep = new CompositeDataRecoveryStep(_recoveryStep, new AuthorRecoveryStep(_snapshotManager)); if (_initConfig.IsMining) { _sealer = new CliqueSealer(new BasicWallet(_nodeKey), cliqueConfig, _snapshotManager, _nodeKey.Address, _logManager); } else { _sealer = NullSealEngine.Instance; } break; case SealEngineType.NethDev: _sealer = NullSealEngine.Instance; _sealValidator = NullSealEngine.Instance; _rewardCalculator = NoBlockRewards.Instance; break; case SealEngineType.Ethash: _rewardCalculator = new RewardCalculator(_specProvider); var difficultyCalculator = new DifficultyCalculator(_specProvider); if (_initConfig.IsMining) { _sealer = new EthashSealer(new Ethash(_logManager), _logManager); } else { _sealer = NullSealEngine.Instance; } _sealValidator = new EthashSealValidator(_logManager, difficultyCalculator, new Ethash(_logManager)); break; default: throw new NotSupportedException($"Seal engine type {_chainSpec.SealEngineType} is not supported in Nethermind"); } _headerValidator = new HeaderValidator( _blockTree, _sealValidator, _specProvider, _logManager); var ommersValidator = new OmmersValidator( _blockTree, _headerValidator, _logManager); var storageProvider = new StorageProvider( _dbProvider.StateDb, stateProvider, _logManager); var txValidator = new TxValidator(_specProvider.ChainId); _blockValidator = new BlockValidator( txValidator, _headerValidator, ommersValidator, _specProvider, _logManager); var blockhashProvider = new BlockhashProvider( _blockTree, _logManager); var virtualMachine = new VirtualMachine( stateProvider, storageProvider, blockhashProvider, _logManager); var transactionProcessor = new TransactionProcessor( _specProvider, stateProvider, storageProvider, virtualMachine, _logManager); _blockProcessor = new BlockProcessor( _specProvider, _blockValidator, _rewardCalculator, transactionProcessor, _dbProvider.StateDb, _dbProvider.CodeDb, _dbProvider.TraceDb, stateProvider, storageProvider, _txPool, _receiptStorage, _configProvider.GetConfig <ISyncConfig>(), _logManager); _blockchainProcessor = new BlockchainProcessor( _blockTree, _blockProcessor, _recoveryStep, _logManager, _initConfig.StoreReceipts, _initConfig.StoreTraces); string chainFile = Path.Join(Path.GetDirectoryName(_initConfig.ChainSpecPath), "chain.rlp"); if (!File.Exists(chainFile)) { _logger.Info($"Chain file does not exist: {chainFile}, skipping"); return; } var chainFileContent = File.ReadAllBytes(chainFile); var context = new Rlp.DecoderContext(chainFileContent); var blocks = new List <Block>(); while (context.ReadNumberOfItemsRemaining() > 0) { context.PeekNextItem(); blocks.Add(Rlp.Decode <Block>(context)); } for (int i = 0; i < blocks.Count; i++) { ProcessBlock(blocks[i]); } }
public SealEngine(ISealer?sealer, ISealValidator?sealValidator) { _sealer = sealer ?? throw new ArgumentNullException(nameof(sealer)); _sealValidator = sealValidator ?? throw new ArgumentNullException(nameof(sealValidator)); }
private async Task InitBlockchain() { /* spec */ if (_chainSpec.ChainId == RopstenSpecProvider.Instance.ChainId) { _specProvider = RopstenSpecProvider.Instance; } else if (_chainSpec.ChainId == MainNetSpecProvider.Instance.ChainId) { _specProvider = MainNetSpecProvider.Instance; } else if (_chainSpec.ChainId == RinkebySpecProvider.Instance.ChainId) { _specProvider = RinkebySpecProvider.Instance; } else if (_chainSpec.ChainId == GoerliSpecProvider.Instance.ChainId) { _specProvider = GoerliSpecProvider.Instance; } else if (_chainSpec.ChainId == SturebySpecProvider.Instance.ChainId) { _specProvider = SturebySpecProvider.Instance; } else { _specProvider = new SingleReleaseSpecProvider(LatestRelease.Instance, _chainSpec.ChainId); } /* sync */ IDbConfig dbConfig = _configProvider.GetConfig <IDbConfig>(); foreach (PropertyInfo propertyInfo in typeof(IDbConfig).GetProperties()) { if (_logger.IsDebug) { _logger.Debug($"DB {propertyInfo.Name}: {propertyInfo.GetValue(dbConfig)}"); } } _dbProvider = HiveEnabled ? (IDbProvider) new MemDbProvider() : new RocksDbProvider(_initConfig.BaseDbPath, dbConfig, _logManager, _initConfig.StoreTraces, _initConfig.StoreReceipts); _ethereumEcdsa = new EthereumEcdsa(_specProvider, _logManager); _transactionPool = new TransactionPool( new PersistentTransactionStorage(_dbProvider.PendingTxsDb, _specProvider), new PendingTransactionThresholdValidator(_initConfig.ObsoletePendingTransactionInterval, _initConfig.RemovePendingTransactionInterval), new Timestamp(), _ethereumEcdsa, _specProvider, _logManager, _initConfig.RemovePendingTransactionInterval, _initConfig.PeerNotificationThreshold); _receiptStorage = new PersistentReceiptStorage(_dbProvider.ReceiptsDb, _specProvider); // IDbProvider debugRecorder = new RocksDbProvider(Path.Combine(_dbBasePath, "debug"), dbConfig); // _dbProvider = new RpcDbProvider(_jsonSerializer, new BasicJsonRpcClient(KnownRpcUris.NethVm1, _jsonSerializer, _logManager), _logManager, debugRecorder); // IDbProvider debugReader = new ReadOnlyDbProvider(new RocksDbProvider(Path.Combine(_dbBasePath, "debug"), dbConfig)); // _dbProvider = debugReader; _blockTree = new BlockTree( _dbProvider.BlocksDb, _dbProvider.BlockInfosDb, _specProvider, _transactionPool, _logManager); _recoveryStep = new TxSignaturesRecoveryStep(_ethereumEcdsa, _transactionPool); CliqueConfig cliqueConfig = null; _snapshotManager = null; switch (_chainSpec.SealEngineType) { case SealEngineType.None: _sealer = NullSealEngine.Instance; _sealValidator = NullSealEngine.Instance; _rewardCalculator = NoBlockRewards.Instance; break; case SealEngineType.Clique: _rewardCalculator = NoBlockRewards.Instance; cliqueConfig = new CliqueConfig(); cliqueConfig.BlockPeriod = _chainSpec.CliquePeriod; cliqueConfig.Epoch = _chainSpec.CliqueEpoch; _snapshotManager = new SnapshotManager(cliqueConfig, _dbProvider.BlocksDb, _blockTree, _ethereumEcdsa, _logManager); _sealValidator = new CliqueSealValidator(cliqueConfig, _snapshotManager, _logManager); _recoveryStep = new CompositeDataRecoveryStep(_recoveryStep, new AuthorRecoveryStep(_snapshotManager)); if (_initConfig.IsMining) { _sealer = new CliqueSealer(new BasicWallet(_nodeKey), cliqueConfig, _snapshotManager, _nodeKey.Address, _logManager); } else { _sealer = NullSealEngine.Instance; } break; case SealEngineType.NethDev: _sealer = NullSealEngine.Instance; _sealValidator = NullSealEngine.Instance; _rewardCalculator = NoBlockRewards.Instance; break; case SealEngineType.Ethash: _rewardCalculator = new RewardCalculator(_specProvider); var difficultyCalculator = new DifficultyCalculator(_specProvider); if (_initConfig.IsMining) { _sealer = new EthashSealer(new Ethash(_logManager), _logManager); } else { _sealer = NullSealEngine.Instance; } _sealValidator = new EthashSealValidator(_logManager, difficultyCalculator, new Ethash(_logManager)); break; default: throw new NotSupportedException($"Seal engine type {_chainSpec.SealEngineType} is not supported in Nethermind"); } /* validation */ var headerValidator = new HeaderValidator( _blockTree, _sealValidator, _specProvider, _logManager); var ommersValidator = new OmmersValidator( _blockTree, headerValidator, _logManager); var txValidator = new TransactionValidator( new SignatureValidator(_specProvider.ChainId)); _blockValidator = new BlockValidator( txValidator, headerValidator, ommersValidator, _specProvider, _logManager); var stateTree = new StateTree(_dbProvider.StateDb); var stateProvider = new StateProvider( stateTree, _dbProvider.CodeDb, _logManager); _stateProvider = stateProvider; var storageProvider = new StorageProvider( _dbProvider.StateDb, stateProvider, _logManager); _transactionPoolInfoProvider = new TransactionPoolInfoProvider(stateProvider); /* blockchain processing */ var blockhashProvider = new BlockhashProvider( _blockTree); var virtualMachine = new VirtualMachine( stateProvider, storageProvider, blockhashProvider, _logManager); var transactionProcessor = new TransactionProcessor( _specProvider, stateProvider, storageProvider, virtualMachine, _logManager); _blockProcessor = new BlockProcessor( _specProvider, _blockValidator, _rewardCalculator, transactionProcessor, _dbProvider.StateDb, _dbProvider.CodeDb, _dbProvider.TraceDb, stateProvider, storageProvider, _transactionPool, _receiptStorage, _logManager); _blockchainProcessor = new BlockchainProcessor( _blockTree, _blockProcessor, _recoveryStep, _logManager, _initConfig.StoreReceipts, _initConfig.StoreTraces); // create shared objects between discovery and peer manager IStatsConfig statsConfig = _configProvider.GetConfig <IStatsConfig>(); _nodeStatsManager = new NodeStatsManager(statsConfig, _logManager, !statsConfig.CaptureNodeStatsEventHistory); if (_initConfig.IsMining) { IReadOnlyDbProvider minerDbProvider = new ReadOnlyDbProvider(_dbProvider, false); AlternativeChain producerChain = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, minerDbProvider, _recoveryStep, _logManager, _transactionPool, _receiptStorage); switch (_chainSpec.SealEngineType) { case SealEngineType.Clique: { // TODO: need to introduce snapshot provider for clique and pass it here instead of CliqueSealEngine if (_logger.IsWarn) { _logger.Warn("Starting Clique block producer & sealer"); } _blockProducer = new CliqueBlockProducer(_transactionPool, producerChain.Processor, _blockTree, _timestamp, _cryptoRandom, producerChain.StateProvider, _snapshotManager, (CliqueSealer)_sealer, _nodeKey.Address, cliqueConfig, _logManager); break; } case SealEngineType.NethDev: { if (_logger.IsWarn) { _logger.Warn("Starting Dev block producer & sealer"); } _blockProducer = new DevBlockProducer(_transactionPool, producerChain.Processor, _blockTree, _timestamp, _logManager); break; } default: throw new NotSupportedException($"Mining in {_chainSpec.SealEngineType} mode is not supported"); } _blockProducer.Start(); } if (!HiveEnabled) { _blockchainProcessor.Start(); LoadGenesisBlock(_chainSpec, string.IsNullOrWhiteSpace(_initConfig.GenesisHash) ? null : new Keccak(_initConfig.GenesisHash), _blockTree, stateProvider, _specProvider); if (_initConfig.ProcessingEnabled) { #pragma warning disable 4014 LoadBlocksFromDb(); #pragma warning restore 4014 } else { if (_logger.IsWarn) { _logger.Warn($"Shutting down processor due to {nameof(InitConfig)}.{nameof(InitConfig.ProcessingEnabled)} set to false"); } await _blockchainProcessor.StopAsync(); } } await InitializeNetwork( _receiptStorage, _sealValidator, txValidator); }
public TestAuraProducer(ITxSource transactionSource, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, ITimestamper timestamper, ILogManager logManager, IAuRaStepCalculator auRaStepCalculator, IAuraConfig config, Address nodeAddress) : base(transactionSource, processor, stateProvider, sealer, blockTree, blockProcessingQueue, timestamper, logManager, auRaStepCalculator, config, nodeAddress) { }
private async Task InitBlockchain() { _specProvider = new ChainSpecBasedSpecProvider(_chainSpec); Account.AccountStartNonce = _chainSpec.Parameters.AccountStartNonce; /* sync */ IDbConfig dbConfig = _configProvider.GetConfig <IDbConfig>(); _syncConfig = _configProvider.GetConfig <ISyncConfig>(); foreach (PropertyInfo propertyInfo in typeof(IDbConfig).GetProperties()) { if (_logger.IsDebug) { _logger.Debug($"DB {propertyInfo.Name}: {propertyInfo.GetValue(dbConfig)}"); } } _dbProvider = HiveEnabled ? (IDbProvider) new MemDbProvider() : new RocksDbProvider(_initConfig.BaseDbPath, dbConfig, _logManager, _initConfig.StoreTraces, _initConfig.StoreReceipts || _syncConfig.DownloadReceiptsInFastSync); _ethereumEcdsa = new EthereumEcdsa(_specProvider, _logManager); _txPool = new TxPool( new PersistentTxStorage(_dbProvider.PendingTxsDb, _specProvider), Timestamp.Default, _ethereumEcdsa, _specProvider, _txPoolConfig, _logManager); var _rc7FixDb = _initConfig.EnableRc7Fix ? _dbProvider.HeadersDb : NullDb.Instance; _receiptStorage = new PersistentReceiptStorage(_dbProvider.ReceiptsDb, _rc7FixDb, _specProvider, _logManager); // IDbProvider debugRecorder = new RocksDbProvider(Path.Combine(_dbBasePath, "debug"), dbConfig); // _dbProvider = new RpcDbProvider(_jsonSerializer, new BasicJsonRpcClient(KnownRpcUris.NethVm1, _jsonSerializer, _logManager), _logManager, debugRecorder); // IDbProvider debugReader = new ReadOnlyDbProvider(new RocksDbProvider(Path.Combine(_dbBasePath, "debug"), dbConfig)); // _dbProvider = debugReader; _blockTree = new BlockTree( _dbProvider.BlocksDb, _dbProvider.HeadersDb, _dbProvider.BlockInfosDb, _specProvider, _txPool, _syncConfig, _logManager); _recoveryStep = new TxSignaturesRecoveryStep(_ethereumEcdsa, _txPool, _logManager); CliqueConfig cliqueConfig = null; _snapshotManager = null; switch (_chainSpec.SealEngineType) { case SealEngineType.None: _sealer = NullSealEngine.Instance; _sealValidator = NullSealEngine.Instance; _rewardCalculator = NoBlockRewards.Instance; break; case SealEngineType.Clique: _rewardCalculator = NoBlockRewards.Instance; cliqueConfig = new CliqueConfig(); cliqueConfig.BlockPeriod = _chainSpec.Clique.Period; cliqueConfig.Epoch = _chainSpec.Clique.Epoch; _snapshotManager = new SnapshotManager(cliqueConfig, _dbProvider.BlocksDb, _blockTree, _ethereumEcdsa, _logManager); _sealValidator = new CliqueSealValidator(cliqueConfig, _snapshotManager, _logManager); _recoveryStep = new CompositeDataRecoveryStep(_recoveryStep, new AuthorRecoveryStep(_snapshotManager)); if (_initConfig.IsMining) { _sealer = new CliqueSealer(new BasicWallet(_nodeKey), cliqueConfig, _snapshotManager, _nodeKey.Address, _logManager); } else { _sealer = NullSealEngine.Instance; } break; case SealEngineType.NethDev: _sealer = NullSealEngine.Instance; _sealValidator = NullSealEngine.Instance; _rewardCalculator = NoBlockRewards.Instance; break; case SealEngineType.Ethash: _rewardCalculator = new RewardCalculator(_specProvider); var difficultyCalculator = new DifficultyCalculator(_specProvider); if (_initConfig.IsMining) { _sealer = new EthashSealer(new Ethash(_logManager), _logManager); } else { _sealer = NullSealEngine.Instance; } _sealValidator = new EthashSealValidator(_logManager, difficultyCalculator, new Ethash(_logManager)); break; default: throw new NotSupportedException($"Seal engine type {_chainSpec.SealEngineType} is not supported in Nethermind"); } /* validation */ _headerValidator = new HeaderValidator( _blockTree, _sealValidator, _specProvider, _logManager); var ommersValidator = new OmmersValidator( _blockTree, _headerValidator, _logManager); var txValidator = new TxValidator(_specProvider.ChainId); _blockValidator = new BlockValidator( txValidator, _headerValidator, ommersValidator, _specProvider, _logManager); var stateProvider = new StateProvider( _dbProvider.StateDb, _dbProvider.CodeDb, _logManager); _stateProvider = stateProvider; var storageProvider = new StorageProvider( _dbProvider.StateDb, stateProvider, _logManager); _txPoolInfoProvider = new TxPoolInfoProvider(stateProvider); _transactionPoolInfoProvider = new TxPoolInfoProvider(stateProvider); /* blockchain processing */ var blockhashProvider = new BlockhashProvider( _blockTree, _logManager); var virtualMachine = new VirtualMachine( stateProvider, storageProvider, blockhashProvider, _logManager); var transactionProcessor = new TransactionProcessor( _specProvider, stateProvider, storageProvider, virtualMachine, _logManager); _blockProcessor = new BlockProcessor( _specProvider, _blockValidator, _rewardCalculator, transactionProcessor, _dbProvider.StateDb, _dbProvider.CodeDb, _dbProvider.TraceDb, stateProvider, storageProvider, _txPool, _receiptStorage, _logManager); _blockchainProcessor = new BlockchainProcessor( _blockTree, _blockProcessor, _recoveryStep, _logManager, _initConfig.StoreReceipts, _initConfig.StoreTraces); // create shared objects between discovery and peer manager IStatsConfig statsConfig = _configProvider.GetConfig <IStatsConfig>(); _nodeStatsManager = new NodeStatsManager(statsConfig, _logManager); if (_initConfig.IsMining) { IReadOnlyDbProvider minerDbProvider = new ReadOnlyDbProvider(_dbProvider, false); AlternativeChain producerChain = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, minerDbProvider, _recoveryStep, _logManager, _txPool, _receiptStorage); switch (_chainSpec.SealEngineType) { case SealEngineType.Clique: { if (_logger.IsWarn) { _logger.Warn("Starting Clique block producer & sealer"); } _blockProducer = new CliqueBlockProducer(_txPool, producerChain.Processor, _blockTree, _timestamp, _cryptoRandom, producerChain.StateProvider, _snapshotManager, (CliqueSealer)_sealer, _nodeKey.Address, cliqueConfig, _logManager); break; } case SealEngineType.NethDev: { if (_logger.IsWarn) { _logger.Warn("Starting Dev block producer & sealer"); } _blockProducer = new DevBlockProducer(_txPool, producerChain.Processor, _blockTree, _timestamp, _logManager); break; } default: throw new NotSupportedException($"Mining in {_chainSpec.SealEngineType} mode is not supported"); } _blockProducer.Start(); } _blockchainProcessor.Start(); LoadGenesisBlock(_chainSpec, string.IsNullOrWhiteSpace(_initConfig.GenesisHash) ? null : new Keccak(_initConfig.GenesisHash), _blockTree, stateProvider, _specProvider); if (_initConfig.ProcessingEnabled) { #pragma warning disable 4014 LoadBlocksFromDb(); #pragma warning restore 4014 } else { if (_logger.IsWarn) { _logger.Warn($"Shutting down the blockchain processor due to {nameof(InitConfig)}.{nameof(InitConfig.ProcessingEnabled)} set to false"); } await _blockchainProcessor.StopAsync(); } if (HiveEnabled) { await InitHive(); } if (HiveEnabled) { await InitHive(); } var producers = new List <IProducer>(); if (_initConfig.PubSubEnabled) { var kafkaProducer = await PrepareKafkaProducer(_blockTree, _configProvider.GetConfig <IKafkaConfig>()); producers.Add(kafkaProducer); } var grpcClientConfig = _configProvider.GetConfig <IGrpcClientConfig>(); if (grpcClientConfig.Enabled) { var grpcProducer = new GrpcProducer(_grpcClient, _logManager); producers.Add(grpcProducer); } ISubscription subscription; if (producers.Any()) { subscription = new Subscription(producers, _blockProcessor, _logManager); } else { subscription = new EmptySubscription(); } _disposeStack.Push(subscription); _dataBridge = new DataBridge(subscription, _receiptStorage, _blockTree, _logManager); _dataBridge.Start(); await InitializeNetwork(); }
protected override IBlockProducer CreateTestBlockProducer(TxPoolTxSource txPoolTxSource, ISealer sealer, ITransactionComparerProvider transactionComparerProvider) { MiningConfig miningConfig = new() { MinGasPrice = UInt256.One }; BlockProducerEnvFactory blockProducerEnvFactory = new BlockProducerEnvFactory( DbProvider, BlockTree, ReadOnlyTrieStore, SpecProvider, BlockValidator, NoBlockRewards.Instance, ReceiptStorage, BlockPreprocessorStep, TxPool, transactionComparerProvider, miningConfig, LogManager) { TransactionsExecutorFactory = new AABlockProducerTransactionsExecutorFactory( SpecProvider, LogManager, Signer, EntryPointAddresses) }; UserOperationTxSource = new(UserOperationTxBuilder, UserOperationPool, UserOperationSimulator, SpecProvider, State, Signer, LogManager.GetClassLogger()); Eth2TestBlockProducerFactory producerFactory = new Eth2TestBlockProducerFactory(GasLimitCalculator, UserOperationTxSource); Eth2BlockProducer blockProducer = producerFactory.Create( blockProducerEnvFactory, BlockTree, BlockProductionTrigger, SpecProvider, new Eth2Signer(MinerAddress), Timestamper, miningConfig, LogManager); return(blockProducer); }
protected override IBlockProducer CreateTestBlockProducer(TxPoolTxSource txPoolTxSource, ISealer sealer, ITransactionComparerProvider transactionComparerProvider) { SealEngine = new MergeSealEngine(SealEngine, PoSSwitcher, SealValidator, LogManager); MiningConfig miningConfig = new() { Enabled = true, MinGasPrice = 0 }; TargetAdjustedGasLimitCalculator targetAdjustedGasLimitCalculator = new(SpecProvider, miningConfig); EthSyncingInfo = new EthSyncingInfo(BlockTree); PostMergeBlockProducerFactory blockProducerFactory = new( SpecProvider, SealEngine, Timestamper, miningConfig, LogManager, targetAdjustedGasLimitCalculator); BlockProducerEnvFactory blockProducerEnvFactory = new( DbProvider, BlockTree, ReadOnlyTrieStore, SpecProvider, BlockValidator, NoBlockRewards.Instance, ReceiptStorage, BlockPreprocessorStep, TxPool, transactionComparerProvider, miningConfig, LogManager); BlockProducerEnv blockProducerEnv = blockProducerEnvFactory.Create(); PostMergeBlockProducer postMergeBlockProducer = blockProducerFactory.Create(blockProducerEnv, BlockProductionTrigger); PostMergeBlockProducer = postMergeBlockProducer; PayloadPreparationService ??= new PayloadPreparationService( postMergeBlockProducer, new BlockImprovementContextFactory(BlockProductionTrigger, TimeSpan.FromSeconds(MergeConfig.SecondsPerSlot) ), TimerFactory.Default, LogManager, TimeSpan.FromSeconds(MergeConfig.SecondsPerSlot) ); IAuRaStepCalculator auraStepCalculator = Substitute.For <IAuRaStepCalculator>(); auraStepCalculator.TimeToNextStep.Returns(TimeSpan.FromMilliseconds(0)); FollowOtherMiners gasLimitCalculator = new(MainnetSpecProvider.Instance); AuRaBlockProducer preMergeBlockProducer = new( txPoolTxSource, blockProducerEnvFactory.Create().ChainProcessor, ((TestBlockchain)this).BlockProductionTrigger, State, sealer, BlockTree, Timestamper, auraStepCalculator, NullReportingValidator.Instance, new AuRaConfig(), gasLimitCalculator, SpecProvider, LogManager ); return(new MergeBlockProducer(preMergeBlockProducer, postMergeBlockProducer, PoSSwitcher)); } }
protected override IBlockProducer CreateTestBlockProducer(TxPoolTxSource txPoolTxSource, ISealer sealer, ITransactionComparerProvider transactionComparerProvider) { MiningConfig miningConfig = new() { MinGasPrice = UInt256.One }; SpecProvider.UpdateMergeTransitionInfo(1, 0); BlockProducerEnvFactory blockProducerEnvFactory = new( DbProvider, BlockTree, ReadOnlyTrieStore, SpecProvider, BlockValidator, NoBlockRewards.Instance, ReceiptStorage, BlockPreprocessorStep, TxPool, transactionComparerProvider, miningConfig, LogManager) { TransactionsExecutorFactory = new MevBlockProducerTransactionsExecutorFactory(SpecProvider, LogManager) }; PostMergeBlockProducer CreatePostMergeBlockProducer(IBlockProductionTrigger blockProductionTrigger, ITxSource?txSource = null) { BlockProducerEnv blockProducerEnv = blockProducerEnvFactory.Create(txSource); return(new PostMergeBlockProducerFactory(SpecProvider, SealEngine, Timestamper, miningConfig, LogManager).Create( blockProducerEnv, blockProductionTrigger, txSource)); } MevBlockProducer.MevBlockProducerInfo CreateProducer(int bundleLimit = 0, ITxSource?additionalTxSource = null) { // TODO: this could be simplified a lot of the parent was not retrieved, not sure why do we need the parent here bool BundleLimitTriggerCondition(BlockProductionEventArgs e) { // TODO: why do we need this parent? later we use only the current block number BlockHeader?parent = BlockTree.GetProducedBlockParent(e.ParentHeader); if (parent is not null) { // ToDo resolved conflict parent.Timestamp? IEnumerable <MevBundle> bundles = BundlePool.GetBundles(parent.Number + 1, parent.Timestamp); return(bundles.Count() >= bundleLimit); } return(false); } IManualBlockProductionTrigger manualTrigger = new BuildBlocksWhenRequested(); IBlockProductionTrigger trigger = manualTrigger; if (bundleLimit != 0) { trigger = new TriggerWithCondition(manualTrigger, BundleLimitTriggerCondition); } IBlockProducer producer = CreatePostMergeBlockProducer(trigger, additionalTxSource); return(new MevBlockProducer.MevBlockProducerInfo(producer, manualTrigger, new BeneficiaryTracer())); } int megabundleProducerCount = _relayAddresses.Any() ? 1 : 0; List <MevBlockProducer.MevBlockProducerInfo> blockProducers = new(_maxMergedBundles + megabundleProducerCount + 1); // Add non-mev block MevBlockProducer.MevBlockProducerInfo standardProducer = CreateProducer(); blockProducers.Add(standardProducer); // Try blocks with all bundle numbers <= maxMergedBundles for (int bundleLimit = 1; bundleLimit <= _maxMergedBundles; bundleLimit++) { BundleSelector bundleSelector = new(BundlePool, bundleLimit); BundleTxSource bundleTxSource = new(bundleSelector, Timestamper); MevBlockProducer.MevBlockProducerInfo bundleProducer = CreateProducer(bundleLimit, bundleTxSource); blockProducers.Add(bundleProducer); } if (megabundleProducerCount > 0) { MegabundleSelector megabundleSelector = new(BundlePool); BundleTxSource megabundleTxSource = new(megabundleSelector, Timestamper); MevBlockProducer.MevBlockProducerInfo bundleProducer = CreateProducer(0, megabundleTxSource); blockProducers.Add(bundleProducer); } MevBlockProducer blockProducer = new MevBlockProducer(BlockProductionTrigger, LogManager, blockProducers.ToArray()); blockProducer.BlockProduced += OnBlockProduced; return(blockProducer); }
protected virtual ITestBlockProducer CreateTestBlockProducer(TxPoolTxSource txPoolTxSource, BlockchainProcessor chainProcessor, IStateProvider producerStateProvider, ISealer sealer) { return(new TestBlockProducer(txPoolTxSource, chainProcessor, producerStateProvider, sealer, BlockTree, chainProcessor, Timestamper, SpecProvider, LogManager)); }