Skip to content
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

docs: testnet 5 documentation for Babylon validators #369

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Changes from 7 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0c9b468
Create README.md
samricotta Oct 26, 2024
fa80df0
Update README.md
samricotta Oct 30, 2024
72e3b67
Update README.md
samricotta Oct 30, 2024
12bf5c0
Update README.md
samricotta Oct 30, 2024
a652464
Update README.md
samricotta Oct 30, 2024
bbb9eed
Update README.md
samricotta Oct 30, 2024
f2d4734
Update README.md
samricotta Oct 31, 2024
0d86a88
Update README.md
samricotta Nov 12, 2024
a21af5e
Update pages node and validator
samricotta Nov 15, 2024
f2a855b
update to formatting
samricotta Nov 15, 2024
25c8d75
Update README.md
samricotta Nov 15, 2024
17c63eb
Update README.md
samricotta Nov 15, 2024
931b9b5
Review comments part 1
samricotta Nov 18, 2024
43a0dc7
Update README.md
samricotta Nov 19, 2024
b9de762
Update README.md
samricotta Nov 19, 2024
9c5d79f
Update README.md
samricotta Nov 19, 2024
eaf6943
updates to secuity and monitoring
samricotta Nov 20, 2024
d3765c7
update security and monitoring
samricotta Nov 20, 2024
35145f8
networks landing page
samricotta Nov 20, 2024
c887828
review updates
samricotta Nov 22, 2024
b1ccfcf
update sections - review
samricotta Nov 22, 2024
0974f3b
Update README.md
samricotta Nov 22, 2024
30dd52d
update docs
samricotta Nov 27, 2024
35b58e5
WIP
samricotta Nov 27, 2024
225c88a
comments
samricotta Nov 27, 2024
82be18b
fix table of contents
samricotta Nov 27, 2024
81405cd
edits
samricotta Nov 27, 2024
6d7bf4d
Update README.md
samricotta Nov 27, 2024
7def697
update
samricotta Nov 27, 2024
312803e
Update README.md
samricotta Nov 27, 2024
c61ec3f
node guide updates
vitsalis Nov 27, 2024
027ac27
more updates
vitsalis Nov 27, 2024
0a7beab
Updates from review
samricotta Nov 28, 2024
700b0b2
Part 1 of review comments
samricotta Dec 2, 2024
43fe9b6
Update README.md
samricotta Dec 3, 2024
38ffac4
Update README.md
samricotta Dec 4, 2024
a63f477
Update README.md
samricotta Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 290 additions & 0 deletions bbn-test-5/babylon-validators/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# Babylon Validator Setup

## Table of Contents

1. [System Requirements](#system-requirements)
2. [Install Babylon Binary](#install-babylon-binary)
3. [Setup Node Home Directory and Configure](#setup-your-node-home-directory-and-configure)
4. [Setup Required Keys](#setup-the-required-keys-for-operating-a-validator)
5. [Sync Node](#sync-node)
6. [Get Funds](#get-funds)
7. [Create Validator](#create-validator)

## System Requirements

The Babylon node is built using the Cosmos SDK and has similar system requirements with typical Cosmos SDK ecosystem nodes.

As a reference, the following system specification is typically used by validators and found to be comfortable for high up-time operations.

- Quad Core or larger AMD or Intel (amd64) CPU
- 32GB RAM
- 1TB NVMe Storage
samricotta marked this conversation as resolved.
Show resolved Hide resolved
- 100MBps bidirectional internet connection

Note: the above is a sample system specification that might not fit your specific infrastructure. Please do your own research before committing to a
setup and verifying that it can scale well depending on your operations and needs.

## Install Babylon Binary
<!-- TODO: check add in the correct tag for the testnet -->
Download [Golang 1.21](https://go.dev/dl) 

Using the go version 1.21.x (where x is any patch version like 1.21.0, 1.21.1, etc.)
samricotta marked this conversation as resolved.
Show resolved Hide resolved
Once installed run:

```shell
go version
```
samricotta marked this conversation as resolved.
Show resolved Hide resolved

To ensure you are using the correct version, the terminal should return something similar to the below.

```shell
go: downloading go1.21 (darwin/arm64)
```
samricotta marked this conversation as resolved.
Show resolved Hide resolved

Subsequently clone the babylon [repository](https://github.com/babylonlabs-io/babylon).

```shell
git clone [email protected]:babylonlabs-io/babylon.git
```

Once the `babylon` repository is downloaded then checkout the corresponding tag for `bbn-testnet-5`.
samricotta marked this conversation as resolved.
Show resolved Hide resolved

``` shell
git checkout <tag>
samricotta marked this conversation as resolved.
Show resolved Hide resolved
```

You should now have the repository on your machine. Next navigate into the repository you just cloned and run the following:

```shell
make install
```

This command does the following:
- Builds the daemon
- Compile all Go packages in the project
samricotta marked this conversation as resolved.
Show resolved Hide resolved
- Installs the binary
- Makes the `babylond` command globally accessible from your terminal

And should return something such as below:
samricotta marked this conversation as resolved.
Show resolved Hide resolved

```shell
go install -mod=readonly -tags "netgo ledger mainnet" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=babylon -X github.com/cosmos/cosmos-sdk/version.AppName=babylond -X github.com/cosmos/cosmos-sdk/version.Version=v0.13.0 -X github.com/cosmos/cosmos-sdk/version.Commit=976e94b926dcf287cb487e8f35dbf400c7d930cc -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" -w -s' -trimpath ./...
```

Now it has successfully compiled, lets check the available actions.

```shell
babylond
```

Which will give us a list of available actions.
samricotta marked this conversation as resolved.
Show resolved Hide resolved

```shell
Available Commands:
add-genesis-account Add a genesis account to genesis.json
collect-gentxs Collect genesis txs and output a genesis.json file
comet CometBFT subcommands
config Utilities for managing application configuration
...
```

samricotta marked this conversation as resolved.
Show resolved Hide resolved
If this isn't working then it might not have saved successfully in your `gopath`

If it hasn't saved successfully in your gopath then it might have saved in the `./build` directory, so instead use the following from the project root directory.

```shell
./build/babylond
```
samricotta marked this conversation as resolved.
Show resolved Hide resolved
## Setup your node, home directory and configure

Next we initialize the node and home directory. It should generate all of the necessary files such as `app.toml`, `client.toml`, `genesis.json` with the below command.

```shell
babylond init <moniker> --chain-id bbn-test-5 --home=./nodeDir
```

The `<moniker>` is a unique identifier for your node. So for example `node0`.

Next we should navigate to `app.toml`, update the following section:

```shell
Base configuration
iavl-cache-size = 0

[btc-config]

# Configures which bitcoin network should be used for checkpointing
# valid values are: [mainnet, testnet, simnet, signet, regtest]
network = "signet"
```

In `app.toml` under `[btc-network]`change network to `signet` and `iavl-cache-size = 0` instead of what is listed in the automatically generated template.

Navigate to `config.toml`. Add in your seed that should look something like this `[email protected]:26656`

```shell
samricotta marked this conversation as resolved.
Show resolved Hide resolved
P2P Configuration Options

# Comma separated list of seed nodes to connect to
seeds = "[email protected]:26656"

# Comma separated list of nodes to keep persistent connections to
persistent_peers = "[email protected]:26656"
```

In the `config.toml` add in the `seeds` and `persistent-peers` token (this can be the same token).
samricotta marked this conversation as resolved.
Show resolved Hide resolved

We next want to add in the `genesis.json` file. To do this, either copy the genesis file from `https://rpc.devnet.babylonlabs.io/genesis` or we can use the terminal with the following command.

```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add the --keyring-backend test here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maiquanghiep we would if we are using keys no?

wget https://github.com/babylonlabs-io/networks/raw/main/bbn-test-5/genesis.tar.bz2
tar -xjf genesis.tar.bz2 && rm genesis.tar.bz2
mv genesis.json ~/.babylond/config/genesis.json
```

This file needs to overwrite the existing genesis file in the `~/.babylond/config/genesis.json` and please ensure that the `chain-id` is correct. The chain id is what you used in the `babylond init` command above.
## Setup the required keys for operating a validator
samricotta marked this conversation as resolved.
Show resolved Hide resolved

### Keys for a CometBFT validator

Setting up the key is crucial as it serves as the validator's identity. The key-pair will be used for signing blocks, participating in consensus and managing validator operations. To add a key run the following command:

```shell
babylond --keyring-backend test keys add <name> --home=./nodeDir
samricotta marked this conversation as resolved.
Show resolved Hide resolved
```

We use `--keyring-backend test`, which specifies which backend to use for the keyring, `test` stores keys unencrypted on disk. The `<name>` specifies a unique identifier for the key.

The execution result displays the address of the newly generated key and its public key. Following is a sample output for the command:

```shell
- address: bbn1kvajzzn6gtfn2x6ujfvd6q54etzxnqg7pkylk9

name: test-val
samricotta marked this conversation as resolved.
Show resolved Hide resolved

pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Ayau+8f945c1iQp9tfTVaCT5lzhD8n4MRkZNqpoL6Tpo"}'

type: local
```
### Keys for a BLS Voting
#### What is BLS Voting

BLS (Boneh-Lynn-Shacham) voting is used to create compact checkpoints at the end of each epoch. An epoch is a fixed period within the blockchain, defined or set by a number of blocks, during which a validator set remains consistent. This stability allows Babylon to create and submit checkpoints only once per epoch, reducing the overhead of interacting with the Bitcoin blockchain.

To read more on BLS Voting please see [here](#)
#### Create BLS Key

Validators are expected to submit a BLS signature at the end of each epoch. To do that, a validator needs to have a BLS key pair to sign information with.

Using your address from the keyring generation run:

```shell
babylond create-bls-key <address>
```

Your address should be the one that was generated in the keyring generation step and looks something like this: `bbn1kvajzzn6gtfn2x6ujfvd6q54etzxnqg7pkylk9`.

This command will create a BLS key and add it to the `~/.babylond/config/priv_validator_key.json` that was generated when `init` was run.
samricotta marked this conversation as resolved.
Show resolved Hide resolved

## Sync Node

We are now ready to sync the node.

```shell
babylond start --chain-id=bbn-test-5 --home=./nodeDir --minimum-gas-prices=0.005ubbn
```

Lets go through the flags of the above command:

- `start`: This is the command to start the Babylon node.
- `--chain-id bbn-test-5`: Specifies the ID of the blockchain network you're connecting to.
- `--home=./nodeDir`: Sets the directory for the node's data and configuration files and is dependant on where the files were generated for you from the initialization. In this case, it's using a directory named "nodeDir" in the current path.
- `--minimum-gas-prices=0.005ubbn`: This flag sets the minimum gas price for transactions the node will accept. This can also be manually set in the `app.toml`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--x-crisis-skip-assert-invariants - add this

#### Connect to Nodes

To connect your node to the network, you'll need peer addresses.
<!-- insert links when we have them -->

As mentioned in the configuration step, add these to your `config.toml` under `persistent_peers` or `seeds`.
#### Use a Snapshot

For faster syncing, you can use a snapshot instead of syncing from genesis. Snapshots are
periodic backups of the chain state. Find them at:
<!-- - add link here -->

Note: Always verify snapshot sources and checksums before using them to ensure security.

## Get Funds
<!-- This needs to be updated to the correct testnet and potentially need help with the correct instructions as I cant access the faucet -->

Request Funds from the Babylon Testnet Faucet​ [here](https://faucet.devnet.babylonlabs.io/)

## Create Validator

Contrary to a vanilla Cosmos SDK chain, a validator for Babylon is created through the `babylond tx checkpointing create-validator` command. This command expects that a BLS validator key exists under the `~/.babylond/config/priv_validator_key.json`.

To create the validator (using sample parameters):

```
babylond tx checkpointing create-validator ./dir/node0/babylond/config/priv_validator_key.json\
--chain-id="devnet-2" \
samricotta marked this conversation as resolved.
Show resolved Hide resolved
--gas="auto" \
--gas-adjustment="1.5" \
--gas-prices="0.025ubbn" \
--from=bbn12k7w0mtdqp5yff8hr9gj6xe3uq7hnfhgpzwa7f
```

This should return a transaction, which contains your validator address as below:

```
bbnvaloper12k7w0mtdqp5yff8hr9gj6xe3uq7hnfhguqyqjg`
```
### Verify your Validator

To verify your validator, run:

```
babylond keys show <address or name> -a --bech val
```

Should return your validator address `bbnvaloper12k7w0mtdqp5yff8hr9gj6xe3uq7hnfhguqyqjg` which was returned during the `create-validator` action.

Next, lets check what is listed under the staking validator. Here we use the validator address we received in the response in the last command.

Here we run:

```
babylond query staking validator <validator address>
```

And should receive a response that corresponds to the params from your`create-validator` transaction.

```
validator:
commission:
commission_rates:
max_change_rate: "10000000000000000"
max_rate: "1000000000000000000"
rate: "100000000000000000"
update_time: "2024-10-23T12:21:59.581302666Z"
consensus_pubkey:
type: tendermint/PubKeyEd25519
value: jKjSVn02f8XbnJe4KWxwOWCGGmvyz++3g+8Ppfmbwfw=
delegator_shares: "100000000000000000000"
description:
details: node0val
moniker: node0
security_contact: [email protected]
website: https://myweb.site
min_self_delegation: "1"
operator_address: bbnvaloper12k7w0mtdqp5yff8hr9gj6xe3uq7hnfhguqyqjg
status: 1
tokens: "100"
unbonding_time: "1970-01-01T00:00:00Z"
```

After the epoch (a period of time in which the chain divides time into different periods to help coordinate a number of network-wide activities) ends and if you have enough stake to be an active validator, performing this query will return you a status `BOND_STATUS_BONDED`.

Congrats! You are now a validator on the Babylon system.

If you want to `delegate`, `redelegate`, `unbond` or `cancel-unbond`, please use the wrapped messages in the checkpointing and epoching modules as the messages in staking module are disabled. Read more [here](https://docs.babylonlabs.io/docs/developer-guides/modules/epoching#delaying-wrapped-messages-to-the-end-of-epochs)