Skip to content

A port replacer (or resetter) for app.toml and config.toml files, used in Tendermint or CometBFT-based protocols. Also includes a variant for the Namada chain in a separate branch.

License

Notifications You must be signed in to change notification settings

zenodeapp/port-shifter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Port Shifter

A port replacer (or resetter) for the configuration files used in Tendermint or CometBFT-based protocols.

This has been written by ZENODE and is licensed under the MIT-license (see LICENSE.md).

Overview

It can get quite time-consuming to replace the ports inside of the app.toml, config.toml and client.toml files if you plan on running multiple nodes. This small repository aims to solve this problem by providing two scripts; both having the same purpose of simplifying the process of replacing the port values.

This wizard can either increment all ports by a common value or let the user customize each port individually. It will start by asking whether you'd like to customize each port individually or not and continue from there.

This script can be run using:

sh shift-wizard.sh <path_to_config_dir>

<path_to_config_dir> can either be an absolute or relative path towards the directory containing the app.toml, config.toml and client.toml files.

Tip

If you made a mess of all your ports, then you can reset the ports to their default values by giving it an increment of 0.

If you're in a limited or restrictive environment or do not trust running "complex" scripts then use this one instead. It is only capable of incrementing all port values, but can also be edited if one desires to edit every port individually by just changing the values for every port variable inside of the file and keeping the increment value at 0.

This script can be run using:

sh quick-shift.sh <path_to_config_dir> [port_increment_value]

[port_increment_value] is optional and defaults to 0, which will reset all the ports to their default values.

Support

Here follows a list of all the ports that are currently supported, with their default values:

# config.toml
proxy_app                    = 26658
[rpc] laddr                  = 26657
pprof_laddr                  = 6060
[p2p] laddr                  = 26656
prometheus_listen_addr       = 26660

# app.toml
[api] address                = 1317
[rosetta] address            = 8080
[grpc] address               = 9090
[grpc-web] address           = 9091
[json-rpc] address           = 8545
[json-rpc] ws-address        = 8546
[json-rpc] metrics-address   = 6065

Logic

for port replacement

Important

These scripts make a backup of the .toml files (as .toml.bak files), but do not take in account what ports were already configured when incrementing. Therefore the new ports get calculated using the default port values stated in the script itself and not what you already had configured.

The logic for the sed-commands is to always look for the last colon (:). That way we only replace the :port part, without having to worry about overwriting pre-configured ip-addresses that use localhost, IPv4 or IPv6 formatted addresses or protocols like https:// and tcp://.

for identical keys

The lines that have the same key name are separated from one another by checking under which section they belong (for instance the key address gets used multiple times in e.g. [api], [grpc] and [rosetta]).


— ZEN

Copyright (c) 2024 ZENODE

About

A port replacer (or resetter) for app.toml and config.toml files, used in Tendermint or CometBFT-based protocols. Also includes a variant for the Namada chain in a separate branch.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages