Skip to main content

Run a Node

Automated deployment

Execute init-gravity.sh in the root directory to run the local node via an automation script

    init-gravity.sh
caution

The ❗️ automation script will delete all pre-existing binaries that have been installed. If you want to keep the binaries and other configuration files, please use manual deployment.

Manual deployment

Start node

    treasurenetd start --json-rpc.enable=true --json-rpc.api="eth,txpool,personal,net,debug,web3,miner"

Key Management

Run a node using the same Key each time: replace treasurenetd keys add $KEY in init-gravity.sh.

    echo "your mnemonic here" | treasurenetd keys add $KEY --recover 
caution

treasurenet now only supports 24-word mnemonics

Generate a validator key, orchestrator key, and eth key for each validator

You can register a new key/helper word:

    treasurenetd keys add $VALIDATOR_KEY --keyring-backend test --algo eth_secp256k1 2>> /validator-phrases

Together we may refer to the Gravity Orchestrator Cosmos Key and Gravity Orchestrator Ethereum Keys as 'Gravity delegate keys' as they act as a 'delegate' for your Validator Operator key.

If you lose your Gravity delegate keys you will have to unbond and create a new validator because it's not possible to rotate them. So store all output of the following commands in a safe place.

    treasurenetd keys add $ORCHESTRATOR_KEY --keyring-backend test --algo eth_secp256k1 2>> /orchestrator-phrases
    treasurenetd eth_keys add --keyring-backend test --algo eth_secp256k1 >> /validator-eth-keys

To export your treasurenetd private key as an Ethereum private key (e.g. to use with Metamask)

    treasurenetd keys unsafe-export-eth-key $VALIDATOR_KEY

More information about the key command can be found at --help

    treasurenetd keys [command] -h

Clearing data from chain

Reset Data

You can reset the blockchain data, delete the addresses stored in the nodes (address book) and reset the creation status of priv_validator.json.

caution

❗️ If you are running a validator node, usually be very careful with the unsafe-reset-all command.

❗️ Make sure that each node has a separate priv_validator.json file. Do not try to copy this file from an old node to a new one; using the same priv_validator.json file on both nodes will cause your nodes to double sign.

First, delete all expired files and reset your data

    rm $HOME/.treasurenetd/config/addrbook.json $HOME/.treasurenetd/config/genesis.json
treasurenetd tendermint unsafe-reset-all --home $HOME/.treasurenetd

Your node is now in its initial state, while keeping the initial priv_validator.json and config.toml. If you set any before, your node will try to connect to them.

Delete Data

The data generated by treasurenetd's binary tool is stored in ~/.treasurenetd by default, and the existing binaries and configuration information can be deleted using the following command


rm -rf ~/.treasurenetd

Adding Genesis Accounts

Before starting the chain, you need to populate the state with at least one account. To do so, first create a new account in the keyring named my_validator under the test keyring backend (feel free to choose another name and another backend).

Now that you have created a local account, go ahead and grant it some stake tokens in your chain's genesis file. Doing so will also make sure your chain is aware of this account's existence:

    treasurenetd add-genesis-account --home /root/.treasurenetd --keyring-backend test (treasurenetd keys show $VALIDATOR_KEY -a --home /root/.treasurenetd --keyring-backend test) 100000000000000000000000000aunit
treasurenetd add-genesis-account --home /root/.treasurenetd --keyring-backend test (treasurenetd keys show $ORCHESTRATOR_KEY -a --home /root/.treasurenetd --keyring-backend test) 100000000000000000000000000aunit

Now that your account has some tokens, you need to add a validator to your chain. Validators are special full-nodes that participate in the consensus process (implemented in the underlying consensus engine) in order to add new blocks to the chain. Any account can declare its intention to become a validator operator, but only those with sufficient delegation get to enter the active set (for example, only the top 125 validator candidates with the most delegation get to be validators in the Treasurenet). For this guide, you will add your local node (created via the init command above) as a validator of your chain. Validators can be declared before a chain is first started via a special transaction included in the genesis file called a gentx:

    # Create a gentx.
treasurenetd gentx
--home /root/.treasurenetd
--keyring-backend test
--moniker # The validator(optional) moniker
--chain-id=treasurenet_5005-1
[key_name] # $VALIDATOR_KEY
[amount] # 258000000000000000000aunit
[eth-address] # $ETHEREUM_KEY
[orchestrator-address] # $ORCHESTRATOR_KEY

# Add the gentx to the genesis file.
treasurenetd collect-gentxs

A gentx does three things:

  • Registers the validator account you created as a validator operator account (i.e. the account that controls the validator).
  • Self-delegates the provided aunit of staking tokens.
  • Link the operator account with a CometBFT node pubkey that will be used for signing blocks. If no --pubkey flag is provided, it defaults to the local node pubkey created via the treasurenetd init command above.

Run a Localnet

Now that everything is set up, you can finally start your node:

    treasurenetd start