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

Maintain sdk46 #165

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
743a2e6
init
anhductn2001 Apr 13, 2023
9d50fea
add packet foward test
anhductn2001 Apr 13, 2023
fe55580
add makefile and CI jobs
anhductn2001 Apr 13, 2023
57f30cf
add bytecode and code structure
GNaD13 Apr 14, 2023
3c529ea
Use interchaintest folk from notional-labs but need bump cosmossdk to…
anhductn2001 Apr 16, 2023
7c89df7
nit
GNaD13 Apr 16, 2023
df8b1a0
Revert "Use interchaintest folk from notional-labs but need bump cosm…
anhductn2001 Apr 17, 2023
1e0c881
add setup rly ictest
GNaD13 Apr 17, 2023
ac40ec5
add balancer types and create pool msg
GNaD13 Apr 17, 2023
0c09baf
add setup contract
GNaD13 Apr 18, 2023
c4b1718
add create pool
GNaD13 Apr 18, 2023
abedf44
add contract for xcs
GNaD13 Apr 19, 2023
c48caea
add xcs
GNaD13 Apr 19, 2023
f064cc7
add check
GNaD13 Apr 19, 2023
a1c453f
nit
GNaD13 Apr 19, 2023
cb512b2
add log check
GNaD13 Apr 19, 2023
cb1e491
add wait for block
GNaD13 Apr 19, 2023
2eb189d
add proposl
GNaD13 Apr 19, 2023
a6d97c1
add setup
GNaD13 Apr 19, 2023
67257a8
merge main
GNaD13 Apr 19, 2023
5b72008
merge main
GNaD13 Apr 19, 2023
a3f65e8
nit
GNaD13 Apr 20, 2023
cf836b2
done
GNaD13 Apr 20, 2023
102d0d9
nit
GNaD13 Apr 20, 2023
fe38bd7
Merge pull request #136 from notional-labs/dang/test-ictest
GNaD13 Apr 20, 2023
0a67206
delete go.work.sum
anhductn2001 Apr 21, 2023
be9f1df
correct register interface:
GNaD13 Apr 24, 2023
4f0689e
clean todo
anhductn2001 Apr 25, 2023
7d9c49f
Merge pull request #144 from notional-labs/ducnt/clean-todo
GNaD13 Apr 26, 2023
fe8c415
update osmosis contract
GNaD13 Apr 26, 2023
edf0919
add log
GNaD13 Apr 26, 2023
2021169
nit
GNaD13 Apr 26, 2023
3149e26
nit
GNaD13 Apr 26, 2023
ddccffb
nit
GNaD13 Apr 27, 2023
700a764
use source channel directly from param
anhductn2001 Apr 27, 2023
645bee5
Merge pull request #145 from notional-labs/ducnt/channel
GNaD13 Apr 27, 2023
172b246
Implement OnTimeoutPacket (#142)
anhductn2001 Apr 27, 2023
e49e238
Merge pull request #134 from notional-labs/ducnt/ictest
GNaD13 Apr 27, 2023
533569a
update proto-builder
anhductn2001 May 8, 2023
add967c
minor
anhductn2001 May 9, 2023
7c790f3
update image
anhductn2001 May 9, 2023
d61944f
update protogenc
anhductn2001 May 9, 2023
864a4fb
try sleep
anhductn2001 May 9, 2023
9931109
revert and remove check-generate proto
anhductn2001 May 9, 2023
3ce0bdf
Merge pull request #151 from notional-labs/ducnt/proto
anhductn2001 May 9, 2023
89a8bcd
Revert "Update protogenc for sdk47"
anhductn2001 May 9, 2023
10d546d
Merge pull request #152 from notional-labs/revert-151-ducnt/proto
anhductn2001 May 9, 2023
66364b0
nit
GNaD13 May 9, 2023
e1372d0
move some TODO
GNaD13 May 9, 2023
8948f42
Merge pull request #154 from notional-labs/dang/correct-check-token-a…
GNaD13 May 9, 2023
dd79a95
use latest image of feeabs to test
anhductn2001 May 18, 2023
c02b055
need build and push image
anhductn2001 May 18, 2023
9fd1e8b
Merge pull request #155 from notional-labs/ducnt/fix-ic
anhductn2001 May 19, 2023
065178d
correct docs
GNaD13 May 23, 2023
0871e81
Merge pull request #156 from notional-labs/dang/update-docs2305
GNaD13 May 23, 2023
d6d5b23
Use feeapp:debug in local test (#157)
anhductn2001 May 26, 2023
0f2feb7
Update README.md (#158)
vuong177 Jul 17, 2023
1ca41a5
update readme
GNaD13 Jul 22, 2023
a9323e8
nit
GNaD13 Jul 22, 2023
2f6e50d
Merge pull request #160 from notional-labs/dang/update-readme
GNaD13 Jul 22, 2023
5c288b4
temporary merge main
phamminh0811 Aug 4, 2023
499aed8
all unit test success
phamminh0811 Aug 9, 2023
94a56ea
merge sdk 46
phamminh0811 Aug 9, 2023
f195061
change iavl version
phamminh0811 Aug 9, 2023
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
51 changes: 51 additions & 0 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,38 @@ on:
- main

jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
id: build_push_image
uses: docker/build-push-action@v3
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/notional-labs/fee-abstraction-ictest:latest
test-basic:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v3
Expand All @@ -19,9 +49,12 @@ jobs:
uses: actions/checkout@v3

- run: make ictest-basic
env:
BRANCH_CI: "latest"

test-ibc:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v3
Expand All @@ -32,4 +65,22 @@ jobs:
uses: actions/checkout@v3

- run: make ictest-ibc
env:
BRANCH_CI: "latest"

test-packet-forward:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: checkout code
uses: actions/checkout@v3

- run: make ictest-packet-forward
env:
BRANCH_CI: "latest"

9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ install: go.sum
build:
go build $(BUILD_FLAGS) -o bin/feeappd ./cmd/feeappd

docker-build-debug:
@DOCKER_BUILDKIT=1 docker build -t feeapp:debug -f Dockerfile .

###############################################################################
### Interchain test ###
###############################################################################
Expand All @@ -103,7 +106,11 @@ ictest-basic:

# Executes IBC tests via interchaintest
ictest-ibc:
cd tests/interchaintest && go test -race -v -run TestFeeabsGaiaIBCTransfer .
cd tests/interchaintest && go test -timeout=25m -race -v -run TestFeeabsGaiaIBCTransfer .

# Executes IBC tests via interchaintest
ictest-packet-forward:
cd tests/interchaintest && go test -timeout=25m -race -v -run TestPacketForwardMiddleware .

# Executes IBC tests via interchaintest
ictest-packet-forward:
Expand Down
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Fee Abstraction

## This repo has been moved to https://github.com/osmosis-labs/fee-abstraction
## Context

The concrete use cases which motivated this module include:
Expand All @@ -17,15 +17,13 @@ The implememtation also uses Osmosis swap router and async-icq module which are

## Prototype

Firstly, we narrow the feature of fee-abs from allowing general ibc token as tx fee to allowing only ibc-ed osmosis as tx fee. If thing goes smoothly , we'll work on developing the full feature of fee-abs.

Fee-abs mechanism in a nutshell:
1. Pulling `twap data` and update exchange rate:
- Periodically pulling `twap data` from osmosis by ibc-ing to `async-icq` module on Osmosis, this `twap data` will update the exchange rate of osmosis to customer chain's native token.
2. Handling txs with ibc-osmosis fee:
- The exchange rate is used to calculate the amount of ibc-osmosis needed for tx fee allowing users to pay ibc-osmosis for tx fee instead of chain's native token.
3. Swap accumulated ibc-osmosis fee:
- The collected ibc-osmosis users use for tx fee is periodically swaped back to customer chain's native token using osmosis.
2. Handling txs with ibc-token fee:
- The exchange rate is used to calculate the amount of ibc-token needed for tx fee allowing users to pay ibc-token for tx fee instead of chain's native token.
3. Swap accumulated ibc-token fee:
- The collected ibc-token users use for tx fee is periodically swaped back to customer chain's native token using osmosis.

We'll goes into all the details now:

Expand All @@ -40,17 +38,28 @@ Description :
For every `update exchange rate period`, at fee-abs `BeginBlocker()` we submit a `InterchainQueryPacketData` which wrapped `QueryArithmeticTwapToNowRequest` to the querying channel on the customer chain's end. Then relayers will submit `MsgReceivePacket` so that our `QueryTwapPacket` which will be routed to `async-icq` module to be processed. `async-icq` module then unpack `InterchainQueryPacketData` and send query to TWAP module. The correspone response will be wrapped in the ibc acknowledgement. Relayers then submit `MsgAcknowledgement` to the customer chain so that the ibc acknowledgement is routed to fee-abs to be processed. Fee-abs then update exchange rate according to the Twap wrapped in the ibc acknowledgement.

#### Handling txs with ibc-token fee
We modified `MempoolFeeDecorator` so that it can handle ibc-osmosis as fee. If the tx has osmosis fee, we basically replace the ibc-osmosis amount with the equivalent native-token amount which is calculated by `exchange rate` * `ibc-osmosis amount`.
We modified `MempoolFeeDecorator` so that it can handle ibc-token as fee. If the tx has ibc-token fee, the AnteHandler will first check if that token is allowed (which is setup by Gov) we basically replace the amount of ibc-token with the equivalent native-token amount which is calculated by `exchange rate` * `ibc-token amount`.

We have an account to manage the ibc-osmosis user used to pay for tx fee. The collected osmosis fee is sent to that account instead of community pool account.
We have an account to manage the ibc-token user used to pay for tx fee. The collected ibc-token fee is sent to that account instead of community pool account.

#### Swap accumulated ibc-tokens fee
##### Swap with Osmosis's tokens
We use osmosis's ibc hook feature to do this. We basically ibc transfer to the osmosis crosschain swap contract with custom memo to swap the osmosis fee back to customer chain's native-token and ibc transfer back to the customer chain.
Fee-abstraction will use osmosis's Cross chain Swap (XCS) feature to do this. We basically ibc transfer to the osmosis crosschain swap contract with custom memo to swap the osmosis fee back to customer chain's native-token and ibc transfer back to the customer chain.

##### How XCS work
###### Reverse With Path-unwinding to get Ibc-token on Osmosis:
- Create a ibc transfer message with a specific MEMO to work with ibc [``packet-forward-middleware``](https://github.com/strangelove-ventures/packet-forward-middleware) which is path-unwinding (an ibc feature that allow to automatic define the path and ibc transfer multiple hop follow the defined path)
- Ibc transfer the created packet to get the fee Ibc-token on Osmosis

Ex: When you sent STARS on Hub to Osmosis, you will get Osmosis(Hub(STARS)) which is different with STARS on Osmosis Osmosis(STARS). It will reverse back Osmosis(Hub(STARS)) to Osmosis(STARS):

![](https://i.imgur.com/D1wSrMm.png)

###### Swap Ibc-token:
After reverse the ibc-token, XCS will :
- Swap with the specific pool (which is defined in the transfer packet from Feeabs-chain) to get Feeabs-chain native-token
- Transfer back Feeabs-chain native-token to Feeabs module account (will use to pay fee for other transaction)

![](https://i.imgur.com/YKOK8mr.png)

##### Swap with others ibc-tokens
We use [``packet-forward-middleware``](https://github.com/strangelove-ventures/packet-forward-middleware) to do this. The ibc-tokens will be transferred to the host chain with the specific MEMO to forwarding transfer to osmosis crosschain swap contract. After that, Osmosis chain will swap to customer chain's native-token and ibc transfer back to the customer chain.
Current version of fee-abstraction working with XCSv2

## Resources
- Main repo: https://github.com/notional-labs/fee-abstraction
- Contract repo: https://github.com/notional-labs/feeabstraction-contract
2 changes: 0 additions & 2 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ func interBlockCacheOpt() func(*baseapp.BaseApp) {
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
}

// // TODO: Make another test for the fuzzer itself, which just has noOp txs
// // and doesn't depend on the application.
func TestAppStateDeterminism(t *testing.T) {
if !simapp.FlagEnabledValue {
t.Skip("skipping application simulation")
Expand Down
40 changes: 20 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/CosmWasm/wasmd v0.30.0
github.com/CosmWasm/wasmvm v1.1.1
github.com/cosmos/cosmos-sdk v0.46.7
github.com/cosmos/gogoproto v1.4.3
github.com/cosmos/gogoproto v1.4.6
github.com/cosmos/ibc-go/v6 v6.1.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
Expand All @@ -18,21 +18,21 @@ require (
github.com/prometheus/client_golang v1.14.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.6.1
github.com/spf13/cobra v1.7.0
github.com/strangelove-ventures/packet-forward-middleware/v6 v6.0.2
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.2
github.com/tendermint/tendermint v0.34.24
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e
google.golang.org/grpc v1.50.1
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f
google.golang.org/grpc v1.53.0
)

require (
cloud.google.com/go v0.104.0 // indirect
cloud.google.com/go/compute v1.12.1 // indirect
cloud.google.com/go v0.105.0 // indirect
cloud.google.com/go/compute v1.13.0 // indirect
cloud.google.com/go/compute/metadata v0.2.1 // indirect
cloud.google.com/go/iam v0.4.0 // indirect
cloud.google.com/go/storage v1.23.0 // indirect
cloud.google.com/go/iam v0.8.0 // indirect
cloud.google.com/go/storage v1.27.0 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand All @@ -55,7 +55,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-alpha8 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.4 // indirect
github.com/cosmos/iavl v0.19.5 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.1 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
Expand Down Expand Up @@ -83,8 +83,7 @@ require (
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.6.0 // indirect
github.com/googleapis/go-type-adapters v1.0.0 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
Expand All @@ -102,7 +101,7 @@ require (
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
Expand Down Expand Up @@ -146,16 +145,16 @@ require (
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.opencensus.io v0.23.0 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.2.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect
golang.org/x/net v0.6.0 // indirect
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.102.0 // indirect
google.golang.org/api v0.103.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand All @@ -169,6 +168,7 @@ replace (
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/CosmWasm/wasmd => github.com/notional-labs/wasmd v0.30.0-sdk46
github.com/cosmos/iavl => github.com/cosmos/iavl v0.19.4
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
google.golang.org/grpc => google.golang.org/grpc v1.50.1
)
Loading