Skip to content

Latest commit

 

History

History
144 lines (123 loc) · 7.96 KB

PUBLIC_NODE.md

File metadata and controls

144 lines (123 loc) · 7.96 KB

Public node setup guide

gm can be used to set up nodes connecting to existing networks. Below is an example connecting to the Cosmos Hub from an Intel Mac. (You can customize it to other operating systems by changing the binary in gm.toml.)

Useful links:

Set up gm

Minimalistic gm.toml:

[global]
gaiad_binary = "https://github.com/cosmos/gaia/releases/download/v7.1.0/gaiad-v7.1.0-darwin-amd64"
[cosmoshub-4]

One-node, no-nonsense Gaiad testnet network.

Set up the folders

We gm start to create the folders for this local testnet called "cosmoshub-4" and then we gm stop it, so we can replace the configuration with the mainnet data. We do a gm reset to remove the testnet database entries.

$ gm start
Creating cosmoshub-4 config...
cosmoshub-4 started, PID: 97569, LOG: /Users/maphlaves/.gm/cosmoshub-4/log
$ gm stop
Stopping cosmoshub-4 with PID 97569...
$ gm reset cosmoshub-4
Resetting cosmoshub-4...
I[2022-12-08|11:47:06.989] Removed existing address book                file=/Users/maphlaves/.gm/cosmoshub-4/config/addrbook.json
I[2022-12-08|11:47:06.994] Removed all blockchain history               dir=/Users/maphlaves/.gm/cosmoshub-4/data
I[2022-12-08|11:47:06.996] Reset private validator file to genesis state keyFile=/Users/maphlaves/.gm/cosmoshub-4/config/priv_validator_key.json stateFile=/Users/maphlaves/.gm/cosmoshub-4/data/priv_validator_state.json

Configure the node

We are ready to configure our node. Download the Cosmos Hub genesis from the chain registry:

$ wget -O ~/.gm/cosmoshub-4/config/genesis.json.gz https://github.com/cosmos/mainnet/raw/master/genesis/genesis.cosmoshub-4.json.gz
#(modem noises)
$ gunzip ~/.gm/cosmoshub-4/config/genesis.json.gz
/Users/maphlaves/.gm/cosmoshub-4/config/genesis.json already exists -- do you wish to overwrite (y or n)? y

Now onto the more complex task of changing our node configuration parameters: Edit your app.toml at $HOME/.gm/cosmoshub-4/config/app.toml and change:

minimum-gas-prices = "0.002uatom"

This ensures a minimal amount of spam protection: zero-fee transactions will be rejected from the mempool.

Edit your config.toml at $HOME/.gm/cosmoshub-4/config/config.toml and change:

moniker = "anything you like"
[p2p]
addr_book_strict = true
allow_duplicate_ip = false
external_address = "find out your public IP address:27003"
persistent_peers = "[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,f1b16c603f3a0e59f0ce5179dc80f549a7ecd0e2@sentries.us-east1.iqext.net:26656,[email protected]:26656,[email protected]:26656"
seeds = "bf8328b66dceb4987e5cd94430af66045e59899f@public-seed.cosmos.vitwit.com:26656,[email protected]:26656,[email protected]:26656,ba3bacc714817218562f743178228f23678b2873@public-seed-node.cosmoshub.certus.one:26656,[email protected]:26656,[email protected]:26656,bcef90de8a83673c336bf3b3a352445b3a3a1f08@cosmos-seed.sunshinevalidation.io:31038,[email protected]:2000,[email protected]:14956,[email protected]:14956,57a5297537b9b6ef8b105c08a8ad3f6ac452c423@seeds.goldenratiostaking.net:1618"

The first two settings will require other nodes to be on the public Internet. This was not a requirement on testnets.

To find your public IP address, you can run curl api.ipify.org in the terminal.

You can get a fresh list of persistent_peers and/or seeds from the chain registry.

You do not need to populate both seeds and persistent_peers but you need to populate at least one.

If you are behind a firewall you don't control, setting the external IP address might not really help: no one will be able to connect to your node unless the p2p port (27003 in the example) is routed toward your machine. You will be able to connect to other nodes, though, just the initial startup might be slower.

State syncing

State syncing requires the following information:

  • A hash for a trusted, previous height
  • Two RPC nodes for some authentication of that information
  • P2P connections so the node can gather the state snapshot

Your node will go and search for state snapshots over P2P that were created above "trusted height".

Set these in config.toml:

[statesync]
enable = true
rpc_servers = "https://cosmos-rpc.polkachu.com:443,https://rpc-cosmoshub.blockapsis.com:443"
trust_hash = "3E8009B4D306ADD7CB19AE1ACEAD882F0A2D4F5E0418910989F194788E227539"
trust_height = 13165039

You can find RPC servers in the chain registry.

Set the trust hash and trust height by looking at an existing, trusted Gaia node and query some older heights from it.

Start your node

...and see how it behaves:

gm start
gm log cosmoshub-4 -f

The node will start with invariant checks then it will try to dial some peers. After a while it will start stake syncing and you will see similar entries in the log:

1:37PM INF Fetching snapshot chunk chunk=43 format=1 height=13166000 module=statesync total=76

If you poll the /status endpoint, you will see that the node is catching up:

{
  "jsonrpc": "2.0",
  "id": -1,
  "result": {
    "node_info": {},
    "sync_info": {
      "latest_block_hash": "",
      "latest_app_hash": "",
      "latest_block_height": "0",
      "latest_block_time": "1970-01-01T00:00:00Z",
      "earliest_block_hash": "",
      "earliest_app_hash": "",
      "earliest_block_height": "0",
      "earliest_block_time": "1970-01-01T00:00:00Z",
      "catching_up": true
    },
    "validator_info": {}
  }
}

Then your laptop overheats.

System requirements

Finally, we should mention what you always find out last: how much resource will a node need? The current Cosmos Hub node in production uses about 6-8 cores, 30GB of RAM and 300GB of disk space allocated. You can try with lower settings as a test but depending on network, some require a lot of RAM for crisis invariant checks. The good news is that if you run this on your laptop, it will eat up all your available resources.

gm is flexible, so you can even start your node directly with gaiad (but it's worth doing it through gm for convenience).

To start a node with no invariant checks, you run:

gaiad start --x-crisis-skip-assert-invariants --home $HOME/.gm/cosmoshub-4

In this case, managing the process is completely out of gm's hands.