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

icq relayer keyring configuration added #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
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
78 changes: 75 additions & 3 deletions docs/relaying/icq-relayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,32 @@ This section contains description for all the possible config values that the Re
- `RELAYER_NEUTRON_CHAIN_RPC_ADDR` — RPC address of a Neutron node to interact with (e.g. get events and to submit results);
- `RELAYER_NEUTRON_CHAIN_REST_ADDR` — REST address of a Neutron node to interact with (e.g. get registered queries list);
- `RELAYER_NEUTRON_CHAIN_HOME_DIR` — path to keys directory;
- `RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME` — name of the key pair to be used by the Relayer;
- `RELAYER_NEUTRON_CHAIN_TIMEOUT` — timeout for Neutron RPC calls;
- `RELAYER_NEUTRON_CHAIN_GAS_PRICES` — the price for a unit of gas used by the Relayer;
- `RELAYER_NEUTRON_CHAIN_GAS_LIMIT` — the maximum price to be paid for a single submission;
- `RELAYER_NEUTRON_CHAIN_GAS_ADJUSTMENT` — gas multiplier used in order to avoid underestimating;
- `RELAYER_NEUTRON_CHAIN_CONNECTION_ID` — Neutron chain connection ID; Relayer will only relay events for this connection;
- `RELAYER_NEUTRON_CHAIN_DEBUG` — flag to run neutron chain provider in debug mode;
- `RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND` — described [here](https://docs.cosmos.network/master/run-node/keyring.html#the-kwallet-backend);
- `RELAYER_NEUTRON_CHAIN_OUTPUT_FORMAT` — Neutron chain provider output format;
- `RELAYER_NEUTRON_CHAIN_SIGN_MODE_STR` — described [here](https://docs.cosmos.network/master/core/transactions.html#signing-transactions), also consider use short variation, e.g. `direct`.

#### Keyring settings

- `RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND` — the type of backend (more about keyring types [here](https://docs.cosmos.network/master/run-node/keyring.html#the-kwallet-backend));
Copy link
Contributor

@sotnikov-s sotnikov-s Nov 30, 2022

Choose a reason for hiding this comment

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

do you think we need the NEUTRON_CHAIN part in these variable names? I'd simplify to RELAYER_KEYRING_BACKEND and so on:

  1. we don't have corresponding values for the target chain, so no need to specify it. I mean, it should be obvious that we have keyring-related values only at the neutron's side, whereas such NEUTRON_CHAIN parts in names would only confuse the user like "oh, here's neutron's side keyring... is there a not-neutron's side keyring...?";
  2. these are not the neutron chain specific values, these are relayer's values.

given the above, I'd remove the NEUTRON_CHAIN part from all keyring related variables and also moved the gas-related values to this, say, "group":

RELAYER_NEUTRON_CHAIN_RPC_ADDR
RELAYER_NEUTRON_CHAIN_REST_ADDR
RELAYER_NEUTRON_CHAIN_HOME_DIR
RELAYER_NEUTRON_CHAIN_TIMEOUT
RELAYER_NEUTRON_CHAIN_CONNECTION_ID
RELAYER_NEUTRON_CHAIN_OUTPUT_FORMAT
RELAYER_NEUTRON_CHAIN_DEBUG

RELAYER_KEYRING_BACKEND
RELAYER_KEYRING_PASSWORD
RELAYER_SIGN_KEY_NAME
RELAYER_SIGN_KEY_SEED
RELAYER_SIGN_KEY_HD_PATH
RELAYER_SIGN_MODE_STR
RELAYER_GAS_PRICES
RELAYER_GAS_LIMIT
RELAYER_GAS_ADJUSTMENT

RELAYER_TARGET_CHAIN_RPC_ADDR
RELAYER_TARGET_CHAIN_ACCOUNT_PREFIX
RELAYER_TARGET_CHAIN_VALIDATOR_ACCOUNT_PREFIX
RELAYER_TARGET_CHAIN_TIMEOUT
RELAYER_TARGET_CHAIN_DEBUG
RELAYER_TARGET_CHAIN_OUTPUT_FORMAT

RELAYER_REGISTRY_ADDRESSES

what do you think?

- `RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME` — name of the key used by the relayer;
- `RELAYER_NEUTRON_CHAIN_KEYRING_PASSWORD` — password for accessing the keyring;
- `RELAYER_NEUTRON_CHAIN_SIGN_KEY_SEED` — mnemonic of the key for `memory` backend;
- `RELAYER_NEUTRON_CHAIN_SIGN_KEY_HD_PATH` — HD path of the key for `memory` backend.

The table below describes which parameters are required for different backends types.

| Key name | os | file | pass | kwallet | test | memory |
|------------------------------------------|----------|----------|----------|----------|----------|----------|
| `RELAYER_NEUTRON_CHAIN_KEYRING_PASSWORD` | required | required | required | required | ignored | ignored |
| `RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME` | required | required | required | required | required | ignored |
| `RELAYER_NEUTRON_CHAIN_SIGN_KEY_SEED` | ignored | ignored | ignored | ignored | ignored | required |
| `RELAYER_NEUTRON_CHAIN_SIGN_KEY_HD_PATH` | ignored | ignored | ignored | ignored | ignored | optional |

### Target chain node settings

- `RELAYER_TARGET_CHAIN_RPC_ADDR` — RPC address of a target chain node to interact with (e.g. send queries);
Expand Down Expand Up @@ -99,6 +114,35 @@ Before running the Relayer application for production purposes, you need to crea

### Setting up Relayer wallet

**Recommended keyring backends for production environments are `memory` and `file`**.

However, ICQ relayer supports all the types of keyring backends that are typically supported by cosmos apps.
Other types of backends are not recommended because of following reasons:

1. `kwallet` and `pass` backends typically request password in an interactive mode which is not suitable for the way ICQ relayer works;
2. `kwallet` itself is a UI-only thing;
3. `test` backend stores keys unencrypted;
4. `os` might require providing an app the os-level secret.

#### Using the `memory` backend

The `memory` keyring in ICQ relayer works in a way where the relayer creates empty in-memory key storage and put there the key based on environment variables (mnemonic and HD Path).
HD Path default value is `m/44'/118'/0'/0/0`.

`.env` file example for the `memory` backend:

```
...
RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND=test
Copy link
Contributor

Choose a reason for hiding this comment

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

here should've been RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND=memory I presume

RELAYER_NEUTRON_CHAIN_SIGN_KEY_SEED="my awesome super secure mnemonic ..."
RELAYER_NEUTRON_CHAIN_SIGN_KEY_HD_PATH="m/44'/118'/0'/0/1"
...
```

#### Using the `test` backend

While not being recommended for using in production deployments, `test` backend is suitable for any types of testing environments.

1. The keyring folder for Relayer's usage is configured by the `RELAYER_NEUTRON_CHAIN_HOME_DIR` variable. The easiest way is to run `neutrond keys` from the cloned [neutron repository](https://github.com/neutron-org/neutron) and get the default value from the `--keyring-dir` flag:

```
Expand All @@ -115,9 +159,37 @@ Global Flags:
```

2. Then execute `neutrond keys add relayer --keyring-backend test` to create an account in the default keyring directory;
3. Use `relayer` as the `RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME`, `test` as the `RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND`, and pass the keyring directory as a volume to the Relayer's docker container using the keyring path in the container as the `RELAYER_NEUTRON_CHAIN_HOME_DIR`;
3. Add necessary parameters into `.env` file, for example:

```
...
RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND=test
RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME=relayer
RELAYER_NEUTRON_CHAIN_HOME_DIR=/home/user/.neutrond
...
```

4. Get the Relayer's wallet address and top its balance up. If you're running the Relayer on the testnet, use the official Neutron faucet. For the mainnet, get some NTRN for the address.

#### Using the `file` backend

The process is almost the same as for `test` backend. The only difference is that `RELAYER_NEUTRON_CHAIN_KEYRING_PASSWORD` has to be specified.

1. Add keys with `neutrond`, e.g.:

`neutrond keys add relayer --keyring-backend file`

2. Add necessary parameters into `.env` file, for example:

```
...
RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND=file
RELAYER_NEUTRON_CHAIN_KEYRING_PASSWORD=P@ssword1
RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME=relayer
RELAYER_NEUTRON_CHAIN_HOME_DIR=/home/user/.neutrond
...
```

## Running the Relayer

1. Make sure you've finished the [Configuration](#configuration) part;
Expand Down