diff --git a/Framework/NethereumWorkflow/NethereumInteractionCreator.cs b/Framework/NethereumWorkflow/NethereumInteractionCreator.cs index bd7d2d97..1f7c3482 100644 --- a/Framework/NethereumWorkflow/NethereumInteractionCreator.cs +++ b/Framework/NethereumWorkflow/NethereumInteractionCreator.cs @@ -1,6 +1,7 @@ using BlockchainUtils; using Logging; using Nethereum.Web3; +using Utils; namespace NethereumWorkflow { @@ -27,6 +28,12 @@ namespace NethereumWorkflow return new NethereumInteraction(log, CreateWeb3(), blockCache); } + public EthAddress GetEthAddress() + { + var account = new Nethereum.Web3.Accounts.Account(privateKey); + return new EthAddress(account.Address); + } + private Web3 CreateWeb3() { var account = new Nethereum.Web3.Accounts.Account(privateKey); diff --git a/ProjectPlugins/GethPlugin/GethNode.cs b/ProjectPlugins/GethPlugin/GethNode.cs index 6f307eef..970bb3b2 100644 --- a/ProjectPlugins/GethPlugin/GethNode.cs +++ b/ProjectPlugins/GethPlugin/GethNode.cs @@ -13,6 +13,7 @@ namespace GethPlugin public interface IGethNode : IHasContainer { GethDeployment StartResult { get; } + EthAddress CurrentAddress { get; } Ether GetEthBalance(); Ether GetEthBalance(IHasEthAddress address); @@ -46,10 +47,12 @@ namespace GethPlugin this.log = log; this.blockCache = blockCache; StartResult = startResult; + CurrentAddress = new EthAddress(startResult.Account.Account); } public GethDeployment StartResult { get; } public RunningContainer Container => StartResult.Container; + public EthAddress CurrentAddress { get; } public GethBootstrapNode GetBootstrapRecord() { @@ -97,6 +100,7 @@ namespace GethPlugin public GethDeployment StartResult => throw new NotImplementedException(); public RunningContainer Container => throw new NotImplementedException(); + public EthAddress CurrentAddress { get; } public CustomGethNode(ILog log, BlockCache blockCache, string gethHost, int gethPort, string privateKey) { @@ -105,6 +109,9 @@ namespace GethPlugin this.gethHost = gethHost; this.gethPort = gethPort; this.privateKey = privateKey; + + var creator = new NethereumInteractionCreator(log, blockCache, gethHost, gethPort, privateKey); + CurrentAddress = creator.GetEthAddress(); } public GethBootstrapNode GetBootstrapRecord() diff --git a/ProjectPlugins/GethPlugin/GethStarter.cs b/ProjectPlugins/GethPlugin/GethStarter.cs index 0083c011..468e1f75 100644 --- a/ProjectPlugins/GethPlugin/GethStarter.cs +++ b/ProjectPlugins/GethPlugin/GethStarter.cs @@ -1,16 +1,19 @@ using BlockchainUtils; using Core; using KubernetesWorkflow; +using Logging; namespace GethPlugin { public class GethStarter { private readonly IPluginTools tools; + private readonly ILog log; public GethStarter(IPluginTools tools) { this.tools = tools; + log = new LogPrefixer(tools.GetLog(), $"({nameof(GethStarter)}) "); } public GethDeployment StartGeth(GethStartupConfig gethStartupConfig) @@ -26,7 +29,7 @@ namespace GethPlugin if (containers.Containers.Length != 1) throw new InvalidOperationException("Expected 1 Geth bootstrap node to be created. Test infra failure."); var container = containers.Containers[0]; - var extractor = new GethContainerInfoExtractor(tools.GetLog(), workflow, container); + var extractor = new GethContainerInfoExtractor(log, workflow, container); var account = extractor.ExtractAccounts().Accounts.First(); var pubKey = extractor.ExtractPubKey(); @@ -45,12 +48,14 @@ namespace GethPlugin public IGethNode WrapGethContainer(GethDeployment startResult, BlockCache blockCache) { startResult = SerializeGate.Gate(startResult); - return new DeploymentGethNode(tools.GetLog(), blockCache, startResult); + var node = new DeploymentGethNode(tools.GetLog(), blockCache, startResult); + Log($"EthAddress: {node.CurrentAddress}"); + return node; } private void Log(string msg) { - tools.GetLog().Log(msg); + log.Log(msg); } } }