Esempio n. 1
0
        private void Initialize()
        {
            NewStorage();
            var transactionManager      = new TransactionManager(_dataStore, _logger);
            var transactionTraceManager = new TransactionTraceManager(_dataStore);

            _functionMetadataService = new FunctionMetadataService(_dataStore, _logger);
            var chainManagerBasic = new ChainManagerBasic(_dataStore);

            ChainService = new ChainService(chainManagerBasic, new BlockManagerBasic(_dataStore),
                                            transactionManager, transactionTraceManager, _dataStore, StateStore);
            _smartContractRunnerFactory = new SmartContractRunnerFactory();
            var runner = new SmartContractRunner("../../../../AElf.Runtime.CSharp.Tests.TestContract/bin/Debug/netstandard2.0/");

            _smartContractRunnerFactory.AddRunner(0, runner);
            _chainCreationService = new ChainCreationService(ChainService,
                                                             new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory,
                                                                                      StateStore, _functionMetadataService), _logger);
            SmartContractManager = new SmartContractManager(_dataStore);
            Task.Factory.StartNew(async() =>
            {
                await Init();
            }).Unwrap().Wait();
            SmartContractService = new SmartContractService(SmartContractManager, _smartContractRunnerFactory, StateStore, _functionMetadataService);
            ChainService         = new ChainService(new ChainManagerBasic(_dataStore), new BlockManagerBasic(_dataStore), new TransactionManager(_dataStore), new TransactionTraceManager(_dataStore), _dataStore, StateStore);
        }
Esempio n. 2
0
        private void Initialize()
        {
            _transactionManager        = new TransactionManager(_dataStore, _logger);
            _transactionReceiptManager = new TransactionReceiptManager(_database);
            _smartContractManager      = new SmartContractManager(_dataStore);
            _transactionResultManager  = new TransactionResultManager(_dataStore);
            _transactionTraceManager   = new TransactionTraceManager(_dataStore);
            _functionMetadataService   = new FunctionMetadataService(_dataStore, _logger);
            _chainManagerBasic         = new ChainManagerBasic(_dataStore);
            _chainService = new ChainService(_chainManagerBasic, new BlockManagerBasic(_dataStore),
                                             _transactionManager, _transactionTraceManager, _dataStore, StateStore);
            _smartContractRunnerFactory = new SmartContractRunnerFactory();

            /*var runner = new SmartContractRunner("../../../../AElf.SDK.CSharp/bin/Debug/netstandard2.0/");
             * _smartContractRunnerFactory.AddRunner(0, runner);*/
            var runner = new SmartContractRunner(ContractCodes.TestContractFolder);

            _smartContractRunnerFactory.AddRunner(0, runner);
            _concurrencyExecutingService = new SimpleExecutingService(
                new SmartContractService(_smartContractManager, _smartContractRunnerFactory, StateStore,
                                         _functionMetadataService), _transactionTraceManager, StateStore,
                new ChainContextService(_chainService));

            _chainCreationService = new ChainCreationService(_chainService,
                                                             new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory,
                                                                                      StateStore, _functionMetadataService), _logger);

            _binaryMerkleTreeManager = new BinaryMerkleTreeManager(_dataStore);
            _chainContextService     = new ChainContextService(_chainService);
            _stateStore = new StateStore(_database);
        }
Esempio n. 3
0
        public Benchmarks(IStateStore stateStore, IChainCreationService chainCreationService,
                          IChainContextService chainContextService, ISmartContractService smartContractService,
                          ILogger logger, IFunctionMetadataService functionMetadataService, BenchmarkOptions options, IExecutingService executingService)
        {
            ChainId               = Hash.Generate();
            _stateStore           = stateStore;
            _chainCreationService = chainCreationService;
            _smartContractService = smartContractService;
            _logger               = logger;
            _options              = options;
            _executingService     = executingService;


            _servicePack = new ServicePack
            {
                ChainContextService      = chainContextService,
                SmartContractService     = _smartContractService,
                ResourceDetectionService = new ResourceUsageDetectionService(functionMetadataService),
                StateStore = _stateStore
            };

            _dataGenerater = new TransactionDataGenerator(options);
            byte[] code;
            using (FileStream file = File.OpenRead(Path.GetFullPath(options.DllDir + "/" + options.ContractDll)))
            {
                code = file.ReadFully();
            }
            _contractHash = Prepare(code).Result;
        }
Esempio n. 4
0
 public MainchainNodeService(IStateStore stateStore, ITxHub hub, IChainCreationService chainCreationService,
                             IBlockSynchronizer blockSynchronizer, IChainService chainService, IMiner miner, ILogger logger)
 {
     _stateStore           = stateStore;
     _chainCreationService = chainCreationService;
     _chainService         = chainService;
     _txHub             = hub;
     _logger            = logger;
     _miner             = miner;
     _blockSynchronizer = blockSynchronizer;
 }
Esempio n. 5
0
        public BlockchainNodeContextService(
            IBlockchainService blockchainService, IChainCreationService chainCreationService,
            IDefaultContractZeroCodeProvider defaultContractZeroCodeProvider, IConsensusService consensusService)
        {
            _blockchainService               = blockchainService;
            _chainCreationService            = chainCreationService;
            _defaultContractZeroCodeProvider = defaultContractZeroCodeProvider;
            _consensusService = consensusService;

            EventBus = NullLocalEventBus.Instance;
        }
 public BlockchainNodeContextService(
     IBlockchainService blockchainService, IChainCreationService chainCreationService, ITxHub txHub,
     ISmartContractAddressUpdateService smartContractAddressUpdateService,
     IDefaultContractZeroCodeProvider defaultContractZeroCodeProvider, IConsensusService consensusService)
 {
     _blockchainService    = blockchainService;
     _chainCreationService = chainCreationService;
     _txHub = txHub;
     _smartContractAddressUpdateService = smartContractAddressUpdateService;
     _defaultContractZeroCodeProvider   = defaultContractZeroCodeProvider;
     _consensusService = consensusService;
 }
Esempio n. 7
0
 public ContractTest(IStateStore stateStore,
                     IChainCreationService chainCreationService, IChainService chainService,
                     ITransactionManager transactionManager, ISmartContractManager smartContractManager,
                     IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory)
 {
     _stateStore                 = stateStore;
     _chainCreationService       = chainCreationService;
     _chainService               = chainService;
     _transactionManager         = transactionManager;
     _smartContractManager       = smartContractManager;
     _chainContextService        = chainContextService;
     _functionMetadataService    = functionMetadataService;
     _smartContractRunnerFactory = smartContractRunnerFactory;
     _smartContractService       = new SmartContractService(_smartContractManager, _smartContractRunnerFactory, stateStore, _functionMetadataService);
 }
Esempio n. 8
0
 public MockSetup(IStateStore stateStore, IChainCreationService chainCreationService, IDataStore dataStore, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory)
 {
     StateStore                  = stateStore;
     _chainCreationService       = chainCreationService;
     _functionMetadataService    = functionMetadataService;
     _smartContractRunnerFactory = smartContractRunnerFactory;
     _smartContractManager       = new SmartContractManager(dataStore);
     Task.Factory.StartNew(async() =>
     {
         await Init();
     }).Unwrap().Wait();
     SmartContractService = new SmartContractService(_smartContractManager, _smartContractRunnerFactory, stateStore, _functionMetadataService);
     Task.Factory.StartNew(async() =>
     {
         await DeploySampleContracts();
     }).Unwrap().Wait();
 }
Esempio n. 9
0
        public MockSetup(IDataStore dataStore, IChainCreationService chainCreationService,
                         IChainService chainService, IActorEnvironment actorEnvironment,
                         IChainContextService chainContextService, IFunctionMetadataService functionMetadataService,
                         ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger,
                         IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager)
        {
            _logger          = logger;
            _stateStore      = stateStore;
            ActorEnvironment = actorEnvironment;
            if (!ActorEnvironment.Initialized)
            {
                ActorEnvironment.InitActorSystem();
            }
            _hashManager                = hashManager;
            _transactionManager         = transactionManager;
            _chainCreationService       = chainCreationService;
            _chainService               = chainService;
            ChainContextService         = chainContextService;
            _functionMetadataService    = functionMetadataService;
            _smartContractRunnerFactory = smartContractRunnerFactory;
            SmartContractManager        = new SmartContractManager(dataStore);
            Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait();
            SmartContractService =
                new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore,
                                         functionMetadataService);
            Task.Factory.StartNew(async() => { await DeploySampleContracts(); }).Unwrap().Wait();
            ServicePack = new ServicePack()
            {
                ChainContextService      = chainContextService,
                SmartContractService     = SmartContractService,
                ResourceDetectionService = new NewMockResourceUsageDetectionService(),
                StateStore = _stateStore
            };

            // These are only required for workertest
            // other tests use ActorEnvironment
            var workers = new[] { "/user/worker1", "/user/worker2" };

            Worker1 = Sys.ActorOf(Props.Create <Worker>(), "worker1");
            Worker2 = Sys.ActorOf(Props.Create <Worker>(), "worker2");
            Router  = Sys.ActorOf(Props.Empty.WithRouter(new TrackedGroup(workers)), "router");
            Worker1.Tell(new LocalSerivcePack(ServicePack));
            Worker2.Tell(new LocalSerivcePack(ServicePack));
            Requestor = Sys.ActorOf(AElf.Execution.Execution.Requestor.Props(Router));
        }
Esempio n. 10
0
 public ChainCreationEventListener(ILogger logger, ITransactionResultManager transactionResultManager,
                                   IChainCreationService chainCreationService, IChainManagerBasic chainManagerBasic)
 {
     _logger = logger;
     TransactionResultManager = transactionResultManager;
     ChainCreationService     = chainCreationService;
     _chainManagerBasic       = chainManagerBasic;
     _interestedLogEvent      = new LogEvent()
     {
         Address = GetGenesisContractHash(),
         Topics  =
         {
             ByteString.CopyFrom("SideChainCreationRequestApproved".CalculateHash())
         }
     };
     _bloom = _interestedLogEvent.GetBloom();
     InitializeClient();
 }
Esempio n. 11
0
        public MockSetup(IStateStore stateStore, IChainCreationService chainCreationService, IDataStore dataStore, IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory)
        {
            StateStore                  = stateStore;
            _chainCreationService       = chainCreationService;
            ChainContextService         = chainContextService;
            _functionMetadataService    = functionMetadataService;
            _smartContractRunnerFactory = smartContractRunnerFactory;
            SmartContractManager        = new SmartContractManager(dataStore);
            Task.Factory.StartNew(async() =>
            {
                await Init();
            }).Unwrap().Wait();
            SmartContractService = new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore, _functionMetadataService);

            ServicePack = new ServicePack()
            {
                ChainContextService      = chainContextService,
                SmartContractService     = SmartContractService,
                ResourceDetectionService = null,
                StateStore = StateStore
            };
        }
Esempio n. 12
0
 public BlockChainTests_MockSetup(IDataStore dataStore, IChainCreationService chainCreationService,
                                  IChainService chainService,
                                  IChainContextService chainContextService, IFunctionMetadataService functionMetadataService,
                                  ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger,
                                  IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager)
 {
     _logger                     = logger;
     _stateStore                 = stateStore;
     _hashManager                = hashManager;
     _transactionManager         = transactionManager;
     _chainCreationService       = chainCreationService;
     ChainService                = chainService;
     ChainContextService         = chainContextService;
     _functionMetadataService    = functionMetadataService;
     _smartContractRunnerFactory = smartContractRunnerFactory;
     SmartContractManager        = new SmartContractManager(dataStore);
     Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait();
     SmartContractService =
         new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore,
                                  functionMetadataService);
     Task.Factory.StartNew(async() => { await DeploySampleContracts(); }).Unwrap().Wait();
 }
Esempio n. 13
0
 public BlockTest(IChainService chainService, IChainCreationService chainCreationService)
 {
     //_smartContractZero = smartContractZero;
     _chainCreationService = chainCreationService;
     _chainService         = chainService;
 }
Esempio n. 14
0
 public ChainTest(IChainCreationService chainCreationService, IChainService chainService)
 {
     _chainCreationService = chainCreationService;
     _chainService         = chainService;
 }
Esempio n. 15
0
 public ChainCreationServiceTests(IChainCreationService service)
 {
     _service = service;
 }