Skip to content

cmd, node: initialize ports with --instance#2298

Merged
zzzckck merged 2 commits intobnb-chain:developfrom
weiihann:develop/instance
Mar 21, 2024
Merged

cmd, node: initialize ports with --instance#2298
zzzckck merged 2 commits intobnb-chain:developfrom
weiihann:develop/instance

Conversation

@weiihann
Copy link
Copy Markdown
Contributor

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 for port, authrpc.port, discovery,port, http.port, ws.port.

The calculation of port numbers is as follows:

authrpc.port = 8551 (default) + `instance`*100 - 100
http.port = 8545 (default) - `instance` + 1
ws.port = 8546 (default) + `instance`*2 - 2
port = 30303 (default) + `instance` - 1
discovery.port = 30303 (default) + `instance` - 1

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

authrpc.port = 8651
http.port = 8544
ws.port = 8548
port = 30304
discovery.port = 30304

Usage: geth --instance 2 --authrpc.port 8551

authrpc.port = 8551
http.port = 8544
ws.port = 8548
port = 30304
discovery.port = 30304

Usage: geth --instance 201

Fatal: Instance number 201 is too high, maximum is 200

Credits

This flag is inspired by reth.

zzzckck
zzzckck previously approved these changes Mar 19, 2024
zlacfzy
zlacfzy previously approved these changes Mar 21, 2024
@zzzckck zzzckck dismissed stale reviews from zlacfzy and themself via 445a0b1 March 21, 2024 03:47
@zzzckck zzzckck merged commit 1208d07 into bnb-chain:develop Mar 21, 2024
@Pjrich1313 Pjrich1313 mentioned this pull request Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants