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

chore: add advanced setup #44

Merged
merged 9 commits into from
Apr 11, 2024
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ export the following variables:
```shell
export ROLLAPP_CHAIN_ID="rollappwasm_1234-1"
export KEY_NAME_ROLLAPP="rol-user"
export DENOM="urax"
export BASE_DENOM="awsm"
export DENOM=$(echo "$BASE_DENOM" | sed 's/^.//')
export MONIKER="$ROLLAPP_CHAIN_ID-sequencer"

export ROLLAPP_HOME_DIR="$HOME/.rollapp"
export ROLLAPP_SETTLEMENT_INIT_DIR_PATH="${ROLLAPP_HOME_DIR}/init"
```

And initialize the rollapp:
Expand Down Expand Up @@ -82,6 +86,20 @@ You should have a running local rollapp!

Follow the instructions on [Dymension docs](https://docs.dymension.xyz/validate/dymension/build-dymd?network=localhost) to run local dymension hub node

all scripts are adjusted to use local hub node that's hosted on the default port `localhost:36657`.

configuration with a remote hub node is also supported, the following variables must be set:

```shell
export HUB_RPC_ENDPOINT="http://localhost"
export HUB_RPC_PORT="36657" # default: 36657
export HUB_RPC_URL="http://${HUB_RPC_ENDPOINT}:${HUB_RPC_PORT}"
export HUB_CHAIN_ID="dymension_100-1"

dymd config chain-id ${HUB_CHAIN_ID}
dymd config node ${HUB_RPC_URL}
```

### Create sequencer keys

create sequencer key using `dymd`
Expand All @@ -94,7 +112,13 @@ SEQUENCER_ADDR=`dymd keys show sequencer --address --keyring-backend test --keyr
fund the sequencer account

```shell
dymd tx bank send local-user $SEQUENCER_ADDR 10000000000000000000000adym --keyring-backend test --broadcast-mode block --fees 20000000000000adym -y
# this will retrieve the min bond amount from the hub
# if you're using an new address for registering a sequencer,
# you have to account for gas fees so it should the final value should be increased
BOND_AMOUNT="$(dymd q sequencer params -o json | jq -r '.params.min_bond.amount')$(dymd q sequencer params -o jsono | jq -r '.params.min_bond.denom')"
echo $BOND_AMOUNT

dymd tx bank send local-user dym1978q3tcxwg0ldzgv7ynfr3mzytr9qfsuwjt7tl 100000000000000000000000adym --keyring-backend test --broadcast-mode block --fees 20000000000000adym -y
```

### Register rollapp on settlement
Expand All @@ -115,8 +139,9 @@ Modify `dymint.toml` in the chain directory (`~/.rollapp/config`)
set:

```shell
settlement_layer = "dymension"
gas_prices = "0.025adym"
sed -i 's/settlement_layer.*/settlement_layer = "dymension"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
sed -i '/node_address =/c\node_address = '\"$HUB_RPC_URL\" "${ROLLAPP_HOME_DIR}/config/dymint.toml"
sed -i '/rollapp_id =/c\rollapp_id = '\"$ROLLAPP_CHAIN_ID\" "${ROLLAPP_HOME_DIR}/config/dymint.toml"
```

### Run rollapp locally
Expand Down
244 changes: 244 additions & 0 deletions README.with-advanced-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
# Dymension WASM Rollapp

## rollappd - A template WASM RollApp chain

This repository hosts `rollappd`, a template implementation of a dymension rollapp with `WASM` execution layer.

`rollappd` is an example of a working RollApp using `dymension-RDK` and `dymint`.

It uses Cosmos-SDK's [simapp](https://github.com/cosmos/cosmos-sdk/tree/main/simapp) as a reference, but with the following changes:

- minimal app setup
- wired IBC for [ICS 20 Fungible Token Transfers](https://github.com/cosmos/ibc/tree/main/spec/app/ics-020-fungible-token-transfer)
- Uses `dymint` for block sequencing and replacing `tendermint`
- Uses modules from `dymension-RDK` to sync with `dymint` and provide RollApp custom logic

## Overview

**Note**: Requires [Go 1.20](https://go.dev/)

## Quick guide

Get started with [building RollApps](https://docs.dymension.xyz/develop/get-started/setup)

## Installing / Getting started

Build and install the ```rollappd``` binary:

```shell
make install
```

### Initial configuration

export the following variables:

```shell
export ROLLAPP_CHAIN_ID="rollappwasm_1234-1"
export KEY_NAME_ROLLAPP="rol-user"
export BASE_DENOM="awsm"
export DENOM=$(echo "$BASE_DENOM" | sed 's/^.//')
export MONIKER="$ROLLAPP_CHAIN_ID-sequencer"

export ROLLAPP_HOME_DIR="$HOME/.rollapp"
export ROLLAPP_SETTLEMENT_INIT_DIR_PATH="${ROLLAPP_HOME_DIR}/init"
```

if you want to change the max wasm size:

```shell
export MAX_WASM_SIZE=WASM_SIZE_IN_BYTES
```

And initialize the rollapp:

```shell
sh scripts/init.sh
```

### Download cw20-ics20 smartcontract

Download cw20-ics20 smartcontract with a specific version:

```shell
bash scripts/download_release.sh v1.0.0
```

### Run rollapp

```shell
rollappd start
```

You should have a running local rollapp!

## Run a rollapp with a settlement node

### Run local dymension hub node

Follow the instructions on [Dymension Hub docs](https://docs.dymension.xyz/develop/get-started/run-base-layers) to run local dymension hub node

all scripts are adjusted to use local hub node that's hosted on the default port `localhost:36657`.

configuration with a remote hub node is also supported, the following variables must be set:

```shell
export HUB_RPC_ENDPOINT="http://localhost"
export HUB_RPC_PORT="36657" # default: 36657
export HUB_RPC_URL="http://${HUB_RPC_ENDPOINT}:${HUB_RPC_PORT}"
export HUB_CHAIN_ID="dymension_100-1"

dymd config chain-id ${HUB_CHAIN_ID}
dymd config node ${HUB_RPC_URL}
```

### Create sequencer keys

create sequencer key using `dymd`

```shell
dymd keys add sequencer --keyring-dir ${ROLLAPP_HOME_DIR}/sequencer_keys --keyring-backend test
SEQUENCER_ADDR=`dymd keys show sequencer --address --keyring-backend test --keyring-dir ${ROLLAPP_HOME_DIR}/sequencer_keys`
```

fund the sequencer account (if you're using a remote hub node, you must fund the sequencer account or you must have an account with enough funds in your keyring)

```shell
# this will retrieve the min bond amount from the hub
# if you're using an new address for registering a sequencer,
# you have to account for gas fees so it should the final value should be increased
BOND_AMOUNT="$(dymd q sequencer params -o json | jq -r '.params.min_bond.amount')$(dymd q sequencer params -o json | jq -r '.params.min_bond.denom')"

dymd tx bank send local-user $SEQUENCER_ADDR ${BOND_AMOUNT} --keyring-backend test --broadcast-mode block --fees 1dym -y
```

### Generate denommetadata

```shell

sh scripts/settlement/generate_denom_metadata.sh
```

### Add genesis accounts


Check failure on line 124 in README.with-advanced-features.md

View workflow job for this annotation

GitHub Actions / markdownlint

Multiple consecutive blank lines [Expected: 1; Actual: 2]
```shell
sh scripts/settlement/add_genesis_accounts.sh
```

### Register rollapp on settlement

```shell
# for permissioned deployment setup, you must have access to an account whitelisted for rollapp
# registration, assuming you want to import an existing account, you can do:
dymd keys add local-user --recover
# input mnemonic from the account that has the permission to register rollapp

sh scripts/settlement/register_rollapp_to_hub.sh
```

### Register sequencer for rollapp on settlement

```shell
sh scripts/settlement/register_sequencer_to_hub.sh
```

### Configure the rollapp

Modify `dymint.toml` in the chain directory (`${ROLLAPP_HOME_DIR}/config`)

set:

```shell
sed -i 's/settlement_layer.*/settlement_layer = "dymension"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
sed -i '/node_address =/c\node_address = '\"$HUB_RPC_URL\" "${ROLLAPP_HOME_DIR}/config/dymint.toml"
sed -i '/rollapp_id =/c\rollapp_id = '\"$ROLLAPP_CHAIN_ID\" "${ROLLAPP_HOME_DIR}/config/dymint.toml"
```

### Update the Genesis file to include the denommetadata, genesis accounts, module account and elevated accounts

```shell
sh scripts/update_genesis_file.sh
```

### Update the Genesis file to include the denommetadata, genesis accounts, module account and elevated accounts

Check failure on line 164 in README.with-advanced-features.md

View workflow job for this annotation

GitHub Actions / markdownlint

Multiple headings with the same content [Context: "### Update the Genesis file to..."]

```shell
# this script automatically adds 2 vesting accounts, adjust the timestampts to your liking or skip this step
sh scripts/add_vesting_accounts_to_genesis_file.sh
```

### Run rollapp locally

```shell
rollappd start
```

or as a systemd service:

```shell
sudo tee /etc/systemd/system/rollapp.service > /dev/null <<EOF
[Unit]
Description=rollapp
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=$(which rollappd) start
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
```

## Setup IBC between rollapp and local dymension hub node

### Install dymension relayer

```shell
git clone https://github.com/dymensionxyz/go-relayer.git --branch v0.2.0-v2.3.1-relayer
cd go-relayer && make install
```

### Establish IBC channel

while the rollapp and the local dymension hub node running, run:

```shell
sh scripts/ibc/setup_ibc.sh
```

After successful run, the new established channels will be shown

### run the relayer

```shell
rly start hub-rollapp
```

or as a systemd service:

```shell
sudo tee /etc/systemd/system/relayer.service > /dev/null <<EOF
[Unit]
Description=rollapp
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=$(which rly) start hub-rollapp
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
```


Check failure on line 241 in README.with-advanced-features.md

View workflow job for this annotation

GitHub Actions / markdownlint

Multiple consecutive blank lines [Expected: 1; Actual: 2]
## Developers guide

TODO
14 changes: 14 additions & 0 deletions scripts/add_vesting_accounts_to_genesis_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
BINARY="rollappd"

$BINARY keys add three-year-vester --keyring-backend test
$BINARY add-genesis-account three-year-vester \
10000000000000000000000${BASE_DENOM} --keyring-backend test \
--vesting-amount 10000000000000000000000${BASE_DENOM} \
--vesting-end-time 1805902584

$BINARY keys add two-year-vester-after-1-week --keyring-backend test
$BINARY add-genesis-account two-year-vester-after-1-week \
10000000000000000000000${BASE_DENOM} --keyring-backend test \
--vesting-amount 10000000000000000000000${BASE_DENOM} \
--vesting-end-time 1774366584 --vesting-start-time 1711985835
Loading
Loading