Separate port for geth listening

This commit is contained in:
benbierens 2023-10-27 08:33:07 +02:00
parent 9b1ab3185f
commit a362eb1e96
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
6 changed files with 24 additions and 4 deletions

View File

@ -31,7 +31,10 @@ namespace CodexContractsPlugin
try
{
return DeployContract(container, workflow, gethNode);
var result = DeployContract(container, workflow, gethNode);
workflow.Stop(containers);
Log("Container stopped.");
return result;
}
catch (Exception ex)
{

View File

@ -9,6 +9,7 @@ namespace GethPlugin
public const string HttpPortTag = "http_port";
public const string DiscoveryPortTag = "disc_port";
public const string ListenPortTag = "listen_port";
public const string WsPortTag = "ws_port";
public const string AuthRpcPortTag = "auth_rpc_port";
public const string AccountsFilename = "accounts.csv";
@ -32,10 +33,11 @@ namespace GethPlugin
var httpPort = CreateApiPort(config, tag: HttpPortTag);
var discovery = CreateDiscoveryPort(config);
var listen = CreateListenPort(config);
var authRpc = CreateP2pPort(config, tag: AuthRpcPortTag);
var wsPort = CreateP2pPort(config, tag: WsPortTag);
var args = $"--http.addr 0.0.0.0 --http.port {httpPort.Number} --port {discovery.Number} --discovery.port {discovery.Number} {GetTestNetArgs(config)} {defaultArgs}";
var args = $"--http.addr 0.0.0.0 --http.port {httpPort.Number} --port {listen.Number} --discovery.port {discovery.Number} {GetTestNetArgs(config)} {defaultArgs}";
if (config.BootstrapNode != null)
{
@ -73,6 +75,13 @@ namespace GethPlugin
return AddExposedPort(config.IsPublicTestNet.DiscoveryPort, DiscoveryPortTag, PortProtocol.UDP);
}
private Port CreateListenPort(GethStartupConfig config)
{
if (config.IsPublicTestNet == null) return AddInternalPort(ListenPortTag);
return AddExposedPort(config.IsPublicTestNet.ListenPort, ListenPortTag);
}
private Port CreateP2pPort(GethStartupConfig config, string tag)
{
if (config.IsPublicTestNet != null)

View File

@ -42,14 +42,16 @@
public class GethTestNetConfig
{
public GethTestNetConfig(string publicIp, int discoveryPort)
public GethTestNetConfig(string publicIp, int discoveryPort, int listenPort)
{
PublicIp = publicIp;
DiscoveryPort = discoveryPort;
ListenPort = listenPort;
}
public string PublicIp { get; }
public int DiscoveryPort { get; }
public int ListenPort { get; }
}
public class GethBootstrapNode

View File

@ -101,6 +101,9 @@ namespace CodexNetDeployer
[Uniform("public-gethdiscport", "pgdp", "PUBLICGETHDISCPORT", false, "Required if public-testnet is true. Single port number used for Geth's public discovery port.")]
public int PublicGethDiscPort { get; set; }
[Uniform("public-gethlistenport", "pglp", "PUBLICGETHLISTENPORT", false, "Required if public-testnet is true. Single port number used for Geth's public listen port.")]
public int PublicGethListenPort { get; set; }
[Uniform("discord-bot", "dbot", "DISCORDBOT", false, "If true, will deploy discord bot. Default is false.")]
public bool DeployDiscordBot { get; set; } = false;
@ -151,6 +154,7 @@ namespace CodexNetDeployer
if (PublicDiscPorts.Split(",").Length != NumberOfCodexNodes) errors.Add("Number of public discovery-ports provided does not match number of codex nodes.");
if (PublicListenPorts.Split(",").Length != NumberOfCodexNodes) errors.Add("Number of public listen-ports provided does not match number of codex nodes.");
if (PublicGethDiscPort == 0) errors.Add("Geth public discovery port is not set.");
if (PublicGethListenPort == 0) errors.Add("Geth public listen port is not set.");
}
if (DeployDiscordBot)

View File

@ -114,7 +114,8 @@ namespace CodexNetDeployer
{
s.AsPublicTestNet(new GethTestNetConfig(
publicIp: config.PublicGethIP,
discoveryPort: config.PublicGethDiscPort
discoveryPort: config.PublicGethDiscPort,
listenPort: config.PublicGethListenPort
));
}
});

View File

@ -21,6 +21,7 @@ dotnet run \
--public-listenports=20011,20021,20031 \
--public-gethip=1.2.3.5 \
--public-gethdiscport=20040 \
--public-gethlistenport=20041 \
\
--discord-bot=1 \
--dbot-token=tokenhere \