Chain Port Prefixes

List of port prefixes for each Cosmos ecosystem chain, and instructions for changing them quickly.

Rationale

Node operators in the Cosmos ecosystem often wants to run multiple Cosmos SDK-based nodes on the sames server to save cost.

The Cosmos SDK init command will generate config.toml and app.toml for each node. Without revision, the ports in these files will conflict with each other if multiple nodes are ran on the same server.

This project is an attempt to standardize these ports while avoiding port conflict. While any random non-conflicting ports can do, a standardized port prefix system can make the port assignment more predictable. Moreover, if two node operators follow the same system, they can easily exchange deployment scripts without breaking codes.

How to Use

The best way to use the port prefix system is to use Ansible deployment script.

You can also change these 9 ports (5 in config.toml and 4 in app.toml) manually. See below.

config.toml:
  'laddr = "tcp://0.0.0.0:26656"': 'laddr = "tcp://0.0.0.0:{{ custom_port_prefix }}56"' # also use this port for external_address 
  'laddr = "tcp://127.0.0.1:26657"': 'laddr = "tcp://0.0.0.0:{{ custom_port_prefix }}57"''proxy_app = "tcp://127.0.0.1:26658"': 'proxy_app = "tcp://127.0.0.1:{{ custom_port_prefix }}58"''prometheus_listen_addr = ":26660"': 'prometheus_listen_addr = ":{{ custom_port_prefix }}61"''pprof_laddr = "localhost:6060"': 'pprof_laddr = "localhost:{{ custom_port_prefix }}60"'app.toml:
  'address = "tcp://0.0.0.0:1317"': 'address = "tcp://0.0.0.0:{{ custom_port_prefix }}17"''address = ":8080"': 'address = ":{{ custom_port_prefix }}80"''address = "0.0.0.0:9090"': 'address = "0.0.0.0:{{ custom_port_prefix }}90"''address = "0.0.0.0:9091"': 'address = "0.0.0.0:{{ custom_port_prefix }}91"'

Example Usage:

  • In your terminal, set the following environment variable:

export NODES_NUM=”0”
# where 0 is replaced by your chains port prefix

source ~/.zshrc
  • then, run the following sed commands to replace our ports in config.toml:

sed -i.bak -e "\
s%^proxy_app = \"tcp://127.0.0.1:26658\"%proxy_app = \"tcp://127.0.0.1:$((NODES_NUM+0))58\"%; \
s%^laddr = \"tcp://127.0.0.1:26657\"%laddr = \"tcp://0.0.0.0:$((NODES_NUM+0))57\"%; \
s%^pprof_laddr = \"localhost:6060\"%pprof_laddr = \"localhost:$((NODES_NUM+0))60\"%; \
s%^laddr = \"tcp://0.0.0.0:26656\"%laddr = \"tcp://0.0.0.0:$((NODES_NUM+0))56\"%; \
s%^prometheus_listen_addr = \":26660\"%prometheus_listen_addr = \":$((NODES_NUM+0))60\"%" $HOME/.stchaind/config/config.toml
  • we'll repeat this for app.toml:

sed -i.bak -e "\
s%^address = \"tcp://0.0.0.0:1317\"%address = \"tcp://0.0.0.0:$((NODES_NUM))17\"%; \
s%^address = \":8080\"%address = \":$((NODES_NUM))80\"%; \
s%^address = \"0.0.0.0:9090\"%address = \"0.0.0.0:$((NODES_NUM))90\"%; \
s%^address = \"0.0.0.0:9091\"%address = \"0.0.0.0:$((NODES_NUM))91\"%" $HOME/.stchaind/config/app.toml

Supported Chains and Prefixes

Note: Please do not use 266 as port prefix because this is the default Tendermint port prefix.

JSON API

Last updated

Logo

Made with ❤️ by WhisperNode // © 2024.