private List <List <string> > CreateAndSignTransactions(EthereumClient client, List <List <EthECKey> > keyBatches, BigInteger nonceStart) { int taskCount = keyBatches.Count; var tasks = new List <Task <List <string> > >(); for (int t = 0; t < taskCount; t++) { int taskId = t; List <EthECKey> keyBatch = keyBatches[t]; Task <List <string> > task = Task.Run(async() => { var transactions = new List <string>(); for (int i = 0; i < keyBatch.Count; i++) { EthECKey ecKey = keyBatch[i]; BigInteger nonce = nonceStart + i * taskCount + taskId; string tx = await client.CreateMintTransactionAsync(nonce, ecKey.GetPublicAddress(), 1000000); transactions.Add(tx); } return(transactions); }); tasks.Add(task); } var result = new List <List <string> >(); foreach (var task in tasks) { result.Add(task.Result); } return(result); }
public async Task SendMintTransactions() { int count = 30000; var client = new EthereumClient(_client0, ContractAddress, MinterKey); Stopwatch sw = Stopwatch.StartNew(); List <List <EthECKey> > targetKeyBatches = GenerateKeys(count); Debug.WriteLine($"Generated {targetKeyBatches.Sum(x => x.Count)} keys in {sw.Elapsed}"); BigInteger nonceStart = await client.GetCurrentMintingNonceAsync(); sw.Restart(); List <List <string> > transactionBatches = CreateAndSignTransactions(client, targetKeyBatches, nonceStart); Debug.WriteLine($"Created {transactionBatches.Sum(x => x.Count)} transactions in {sw.Elapsed}"); BigInteger blockNumber = await client.GetBlockNumberAsync(); Debug.WriteLine($"BlockNumber on start {blockNumber}"); EthereumClient[] clients = new[] { new EthereumClient(_client0, ContractAddress, MinterKey), new EthereumClient(_client1, ContractAddress, MinterKey), new EthereumClient(_client2, ContractAddress, MinterKey) }; sw.Restart(); List <string> transactionHashes = SendTransactions(clients, transactionBatches); Debug.WriteLine($"Sent {transactionBatches.Sum(x => x.Count)} transactions in {sw.Elapsed}"); }
private List <string> SendTransactions(EthereumClient[] clients, List <List <string> > transactionBatches) { int taskCount = transactionBatches.Count; var tasks = new List <Task <List <string> > >(); for (int t = 0; t < taskCount; t++) { int taskId = t; var transactions = transactionBatches[t]; EthereumClient client = clients[taskId % clients.Length]; Task <List <string> > task = Task.Run(async() => { var hashes = new List <string>(); for (int i = 0; i < transactions.Count; i++) { string transaction = transactions[i]; string hash = await client.SendAsync(transaction); hashes.Add(hash); } return(hashes); }); tasks.Add(task); } var result = new List <string>(); foreach (var task in tasks) { result.AddRange(task.Result); } return(result); }
public ScoringOffersController( IScoringService scoringService, EthereumClient ethereumClient, IClock clock) { _scoringService = scoringService; _ethereumClient = ethereumClient; _clock = clock; }
public TransactionHandlingSaga( EthereumClient ethereumClient, IEthereumTransactionService ethereumTransactionService, ILogger logger) { _ethereumClient = ethereumClient; _ethereumTransactionService = ethereumTransactionService; _logger = logger; }
public EstimatesController( EthereumClient ethereumClient, IEstimationService estimationService, IScoringCriterionRepository scoringCriterionRepository, IClock clock) { _ethereumClient = ethereumClient; _estimationService = estimationService; _scoringCriterionRepository = scoringCriterionRepository; _clock = clock; }
public ExpertsController( IExpertService expertService, EthereumClient ethereumClient, ICountryRepository countryRepository, IUserRepository userRepository) { _ethereumClient = ethereumClient; _expertService = expertService; _ethereumClient = ethereumClient; _countryRepository = countryRepository; _userRepository = userRepository; }
public async Task DumpBlocks() { BigInteger from = 369; var client = new EthereumClient(_client0, ContractAddress, MinterKey); List <string> blocks = await client.DumpBlocksAsync(from, 50); foreach (string block in blocks) { Debug.WriteLine(block); } }
public AdminController( IExpertService expertService, IAdminService adminService, EthereumClient ethereumClient, IAuthenticationService authenticationService, IUserService userService, IMessageSession messageSession) { _adminService = adminService; _ethereumClient = ethereumClient; _expertService = expertService; _authenticationService = authenticationService; _userService = userService; _messageSession = messageSession; }
public EthereumClientIntegrationFixture() { var config = InitConfiguration(); if (config != null) { var ethereumTestSection = config.GetSection("EthereumTestSettings"); if (ethereumTestSection != null) { var ethereumTestSettings = new EthereumTestSettings(); ethereumTestSection.Bind(ethereumTestSettings); if (!string.IsNullOrEmpty(ethereumTestSettings.GethPath)) { GethClientPath = ethereumTestSettings.GethPath; } if (!string.IsNullOrEmpty(ethereumTestSettings.ParityPath)) { ParityClientPath = ethereumTestSettings.ParityPath; } if (!string.IsNullOrEmpty(ethereumTestSettings.AccountAddress)) { AccountAddress = ethereumTestSettings.AccountAddress; } if (!string.IsNullOrEmpty(ethereumTestSettings.AccountPrivateKey)) { AccountPrivateKey = ethereumTestSettings.AccountPrivateKey; } if (!string.IsNullOrEmpty(ethereumTestSettings.ChainId)) { ChainId = BigInteger.Parse(ethereumTestSettings.ChainId); } if (!string.IsNullOrEmpty(ethereumTestSettings.ManagedAccountPassword)) { ManagedAccountPassword = ethereumTestSettings.ManagedAccountPassword; } if (!string.IsNullOrEmpty(ethereumTestSettings.Client)) { EthereumClient = (EthereumClient)Enum.Parse(typeof(EthereumClient), ethereumTestSettings.Client); } if (!string.IsNullOrEmpty(ethereumTestSettings.InfuraNetwork)) { InfuraNetwork = (InfuraNetwork)Enum.Parse(typeof(InfuraNetwork), ethereumTestSettings.InfuraNetwork); } ; if (!string.IsNullOrEmpty(ethereumTestSettings.InfuraId)) { InfuraId = ethereumTestSettings.InfuraId; } if (!string.IsNullOrEmpty(ethereumTestSettings.HttpUrl)) { HttpUrl = ethereumTestSettings.HttpUrl; } } } var client = Environment.GetEnvironmentVariable("ETHEREUM_CLIENT"); if (client == null) { Console.WriteLine("**************TEST CLIENT NOT CONFIGURED IN ENVIRONMENT USING DEFAULT"); } else { Console.WriteLine("************ENVIRONMENT CONFIGURED WITH CLIENT: " + client.ToString()); } if (string.IsNullOrEmpty(client)) { } else if (client == "geth") { EthereumClient = EthereumClient.Geth; Console.WriteLine("********TESTING WITH GETH****************"); } else if (client == "parity") { EthereumClient = EthereumClient.OpenEthereum; Console.WriteLine("******* TESTING WITH PARITY ****************"); } else if (client == "ganache") { EthereumClient = EthereumClient.Ganache; Console.WriteLine("******* TESTING WITH GANACHE ****************"); } if (EthereumClient == EthereumClient.Geth) { var location = typeof(EthereumClientIntegrationFixture).GetTypeInfo().Assembly.Location; var dirPath = Path.GetDirectoryName(location); _exePath = Path.GetFullPath(Path.Combine(dirPath, GethClientPath)); DeleteData(); var psiSetup = new ProcessStartInfo(_exePath, @" --datadir=devChain init genesis_clique.json ") { CreateNoWindow = false, WindowStyle = ProcessWindowStyle.Normal, UseShellExecute = true, WorkingDirectory = Path.GetDirectoryName(_exePath) }; Process.Start(psiSetup); Thread.Sleep(3000); var psi = new ProcessStartInfo(_exePath, @" --nodiscover --rpc --datadir=devChain --rpccorsdomain "" * "" --mine --rpcapi ""eth, web3, personal, net, miner, admin, debug"" --rpcaddr ""0.0.0.0"" --allow-insecure-unlock --unlock 0x12890d2cce102216644c59daE5baed380d84830c --password ""pass.txt"" --ws --wsaddr ""0.0.0.0"" --wsapi ""eth, web3, personal, net, miner, admin, debug"" --wsorigins "" * "" --verbosity 0 console ") { CreateNoWindow = false, WindowStyle = ProcessWindowStyle.Normal, UseShellExecute = true, WorkingDirectory = Path.GetDirectoryName(_exePath) }; _process = Process.Start(psi); } else if (EthereumClient == EthereumClient.OpenEthereum) { var location = typeof(EthereumClientIntegrationFixture).GetTypeInfo().Assembly.Location; var dirPath = Path.GetDirectoryName(location); _exePath = Path.GetFullPath(Path.Combine(dirPath, ParityClientPath)); DeleteData(); var psi = new ProcessStartInfo(_exePath, @" --config node0.toml") // --logging debug") { CreateNoWindow = false, WindowStyle = ProcessWindowStyle.Normal, UseShellExecute = true, WorkingDirectory = Path.GetDirectoryName(_exePath) }; _process = Process.Start(psi); Thread.Sleep(10000); } else if (EthereumClient == EthereumClient.Ganache) { var psi = new ProcessStartInfo("ganache-cli") { CreateNoWindow = false, WindowStyle = ProcessWindowStyle.Normal, UseShellExecute = true, WorkingDirectory = _exePath, Arguments = " --account=" + AccountPrivateKey + ",10000000000000000000000" }; _process = Process.Start(psi); Thread.Sleep(10000); } Thread.Sleep(3000); }
public BalanceController(IEtherManagerContractClient etherManagerContractClient, EthereumClient ethereumClient) { _etherManagerContractClient = etherManagerContractClient; _ethereumClient = ethereumClient; }
public EthereumClientIntegrationFixture() { var config = InitConfiguration(); if (config != null) { var ethereumTestSection = config.GetSection("EthereumTestSettings"); if (ethereumTestSection != null) { var ethereumTestSettings = new EthereumTestSettings(); ethereumTestSection.Bind(ethereumTestSettings); if (!string.IsNullOrEmpty(ethereumTestSettings.GethPath)) { GethClientPath = ethereumTestSettings.GethPath; } if (!string.IsNullOrEmpty(ethereumTestSettings.ParityPath)) { ParityClientPath = ethereumTestSettings.ParityPath; } } } var client = Environment.GetEnvironmentVariable("ETHEREUM_CLIENT"); if (client == null) { Console.WriteLine("**************TEST CLIENT NOT CONFIGURED IN ENVIRONMENT USING DEFAULT"); } else { Console.WriteLine("************ ENVIRONMENT CONFIGURED WITH CLIENT: " + client.ToString()); } if (string.IsNullOrEmpty(client)) { EthereumClient = EthereumClient.Geth; } else if (client == "geth") { EthereumClient = EthereumClient.Geth; Console.WriteLine("********TESTING WITH GETH****************"); } else { EthereumClient = EthereumClient.Parity; Console.WriteLine("******* TESTING WITH PARITY ****************"); } if (EthereumClient == EthereumClient.Geth) { var location = typeof(EthereumClientIntegrationFixture).GetTypeInfo().Assembly.Location; var dirPath = Path.GetDirectoryName(location); _exePath = Path.GetFullPath(Path.Combine(dirPath, GethClientPath)); DeleteData(); var psiSetup = new ProcessStartInfo(Path.Combine(_exePath, "geth.exe"), @"--datadir=devChain init genesis_clique.json ") { CreateNoWindow = false, WindowStyle = ProcessWindowStyle.Normal, UseShellExecute = true, WorkingDirectory = _exePath }; Process.Start(psiSetup); Thread.Sleep(3000); var psi = new ProcessStartInfo(Path.Combine(_exePath, "geth.exe"), @" --nodiscover --rpc --datadir=devChain --rpccorsdomain "" * "" --mine --rpcapi ""eth, web3, personal, net, miner, admin, debug"" --rpcaddr ""0.0.0.0"" --allow-insecure-unlock --unlock 0x12890d2cce102216644c59daE5baed380d84830c --password ""pass.txt"" --ws --wsaddr ""0.0.0.0"" --wsapi ""eth, web3, personal, net, miner, admin, debug"" --wsorigins "" * "" --verbosity 0 console ") { CreateNoWindow = false, WindowStyle = ProcessWindowStyle.Normal, UseShellExecute = true, WorkingDirectory = _exePath }; _process = Process.Start(psi); } else { var location = typeof(EthereumClientIntegrationFixture).GetTypeInfo().Assembly.Location; var dirPath = Path.GetDirectoryName(location); _exePath = Path.GetFullPath(Path.Combine(dirPath, ParityClientPath)); //DeleteData(); var psi = new ProcessStartInfo(Path.Combine(_exePath, "parity.exe"), @" --config node0.toml") // --logging debug") { CreateNoWindow = false, WindowStyle = ProcessWindowStyle.Normal, UseShellExecute = true, WorkingDirectory = _exePath }; _process = Process.Start(psi); Thread.Sleep(10000); } Thread.Sleep(3000); }