Ejemplo n.º 1
0
 public BlockGenerationService(IBlockExtraDataService blockExtraDataService,
                               IStaticChainInformationProvider staticChainInformationProvider, IBlockchainStateManager blockchainStateManager)
 {
     _blockExtraDataService          = blockExtraDataService;
     _staticChainInformationProvider = staticChainInformationProvider;
     _blockchainStateManager         = blockchainStateManager;
 }
Ejemplo n.º 2
0
 public BlockchainStateService(IBlockchainService blockchainService,
                               IBlockchainStateManager blockchainStateManager)
 {
     _blockchainService      = blockchainService;
     _blockchainStateManager = blockchainStateManager;
     Logger = NullLogger <BlockchainStateService> .Instance;
 }
Ejemplo n.º 3
0
        public async Task GlobalSetup()
        {
            _chains = GetRequiredService <IBlockchainStore <Chain> >();
            _chainStateInfoCollection = GetRequiredService <IStateStore <ChainStateInfo> >();
            _blockchainStateManager   = GetRequiredService <IBlockchainStateManager>();
            _blockchainStateService   = GetRequiredService <IBlockchainStateService>();
            _blockchainService        = GetRequiredService <IBlockchainService>();
            _osTestHelper             = GetRequiredService <OSTestHelper>();
            _chainManager             = GetRequiredService <IChainManager>();
            _blockManager             = GetRequiredService <IBlockManager>();
            _transactionManager       = GetRequiredService <ITransactionManager>();
            _transactionResultManager = GetRequiredService <ITransactionResultManager>();
            _txHub = GetRequiredService <ITxHub>();

            _blockStateSets = new List <BlockStateSet>();
            _blocks         = new List <Block>();

            _chain = await _blockchainService.GetChainAsync();

            var blockHash = _chain.BestChainHash;

            while (true)
            {
                var blockState = await _blockchainStateManager.GetBlockStateSetAsync(blockHash);

                _blockStateSets.Add(blockState);

                var blockHeader = await _blockchainService.GetBlockHeaderByHashAsync(blockHash);

                blockHash = blockHeader.PreviousBlockHash;
                if (blockHash == _chain.LastIrreversibleBlockHash)
                {
                    break;
                }
            }

            await _blockchainStateService.MergeBlockStateAsync(_chain.BestChainHeight, _chain.BestChainHash);

            for (var i = 0; i < BlockCount; i++)
            {
                var transactions = await _osTestHelper.GenerateTransferTransactions(TransactionCount);

                await _osTestHelper.BroadcastTransactions(transactions);

                var block = await _osTestHelper.MinedOneBlock();

                _blocks.Add(block);

                var blockState = await _blockchainStateManager.GetBlockStateSetAsync(block.GetHash());

                _blockStateSets.Add(blockState);
            }

            var chain = await _blockchainService.GetChainAsync();

            await _chainManager.SetIrreversibleBlockAsync(chain, chain.BestChainHash);

            _chainStateInfo = await _chainStateInfoCollection.GetAsync(chain.Id.ToStorageKey());
        }
Ejemplo n.º 4
0
 public TestingSmartContractExecutiveService(ISmartContractRunnerContainer smartContractRunnerContainer,
                                             IBlockchainStateManager blockchainStateManager,
                                             IDefaultContractZeroCodeProvider defaultContractZeroCodeProvider,
                                             IHostSmartContractBridgeContextService hostSmartContractBridgeContextService) : base(
         smartContractRunnerContainer, blockchainStateManager, defaultContractZeroCodeProvider,
         hostSmartContractBridgeContextService)
 {
 }
Ejemplo n.º 5
0
 public SmartContractBridgeService(ISmartContractService smartContractService,
                                   IBlockchainService blockchainService, ISmartContractAddressService smartContractAddressService,
                                   IBlockchainStateManager blockchainStateManager)
 {
     _smartContractService        = smartContractService;
     _blockchainService           = blockchainService;
     _smartContractAddressService = smartContractAddressService;
     _blockchainStateManager      = blockchainStateManager;
     Logger = NullLogger <SmartContractBridgeService> .Instance;
 }
Ejemplo n.º 6
0
 public BlockChainAppServiceTest(ITestOutputHelper outputHelper) : base(outputHelper)
 {
     _blockchainService           = GetRequiredService <IBlockchainService>();
     _smartContractAddressService = GetRequiredService <ISmartContractAddressService>();
     _txHub = GetRequiredService <ITxHub>();
     _blockchainStateMergingService = GetRequiredService <IBlockchainStateMergingService>();
     _blockchainStateManager        = GetRequiredService <IBlockchainStateManager>();
     _osTestHelper   = GetRequiredService <OSTestHelper>();
     _accountService = GetRequiredService <IAccountService>();
 }
Ejemplo n.º 7
0
 public SmartContractExecutiveService(
     ISmartContractRunnerContainer smartContractRunnerContainer, IBlockchainStateManager blockchainStateManager,
     IDefaultContractZeroCodeProvider defaultContractZeroCodeProvider,
     IHostSmartContractBridgeContextService hostSmartContractBridgeContextService)
 {
     _smartContractRunnerContainer          = smartContractRunnerContainer;
     _blockchainStateManager                = blockchainStateManager;
     _defaultContractZeroCodeProvider       = defaultContractZeroCodeProvider;
     _hostSmartContractBridgeContextService = hostSmartContractBridgeContextService;
     _readOnlyContractInfoCache             = new ReadOnlyDictionary <Address, long>(_contractInfoCache);
 }
Ejemplo n.º 8
0
        public BlockChainAppService(IBlockchainService blockchainService,
                                    ITxHub txHub,
                                    IBlockchainStateManager blockchainStateManager)
        {
            _blockchainService      = blockchainService;
            _txHub                  = txHub;
            _blockchainStateManager = blockchainStateManager;

            Logger        = NullLogger <BlockChainAppService> .Instance;
            LocalEventBus = NullLocalEventBus.Instance;
        }
Ejemplo n.º 9
0
        public FullBlockchainExecutingService(IChainManager chainManager,
                                              IBlockchainService blockchainService, IBlockValidationService blockValidationService,
                                              IBlockExecutingService blockExecutingService, IBlockchainStateManager blockchainStateManager)
        {
            _chainManager           = chainManager;
            _blockchainService      = blockchainService;
            _blockValidationService = blockValidationService;
            _blockExecutingService  = blockExecutingService;
            _blockchainStateManager = blockchainStateManager;

            LocalEventBus = NullLocalEventBus.Instance;
        }
Ejemplo n.º 10
0
 public BlockchainStateManagerTests()
 {
     _blockStateSetManger    = GetRequiredService <IBlockStateSetManger>();
     _blockchainStateManager = GetRequiredService <IBlockchainStateManager>();
     _tv = new List <TestPair>();
     for (var i = 0; i < 200; i++)
     {
         _tv.Add(new TestPair()
         {
             BlockHash   = Hash.FromRawBytes(new[] { Convert.ToByte(i) }),
             BlockHeight = i,
             Key         = $"key{i}",
             Value       = ByteString.CopyFromUtf8($"value{i}")
         });
     }
 }
Ejemplo n.º 11
0
 public ParallelTests()
 {
     _blockchainService        = GetRequiredService <IBlockchainService>();
     _blockExecutingService    = GetRequiredService <IBlockExecutingService>();
     _transactionResultManager = GetRequiredService <ITransactionResultManager>();
     _grouper = GetRequiredService <ITransactionGrouper>();
     _blockchainStateService = GetRequiredService <IBlockchainStateService>();
     _txHub = GetRequiredService <ITxHub>();
     _blockAttachService              = GetRequiredService <IBlockAttachService>();
     _accountService                  = GetRequiredService <IAccountService>();
     _parallelTestHelper              = GetRequiredService <ParallelTestHelper>();
     _smartContractAddressService     = GetRequiredService <ISmartContractAddressService>();
     _blockchainStateManager          = GetRequiredService <IBlockchainStateManager>();
     _versionedStates                 = GetRequiredService <IStateStore <VersionedState> >();
     _nonparallelContractCodeProvider = GetRequiredService <INonparallelContractCodeProvider>();
     _blockStateSetManger             = GetRequiredService <IBlockStateSetManger>();
 }
Ejemplo n.º 12
0
        public BlockChainAppService(IBlockchainService blockchainService,
                                    ISmartContractAddressService smartContractAddressService,
                                    ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService,
                                    ITransactionManager transactionManager,
                                    ITransactionResultQueryService transactionResultQueryService,
                                    ITxHub txHub,
                                    IBlockchainStateManager blockchainStateManager
                                    )
        {
            _blockchainService                   = blockchainService;
            _smartContractAddressService         = smartContractAddressService;
            _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService;
            _transactionManager                  = transactionManager;
            _transactionResultQueryService       = transactionResultQueryService;
            _txHub = txHub;
            _blockchainStateManager = blockchainStateManager;

            Logger        = NullLogger <BlockChainAppService> .Instance;
            LocalEventBus = NullLocalEventBus.Instance;
        }
 public BlockchainStateMergingServiceTests()
 {
     _blockchainStateManager        = GetRequiredService <IBlockchainStateManager>();
     _blockchainStateMergingService = GetRequiredService <IBlockchainStateMergingService>();
 }
Ejemplo n.º 14
0
 public StateProviderFactory(IBlockchainStateManager blockchainStateManager)
 {
     _blockchainStateManager = blockchainStateManager;
 }