From f3d1acfc5a9429b20645ee9ccf2caf484fbb7cc3 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Wed, 1 Jun 2022 12:03:10 +0300 Subject: [PATCH 01/15] Fixing ibc test --- .../ibc-defi/cheqd/cheqd.Dockerfile | 49 +++++++++++++------ tests/e2e-complex/ibc-defi/hermes/config.toml | 9 ++-- .../ibc-defi/hermes/hermes.Dockerfile | 2 +- .../e2e-complex/ibc-defi/ibc-transfer-test.sh | 2 +- .../ibc-defi/osmosis/osmosis.Dockerfile | 10 +++- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile b/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile index e0f1566fb..70e35fcda 100644 --- a/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile +++ b/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile @@ -2,30 +2,47 @@ FROM golang:buster as builder -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +RUN apt-get update \ + && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends \ - curl \ - protobuf-compiler \ - libprotobuf-dev \ - wget \ - git \ - nano - -# Starport -# RUN curl https://get.starport.network/starport! | bash -# There is an issue with the latest starport, especially 0.18 version + curl \ + protobuf-compiler \ + libprotobuf-dev \ + wget \ + git \ + nano \ + && rm -rf /var/lib/apt/lists/* + +# Get go protoc compiler plugins. Taken from: tendermintdev/sdk-proto-gen:v0.2 +ENV GOLANG_PROTOBUF_VERSION=1.3.5 \ + GOGO_PROTOBUF_VERSION=1.3.2 \ + GRPC_GATEWAY_VERSION=1.14.7 + +RUN go get \ + github.com/golang/protobuf/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} \ + github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} \ + github.com/gogo/protobuf/protoc-gen-gogofast@v${GOGO_PROTOBUF_VERSION} \ + github.com/gogo/protobuf/protoc-gen-gogofaster@v${GOGO_PROTOBUF_VERSION} \ + github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} \ + github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION} \ + github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest + +# Install buf SHELL ["/bin/bash", "-euo", "pipefail", "-c"] -RUN wget -qO- https://github.com/tendermint/starport/releases/download/v0.18.6/starport_0.18.6_linux_amd64.tar.gz | tar xvz -C /tmp/ && cp /tmp/starport /usr/bin +RUN PREFIX="/usr/local" && \ + VERSION="1.0.0-rc8" && \ + curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m).tar.gz" | \ + tar -xvzf - -C "${PREFIX}" --strip-components 1 -# App +# Fetch and build app WORKDIR /app -RUN git clone --depth 1 --branch v0.3.1 https://github.com/cheqd/cheqd-node +RUN git clone --depth 1 --branch v0.5.0 https://github.com/cheqd/cheqd-node WORKDIR /app/cheqd-node -RUN starport chain build +RUN make proto-gen build ##### Run container ##### @@ -40,7 +57,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ netcat # Node binary -COPY --from=builder /go/bin/cheqd-noded /bin +COPY --from=builder /app/cheqd-node/build/cheqd-noded /bin RUN groupadd --system --gid 1000 cheqd && \ useradd --system --create-home --home-dir /cheqd --shell /bin/bash --gid cheqd --uid 1000 cheqd diff --git a/tests/e2e-complex/ibc-defi/hermes/config.toml b/tests/e2e-complex/ibc-defi/hermes/config.toml index 156e7bc51..0780f4eac 100644 --- a/tests/e2e-complex/ibc-defi/hermes/config.toml +++ b/tests/e2e-complex/ibc-defi/hermes/config.toml @@ -21,7 +21,6 @@ enabled = false enabled = true clear_interval = 100 clear_on_start = true -filter = false tx_confirmation = true [rest] @@ -44,12 +43,14 @@ account_prefix = 'cheqd' key_name = 'cheqd-key' address_type = { derivation = 'cosmos' } store_prefix = 'ibc' -max_gas = 3000000 +default_gas = 100000 +max_gas = 400000 gas_price = { price = 25, denom = 'ncheq' } gas_adjustment = 0.1 max_msg_num = 30 max_tx_size = 2097152 clock_drift = '5s' +max_block_time = '30s' trusting_period = '14days' trust_threshold = { numerator = '1', denominator = '3' } @@ -62,12 +63,14 @@ rpc_timeout = '10s' account_prefix = 'osmo' key_name = 'osmosis-key' store_prefix = 'ibc' -max_gas = 3000000 +default_gas = 100000 +max_gas = 400000 gas_price = { price = 0, denom = 'stake' } gas_adjustment = 0.1 max_msg_num = 30 max_tx_size = 2097152 clock_drift = '5s' +max_block_time = '30s' trusting_period = '14days' trust_threshold = { numerator = '1', denominator = '3' } address_type = { derivation = 'cosmos' } diff --git a/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile b/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile index b4231d386..89f8df5af 100644 --- a/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile +++ b/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile @@ -12,7 +12,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ WORKDIR /app -RUN git clone --depth 1 --branch v0.9.0 https://github.com/informalsystems/ibc-rs +RUN git clone --depth 1 --branch v0.15.0 https://github.com/informalsystems/ibc-rs WORKDIR /app/ibc-rs diff --git a/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh b/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh index ce4e43e8b..7497f21e3 100755 --- a/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh +++ b/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh @@ -58,7 +58,7 @@ docker-compose exec hermes hermes keys restore cheqd --mnemonic "$CHEQD_RELAYER_ docker-compose exec hermes hermes keys restore osmosis --mnemonic "$OSMOSIS_RELAYER_MNEMONIC" --name osmosis-key info "Open channel" # --- -docker-compose exec hermes hermes create channel cheqd osmosis --port-a transfer --port-b transfer +docker-compose exec hermes hermes create channel cheqd --chain-b osmosis --port-a transfer --port-b transfer --new-client-connection -y info "Start hermes" # --- docker-compose exec -d hermes hermes start diff --git a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile index 28cc4088d..17753bdcf 100644 --- a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile +++ b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile @@ -14,14 +14,20 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ git \ jq + +# From https://github.com/CosmWasm/wasmd/blob/master/Dockerfile +# For more details see https://github.com/CosmWasm/wasmvm#builds-of-libwasmvm +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0-beta7/libwasmvm_muslc.a /lib/libwasmvm_muslc.a + + # App WORKDIR /app -RUN git clone --depth 1 --branch v4.2.0 https://github.com/osmosis-labs/osmosis +RUN git clone --depth 1 --branch v8.0.0 https://github.com/osmosis-labs/osmosis WORKDIR /app/osmosis -RUN make install +RUN BUILD_TAGS=muslc make install ##### Run container ##### From 3a10e318b36ee5db416d4103235356ec37de1293 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Thu, 9 Jun 2022 06:44:27 +0300 Subject: [PATCH 02/15] Fix node image --- tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile b/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile index 70e35fcda..b0106729c 100644 --- a/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile +++ b/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile @@ -1,6 +1,6 @@ ##### Build container ##### -FROM golang:buster as builder +FROM golang:1.17.8-buster as builder RUN apt-get update \ && export DEBIAN_FRONTEND=noninteractive \ From a1163df1251c2f476e869089da3d8b1a55966407 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Thu, 30 Jun 2022 14:02:58 +0300 Subject: [PATCH 03/15] Bump IBC to 3.x --- app/app.go | 168 ++++++++++++++++++++++++++++++++++++++--------------- go.mod | 2 +- go.sum | 14 +---- 3 files changed, 125 insertions(+), 59 deletions(-) diff --git a/app/app.go b/app/app.go index f8716ffd6..c3bd6bdbb 100644 --- a/app/app.go +++ b/app/app.go @@ -6,6 +6,8 @@ import ( "os" "path/filepath" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cheqd/cheqd-node/x/resource" cheqdtypes "github.com/cheqd/cheqd-node/x/cheqd/types" @@ -14,16 +16,16 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" - "github.com/cosmos/ibc-go/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/modules/core" - ibcclient "github.com/cosmos/ibc-go/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" - porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" - ibchost "github.com/cosmos/ibc-go/modules/core/24-host" - ibckeeper "github.com/cosmos/ibc-go/modules/core/keeper" + "github.com/cosmos/ibc-go/v3/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v3/modules/core" + ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client" + ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client" + ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -102,6 +104,13 @@ import ( upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" tmjson "github.com/tendermint/tendermint/libs/json" + + ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" + icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" + icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" ) const ( @@ -212,12 +221,14 @@ type App struct { EvidenceKeeper evidencekeeper.Keeper FeegrantKeeper feegrantkeeper.Keeper IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + ICAHostKeeper icahostkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper AuthzKeeper authzkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper cheqdKeeper cheqdkeeper.Keeper resourceKeeper resourcekeeper.Keeper @@ -277,6 +288,7 @@ func New( // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating // their scoped modules in `NewApp` with `ScopeToModule` @@ -308,37 +320,6 @@ func New( ) app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp) - // Upgrade handler - app.UpgradeKeeper.SetUpgradeHandler("v0.3", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Handler for upgrade plan: v0.3") - - app.TestNetMigration(ctx) - initialVM := app.mm.GetVersionMap() - return initialVM, nil - }) - - app.UpgradeKeeper.SetUpgradeHandler("v0.4", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Handler for upgrade plan: v0.4") - - initialVM := app.mm.GetVersionMap() - return initialVM, nil - }) - - app.UpgradeKeeper.SetUpgradeHandler("v0.5", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Handler for upgrade plan: v0.5") - - app.Migration05(ctx) - initialVM := app.mm.GetVersionMap() - return initialVM, nil - }) - - app.UpgradeKeeper.SetUpgradeHandler("cosmovisor_test", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Handler for upgrade plan: cosmovisor_test") - - initialVM := app.mm.GetVersionMap() - return initialVM, nil - }) - // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks app.StakingKeeper = *stakingKeeper.SetHooks( @@ -367,11 +348,30 @@ func New( // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( - appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, - app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + appCodec, + keys[ibctransfertypes.StoreKey], + app.GetSubspace(ibctransfertypes.ModuleName), + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, + app.BankKeeper, + scopedTransferKeeper, ) transferModule := transfer.NewAppModule(app.TransferKeeper) + transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) + + app.ICAHostKeeper = icahostkeeper.NewKeeper( + appCodec, keys[icahosttypes.StoreKey], + app.GetSubspace(icahosttypes.SubModuleName), + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, + scopedICAHostKeeper, + app.MsgServiceRouter(), + ) + icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper) + icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) // Create evidence Keeper for to register the IBC light client misbehaviour evidence route evidenceKeeper := evidencekeeper.NewKeeper( @@ -395,7 +395,8 @@ func New( // Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() - ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule) + ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule). + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) app.IBCKeeper.SetRouter(ibcRouter) /**** Module Options ****/ @@ -431,6 +432,7 @@ func New( resource.NewAppModule(appCodec, app.resourceKeeper, app.cheqdKeeper), ibc.NewAppModule(app.IBCKeeper), transferModule, + icaModule, ) // During begin block slashing happens after distr.BeginBlocker so that @@ -453,6 +455,7 @@ func New( banktypes.ModuleName, crisistypes.ModuleName, ibctransfertypes.ModuleName, + icatypes.ModuleName, govtypes.ModuleName, feegrant.ModuleName, authz.ModuleName, @@ -477,6 +480,7 @@ func New( genutiltypes.ModuleName, banktypes.ModuleName, ibctransfertypes.ModuleName, + icatypes.ModuleName, feegrant.ModuleName, authz.ModuleName, paramstypes.ModuleName, @@ -503,6 +507,7 @@ func New( genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, + icatypes.ModuleName, feegrant.ModuleName, authz.ModuleName, cheqdtypes.ModuleName, @@ -526,6 +531,7 @@ func New( genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, + icatypes.ModuleName, feegrant.ModuleName, authz.ModuleName, cheqdtypes.ModuleName, @@ -564,12 +570,82 @@ func New( app.SetAnteHandler(anteHandler) app.SetEndBlocker(app.EndBlocker) + // Upgrade handlers + app.UpgradeKeeper.SetUpgradeHandler("v0.3", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Handler for upgrade plan: v0.3") + + app.TestNetMigration(ctx) + initialVM := app.mm.GetVersionMap() + return initialVM, nil + }) + + app.UpgradeKeeper.SetUpgradeHandler("v0.4", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Handler for upgrade plan: v0.4") + + initialVM := app.mm.GetVersionMap() + return initialVM, nil + }) + + app.UpgradeKeeper.SetUpgradeHandler("v0.5", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Handler for upgrade plan: v0.5") + + app.Migration05(ctx) + initialVM := app.mm.GetVersionMap() + return initialVM, nil + }) + + app.UpgradeKeeper.SetUpgradeHandler("v0.6", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Handler for upgrade plan: v0.6") + + // set the ICS27 consensus version so InitGenesis is not run + fromVM[icatypes.ModuleName] = icaModule.ConsensusVersion() + + // create ICS27 Controller submodule params + controllerParams := icacontrollertypes.Params{ + ControllerEnabled: true, + } + + // create ICS27 Host submodule params + hostParams := icahosttypes.Params{ + HostEnabled: true, + AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend"}, + } + + // initialize ICS27 module + icaModule.InitModule(ctx, controllerParams, hostParams) + + return fromVM, nil + }) + + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(err) + } + + if upgradeInfo.Name == "v0.6" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{ + Added: []string{icacontrollertypes.StoreKey, icahosttypes.StoreKey}, + } + + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } + + app.UpgradeKeeper.SetUpgradeHandler("cosmovisor_test", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Handler for upgrade plan: cosmovisor_test") + + return fromVM, nil + }) + if loadLatest { if err := app.LoadLatestVersion(); err != nil { - tmos.Exit(err.Error()) + panic(err) } } + app.ScopedIBCKeeper = scopedIBCKeeper + app.ScopedICAHostKeeper = scopedICAHostKeeper + app.ScopedTransferKeeper = scopedTransferKeeper + return app } diff --git a/go.mod b/go.mod index ac059b06c..6a2bfd35f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( filippo.io/edwards25519 v1.0.0-beta.2 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/cosmos/cosmos-sdk v0.45.6 - github.com/cosmos/ibc-go v1.4.0 + github.com/cosmos/ibc-go/v3 v3.1.0 github.com/gabriel-vasile/mimetype v1.4.0 github.com/go-ozzo/ozzo-validation/v4 v4.3.0 github.com/gogo/protobuf v1.3.3 diff --git a/go.sum b/go.sum index 07046cfc7..2c78153c0 100644 --- a/go.sum +++ b/go.sum @@ -144,7 +144,6 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= @@ -227,8 +226,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= -github.com/cosmos/ibc-go v1.4.0 h1:oQIFITF4oOkQNTHkKTan1e4ozvFAp34z1rnIbEnn/e0= -github.com/cosmos/ibc-go v1.4.0/go.mod h1:Ntn57AowrB7bmhFKFrmXbysf290sAZHHBpwZMyNh/vo= +github.com/cosmos/ibc-go/v3 v3.1.0 h1:aVPqkrGBluz6t9+d/sLZIG/zQ9O1KJzVeR4UlL/IFTQ= +github.com/cosmos/ibc-go/v3 v3.1.0/go.mod h1:DbOlOa4yKumaHGKApKkJN90L88PCjSD9ZBdAfL9tT40= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -691,7 +690,6 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -798,7 +796,6 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -918,14 +915,12 @@ github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY52 github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= @@ -940,7 +935,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= @@ -1199,7 +1193,6 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= @@ -1431,7 +1424,6 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= @@ -1552,8 +1544,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= From 2ade5b8f956b8cfbcbed11e78a270bb7e02fd562 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Thu, 30 Jun 2022 17:41:12 +0300 Subject: [PATCH 04/15] Clean-up app bootstrapping --- app/app.go | 402 ++++++++++++++++++++---------------- app/const.go | 33 +++ app/encoding.go | 7 +- app/encoding_test.go | 2 +- cmd/cheqd-noded/cmd/root.go | 2 +- 5 files changed, 266 insertions(+), 180 deletions(-) create mode 100644 app/const.go diff --git a/app/app.go b/app/app.go index c3bd6bdbb..c5dba3a6c 100644 --- a/app/app.go +++ b/app/app.go @@ -113,26 +113,6 @@ import ( icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" ) -const ( - Name = "cheqd-node" - ProtocolVersion = 1 -) - -func getGovProposalHandlers() []govclient.ProposalHandler { - var govProposalHandlers []govclient.ProposalHandler - - govProposalHandlers = append(govProposalHandlers, - paramsclient.ProposalHandler, - distrclient.ProposalHandler, - upgradeclient.ProposalHandler, - upgradeclient.CancelProposalHandler, - ibcclientclient.UpdateClientProposalHandler, - ibcclientclient.UpgradeProposalHandler, - ) - - return govProposalHandlers -} - var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -148,7 +128,14 @@ var ( staking.AppModuleBasic{}, mint.AppModuleBasic{}, distr.AppModuleBasic{}, - gov.NewAppModuleBasic(getGovProposalHandlers()...), + gov.NewAppModuleBasic([]govclient.ProposalHandler{ + paramsclient.ProposalHandler, + distrclient.ProposalHandler, + upgradeclient.ProposalHandler, + upgradeclient.CancelProposalHandler, + ibcclientclient.UpdateClientProposalHandler, + ibcclientclient.UpgradeProposalHandler, + }...), params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, @@ -161,17 +148,19 @@ var ( authzmodule.AppModuleBasic{}, cheqd.AppModuleBasic{}, resource.AppModuleBasic{}, + ica.AppModuleBasic{}, ) // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, distrtypes.ModuleName: nil, + icatypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } ) @@ -180,26 +169,16 @@ var ( _ servertypes.Application = (*App)(nil) ) -func init() { - userHomeDir, err := os.UserHomeDir() - if err != nil { - panic(err) - } - - DefaultNodeHome = filepath.Join(userHomeDir, ".cheqdnode") -} - // App extends an ABCI application, but with most of its parameters exported. // They are exported for convenience in creating helper functions, as object // capabilities aren't needed for testing. type App struct { *baseapp.BaseApp - cdc *codec.LegacyAmino + legacyAnimo *codec.LegacyAmino appCodec codec.Codec interfaceRegistry types.InterfaceRegistry - - invCheckPeriod uint + invCheckPeriod uint // keys to access the substores keys map[string]*sdk.KVStoreKey @@ -218,11 +197,11 @@ type App struct { CrisisKeeper crisiskeeper.Keeper UpgradeKeeper upgradekeeper.Keeper ParamsKeeper paramskeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - FeegrantKeeper feegrantkeeper.Keeper IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly ICAHostKeeper icahostkeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper AuthzKeeper authzkeeper.Keeper // make scoped keepers public for test purposes @@ -235,6 +214,17 @@ type App struct { // the module manager mm *module.Manager + + configurator module.Configurator +} + +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, Home) } // New returns a reference to an initialized Gaia. @@ -245,30 +235,46 @@ func New( appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { appCodec := encodingConfig.Codec - cdc := encodingConfig.Amino + legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry - bApp := baseapp.NewBaseApp(Name, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) + bApp := baseapp.NewBaseApp( + Name, + logger, + db, + encodingConfig.TxConfig.TxDecoder(), + baseAppOptions..., + ) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) - bApp.SetProtocolVersion(ProtocolVersion) bApp.SetInterfaceRegistry(interfaceRegistry) keys := sdk.NewKVStoreKeys( - authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, - minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, - evidencetypes.StoreKey, capabilitytypes.StoreKey, feegrant.StoreKey, - ibchost.StoreKey, ibctransfertypes.StoreKey, authzkeeper.StoreKey, - cheqdtypes.StoreKey, resourcetypes.StoreKey, + authtypes.StoreKey, + banktypes.StoreKey, + stakingtypes.StoreKey, + minttypes.StoreKey, + distrtypes.StoreKey, + slashingtypes.StoreKey, + govtypes.StoreKey, + paramstypes.StoreKey, + ibchost.StoreKey, + upgradetypes.StoreKey, + evidencetypes.StoreKey, + ibctransfertypes.StoreKey, + capabilitytypes.StoreKey, + feegrant.StoreKey, + authzkeeper.StoreKey, + icahosttypes.StoreKey, + cheqdtypes.StoreKey, + resourcetypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &App{ BaseApp: bApp, - cdc: cdc, + legacyAnimo: legacyAmino, appCodec: appCodec, interfaceRegistry: interfaceRegistry, invCheckPeriod: invCheckPeriod, @@ -277,10 +283,12 @@ func New( memKeys: memKeys, } - app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) // set the BaseApp's parameter store - bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) + bApp.SetParamStore( + app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()), + ) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) @@ -296,29 +304,74 @@ func New( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( - appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, + appCodec, + keys[authtypes.StoreKey], + app.GetSubspace(authtypes.ModuleName), + authtypes.ProtoBaseAccount, + maccPerms, ) + app.BankKeeper = bankkeeper.NewBaseKeeper( - appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), + appCodec, + keys[banktypes.StoreKey], + app.AccountKeeper, + app.GetSubspace(banktypes.ModuleName), + app.BlockedModuleAccountAddrs(), + ) + + app.AuthzKeeper = authzkeeper.NewKeeper( + keys[authzkeeper.StoreKey], + appCodec, + app.MsgServiceRouter(), + ) + + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + keys[feegrant.StoreKey], + app.AccountKeeper, ) + stakingKeeper := stakingkeeper.NewKeeper( - appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), + appCodec, + keys[stakingtypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + app.GetSubspace(stakingtypes.ModuleName), ) + app.MintKeeper = mintkeeper.NewKeeper( - appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, - app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, + appCodec, + keys[minttypes.StoreKey], + app.GetSubspace(minttypes.ModuleName), + &stakingKeeper, + app.AccountKeeper, + app.BankKeeper, + authtypes.FeeCollectorName, ) + app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), + appCodec, keys[distrtypes.StoreKey], + app.GetSubspace(distrtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + &stakingKeeper, + authtypes.FeeCollectorName, + app.BlockedModuleAccountAddrs(), ) + app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), + appCodec, + keys[slashingtypes.StoreKey], + &stakingKeeper, + app.GetSubspace(slashingtypes.ModuleName), ) + app.CrisisKeeper = crisiskeeper.NewKeeper( - app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, + app.GetSubspace(crisistypes.ModuleName), + invCheckPeriod, + app.BankKeeper, + authtypes.FeeCollectorName, ) - app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks @@ -326,17 +379,24 @@ func New( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), ) - // Create IBC Keeper - app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + // UpgradeKeeper must be created before IBCKeeper + app.UpgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + keys[upgradetypes.StoreKey], + appCodec, + homePath, + app.BaseApp, ) - app.FeegrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) - - authzKeeper := authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), + // Create IBC Keeper + app.IBCKeeper = ibckeeper.NewKeeper( + appCodec, + keys[ibchost.StoreKey], + app.GetSubspace(ibchost.ModuleName), + app.StakingKeeper, + app.UpgradeKeeper, + scopedIBCKeeper, ) - app.AuthzKeeper = authzKeeper // register the proposal types govRouter := govtypes.NewRouter() @@ -346,6 +406,16 @@ func New( AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + app.GovKeeper = govkeeper.NewKeeper( + appCodec, + keys[govtypes.StoreKey], + app.GetSubspace(govtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + &stakingKeeper, + govRouter, + ) + // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, @@ -361,6 +431,7 @@ func New( transferModule := transfer.NewAppModule(app.TransferKeeper) transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) + // Create IBC Host Keepers app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), @@ -373,10 +444,21 @@ func New( icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper) icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) + // Create static IBC router, add transfer route, then set and seal it + ibcRouter := porttypes.NewRouter() + ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule). + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) + + app.IBCKeeper.SetRouter(ibcRouter) + // Create evidence Keeper for to register the IBC light client misbehaviour evidence route evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper, + appCodec, + keys[evidencetypes.StoreKey], + &app.StakingKeeper, + app.SlashingKeeper, ) + // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper @@ -388,26 +470,12 @@ func New( appCodec, keys[resourcetypes.StoreKey], ) - app.GovKeeper = govkeeper.NewKeeper( - appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, govRouter, - ) - - // Create static IBC router, add transfer route, then set and seal it - ibcRouter := porttypes.NewRouter() - ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule). - AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) - app.IBCKeeper.SetRouter(ibcRouter) - - /**** Module Options ****/ - // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.mm = module.NewManager( genutil.NewAppModule( app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, @@ -425,14 +493,14 @@ func New( staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), - params.NewAppModule(app.ParamsKeeper), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeegrantKeeper, app.interfaceRegistry), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - cheqd.NewAppModule(appCodec, app.cheqdKeeper), - resource.NewAppModule(appCodec, app.resourceKeeper, app.cheqdKeeper), ibc.NewAppModule(app.IBCKeeper), + params.NewAppModule(app.ParamsKeeper), transferModule, icaModule, + cheqd.NewAppModule(appCodec, app.cheqdKeeper), + resource.NewAppModule(appCodec, app.resourceKeeper, app.cheqdKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -448,20 +516,20 @@ func New( slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, - ibchost.ModuleName, - cheqdtypes.ModuleName, - resourcetypes.ModuleName, - genutiltypes.ModuleName, + authtypes.ModuleName, banktypes.ModuleName, + govtypes.ModuleName, crisistypes.ModuleName, + ibchost.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, - govtypes.ModuleName, - feegrant.ModuleName, + genutiltypes.ModuleName, authz.ModuleName, + feegrant.ModuleName, paramstypes.ModuleName, - authtypes.ModuleName, vestingtypes.ModuleName, + cheqdtypes.ModuleName, + resourcetypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -517,84 +585,38 @@ func New( paramstypes.ModuleName, ) - app.mm.SetOrderMigrations( - capabilitytypes.ModuleName, - authtypes.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - stakingtypes.ModuleName, - slashingtypes.ModuleName, - govtypes.ModuleName, - minttypes.ModuleName, - crisistypes.ModuleName, - ibchost.ModuleName, - genutiltypes.ModuleName, - evidencetypes.ModuleName, - ibctransfertypes.ModuleName, - icatypes.ModuleName, - feegrant.ModuleName, - authz.ModuleName, - cheqdtypes.ModuleName, - resourcetypes.ModuleName, - paramstypes.ModuleName, - vestingtypes.ModuleName, - upgradetypes.ModuleName, - ) + // Uncomment if you want to set a custom migration order here. + // app.mm.SetOrderMigrations(custom order) app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) - app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())) + + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + app.mm.RegisterServices(app.configurator) // initialize stores app.MountKVStores(keys) app.MountTransientStores(tkeys) app.MountMemoryStores(memKeys) - // initialize BaseApp - app.SetInitChainer(app.InitChainer) - app.SetBeginBlocker(app.BeginBlocker) - - handlerOptions := ante.HandlerOptions{ + anteHandler, err := ante.NewAnteHandler(ante.HandlerOptions{ AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, - FeegrantKeeper: app.FeegrantKeeper, + FeegrantKeeper: app.FeeGrantKeeper, SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - } - - anteHandler, err := ante.NewAnteHandler(handlerOptions) + }) if err != nil { tmos.Exit(err.Error()) } app.SetAnteHandler(anteHandler) + app.SetInitChainer(app.InitChainer) + app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - // Upgrade handlers - app.UpgradeKeeper.SetUpgradeHandler("v0.3", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Handler for upgrade plan: v0.3") - - app.TestNetMigration(ctx) - initialVM := app.mm.GetVersionMap() - return initialVM, nil - }) - - app.UpgradeKeeper.SetUpgradeHandler("v0.4", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Handler for upgrade plan: v0.4") - - initialVM := app.mm.GetVersionMap() - return initialVM, nil - }) - - app.UpgradeKeeper.SetUpgradeHandler("v0.5", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Handler for upgrade plan: v0.5") - - app.Migration05(ctx) - initialVM := app.mm.GetVersionMap() - return initialVM, nil - }) - - app.UpgradeKeeper.SetUpgradeHandler("v0.6", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Latest upgrade handler + app.UpgradeKeeper.SetUpgradeHandler(UpgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("Handler for upgrade plan: v0.6") // set the ICS27 consensus version so InitGenesis is not run @@ -607,30 +629,60 @@ func New( // create ICS27 Host submodule params hostParams := icahosttypes.Params{ - HostEnabled: true, - AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend"}, + HostEnabled: true, + AllowMessages: []string{ + authzMsgExec, + authzMsgGrant, + authzMsgRevoke, + bankMsgSend, + bankMsgMultiSend, + distrMsgSetWithdrawAddr, + distrMsgWithdrawValidatorCommission, + distrMsgFundCommunityPool, + distrMsgWithdrawDelegatorReward, + feegrantMsgGrantAllowance, + feegrantMsgRevokeAllowance, + govMsgVoteWeighted, + govMsgSubmitProposal, + govMsgDeposit, + govMsgVote, + stakingMsgEditValidator, + stakingMsgDelegate, + stakingMsgUndelegate, + stakingMsgBeginRedelegate, + stakingMsgCreateValidator, + vestingMsgCreateVestingAccount, + ibcMsgTransfer, + }, } // initialize ICS27 module + ctx.Logger().Info("start to init interchainaccount module...") icaModule.InitModule(ctx, controllerParams, hostParams) + ctx.Logger().Info("start to run module migrations...") return fromVM, nil }) + // Store migration for the latest upgrade upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(err) } - if upgradeInfo.Name == "v0.6" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{icacontrollertypes.StoreKey, icahosttypes.StoreKey}, + Added: []string{ + icahosttypes.StoreKey, + resourcetypes.StoreKey, + }, } app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } - app.UpgradeKeeper.SetUpgradeHandler("cosmovisor_test", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Test upgrade handler + app.UpgradeKeeper.SetUpgradeHandler(CosmovisorTestUpgrade, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("Handler for upgrade plan: cosmovisor_test") return fromVM, nil @@ -662,12 +714,6 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo return app.mm.EndBlock(ctx, req) } -func (app *App) TestNetMigration(ctx sdk.Context) { - if ctx.ChainID() == "cheqd-testnet-2" { - app.cheqdKeeper.SetDidNamespace(&ctx, "testnet") - } -} - // InitChainer application update at chain initialization func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { // FIXME: This should have been done from the beginning. @@ -697,12 +743,23 @@ func (app *App) ModuleAccountAddrs() map[string]bool { return modAccAddrs } +// BlockedModuleAccountAddrs returns all the app's blocked module account +// addresses. +func (app *App) BlockedModuleAccountAddrs() map[string]bool { + modAccAddrs := app.ModuleAccountAddrs() + + // remove module accounts that are ALLOWED to received funds + delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + + return modAccAddrs +} + // LegacyAmino returns SimApp's amino codec. // // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. func (app *App) LegacyAmino() *codec.LegacyAmino { - return app.cdc + return app.legacyAnimo } // AppCodec returns Gaia's app codec. @@ -751,12 +808,13 @@ func (app *App) GetSubspace(moduleName string) paramstypes.Subspace { // API server. func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { clientCtx := apiSvr.ClientCtx + + // Register legacy rpc and authrest routes rpc.RegisterRoutes(clientCtx, apiSvr.Router) - // Register legacy tx routes. authrest.RegisterTxRoutes(clientCtx, apiSvr.Router) - // Register new tx routes from grpc-gateway. + + // Register new tx anr tendermint routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register new tendermint queries routes from grpc-gateway. tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register legacy and grpc-gateway routes for all modules. @@ -790,15 +848,6 @@ func (app *App) RegisterTendermintService(clientCtx client.Context) { tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) } -// GetMaccPerms returns a copy of the module account permissions -func GetMaccPerms() map[string][]string { - dupMaccPerms := make(map[string][]string) - for k, v := range maccPerms { - dupMaccPerms[k] = v - } - return dupMaccPerms -} - // initParamsKeeper init params keeper and its subspaces func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) @@ -811,8 +860,9 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(ibctransfertypes.ModuleName) + paramsKeeper.Subspace(icahosttypes.SubModuleName) return paramsKeeper } diff --git a/app/const.go b/app/const.go new file mode 100644 index 000000000..6d6fa8e17 --- /dev/null +++ b/app/const.go @@ -0,0 +1,33 @@ +package app + +const ( + Name = "cheqd-node" + Home = ".cheqdnode" + + UpgradeName = "v0.6" + CosmovisorTestUpgrade = "cosmovisor_test" + + // allowed msg types of ica host + authzMsgExec = "/cosmos.authz.v1beta1.MsgExec" + authzMsgGrant = "/cosmos.authz.v1beta1.MsgGrant" + authzMsgRevoke = "/cosmos.authz.v1beta1.MsgRevoke" + bankMsgSend = "/cosmos.bank.v1beta1.MsgSend" + bankMsgMultiSend = "/cosmos.bank.v1beta1.MsgMultiSend" + distrMsgSetWithdrawAddr = "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress" + distrMsgWithdrawValidatorCommission = "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission" + distrMsgFundCommunityPool = "/cosmos.distribution.v1beta1.MsgFundCommunityPool" + distrMsgWithdrawDelegatorReward = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward" + feegrantMsgGrantAllowance = "/cosmos.feegrant.v1beta1.MsgGrantAllowance" + feegrantMsgRevokeAllowance = "/cosmos.feegrant.v1beta1.MsgRevokeAllowance" + govMsgVoteWeighted = "/cosmos.gov.v1beta1.MsgVoteWeighted" + govMsgSubmitProposal = "/cosmos.gov.v1beta1.MsgSubmitProposal" + govMsgDeposit = "/cosmos.gov.v1beta1.MsgDeposit" + govMsgVote = "/cosmos.gov.v1beta1.MsgVote" + stakingMsgEditValidator = "/cosmos.staking.v1beta1.MsgEditValidator" + stakingMsgDelegate = "/cosmos.staking.v1beta1.MsgDelegate" + stakingMsgUndelegate = "/cosmos.staking.v1beta1.MsgUndelegate" + stakingMsgBeginRedelegate = "/cosmos.staking.v1beta1.MsgBeginRedelegate" + stakingMsgCreateValidator = "/cosmos.staking.v1beta1.MsgCreateValidator" + vestingMsgCreateVestingAccount = "/cosmos.vesting.v1beta1.MsgCreateVestingAccount" + ibcMsgTransfer = "/ibc.applications.transfer.v1.MsgTransfer" +) diff --git a/app/encoding.go b/app/encoding.go index 2ed725346..f390e831e 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -5,8 +5,11 @@ import ( "github.com/cosmos/cosmos-sdk/std" ) -// MakeEncodingConfig creates an EncodingConfig for testing -func MakeEncodingConfig() params.EncodingConfig { +// MakeTestEncodingConfig creates an EncodingConfig for testing. This function +// should be used only in tests or when creating a new app instance (NewApp*()). +// App user shouldn't create new codecs - use the app.AppCodec instead. +// [DEPRECATED] +func MakeTestEncodingConfig() params.EncodingConfig { encodingConfig := params.MakeEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) diff --git a/app/encoding_test.go b/app/encoding_test.go index 5f3dc309b..acd26ab32 100644 --- a/app/encoding_test.go +++ b/app/encoding_test.go @@ -8,7 +8,7 @@ import ( ) func Test_MsgCreateDidPayload_UnmarshalJSON(t *testing.T) { - cdc := MakeEncodingConfig() + cdc := MakeTestEncodingConfig() createPayloadJson := `{"id": "did:cheqd:alice"}` diff --git a/cmd/cheqd-noded/cmd/root.go b/cmd/cheqd-noded/cmd/root.go index df2a4865d..ec948b35c 100644 --- a/cmd/cheqd-noded/cmd/root.go +++ b/cmd/cheqd-noded/cmd/root.go @@ -46,7 +46,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { // Set config for prefixes app.SetConfig() - encodingConfig := app.MakeEncodingConfig() + encodingConfig := app.MakeTestEncodingConfig() initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). From 2832b50a77164c852c17a0d42963bda2fe9677ef Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Thu, 30 Jun 2022 19:33:46 +0100 Subject: [PATCH 05/15] Remove unused Gravity DEX IBC test --- .../ibc-defi/gravity/gravity.Dockerfile | 52 ------------------- .../ibc-defi/gravity/gravity_init.sh | 30 ----------- 2 files changed, 82 deletions(-) delete mode 100644 tests/e2e-complex/ibc-defi/gravity/gravity.Dockerfile delete mode 100755 tests/e2e-complex/ibc-defi/gravity/gravity_init.sh diff --git a/tests/e2e-complex/ibc-defi/gravity/gravity.Dockerfile b/tests/e2e-complex/ibc-defi/gravity/gravity.Dockerfile deleted file mode 100644 index 644f761ec..000000000 --- a/tests/e2e-complex/ibc-defi/gravity/gravity.Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -##### Build container ##### - -FROM golang:buster as builder - -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - curl \ - protobuf-compiler \ - libprotobuf-dev \ - wget \ - git \ - nano - -# App -WORKDIR /app - -RUN git clone --depth 1 --branch v1.4.0 https://github.com/tendermint/liquidity - -WORKDIR /app/liquidity - -RUN make install - - -##### Run container ##### - -FROM debian:buster - -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - nano \ - curl \ - wget \ - netcat - -# Node binary -COPY --from=builder /go/bin/liquidityd /bin - -RUN groupadd --system --gid 1000 gravity && \ - useradd --system --create-home --home-dir /gravity --shell /bin/bash --gid gravity --uid 1000 gravity -RUN chown -R gravity /gravity - -WORKDIR /gravity -USER gravity - -EXPOSE 26656 26657 -STOPSIGNAL SIGTERM - -# Init network -COPY gravity_init.sh . -RUN bash gravity_init.sh - -ENTRYPOINT [ "liquidityd", "start" ] diff --git a/tests/e2e-complex/ibc-defi/gravity/gravity_init.sh b/tests/e2e-complex/ibc-defi/gravity/gravity_init.sh deleted file mode 100755 index c4a03de8b..000000000 --- a/tests/e2e-complex/ibc-defi/gravity/gravity_init.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -euox pipefail - -# sed in macos requires extra argument - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - -CHAIN_ID="gravity" - -# Node -liquidityd init node0 --chain-id $CHAIN_ID -NODE_0_VAL_PUBKEY=$(liquidityd tendermint show-validator) - -# User -liquidityd keys add gravity-user --keyring-backend test - -# Config -sed -i $sed_extension 's|minimum-gas-prices = ""|minimum-gas-prices = "0stake"|g' "$HOME/.liquidityapp/config/app.toml" -sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.liquidityapp/config/config.toml" - -liquidityd add-genesis-account gravity-user 1000000000stake --keyring-backend test -liquidityd gentx gravity-user 1000000000stake --chain-id $CHAIN_ID --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test - -liquidityd collect-gentxs -liquidityd validate-genesis From ed0ab443cf36a76d4499dabea4c8a8d6d0c98c99 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Fri, 1 Jul 2022 16:02:11 +0300 Subject: [PATCH 06/15] Fix ibc test --- tests/e2e-complex/ibc-defi/ibc-transfer-test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh b/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh index 7497f21e3..bf154affb 100755 --- a/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh +++ b/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh @@ -34,7 +34,7 @@ sleep 15 # Wait for chains info "Create relayer user on cheqd" # --- CHEQD_RELAYER_KEY_NAME="cheqd-relayer" -CHEQD_RELAYER_ACCOUNT=$(docker-compose exec cheqd cheqd-noded keys add ${CHEQD_RELAYER_KEY_NAME} --keyring-backend test --output json) +CHEQD_RELAYER_ACCOUNT=$(docker-compose exec cheqd cheqd-noded keys add ${CHEQD_RELAYER_KEY_NAME} --keyring-backend test --output json 2>&1) CHEQD_RELAYER_ADDRESS=$(echo "${CHEQD_RELAYER_ACCOUNT}" | jq --raw-output '.address') CHEQD_RELAYER_MNEMONIC=$(echo "${CHEQD_RELAYER_ACCOUNT}" | jq --raw-output '.mnemonic') @@ -44,7 +44,7 @@ assert_tx_successful "${RES}" info "Create relayer user on osmosis" # --- OSMOSIS_RELAYER_KEY_NAME="osmosis-relayer" -OSMOSIS_RELAYER_ACCOUNT=$(docker-compose exec osmosis osmosisd keys add ${OSMOSIS_RELAYER_KEY_NAME} --output json --keyring-backend test) +OSMOSIS_RELAYER_ACCOUNT=$(docker-compose exec osmosis osmosisd keys add ${OSMOSIS_RELAYER_KEY_NAME} --output json --keyring-backend test 2>&1) OSMOSIS_RELAYER_ADDRESS=$(echo "${OSMOSIS_RELAYER_ACCOUNT}" | jq --raw-output '.address') OSMOSIS_RELAYER_MNEMONIC=$(echo "${OSMOSIS_RELAYER_ACCOUNT}" | jq --raw-output '.mnemonic') @@ -58,7 +58,7 @@ docker-compose exec hermes hermes keys restore cheqd --mnemonic "$CHEQD_RELAYER_ docker-compose exec hermes hermes keys restore osmosis --mnemonic "$OSMOSIS_RELAYER_MNEMONIC" --name osmosis-key info "Open channel" # --- -docker-compose exec hermes hermes create channel cheqd --chain-b osmosis --port-a transfer --port-b transfer --new-client-connection -y +docker-compose exec hermes hermes create channel cheqd --chain-b osmosis --port-a transfer --port-b transfer --new-client-connection info "Start hermes" # --- docker-compose exec -d hermes hermes start From 990edff30e1adb878c3527e4fb5d4d7fc9599c68 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Fri, 1 Jul 2022 16:38:00 +0300 Subject: [PATCH 07/15] Bump osmosis in the IBC test --- .../ibc-defi/osmosis/osmosis.Dockerfile | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile index 17753bdcf..acbe6f2ea 100644 --- a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile +++ b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile @@ -1,33 +1,27 @@ ##### Build container ##### -FROM golang:buster as builder - -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - curl \ - make \ - gcc \ - python \ - protobuf-compiler \ - libprotobuf-dev \ - wget \ - git \ - jq +# Taken from: https://github.com/osmosis-labs/osmosis/blob/v10.0.1/Dockerfile +FROM golang:1.18.2-alpine3.15 as build +RUN set -eux; apk add --no-cache ca-certificates build-base; +RUN apk add git +# Needed by github.com/zondax/hid +RUN apk add linux-headers -# From https://github.com/CosmWasm/wasmd/blob/master/Dockerfile -# For more details see https://github.com/CosmWasm/wasmvm#builds-of-libwasmvm -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0-beta7/libwasmvm_muslc.a /lib/libwasmvm_muslc.a - - -# App -WORKDIR /app - +WORKDIR / RUN git clone --depth 1 --branch v8.0.0 https://github.com/osmosis-labs/osmosis +WORKDIR /osmosis + +# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a +RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc +RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 -WORKDIR /app/osmosis +# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` +RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a -RUN BUILD_TAGS=muslc make install +RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build ##### Run container ##### @@ -42,7 +36,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ netcat # Node binary -COPY --from=builder /go/bin/osmosisd /bin +COPY --from=build /osmosis/build/osmosisd /bin/osmosisd RUN groupadd --system --gid 1000 osmosis && \ useradd --system --create-home --home-dir /osmosis --shell /bin/bash --gid osmosis --uid 1000 osmosis From 884f09f37740968d7d40237e14a6a2d996cd441d Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Fri, 1 Jul 2022 16:40:37 +0300 Subject: [PATCH 08/15] Make max_gaas consistent --- tests/e2e-complex/ibc-defi/hermes/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e-complex/ibc-defi/hermes/config.toml b/tests/e2e-complex/ibc-defi/hermes/config.toml index 0780f4eac..4a0f513ed 100644 --- a/tests/e2e-complex/ibc-defi/hermes/config.toml +++ b/tests/e2e-complex/ibc-defi/hermes/config.toml @@ -44,7 +44,7 @@ key_name = 'cheqd-key' address_type = { derivation = 'cosmos' } store_prefix = 'ibc' default_gas = 100000 -max_gas = 400000 +max_gas = 2000000 gas_price = { price = 25, denom = 'ncheq' } gas_adjustment = 0.1 max_msg_num = 30 From 3b87fbdc81ba4b43c51fe4609f53877099a9065a Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Fri, 1 Jul 2022 16:45:45 +0300 Subject: [PATCH 09/15] Fix merge conflicts --- app/app.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/app.go b/app/app.go index 66ffdc8ae..c5dba3a6c 100644 --- a/app/app.go +++ b/app/app.go @@ -12,7 +12,6 @@ import ( cheqdtypes "github.com/cheqd/cheqd-node/x/cheqd/types" resourcetypes "github.com/cheqd/cheqd-node/x/resource/types" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" From 121e17943dbf750d8e1f6f1fd2f7ac1162f87d00 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Fri, 1 Jul 2022 18:03:24 +0300 Subject: [PATCH 10/15] Supress version pins in dockerfiles --- .github/linters/.hadolint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/linters/.hadolint.yml b/.github/linters/.hadolint.yml index 4fac55596..19159d3c5 100644 --- a/.github/linters/.hadolint.yml +++ b/.github/linters/.hadolint.yml @@ -12,4 +12,5 @@ override: info: - DL3008 - DL3027 + - DL3018 style: From 790df15da12bfa88f6929ba0541116fcec57ab46 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Fri, 1 Jul 2022 18:03:34 +0300 Subject: [PATCH 11/15] Fix linter issues --- tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile index acbe6f2ea..dfdb98b4e 100644 --- a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile +++ b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile @@ -15,11 +15,11 @@ WORKDIR /osmosis # CosmWasm: see https://github.com/CosmWasm/wasmvm/releases ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a -RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc -RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 +RUN set -o pipefail; sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc +RUN set -o pipefail; sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 # CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` -RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a +RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build From d5887bc02051c52d99467f265ebc793dd64ae16d Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Fri, 1 Jul 2022 18:10:22 +0300 Subject: [PATCH 12/15] Remove checksumm validation --- tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile index dfdb98b4e..7304f1bfe 100644 --- a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile +++ b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile @@ -15,8 +15,6 @@ WORKDIR /osmosis # CosmWasm: see https://github.com/CosmWasm/wasmvm/releases ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a -RUN set -o pipefail; sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc -RUN set -o pipefail; sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 # CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a From ebeb1a4c7d40af3ede8bf2892c0ca292583dff58 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 1 Jul 2022 17:19:43 +0100 Subject: [PATCH 13/15] Updated docker-compose with cheqd --- .../cheqd/{cheqd_init.sh => cheqd-init.sh} | 0 tests/e2e-complex/ibc-defi/docker-compose.yaml | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) rename tests/e2e-complex/ibc-defi/cheqd/{cheqd_init.sh => cheqd-init.sh} (100%) diff --git a/tests/e2e-complex/ibc-defi/cheqd/cheqd_init.sh b/tests/e2e-complex/ibc-defi/cheqd/cheqd-init.sh similarity index 100% rename from tests/e2e-complex/ibc-defi/cheqd/cheqd_init.sh rename to tests/e2e-complex/ibc-defi/cheqd/cheqd-init.sh diff --git a/tests/e2e-complex/ibc-defi/docker-compose.yaml b/tests/e2e-complex/ibc-defi/docker-compose.yaml index e4acb0da0..3718fe646 100644 --- a/tests/e2e-complex/ibc-defi/docker-compose.yaml +++ b/tests/e2e-complex/ibc-defi/docker-compose.yaml @@ -1,11 +1,16 @@ -version: '3.2' +version: '3.7' services: cheqd: image: cheqd build: - context: ./cheqd - dockerfile: cheqd.Dockerfile + context: ../../../ + dockerfile: docker/Dockerfile + target: base + configs: + - source: cheqd-init + target: /home/cheqd/cheqd-init.sh + entrypoint: /home/cheqd/cheqd-init.sh ports: - "26656:26656" # p2p - "26657:26657" # rpc @@ -32,3 +37,7 @@ services: - "3000:3000" # rest - "3001:3001" # telemetry entrypoint: tail -f /dev/null + +configs: + cheqd-init: + file: ./cheqd/cheqd-init.sh From ef7d875dbe95e3bb9a3064e46d203b7226ee0cbc Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Mon, 4 Jul 2022 16:15:35 +0300 Subject: [PATCH 14/15] Process review issues --- go.mod | 4 +- go.sum | 4 +- .../ibc-defi/cheqd/cheqd.Dockerfile | 76 ------------------- .../e2e-complex/ibc-defi/docker-compose.yaml | 17 +++-- .../ibc-defi/hermes/hermes.Dockerfile | 21 +++-- .../ibc-defi/hermes/hermes_init.sh | 3 - .../e2e-complex/ibc-defi/ibc-transfer-test.sh | 47 +++++++++++- .../ibc-defi/osmosis/osmosis.Dockerfile | 49 +++--------- 8 files changed, 77 insertions(+), 144 deletions(-) delete mode 100644 tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile delete mode 100755 tests/e2e-complex/ibc-defi/hermes/hermes_init.sh diff --git a/go.mod b/go.mod index 6a2bfd35f..27f64d374 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( filippo.io/edwards25519 v1.0.0-beta.2 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce - github.com/cosmos/cosmos-sdk v0.45.6 + github.com/cosmos/cosmos-sdk v0.45.5 github.com/cosmos/ibc-go/v3 v3.1.0 github.com/gabriel-vasile/mimetype v1.4.0 github.com/go-ozzo/ozzo-validation/v4 v4.3.0 @@ -139,7 +139,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/cheqd/cosmos-sdk v0.45.4-cheqd-tag + github.com/cosmos/cosmos-sdk => github.com/cheqd/cosmos-sdk v0.45.5-cheqd-tag // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 diff --git a/go.sum b/go.sum index 2c78153c0..c31311712 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= -github.com/cheqd/cosmos-sdk v0.45.4-cheqd-tag h1:vQZAlbsqwPkC8DdwRI3TpRJ8ofoqKzAkPvHNzcrx9L0= -github.com/cheqd/cosmos-sdk v0.45.4-cheqd-tag/go.mod h1:WOqtDxN3eCCmnYLVla10xG7lEXkFjpTaqm2a2WasgCc= +github.com/cheqd/cosmos-sdk v0.45.5-cheqd-tag h1:Uky4sG2mlbQmEIIaXcpJMKwUQ3BkBJVz2HVjyAWtX0o= +github.com/cheqd/cosmos-sdk v0.45.5-cheqd-tag/go.mod h1:WOqtDxN3eCCmnYLVla10xG7lEXkFjpTaqm2a2WasgCc= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= diff --git a/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile b/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile deleted file mode 100644 index b0106729c..000000000 --- a/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile +++ /dev/null @@ -1,76 +0,0 @@ -##### Build container ##### - -FROM golang:1.17.8-buster as builder - -RUN apt-get update \ - && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - curl \ - protobuf-compiler \ - libprotobuf-dev \ - wget \ - git \ - nano \ - && rm -rf /var/lib/apt/lists/* - -# Get go protoc compiler plugins. Taken from: tendermintdev/sdk-proto-gen:v0.2 -ENV GOLANG_PROTOBUF_VERSION=1.3.5 \ - GOGO_PROTOBUF_VERSION=1.3.2 \ - GRPC_GATEWAY_VERSION=1.14.7 - -RUN go get \ - github.com/golang/protobuf/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} \ - github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} \ - github.com/gogo/protobuf/protoc-gen-gogofast@v${GOGO_PROTOBUF_VERSION} \ - github.com/gogo/protobuf/protoc-gen-gogofaster@v${GOGO_PROTOBUF_VERSION} \ - github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} \ - github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION} \ - github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest - -# Install buf -SHELL ["/bin/bash", "-euo", "pipefail", "-c"] - -RUN PREFIX="/usr/local" && \ - VERSION="1.0.0-rc8" && \ - curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m).tar.gz" | \ - tar -xvzf - -C "${PREFIX}" --strip-components 1 - -# Fetch and build app -WORKDIR /app - -RUN git clone --depth 1 --branch v0.5.0 https://github.com/cheqd/cheqd-node - -WORKDIR /app/cheqd-node - -RUN make proto-gen build - - -##### Run container ##### - -FROM debian:buster - -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - nano \ - curl \ - wget \ - netcat - -# Node binary -COPY --from=builder /app/cheqd-node/build/cheqd-noded /bin - -RUN groupadd --system --gid 1000 cheqd && \ - useradd --system --create-home --home-dir /cheqd --shell /bin/bash --gid cheqd --uid 1000 cheqd -RUN chown -R cheqd /cheqd - -WORKDIR /cheqd -USER cheqd - -EXPOSE 26656 26657 -STOPSIGNAL SIGTERM - -# Init network -COPY cheqd_init.sh . -RUN bash cheqd_init.sh - -ENTRYPOINT [ "cheqd-noded", "start" ] diff --git a/tests/e2e-complex/ibc-defi/docker-compose.yaml b/tests/e2e-complex/ibc-defi/docker-compose.yaml index 3718fe646..bc1808be8 100644 --- a/tests/e2e-complex/ibc-defi/docker-compose.yaml +++ b/tests/e2e-complex/ibc-defi/docker-compose.yaml @@ -4,40 +4,41 @@ services: cheqd: image: cheqd build: - context: ../../../ + context: ../../.. dockerfile: docker/Dockerfile target: base - configs: - - source: cheqd-init - target: /home/cheqd/cheqd-init.sh - entrypoint: /home/cheqd/cheqd-init.sh ports: - "26656:26656" # p2p - "26657:26657" # rpc - "9090:9090" # grpc - "9091:9091" # grpc-web + entrypoint: tail -f /dev/null osmosis: image: osmosis build: - context: ./osmosis + context: osmosis dockerfile: osmosis.Dockerfile ports: - "26666:26656" # p2p - "26667:26657" # rpc - "9190:9090" # grpc - "9191:9091" # grpc-web + entrypoint: tail -f /dev/null hermes: image: hermes build: context: ./hermes dockerfile: hermes.Dockerfile + configs: + - source: hermes-config + target: /hermes/.hermes/config.toml ports: - "3000:3000" # rest - "3001:3001" # telemetry entrypoint: tail -f /dev/null configs: - cheqd-init: - file: ./cheqd/cheqd-init.sh + hermes-config: + file: ./hermes/config.toml diff --git a/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile b/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile index 89f8df5af..7bd40b3fd 100644 --- a/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile +++ b/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile @@ -34,21 +34,18 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # Node binary COPY --from=builder /app/ibc-rs/target/release/hermes /bin -# User -RUN groupadd --system --gid 1000 hermes && \ - useradd --system --create-home --home-dir /hermes --shell /bin/bash --gid hermes --uid 1000 hermes +ARG USER=hermes +ARG GROUP=hermes -WORKDIR /hermes +ARG HOME=/home/$USER -# Init -COPY hermes_init.sh . -RUN bash hermes_init.sh +# User +RUN groupadd --system --gid 1000 $USER && \ + useradd --system --create-home --home-dir $HOME --shell /bin/bash --gid $GROUP --uid 1000 $USER -# Config -RUN mkdir .hermes -COPY config.toml .hermes +WORKDIR $HOME -RUN chown -R hermes /hermes -USER hermes +RUN chown -R $USER $HOME +USER $USER ENTRYPOINT [ "hermes" ] diff --git a/tests/e2e-complex/ibc-defi/hermes/hermes_init.sh b/tests/e2e-complex/ibc-defi/hermes/hermes_init.sh deleted file mode 100755 index b34d77f65..000000000 --- a/tests/e2e-complex/ibc-defi/hermes/hermes_init.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -set -euox pipefail diff --git a/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh b/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh index bf154affb..c006c08ec 100755 --- a/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh +++ b/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh @@ -16,7 +16,7 @@ function err() { } function assert_tx_successful() { - RES=$1 + RES="$1" if [[ $(echo "${RES}" | jq --raw-output '.code') == 0 ]] then @@ -27,10 +27,47 @@ function assert_tx_successful() { fi } +function assert_network_running() { + RES="$1" + LATEST_HEIGHT=$(echo "${RES}" | jq --raw-output '.SyncInfo.latest_block_height') + info "latest height: ${LATEST_HEIGHT}" + + if [[ $LATEST_HEIGHT -gt 1 ]] + then + info "network is running" + else + err "network is not running" + exit 1 + fi +} + + +info "Cleanup" +docker-compose down --volumes --remove-orphans + +info "Running cheqd network" +docker-compose up -d cheqd +docker-compose cp cheqd/cheqd-init.sh cheqd:/home/cheqd/cheqd-init.sh +docker-compose exec cheqd bash /home/cheqd/cheqd-init.sh +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 exec -d osmosis osmosisd start + +info "Waiting for chains" +# TODO: Get rid of this +sleep 10 + +info "Checking statuses" +CHEQD_STATUS=$(docker-compose exec cheqd cheqd-noded status 2>&1) +assert_network_running "${CHEQD_STATUS}" + +OSMOSIS_STATUS=$(docker-compose exec osmosis osmosisd status 2>&1) +assert_network_running "${OSMOSIS_STATUS}" -info "Run docker" # --- -docker-compose up --detach --build --force-recreate --remove-orphans -sleep 15 # Wait for chains info "Create relayer user on cheqd" # --- CHEQD_RELAYER_KEY_NAME="cheqd-relayer" @@ -53,7 +90,9 @@ RES=$(docker-compose exec osmosis osmosisd tx bank send osmosis-user "${OSMOSIS_ assert_tx_successful "${RES}" sleep 10 # Wait for state + info "Import accounts in hermes" # --- +docker-compose up -d hermes docker-compose exec hermes hermes keys restore cheqd --mnemonic "$CHEQD_RELAYER_MNEMONIC" --name cheqd-key docker-compose exec hermes hermes keys restore osmosis --mnemonic "$OSMOSIS_RELAYER_MNEMONIC" --name osmosis-key diff --git a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile index 7304f1bfe..b0a21b4c1 100644 --- a/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile +++ b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile @@ -1,29 +1,3 @@ -##### Build container ##### - -# Taken from: https://github.com/osmosis-labs/osmosis/blob/v10.0.1/Dockerfile -FROM golang:1.18.2-alpine3.15 as build - -RUN set -eux; apk add --no-cache ca-certificates build-base; -RUN apk add git -# Needed by github.com/zondax/hid -RUN apk add linux-headers - -WORKDIR / -RUN git clone --depth 1 --branch v8.0.0 https://github.com/osmosis-labs/osmosis -WORKDIR /osmosis - -# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a - -# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` -RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a - -RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build - - -##### Run container ##### - FROM debian:buster RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ @@ -34,20 +8,21 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ netcat # Node binary -COPY --from=build /osmosis/build/osmosisd /bin/osmosisd +COPY --from=osmolabs/osmosis:10 /bin/osmosisd /bin/osmosisd + +ARG USER=osmosis +ARG GROUP=osmosis + +ARG HOME=/home/$USER -RUN groupadd --system --gid 1000 osmosis && \ - useradd --system --create-home --home-dir /osmosis --shell /bin/bash --gid osmosis --uid 1000 osmosis -RUN chown -R osmosis /osmosis +# User +RUN groupadd --system --gid 1000 $USER && \ + useradd --system --create-home --home-dir $HOME --shell /bin/bash --gid $GROUP --uid 1000 $USER -WORKDIR /osmosis -USER osmosis +WORKDIR $HOME -EXPOSE 26656 26657 -STOPSIGNAL SIGTERM +RUN chown -R $USER $HOME +USER $USER -# Init network -COPY osmosis_init.sh . -RUN bash osmosis_init.sh ENTRYPOINT [ "osmosisd", "start" ] From e5fedcfd8a47a0a2891361a1c6ff8679b17e423d Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Mon, 4 Jul 2022 16:20:53 +0300 Subject: [PATCH 15/15] Supress DL3022 --- .github/linters/.hadolint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/linters/.hadolint.yml b/.github/linters/.hadolint.yml index 19159d3c5..0d2c353e2 100644 --- a/.github/linters/.hadolint.yml +++ b/.github/linters/.hadolint.yml @@ -13,4 +13,5 @@ override: - DL3008 - DL3027 - DL3018 + - DL3022 style: