Skip to content

Commit

Permalink
Wasm clients (#7637)
Browse files Browse the repository at this point in the history
* feat: introduce wasm clients

* make tests run sequencially to avoid race conditions related to the wasm lightclient store key

* use a tagged version of 08-wasm

Signed-off-by: aeryz <[email protected]>

* add wasm light client to CHANGELOG.md

Signed-off-by: aeryz <[email protected]>

* update go.sum

* updated go version in workflows and readme

* more version upgrades

* undo init image base go version change

* added store to upgrade

* run e2e-setup

* test

* add back go setup

* Revert "add back go setup"

This reverts commit bf5226d.

* Revert "Revert "add back go setup""

This reverts commit ce50db7.

* added comment for the future

---------

Signed-off-by: aeryz <[email protected]>
Co-authored-by: aeryz <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
  • Loading branch information
3 people authored Mar 5, 2024
1 parent f425e92 commit 7fa4daa
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/gen-upgrade-on-manual-input.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:
- name: 🐿 Setup Golang
uses: actions/setup-go@v5
with:
go-version: "^1.20"
- name: Specify input
go-version: '^1.21'
-
name: Specify input
run: |
env=${{ inputs.version }}
if [[ $env != '' ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-mod-auto-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ">=1.20.0"
go-version: ">=1.21.0"
- name: Fetch branches and checkout target
run: |
git fetch origin ${{ inputs.target-branch }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ on:
- concentrated-liquidity-main

env:
GO_VERSION: "1.20.5"
GO_VERSION: "1.21"
GIT_DIFF:


jobs:
golangci:
name: Run golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutest-issue-generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: 🐿 Setup Golang
uses: actions/setup-go@v5
with:
go-version: "^1.20"
go-version: "^1.21"
- name: Display go version
run: go version
- name: Run mutation test
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/sim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
- name: 🐿 Setup Golang
uses: actions/setup-go@v5
with:
go-version: "^1.20"
- name: Get git diff
go-version: '^1.21'
-
name: Get git diff
uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
# Setup Golang based on the go.mod file.
# This is needed when the go version has changed and the code uses features from the new version.gi
- name: 🐿 Setup Golang
uses: actions/setup-go@v5
with:
Expand Down Expand Up @@ -124,6 +126,10 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 🐿 Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build e2e image
uses: docker/build-push-action@v5
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/update-go-import-paths.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ on:
required: true

env:
GO_VERSION: "1.20.5"
GO_VERSION: '1.21'


jobs:
update-import-paths:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#7619](https://github.com/osmosis-labs/osmosis/pull/7619) Slight speedup/gas improvement to CL GetTotalPoolLiquidity queries
* [#7623](https://github.com/osmosis-labs/osmosis/pull/7623) Add query for querying all before send hooks
* [#7622](https://github.com/osmosis-labs/osmosis/pull/7622) Remove duplicate CL accumulator update logic.
* [#7503](https://github.com/osmosis-labs/osmosis/pull/7503) Add IBC wasm light clients module.

### State Compatible

Expand Down
20 changes: 20 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper"
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"

Expand Down Expand Up @@ -232,6 +234,12 @@ func NewOsmosisApp(
app.homePath = homePath
dataDir := filepath.Join(homePath, "data")
wasmDir := filepath.Join(homePath, "wasm")
ibcWasmConfig :=
ibcwasmtypes.WasmConfig{
DataDir: filepath.Join(homePath, "ibc_08-wasm"),
SupportedCapabilities: "iterator",
ContractDebugMode: false,
}
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
// Uncomment this for debugging contracts. In the future this could be made into a param passed by the tests
// wasmConfig.ContractDebugMode = true
Expand All @@ -258,6 +266,7 @@ func NewOsmosisApp(
wasmConfig,
wasmOpts,
app.BlockedAddrs(),
ibcWasmConfig,
)

// Initialize the ingest manager for propagating data to external sinks.
Expand Down Expand Up @@ -393,6 +402,13 @@ func NewOsmosisApp(
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}

err = manager.RegisterExtensions(
ibcwasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), app.IBCWasmClientKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}
}

if loadLatest {
Expand All @@ -406,6 +422,10 @@ func NewOsmosisApp(
if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil {
tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err))
}

if err := ibcwasmkeeper.InitializePinnedCodes(ctx, appCodec); err != nil {
tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err))
}
}

return app
Expand Down
17 changes: 17 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import (
ibchookstypes "github.com/osmosis-labs/osmosis/x/ibc-hooks/types"

icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper"
ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper"
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
Expand Down Expand Up @@ -143,6 +145,7 @@ type AppKeepers struct {
ICAHostKeeper *icahostkeeper.Keeper
ICQKeeper *icqkeeper.Keeper
TransferKeeper *ibctransferkeeper.Keeper
IBCWasmClientKeeper *ibcwasmkeeper.Keeper
EvidenceKeeper *evidencekeeper.Keeper
GAMMKeeper *gammkeeper.Keeper
TwapKeeper *twap.Keeper
Expand Down Expand Up @@ -191,6 +194,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
wasmConfig wasmtypes.WasmConfig,
wasmOpts []wasmkeeper.Option,
blockedAddress map[string]bool,
ibcWasmConfig ibcwasmtypes.WasmConfig,
) {
legacyAmino := encodingConfig.Amino
// Add 'normal' keepers
Expand Down Expand Up @@ -271,6 +275,18 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
)
appKeepers.IBCHooksKeeper = hooksKeeper

// We are using a separate VM here
ibcWasmClientKeeper := ibcwasmkeeper.NewKeeperWithConfig(
appCodec,
appKeepers.keys[ibcwasmtypes.StoreKey],
appKeepers.IBCKeeper.ClientKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ibcWasmConfig,
bApp.GRPCQueryRouter(),
)

appKeepers.IBCWasmClientKeeper = &ibcWasmClientKeeper

appKeepers.WireICS20PreWasmKeeper(appCodec, bApp, appKeepers.IBCHooksKeeper)

icaHostKeeper := icahostkeeper.NewKeeper(
Expand Down Expand Up @@ -812,6 +828,7 @@ func KVStoreKeys() []string {
upgradetypes.StoreKey,
evidencetypes.StoreKey,
ibctransfertypes.StoreKey,
ibcwasmtypes.StoreKey,
capabilitytypes.StoreKey,
gammtypes.StoreKey,
twaptypes.StoreKey,
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"
ibcwasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm"
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"

"github.com/cosmos/cosmos-sdk/x/consensus"
Expand Down Expand Up @@ -125,6 +126,7 @@ var AppModuleBasics = []module.AppModuleBasic{
ica.AppModuleBasic{},
ibc_hooks.AppModuleBasic{},
ibcratelimitmodule.AppModuleBasic{},
ibcwasm.AppModuleBasic{},
packetforward.AppModuleBasic{},
cosmwasmpoolmodule.AppModuleBasic{},
tendermint.AppModuleBasic{},
Expand Down
4 changes: 4 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"

ibcwasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm"
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported"
Expand Down Expand Up @@ -162,6 +164,7 @@ func appModules(
evidence.NewAppModule(*app.EvidenceKeeper),
authzmodule.NewAppModule(appCodec, *app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
ibcwasm.NewAppModule(*app.IBCWasmClientKeeper),
ica.NewAppModule(nil, app.ICAHostKeeper),
params.NewAppModule(*app.ParamsKeeper),
consensus.NewAppModule(appCodec, *app.AppKeepers.ConsensusParamsKeeper),
Expand Down Expand Up @@ -280,6 +283,7 @@ func OrderInitGenesis(allModuleNames []string) []string {
ibcratelimittypes.ModuleName,
// wasm after ibc transfer
wasmtypes.ModuleName,
ibcwasmtypes.ModuleName,
// ibc_hooks after auth keeper
ibchookstypes.ModuleName,
icqtypes.ModuleName,
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/v24/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v24

import (
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
"github.com/osmosis-labs/osmosis/v23/app/upgrades"

store "github.com/cosmos/cosmos-sdk/store/types"
Expand All @@ -13,7 +14,7 @@ var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Added: []string{ibcwasmtypes.StoreKey},
Deleted: []string{},
},
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.1
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092633-b306e7a706e1
github.com/cosmos/ibc-go/v7 v7.3.2
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.1 h1:PqI
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.1/go.mod h1:UvDmcGIWJPIytq+Q78/ff5NTOsuX/7IrNgEugTW5i0s=
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1 h1:02RCbih5lQ8aGdDMSvxhTnk5JDLEDitn17ytEE1Qhko=
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1/go.mod h1:LvVkEXTORVgd87W2Yu7ZY3acKKeTMq/txdTworn8EZI=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092633-b306e7a706e1 h1:fCtG9qasnNzhgxGR1jM9eBufZ5WQVpy0KdaOpKRfg8Y=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092633-b306e7a706e1/go.mod h1:h114vYKBtI5zKBeSyr8y5JZ8ZtpQJInO4TYww2IQr6o=
github.com/cosmos/ibc-go/v7 v7.3.2 h1:FeUDcBX7VYY0e0iRmcVkPPUjYfAqIc//QuHXo8JHz9c=
github.com/cosmos/ibc-go/v7 v7.3.2/go.mod h1:IMeOXb7gwpZ+/nOG5BuUkdW4weM1ezvN4PQPws4uzOI=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
Expand Down
2 changes: 1 addition & 1 deletion proto/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

FROM bufbuild/buf:1.7.0 as BUILDER

FROM golang:1.20-alpine
FROM golang:1.21-alpine


RUN apk add --no-cache \
Expand Down
2 changes: 1 addition & 1 deletion tests/localosmosis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ services:
# dockerfile: Dockerfile
# args:
# RUNNER_IMAGE: alpine:3.17
# GO_VERSION: 1.20
# GO_VERSION: 1.21
```

2. Checkout the Osmosis repository to a different `ref` that includes the new version, and then rebuild and restart LocalOsmosis using `make localnet-start`. Make sure to don't delete your `~/.osmosisd-local` folder.
Expand Down
6 changes: 5 additions & 1 deletion x/concentrated-liquidity/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ func fuzz(t *testing.T, numSwaps int, numPositions int, numIterations int) {
currentSuite.iteration = i

t.Run(fmt.Sprintf("Fuzz %d, seed: %d", i, currentSeed), func(t *testing.T) {
t.Parallel()
// This is commented out temporarily to avoid issues with the wasmStoreKey being
// a global in the wasm light client.
// See https://github.com/cosmos/ibc-go/blob/modules/light-clients/08-wasm/v0.1.0%2Bibc-go-v7.3-wasmvm-v1.5/modules/light-clients/08-wasm/internal/ibcwasm/wasm.go#L15-L17
// Once we move to ibc v8 we can make these tests run in parallel again.
//t.Parallel()

currentSuite.individualFuzz(r, i, numSwaps, numPositions)
})
Expand Down

0 comments on commit 7fa4daa

Please sign in to comment.