public ReflectionSmartContractExecutorFactory(ILoggerFactory loggerFactory, IContractPrimitiveSerializer contractPrimitiveSerializer, ICallDataSerializer serializer, ISmartContractResultRefundProcessor refundProcessor, ISmartContractResultTransferProcessor transferProcessor, ISmartContractVirtualMachine vm) { this.loggerFactory = loggerFactory; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.vm = vm; this.contractPrimitiveSerializer = contractPrimitiveSerializer; this.serializer = serializer; }
public ReflectionSmartContractExecutorFactory(ILoggerFactory loggerFactory, ICallDataSerializer serializer, ISmartContractResultRefundProcessor refundProcessor, ISmartContractResultTransferProcessor transferProcessor, Network network, IStateFactory stateFactory) { this.loggerFactory = loggerFactory; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.network = network; this.stateFactory = stateFactory; }
public Executor(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IContractStateRepository stateSnapshot, ISmartContractResultRefundProcessor refundProcessor, ISmartContractResultTransferProcessor transferProcessor, ISmartContractVirtualMachine vm) { this.logger = loggerFactory.CreateLogger(this.GetType()); this.stateSnapshot = stateSnapshot; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.vm = vm; this.serializer = serializer; }
public LocalExecutor(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IStateRepositoryRoot stateRoot, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.logger = loggerFactory.CreateLogger(this.GetType()); this.stateRoot = stateRoot; this.serializer = serializer; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
public SmartContractTransactionService( Network network, IWalletManager walletManager, IWalletTransactionHandler walletTransactionHandler, IMethodParameterStringSerializer methodParameterStringSerializer, ICallDataSerializer callDataSerializer, IAddressGenerator addressGenerator) { this.network = network; this.walletManager = walletManager; this.walletTransactionHandler = walletTransactionHandler; this.methodParameterStringSerializer = methodParameterStringSerializer; this.callDataSerializer = callDataSerializer; this.addressGenerator = addressGenerator; }
public SmartContractExecutorTests() { this.keyEncodingStrategy = BasicKeyEncodingStrategy.Default; this.loggerFactory = new ExtendedLoggerFactory(); this.loggerFactory.AddConsoleWithFilters(); this.network = new SmartContractsRegTest(); this.refundProcessor = new SmartContractResultRefundProcessor(this.loggerFactory); this.state = new ContractStateRepositoryRoot(new NoDeleteSource <byte[], byte[]>(new MemoryDictionarySource())); this.transferProcessor = new SmartContractResultTransferProcessor(this.loggerFactory, this.network); this.validator = new SmartContractValidator(new ISmartContractValidator[] { }); this.internalTxExecutorFactory = new InternalTransactionExecutorFactory(this.keyEncodingStrategy, this.loggerFactory, this.network); this.validator = new SmartContractValidator(new List <ISmartContractValidator>()); this.vm = new ReflectionVirtualMachine(this.validator, this.internalTxExecutorFactory, this.loggerFactory, this.network); this.serializer = CallDataSerializer.Default; }
public SmartContractPoACoinviewRule( IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView) { this.stateRepositoryRoot = stateRepositoryRoot; this.executorFactory = executorFactory; this.callDataSerializer = callDataSerializer; this.senderRetriever = senderRetriever; this.receiptRepository = receiptRepository; this.coinView = coinView; }
public Executor(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IContractStateRoot stateRoot, ISmartContractResultRefundProcessor refundProcessor, ISmartContractResultTransferProcessor transferProcessor, Network network, IStateFactory stateFactory) { this.logger = loggerFactory.CreateLogger(this.GetType()); this.stateRoot = stateRoot; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.network = network; this.stateFactory = stateFactory; }
public ReflectionExecutorFactory(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IContractRefundProcessor refundProcessor, IContractTransferProcessor transferProcessor, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.loggerFactory = loggerFactory; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
protected SmartContractCoinviewRule(Network network, IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView) { this.network = network; this.stateRepositoryRoot = stateRepositoryRoot; this.executorFactory = executorFactory; this.callDataSerializer = callDataSerializer; this.senderRetriever = senderRetriever; this.receiptRepository = receiptRepository; this.coinView = coinView; }
public SignedContractPoARuleRegistration(Network network, IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView) { this.network = network; this.stateRepositoryRoot = stateRepositoryRoot; this.executorFactory = executorFactory; this.callDataSerializer = callDataSerializer; this.senderRetriever = senderRetriever; this.receiptRepository = receiptRepository; this.coinView = coinView; }
public SmartContractCoinViewRuleLogic(IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView) { this.stateRepositoryRoot = stateRepositoryRoot; this.executorFactory = executorFactory; this.callDataSerializer = callDataSerializer; this.senderRetriever = senderRetriever; this.receiptRepository = receiptRepository; this.coinView = coinView; this.refundCounter = 1; this.blockTxsProcessed = new List <Transaction>(); this.receipts = new List <Receipt>(); }
public ContractExecutor( ICallDataSerializer serializer, IStateRepository stateRoot, IContractRefundProcessor refundProcessor, IContractTransferProcessor transferProcessor, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.stateRoot = stateRoot; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
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) }; }
/// <summary> /// Adds the smart contract feature to the node. /// </summary> public static IFullNodeBuilder AddSmartContracts(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <SmartContractFeature>("smartcontracts"); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <SmartContractFeature>() .FeatureServices(services => { // STATE ---------------------------------------------------------------------------- services.AddSingleton <DBreezeContractStateStore>(); services.AddSingleton <NoDeleteContractStateSource>(); services.AddSingleton <IStateRepositoryRoot, StateRepositoryRoot>(); // CONSENSUS ------------------------------------------------------------------------ services.AddSingleton <IMempoolValidator, SmartContractMempoolValidator>(); services.AddSingleton <StandardTransactionPolicy, SmartContractTransactionPolicy>(); // CONTRACT EXECUTION --------------------------------------------------------------- services.AddSingleton <IInternalExecutorFactory, InternalExecutorFactory>(); services.AddSingleton <IVirtualMachine, ReflectionVirtualMachine>(); services.AddSingleton <IAddressGenerator, AddressGenerator>(); services.AddSingleton <ILoader, ContractAssemblyLoader>(); services.AddSingleton <IContractModuleDefinitionReader, ContractModuleDefinitionReader>(); services.AddSingleton <IStateFactory, StateFactory>(); services.AddSingleton <SmartContractTransactionPolicy>(); services.AddSingleton <IStateProcessor, StateProcessor>(); services.AddSingleton <ISmartContractStateFactory, SmartContractStateFactory>(); // RECEIPTS ------------------------------------------------------------------------- services.AddSingleton <IReceiptRepository, PersistentReceiptRepository>(); // UTILS ---------------------------------------------------------------------------- services.AddSingleton <ISenderRetriever, SenderRetriever>(); services.AddSingleton <IVersionProvider, SmartContractVersionProvider>(); ICallDataSerializer callDataSerializer = CallDataSerializer.Default; services.AddSingleton(callDataSerializer); services.Replace(new ServiceDescriptor(typeof(IScriptAddressReader), new SmartContractScriptAddressReader(new ScriptAddressReader(), callDataSerializer))); }); }); return(fullNodeBuilder); }
public SmartContractWalletController( IBroadcasterManager broadcasterManager, ICallDataSerializer callDataSerializer, IConnectionManager connectionManager, ILoggerFactory loggerFactory, Network network, IReceiptRepository receiptRepository, IWalletManager walletManager) { this.broadcasterManager = broadcasterManager; this.callDataSerializer = callDataSerializer; this.connectionManager = connectionManager; this.coinType = (CoinType)network.Consensus.CoinType; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.network = network; this.receiptRepository = receiptRepository; this.walletManager = walletManager; }
public TestFederatedPegBlockDefinition( IBlockBufferGenerator blockBufferGenerator, ICoinView coinView, IConsensusManager consensusManager, IDateTimeProvider dateTimeProvider, IContractExecutorFactory executorFactory, ILoggerFactory loggerFactory, ITxMempool mempool, MempoolSchedulerLock mempoolLock, Network network, ISenderRetriever senderRetriever, IStateRepositoryRoot stateRoot, IBlockExecutionResultCache executionCache, ICallDataSerializer callDataSerializer, MinerSettings minerSettings) : base(blockBufferGenerator, coinView, consensusManager, dateTimeProvider, executorFactory, loggerFactory, mempool, mempoolLock, network, senderRetriever, stateRoot, executionCache, callDataSerializer, minerSettings) { }
public SmartContractWalletController( IBroadcasterManager broadcasterManager, ICallDataSerializer callDataSerializer, IConnectionManager connectionManager, ILoggerFactory loggerFactory, Network network, IReceiptRepository receiptRepository, IWalletManager walletManager, ISmartContractTransactionService smartContractTransactionService) { this.broadcasterManager = broadcasterManager; this.callDataSerializer = callDataSerializer; this.connectionManager = connectionManager; this.logger = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode"); this.network = network; this.receiptRepository = receiptRepository; this.walletManager = walletManager; this.smartContractTransactionService = smartContractTransactionService; }
public SmartContractPoACoinviewRule( IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView, IBlockExecutionResultCache executionCache, ILoggerFactory loggerFactory) { this.stateRepositoryRoot = stateRepositoryRoot; this.executorFactory = executorFactory; this.callDataSerializer = callDataSerializer; this.senderRetriever = senderRetriever; this.receiptRepository = receiptRepository; this.coinView = coinView; this.executionCache = executionCache; this.loggerFactory = loggerFactory; }
public SmartContractPoARuleRegistration(Network network, IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView, IEnumerable <IContractTransactionValidationLogic> validationRules) { this.baseRuleRegistration = new PoAConsensusRulesRegistration(); this.network = network; this.stateRepositoryRoot = stateRepositoryRoot; this.executorFactory = executorFactory; this.callDataSerializer = callDataSerializer; this.senderRetriever = senderRetriever; this.receiptRepository = receiptRepository; this.coinView = coinView; this.validationRules = validationRules; }
public SmartContractPosRuleRegistration(Network network, IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView, IStakeChain stakeChain, IStakeValidator stakeValidator) { this.network = network; this.stateRepositoryRoot = stateRepositoryRoot; this.executorFactory = executorFactory; this.callDataSerializer = callDataSerializer; this.senderRetriever = senderRetriever; this.receiptRepository = receiptRepository; this.coinView = coinView; this.stakeChain = stakeChain; this.stakeValidator = stakeValidator; }
public ContractExecutor(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IStateRepository stateRoot, IContractRefundProcessor refundProcessor, IContractTransferProcessor transferProcessor, Network network, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.logger = loggerFactory.CreateLogger(this.GetType()); this.stateRoot = stateRoot; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.network = network; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
public SmartContractTransactionService( Network network, IWalletManager walletManager, IWalletTransactionHandler walletTransactionHandler, IMethodParameterStringSerializer methodParameterStringSerializer, ICallDataSerializer callDataSerializer, IAddressGenerator addressGenerator, IStateRepositoryRoot stateRoot, IReserveUtxoService reserveUtxoService ) { this.network = network; this.walletManager = walletManager; this.walletTransactionHandler = walletTransactionHandler; this.methodParameterStringSerializer = methodParameterStringSerializer; this.callDataSerializer = callDataSerializer; this.addressGenerator = addressGenerator; this.stateRoot = stateRoot; this.reserveUtxoService = reserveUtxoService; }
public SmartContractPoABlockDefinition( IBlockBufferGenerator blockBufferGenerator, ICoinView coinView, IConsensusManager consensusManager, IDateTimeProvider dateTimeProvider, IContractExecutorFactory executorFactory, ILoggerFactory loggerFactory, ITxMempool mempool, MempoolSchedulerLock mempoolLock, Network network, ISenderRetriever senderRetriever, IStateRepositoryRoot stateRoot, IBlockExecutionResultCache executionCache, ICallDataSerializer callDataSerializer, MinerSettings minerSettings, NodeDeployments nodeDeployments) : base(blockBufferGenerator, coinView, consensusManager, dateTimeProvider, executorFactory, loggerFactory, mempool, mempoolLock, minerSettings, network, senderRetriever, stateRoot, executionCache, callDataSerializer, nodeDeployments) { // TODO: Fix gross MinerSettings injection ^^ }
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) }; }
/// <inheritdoc /> public FederatedPegBlockDefinition( IBlockBufferGenerator blockBufferGenerator, ICoinView coinView, IConsensusManager consensusManager, IDateTimeProvider dateTimeProvider, IContractExecutorFactory executorFactory, ILoggerFactory loggerFactory, ITxMempool mempool, MempoolSchedulerLock mempoolLock, Network network, ISenderRetriever senderRetriever, IStateRepositoryRoot stateRoot, ICoinbaseSplitter premineSplitter, IBlockExecutionResultCache executionCache, ICallDataSerializer callDataSerializer, MinerSettings minerSettings, FederatedPegSettings federatedPegSettings) : base(blockBufferGenerator, coinView, consensusManager, dateTimeProvider, executorFactory, loggerFactory, mempool, mempoolLock, network, senderRetriever, stateRoot, executionCache, callDataSerializer, minerSettings) { this.payToMultisigScript = federatedPegSettings.MultiSigAddress.ScriptPubKey; this.premineSplitter = premineSplitter; }
public ContractTransactionFullValidationRule(ICallDataSerializer serializer, IEnumerable <IContractTransactionFullValidationRule> internalRules) { this.transactionChecker = new ContractTransactionChecker(serializer); this.internalRules = internalRules; }
public SmartContractPowCoinviewRule(Network network, IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView) : base(network, stateRepositoryRoot, executorFactory, callDataSerializer, senderRetriever, receiptRepository, coinView) { }
public SmartContractPosCoinviewRule(Network network, IStateRepositoryRoot stateRepositoryRoot, IContractExecutorFactory executorFactory, ICallDataSerializer callDataSerializer, ISenderRetriever senderRetriever, IReceiptRepository receiptRepository, ICoinView coinView, IStakeChain stakeChain, IStakeValidator stakeValidator) : base(network, stateRepositoryRoot, executorFactory, callDataSerializer, senderRetriever, receiptRepository, coinView) { this.consensus = network.Consensus; this.stakeChain = stakeChain; this.stakeValidator = stakeValidator; }
public ContractValidationRuleTest() { this.network = new SmartContractsRegTest(); this.callDataSerializer = new CallDataSerializer(new ContractPrimitiveSerializer(this.network)); }