예제 #1
0
 public MempoolValidator(
     ITxMempool memPool,
     MempoolSchedulerLock mempoolLock,
     IDateTimeProvider dateTimeProvider,
     MempoolSettings mempoolSettings,
     ChainIndexer chainIndexer,
     ICoinView coinView,
     ILoggerFactory loggerFactory,
     NodeSettings nodeSettings,
     IConsensusRuleEngine consensusRules,
     IEnumerable <IMempoolRule> mempoolRules,
     NodeDeployments nodeDeployments)
 {
     this.memPool            = memPool;
     this.mempoolLock        = mempoolLock;
     this.dateTimeProvider   = dateTimeProvider;
     this.mempoolSettings    = mempoolSettings;
     this.chainIndexer       = chainIndexer;
     this.network            = chainIndexer.Network;
     this.coinView           = coinView;
     this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
     this.PerformanceCounter = new MempoolPerformanceCounter(this.dateTimeProvider);
     this.minRelayTxFee      = nodeSettings.MinRelayTxFeeRate;
     this.consensusRules     = consensusRules;
     this.nodeDeployments    = nodeDeployments;
     this.mempoolRules       = mempoolRules.ToList();
 }
예제 #2
0
        public PartialValidator(IConsensusRuleEngine consensusRules, ILoggerFactory loggerFactory)
        {
            this.consensusRules = consensusRules;
            this.logger         = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");

            this.asyncQueue = new AsyncQueue <PartialValidationItem>(this.OnEnqueueAsync);
        }
예제 #3
0
        public BaseFeature(NodeSettings nodeSettings,
                           DataFolder dataFolder,
                           INodeLifetime nodeLifetime,
                           ChainIndexer chainIndexer,
                           IChainState chainState,
                           IConnectionManager connectionManager,
                           IChainRepository chainRepository,
                           IFinalizedBlockInfoRepository finalizedBlockInfo,
                           IDateTimeProvider dateTimeProvider,
                           IAsyncProvider asyncProvider,
                           ITimeSyncBehaviorState timeSyncBehaviorState,
                           ILoggerFactory loggerFactory,
                           IInitialBlockDownloadState initialBlockDownloadState,
                           IPeerBanning peerBanning,
                           IPeerAddressManager peerAddressManager,
                           IConsensusManager consensusManager,
                           IConsensusRuleEngine consensusRules,
                           IPartialValidator partialValidator,
                           IBlockPuller blockPuller,
                           IBlockStore blockStore,
                           Network network,
                           ITipsManager tipsManager,
                           NodeDeployments nodeDeployments,
                           IKeyValueRepository keyValueRepo,
                           INodeStats nodeStats,
                           IBroadcasterManager broadcasterManager,
                           IProvenBlockHeaderStore provenBlockHeaderStore = null)
        {
            this.chainState      = Guard.NotNull(chainState, nameof(chainState));
            this.chainRepository = Guard.NotNull(chainRepository, nameof(chainRepository));
            this.finalizedBlockInfoRepository = Guard.NotNull(finalizedBlockInfo, nameof(finalizedBlockInfo));
            this.nodeSettings           = Guard.NotNull(nodeSettings, nameof(nodeSettings));
            this.dataFolder             = Guard.NotNull(dataFolder, nameof(dataFolder));
            this.nodeLifetime           = Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            this.chainIndexer           = Guard.NotNull(chainIndexer, nameof(chainIndexer));
            this.connectionManager      = Guard.NotNull(connectionManager, nameof(connectionManager));
            this.consensusManager       = consensusManager;
            this.consensusRules         = consensusRules;
            this.blockPuller            = blockPuller;
            this.blockStore             = blockStore;
            this.network                = network;
            this.nodeStats              = nodeStats;
            this.broadcasterManager     = broadcasterManager;
            this.provenBlockHeaderStore = provenBlockHeaderStore;
            this.partialValidator       = partialValidator;
            this.peerBanning            = Guard.NotNull(peerBanning, nameof(peerBanning));
            this.tipsManager            = Guard.NotNull(tipsManager, nameof(tipsManager));
            this.keyValueRepo           = Guard.NotNull(keyValueRepo, nameof(keyValueRepo));
            this.nodeDeployments        = nodeDeployments;

            this.peerAddressManager = Guard.NotNull(peerAddressManager, nameof(peerAddressManager));
            this.peerAddressManager.PeerFilePath = this.dataFolder;

            this.initialBlockDownloadState = initialBlockDownloadState;
            this.dateTimeProvider          = dateTimeProvider;
            this.asyncProvider             = asyncProvider;
            this.timeSyncBehaviorState     = timeSyncBehaviorState;
            this.loggerFactory             = loggerFactory;
            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
        }
        public PartialValidator(IConsensusRuleEngine consensusRules, ILoggerFactory loggerFactory)
        {
            this.consensusRules = consensusRules;
            this.logger         = loggerFactory.CreateLogger(this.GetType().FullName);

            this.asyncQueue = new AsyncQueue <PartialValidationItem>(this.OnEnqueueAsync);
        }
예제 #5
0
        public ConsensusStats(
            ICoinView coinView,
            IConsensusManager consensusManager,
            IConsensusRuleEngine consensusRules,
            IInitialBlockDownloadState initialBlockDownloadState,
            ConcurrentChain chain,
            IConnectionManager connectionManager,
            IDateTimeProvider dateTimeProvider,
            IBlockPuller blockPuller,
            ILoggerFactory loggerFactory,
            INodeLifetime nodeLifetime)
        {
            var stack = new CoinViewStack(coinView);

            this.cache   = stack.Find <CachedCoinView>();
            this.dbreeze = stack.Find <DBreezeCoinView>();
            this.bottom  = stack.Bottom;

            this.consensusManager = consensusManager;
            this.consensusRules   = consensusRules;

            this.lastSnapshot              = consensusRules.PerformanceCounter.Snapshot();
            this.lastSnapshot2             = this.dbreeze?.PerformanceCounter.Snapshot();
            this.lastSnapshot3             = this.cache?.PerformanceCounter.Snapshot();
            this.initialBlockDownloadState = initialBlockDownloadState;
            this.chain             = chain;
            this.connectionManager = connectionManager;
            this.dateTimeProvider  = dateTimeProvider;
            this.blockPuller       = blockPuller;
            this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
            this.nodeLifetime      = nodeLifetime;
        }
 public X1RequireWitnessMempoolRule(Network network,
                                    ITxMempool mempool,
                                    MempoolSettings mempoolSettings,
                                    ChainIndexer chainIndexer,
                                    IConsensusRuleEngine consensusRules,
                                    ILoggerFactory loggerFactory) : base(network, mempool, mempoolSettings, chainIndexer, loggerFactory)
 {
 }
예제 #7
0
        public PartialValidator(IAsyncProvider asyncProvider, IConsensusRuleEngine consensusRules, ILoggerFactory loggerFactory)
        {
            this.asyncProvider  = Guard.NotNull(asyncProvider, nameof(asyncProvider));
            this.consensusRules = consensusRules;
            this.logger         = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");

            this.asyncQueue = asyncProvider.CreateAndRunAsyncDelegateDequeuer <PartialValidationItem>(this.GetType().Name, this.OnEnqueueAsync);
        }
 public X1EmptyScriptSigMempoolRule(Network network,
                                    ITxMempool mempool,
                                    MempoolSettings mempoolSettings,
                                    ChainIndexer chainIndexer,
                                    IConsensusRuleEngine consensusRules,
                                    ILoggerFactory loggerFactory) : base(network, mempool, mempoolSettings, chainIndexer, loggerFactory)
 {
 }
 public XdsOutputNotWhitelistedMempoolRule(Network network,
                                           ITxMempool mempool,
                                           MempoolSettings mempoolSettings,
                                           ChainIndexer chainIndexer,
                                           IConsensusRuleEngine consensusRules,
                                           ILoggerFactory loggerFactory) : base(network, mempool, mempoolSettings, chainIndexer, loggerFactory)
 {
 }
 public CreateMempoolEntryMempoolRule(Network network,
                                      ITxMempool mempool,
                                      MempoolSettings mempoolSettings,
                                      ChainIndexer chainIndexer,
                                      IConsensusRuleEngine consensusRules,
                                      ILoggerFactory loggerFactory) : base(network, mempool, mempoolSettings, chainIndexer, loggerFactory)
 {
     this.consensusRules = consensusRules;
 }
예제 #11
0
 public CheckAllInputsMempoolRule(Network network,
                                  ITxMempool mempool,
                                  MempoolSettings mempoolSettings,
                                  ChainIndexer chainIndexer,
                                  IConsensusRuleEngine consensusRuleEngine,
                                  ILoggerFactory loggerFactory) : base(network, mempool, mempoolSettings, chainIndexer, loggerFactory)
 {
     this.consensusRuleEngine = consensusRuleEngine;
 }
예제 #12
0
 public SmartContractMempoolValidator(ITxMempool memPool, MempoolSchedulerLock mempoolLock,
                                      IDateTimeProvider dateTimeProvider, MempoolSettings mempoolSettings, ChainIndexer chainIndexer,
                                      ICoinView coinView, ILoggerFactory loggerFactory, NodeSettings nodeSettings,
                                      IConsensusRuleEngine consensusRules, IEnumerable <IMempoolRule> mempoolRules, NodeDeployments nodeDeployments)
     : base(memPool, mempoolLock, dateTimeProvider, mempoolSettings, chainIndexer, coinView, loggerFactory, nodeSettings, consensusRules, mempoolRules, nodeDeployments)
 {
     // Dirty hack, but due to AllowedScriptTypeRule we don't need to check for standard scripts on any network, even live.
     // TODO: Remove ASAP. Ensure RequireStandard isn't used on SC mainnets, or the StandardScripts check is modular.
     mempoolSettings.RequireStandard = false;
 }
예제 #13
0
        public BaseFeature(
            NodeSettings nodeSettings,
            DataFolder dataFolder,
            INodeLifetime nodeLifetime,
            ConcurrentChain chain,
            IChainState chainState,
            IConnectionManager connectionManager,
            IChainRepository chainRepository,
            IFinalizedBlockInfoRepository finalizedBlockInfo,
            IDateTimeProvider dateTimeProvider,
            IAsyncLoopFactory asyncLoopFactory,
            ITimeSyncBehaviorState timeSyncBehaviorState,
            DBreezeSerializer dbreezeSerializer,
            ILoggerFactory loggerFactory,
            IInitialBlockDownloadState initialBlockDownloadState,
            IPeerBanning peerBanning,
            IPeerAddressManager peerAddressManager,
            IConsensusManager consensusManager,
            IConsensusRuleEngine consensusRules,
            IPartialValidator partialValidator,
            IBlockPuller blockPuller,
            IBlockStore blockStore,
            Network network)
        {
            this.chainState      = Guard.NotNull(chainState, nameof(chainState));
            this.chainRepository = Guard.NotNull(chainRepository, nameof(chainRepository));
            this.finalizedBlockInfoRepository = Guard.NotNull(finalizedBlockInfo, nameof(finalizedBlockInfo));
            this.nodeSettings      = Guard.NotNull(nodeSettings, nameof(nodeSettings));
            this.dataFolder        = Guard.NotNull(dataFolder, nameof(dataFolder));
            this.nodeLifetime      = Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            this.chain             = Guard.NotNull(chain, nameof(chain));
            this.connectionManager = Guard.NotNull(connectionManager, nameof(connectionManager));
            this.consensusManager  = consensusManager;
            this.consensusRules    = consensusRules;
            this.blockPuller       = blockPuller;
            this.blockStore        = blockStore;
            this.network           = network;
            this.partialValidator  = partialValidator;
            this.peerBanning       = Guard.NotNull(peerBanning, nameof(peerBanning));

            this.peerAddressManager = Guard.NotNull(peerAddressManager, nameof(peerAddressManager));
            this.peerAddressManager.PeerFilePath = this.dataFolder;

            this.initialBlockDownloadState = initialBlockDownloadState;
            this.dateTimeProvider          = dateTimeProvider;
            this.asyncLoopFactory          = asyncLoopFactory;
            this.timeSyncBehaviorState     = timeSyncBehaviorState;
            this.loggerFactory             = loggerFactory;
            this.dbreezeSerializer         = dbreezeSerializer;
            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
        }
        public MainNetPreMempoolChecksMempoolRule(Network network,
                                                  ITxMempool txMempool,
                                                  MempoolSettings mempoolSettings,
                                                  ChainIndexer chainIndexer,
                                                  IConsensusRuleEngine consensusRules,
                                                  IDateTimeProvider dateTimeProvider,
                                                  NodeSettings nodeSettings,
                                                  ILoggerFactory loggerFactory) : base(network, txMempool, mempoolSettings, chainIndexer, loggerFactory)
        {
            this.dateTimeProvider = dateTimeProvider;
            this.nodeSettings     = nodeSettings;

            this.checkPowTransactionRule = consensusRules.GetRule <CheckPowTransactionRule>();
        }
예제 #15
0
 public PowTestBlockDefinition(
     IConsensusManager consensusLoop,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IConsensusRuleEngine consensusRules,
     BlockDefinitionOptions options = null)
     : base(consensusLoop, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, consensusRules)
 {
     this.block = this.BlockTemplate.Block;
 }
예제 #16
0
 public PowBlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IConsensusRuleEngine consensusRules,
     BlockDefinitionOptions options = null)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network)
 {
     this.consensusRules = consensusRules;
     this.logger         = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
 }
예제 #17
0
 public PowBlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IConsensusRuleEngine consensusRules,
     NodeDeployments nodeDeployments,
     BlockDefinitionOptions options = null)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, nodeDeployments)
 {
     this.consensusRules = consensusRules;
     this.logger         = loggerFactory.CreateLogger(this.GetType().FullName);
 }
        public SmartContractMempoolValidator(ITxMempool memPool, MempoolSchedulerLock mempoolLock,
                                             IDateTimeProvider dateTimeProvider, MempoolSettings mempoolSettings, ConcurrentChain chain,
                                             ICoinView coinView, ILoggerFactory loggerFactory, NodeSettings nodeSettings,
                                             IConsensusRuleEngine consensusRules, ICallDataSerializer callDataSerializer, Network network,
                                             IStateRepositoryRoot stateRepositoryRoot)
            : base(memPool, mempoolLock, dateTimeProvider, mempoolSettings, chain, coinView, loggerFactory, nodeSettings, consensusRules)
        {
            // Dirty hack, but due to AllowedScriptTypeRule we don't need to check for standard scripts on any network, even live.
            // TODO: Remove ASAP. Ensure RequireStandard isn't used on SC mainnets, or the StandardScripts check is modular.
            mempoolSettings.RequireStandard = false;

            this.callDataSerializer  = callDataSerializer;
            this.stateRepositoryRoot = stateRepositoryRoot;

            var p2pkhRule = new P2PKHNotContractRule(stateRepositoryRoot);

            var scriptTypeRule = new AllowedScriptTypeRule(network);

            scriptTypeRule.Initialize();

            this.preTxRules = new List <ISmartContractMempoolRule>
            {
                new MempoolOpSpendRule(),
                new TxOutSmartContractExecRule(),
                scriptTypeRule,
                p2pkhRule
            };

            // TODO: Tidy this up. Rules should be injected? Shouldn't be generating here based on Network.
            var txChecks = new List <IContractTransactionValidationLogic>
            {
                new SmartContractFormatLogic()
            };

            if (network is ISignedCodePubKeyHolder holder)
            {
                txChecks.Add(new ContractSignedCodeLogic(new ContractSigner(), holder.SigningContractPubKey));
            }


            this.feeTxRules = new List <ISmartContractMempoolRule>()
            {
                new ContractTransactionValidationRule(this.callDataSerializer, txChecks)
            };
        }
        public SmartContractMempoolValidator(ITxMempool memPool, MempoolSchedulerLock mempoolLock,
                                             IDateTimeProvider dateTimeProvider, MempoolSettings mempoolSettings, ChainIndexer chainIndexer,
                                             ICoinView coinView, ILoggerFactory loggerFactory, NodeSettings nodeSettings,
                                             IConsensusRuleEngine consensusRules, ICallDataSerializer callDataSerializer, Network network,
                                             IStateRepositoryRoot stateRepositoryRoot,
                                             IEnumerable <IContractTransactionFullValidationRule> txFullValidationRules)
            : base(memPool, mempoolLock, dateTimeProvider, mempoolSettings, chainIndexer, coinView, loggerFactory, nodeSettings, consensusRules)
        {
            // Dirty hack, but due to AllowedScriptTypeRule we don't need to check for standard scripts on any network, even live.
            // TODO: Remove ASAP. Ensure RequireStandard isn't used on SC mainnets, or the StandardScripts check is modular.
            mempoolSettings.RequireStandard = false;

            this.callDataSerializer  = callDataSerializer;
            this.stateRepositoryRoot = stateRepositoryRoot;

            var p2pkhRule = new P2PKHNotContractRule(stateRepositoryRoot);

            var scriptTypeRule = new AllowedScriptTypeRule(network);

            scriptTypeRule.Initialize();

            this.preTxRules = new List <ISmartContractMempoolRule>
            {
                new MempoolOpSpendRule(),
                new TxOutSmartContractExecRule(),
                scriptTypeRule,
                p2pkhRule
            };

            var txChecks = new List <IContractTransactionPartialValidationRule>()
            {
                new SmartContractFormatLogic()
            };

            this.feeTxRules = new List <ISmartContractMempoolRule>()
            {
                new ContractTransactionPartialValidationRule(this.callDataSerializer, txChecks),
                new ContractTransactionFullValidationRule(this.callDataSerializer, txFullValidationRules)
            };
        }
        public SmartContractMempoolValidator(ITxMempool memPool, MempoolSchedulerLock mempoolLock, IDateTimeProvider dateTimeProvider, MempoolSettings mempoolSettings, ConcurrentChain chain, ICoinView coinView, ILoggerFactory loggerFactory, NodeSettings nodeSettings, IConsensusRuleEngine consensusRules, ICallDataSerializer callDataSerializer)
            : base(memPool, mempoolLock, dateTimeProvider, mempoolSettings, chain, coinView, loggerFactory, nodeSettings, consensusRules)
        {
            // Dirty hack, but due to AllowedScriptTypeRule we don't need to check for standard scripts on any network, even live.
            // TODO: Remove ASAP. Ensure RequireStandard isn't used on SC mainnets, or the StandardScripts check is modular.
            mempoolSettings.RequireStandard = false;

            this.callDataSerializer = callDataSerializer;

            var p2pkhRule = new P2PKHNotContractRule();

            p2pkhRule.Parent = (ConsensusRuleEngine)consensusRules;
            p2pkhRule.Initialize();

            var scriptTypeRule = new AllowedScriptTypeRule();

            scriptTypeRule.Parent = (ConsensusRuleEngine)consensusRules;
            scriptTypeRule.Initialize();

            this.preTxRules = new List <ISmartContractMempoolRule>
            {
                new MempoolOpSpendRule(),
                new TxOutSmartContractExecRule(),
                scriptTypeRule,
                p2pkhRule
            };

            this.feeTxRules = new List <ISmartContractMempoolRule>()
            {
                new SmartContractFormatRule(callDataSerializer)
            };
        }
예제 #21
0
        public TestContext()
        {
            this.Network = KnownNetworks.RegTest;

            this.chainIndexer     = new ChainIndexer(this.Network);
            this.dateTimeProvider = new DateTimeProvider();
            this.hashStore        = new InvalidBlockHashStore(this.dateTimeProvider);

            this.coinView        = new TestInMemoryCoinView(this.chainIndexer.Tip.HashBlock);
            this.HeaderValidator = new Mock <IHeaderValidator>();
            this.HeaderValidator.Setup(hv => hv.ValidateHeader(It.IsAny <ChainedHeader>())).Returns(new ValidationContext());

            this.nodeLifetime = new NodeLifetime();
            this.ibd          = new Mock <IInitialBlockDownloadState>();
            this.BlockPuller  = new Mock <IBlockPuller>();

            this.BlockPuller.Setup(b => b.Initialize(It.IsAny <BlockPuller.OnBlockDownloadedCallback>()))
            .Callback <BlockPuller.OnBlockDownloadedCallback>((d) => { this.blockPullerBlockDownloadCallback = d; });
            this.BlockStore  = new Mock <IBlockStore>();
            this.checkpoints = new Mock <ICheckpoints>();
            this.ChainState  = new Mock <IChainState>();

            string[] param = new string[] { };
            this.nodeSettings      = new NodeSettings(this.Network, args: param);
            this.ConsensusSettings = new ConsensusSettings(this.nodeSettings);

            this.loggerFactory = this.nodeSettings.LoggerFactory;

            this.nodeStats = new NodeStats(this.dateTimeProvider, this.loggerFactory);

            var connectionSettings = new ConnectionManagerSettings(this.nodeSettings);

            this.selfEndpointTracker       = new SelfEndpointTracker(this.loggerFactory, connectionSettings);
            this.Network.Consensus.Options = new ConsensusOptions();

            this.signals       = new Bitcoin.Signals.Signals(this.loggerFactory, null);
            this.asyncProvider = new AsyncProvider(this.loggerFactory, this.signals, this.nodeLifetime);

            // Dont check PoW of a header in this test.
            this.Network.Consensus.ConsensusRules.HeaderValidationRules.RemoveAll(x => x.GetType() == typeof(CheckDifficultyPowRule));

            this.ChainedHeaderTree = new ChainedHeaderTree(
                this.Network,
                this.loggerFactory,
                this.HeaderValidator.Object,
                this.checkpoints.Object,
                this.ChainState.Object,
                this.FinalizedBlockMock.Object,
                this.ConsensusSettings,
                this.hashStore);

            this.peerAddressManager = new PeerAddressManager(DateTimeProvider.Default, this.nodeSettings.DataFolder, this.loggerFactory, this.selfEndpointTracker);

            this.networkPeerFactory = new NetworkPeerFactory(this.Network,
                                                             this.dateTimeProvider,
                                                             this.loggerFactory, new PayloadProvider().DiscoverPayloads(),
                                                             this.selfEndpointTracker,
                                                             this.ibd.Object,
                                                             new ConnectionManagerSettings(this.nodeSettings),
                                                             this.asyncProvider,
                                                             this.peerAddressManager);

            var peerDiscovery = new PeerDiscovery(this.asyncProvider, this.loggerFactory, this.Network, this.networkPeerFactory, this.nodeLifetime, this.nodeSettings, this.peerAddressManager);

            this.connectionManager = new ConnectionManager(this.dateTimeProvider, this.loggerFactory, this.Network, this.networkPeerFactory, this.nodeSettings,
                                                           this.nodeLifetime, new NetworkPeerConnectionParameters(), this.peerAddressManager, new IPeerConnector[] { },
                                                           peerDiscovery, this.selfEndpointTracker, connectionSettings, new VersionProvider(), this.nodeStats, this.asyncProvider);

            this.deployments = new NodeDeployments(this.Network, this.chainIndexer);

            this.consensusRules = new PowConsensusRuleEngine(this.Network, this.loggerFactory, this.dateTimeProvider, this.chainIndexer, this.deployments, this.ConsensusSettings,
                                                             this.checkpoints.Object, this.coinView, this.ChainState.Object, this.hashStore, this.nodeStats, this.asyncProvider, new ConsensusRulesContainer());

            this.consensusRules.SetupRulesEngineParent();

            var tree = new ChainedHeaderTree(this.Network, this.loggerFactory, this.HeaderValidator.Object, this.checkpoints.Object,
                                             this.ChainState.Object, this.FinalizedBlockMock.Object, this.ConsensusSettings, this.hashStore);

            this.PartialValidator = new Mock <IPartialValidator>();
            this.FullValidator    = new Mock <IFullValidator>();

            this.peerBanning = new PeerBanning(this.connectionManager, this.loggerFactory, this.dateTimeProvider, this.peerAddressManager);

            this.IntegrityValidator.Setup(i => i.VerifyBlockIntegrity(It.IsAny <ChainedHeader>(), It.IsAny <Block>()))
            .Returns(new ValidationContext());

            ConsensusManager consensusManager = new ConsensusManager(tree, this.Network, this.loggerFactory, this.ChainState.Object, this.IntegrityValidator.Object,
                                                                     this.PartialValidator.Object, this.FullValidator.Object, this.consensusRules,
                                                                     this.FinalizedBlockMock.Object, this.signals, this.peerBanning, this.ibd.Object, this.chainIndexer,
                                                                     this.BlockPuller.Object, this.BlockStore.Object, this.connectionManager, this.nodeStats, this.nodeLifetime, this.ConsensusSettings, this.dateTimeProvider);

            this.TestConsensusManager = new TestConsensusManager(consensusManager);
        }
예제 #22
0
        public SmartContractMempoolValidator(ITxMempool memPool, MempoolSchedulerLock mempoolLock, IDateTimeProvider dateTimeProvider, MempoolSettings mempoolSettings, ConcurrentChain chain, ICoinView coinView, ILoggerFactory loggerFactory, NodeSettings nodeSettings, IConsensusRuleEngine consensusRules, ICallDataSerializer callDataSerializer)
            : base(memPool, mempoolLock, dateTimeProvider, mempoolSettings, chain, coinView, loggerFactory, nodeSettings, consensusRules)
        {
            this.callDataSerializer = callDataSerializer;

            var p2pkhRule = new P2PKHNotContractRule();

            p2pkhRule.Parent = (ConsensusRuleEngine)consensusRules;
            p2pkhRule.Initialize();

            var scriptTypeRule = new AllowedScriptTypeRule();

            scriptTypeRule.Parent = (ConsensusRuleEngine)consensusRules;
            scriptTypeRule.Initialize();

            this.preTxRules = new List <ISmartContractMempoolRule>
            {
                new MempoolOpSpendRule(),
                new TxOutSmartContractExecRule(),
                scriptTypeRule,
                p2pkhRule
            };

            this.feeTxRules = new List <ISmartContractMempoolRule>()
            {
                new SmartContractFormatRule(callDataSerializer)
            };
        }
예제 #23
0
 public HeaderValidator(IConsensusRuleEngine consensusRules, ILoggerFactory loggerFactory)
 {
     this.consensusRules = consensusRules;
     this.logger         = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");
 }
예제 #24
0
 public HeaderValidator(IConsensusRuleEngine consensusRules, ILoggerFactory loggerFactory)
 {
     this.consensusRules = consensusRules;
     this.logger         = loggerFactory.CreateLogger(GetType().FullName);
 }