Skip to content

Commit

Permalink
Add doc for integrate feeabs module with new chain. (#148)
Browse files Browse the repository at this point in the history
* Add doc for integrate feeabs module with new chain.

* Update documentation for integrate Cosmos Hub.

* wip: add guide for Stargaze

* update

* update relayer mnemonic

* linting

* Update documentation for integrate Cosmos Hub.

* Fix lint

* Add scripts run relayer

* Update docs

* Fix version query path

* Update docs

* add script for binary installation

* Update docs

* Update docs

* Refactor docs

---------

Co-authored-by: Tuan Tran <[email protected]>
Co-authored-by: nghuyenthevinh2000 <[email protected]>
  • Loading branch information
3 people authored Mar 8, 2024
1 parent b217b6e commit b032641
Show file tree
Hide file tree
Showing 32 changed files with 710 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ go.work.sum
go.work

bin/
_build/

# IDE config
.vscode/
Expand Down
16 changes: 16 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[submodule "deps/gaia"]
path = deps/gaia
url = https://github.com/notional-labs/gaia.git
branch = feeabs
[submodule "deps/stargaze"]
path = deps/stargaze
url = https://github.com/notional-labs/stargaze.git
branch = feature/feeabs
[submodule "deps/relayer"]
path = deps/relayer
url = https://github.com/cosmos/relayer.git
branch = release/v2.4.x
[submodule "deps/osmosis"]
path = deps/osmosis
url = https://github.com/osmosis-labs/osmosis.git
branch = v23.x
70 changes: 40 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

ifeq (,$(VERSION))
VERSION := $(shell git describe --tags)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
VERSION := $(shell git describe --tags)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif

LEDGER_ENABLED ?= true
Expand All @@ -25,30 +25,30 @@ export GO111MODULE = on

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif

ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
build_tags += gcc cleveldb
build_tags += gcc cleveldb
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
Expand All @@ -67,21 +67,21 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=feeapp \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TM_VERSION)

ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
ldflags += -w -s
ldflags += -w -s
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# check for nostrip option
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
BUILD_FLAGS += -trimpath
endif


Expand Down Expand Up @@ -135,6 +135,16 @@ ictest-all: ictest-basic ictest-ibc ictest-packet-forward ictest-host-zone-propo

.PHONY: ictest-basic ictest-ibc ictest-packet-forward ictest-all ictest-host-zone-proposal ictest-query-osmosis-twap ictest-feeabs

###############################################################################
### Integration Test ###
###############################################################################

build-integration-binary:
@git submodule update --init --recursive
@bash tests/integration/build-binary.sh

.PHONY: build-integration-binary

###############################################################################
### Proto ###
###############################################################################
Expand Down
1 change: 1 addition & 0 deletions deps/gaia
Submodule gaia added at 19e63c
1 change: 1 addition & 0 deletions deps/osmosis
Submodule osmosis added at dba4b8
1 change: 1 addition & 0 deletions deps/relayer
Submodule relayer added at a63cd7
1 change: 1 addition & 0 deletions deps/stargaze
Submodule stargaze added at 66f830
5 changes: 5 additions & 0 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SETUP GUIDE FOR INTEGRATION TEST

## build binaries
1. run `make build-integration-binary`, binaries will be in _build/binary
2. if you want to recreate a binary, delete that binary in _build/binary and run `make build-integration-binary` again
43 changes: 43 additions & 0 deletions tests/integration/build-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

ROOT=$(pwd)

# underscore so that go tool will not take gocache into account
mkdir -p _build/gocache
export GOMODCACHE=$ROOT/_build/gocache

# install gaid binary
if ! command -v _build/binary/gaid &> /dev/null
then
echo "Building gaiad..."
cd deps/gaia
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
cd ../..
fi

# install osmosisd binary
if ! command -v _build/binary/osmosisd &> /dev/null
then
echo "Building osmosisd..."
cd deps/osmosis
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
cd ../..
fi

# install relayer binary
if ! command -v _build/binary/relayer &> /dev/null
then
echo "Building relayer..."
cd deps/relayer
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
cd ../..
fi

# install stargaze binary
if ! command -v _build/binary/starsd &> /dev/null
then
echo "Building starsd..."
cd deps/stargaze
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
cd ../..
fi
115 changes: 115 additions & 0 deletions tests/integration/cosmoshub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Integrate `x/feeabs` with Cosmos Hub

This is document for testing integrate a new chain with `x/feeabs` module.

Firstly, we will add `feeabs` module to Cosmos Hub and using Osmosis testnet to minimize effort.

* Original Fee Abstraction repository:

<https://github.com/osmosis-labs/fee-abstraction>

* Cosmos Hub with added `feeabs` module:

<https://github.com/notional-labs/gaia/tree/feeabs>

## 1. Setup nodes

* Install binaries: [install binaries guide](../README.md)

* Run nodes:
* In `gaia` working dir, run:

```bash
sh startnode.sh
```

## 2. Setup relayers

* Run relayers:

```bash
# Setup chains and paths for relayer between gaia-feeabs
cd <fee-abstraction>/tests/integration/cosmoshub
sh tools/setup_relayer.sh

rly tx link transfer -d -t 10s --client-tp 36h
rly tx link query --src_port feeabs --dst_port icqhost --order unordered --version icq-1 -d -t 10s --client-tp 36h

rly start
```

* Get ibc token info:

```bash
# Get channels in gaia
rly q channels gaia

# {"chain_id":"gaia-1","channel_id":"channel-0","client_id":"07-tendermint-0","connection_hops":["connection-0"],"counterparty":{"chain_id":"osmo-test-5","channel_id":"channel-6084","client_id":"07-tendermint-2545","connection_id":"connection-2390","port_id":"transfer"},"ordering":"ORDER_UNORDERED","port_id":"transfer","state":"STATE_OPEN","version":"ics20-1"}
# {"chain_id":"gaia-1","channel_id":"channel-1","client_id":"07-tendermint-0","connection_hops":["connection-1"],"counterparty":{"chain_id":"osmo-test-5","channel_id":"channel-6085","client_id":"07-tendermint-2545","connection_id":"connection-2391","port_id":"transfer"},"ordering":"ORDER_UNORDERED","port_id":"transfer","state":"STATE_OPEN","version":"ics20-1"}

# Transfer uatom from gaia to osmosis
rly tx transfer gaia osmosis 100000000uatom osmo1wrhdsm4gy307mygkgmanjc3r2g0ttuhnhkfp44 channel-0 --path transfer

# Transfer uosmo from osmosis to gaia
rly tx transfer osmosis gaia 100000uosmo cosmos1wrhdsm4gy307mygkgmanjc3r2g0ttuhnld63r8 channel-6084 --path transfer


# Query balances of relayer wallet
rly q balance gaia --ibc-denoms
rly q balance osmosis --ibc-denoms

# ibc/uatom on osmosis: ibc/80C64E7EB7E8B6705FC9C1D9C486EB6278823068D9224915B6A5DABDF03FB2D5
# ibc/uosmo on gaia: ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518
```

## 3. Setup pools, contracts on Osmosis testnet

a. Pre-deploy contracts:

* Registry:

* code_id: `7238`
* address: `osmo1m9jk8zvrkpex0rxhp76emr0qm2z5khvj09msl9c78gcq7c38xdzsgq0cgm`

* SwapRouter:

* code_id: `7239`
* address: `osmo1j48ncj9wkzs3pnkux96ct6peg7rznnt4jx6ysdcs0283ysxj2ztqtr602y`

* XCSv2:
* code_id: `7240`
* address: `osmo177jurcy582fk5q298es6662pu48a46ze6eequnv3z0parekpwhhs034wsv`

b. Create pool:

Correct information on `<cosmoshub>/pools/pool.json`, and run script:

```bash
sh tools/create_pool.sh
```

c. Set swap route

Correct information on `<cosmoshub>/tools/set_route.sh`, and run script:

```bash
sh tools/set_route.sh
```

## 4. Testing fee abstraction

a. Change params of `feeabs` module

Correct information on `<cosmoshub>/proposals/params.json`, and run script:

```bash
sh tools/change_feeabs_params.sh
```

b. Add host zone config

Correct information on `<cosmoshub>/proposals/add_host_zone.json`, and run script:

```bash
sh tools/add_host_zone.sh
```
1 change: 1 addition & 0 deletions tests/integration/cosmoshub/keys/osmo_admin.info
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
river tackle scare kiss top depend know siege member awesome left display exotic skate assault glue observe prosper female reveal recall north shine behind
1 change: 1 addition & 0 deletions tests/integration/cosmoshub/keys/relayer.info
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bomb jewel cushion behave orphan lava bulk defy evolve spend match grass dress upgrade blast please business stairs learn syrup kick narrow bleak canoe
7 changes: 7 additions & 0 deletions tests/integration/cosmoshub/pools/pool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"weights": "1uosmo,100ibc/80C64E7EB7E8B6705FC9C1D9C486EB6278823068D9224915B6A5DABDF03FB2D5",
"initial-deposit": "1000uosmo,100000ibc/80C64E7EB7E8B6705FC9C1D9C486EB6278823068D9224915B6A5DABDF03FB2D5",
"swap-fee": "0.01",
"exit-fee": "0",
"future-governor": ""
}
11 changes: 11 additions & 0 deletions tests/integration/cosmoshub/proposals/add_host_zone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"title": "Add Fee Abstraction Host Zone Proposal",
"description": "Add Fee Abstraction Host Zone",
"host_chain_fee_abs_config": {
"ibc_denom": "ibc/80C64E7EB7E8B6705FC9C1D9C486EB6278823068D9224915B6A5DABDF03FB2D5",
"osmosis_pool_token_denom_in": "uosmo",
"pool_id": "408",
"frozen": false
},
"deposit": "100000000uatom"
}
32 changes: 32 additions & 0 deletions tests/integration/cosmoshub/proposals/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"title": "Enable Fee Abtraction",
"description": "Change params for enable fee abstraction",
"changes": [
{
"subspace": "feeabs",
"key": "NativeIbcedInOsmosis",
"value": "ibc/62DDD1848B6F9182A658B6E88D7625F71D863E678ED043660692BD307C9217A0"
},
{
"subspace": "feeabs",
"key": "ChainName",
"value": "gaia"
},
{
"subspace": "feeabs",
"key": "IbcTransferChannel",
"value": "channel-0"
},
{
"subspace": "feeabs",
"key": "IbcQueryIcqChannel",
"value": "channel-2"
},
{
"subspace": "feeabs",
"key": "OsmosisCrosschainSwapAddress",
"value": "osmo177jurcy582fk5q298es6662pu48a46ze6eequnv3z0parekpwhhs034wsv"
}
],
"deposit": "100000000uatom"
}
11 changes: 11 additions & 0 deletions tests/integration/cosmoshub/proposals/set_host_zone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"title": "Update Fee Abstraction Host Zone Proposal",
"description": "Unfrozen Fee Abstraction Host Zone",
"host_chain_fee_abs_config": {
"ibc_denom": "ibc/80C64E7EB7E8B6705FC9C1D9C486EB6278823068D9224915B6A5DABDF03FB2D5",
"osmosis_pool_token_denom_in": "uosmo",
"pool_id": "408",
"frozen": false
},
"deposit": "100000000uatom"
}
Loading

0 comments on commit b032641

Please sign in to comment.