Skip to content

Commit b032641

Browse files
tnv1catconcatnghuyenthevinh2000
authored
Add doc for integrate feeabs module with new chain. (#148)
* 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]>
1 parent b217b6e commit b032641

32 files changed

+710
-32
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ go.work.sum
1616
go.work
1717

1818
bin/
19+
_build/
1920

2021
# IDE config
2122
.vscode/

.gitmodules

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[submodule "deps/gaia"]
2+
path = deps/gaia
3+
url = https://github.com/notional-labs/gaia.git
4+
branch = feeabs
5+
[submodule "deps/stargaze"]
6+
path = deps/stargaze
7+
url = https://github.com/notional-labs/stargaze.git
8+
branch = feature/feeabs
9+
[submodule "deps/relayer"]
10+
path = deps/relayer
11+
url = https://github.com/cosmos/relayer.git
12+
branch = release/v2.4.x
13+
[submodule "deps/osmosis"]
14+
path = deps/osmosis
15+
url = https://github.com/osmosis-labs/osmosis.git
16+
branch = v23.x

Makefile

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
44
COMMIT := $(shell git log -1 --format='%H')
55

66
ifeq (,$(VERSION))
7-
VERSION := $(shell git describe --tags)
8-
# if VERSION is empty, then populate it with branch's name and raw commit hash
9-
ifeq (,$(VERSION))
10-
VERSION := $(BRANCH)-$(COMMIT)
11-
endif
7+
VERSION := $(shell git describe --tags)
8+
# if VERSION is empty, then populate it with branch's name and raw commit hash
9+
ifeq (,$(VERSION))
10+
VERSION := $(BRANCH)-$(COMMIT)
11+
endif
1212
endif
1313

1414
LEDGER_ENABLED ?= true
@@ -25,30 +25,30 @@ export GO111MODULE = on
2525

2626
build_tags = netgo
2727
ifeq ($(LEDGER_ENABLED),true)
28-
ifeq ($(OS),Windows_NT)
29-
GCCEXE = $(shell where gcc.exe 2> NUL)
30-
ifeq ($(GCCEXE),)
31-
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
32-
else
33-
build_tags += ledger
34-
endif
35-
else
36-
UNAME_S = $(shell uname -s)
37-
ifeq ($(UNAME_S),OpenBSD)
38-
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
39-
else
40-
GCC = $(shell command -v gcc 2> /dev/null)
41-
ifeq ($(GCC),)
42-
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
43-
else
44-
build_tags += ledger
45-
endif
46-
endif
47-
endif
28+
ifeq ($(OS),Windows_NT)
29+
GCCEXE = $(shell where gcc.exe 2> NUL)
30+
ifeq ($(GCCEXE),)
31+
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
32+
else
33+
build_tags += ledger
34+
endif
35+
else
36+
UNAME_S = $(shell uname -s)
37+
ifeq ($(UNAME_S),OpenBSD)
38+
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
39+
else
40+
GCC = $(shell command -v gcc 2> /dev/null)
41+
ifeq ($(GCC),)
42+
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
43+
else
44+
build_tags += ledger
45+
endif
46+
endif
47+
endif
4848
endif
4949

5050
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
51-
build_tags += gcc cleveldb
51+
build_tags += gcc cleveldb
5252
endif
5353
build_tags += $(BUILD_TAGS)
5454
build_tags := $(strip $(build_tags))
@@ -67,21 +67,21 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=feeapp \
6767
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TM_VERSION)
6868

6969
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
70-
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
70+
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
7171
endif
7272
ifeq ($(LINK_STATICALLY),true)
73-
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
73+
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
7474
endif
7575
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
76-
ldflags += -w -s
76+
ldflags += -w -s
7777
endif
7878
ldflags += $(LDFLAGS)
7979
ldflags := $(strip $(ldflags))
8080

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

8787

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

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

138+
###############################################################################
139+
### Integration Test ###
140+
###############################################################################
141+
142+
build-integration-binary:
143+
@git submodule update --init --recursive
144+
@bash tests/integration/build-binary.sh
145+
146+
.PHONY: build-integration-binary
147+
138148
###############################################################################
139149
### Proto ###
140150
###############################################################################

deps/gaia

Submodule gaia added at 19e63c1

deps/osmosis

Submodule osmosis added at dba4b88

deps/relayer

Submodule relayer added at a63cd79

deps/stargaze

Submodule stargaze added at 66f8308

tests/integration/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SETUP GUIDE FOR INTEGRATION TEST
2+
3+
## build binaries
4+
1. run `make build-integration-binary`, binaries will be in _build/binary
5+
2. if you want to recreate a binary, delete that binary in _build/binary and run `make build-integration-binary` again

tests/integration/build-binary.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
ROOT=$(pwd)
4+
5+
# underscore so that go tool will not take gocache into account
6+
mkdir -p _build/gocache
7+
export GOMODCACHE=$ROOT/_build/gocache
8+
9+
# install gaid binary
10+
if ! command -v _build/binary/gaid &> /dev/null
11+
then
12+
echo "Building gaiad..."
13+
cd deps/gaia
14+
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
15+
cd ../..
16+
fi
17+
18+
# install osmosisd binary
19+
if ! command -v _build/binary/osmosisd &> /dev/null
20+
then
21+
echo "Building osmosisd..."
22+
cd deps/osmosis
23+
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
24+
cd ../..
25+
fi
26+
27+
# install relayer binary
28+
if ! command -v _build/binary/relayer &> /dev/null
29+
then
30+
echo "Building relayer..."
31+
cd deps/relayer
32+
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
33+
cd ../..
34+
fi
35+
36+
# install stargaze binary
37+
if ! command -v _build/binary/starsd &> /dev/null
38+
then
39+
echo "Building starsd..."
40+
cd deps/stargaze
41+
GOBIN="$ROOT/_build/binary" go install -mod=readonly ./...
42+
cd ../..
43+
fi
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Integrate `x/feeabs` with Cosmos Hub
2+
3+
This is document for testing integrate a new chain with `x/feeabs` module.
4+
5+
Firstly, we will add `feeabs` module to Cosmos Hub and using Osmosis testnet to minimize effort.
6+
7+
* Original Fee Abstraction repository:
8+
9+
<https://github.com/osmosis-labs/fee-abstraction>
10+
11+
* Cosmos Hub with added `feeabs` module:
12+
13+
<https://github.com/notional-labs/gaia/tree/feeabs>
14+
15+
## 1. Setup nodes
16+
17+
* Install binaries: [install binaries guide](../README.md)
18+
19+
* Run nodes:
20+
* In `gaia` working dir, run:
21+
22+
```bash
23+
sh startnode.sh
24+
```
25+
26+
## 2. Setup relayers
27+
28+
* Run relayers:
29+
30+
```bash
31+
# Setup chains and paths for relayer between gaia-feeabs
32+
cd <fee-abstraction>/tests/integration/cosmoshub
33+
sh tools/setup_relayer.sh
34+
35+
rly tx link transfer -d -t 10s --client-tp 36h
36+
rly tx link query --src_port feeabs --dst_port icqhost --order unordered --version icq-1 -d -t 10s --client-tp 36h
37+
38+
rly start
39+
```
40+
41+
* Get ibc token info:
42+
43+
```bash
44+
# Get channels in gaia
45+
rly q channels gaia
46+
47+
# {"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"}
48+
# {"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"}
49+
50+
# Transfer uatom from gaia to osmosis
51+
rly tx transfer gaia osmosis 100000000uatom osmo1wrhdsm4gy307mygkgmanjc3r2g0ttuhnhkfp44 channel-0 --path transfer
52+
53+
# Transfer uosmo from osmosis to gaia
54+
rly tx transfer osmosis gaia 100000uosmo cosmos1wrhdsm4gy307mygkgmanjc3r2g0ttuhnld63r8 channel-6084 --path transfer
55+
56+
57+
# Query balances of relayer wallet
58+
rly q balance gaia --ibc-denoms
59+
rly q balance osmosis --ibc-denoms
60+
61+
# ibc/uatom on osmosis: ibc/80C64E7EB7E8B6705FC9C1D9C486EB6278823068D9224915B6A5DABDF03FB2D5
62+
# ibc/uosmo on gaia: ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518
63+
```
64+
65+
## 3. Setup pools, contracts on Osmosis testnet
66+
67+
a. Pre-deploy contracts:
68+
69+
* Registry:
70+
71+
* code_id: `7238`
72+
* address: `osmo1m9jk8zvrkpex0rxhp76emr0qm2z5khvj09msl9c78gcq7c38xdzsgq0cgm`
73+
74+
* SwapRouter:
75+
76+
* code_id: `7239`
77+
* address: `osmo1j48ncj9wkzs3pnkux96ct6peg7rznnt4jx6ysdcs0283ysxj2ztqtr602y`
78+
79+
* XCSv2:
80+
* code_id: `7240`
81+
* address: `osmo177jurcy582fk5q298es6662pu48a46ze6eequnv3z0parekpwhhs034wsv`
82+
83+
b. Create pool:
84+
85+
Correct information on `<cosmoshub>/pools/pool.json`, and run script:
86+
87+
```bash
88+
sh tools/create_pool.sh
89+
```
90+
91+
c. Set swap route
92+
93+
Correct information on `<cosmoshub>/tools/set_route.sh`, and run script:
94+
95+
```bash
96+
sh tools/set_route.sh
97+
```
98+
99+
## 4. Testing fee abstraction
100+
101+
a. Change params of `feeabs` module
102+
103+
Correct information on `<cosmoshub>/proposals/params.json`, and run script:
104+
105+
```bash
106+
sh tools/change_feeabs_params.sh
107+
```
108+
109+
b. Add host zone config
110+
111+
Correct information on `<cosmoshub>/proposals/add_host_zone.json`, and run script:
112+
113+
```bash
114+
sh tools/add_host_zone.sh
115+
```

0 commit comments

Comments
 (0)