public void Setup() { _container?.Dispose(); TestUtils.DeleteTestChainData(); _eventData = new Dictionary <UInt256, ByteString>(); var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager( Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.json"), new RunOptions() )); containerBuilder.RegisterModule <BlockchainModule>(); containerBuilder.RegisterModule <ConfigModule>(); containerBuilder.RegisterModule <StorageModule>(); _container = containerBuilder.Build(); _blockManager = _container.Resolve <IBlockManager>(); _transactionBuilder = _container.Resolve <ITransactionBuilder>(); _stateManager = _container.Resolve <IStateManager>(); _wallet = _container.Resolve <IPrivateWallet>(); _transactionPool = _container.Resolve <ITransactionPool>(); _configManager = _container.Resolve <IConfigManager>(); // set chainId from config if (TransactionUtils.ChainId(false) == 0) { var chainId = _configManager.GetConfig <NetworkConfig>("network")?.ChainId; var newChainId = _configManager.GetConfig <NetworkConfig>("network")?.NewChainId; TransactionUtils.SetChainId((int)chainId !, (int)newChainId !); HardforkHeights.SetHardforkHeights(_configManager.GetConfig <HardforkConfig>("hardfork") ?? throw new InvalidOperationException()); StakingContract.Initialize(_configManager.GetConfig <NetworkConfig>("network") ?? throw new InvalidOperationException()); CycleDuration = StakingContract.CycleDuration; } }
public void Setup() { _container?.Dispose(); TestUtils.DeleteTestChainData(); var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager( Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.json"), new RunOptions() )); containerBuilder.RegisterModule <BlockchainModule>(); containerBuilder.RegisterModule <ConfigModule>(); containerBuilder.RegisterModule <StorageModule>(); _container = containerBuilder.Build(); _blockManager = _container.Resolve <IBlockManager>(); _stateManager = _container.Resolve <IStateManager>(); _wallet = _container.Resolve <IPrivateWallet>(); _transactionPool = _container.Resolve <ITransactionPool>(); _configManager = _container.Resolve <IConfigManager>(); // set chainId from config if (TransactionUtils.ChainId(false) == 0) { var chainId = _configManager.GetConfig <NetworkConfig>("network")?.ChainId; var newChainId = _configManager.GetConfig <NetworkConfig>("network")?.ChainId; TransactionUtils.SetChainId((int)chainId !, (int)newChainId !); HardforkHeights.SetHardforkHeights(_configManager.GetConfig <HardforkConfig>("hardfork") ?? throw new InvalidOperationException()); } _validatorStatusManager = new ValidatorStatusManager( _transactionPool, _container.Resolve <ITransactionSigner>(), _container.Resolve <ITransactionBuilder>(), _wallet, _stateManager, _container.Resolve <IValidatorAttendanceRepository>(), _container.Resolve <ISystemContractReader>() ); }
public void Setup() { _container?.Dispose(); TestUtils.DeleteTestChainData(); var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager( Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.json"), new RunOptions() )); containerBuilder.RegisterModule <ConfigModule>(); _container = containerBuilder.Build(); _configManager = _container.Resolve <IConfigManager>(); if (TransactionUtils.ChainId(false) == 0) { var chainId = _configManager.GetConfig <NetworkConfig>("network")?.ChainId; var newChainId = _configManager.GetConfig <NetworkConfig>("network")?.NewChainId; TransactionUtils.SetChainId((int)chainId !, (int)newChainId !); HardforkHeights.SetHardforkHeights(_configManager.GetConfig <HardforkConfig>("hardfork") ?? throw new InvalidOperationException()); } Console.WriteLine($"old chain id: {TransactionUtils.ChainId(false)}, new chain id: {TransactionUtils.ChainId(true)}"); }
public static JObject Web3UnsignedTransaction(Transaction tx, bool useNewChainId) { return(new JObject { ["from"] = Web3Data(tx.From), ["gas"] = Web3Number(tx.GasLimit), ["gasPrice"] = Web3Number(tx.GasPrice), ["data"] = Web3Data(tx.Invocation), ["nonce"] = Web3Number(tx.Nonce), ["to"] = tx.To.Buffer.IsEmpty ? null : Web3Data(tx.To), ["value"] = Web3Number(tx.Value), ["chainId"] = TransactionUtils.ChainId(useNewChainId), }); }
public void Setup() { _container?.Dispose(); TestUtils.DeleteTestChainData(); var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager( Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config2.json"), new RunOptions() )); containerBuilder.RegisterModule <BlockchainModule>(); containerBuilder.RegisterModule <ConfigModule>(); containerBuilder.RegisterModule <StorageModule>(); _container = containerBuilder.Build(); _configManager = _container.Resolve <IConfigManager>(); _stateManager = _container.Resolve <IStateManager>(); _contractRegisterer = _container.Resolve <IContractRegisterer>(); _privateWallet = _container.Resolve <IPrivateWallet>(); _snapshotIndexer = _container.Resolve <ISnapshotIndexRepository>(); _systemContractReader = _container.Resolve <ISystemContractReader>(); _transactionManager = _container.Resolve <ITransactionManager>(); _transactionBuilder = _container.Resolve <ITransactionBuilder>(); _transactionSigner = _container.Resolve <ITransactionSigner>(); _transactionPool = _container.Resolve <ITransactionPool>(); _blockManager = _container.Resolve <IBlockManager>(); // set chainId from config if (TransactionUtils.ChainId(false) == 0) { var chainId = _configManager.GetConfig <NetworkConfig>("network")?.ChainId; var newChainId = _configManager.GetConfig <NetworkConfig>("network")?.ChainId; TransactionUtils.SetChainId((int)chainId !, (int)newChainId !); HardforkHeights.SetHardforkHeights(_configManager.GetConfig <HardforkConfig>("hardfork") ?? throw new InvalidOperationException()); } ServiceBinder.BindService <GenericParameterAttributes>(); _apiService = new AccountServiceWeb3(_stateManager, _snapshotIndexer, _contractRegisterer, _systemContractReader, _transactionPool); _transactionApiService = new TransactionServiceWeb3(_stateManager, _transactionManager, _transactionBuilder, _transactionSigner, _transactionPool, _contractRegisterer, _privateWallet); _blockManager.TryBuildGenesisBlock(); }
public string NetVersion() { return(TransactionUtils.ChainId(HardforkHeights.IsHardfork_9Active(_blockManager.GetHeight() + 1)).ToHex()); }