2023-04-14 07:54:07 +00:00
|
|
|
|
using KubernetesWorkflow;
|
|
|
|
|
|
|
|
|
|
namespace DistTestCore.Marketplace
|
|
|
|
|
{
|
|
|
|
|
public class GethContainerRecipe : ContainerRecipeFactory
|
|
|
|
|
{
|
2023-04-14 10:37:05 +00:00
|
|
|
|
public const string DockerImage = "thatbenbierens/geth-confenv:latest";
|
2023-04-14 08:51:35 +00:00
|
|
|
|
public const string HttpPortTag = "http_port";
|
2023-04-17 08:31:14 +00:00
|
|
|
|
public const string DiscoveryPortTag = "disc_port";
|
2023-04-14 07:54:07 +00:00
|
|
|
|
public const string AccountFilename = "account_string.txt";
|
|
|
|
|
public const string GenesisFilename = "genesis.json";
|
2023-04-18 11:22:41 +00:00
|
|
|
|
public const string BootstrapPrivateKeyFilename = "bootstrap_private.key";
|
|
|
|
|
|
2023-04-14 10:37:05 +00:00
|
|
|
|
protected override string Image => DockerImage;
|
2023-04-14 07:54:07 +00:00
|
|
|
|
|
|
|
|
|
protected override void Initialize(StartupConfig startupConfig)
|
|
|
|
|
{
|
|
|
|
|
var config = startupConfig.Get<GethStartupConfig>();
|
|
|
|
|
|
|
|
|
|
var args = CreateArgs(config);
|
|
|
|
|
|
|
|
|
|
AddEnvVar("GETH_ARGS", args);
|
|
|
|
|
AddEnvVar("GENESIS_JSON", config.GenesisJsonBase64);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string CreateArgs(GethStartupConfig config)
|
|
|
|
|
{
|
2023-04-17 08:31:14 +00:00
|
|
|
|
var discovery = AddInternalPort(tag: DiscoveryPortTag);
|
|
|
|
|
|
2023-04-14 07:54:07 +00:00
|
|
|
|
if (config.IsBootstrapNode)
|
|
|
|
|
{
|
|
|
|
|
AddEnvVar("IS_BOOTSTRAP", "1");
|
2023-04-17 14:28:07 +00:00
|
|
|
|
var exposedPort = AddExposedPort(tag: HttpPortTag);
|
2023-04-17 08:31:14 +00:00
|
|
|
|
return $"--http.port {exposedPort.Number} --discovery.port {discovery.Number} --nodiscover";
|
2023-04-14 07:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var port = AddInternalPort();
|
|
|
|
|
var authRpc = AddInternalPort();
|
2023-04-14 08:51:35 +00:00
|
|
|
|
var httpPort = AddInternalPort(tag: HttpPortTag);
|
2023-04-17 08:31:14 +00:00
|
|
|
|
|
|
|
|
|
var bootPubKey = config.BootstrapNode.PubKey;
|
|
|
|
|
var bootIp = config.BootstrapNode.RunningContainers.Containers[0].Pod.Ip;
|
|
|
|
|
var bootPort = config.BootstrapNode.DiscoveryPort.Number;
|
|
|
|
|
var bootstrapArg = $"--bootnodes enode://{bootPubKey}@{bootIp}:{bootPort}";
|
|
|
|
|
// geth --bootnodes enode://pubkey1@ip1:port1
|
|
|
|
|
|
|
|
|
|
return $"--port {port.Number} --discovery.port {discovery.Number} --authrpc.port {authRpc.Number} --http.port {httpPort.Number} --nodiscover {bootstrapArg}";
|
2023-04-14 07:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|