Skip to content

Commit

Permalink
add walkthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
okdas committed Dec 16, 2024
1 parent a35d2d6 commit 273b352
Show file tree
Hide file tree
Showing 2 changed files with 238 additions and 22 deletions.
20 changes: 9 additions & 11 deletions docusaurus/docs/operate/quickstart/validator_cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ This cheat sheet provides quick copy-pasta instructions for staking and running

## Prerequisites

1. **Run a Full Node**: Make sure you have followed the [Full Node Cheat Sheet](./full_node_cheatsheet.md) to install and run a Full Node first.

2. **Install `poktrolld` CLI**: Make sure `poktrolld` is installed and accessible from your command line.
**Run a Full Node**: Make sure you have followed the [Full Node Cheat Sheet](./full_node_cheatsheet.md) to install and run a Full Node first.

## Account Setup

Expand All @@ -29,7 +27,7 @@ if you're running a full node using the [Full Node Cheat Sheet](./full_node_chea
the user you created in the full node setup to get access to the `poktrolld` CLI. Like this:

```bash
su - poktroll
su - poktroll # or a different user if you used a different name
```

:::
Expand All @@ -50,7 +48,7 @@ Set the validator address in an environment variable for convenience:
export VALIDATOR_ADDR=$(poktrolld keys show validator -a)
```

Fund the validator account using the TestNet faucet or by transferring tokens from another account.
Fund the validator account using [the faucet](../../explore/tools.md) or by transferring tokens from another account.

Check the balance:

Expand Down Expand Up @@ -104,15 +102,15 @@ Create a JSON file named `validator.json` with the following content:
Run the following command to create the validator:

```bash
poktrolld tx staking create-validator ~/validator.json --from validator --chain-id pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt --yes
poktrolld tx staking create-validator ./validator.json --from=validator --chain-id=pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

This command uses the `validator.json` file to submit the `create-validator` transaction.

**Example**:

```bash
poktrolld tx staking create-validator ~/validator.json --from validator --chain-id=pocket-beta --gas=auto --gas-prices=1upokt --gas-adjustment=1.5 --yes
poktrolld tx staking create-validator ./validator.json --from=validator --chain-id=pocket-beta --gas=auto --gas-prices=1upokt --gas-adjustment=1.5
```

## Verify the Validator Status
Expand All @@ -130,19 +128,19 @@ This will display information about your validator, including its status and del
- **Delegate additional tokens to your validator**:

```bash
poktrolld tx staking delegate $VALIDATOR_ADDR 1000000upokt --from your_account --chain-id pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt --yes
poktrolld tx staking delegate $VALIDATOR_ADDR 1000000upokt --from your_account --chain-id=pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

- **Unbond (undelegate) tokens from your validator**:

```bash
poktrolld tx staking unbond $VALIDATOR_ADDR 500000upokt --from your_account --chain-id pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt --yes
poktrolld tx staking unbond $VALIDATOR_ADDR 500000upokt --from your_account --chain-id=pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

- **Withdraw rewards**:

```bash
poktrolld tx distribution withdraw-rewards $VALIDATOR_ADDR --commission --from validator --chain-id pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt --yes
poktrolld tx distribution withdraw-rewards $VALIDATOR_ADDR --commission --from validator --chain-id=pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

- **Check validator's commission and rewards**:
Expand All @@ -161,7 +159,7 @@ This will display information about your validator, including its status and del

:::tip

If you're interested in understanding everything, or having full control of every
If you're interested in understanding everything validator related, or having full control of every
step, check out the [Validator Walkthrough](../run_a_node/validator_walkthrough.md).

:::
240 changes: 229 additions & 11 deletions docusaurus/docs/operate/run_a_node/validator_walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,245 @@ title: Validator Walkthrough
sidebar_position: 4
---

## Validator Walkthrough <!-- omit in toc -->
This walkthrough provides detailed step-by-step instructions to stake and run a Validator node on Pocket Network.

<!-- TODO_MAINNET(@okdas, #754): Update this page with all the details. -->

This walkthrough provides a detailed step-by-step instructions to run a validator node for Pocket Network.
<!-- TODO_IN_THIS_PR: should we add a note about POKT rewards not being available for Validators? And suggesting to provide service on the network instead? -->

:::tip

If you're comfortable using an automated scripts, or simply want to _copy-pasta_ a
few commands to get started, check out the [Validator Cheat Sheet](../quickstart/validator_cheatsheet.md).
If you're interested in a simple guide with _copy-pasta_ of a few commands to get started, check out the [Validator Cheat Sheet](../quickstart/validator_cheatsheet.md) instead.

:::

- [Introduction](#introduction)
- [Pre-Requisites](#pre-requisites)
- [Prerequisites](#prerequisites)
- [1. Run a Full Node](#1-run-a-full-node)
- [2. Account Setup](#2-account-setup)
- [2.1. Create and Fund the Validator Account](#21-create-and-fund-the-validator-account)
- [3. Get the Validator's Public Key](#3-get-the-validators-public-key)
- [4. Create the Validator JSON File](#4-create-the-validator-json-file)
- [5. Create the Validator](#5-create-the-validator)
- [6. Verify the Validator Status](#6-verify-the-validator-status)
- [7. Additional Commands](#7-additional-commands)
- [Notes](#notes)

## Introduction

This guide will help you install a Validator on Pocket Network, from scratch, manually,
**giving you control over each step of the process**.
This guide will help you stake and run a Validator node on Pocket Network, from scratch, manually, **giving you control over each step of the process**.

As a Validator, you'll be participating in the consensus of the network, validating transactions, and securing the blockchain.

## Prerequisites

**Run a Full Node**: Ensure you have followed the [Full Node Walkthrough](./full_node_walkthrough.md) to install and run a Full Node. Your node must be fully synced with the network before proceeding.

## 1. Run a Full Node

Before becoming a Validator, you need to run a Full Node. If you haven't set up a Full Node yet, please follow the [Full Node Walkthrough](./full_node_walkthrough.md) to install and configure your node.

:::tip

if you're already running a full node using the [Full Node Walkthrough](./full_node_walkthrough.md), you can can switch to
the user you created in the full node setup to get access to the `poktrolld` CLI. Like this:

```bash
su - poktroll # or a different user if you used a different name
```

:::

Ensure your node is running and fully synchronized with the network. You can check the synchronization status by running:

```bash
poktrolld status
```

## 2. Account Setup

To become a Validator, you need a Validator account with sufficient funds to stake.

### 2.1. Create and Fund the Validator Account

Create a new key pair for your Validator account:

```bash
poktrolld keys add validator
```

- This command generates a new key pair and stores it in your local keyring.
- You will see output containing your new address and a mnemonic seed phrase.
- **Important**: Securely save the mnemonic phrase in a safe place. If you lose it, you won't be able to recover your account.

Set the Validator address as an environment variable for convenience:

```bash
export VALIDATOR_ADDR=$(poktrolld keys show validator -a)
```

You can verify your Validator address by displaying the environment variable:

```bash
echo $VALIDATOR_ADDR
```

Next, fund your Validator account. You need to send tokens to your Validator address to cover staking and transaction fees.

- On **testnet**, you can use the [faucet](../../explore/tools.md) to obtain tokens.
- On **mainnet**, you'll need to acquire tokens from an exchange or another account.

Check the balance of your Validator account:

```bash
poktrolld query bank balances $VALIDATOR_ADDR
```

## 3. Get the Validator's Public Key

Your node has a unique public key associated with it, which is required for creating the Validator.

To retrieve your node's public key, run:

```bash
poktrolld comet show-validator
```

This command outputs your node's public key in JSON format:

```json
{"@type":"/cosmos.crypto.ed25519.PubKey","key":"YourPublicKeyHere"}
```

- Copy the entire output (including `"@type"` and `"key"`), as you'll need it for the next step.

## 4. Create the Validator JSON File

Create a JSON file named `validator.json` in your home directory (or any convenient location), which contains the information required to create your Validator.

```bash
nano ~/validator.json
```

Paste the following content into `validator.json`, replacing placeholders with your information:

```json
{
"pubkey": {"@type":"/cosmos.crypto.ed25519.PubKey","key":"YourPublicKeyHere"},
"amount": "1000000upokt",
"moniker": "YourValidatorName",
"identity": "",
"website": "",
"security": "",
"details": "",
"commission-rate": "0.10",
"commission-max-rate": "0.20",
"commission-max-change-rate": "0.01",
"min-self-delegation": "1"
}
```

## Pre-Requisites
- **Replace** `"YourPublicKeyHere"` with the `"key"` value from `poktrolld comet show-validator`.
- **Update** `"amount"` with the amount you wish to stake (e.g., `"1000000upokt"`). Ensure this amount is less than or equal to your account balance.
- **Set** `"moniker"` to your desired Validator name. This is how your Validator will appear to others.
- **Optional**: Fill in `"identity"`, `"website"`, `"security"`, and `"details"` if you wish to provide additional information about your Validator.

Save and close the file.

## 5. Create the Validator

Now, you are ready to create your Validator on the network.

Run the following command:

```bash
poktrolld tx staking create-validator ~/validator.json --from=validator --chain-id=<your-chain-id> --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

- **Parameters**:
- `~/validator.json`: The path to your validator JSON file.
- `--from=validator`: Specifies the local key to sign the transaction.
- `--chain-id=<your-chain-id>`: Replace `<your-chain-id>` with the chain ID of the network you are joining (e.g., `pocket-beta` for testnet).
- `--gas=auto`: Automatically estimate gas required for the transaction.
- `--gas-adjustment=1.5`: Adjust the estimated gas by a factor (can help prevent out-of-gas errors).
- `--gas-prices=1upokt`: Set the gas price; adjust as needed based on network conditions.

**Example**:

```bash
poktrolld tx staking create-validator ~/validator.json --from=validator --chain-id=pocket-beta --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

After running the command, you should see a transaction confirmation with an output hash.

## 6. Verify the Validator Status

To verify that your Validator has been successfully created, run:

```bash
poktrolld query staking validator $VALIDATOR_ADDR
```

This command displays information about your Validator, including status, tokens staked, commission rates, and more.

Ensure that the `status` field indicates that your Validator is active.

## 7. Additional Commands

Here are some useful commands for managing your Validator:

- **Delegate additional tokens to your Validator**:

If you wish to increase your self-delegation or others want to delegate to your Validator, use:

```bash
poktrolld tx staking delegate $VALIDATOR_ADDR <amount> --from <delegator_account> --chain-id=<your-chain-id> --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

Replace `<amount>` with the amount to delegate (e.g., `1000000upokt`) and `<delegator_account>` with the name of the key in your keyring.

- **Unbond (undelegate) tokens from your Validator**:

To unbond a portion of your staked tokens:

```bash
poktrolld tx staking unbond $VALIDATOR_ADDR <amount> --from <delegator_account> --chain-id=<your-chain-id> --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

Note that unbonding tokens initiates an unbonding period during which the tokens are locked and not earning rewards. The unbonding period duration depends on the network configuration.

- **Withdraw rewards**:

To withdraw accumulated rewards from your Validator:

```bash
poktrolld tx distribution withdraw-rewards $VALIDATOR_ADDR --commission --from validator --chain-id=<your-chain-id> --gas=auto --gas-adjustment=1.5 --gas-prices=1upokt
```

The `--commission` flag indicates that you are withdrawing both your commission and rewards.

- **Check Validator's commission and rewards**:

To view your Validator's commission:

```bash
poktrolld query distribution commission $VALIDATOR_ADDR
```

To view rewards:

```bash
poktrolld query distribution rewards $VALIDATOR_ADDR
```

## Notes

- **Node Synchronization**: Your Full Node must be fully synchronized with the network before creating the Validator. Use `poktrolld status` to check synchronization status.

- **Security**: Keep your mnemonic phrases and private keys secure. Do not share them or store them in insecure locations.

- **Monitoring**: Regularly monitor your Validator's status to ensure it remains active and does not get jailed due to downtime or misbehavior.

- **Upgrades**: Keep your node software up-to-date. Follow upgrade notifications in Pocket Network's [Discord](https://discord.com/invite/pocket-network) and ensure your node is running the [latest recommended version](../../protocol/upgrades/upgrade_list.md).

---

1. **Run a Full Node**: Make sure you have followed the [Full Node Walkthrough](../run_a_node/full_node_walkthrough.md) to install and run a Full Node first
Congratulations! You have successfully set up and run a Validator on Pocket Network. Remember to stay engaged with the community and keep your node running smoothly to contribute to the network's security and decentralization.

0 comments on commit 273b352

Please sign in to comment.