Devnet (Dev-Theodoric-1)
Instructions for Running a Node
- Submit DChain address for pre-genesis allocation
- After pre-genesis is issued, create Genesis Transaction and Submit
Basica Setup
This step is to show the essential components for the two steps above.
# Simple server setup
sudo apt update
sudo apt install git make gcc
wget https://go.dev/dl/go1.21.1.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz
# add the following and save file
vim ~/.profile
export PATH=$PATH:/usr/local/go/bin
source ~/.profile
#test
go version # go version go1.21.1 linux/amd64
# install dchain binary (building)
git clone --branch v0.3.0 --depth 1 git@github.com:d-foundation/protocol
cd protocol
make build
sudo mv ./dchain /usr/local/bin
# instsall dchain binary (pre-built)
wget https://github.com/d-foundation/protocol/releases/download/v0.3.0/dchain-0.3.0-linux-amd64.tar.gz
tar -xzf dchain-0.3.0-linux-amd64.tar.gz
# check version to be the below:
# commit: 4cb555490e78c4f47fb36bdf5e0bc7e3429ca848
# cosmos_sdk_version: v0.0.0-20240820023506-6f2d52be7a55
# go: go version go1.21.1 linux/amd64
# name: dchain
# server_name: dchain
# version: HEAD-4cb555490e78c4f47fb36bdf5e0bc7e3429ca848
dchain version --long
1. Submit chain address for pre-genesis allocation
After you have downloaded the dchain
binary,
as a validator, please provide the account for the pre-genesis allocation.
You can do this by generating a new set of keypair and address for dchain.
dchain keys add <your-key-name>
Please provide the address on the dfoundation.io form.
2. Create and Submit Genesis Trasaction
After the pre-genesis file has been prepared, you can now create the genesis transaction.
# setting the chain id
dchain config set client chain-id dev-theodoric-1
# creating the validator consensus key and address
# This will create your validator private key in `~/.dchain/config/priv_validator_key.json`
# you can replace this with your own as well
dchain init <validator>
3. Get the correct version of pre-genesis file
This must be done after initialising the dchain node as it overwrites the genesis file.
# clone the pre-genesis file
# usually we will do curl .... > $HOME/debian/.dchain/config/genesis.json
# but since the network repo is not public yet, we will just scp for now
# in local machine in this repo
scp ./devnets/dev-theodoric/pre-genesis.json devnet-ovh-3:/home/debian/.dchain/config/genesis.json
2. Recover delegator key
# setting the node operator address previously provided for genesis allocation
# devnet setup uses keyring-backend=file
dchain keys add <key-name> --recover # or importing private keys in other ways
3. Create genesis transaction keys
dchain cometbft show-validator # shows your validator pubkey
dchain cometbft show-address # shows your validator consensus address starting with `dchainvalcons1`
dchain cometbft show-node-id # shows your node-id
dchain genesis gentx <key-name> 100000000000000udt \
--chain-id="dev-theodoric-1" \
--moniker=gayadeed \
--commission-max-change-rate="0.01" \
--commission-max-rate="0.1" \
--commission-rate="0.05" \
--min-self-delegation="1000000" \
--details="" \
--security-contact="" \
--pubkey=$(dchain cometbft show-validator) \
--node-id=$(dchain cometbft show-node-id) \
--from <key name> \
--keyring-backend file
which should result in a file written to Genesis transaction written to "/home/debian/.dchain/config/gentx/gentx-<>.json"
Upload this file to the Networks repo under devnets/dev-theodoric/gentx
.
Please also add peer information to devnets/dev-theodoric/peers
.
It should be in the form of $(dchain comet show-node-id)@<ip>:<port>
.
Running the Network with Cosmovisor
Setting up Cosmovisor
# download cosmovisor
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.6.0
This will download cosmovisor to your $GOPATH/bin
directory.
If the $GOPATH
var is not set, it will be downloaded to ~/go/bin
.
# move cosmovisor to /usr/local/bin
sudo mv ~/go/bin/cosmovisor /usr/local/bin
Then we have to create the expected directory structure for cosmovisor to work. Details are provided by the cosmos docs
# create the cosmovisor directory
mkdir -p ~/.dchain/cosmovisor/genesis/bin
cp /usr/local/bin/dchain ~/.dchain/cosmovisor/genesis/bin
Getting the genesis file
# clone the genesis file
# usually we will do curl .... > $HOME/debian/.dchain/config/genesis.json
# but since the network repo is not public yet, we will just scp for now
# in local machine in this repo
scp ./devnets/dev-theodoric/genesis.json devnet-ovh-3:/home/debian/.dchain/config/genesis.json
Adding Verifiable Presentation for Validator
The verifiable presentation must be for the consensus address from dchain cometbft show-address
.
The address should start with dchainvalcons1
.
This is added to the config by running.
dchain vp add <verifiable-presentation>
Running the node
For devnet, we will be using persistent_peers
to connect to the other nodes.
You can find the peer information in the devnets/dev-theodoric/peers
files.
Make sure these peers are added in the $HOME/.dchain/config/config.toml
file.
persistent_peers = "ee79ef2ce465ce4ce15aade814fc563f36f5140e@148.113.192.239:26656,051b125875acde50e18585b4c8cafdcdb1e27a5a@15.235.207.44:26656"
We will be setting up systemd to run the node.
# create the systemd service file
sudo vim /etc/systemd/system/dchain.service
Here is a simple example of the service file, for more details please look at details of Environment variables.
[Unit]
Description=DChain Validator Node
After=network-online.target
[Service]
User=debian
ExecStart=/usr/local/bin/cosmovisor run start
Restart=always
RestartSec=3
LimitNOFILE=65535
Environment="DAEMON_NAME=dchain"
Environment="DAEMON_HOME=/home/debian/.dchain"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
[Install]
WantedBy=multi-user.target
After we have the systemd file
# reload the systemd daemon
sudo systemctl daemon-reload
# enable the service
sudo systemctl enable dchain
# start the service
sudo systemctl start dchain
# check the status
sudo systemctl status dchain
# check the logs
journalctl -u dchain -f
# stop the service
sudo systemctl stop dchain