Skip to content

Commit

Permalink
Updated the supplier cheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Dec 13, 2024
1 parent 8d64e2a commit 46fea4d
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 77 deletions.
8 changes: 7 additions & 1 deletion docusaurus/docs/operate/quickstart/gateway_cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ TODO_TECHDEBT(@olshansky): Adapt the instructions to be macOS friendly.
- [Check the `PATH Gateway` is serving relays](#check-the-path-gateway-is-serving-relays)

:::note

For detailed instructions, troubleshooting, and observability setup, see the [Gateway Walkthrough](./../run_a_node/gateway_walkthrough.md).

:::

## Pre-Requisites
Expand Down Expand Up @@ -66,7 +68,9 @@ poktrolld keys add gateway
:::tip

You can set the `--keyring-backend` flag to `test` to avoid entering the password
each time. Learn more about [cosmos keyring backends here](https://docs.cosmos.network/v0.46/run-node/keyring.html).
each time.

Learn more about [cosmos keyring backends here](https://docs.cosmos.network/v0.46/run-node/keyring.html).

:::

Expand Down Expand Up @@ -116,7 +120,9 @@ poktrolld query bank balances $APP_ADDR $NODE_FLAGS
```

:::tip

You can find all the explorers, faucets and tools at the [tools page](../../explore/tools.md).

:::

### Stake the `Gateway`
Expand Down
254 changes: 178 additions & 76 deletions docusaurus/docs/operate/quickstart/supplier_cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,46 @@ title: Supplier (RelayMiner) Cheat Sheet

## Supplier Cheat Sheet <!-- omit in toc -->

- [Context](#context)
This guide provides quick reference commands for setting up a **Supplier** and
running a **RelayMiner** on Pocket Network.

:::warning

These instructions are intended to run on a Linux machine.

TODO_TECHDEBT(@olshansky): Adapt the instructions to be macOS friendly.

:::

- [Pre-Requisites](#pre-requisites)
- [Suppliers](#suppliers)
- [Context](#context)
- [Account Setup](#account-setup)
- [Create and fund the `Supplier` account](#create-and-fund-the-supplier-account)
- [Prepare your environment](#prepare-your-environment)
- [Supplier Configuration](#supplier-configuration)
- [Fund the Supplier account](#fund-the-supplier-account)
- [Stake the Supplier](#stake-the-supplier)
- [RelayMiner Configuration](#relayminer-configuration)
- [Configure the RelayMiner](#configure-the-relayminer)
- [Start the RelayMiner](#start-the-relayminer)
- [Secure vs Non-Secure `query_node_grpc_url`](#secure-vs-non-secure-query_node_grpc_url)
- [Supplier FAQ](#supplier-faq)
- [What Supplier transactions are available?](#what-supplier-transactions-are-available)
- [What Supplier queries are available?](#what-supplier-queries-are-available)
- [How do I query for all existing onchain Suppliers?](#how-do-i-query-for-all-existing-onchain-suppliers)
- [How do I stake an onchain Supplier?](#how-do-i-stake-an-onchain-supplier)
- [Supplier Configuration](#supplier-configuration)
- [Supplier Transaction](#supplier-transaction)
- [How do I learn more about interacting with Suppliers?](#how-do-i-learn-more-about-interacting-with-suppliers)
- [Supplier Transactions](#supplier-transactions)
- [Supplier Queries](#supplier-queries)
- [RelayMiners](#relayminers)
- [Retrieve the source code](#retrieve-the-source-code)

:::note

For detailed instructions, troubleshooting, and observability setup, see the [Supplier Walkthrough](./../run_a_node/supplier_walkthrough.md).

:::

## Pre-Requisites

1. Make sure to [install the `poktrolld` CLI](../user_guide/install.md).
2. Make sure you know how to [create and fund a new account](../user_guide/create-new-wallet.md).
3. You have either [staked a new `service` or found an existing one](./service_cheatsheet.md).
4. `[Optional]` You can run things locally or have dedicated long-running hardware. See the [Docker Compose Cheat Sheet](./docker_compose_debian_cheatsheet#deploy-your-server) if you're interested in the latter.

### Context

Expand All @@ -27,137 +55,211 @@ This document is a cheat sheet to get you quickly started with two things:

By the end of it, you should be able to serve Relays onchain.

## Account Setup

### Create and fund the `Supplier` account

Create a new key pair for the `Supplier`

```bash
poktrolld keys add supplier

# Optionally, to avoid entering the password each time:
# poktrolld keys add supplier --keyring-backend test
```

:::tip

It is intended to be a < 10 minute quick copy-pasta.
You can set the `--keyring-backend` flag to `test` to avoid entering the password
each time.

If you're interested in spending hours reading and understanding how things work,
please see the [Supplier Walkthrough](./../run_a_node/supplier_walkthrough.md)
Learn more about [cosmos keyring backends here](https://docs.cosmos.network/v0.46/run-node/keyring.html).

:::

### Pre-Requisites
### Prepare your environment

1. Make sure to [install the `poktrolld` CLI](../user_guide/install.md).
2. Make sure you know how to [create and fund a new `account`](../user_guide/create-new-wallet.md).
3. You have either [staked a new `service` or found an existing](./service_cheatsheet.md).
4. `[Optional]` You can run things locally or have dedicated long-running hardware. See the [Docker Compose Cheat Sheet](./docker_compose_debian_cheatsheet#deploy-your-server) if you're interested in the latter.
For convenience, we're setting several environment variables to streamline
the process of interacting with the Shannon network:

We recommend you put these in your `~/.bashrc` file:

### Suppliers
```bash
export NODE="https://shannon-testnet-grove-rpc.beta.poktroll.com"
export NODE_FLAGS="--node=https://shannon-testnet-grove-rpc.beta.poktroll.com"
export TX_PARAM_FLAGS="--gas=auto --gas-prices=1upokt --gas-adjustment=1.5 --chain-id=pocket-beta --yes"
export SUPPLIER_ADDR=$(poktrolld keys show supplier -a)

#### How do I query for all existing onchain Suppliers?
# Optionally, to avoid entering the password each time:
# export SUPPLIER_ADDR=$(poktrolld keys show supplier -a --keyring-backend test
```

Then, you can query for all services like so:
:::tip

You can put the above in a special `~/.poktrollrc` and add `source ~/.poktrollrc` to
your `~/.profile` file for a cleaner organization.

:::

## Supplier Configuration

### Fund the Supplier account

Run the following command to get the `Supplier`:

```bash
poktrolld query supplier list-supplier --node https://shannon-testnet-grove-rpc.beta.poktroll.com --output json | jq
echo "Supplier address: $SUPPLIER_ADDR"
```

#### How do I stake an onchain Supplier?
Then use the [Shannon Beta TestNet faucet](https://faucet.beta.testnet.pokt.network/) to fund the account.

Afterwards, you can query the balance using the following command:

```bash
poktrolld query bank balances $SUPPLIER_ADDR $NODE_FLAGS
```

:::tip

For an in-depth look at how to stake a supplier, see the [Supplier configuration docs](./../configs/supplier_staking_config.md).
You can find all the explorers, faucets and tools at the [tools page](../../explore/tools.md).

:::

The following is a very quick and simple way to get you started by staking for
### Stake the Supplier

:::info

For an in-depth look at how to stake a supplier, see the [Supplier configuration docs](./../configs/supplier_staking_config.md).

The example below is a very quick and simple way to get you started by staking for
Pocket Network's Morse service on Shannon using a public RPC endpoint provided by
[Liquify](https://liquify.com/).

```yaml
owner_address: pokt1v6ap5mmaaldw35vrhtmwm6uxr9dn3jz8zj9cmk
operator_address: pokt1v6ap5mmaaldw35vrhtmwm6uxr9dn3jz8zj9cmk
:::

Retrieve your external IP address:

```bash
EXTERNAL_IP=$(curl -4 ifconfig.me/ip)
```

Choose a port that'll be publicly accessible from the internet (e.g. `8545`)

```bash
sudo ufw allow 8545/tcp
```

Create a Supplier stake configuration file:

```bash
cat <<EOF > /tmp/stake_supplier_config.yaml
owner_address: $SUPPLIER_ADDR
operator_address: $SUPPLIER_ADDR
stake_amount: 1000069upokt
default_rev_share_percent:
pokt1v6ap5mmaaldw35vrhtmwm6uxr9dn3jz8zj9cmk: 100
$SUPPLIER_ADDR: 100
services:
- service_id: "morse"
endpoints:
- publicly_exposed_url: https://pocket-rpc.liquify.com
- publicly_exposed_url: http://$EXTERNAL_IP:8545
rpc_type: JSON_RPC
EOF
```

And run the following command to stake the `Supplier`:

```bash
poktrolld tx supplier stake-supplier --config /tmp/stake_supplier_config.yaml --from=$SUPPLIER_ADDR $TX_PARAM_FLAGS $NODE_FLAGS

# Optionally, to avoid entering the password each time:
# poktrolld tx supplier stake-supplier --config /tmp/stake_supplier_config.yaml --from=$SUPPLIER_ADDR $TX_PARAM_FLAGS $NODE_FLAGS --keyring-backend test
```
poktrolld tx supplier stake-supplier --config /var/folders/th/667_sx1j13343j4_k93ppf380000gn/T/tmp0gqsnj4k --from user_key_2ui31x --yes --output json --node tcp://127.0.0.1:26657 --chain-id poktroll --home /Users/olshansky/workspace/pocket/poktroll/localnet/poktrolld --keyring-backend test

After about a minute, you can check the `Supplier`'s status like so:

```bash
poktrolld query supplier show-supplier $SUPPLIER_ADDR $NODE_FLAGS
```

Here is an example of the output on Beta TestNet as of writing this document:
## RelayMiner Configuration

```json
default_signing_key_names: [user_key_ste8bz]
smt_store_path: /tmp/poktroll/smt
metrics:
enabled: true
addr: :9091
### Configure the RelayMiner

```bash
cat <<EOF > /tmp/relayminer_config.yaml
default_signing_key_names:
- supplier
smt_store_path: /home/pocket/.poktroll/smt
pocket_node:
query_node_rpc_url: https://shannon-testnet-grove-rpc.beta.poktroll.com
query_node_grpc_url: https://shannon-testnet-grove-grpc.beta.poktroll.com
query_node_grpc_url: https://shannon-testnet-grove-grpc.beta.poktroll.com:443
tx_node_rpc_url: https://shannon-testnet-grove-rpc.beta.poktroll.com
suppliers:
- service_id: svc_8ymf38
listen_url: http://localhost:8500
- service_id: "morse"
service_config:
backend_url: http://localhost:8547
backend_url: "https://pocket-rpc.liquify.com"
publicly_exposed_endpoints:
- localhost
pprof:
- $EXTERNAL_IP
listen_url: http://0.0.0.0:8545
metrics:
enabled: false
addr: localhost:6060
ping:
addr: :9090
pprof:
enabled: false
addr: localhost:8082
addr: :6060
EOF
```

#### Supplier Configuration

#### Supplier Transaction

poktrolld tx supplier stake-supplier --config /var/folders/th/667_sx1j13343j4_k93ppf380000gn/T/tmp0gqsnj4k --from user_key_2ui31x --yes --output json --node tcp://127.0.0.1:26657 --chain-id poktroll --home /Users/olshansky/workspace/pocket/poktroll/localnet/poktrolld --keyring-backend test
You can use the `ad d-service` command to create a new service like so:
### Start the RelayMiner

```bash
poktrolld tx service add-service ${SERVICE_ID} "${SERVICE_NAME_OR_DESCRIPTION}" ${COMPUTE_UNITS_PER_RELAY} --from ${SERVICE_OWNER}
poktrolld \
relayminer \
--grpc-insecure=false \
--log_level=debug \
--config=/tmp/relayminer_config.yaml \
# --keyring-backend=test
```

Here is a concrete copy-pasta assuming you have created and funded a new account called `$USER`:
### Secure vs Non-Secure `query_node_grpc_url`

```bash
poktrolld tx service add-service "svc-$USER" "service description for $USER" 69 \
--node https://shannon-testnet-grove-rpc.beta.poktroll.com \
--fees 1upokt --from $USER --chain-id pocket-beta
```
In `/tmp/relayminer_config.yaml`, you'll see that we specify an endpoint with TLS
for `query_node_grpc_url`.

Optionally, you can add some more flags to be ultra-verbose about your local environment:
If `grpc-insecure=true` then it **MUST** be an HTTP port, no TLS.

```bash
poktrolld tx service add-service "svc-$USER" "service description for $USER" 69 \
--node https://shannon-testnet-grove-rpc.beta.poktroll.com \
--fees 1upokt --from $USER --chain-id pocket-beta \
--home ~/.poktroll --keyring-backend test \
--yes --output json
```
The Grove team exposed one such endpoint on one of our validators for Beta Testnet at `http://149.28.34.68:9090`.
It can be validated with `grpcurl -plaintext 149.28.34.68:9090`; note that the `-plaintext` flag meaning no TLS encryption.

If `grpc-insecure=false`, then it **MUST** be an HTTPS port, with TLS.

The Grove team exposed one such endpoint on one of our validators for Beta Testnet at `https://shannon-testnet-grove-grpc.beta.poktroll.com:443`.
It can be validated with `grpcurl https://shannon-testnet-grove-grpc.beta.poktroll.com:443`; note no `-plaintext` flag meaning no TLS encryption.

:::tip

### How do I learn more about interacting with Suppliers?
You can replace both `http` and `https` with `tcp` and it should work the same.

#### Supplier Transactions
:::

## Supplier FAQ

### What Supplier transactions are available?

```bash
poktrolld tx supplier -h
```

#### Supplier Queries
### What Supplier queries are available?

```bash
poktrolld query supplier -h
```

### RelayMiners
### How do I query for all existing onchain Suppliers?

#### Retrieve the source code
Then, you can query for all services like so:

```bash
mkdir ~/workspace && cd ~/workspace
git clone https://github.com/pokt-network/poktroll-docker-compose-example.git
cd poktroll-docker-compose-example
poktrolld query supplier list-supplier --node https://shannon-testnet-grove-rpc.beta.poktroll.com --output json | jq
```

0 comments on commit 46fea4d

Please sign in to comment.