Skip to content

Commit

Permalink
chore: bump ics to v4.2.0-lsm-rc0 (#3089)
Browse files Browse the repository at this point in the history
* chore: bump ics to v4.2.0-lsm-rc0

* disable unused test

* deps!: add provider to transferstack

* rename ibcprovider -> icsprovider

* add comment on transferstack

* fix!: mv provider middlewares up the stack

* tests: add extra gas on unbond (due to LSM)
  • Loading branch information
MSalopek authored May 2, 2024
1 parent 07c1fe9 commit 0a16a03
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 111 deletions.
27 changes: 15 additions & 12 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcprovider "github.com/cosmos/interchain-security/v4/x/ccv/provider"
ibcproviderkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper"
icsprovider "github.com/cosmos/interchain-security/v4/x/ccv/provider"
icsproviderkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper"
providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -110,7 +110,7 @@ type AppKeepers struct {
ConsensusParamsKeeper consensusparamkeeper.Keeper

// ICS
ProviderKeeper ibcproviderkeeper.Keeper
ProviderKeeper icsproviderkeeper.Keeper

PFMRouterKeeper *pfmrouterkeeper.Keeper
RatelimitKeeper ratelimitkeeper.Keeper
Expand All @@ -121,14 +121,14 @@ type AppKeepers struct {
TransferModule transfer.AppModule
PFMRouterModule pfmrouter.AppModule
RateLimitModule ratelimit.AppModule
ProviderModule ibcprovider.AppModule
ProviderModule icsprovider.AppModule

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedIBCProviderKeeper capabilitykeeper.ScopedKeeper
ScopedICSproviderkeeper capabilitykeeper.ScopedKeeper
}

func NewAppKeeper(
Expand Down Expand Up @@ -186,7 +186,7 @@ func NewAppKeeper(
appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
appKeepers.ScopedICAControllerKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
appKeepers.ScopedIBCProviderKeeper = appKeepers.CapabilityKeeper.ScopeToModule(providertypes.ModuleName)
appKeepers.ScopedICSproviderkeeper = appKeepers.CapabilityKeeper.ScopeToModule(providertypes.ModuleName)

// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
// their scoped modules in `NewApp` with `ScopeToModule`
Expand Down Expand Up @@ -312,11 +312,11 @@ func NewAppKeeper(
govConfig,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
appKeepers.ProviderKeeper = ibcproviderkeeper.NewKeeper(
appKeepers.ProviderKeeper = icsproviderkeeper.NewKeeper(
appCodec,
appKeepers.keys[providertypes.StoreKey],
appKeepers.GetSubspace(providertypes.ModuleName),
appKeepers.ScopedIBCProviderKeeper,
appKeepers.ScopedICSproviderkeeper,
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.IBCKeeper.ConnectionKeeper,
Expand All @@ -330,7 +330,7 @@ func NewAppKeeper(
authtypes.FeeCollectorName,
)

appKeepers.ProviderModule = ibcprovider.NewAppModule(&appKeepers.ProviderKeeper, appKeepers.GetSubspace(providertypes.ModuleName))
appKeepers.ProviderModule = icsprovider.NewAppModule(&appKeepers.ProviderKeeper, appKeepers.GetSubspace(providertypes.ModuleName))

// Register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
Expand All @@ -342,7 +342,7 @@ func NewAppKeeper(
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)).
AddRoute(providertypes.RouterKey, ibcprovider.NewProviderProposalHandler(appKeepers.ProviderKeeper))
AddRoute(providertypes.RouterKey, icsprovider.NewProviderProposalHandler(appKeepers.ProviderKeeper))

// Set legacy router for backwards compatibility with gov v1beta1
appKeepers.GovKeeper.SetLegacyRouter(govRouter)
Expand Down Expand Up @@ -445,13 +445,16 @@ func NewAppKeeper(
// - ibcfee
// - ratelimit
// - pfm
// - provider
// - transfer
//
// This is how transfer stack will work in the end:
// * RecvPacket -> IBC core -> Fee -> RateLimit -> PFM -> Transfer (AddRoute)
// * SendPacket -> Transfer -> PFM -> RateLimit -> Fee -> IBC core (ICS4Wrapper)
// * RecvPacket -> IBC core -> Fee -> RateLimit -> PFM -> Provider -> Transfer (AddRoute)
// * SendPacket -> Transfer -> Provider -> PFM -> RateLimit -> Fee -> IBC core (ICS4Wrapper)

var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(appKeepers.TransferKeeper)
transferStack = icsprovider.NewIBCMiddleware(transferStack, appKeepers.ProviderKeeper)
transferStack = pfmrouter.NewIBCMiddleware(
transferStack,
appKeepers.PFMRouterKeeper,
Expand Down
29 changes: 16 additions & 13 deletions app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,26 @@ func AddRateLimits(ctx sdk.Context, k ratelimitkeeper.Keeper) error {
return nil
}

// NOTE: This is commented out because the valset is already initialized and the function has no effect
// ComputeNextEpochConsumerValSet was removed and build was broken
// code is kept here for reference
func InitICSEpochs(ctx sdk.Context, pk providerkeeper.Keeper, sk stakingkeeper.Keeper) error {
ctx.Logger().Info("Initializing ICS epochs...")

// get the bonded validators from the staking module
bondedValidators := sk.GetLastValidators(ctx)

for _, chain := range pk.GetAllConsumerChains(ctx) {
chainID := chain.ChainId
valset := pk.GetConsumerValSet(ctx, chainID)
if len(valset) > 0 {
ctx.Logger().Info("consumer chain `%s` already has the valset initialized", chainID)
} else {
// init valset for consumer with chainID
nextValidators := pk.ComputeNextEpochConsumerValSet(ctx, chainID, bondedValidators)
pk.SetConsumerValSet(ctx, chainID, nextValidators)
}
}
// _ = sk.GetLastValidators(ctx)

// for _, chain := range pk.GetAllConsumerChains(ctx) {
// chainID := chain.ChainId
// valset := pk.GetConsumerValSet(ctx, chainID)
// if len(valset) > 0 {
// ctx.Logger().Info("consumer chain `%s` already has the valset initialized", chainID)
// } else {
// // init valset for consumer with chainID
// nextValidators := pk.ComputeNextEpochConsumerValSet(ctx, chainID, bondedValidators)
// pk.SetConsumerValSet(ctx, chainID, nextValidators)
// }
// }

ctx.Logger().Info("Finished initializing ICS epochs")
return nil
Expand Down
34 changes: 0 additions & 34 deletions app/upgrades/v16/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,3 @@ func TestAddRateLimits(t *testing.T) {
require.Equal(t, expectedRateLimit, rateLimit)
}
}

func TestInitICSEpochs(t *testing.T) {
gaiaApp := helpers.Setup(t)
ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{})

providerKeeper := gaiaApp.ProviderKeeper
stakingKeeper := gaiaApp.StakingKeeper

// the setup has only one validator that is bonded
expBondedVals := stakingKeeper.GetAllValidators(ctx)
require.Equal(t, 1, len(expBondedVals))
expVal := expBondedVals[0]
expPower := expVal.ConsensusPower(stakingKeeper.PowerReduction(ctx))
expConsAddr, err := expVal.GetConsAddr()
require.NoError(t, err)
expConsumerPublicKey, err := expVal.TmConsPublicKey()
require.NoError(t, err)

providerKeeper.SetConsumerClientId(ctx, "chainID-0", "clientID-0")
providerKeeper.SetConsumerClientId(ctx, "chainID-1", "clientID-1")

err = v16.InitICSEpochs(ctx, providerKeeper, *stakingKeeper)
require.NoError(t, err)

for _, chain := range providerKeeper.GetAllConsumerChains(ctx) {
chainID := chain.ChainId
valset := providerKeeper.GetConsumerValSet(ctx, chainID)
require.Equal(t, 1, len(valset))
val := valset[0]
require.Equal(t, expPower, val.Power)
require.Equal(t, expConsAddr.Bytes(), val.ProviderConsAddr)
require.Equal(t, expConsumerPublicKey, *val.ConsumerPublicKey)
}
}
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3
github.com/cosmos/ibc-go/v7 v7.4.0
github.com/cosmos/interchain-security/v4 v4.1.1
github.com/cosmos/interchain-security/v4 v4.2.0
github.com/google/gofuzz v1.2.0
github.com/gorilla/mux v1.8.1
github.com/ory/dockertest/v3 v3.10.0
Expand All @@ -26,20 +26,20 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de
)

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.36.0 // indirect
github.com/golang/protobuf v1.5.4
// github.com/gravity-devs/liquidity v1.6.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2
)

require (
Expand Down Expand Up @@ -100,7 +100,7 @@ require (
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
Expand All @@ -125,7 +125,7 @@ require (
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.1 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
Expand Down Expand Up @@ -192,28 +192,28 @@ require (
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/mock v0.2.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/api v0.155.0 // indirect
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -231,7 +231,7 @@ replace (
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.47.13-ics-lsm

// Use special ICS v4.1.0-ics-lsm release with support for LSM
github.com/cosmos/interchain-security/v4 => github.com/cosmos/interchain-security/v4 v4.1.1-lsm
github.com/cosmos/interchain-security/v4 => github.com/cosmos/interchain-security/v4 v4.2.0-lsm-rc0

// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
Expand Down
Loading

0 comments on commit 0a16a03

Please sign in to comment.