Example #1
0
        private IGasLimitOverride?GetGasLimitOverride()
        {
            if (_context.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_context.ChainSpec));
            }
            var blockGasLimitContractTransitions = _context.ChainSpec.AuRa.BlockGasLimitContractTransitions;

            if (blockGasLimitContractTransitions?.Any() == true)
            {
                _context.GasLimitOverrideCache = new IGasLimitOverride.Cache();

                var gasLimitOverride = new AuRaContractGasLimitOverride(
                    blockGasLimitContractTransitions.Select(blockGasLimitContractTransition =>
                                                            new BlockGasLimitContract(
                                                                _context.AbiEncoder,
                                                                blockGasLimitContractTransition.Value,
                                                                blockGasLimitContractTransition.Key,
                                                                GetReadOnlyTransactionProcessorSource()))
                    .ToArray <IBlockGasLimitContract>(),
                    _context.GasLimitOverrideCache,
                    _context.Config <IAuraConfig>().Minimum2MlnGasPerBlockWhenUsingBlockGasLimitContract,
                    _context.LogManager);

                return(gasLimitOverride);
            }

            return(null);
        }
Example #2
0
        protected override void BuildProducer()
        {
            if (_context.NodeKey == null)
            {
                throw new StepDependencyException(nameof(_context.NodeKey));
            }
            if (_context.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_context.ChainSpec));
            }

            ILogger logger = _context.LogManager.GetClassLogger();

            if (logger.IsWarn)
            {
                logger.Warn("Starting AuRa block producer & sealer");
            }

            IAuRaStepCalculator  stepCalculator  = new AuRaStepCalculator(_context.ChainSpec.AuRa.StepDuration, _context.Timestamper);
            BlockProducerContext producerContext = GetProducerChain();
            var auraConfig = _context.Config <IAuraConfig>();

            _context.BlockProducer = new AuRaBlockProducer(
                producerContext.PendingTxSelector,
                producerContext.ChainProcessor,
                producerContext.ReadOnlyStateProvider,
                _context.Sealer,
                _context.BlockTree,
                _context.BlockProcessingQueue,
                _context.Timestamper,
                _context.LogManager,
                stepCalculator,
                auraConfig,
                _context.NodeKey.Address);
        }
        protected override void BuildProducer()
        {
            if (_context.Signer == null)
            {
                throw new StepDependencyException(nameof(_context.Signer));
            }
            if (_context.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_context.ChainSpec));
            }

            _auraConfig = _context.Config <IAuraConfig>();
            ILogger logger = _context.LogManager.GetClassLogger();

            if (logger.IsWarn)
            {
                logger.Warn("Starting AuRa block producer & sealer");
            }

            IAuRaStepCalculator  stepCalculator  = new AuRaStepCalculator(_context.ChainSpec.AuRa.StepDuration, _context.Timestamper, _context.LogManager);
            BlockProducerContext producerContext = GetProducerChain();

            _context.BlockProducer = new AuRaBlockProducer(
                producerContext.TxSource,
                producerContext.ChainProcessor,
                producerContext.ReadOnlyStateProvider,
                _context.Sealer,
                _context.BlockTree,
                _context.BlockProcessingQueue,
                _context.Timestamper,
                _context.LogManager,
                stepCalculator,
                _context.ReportingValidator,
                _auraConfig,
                GetGasLimitOverride(producerContext.ReadOnlyTxProcessingEnv, producerContext.ReadOnlyTransactionProcessorSource));
        }