New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd, node: initialize ports with --instance #29268
base: master
Are you sure you want to change the base?
Conversation
d625efe
to
78f172e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how this flag would be useful when running multiple local nodes on the same host. Because the main use-case for this is for testing, I would opt to not include this flag in Geth.
cmd/utils/flags.go
Outdated
@@ -114,6 +114,13 @@ var ( | |||
Usage: "Minimum free disk space in MB, once reached triggers auto shut down (default = --cache.gc converted to MB, 0 = disabled)", | |||
Category: flags.EthCategory, | |||
} | |||
InstanceFlag = &cli.IntFlag{ | |||
Name: "instance", | |||
Usage: "Configures the ports to avoid conflicts when running multiple nodes on the same machine. Maximum is 200. Only applicable for: port, authrpc.port, discovery,port, http.port, ws.port", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a complete explanation of what this flag does, similarly to the full description from reth
:
Add a new instance of a node.
Configures the ports of the node to avoid conflicts with the defaults. This is useful for running multiple nodes on the same machine.
Max number of instances is 200. It is chosen in a way so that it's not possible to have port numbers that conflict with each other.
Changes to the following port numbers: - DISCOVERY_PORT: default + `instance` - 1 - AUTH_PORT: default + `instance` * 100 - 100 - HTTP_RPC_PORT: default - `instance` + 1 - WS_RPC_PORT: default + `instance` * 2 - 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amended.
Primarily, I think users would need to run multiple nodes in this scenario:
For me, I encountered the need to run multiple nodes when I was running 1 mainnet node and 2 testnet nodes. So having this flag would save me some time figuring out the correct ports. For users that are not that familiar with ports, this will save them some trouble. |
cmd/utils, node: const for listen and disc ports amend usage description
e916a02
to
24c4018
Compare
Description
This PR adds a new CLI flag called
--instance <value>
, used to configure ports when running multiple nodes on the same machine to avoid port conflicts. This is only applicable forport, authrpc.port, discovery,port, http.port, ws.port
.The calculation of port numbers is as follows:
In a scenario where the user specify both
--instance
and the supported port list (i.e.port, authrpc.port, ...
), then the ports specified will supersede the port values configured by--instance
.Example
Usage:
geth --instance 2
Usage:
geth --instance 2 --authrpc.port 8551
Usage:
geth --instance 201
Credits
This flag is inspired by reth.