protected override ITxSource CreateTxSourceForProducer(ReadOnlyTxProcessingEnv readOnlyTxProcessingEnv, ReadOnlyTransactionProcessorSource readOnlyTransactionProcessorSource)
        {
            bool CheckAddPosdaoTransactions(IList <ITxSource> list, long auRaPosdaoTransition)
            {
                if (auRaPosdaoTransition < AuRaParameters.TransitionDisabled && _validator is ITxSource validatorSource)
                {
                    list.Insert(0, validatorSource);
                    return(true);
                }

                return(false);
            }

            bool CheckAddRandomnessTransactions(IList <ITxSource> list, IDictionary <long, Address> randomnessContractAddress, ISigner signer)
            {
                IList <IRandomContract> GetRandomContracts(
                    IDictionary <long, Address> randomnessContractAddressPerBlock,
                    IAbiEncoder abiEncoder,
                    IReadOnlyTransactionProcessorSource txProcessorSource,
                    ISigner signer) =>
                randomnessContractAddressPerBlock
                .Select(kvp => new RandomContract(
                            abiEncoder,
                            kvp.Value,
                            txProcessorSource,
                            kvp.Key,
                            signer))
                .ToArray <IRandomContract>();

                if (randomnessContractAddress?.Any() == true)
                {
                    var randomContractTxSource = new RandomContractTxSource(
                        GetRandomContracts(randomnessContractAddress, _context.AbiEncoder,
                                           readOnlyTransactionProcessorSource,
                                           signer),
                        new EciesCipher(_context.CryptoRandom),
                        _context.NodeKey,
                        _context.CryptoRandom);

                    list.Insert(0, randomContractTxSource);
                    return(true);
                }

                return(false);
            }

            if (_context.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_context.ChainSpec));
            }
            if (_context.BlockTree == null)
            {
                throw new StepDependencyException(nameof(_context.BlockTree));
            }
            if (_context.Signer == null)
            {
                throw new StepDependencyException(nameof(_context.Signer));
            }

            IList <ITxSource> txSources = new List <ITxSource> {
                base.CreateTxSourceForProducer(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource)
            };
            bool needSigner = false;

            needSigner |= CheckAddPosdaoTransactions(txSources, _context.ChainSpec.AuRa.PosdaoTransition);
            needSigner |= CheckAddRandomnessTransactions(txSources, _context.ChainSpec.AuRa.RandomnessContractAddress, _context.Signer);

            ITxSource txSource = txSources.Count > 1 ? new CompositeTxSource(txSources.ToArray()) : txSources[0];

            if (needSigner)
            {
                TxSealer transactionSealer = new TxSealer(_context.Signer, _context.Timestamper);
                txSource = new GeneratedTxSourceSealer(txSource, transactionSealer, readOnlyTxProcessingEnv.StateReader);
            }

            var txPermissionFilter = GetTxPermissionFilter(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource);

            if (txPermissionFilter != null)
            {
                txSource = new TxFilterTxSource(txSource, txPermissionFilter);
            }

            return(txSource);
        }
        protected override ITxSource CreateTxSourceForProducer(ReadOnlyTxProcessingEnv readOnlyTxProcessingEnv, ReadOnlyTransactionProcessorSource readOnlyTransactionProcessorSource)
        {
            IList <RandomContract> GetRandomContracts(
                IDictionary <long, Address> randomnessContractAddress,
                ITransactionProcessor transactionProcessor,
                IAbiEncoder abiEncoder,
                IReadOnlyTransactionProcessorSource txProcessorSource,
                Address nodeAddress) =>
            randomnessContractAddress
            .Select(kvp => new RandomContract(transactionProcessor,
                                              abiEncoder,
                                              kvp.Value,
                                              txProcessorSource,
                                              kvp.Key,
                                              nodeAddress))
            .ToArray();


            if (_context.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_context.ChainSpec));
            }
            if (_context.BlockTree == null)
            {
                throw new StepDependencyException(nameof(_context.BlockTree));
            }
            if (_context.NodeKey == null)
            {
                throw new StepDependencyException(nameof(_context.NodeKey));
            }

            IList <ITxSource> txSources = new List <ITxSource> {
                base.CreateTxSourceForProducer(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource)
            };
            bool needSigner = false;

            if (_context.ChainSpec.AuRa.RandomnessContractAddress?.Any() == true)
            {
                var randomContractTxSource = new RandomContractTxSource(
                    GetRandomContracts(_context.ChainSpec.AuRa.RandomnessContractAddress,
                                       readOnlyTxProcessingEnv.TransactionProcessor, _context.AbiEncoder,
                                       readOnlyTransactionProcessorSource,
                                       _context.NodeKey.Address),
                    new EciesCipher(_context.CryptoRandom),
                    _context.NodeKey,
                    _context.CryptoRandom);

                txSources.Insert(0, randomContractTxSource);
                needSigner = true;
            }

            ITxSource txSource = txSources.Count > 1 ? new CompositeTxSource(txSources.ToArray()) : txSources[0];

            if (needSigner)
            {
                txSource = new GeneratedTxSourceApprover(txSource, new BasicWallet(_context.NodeKey), _context.Timestamper, readOnlyTxProcessingEnv.StateReader, _context.BlockTree.ChainId);
            }

            var txPermissionFilter = GetTxPermissionFilter(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource);

            if (txPermissionFilter != null)
            {
                txSource = new TxFilterTxSource(txSource, txPermissionFilter);
            }

            return(txSource);
        }