-
Notifications
You must be signed in to change notification settings - Fork 352
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
Gaiad manager #928
Merged
Merged
Gaiad manager #928
Changes from 21 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
9e06b07
gm first stab
greg-szabo 5ffaa73
Shellism fixes
greg-szabo 6245e04
new features implemented
greg-szabo ebf1e1f
Compatibility with the full-mesh tool's different naming convention
greg-szabo 18743dd
Final feature set, bugfixes
greg-szabo 7f7a730
config fix
greg-szabo 60e0c37
[global]
greg-szabo da26b86
Config update, README added
greg-szabo e612afc
CHANGELOG update
greg-szabo 449780e
Merge branch 'master' into greg/local-gaiad-manager
greg-szabo 9934f04
fluff
greg-szabo 05be29a
Merge branch 'master' into greg/local-gaiad-manager
greg-szabo 7960bc5
Merge branch 'master' into greg/local-gaiad-manager
greg-szabo 86533a2
Merge branch 'master' into greg/local-gaiad-manager
greg-szabo b24b449
colin's fixes
greg-szabo a8edcde
fix hemres config ID
greg-szabo 8b5e87a
fixes-fixes and new feature unsafe-reset
greg-szabo 77e5529
default typo fix
greg-szabo f8ed012
README update: full-mesh config
greg-szabo f219334
fix dash issue
greg-szabo 6324fe9
typo fix
greg-szabo 6e6a534
Update scripts/gm/README.md
greg-szabo a4c3555
Added rm command, renamed reset command, added wallet_mnemonics confi…
greg-szabo d15a902
shell suport fix
greg-szabo 956c95f
better log command, goes to end normally
greg-szabo 9872c5c
log command fix
greg-szabo 827704c
wallet_hdpath added
greg-szabo 6c2101a
denom issue workaround
greg-szabo 62c3475
comments about tr
greg-szabo 777ab75
remove supply from genesis as a workaround
greg-szabo d1a3c25
Added GRPC-Web port support
greg-szabo 2ccf8ae
Update scripts/gm/bin/gm
greg-szabo ecc07f6
Update scripts/gm/bin/lib-gm
greg-szabo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,298 @@ | ||
# Gaiad Manager `gm` | ||
|
||
## TL;DR | ||
* Tool to manage local gaiad instances - no Docker needed. | ||
* `scripts/gm/bin/gm install` to install it. Follow the instructions there for dependencies. | ||
* `gm start` to start the example configuration of one validator and one full node on your local machine. | ||
* Config file is in `$HOME/.gm/gm.toml` play around and add more nodes. | ||
* Tab completion is pretty good, use it! Or run `gm` by itself for help. | ||
* Pre-1.0 warning: Got a shell error? [Raise an issue!](https://github.com/informalsystems/ibc-rs/issues/) | ||
|
||
## Overview | ||
Gaiad Manager (`gm` from now on) is an easily configurable command-line tool (CLI) that helps manage local `gaiad` | ||
networks. | ||
|
||
Typical problems running multiple `gaiad` instances involve: | ||
* Identifying binaries and configurations for startup and nodes on the system for shutdown. | ||
* Managing port allocations on the local machine. | ||
* Copying and setting up configurations among nodes on the same network. | ||
* Managing `hermes` configuration for IBC. | ||
|
||
`gm` solves this by using a unified configuration file that describes the nodes and their relationship and automating | ||
configuration updates. | ||
|
||
## Requirements | ||
* Bourne shell (`sh`) | ||
* [`sconfig`](https://github.com/freshautomations/sconfig/releases) and | ||
[`stoml`](https://github.com/freshautomations/stoml/releases) installed in your PATH (put them in `/usr/local/bin`) | ||
* `sed` (trying to remove this dependency in the future) | ||
* For shell-completion Bourne Again Shell (`bash`) for the local user (`zsh` shell-completion is coming) | ||
|
||
## How to run | ||
1. Install the dependencies. | ||
|
||
On MacOS: | ||
```bash | ||
curl -Lo /usr/local/bin/sconfig https://github.com/freshautomations/sconfig/releases/download/v0.1.0/sconfig_darwin_amd64 | ||
curl -Lo /usr/local/bin/stoml https://github.com/freshautomations/stoml/releases/download/v0.6.1/stoml_darwin_amd64 | ||
chmod 755 /usr/local/bin/sconfig | ||
chmod 755 /usr/local/bin/stoml | ||
``` | ||
On Linux: | ||
```bash | ||
curl -Lo /usr/local/bin/sconfig https://github.com/freshautomations/sconfig/releases/download/v0.1.0/sconfig_linux_amd64 | ||
curl -Lo /usr/local/bin/stoml https://github.com/freshautomations/stoml/releases/download/v0.6.1/stoml_linux_amd64 | ||
chmod 755 /usr/local/bin/sconfig | ||
chmod 755 /usr/local/bin/stoml | ||
``` | ||
2. Install `gm` | ||
```bash | ||
git clone https://github.com/informal/ibc-rs | ||
ibc-rs/scripts/gm/bin/gm install | ||
``` | ||
|
||
Alternatively, you can create the folder `$HOME/.gm/bin` and copy the files from `scripts/gm/bin` in there. | ||
The rest is just fluff. | ||
|
||
3. Activate `gm` | ||
* Add `source $HOME/.gm/bin/shell-support` to a file that executes when a new terminal window comes up | ||
(`$HOME/.bash_profile` or `$HOME/.bashrc`) | ||
* (Optional) Enable auto-completion | ||
On MacOS: | ||
```bash | ||
brew install bash-completion | ||
``` | ||
On Linux: | ||
``` | ||
apt install bash-completion || yum install bash-completion | ||
``` | ||
* Restart your terminal | ||
|
||
Note: The `shell-support` script allows bash-completion as well as creating a `gm` alias, so you don't need to add more | ||
entries to your PATH environment variable. If you don't want to use this, you can always just add `$HOME/.gm/bin` to | ||
your path. | ||
## Folders and files | ||
### The HOME folder | ||
**Where**: `$HOME/.gm` | ||
|
||
**Description**: The hard-wired home folder for `gm` is `$HOME/.gm`. It contains the binaries required to run `gm` and | ||
the `gm.toml` file for node configuration. By default, newly created node configuration also resides here under the | ||
`$HOME/.gm/<node_name>` folder but that can be configured in `gm.toml`. | ||
|
||
### The configuration: `gm.toml` | ||
**Where**: `$HOME/.gm/gm.toml`. | ||
|
||
**Description**: This file contains all the high-level node configuration that `gm` is aware of. | ||
|
||
**Entries**: | ||
* `[global]` - the global section defines application-wide defaults. All the entries here can be overridden on a | ||
per-node basis, except if indicated otherwise. | ||
* `gaiad_binary` - Path to the `gaiad` binary to use. | ||
* `ports_start_at` | ||
* In the global section this defines the first free port to use for newly created nodes. | ||
The value will be incremented (by 10) when a new node requires ports. | ||
* In the per-node configuration this is the first port to allocate for the node. | ||
A total of 10 ports will be allocated per node. | ||
* `home_dir` | ||
* In the global section this defines the default folder where all node folders will be created. | ||
* In the per-node configuration this is the folder for the node configuration. | ||
* `auto_maintain_config` - automatically update the `persistent_peers` and `unconditional_peer_ids` sections of the node | ||
configuration. | ||
* `add_to_hermes` - this node should be part of the hermes config. | ||
* `network` | ||
* This is a sub-sections-only variable. It will be ignored in the `global` section. | ||
* Defines the network (the validator connection) for the full node. | ||
* **Mandatory for full nodes**, does not exist for validator nodes. | ||
* `hermes_binary` | ||
* Optional variable. | ||
* Path to the `hermes` binary to use. | ||
* Only used in the `hermes` sub-commands. | ||
* This is a global-only variable. It will be ignored in sub-sections. | ||
* `hermes_config` | ||
* Optional variable. | ||
* The hermes configuration file path. | ||
* Only used in the `hermes` sub-commands. | ||
* This is a global-only variable. It will be ignored in sub-sections. | ||
|
||
Note: the user is welcome to create additional nodes outside the scope of `gm` on the local machine but `gm` will only | ||
manage nodes that are added to the configuration file. | ||
|
||
### The network configuration | ||
**Where**: Default is the folder `$HOME/.gm/<node_name>`, but it can be configured in `gm.toml` using the `home_dir` | ||
entry. | ||
|
||
**Description**: The configuration and data folder for a node. Partially resembles a gaiad home folder (`.gaia`) but | ||
it has additional files to store the wallet mnemonics. | ||
|
||
**Entries**: | ||
* `config` - The node configuration folder. If the node is a full-node, the genesis file was copied from a validator | ||
config. The persistent_peers section is automatically managed if the node has the `auto_maintain_config` parameter | ||
enabled in `gm.toml`. | ||
* `data` - The data folder. | ||
* `keyring-test` - the keyring folder as defined by `gaiad testnet` with the "test" keyring-backend. | ||
* `key_seed.json` - the node's signing and wallet key as defined using the `gaiad testnet` command. | ||
* `wallet_seed.json` - an extra wallet mnemonic defined on validator nodes with some tokens for developer use. | ||
* `pid` - the file that contains the process ID of the running node. (a la `/var/run`) Use `gm status` to see. | ||
* `log` - the log file that contains the output of the running node. Use `gm log <node>` to see. | ||
|
||
This setup allows developers to run a node outside of `gm` just by pointing the `gaiad --home-dir` to the folder. | ||
|
||
### Ports | ||
Ports are defined by the `ports_start_at` parameter which will be the first port assigned. | ||
Port assignment is as follows: | ||
``` | ||
| name | port redirection | | ||
|==============|====================| | ||
| RPC (26657) | ports_start_at + 0 | | ||
| App (1317) | ports_start_at + 1 | | ||
| GRPC (9090 | ports_start_at + 2 | | ||
| P2P (26656) | ports_start_at + 3 | | ||
| PPROF (6060) | ports_start_at + 4 | | ||
``` | ||
|
||
Example output of `gm ports` command when `node4.ports_start_at=27050`: | ||
``` | ||
node4 RPC : http://localhost:27050 | ||
node4 APP : http://localhost:27051 | ||
node4 GRPC : http://localhost:27052 | ||
node4 P2P : http://localhost:27053 | ||
node4 PPROF: http://localhost:27054 | ||
``` | ||
|
||
## Execution manual | ||
### `gm help` | ||
**Description**: shows the help screen | ||
|
||
### `gm hermes cc` | ||
**Description**: create the `hermes create client` commands for a fully interconnected set of IBC calls and print them | ||
greg-szabo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
on the screen. | ||
|
||
Tip: Pick and choose the ones you want to create. | ||
|
||
### `gm hermes config` | ||
**Description**: generate the hermes `config.toml` config file and write it to the defined config path. | ||
|
||
Tip: Do not run this command, if you value your current hermes config. It will be overwritten. | ||
|
||
### `gm hermes keys` | ||
**Description**: add network keys to a hermes configuration. | ||
|
||
Tip: Make sure you set the `global.hermes_binary` entry in the config to a valid binary path. | ||
|
||
### `gm install` | ||
**Description**: Install the `gm` command under `$HOME/.gm`, create a default configuration and warn about missing | ||
dependencies. | ||
|
||
Tip: You can run this command multiple times to check if the dependencies are met. | ||
|
||
### `gm keys [<node> ...]` | ||
**Description**: List the keys installed on a node. (It gets them from the `keyring-test` folder.) | ||
If no node is specified then it lists all keys. | ||
|
||
Tip: it will show you the seed phrase if it can find it in the folder. | ||
|
||
### `gm log <node> [<node> ...] [-f]` | ||
**Description**: Show the log of the specified node(s). At least one node has to be specified. | ||
|
||
Tip: You can put `-f` anywhere after `log` to get `tail -f`-like functionality. | ||
|
||
### `gm ports [<node> ...]` | ||
**Description**: List the ports assigned to a node. | ||
If no node is specified then it lists all nodes' ports. | ||
|
||
Tip: When automation doesn't get you all the way, this helps in identifying your nodes on your local machine. | ||
|
||
### `gm start [<node> ...]` | ||
**Description**: Start the node(s). This will use the defined `gaiad` binary and configuration. | ||
If no node is specified then it will start all nodes. | ||
|
||
Tip: You can freely start nodes over-and-over. If they are proven running, the command will not do anything, if they | ||
were killed for any reason, the `pid` configuration will be updated, and a fresh node started. | ||
|
||
### `gm status` | ||
**Description**: List all nodes and their basic properties, such as: their PID if they are running, their home folder, | ||
and the most common ports used. | ||
|
||
Tip: PIDs in brackets mean that the node is not running when `gm` started them. This could be because of a configuration | ||
error or maybe the user simply killed the PID. No worries, `gm` will clean up when `start` or `stop` is invoked. | ||
|
||
### `gm stop [<node> ...]` | ||
**Description**: Stop the node(s). This will use the defined `gaiad` binary and configuration. | ||
If no node is specified then it will stop all nodes. | ||
|
||
Tip: If a node was killed, you can use `gm stop` to clean up the PID file. | ||
|
||
### `gm unsafe-reset [<node> ...]` | ||
**Description**: Run `unsafe-reset-all` on the node(s). This will use the defined `gaiad` binary and configuration. | ||
If no node is specified then it will run for all nodes. | ||
|
||
Tip: It will skip nodes that are running. | ||
|
||
### `gm version` | ||
**Description**: Display the version of `gm`. | ||
|
||
Tip: Congratulations in reaching the bottom of the command references. For your endurance, you are rewarded | ||
with an unsupported yet useful command: `gm ss` will list the open ports between 27000-28000 (the default port set | ||
used by `gm`) on your local machine. Use it when you get port-clashes because of rogue processes on your machine that | ||
`gm` can't account for. | ||
|
||
## Example: 5 networks with 5 full nodes attached | ||
This is an example that recreates the "full-mesh" tool's default network setup with the added twist that all networks | ||
have a full node and the hermes config is going through the full nodes instead of the validator nodes. | ||
|
||
You can get the hermes configuration automatically. | ||
|
||
You might need to replace the value of the `gaiad_binary` entry, if you don't set `$GOPATH` in your regular executions. | ||
|
||
The same is true for `hermes_binary`. | ||
|
||
`gm.toml`: | ||
```toml | ||
[global] | ||
gaiad_binary="$GOPATH/bin/gaiad" | ||
ports_start_at=27000 | ||
home_dir="$HOME/.gm" | ||
auto_maintain_config=true | ||
add_to_hermes=false | ||
hermes_binary="./hermes" | ||
hermes_config="$HOME/.hermes/config.toml" | ||
|
||
[network1] | ||
[network2] | ||
[network3] | ||
[network4] | ||
[network5] | ||
|
||
[node1] | ||
network="network1" | ||
add_to_hermes=true | ||
[node2] | ||
network="network2" | ||
add_to_hermes=true | ||
[node3] | ||
network="network3" | ||
add_to_hermes=true | ||
[node4] | ||
network="network4" | ||
add_to_hermes=true | ||
[node5] | ||
network="network5" | ||
add_to_hermes=true | ||
``` | ||
(Ports will be auto-assigned and written in the configuration file on the first start.) | ||
|
||
Run the below: | ||
```bash | ||
gm start | ||
gm hermes config | ||
gm hermes keys | ||
gm hermes cc | ||
``` | ||
|
||
This will | ||
* create the node configuration and start all nodes | ||
* generate the keys for hermes | ||
* generate the config for hermes | ||
* print the `create client` commands for a full-mesh connection among the IBC node networks. | ||
|
||
Pick and choose the connections from the list that you want to create. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The new gaia version includes a GRPC-Web which defaults to 9091
There's an enable so I can manually set that to false for now