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

Community Pool Liquid Staking - Phase 1/3 - Liquid Stake and Redeem #926

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
# Commit: ec337e0357ae6b6727ad9092ac0ce3667df91319
path = deps/evmos
url = https://github.com/evmos/evmos
[submodule "deps/dydx"]
# TODO [DYDX]: Switch to official dydxprotocol release after ICA PR is merged
# Commit: fafd3a9e2083180d7f7809f5080897e714e52bec
path = deps/dydx
url = https://github.com/Stride-Labs/v4-chain.git
[submodule "deps/noble"]
# Commit: v3.1.0
path = deps/noble
url = https://github.com/strangelove-ventures/noble.git
# bats
[submodule "dockernet/tests/bats/bats-core"]
path = dockernet/tests/bats/bats-core
Expand Down
1 change: 1 addition & 0 deletions deps/dydx
Submodule dydx added at fafd3a
1 change: 1 addition & 0 deletions deps/noble
Submodule noble added at d14503
38 changes: 23 additions & 15 deletions dockernet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
## Dockernet
### Adding a new host zone
* Create a new dockerfile to `dockernet/dockerfiles` (named `Dockerfile.{new-host-zone}`). Use one of the other host zone's dockerfile's as a starting port to provide the certain boilerplate such as the package installs, adding user, exposing ports, etc. You can often find a dockerfile in the github directory of the host zone. In the dockerfile, set `COMMIT_HASH` to the current mainnet commit hash of the chain being tested (or the target commit hash, if we're launching the zone in the future after an upgrade). For newer chains, create a branch and a pull-request, but *do not* merge it (we don't maintain test versions of each chain).
* Add the repo as a submodule
```
* Add the repo as a submodule(e.g. https://github.com/dydxprotocol/v4-chain.git)
```bash
# run from the top level stride repo
git submodule add {repo-url} deps/{new-host-zone}
```
* Update the commit hash
```
```bash
cd deps/{new-host-zone}
git checkout {commit-hash}
cd ..
```
* Add a comment to `.gitmodules` with the commit hash
* Add the build command for that host zone in `dockernet/build.sh`. For most zones, we use the first letter of the zone, for the new zone, just use `n` (since it won't be merged in, it won't conflict with anything).
* Add the build command for that host zone in `dockernet/build.sh`. For most zones, we use the first letter of the zone, for the new zone, just use `z` (since it won't be merged in, it won't conflict with anything).
```
while getopts sgojhir{n} flag; do
while getopts sgojhir{z} flag; do
case "${flag}" in
...
n) build_local_and_docker {new-host-zone} deps/{new-host-zone} ;;
z) build_local_and_docker {new-host-zone} deps/{new-host-zone} ;;
```
* Before moving on, test that you can build the binary and docker iamge by running
```bash
make build-docker build={z}
```
* Add the host zone and relayer to `dockernet/docker-compose.yml`. Add 5 nodes, adding port forwarding to the first node only. Add the relayer. Drop the RPC port number by 100, and the API/gRPC port by 10, relative to the last host zone that was added.
```
Expand All @@ -44,12 +49,12 @@ while getopts sgojhir{n} flag; do
volumes:
- ./dockernet/state/{new-host-zone}5:/home/{new-host-zone}/.{new-host-zone}d
...
relayer-{chain_id}:
relayer-{chain}:
image: stridezone:relayer
volumes:
- ./state/relayer-{chain_id}:/home/relayer/.relayer
- ./state/relayer-{chain}:/home/relayer/.relayer
restart: always
command: [ "bash", "start.sh", "stride-{chain_id}" ]
command: [ "bash", "start.sh", "stride-{chain}" ]
```
* Add the following parameters to `dockernet/config.sh`, where `CHAIN` is the ID of the new host zone. For the relayer, you can use the mnemonic below or create your own. Note: you'll have to add the variables in the right places in `dockernet/config.sh`, as noted below.
```
Expand Down Expand Up @@ -80,13 +85,16 @@ ST{CHAIN}_DENOM="st{min_denom}"
RELAYER_{CHAIN}_EXEC="docker-compose run --rm relayer-{new-host-zone}"
RELAYER_{CHAIN}_ACCT=rly{add one since the account from the last host zone}

# NOTE: Update the RELAYER_ACCTS variable directly!
RELAYER_ACCTS=(... $RELAYER_{CHAIN}_ACCT)
# NOTE: Update the STRIDE_RELAYER_ACCTS variable directly!
STRIDE_RELAYER_ACCTS=(
...
$RELAYER_{CHAIN}_ACCT
)

# stride1muwz5er4wq7svxnh5dgn2tssm92je5dwthxl7q
RELAYER_{CHAIN}_MNEMONIC="science depart where tell bus ski laptop follow child bronze rebel recall brief plug razor ship degree labor human series today embody fury harvest"
# NOTE: Update the RELAYER_MNEMONICS variable directly!
RELAYER_MNEMONICS=(
# NOTE: Update the STRIDE_RELAYER_MNEMONICS variable directly!
STRIDE_RELAYER_MNEMONICS=(
...
"$RELAYER_{CHAIN}_MNEMONIC"
)
Expand All @@ -97,8 +105,8 @@ ${CHAIN_ID}_ADDRESS() {
}

```
* Add the IBC denom's for the host zone across each channel to `dockernet/config.sh` (e.g. `IBC_{HOST}_CHANNEL_{N}_DENOM)`). You can generate the variables by uncommenting `x/stakeibc/keeper/get_denom_traces_test.go`, specifying the ChainID and denom, and running `make test-unit`. Add the output to `dockernet/config.sh`. Note: You have to run the test using the "run test" button in VSCode, or pass in the `-v` flag and run the tests using `go test -mod=readonly ./x/stakeibc/...`, for the output to show up.
* Add a section to the `dockernet/config/relayer_config.yaml`. Most chains will use either the cosmos coin type (118) or eth coin type (60). If a new coin type is used, add it to the top of `config.sh` for future reference.
* Add the IBC denoms for the host zone across each channel to `dockernet/config.sh` (e.g. `IBC_{HOST}_CHANNEL_{N}_DENOM)`). You can generate the variables by uncommenting `x/stakeibc/keeper/get_denom_traces_test.go`, specifying the ChainID and denom, and running `make test-unit`. Add the output to `dockernet/config.sh`. Note: You have to run the test using the "run test" button in VSCode, or pass in the `-v` flag and run the tests using `go test -mod=readonly ./x/stakeibc/...`, for the output to show up.
* Add a section to the `dockernet/config/relayer_config_stride.yaml`. Most chains will use either the cosmos coin type (118) or eth coin type (60). If a new coin type is used, add it to the top of `config.sh` for future reference.
```
chains:
...
Expand Down
6 changes: 4 additions & 2 deletions dockernet/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ revert_admin_address() {


# build docker images and local binaries
while getopts sgojtehrn flag; do
while getopts sgojtednhrz flag; do
case "${flag}" in
# For stride, we need to update the admin address to one that we have the seed phrase for
s) replace_admin_address
Expand All @@ -99,7 +99,9 @@ while getopts sgojtehrn flag; do
o) build_local_and_docker osmo deps/osmosis ;;
t) build_local_and_docker stars deps/stargaze ;;
e) build_local_and_docker evmos deps/evmos ;;
n) continue ;; # build_local_and_docker {new-host-zone} deps/{new-host-zone} ;;
d) build_local_and_docker dydx deps/dydx/protocol ;;
n) build_local_and_docker noble deps/noble ;;
z) continue ;; # build_local_and_docker {new-host-zone} deps/{new-host-zone} ;;
r) build_local_and_docker relayer deps/relayer ;;
h) echo "Building Hermes Docker... ";
docker build --tag stridezone:hermes -f dockernet/dockerfiles/Dockerfile.hermes . ;
Expand Down
128 changes: 120 additions & 8 deletions dockernet/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ TX_LOGS=$DOCKERNET_HOME/logs/tx.log
KEYS_LOGS=$DOCKERNET_HOME/logs/keys.log

# List of hosts enabled
HOST_CHAINS=()
# HOST_CHAINS have liquid staking support, ACCESSORY_CHAINS do not
HOST_CHAINS=()
ACCESSORY_CHAINS=()

# If no host zones are specified above:
# `start-docker` defaults to just GAIA if HOST_CHAINS is empty
Expand All @@ -28,6 +30,8 @@ HOST_CHAINS=()
# - STARS
# - EVMOS
# - HOST (Stride chain enabled as a host zone)
# - DYDX
# - NOBLE (only runs as an accessory chain - does not have liquid staking functionality)
if [[ "${ALL_HOST_CHAINS:-false}" == "true" ]]; then
HOST_CHAINS=(GAIA EVMOS HOST)
elif [[ "${#HOST_CHAINS[@]}" == "0" ]]; then
Expand All @@ -42,12 +46,16 @@ OSMO_DENOM="uosmo"
STARS_DENOM="ustars"
WALK_DENOM="uwalk"
EVMOS_DENOM="aevmos"
DYDX_DENOM="udydx"
NOBLE_DENOM="utoken"
USDC_DENOM="uusdc"
STATOM_DENOM="stuatom"
STJUNO_DENOM="stujuno"
STOSMO_DENOM="stuosmo"
STSTARS_DENOM="stustars"
STWALK_DENOM="stuwalk"
STEVMOS_DENOM="staevmos"
STDYDX_DENOM="studydx"

IBC_STRD_DENOM='ibc/FF6C2E86490C1C4FBBD24F55032831D2415B9D7882F85C3CC9C2401D79362BEA'

Expand Down Expand Up @@ -81,6 +89,11 @@ IBC_HOST_CHANNEL_1_DENOM='ibc/FB7E2520A1ED6890E1632904A4ACA1B3D2883388F8E2B88F2D
IBC_HOST_CHANNEL_2_DENOM='ibc/D664DC1D38648FC4C697D9E9CF2D26369318DFE668B31F81809383A8A88CFCF4'
IBC_HOST_CHANNEL_3_DENOM='ibc/FD7AA7EB2C1D5D97A8693CCD71FFE3F5AFF12DB6756066E11E69873DE91A33EA'

IBC_DYDX_CHANNEL_0_DENOM='ibc/815D14313C85CADBDFCEB13C8028DB853BE16CF6600D6B3A90ECFB7DCF1FAAF9'
IBC_DYDX_CHANNEL_1_DENOM='ibc/78B7A771A2ECBF5D10DC6AB35568A7AC4161DB21B3A848DA470655358A6DD854'
IBC_DYDX_CHANNEL_2_DENOM='ibc/748465E0D883217048DB25F4C3825D03F682A06FE292E21072BF678E249DAC18'
IBC_DYDX_CHANNEL_3_DENOM='ibc/6301148031C0AC9A392C2DDB1B2D1F11B3B9D0A3ECF20C6B5122685D9E4CC631'

# COIN TYPES
# Coin types can be found at https://github.com/satoshilabs/slips/blob/master/slip-0044.md
COSMOS_COIN_TYPE=118
Expand Down Expand Up @@ -241,6 +254,36 @@ EVMOS_MAIN_CMD="$EVMOS_BINARY --home $DOCKERNET_HOME/state/${EVMOS_NODE_PREFIX}1
EVMOS_RECEIVER_ADDRESS='evmos123z469cfejeusvk87ufrs5520wmdxmmlc7qzuw'
EVMOS_MICRO_DENOM_UNITS="000000000000000000000000"

# DYDX
DYDX_CHAIN_ID=DYDX
DYDX_NODE_PREFIX=dydx
DYDX_NUM_NODES=1
DYDX_BINARY="$DOCKERNET_HOME/../build/dydxprotocold"
DYDX_VAL_PREFIX=val
DYDX_ADDRESS_PREFIX=dydx
DYDX_REV_ACCT=rev
DYDX_DENOM=$DYDX_DENOM
DYDX_RPC_PORT=25957
DYDX_MAIN_CMD="$DYDX_BINARY --home $DOCKERNET_HOME/state/${DYDX_NODE_PREFIX}1"
DYDX_RECEIVER_ADDRESS='dydx1q9caajs6wrfu2yhytvkqd2csxycx6revdcme9y'
# The micro denom is actually the same as default cosmos chains but there's a
# minimum stake amount so this effectively gets the validator over the minimum
DYDX_MICRO_DENOM_UNITS="000000000000000"

# NOBLE
NOBLE_CHAIN_ID=NOBLE
NOBLE_NODE_PREFIX=noble
NOBLE_NUM_NODES=1
NOBLE_BINARY="$DOCKERNET_HOME/../build/nobled"
NOBLE_VAL_PREFIX=val
NOBLE_ADDRESS_PREFIX=noble
NOBLE_REV_ACCT=rev
NOBLE_DENOM=$NOBLE_DENOM
NOBLE_RPC_PORT=25857
NOBLE_MAIN_CMD="$NOBLE_BINARY --home $DOCKERNET_HOME/state/${NOBLE_NODE_PREFIX}1"
NOBLE_RECEIVER_ADDRESS='noble1dd9sxkz3wr723lsf65h549ykdh4npxzh5qawmg'
NOBLE_AUTHORITHY_MNEMONIC="giant screen unit high agree swing impact switch lend universe sand myself conduct sustain august barely misery lawsuit honey social version window demise palace"

# RELAYER
RELAYER_GAIA_EXEC="$DOCKER_COMPOSE run --rm relayer-gaia"
RELAYER_GAIA_ICS_EXEC="$DOCKER_COMPOSE run --rm relayer-gaia-ics"
Expand All @@ -249,42 +292,58 @@ RELAYER_OSMO_EXEC="$DOCKER_COMPOSE run --rm relayer-osmo"
RELAYER_STARS_EXEC="$DOCKER_COMPOSE run --rm relayer-stars"
RELAYER_HOST_EXEC="$DOCKER_COMPOSE run --rm relayer-host"
RELAYER_EVMOS_EXEC="$DOCKER_COMPOSE run --rm relayer-evmos"
RELAYER_DYDX_EXEC="$DOCKER_COMPOSE run --rm relayer-dydx"
RELAYER_NOBLE_EXEC="$DOCKER_COMPOSE run --rm relayer-noble"

# Accounts for relay paths with stride
RELAYER_STRIDE_ACCT=rly1
RELAYER_GAIA_ACCT=rly2
RELAYER_JUNO_ACCT=rly3
RELAYER_OSMO_ACCT=rly4
RELAYER_STARS_ACCT=rly5
RELAYER_HOST_ACCT=rly6
RELAYER_EVMOS_ACCT=rly7
RELAYER_STRIDE_ICS_ACCT=rly11
RELAYER_GAIA_ICS_ACCT=rly12
RELAYER_ACCTS=(
RELAYER_STRIDE_ICS_ACCT=rly8
RELAYER_GAIA_ICS_ACCT=rly9
RELAYER_DYDX_ACCT=rly10
STRIDE_RELAYER_ACCTS=(
$RELAYER_GAIA_ACCT
$RELAYER_JUNO_ACCT
$RELAYER_OSMO_ACCT
$RELAYER_STARS_ACCT
$RELAYER_HOST_ACCT
$RELAYER_EVMOS_ACCT
$RELAYER_GAIA_ICS_ACCT
$RELAYER_DYDX_ACCT
)

# Mnemonics for connections with stride
RELAYER_GAIA_MNEMONIC="fiction perfect rapid steel bundle giant blade grain eagle wing cannon fever must humble dance kitchen lazy episode museum faith off notable rate flavor"
RELAYER_JUNO_MNEMONIC="kiwi betray topple van vapor flag decorate cement crystal fee family clown cry story gain frost strong year blanket remain grass pig hen empower"
RELAYER_OSMO_MNEMONIC="unaware wine ramp february bring trust leaf beyond fever inside option dilemma save know captain endless salute radio humble chicken property culture foil taxi"
RELAYER_STARS_MNEMONIC="deposit dawn erosion talent old broom flip recipe pill hammer animal hill nice ten target metal gas shoe visual nephew soda harbor child simple"
RELAYER_HOST_MNEMONIC="renew umbrella teach spoon have razor knee sock divert inner nut between immense library inhale dog truly return run remain dune virus diamond clinic"
RELAYER_GAIA_ICS_MNEMONIC="size chimney clog job robot thunder gaze vapor economy smooth kit denial alter merit produce front force eager outside mansion believe fan tonight detect"
RELAYER_EVMOS_MNEMONIC="science depart where tell bus ski laptop follow child bronze rebel recall brief plug razor ship degree labor human series today embody fury harvest"
RELAYER_MNEMONICS=(
RELAYER_DYDX_MNEMONIC="mother depth nature rapid draw west afraid depend allow fee siren useful catalog sun biology cabbage busy science front smile nurse balcony medal burst"
STRIDE_RELAYER_MNEMONICS=(
"$RELAYER_GAIA_MNEMONIC"
"$RELAYER_JUNO_MNEMONIC"
"$RELAYER_OSMO_MNEMONIC"
"$RELAYER_STARS_MNEMONIC"
"$RELAYER_HOST_MNEMONIC"
"$RELAYER_EVMOS_MNEMONIC"
"$RELAYER_GAIA_ICS_MNEMONIC"
"$RELAYER_DYDX_MNEMONIC"
)
# Mnemonics for connections between two non-stride chains
RELAYER_NOBLE_DYDX_MNEMONIC="sentence fruit crumble sail bar knife exact flame apart prosper hint myth clean among tiny burden depart purity select envelope identify cross physical emerge"
RELAYER_DYDX_NOBLE_MNEMONIC="aerobic breeze claw climb bounce morning tank victory eight funny employ bracket hire reduce fine flee lava domain warfare loop theme fly tattoo must"
RELAYER_NOBLE_OSMO_MNEMONIC="actual field visual wage orbit add human unit happy rich evil chair entire person february cactus deputy impact gasp elbow sunset brand possible fly"
RELAYER_OSMO_NOBLE_MNEMONIC="obey clinic miss grunt inflict laugh sell moral kitchen tumble gold song flavor rather horn exhaust state amazing poverty differ approve spike village device"
RELAYER_DYDX_OSMO_MNEMONIC="small fire step promote fox reward book seek arctic session illegal loyal because brass spoil minute wonder jazz shoe price muffin churn evil monitor"
RELAYER_OSMO_DYDX_MNEMONIC="risk wool reason sweet current strategy female miracle squeeze that wire develop ocean rapid domain lift blame monkey sick round museum item maze trumpet"


STRIDE_ADDRESS() {
# After an upgrade, the keys query can sometimes print migration info,
Expand All @@ -309,6 +368,12 @@ HOST_ADDRESS() {
EVMOS_ADDRESS() {
$EVMOS_MAIN_CMD keys show ${EVMOS_VAL_PREFIX}1 --keyring-backend test -a
}
DYDX_ADDRESS() {
$DYDX_MAIN_CMD keys show ${DYDX_VAL_PREFIX}1 --keyring-backend test -a
}
NOBLE_ADDRESS() {
$NOBLE_MAIN_CMD keys show ${NOBLE_VAL_PREFIX}1 --keyring-backend test -a
}

CSLEEP() {
for i in $(seq $1); do
Expand All @@ -322,6 +387,12 @@ GET_VAR_VALUE() {
echo "${!var_name}"
}

SAVE_DOCKER_LOGS() {
service_name=$1
log_path=$2
$DOCKER_COMPOSE logs -f $service_name | sed -r -u "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" >> $log_path 2>&1 &
}

WAIT_FOR_BLOCK() {
num_blocks="${2:-1}"
for i in $(seq $num_blocks); do
Expand Down Expand Up @@ -393,11 +464,52 @@ GET_ICA_ADDR() {
$STRIDE_MAIN_CMD q stakeibc show-host-zone $chain_id | grep ${ica_type}_ica_address | awk '{print $2}'
}

GET_HOST_ZONE_FIELD() {
chain_id="$1"
field="$2"

$STRIDE_MAIN_CMD q stakeibc show-host-zone $chain_id | grep $field | awk '{print $2}'
}

GET_IBC_DENOM() {
transfer_channel_id="$1"
base_denom="$2"
chain="$1"
transfer_channel_id="$2"
base_denom="$3"

main_cmd=$(GET_VAR_VALUE ${chain}_MAIN_CMD)
echo "ibc/$($main_cmd q ibc-transfer denom-hash transfer/${transfer_channel_id}/${base_denom} | awk '{print $2}')"
}

GET_CLIENT_ID_FROM_CHAIN_ID() {
src_chain="$1"
counterparty_chain_id="$2"

main_cmd=$(GET_VAR_VALUE ${src_chain}_MAIN_CMD)
$main_cmd q ibc client states | grep $counterparty_chain_id -B 6 | grep client_id | awk '{print $3}'
}

GET_CONNECTION_ID_FROM_CLIENT_ID() {
src_chain="$1"
client_id="$2"

main_cmd=$(GET_VAR_VALUE ${src_chain}_MAIN_CMD)
$main_cmd q ibc connection path $client_id | grep connection- | awk '{print $2}'
}

GET_TRANSFER_CHANNEL_ID_FROM_CONNECTION_ID() {
src_chain="$1"
connection_id="$2"

main_cmd=$(GET_VAR_VALUE ${src_chain}_MAIN_CMD)
$main_cmd q ibc channel connections $connection_id | grep -m 1 "channel_id" | awk '{print $3}'
}

GET_COUNTERPARTY_TRANSFER_CHANNEL_ID() {
src_chain="$1"
channel_id="$2"

echo "ibc/$($STRIDE_MAIN_CMD q ibc-transfer denom-hash transfer/${transfer_channel_id}/${base_denom} | awk '{print $2}')"
main_cmd=$(GET_VAR_VALUE ${src_chain}_MAIN_CMD)
$main_cmd q ibc channel end transfer $channel_id | grep -A 2 counterparty | grep channel_id | awk '{print $2}'
}

TRIM_TX() {
Expand Down
1 change: 1 addition & 0 deletions dockernet/config/ica_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation",
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
"/cosmos.distribution.v1beta1.MsgFundCommunityPool",
"/ibc.applications.transfer.v1.MsgTransfer",
"/cosmwasm.wasm.v1.MsgExecuteContract",
"/cosmwasm.wasm.v1.MsgInstantiateContract"
Expand Down
Loading
Loading