This repository hosts rollapp-wasm, a template implementation of a dymension rollapp.
rollapp-wasm is an example of a working RollApp using dymension-RDK and dymint.
It uses Cosmos-SDK's simapp as a reference, but with the following changes:
- minimal app setup
- wired IBC for ICS 20 Fungible Token Transfers
- Uses
dymintfor block sequencing and replacingtendermint - Uses modules from
dymension-RDKto sync withdymintand provide RollApp custom logic
Note: Requires Go 1.21
Build and install the rollapp-wasm binary:
export BECH32_PREFIX=rol
make install BECH32_PREFIX=$BECH32_PREFIXexport the following variables:
export EXECUTABLE="rollapp-wasm"
export BECH32_PREFIX="rol"
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-wasm"
export ROLLAPP_SETTLEMENT_INIT_DIR_PATH="${ROLLAPP_HOME_DIR}/init"And initialize the rollapp:
sh scripts/init.shYou can find out in https://github.com/CosmWasm/wasmd#compile-time-parameters that:
There are a few variables was allow blockchains to customize at compile time. If you build your own chain and import x/wasm, you can adjust a few items via module parameters, but a few others did not fit in that, as they need to be used by stateless ValidateBasic(). Thus, we made them as flags and set them in start.go so that they can be overridden on your custom chain.
rollapp-wasm start --max-label-size 64 --max-wasm-size 2048000 --max-wasm-proposal-size 2048000Those flags are optional, the default value was set as:
wasmtypes.MaxLabelSize = 128
wasmtypes.MaxWasmSize = 819200
wasmtypes.MaxProposalWasmSize = 3145728Download cw20-ics20 smartcontract with a specific version:
sh scripts/download_release.sh v1.0.0rollapp-wasm startYou should have a running local rollapp!
Follow the instructions on Dymension docs 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:
export HUB_RPC_ENDPOINT="http://localhost"
export HUB_RPC_PORT="36657" # default: 36657
export HUB_RPC_URL="${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}
export HUB_KEY_WITH_FUNDS="hub-user" # This key should exist on the keyring-backend testcreate sequencer key using dymd
dymd keys add sequencer --keyring-dir ~/.rollapp-wasm/sequencer_keys --keyring-backend test
SEQUENCER_ADDR=`dymd keys show sequencer --address --keyring-backend test --keyring-dir ~/.rollapp-wasm/sequencer_keys`fund the sequencer account
# 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 --node ${HUB_RPC_URL} | jq -r '.params.min_bond.amount')$(dymd q sequencer params -o jsono | jq -r '.params.min_bond.denom')"
echo $BOND_AMOUNT
# Extract the numeric part
NUMERIC_PART=$(echo $BOND_AMOUNT | sed 's/adym//')
# Add 100000000000000000000 for fees
NEW_NUMERIC_PART=$(echo "$NUMERIC_PART + 100000000000000000000" | bc)
# Append 'adym' back
TRANSFER_AMOUNT="${NEW_NUMERIC_PART}adym"
dymd tx bank send $HUB_KEY_WITH_FUNDS $SEQUENCER_ADDR ${TRANSFER_AMOUNT} --keyring-backend test --broadcast-mode block --fees 1dym -y --node ${HUB_RPC_URL} --chain-id ${HUB_CHAIN_ID}sh scripts/settlement/generate_denom_metadata.shsh scripts/settlement/add_genesis_accounts.shsh scripts/settlement/register_rollapp_to_hub.shsh scripts/settlement/register_sequencer_to_hub.shModify dymint.toml in the chain directory (~/.rollapp/config)
set:
linux:
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"mac:
sed -i '' 's/settlement_layer.*/settlement_layer = "dymension"/' ${ROLLAPP_HOME_DIR}/config/dymint.toml
sed -i '' 's|node_address =.*|node_address = '\"$HUB_RPC_URL\"'|' "${ROLLAPP_HOME_DIR}/config/dymint.toml"
sed -i '' 's|rollapp_id =.*|rollapp_id = '\"$ROLLAPP_CHAIN_ID\"'|' "${ROLLAPP_HOME_DIR}/config/dymint.toml"rollapp-wasm startor as a systemd service:
sudo tee /etc/systemd/system/rollapp-wasm.service > /dev/null <<EOF
[Unit]
Description=rollapp-wasm
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=$(which rollapp-wasm) start
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reloadgit clone https://github.com/dymensionxyz/go-relayer.git --branch v0.2.0-v2.3.1-relayer
cd go-relayer && make installwhile the rollapp and the local dymension hub node running, run:
sh scripts/ibc/setup_ibc.shAfter successful run, the new established channels will be shown
rly start hub-rollappor as a systemd service:
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
EOFsh scripts/wasm/deploy_contract.shsh scripts/wasm/ibc_transfer.shStop the rollapp:
kill $(pgrep rollapp-wasm)Linux:
sed -i 's/empty_blocks_max_time = "3s"/empty_blocks_max_time = "3600s"/' ${ROLLAPP_HOME_DIR}/config/dymint.tomlMac:
sed -i '' 's/empty_blocks_max_time = "3s"/empty_blocks_max_time = "3600s"/' ${ROLLAPP_HOME_DIR}/config/dymint.tomlStart the rollapp:
rollapp-wasm start