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

fix: ibc defi tests #697

Merged
merged 6 commits into from
Mar 6, 2024
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# ignore mnemonics
tests/ibc-defi/cheqd_relayer_mnemonic.txt
tests/ibc-defi/osmo_relayer_mnemonic.txt
10 changes: 10 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import (
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
Expand Down Expand Up @@ -157,6 +158,7 @@ var (
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctm.AppModuleBasic{},
transfer.AppModuleBasic{},
ica.AppModuleBasic{},
upgrade.AppModuleBasic{},
Expand Down Expand Up @@ -1051,7 +1053,15 @@ func (app *App) RegisterUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
upgradeV2.UpgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// IBC v6 - v7 upgrade
_, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.IBCKeeper.ClientKeeper)

// IBC v7 - v7.3 upgrade
// explicitly update the IBC 02-client params, adding the localhost client type
params := app.IBCKeeper.ClientKeeper.GetParams(ctx)
params.AllowedClients = append(params.AllowedClients, ibcexported.Localhost)
app.IBCKeeper.ClientKeeper.SetParams(ctx, params)

if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions tests/ibc-defi/cheqd/cheqd-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sed -i $SED_EXT 's|minimum-gas-prices = ""|minimum-gas-prices = "50ncheq"|g' "$H

# shellcheck disable=SC2086
sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml"
sed -i $SED_EXT 's|address = "localhost:9090"|address = "0.0.0.0:9090"|g' "$HOME/.cheqdnode/config/app.toml"

# Genesis
GENESIS="$HOME/.cheqdnode/config/genesis.json"
Expand Down
4 changes: 2 additions & 2 deletions tests/ibc-defi/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
entrypoint: tail -f /dev/null

osmosis:
image: osmolabs/osmosis:13-alpine
image: osmolabs/osmosis:23.0.1-alpine
ports:
- "26666:26656" # p2p
- "26667:26657" # rpc
Expand All @@ -23,7 +23,7 @@ services:
entrypoint: tail -f /dev/null

hermes:
image: informalsystems/hermes:1.2.0
image: informalsystems/hermes:v1.8.0
configs:
- source: hermes-config
target: /home/hermes/.hermes/config.toml
Expand Down
6 changes: 3 additions & 3 deletions tests/ibc-defi/hermes/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ port = 3001
id = 'cheqd'
rpc_addr = 'http://cheqd:26657'
grpc_addr = 'http://cheqd:9090'
websocket_addr = 'ws://cheqd:26657/websocket'
event_source = { mode = 'push', url = 'ws://cheqd:26657/websocket', batch_delay = '500ms' }
rpc_timeout = '10s'
account_prefix = 'cheqd'
key_name = 'cheqd-key'
Expand All @@ -58,14 +58,14 @@ trust_threshold = { numerator = '1', denominator = '3' }
id = 'osmosis'
rpc_addr = 'http://osmosis:26657'
grpc_addr = 'http://osmosis:9090'
websocket_addr = 'ws://osmosis:26657/websocket'
event_source = { mode = 'push', url = 'ws://osmosis:26657/websocket', batch_delay = '500ms' }
rpc_timeout = '10s'
account_prefix = 'osmo'
key_name = 'osmosis-key'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 400000
gas_price = { price = 0, denom = 'uosmo' }
gas_price = { price = 1, denom = 'uosmo' }
gas_multiplier = 1.3
max_msg_num = 30
max_tx_size = 2097152
Expand Down
13 changes: 7 additions & 6 deletions tests/ibc-defi/ibc-transfer-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ docker compose exec -d cheqd cheqd-noded start

info "Running osmosis network"
docker compose up -d osmosis
docker compose cp osmosis/osmosis-init.sh osmosis:/home/osmosis/osmosis-init.sh
docker compose exec osmosis bash /home/osmosis/osmosis-init.sh
docker compose cp osmosis/osmosis-init.sh osmosis:/osmosis/osmosis-init.sh
docker compose exec osmosis apk add bash
docker compose exec osmosis bash /osmosis/osmosis-init.sh
docker compose exec -d osmosis osmosisd start

info "Waiting for chains"
Expand All @@ -78,7 +79,7 @@ CHEQD_RELAYER_MNEMONIC=$(echo "${CHEQD_RELAYER_ACCOUNT}" | jq --raw-output '.mne
echo "${CHEQD_RELAYER_MNEMONIC}" > cheqd_relayer_mnemonic.txt

info "Send some tokens to it" # ---
RES=$(docker compose exec cheqd cheqd-noded tx bank send cheqd-user "${CHEQD_RELAYER_ADDRESS}" 1000000000000ncheq --gas-prices 50ncheq --chain-id cheqd -y --keyring-backend test)
RES=$(docker compose exec cheqd cheqd-noded tx bank send cheqd-user "${CHEQD_RELAYER_ADDRESS}" 500000000000000000ncheq --gas-prices 50ncheq --chain-id cheqd -y --keyring-backend test)
assert_tx_successful "${RES}"

info "Create relayer user on osmosis" # ---
Expand All @@ -90,7 +91,7 @@ OSMOSIS_RELAYER_MNEMONIC=$(echo "${OSMOSIS_RELAYER_ACCOUNT}" | jq --raw-output '
echo "${OSMOSIS_RELAYER_MNEMONIC}" > osmo_relayer_mnemonic.txt

info "Send some tokens to it" # ---
RES=$(docker compose exec osmosis osmosisd tx bank send osmosis-user "${OSMOSIS_RELAYER_ADDRESS}" 10000000uosmo --chain-id osmosis -y --keyring-backend test --output json)
RES=$(docker compose exec osmosis osmosisd tx bank send osmosis-user "${OSMOSIS_RELAYER_ADDRESS}" 1000000000uosmo --fees 500uosmo --chain-id osmosis -y --keyring-backend test --output json)
assert_tx_successful "${RES}"
sleep 10 # Wait for state

Expand All @@ -114,7 +115,7 @@ docker compose exec hermes hermes keys add --chain cheqd --mnemonic-file cheqd_r
docker compose exec hermes hermes keys add --chain osmosis --mnemonic-file osmo_relayer_mnemonic.txt --key-name osmosis-key

info "Open channel" # ---
docker compose exec hermes hermes create channel --a-chain cheqd --b-chain osmosis --a-port transfer --b-port transfer --new-client-connection
docker compose exec hermes hermes create channel --a-chain cheqd --b-chain osmosis --a-port transfer --b-port transfer --new-client-connection --yes

info "Start hermes" # ---
docker compose exec -d hermes hermes start
Expand Down Expand Up @@ -145,7 +146,7 @@ docker compose exec osmosis osmosisd query ibc-transfer denom-trace "$DENOM_CUT"
info "Transfer osmosis -> cheqd" # ---
PORT="transfer"
CHANNEL="channel-0"
docker compose exec osmosis osmosisd tx ibc-transfer transfer $PORT $CHANNEL "$CHEQD_USER_ADDRESS" 10000000000"${DENOM}" --from osmosis-user --chain-id osmosis --keyring-backend test -y
docker compose exec osmosis osmosisd tx ibc-transfer transfer $PORT $CHANNEL "$CHEQD_USER_ADDRESS" 10000000000"${DENOM}" --from osmosis-user --chain-id osmosis --fees 500uosmo --keyring-backend test -y
sleep 30 # Wait for relayer

info "Get balances" # ---
Expand Down
12 changes: 5 additions & 7 deletions tests/ibc-defi/osmosis/osmosis-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ CHAIN_ID="osmosis"
# Node
osmosisd init --chain-id "$CHAIN_ID" testing

# User
# Config
sed -i $SED_EXT 's/"stake"/"uosmo"/' "$HOME/.osmosisd/config/genesis.json"
sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml"
sed -i $SED_EXT 's|address = "localhost:9090"|address = "0.0.0.0:9090"|g' "$HOME/.osmosisd/config/app.toml"

osmosisd keys add osmosis-user --keyring-backend=test

# Genesis
osmosisd add-genesis-account "$(osmosisd keys show osmosis-user -a --keyring-backend=test)" 2000000000uosmo
osmosisd gentx osmosis-user 500000000uosmo --keyring-backend=test --chain-id "$CHAIN_ID"
osmosisd collect-gentxs

jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' "$HOME/.osmosisd/config/genesis.json" > "$HOME/.osmosisd/config/tmp_genesis.json" && \
mv "$HOME/.osmosisd/config/tmp_genesis.json" "$HOME/.osmosisd/config/genesis.json"
akhilkumarpilli marked this conversation as resolved.
Show resolved Hide resolved

# Config
sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml"
Loading