From 19aa1234eff305cfc079ef8680c3a9a6a47e2941 Mon Sep 17 00:00:00 2001 From: insumity Date: Fri, 27 Sep 2024 14:18:11 +0200 Subject: [PATCH 01/10] init commit --- app/upgrades/v21/constants.go | 15 ++++ app/upgrades/v21/upgrades.go | 132 ++++++++++++++++++++++++++++++++++ go.mod | 5 +- go.sum | 10 ++- 4 files changed, 154 insertions(+), 8 deletions(-) create mode 100644 app/upgrades/v21/constants.go create mode 100644 app/upgrades/v21/upgrades.go diff --git a/app/upgrades/v21/constants.go b/app/upgrades/v21/constants.go new file mode 100644 index 00000000000..ca58423d985 --- /dev/null +++ b/app/upgrades/v21/constants.go @@ -0,0 +1,15 @@ +package v21 + +import ( + "github.com/cosmos/gaia/v20/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name. + UpgradeName = "v21" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, +} diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go new file mode 100644 index 00000000000..356c6d83b45 --- /dev/null +++ b/app/upgrades/v21/upgrades.go @@ -0,0 +1,132 @@ +package v21 + +import ( + "context" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + upgradetypes "cosmossdk.io/x/upgrade/types" + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/cosmos/gaia/v20/app/keepers" + providerkeeper "github.com/cosmos/interchain-security/v6/x/ccv/provider/keeper" + types2 "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" +) + +// Neutron and Stride denoms that were not whitelisted but the consumer rewards pool contains amounts of those denoms. +// Price in $ for each denom corresponds to an approximation fo the current amount stored in the consumer rewards pool +// as of 27.09.2024. Only denoms with amounts more than $10 are included. +const ( + NeutronUusdc = "ibc/4E0D0854C0F846150FA8389D75EA5B5129B17703D7F4992D0356B4FE7C013D42" // ~$40 + NeutronUtia = "ibc/7054742D02E4F28B7DB5B44D97A496CF5AD16C2AE6948028A5FD57DCE7C5E271" // ~$300 + + StrideStutia = "ibc/17DABEBAC71C388DA064A3D54FB7E68BAF0687965EC39DEADA1FB78C0F1447E6" // ~$18,000 + StrideStadym = "ibc/3F0A41ECB6FAF27E315583DBF39B5B69A7149D23959A0E4B319F7EF5C618DCD7" // ~$800 + StrideStaISLM = "ibc/61A6F21D6AFF9835F66056461F1CAE24AA3323820259856B485FE7C063CA4FA6" // ~$1650 + StrideStuband = "ibc/E9401AC885592AC2023E0FB9BA7C8BC66D346CEE04CED8E9F545F3C25290708A" // ~$300 + StrideStadydx = "ibc/EEFD952A6DE346F2649039E99A16430B05FFEDF628A4DE99F34BB4B5F6A9346E" // ~$21,000 + StrideStusaga = "ibc/F918765AC289257B35DECC52BD92EBCDBA3C139658BD6F2670D70A6E10B97F58" // ~$300 +) + +// CreateUpgradeHandler returns an upgrade handler for Gaia v21. +// It performs module migrations, as well as the following tasks: +// - Initializes the MaxProviderConsensusValidators parameter in the provider module to 180. +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(c context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx := sdk.UnwrapSDKContext(c) + ctx.Logger().Info("Starting module migrations...") + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, errorsmod.Wrapf(err, "running module migrations") + } + + ctx.Logger().Info("distributing rewards of Neutron and Stride unaccounted denoms") + err = DistributeNeutronAndStrideUnaccountedDenoms(ctx, keepers.ProviderKeeper, keepers.BankKeeper, keepers.AccountKeeper) + if err != nil { + return vm, errorsmod.Wrapf(err, "could not distribute rewards of Neutron and Stride unaccounted denoms") + } + + ctx.Logger().Info("Upgrade v21 complete") + return vm, nil + } +} + +// DistributeDenoms distributes all the `denoms` that reside in the `address` and are meant for the chain with `consumerId` +func DistributeDenoms(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, address sdk.AccAddress, consumerId string, denoms []string) error { + for _, denom := range denoms { + coinRewards := bankKeeper.GetBalance(ctx, address, denom) + decCoinRewards := sdk.DecCoins{sdk.DecCoin{Denom: coinRewards.Denom, Amount: math.LegacyNewDecFromInt(coinRewards.Amount)}} + consumerRewardsAllocation := types2.ConsumerRewardsAllocation{Rewards: decCoinRewards} + + isDenomAllowlisted := providerKeeper.ConsumerRewardDenomExists(ctx, denom) + + // allowlist the denom that distribution can take place + providerKeeper.SetConsumerRewardDenom(ctx, denom) + + err := providerKeeper.SetConsumerRewardsAllocationByDenom(ctx, consumerId, denom, consumerRewardsAllocation) + if err != nil { + return err + } + + // call `BeginBlockRD` to actually perform the distribution + providerKeeper.BeginBlockRD(ctx) + + // if you were not allowlisted before, revert to initial state + if !isDenomAllowlisted { + providerKeeper.DeleteConsumerRewardDenom(ctx, denom) + } + } + return nil +} + +// HasExpectedChainIdSanityCheck return true if the chain with the provided `consumerId` is of a chain with the `expectedChainId` +func HasExpectedChainIdSanityCheck(ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerId string, expectedChainId string) bool { + actualChainId, err := providerKeeper.GetConsumerChainId(ctx, consumerId) + if err != nil { + return false + } + if expectedChainId != actualChainId { + return false + } + return true +} + +// DistributeNeutronAndStrideUnaccountedDenoms distributed previously unaccounted denoms to the Stride and Neutron consumer chains +func DistributeNeutronAndStrideUnaccountedDenoms(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, accountKeeper authkeeper.AccountKeeper) error { + consumerRewardsPoolAddress := accountKeeper.GetModuleAccount(ctx, types2.ConsumerRewardsPool).GetAddress() + + const NeutronConsumerId = "0" + const NeutronChainId = "neutron-1" + + if !HasExpectedChainIdSanityCheck(ctx, providerKeeper, NeutronConsumerId, NeutronChainId) { + return fmt.Errorf("failed sanity check: consumer id (%s) does not correspond to chain id (%s)", NeutronConsumerId, NeutronChainId) + } + + neutronUnaccountedDenoms := []string{NeutronUusdc, NeutronUtia} + err := DistributeDenoms(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, NeutronConsumerId, neutronUnaccountedDenoms) + if err != nil { + return fmt.Errorf("cannot distribute rewards for consumer id (%s): %w", NeutronConsumerId, err) + } + + const StrideConsumerId = "1" + const StrideChainId = "stride-1" + + if !HasExpectedChainIdSanityCheck(ctx, providerKeeper, StrideConsumerId, StrideChainId) { + return fmt.Errorf("failed sanity check: consumer id (%s) does not correspond to chain id (%s)", StrideConsumerId, StrideChainId) + } + + strideUnaccountedDenoms := []string{StrideStutia, StrideStadym, StrideStaISLM, StrideStuband, StrideStadydx, StrideStusaga} + err = DistributeDenoms(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, StrideConsumerId, strideUnaccountedDenoms) + if err != nil { + return fmt.Errorf("cannot distribute rewards for consumer id (%s): %w", StrideConsumerId, err) + } + + return nil +} diff --git a/go.mod b/go.mod index c968d51d8d1..d6a752696a8 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( cosmossdk.io/tools/rosetta v0.2.1-0.20230613133644-0a778132a60f cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 - cosmossdk.io/x/tx v0.13.5 + cosmossdk.io/x/tx v0.13.4 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmd v0.53.0 github.com/cometbft/cometbft v0.38.11 @@ -32,7 +32,7 @@ require ( github.com/google/gofuzz v1.2.0 github.com/gorilla/mux v1.8.1 github.com/ory/dockertest/v3 v3.11.0 - github.com/prometheus/client_golang v1.20.4 + github.com/prometheus/client_golang v1.20.2 github.com/rakyll/statik v0.1.7 github.com/skip-mev/feemarket v1.1.1 github.com/spf13/cast v1.7.0 @@ -250,6 +250,7 @@ replace ( // Use special SDK v0.50.x release with support for both ICS and LSM github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.9-lsm + github.com/cosmos/interchain-security/v6 => /Users/karolos/interchain-security // 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 diff --git a/go.sum b/go.sum index 37ad3e61794..7253c99afcf 100644 --- a/go.sum +++ b/go.sum @@ -220,8 +220,8 @@ cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= cosmossdk.io/x/nft v0.1.1 h1:pslAVS8P5NkW080+LWOamInjDcq+v2GSCo+BjN9sxZ8= cosmossdk.io/x/nft v0.1.1/go.mod h1:Kac6F6y2gsKvoxU+fy8uvxRTi4BIhLOor2zgCNQwVgY= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/x/tx v0.13.4 h1:Eg0PbJgeO0gM8p5wx6xa0fKR7hIV6+8lC56UrsvSo0Y= +cosmossdk.io/x/tx v0.13.4/go.mod h1:BkFqrnGGgW50Y6cwTy+JvgAhiffbGEKW6KF9ufcDpvk= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= @@ -443,8 +443,6 @@ github.com/cosmos/ibc-go/v8 v8.5.1 h1:3JleEMKBjRKa3FeTKt4fjg22za/qygLBo7mDkoYTNB github.com/cosmos/ibc-go/v8 v8.5.1/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= -github.com/cosmos/interchain-security/v6 v6.1.0 h1:ycTpT+If90nSEvRVu86ThPJxNtcmnOMjJmFC9ptd/yo= -github.com/cosmos/interchain-security/v6 v6.1.0/go.mod h1:+5zIZEzkL4yNHB/UWXCu75t6GeEgEmWHbz5OnBWiL0o= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= @@ -1122,8 +1120,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= -github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= +github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= From dfa7b077ca9375379f690e7402dfc77947d94342 Mon Sep 17 00:00:00 2001 From: insumity Date: Thu, 3 Oct 2024 10:59:58 +0200 Subject: [PATCH 02/10] Update app/upgrades/v21/upgrades.go Co-authored-by: Simon Noetzlin --- app/upgrades/v21/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index 071207a3fd2..92b51c4c62b 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -13,7 +13,7 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/gaia/v21/app/keepers" providerkeeper "github.com/cosmos/interchain-security/v6/x/ccv/provider/keeper" - types2 "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" ) // Neutron and Stride denoms that were not whitelisted but the consumer rewards pool contains amounts of those denoms. From db07de6b75b80f3685231a53b4b764f2bc16e510 Mon Sep 17 00:00:00 2001 From: insumity Date: Thu, 3 Oct 2024 11:07:14 +0200 Subject: [PATCH 03/10] took into account comments --- app/upgrades/v21/upgrades.go | 45 +++++++++++-------------------- app/upgrades/v21/upgrades_test.go | 26 ++++++++++++++++++ go.mod | 5 ++-- go.sum | 10 ++++--- 4 files changed, 49 insertions(+), 37 deletions(-) create mode 100644 app/upgrades/v21/upgrades_test.go diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index 92b51c4c62b..6d8d79dd172 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -3,6 +3,7 @@ package v21 import ( "context" "fmt" + providertypes "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -13,7 +14,6 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/gaia/v21/app/keepers" providerkeeper "github.com/cosmos/interchain-security/v6/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" ) // Neutron and Stride denoms that were not whitelisted but the consumer rewards pool contains amounts of those denoms. @@ -32,8 +32,6 @@ const ( ) // CreateUpgradeHandler returns an upgrade handler for Gaia v21. -// It performs module migrations, as well as the following tasks: -// - Initializes the MaxProviderConsensusValidators parameter in the provider module to 180. func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, @@ -48,10 +46,10 @@ func CreateUpgradeHandler( return vm, errorsmod.Wrapf(err, "running module migrations") } - ctx.Logger().Info("distributing rewards of Neutron and Stride unaccounted denoms") - err = DistributeNeutronAndStrideUnaccountedDenoms(ctx, keepers.ProviderKeeper, keepers.BankKeeper, keepers.AccountKeeper) + ctx.Logger().Info("allocating rewards of Neutron and Stride unaccounted denoms") + err = AllocateNeutronAndStrideUnaccountedDenoms(ctx, keepers.ProviderKeeper, keepers.BankKeeper, keepers.AccountKeeper) if err != nil { - return vm, errorsmod.Wrapf(err, "could not distribute rewards of Neutron and Stride unaccounted denoms") + return vm, errorsmod.Wrapf(err, "could not allocate rewards of Neutron and Stride unaccounted denoms") } ctx.Logger().Info("Upgrade v21 complete") @@ -59,35 +57,22 @@ func CreateUpgradeHandler( } } -// DistributeDenoms distributes all the `denoms` that reside in the `address` and are meant for the chain with `consumerId` -func DistributeDenoms(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, address sdk.AccAddress, consumerId string, denoms []string) error { +// AllocateRewards allocates all the `denoms` that reside in the `address` and are meant for the chain with `consumerId` +func AllocateRewards(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, address sdk.AccAddress, consumerId string, denoms []string) error { for _, denom := range denoms { coinRewards := bankKeeper.GetBalance(ctx, address, denom) decCoinRewards := sdk.DecCoins{sdk.DecCoin{Denom: coinRewards.Denom, Amount: math.LegacyNewDecFromInt(coinRewards.Amount)}} - consumerRewardsAllocation := types2.ConsumerRewardsAllocation{Rewards: decCoinRewards} - - isDenomAllowlisted := providerKeeper.ConsumerRewardDenomExists(ctx, denom) - - // allowlist the denom that distribution can take place - providerKeeper.SetConsumerRewardDenom(ctx, denom) + consumerRewardsAllocation := providertypes.ConsumerRewardsAllocation{Rewards: decCoinRewards} err := providerKeeper.SetConsumerRewardsAllocationByDenom(ctx, consumerId, denom, consumerRewardsAllocation) if err != nil { return err } - - // call `BeginBlockRD` to actually perform the distribution - providerKeeper.BeginBlockRD(ctx) - - // if you were not allowlisted before, revert to initial state - if !isDenomAllowlisted { - providerKeeper.DeleteConsumerRewardDenom(ctx, denom) - } } return nil } -// HasExpectedChainIdSanityCheck return true if the chain with the provided `consumerId` is of a chain with the `expectedChainId` +// HasExpectedChainIdSanityCheck returns true if the chain with the provided `consumerId` is of a chain with the `expectedChainId` func HasExpectedChainIdSanityCheck(ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerId string, expectedChainId string) bool { actualChainId, err := providerKeeper.GetConsumerChainId(ctx, consumerId) if err != nil { @@ -99,9 +84,9 @@ func HasExpectedChainIdSanityCheck(ctx sdk.Context, providerKeeper providerkeepe return true } -// DistributeNeutronAndStrideUnaccountedDenoms distributed previously unaccounted denoms to the Stride and Neutron consumer chains -func DistributeNeutronAndStrideUnaccountedDenoms(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, accountKeeper authkeeper.AccountKeeper) error { - consumerRewardsPoolAddress := accountKeeper.GetModuleAccount(ctx, types2.ConsumerRewardsPool).GetAddress() +// AllocateNeutronAndStrideUnaccountedDenoms allocates previously unaccounted denoms to the Stride and Neutron consumer chains +func AllocateNeutronAndStrideUnaccountedDenoms(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, accountKeeper authkeeper.AccountKeeper) error { + consumerRewardsPoolAddress := accountKeeper.GetModuleAccount(ctx, providertypes.ConsumerRewardsPool).GetAddress() const NeutronConsumerId = "0" const NeutronChainId = "neutron-1" @@ -111,9 +96,9 @@ func DistributeNeutronAndStrideUnaccountedDenoms(ctx sdk.Context, providerKeeper } neutronUnaccountedDenoms := []string{NeutronUusdc, NeutronUtia} - err := DistributeDenoms(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, NeutronConsumerId, neutronUnaccountedDenoms) + err := AllocateRewards(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, NeutronConsumerId, neutronUnaccountedDenoms) if err != nil { - return fmt.Errorf("cannot distribute rewards for consumer id (%s): %w", NeutronConsumerId, err) + return fmt.Errorf("cannot allocate rewards for consumer id (%s): %w", NeutronConsumerId, err) } const StrideConsumerId = "1" @@ -124,9 +109,9 @@ func DistributeNeutronAndStrideUnaccountedDenoms(ctx sdk.Context, providerKeeper } strideUnaccountedDenoms := []string{StrideStutia, StrideStadym, StrideStaISLM, StrideStuband, StrideStadydx, StrideStusaga} - err = DistributeDenoms(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, StrideConsumerId, strideUnaccountedDenoms) + err = AllocateRewards(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, StrideConsumerId, strideUnaccountedDenoms) if err != nil { - return fmt.Errorf("cannot distribute rewards for consumer id (%s): %w", StrideConsumerId, err) + return fmt.Errorf("cannot allocate rewards for consumer id (%s): %w", StrideConsumerId, err) } return nil diff --git a/app/upgrades/v21/upgrades_test.go b/app/upgrades/v21/upgrades_test.go new file mode 100644 index 00000000000..4de485ff31e --- /dev/null +++ b/app/upgrades/v21/upgrades_test.go @@ -0,0 +1,26 @@ +package v21 + +import ( + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/gaia/v21/app/helpers" + "github.com/stretchr/testify/require" + "testing" +) + +func TestHasExpectedChainIdSanityCheck(t *testing.T) { + gaiaApp := helpers.Setup(t) + ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{}) + + pk := gaiaApp.ProviderKeeper + + // no such consumer chain + consumerId := "0" + require.False(t, HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + + // consumer chain does not have `chain-1` id + pk.SetConsumerChainId(ctx, consumerId, "chain-2") + require.False(t, HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + + pk.SetConsumerChainId(ctx, consumerId, "chain-1") + require.True(t, HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) +} diff --git a/go.mod b/go.mod index b3c34fd48ab..897fd23cf20 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( cosmossdk.io/tools/rosetta v0.2.1-0.20230613133644-0a778132a60f cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 - cosmossdk.io/x/tx v0.13.4 + cosmossdk.io/x/tx v0.13.5 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmd v0.53.0 github.com/cometbft/cometbft v0.38.11 @@ -32,7 +32,7 @@ require ( github.com/google/gofuzz v1.2.0 github.com/gorilla/mux v1.8.1 github.com/ory/dockertest/v3 v3.11.0 - github.com/prometheus/client_golang v1.20.2 + github.com/prometheus/client_golang v1.20.4 github.com/rakyll/statik v0.1.7 github.com/skip-mev/feemarket v1.1.1 github.com/spf13/cast v1.7.0 @@ -250,7 +250,6 @@ replace ( // Use special SDK v0.50.x release with support for both ICS and LSM github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.9-lsm - github.com/cosmos/interchain-security/v6 => /Users/karolos/interchain-security // 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 diff --git a/go.sum b/go.sum index f9c11417d68..92fff64ada3 100644 --- a/go.sum +++ b/go.sum @@ -220,8 +220,8 @@ cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= cosmossdk.io/x/nft v0.1.1 h1:pslAVS8P5NkW080+LWOamInjDcq+v2GSCo+BjN9sxZ8= cosmossdk.io/x/nft v0.1.1/go.mod h1:Kac6F6y2gsKvoxU+fy8uvxRTi4BIhLOor2zgCNQwVgY= -cosmossdk.io/x/tx v0.13.4 h1:Eg0PbJgeO0gM8p5wx6xa0fKR7hIV6+8lC56UrsvSo0Y= -cosmossdk.io/x/tx v0.13.4/go.mod h1:BkFqrnGGgW50Y6cwTy+JvgAhiffbGEKW6KF9ufcDpvk= +cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= +cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= @@ -443,6 +443,8 @@ github.com/cosmos/ibc-go/v8 v8.5.1 h1:3JleEMKBjRKa3FeTKt4fjg22za/qygLBo7mDkoYTNB github.com/cosmos/ibc-go/v8 v8.5.1/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= +github.com/cosmos/interchain-security/v6 v6.1.0 h1:ycTpT+If90nSEvRVu86ThPJxNtcmnOMjJmFC9ptd/yo= +github.com/cosmos/interchain-security/v6 v6.1.0/go.mod h1:+5zIZEzkL4yNHB/UWXCu75t6GeEgEmWHbz5OnBWiL0o= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= @@ -1120,8 +1122,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= -github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= From c506a7a0af01487bc73a4e29ad81b775c9b11552 Mon Sep 17 00:00:00 2001 From: mpoke Date: Thu, 3 Oct 2024 11:37:10 +0200 Subject: [PATCH 04/10] bump ICS --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 897fd23cf20..ee407907ede 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/cosmos/ibc-go/v8 v8.5.1 - github.com/cosmos/interchain-security/v6 v6.1.0 + github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157 github.com/google/gofuzz v1.2.0 github.com/gorilla/mux v1.8.1 github.com/ory/dockertest/v3 v3.11.0 diff --git a/go.sum b/go.sum index 92fff64ada3..35d5f3c795f 100644 --- a/go.sum +++ b/go.sum @@ -443,6 +443,8 @@ github.com/cosmos/ibc-go/v8 v8.5.1 h1:3JleEMKBjRKa3FeTKt4fjg22za/qygLBo7mDkoYTNB github.com/cosmos/ibc-go/v8 v8.5.1/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= +github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157 h1:KzH6KYAF3+psJ7KJKQihuY0oXL3NSgfS5VPAN525bZ8= +github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157/go.mod h1:8Ke3cbEBBMImBkWPfF1bxPFg5ZqYOxZPjpnh0ItxQMQ= github.com/cosmos/interchain-security/v6 v6.1.0 h1:ycTpT+If90nSEvRVu86ThPJxNtcmnOMjJmFC9ptd/yo= github.com/cosmos/interchain-security/v6 v6.1.0/go.mod h1:+5zIZEzkL4yNHB/UWXCu75t6GeEgEmWHbz5OnBWiL0o= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= From 0bc69c9a0c4e8fd1b5a8bb663c68217b68fe9f2d Mon Sep 17 00:00:00 2001 From: insumity Date: Thu, 3 Oct 2024 11:56:02 +0200 Subject: [PATCH 05/10] took into account comments --- app/upgrades/v21/upgrades_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/upgrades/v21/upgrades_test.go b/app/upgrades/v21/upgrades_test.go index 4de485ff31e..60d04575f3a 100644 --- a/app/upgrades/v21/upgrades_test.go +++ b/app/upgrades/v21/upgrades_test.go @@ -1,8 +1,10 @@ -package v21 +package v21_test import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/gaia/v21/app/helpers" + + v21 "github.com/cosmos/gaia/v21/app/upgrades/v21" "github.com/stretchr/testify/require" "testing" ) @@ -15,12 +17,12 @@ func TestHasExpectedChainIdSanityCheck(t *testing.T) { // no such consumer chain consumerId := "0" - require.False(t, HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + require.False(t, v21.HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) // consumer chain does not have `chain-1` id pk.SetConsumerChainId(ctx, consumerId, "chain-2") - require.False(t, HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + require.False(t, v21.HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) pk.SetConsumerChainId(ctx, consumerId, "chain-1") - require.True(t, HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + require.True(t, v21.HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) } From ef9565d05272cbe7cd21e221f1c7404acf751e3a Mon Sep 17 00:00:00 2001 From: mpoke Date: Thu, 3 Oct 2024 12:02:45 +0200 Subject: [PATCH 06/10] run make format --- app/upgrades/v21/upgrades.go | 1 + app/upgrades/v21/upgrades_test.go | 3 ++- tests/interchain/cosmwasm_test.go | 1 - tests/interchain/permissionless_test.go | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index 6d8d79dd172..574594a40b1 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -3,6 +3,7 @@ package v21 import ( "context" "fmt" + providertypes "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" errorsmod "cosmossdk.io/errors" diff --git a/app/upgrades/v21/upgrades_test.go b/app/upgrades/v21/upgrades_test.go index 60d04575f3a..06c94d3c34e 100644 --- a/app/upgrades/v21/upgrades_test.go +++ b/app/upgrades/v21/upgrades_test.go @@ -1,12 +1,13 @@ package v21_test import ( + "testing" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/gaia/v21/app/helpers" v21 "github.com/cosmos/gaia/v21/app/upgrades/v21" "github.com/stretchr/testify/require" - "testing" ) func TestHasExpectedChainIdSanityCheck(t *testing.T) { diff --git a/tests/interchain/cosmwasm_test.go b/tests/interchain/cosmwasm_test.go index 9d3bbb76af7..fa0d8fbf776 100644 --- a/tests/interchain/cosmwasm_test.go +++ b/tests/interchain/cosmwasm_test.go @@ -80,7 +80,6 @@ func (s *CosmWasmSuite) TestCantInstantiateWithoutProp() { } func (s *CosmWasmSuite) TestCreateNewContract() { - _, contractAddr := s.storeInstantiateProposal(initState) count := s.getContractCount(contractAddr) diff --git a/tests/interchain/permissionless_test.go b/tests/interchain/permissionless_test.go index 4087cfcd361..948177436d2 100644 --- a/tests/interchain/permissionless_test.go +++ b/tests/interchain/permissionless_test.go @@ -360,8 +360,8 @@ func (s *PermissionlessConsumersSuite) TestChangePowerShaping() { s.Require().NoError(err) s.Require().Equal(consumer.ValidatorWallets[i].ValConsAddress, valCons) } - } + func (s *PermissionlessConsumersSuite) TestConsumerCommissionRate() { s.UpgradeChain() cfg := s.consumerCfg From 04bfb680982372d163c9bf9652113cb8a2277e9b Mon Sep 17 00:00:00 2001 From: mpoke Date: Thu, 3 Oct 2024 12:10:03 +0200 Subject: [PATCH 07/10] run make format --- app/upgrades/v21/upgrades.go | 4 +++- app/upgrades/v21/upgrades_test.go | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index 574594a40b1..689c0e98a3f 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -4,17 +4,19 @@ import ( "context" "fmt" + providerkeeper "github.com/cosmos/interchain-security/v6/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" upgradetypes "cosmossdk.io/x/upgrade/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/cosmos/gaia/v21/app/keepers" - providerkeeper "github.com/cosmos/interchain-security/v6/x/ccv/provider/keeper" ) // Neutron and Stride denoms that were not whitelisted but the consumer rewards pool contains amounts of those denoms. diff --git a/app/upgrades/v21/upgrades_test.go b/app/upgrades/v21/upgrades_test.go index 06c94d3c34e..af0e79b2ffe 100644 --- a/app/upgrades/v21/upgrades_test.go +++ b/app/upgrades/v21/upgrades_test.go @@ -3,11 +3,12 @@ package v21_test import ( "testing" + "github.com/stretchr/testify/require" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/gaia/v21/app/helpers" + "github.com/cosmos/gaia/v21/app/helpers" v21 "github.com/cosmos/gaia/v21/app/upgrades/v21" - "github.com/stretchr/testify/require" ) func TestHasExpectedChainIdSanityCheck(t *testing.T) { From be2ae6dfa1cead0418ff986a543f855918cc6f60 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 4 Oct 2024 16:08:50 +0200 Subject: [PATCH 08/10] fix linter --- app/upgrades/v21/upgrades.go | 38 +++++++++++++++---------------- app/upgrades/v21/upgrades_test.go | 14 ++++++------ go.sum | 2 -- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index 689c0e98a3f..7dfc0e6cfee 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -60,14 +60,14 @@ func CreateUpgradeHandler( } } -// AllocateRewards allocates all the `denoms` that reside in the `address` and are meant for the chain with `consumerId` -func AllocateRewards(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, address sdk.AccAddress, consumerId string, denoms []string) error { +// AllocateRewards allocates all the `denoms` that reside in the `address` and are meant for the chain with `consumerID` +func AllocateRewards(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, address sdk.AccAddress, consumerID string, denoms []string) error { for _, denom := range denoms { coinRewards := bankKeeper.GetBalance(ctx, address, denom) decCoinRewards := sdk.DecCoins{sdk.DecCoin{Denom: coinRewards.Denom, Amount: math.LegacyNewDecFromInt(coinRewards.Amount)}} consumerRewardsAllocation := providertypes.ConsumerRewardsAllocation{Rewards: decCoinRewards} - err := providerKeeper.SetConsumerRewardsAllocationByDenom(ctx, consumerId, denom, consumerRewardsAllocation) + err := providerKeeper.SetConsumerRewardsAllocationByDenom(ctx, consumerID, denom, consumerRewardsAllocation) if err != nil { return err } @@ -75,13 +75,13 @@ func AllocateRewards(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bank return nil } -// HasExpectedChainIdSanityCheck returns true if the chain with the provided `consumerId` is of a chain with the `expectedChainId` -func HasExpectedChainIdSanityCheck(ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerId string, expectedChainId string) bool { - actualChainId, err := providerKeeper.GetConsumerChainId(ctx, consumerId) +// HasexpectedChainIDSanityCheck returns true if the chain with the provided `consumerID` is of a chain with the `expectedChainID` +func HasExpectedChainIDSanityCheck(ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerID string, expectedChainID string) bool { + actualChainID, err := providerKeeper.GetConsumerChainId(ctx, consumerID) if err != nil { return false } - if expectedChainId != actualChainId { + if expectedChainID != actualChainID { return false } return true @@ -91,30 +91,30 @@ func HasExpectedChainIdSanityCheck(ctx sdk.Context, providerKeeper providerkeepe func AllocateNeutronAndStrideUnaccountedDenoms(ctx sdk.Context, providerKeeper providerkeeper.Keeper, bankKeeper bankkeeper.Keeper, accountKeeper authkeeper.AccountKeeper) error { consumerRewardsPoolAddress := accountKeeper.GetModuleAccount(ctx, providertypes.ConsumerRewardsPool).GetAddress() - const NeutronConsumerId = "0" - const NeutronChainId = "neutron-1" + const NeutronconsumerID = "0" + const NeutronChainID = "neutron-1" - if !HasExpectedChainIdSanityCheck(ctx, providerKeeper, NeutronConsumerId, NeutronChainId) { - return fmt.Errorf("failed sanity check: consumer id (%s) does not correspond to chain id (%s)", NeutronConsumerId, NeutronChainId) + if !HasExpectedChainIDSanityCheck(ctx, providerKeeper, NeutronconsumerID, NeutronChainID) { + return fmt.Errorf("failed sanity check: consumer id (%s) does not correspond to chain id (%s)", NeutronconsumerID, NeutronChainID) } neutronUnaccountedDenoms := []string{NeutronUusdc, NeutronUtia} - err := AllocateRewards(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, NeutronConsumerId, neutronUnaccountedDenoms) + err := AllocateRewards(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, NeutronconsumerID, neutronUnaccountedDenoms) if err != nil { - return fmt.Errorf("cannot allocate rewards for consumer id (%s): %w", NeutronConsumerId, err) + return fmt.Errorf("cannot allocate rewards for consumer id (%s): %w", NeutronconsumerID, err) } - const StrideConsumerId = "1" - const StrideChainId = "stride-1" + const StrideconsumerID = "1" + const StrideChainID = "stride-1" - if !HasExpectedChainIdSanityCheck(ctx, providerKeeper, StrideConsumerId, StrideChainId) { - return fmt.Errorf("failed sanity check: consumer id (%s) does not correspond to chain id (%s)", StrideConsumerId, StrideChainId) + if !HasExpectedChainIDSanityCheck(ctx, providerKeeper, StrideconsumerID, StrideChainID) { + return fmt.Errorf("failed sanity check: consumer id (%s) does not correspond to chain id (%s)", StrideconsumerID, StrideChainID) } strideUnaccountedDenoms := []string{StrideStutia, StrideStadym, StrideStaISLM, StrideStuband, StrideStadydx, StrideStusaga} - err = AllocateRewards(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, StrideConsumerId, strideUnaccountedDenoms) + err = AllocateRewards(ctx, providerKeeper, bankKeeper, consumerRewardsPoolAddress, StrideconsumerID, strideUnaccountedDenoms) if err != nil { - return fmt.Errorf("cannot allocate rewards for consumer id (%s): %w", StrideConsumerId, err) + return fmt.Errorf("cannot allocate rewards for consumer id (%s): %w", StrideconsumerID, err) } return nil diff --git a/app/upgrades/v21/upgrades_test.go b/app/upgrades/v21/upgrades_test.go index af0e79b2ffe..a530e7dd216 100644 --- a/app/upgrades/v21/upgrades_test.go +++ b/app/upgrades/v21/upgrades_test.go @@ -11,20 +11,20 @@ import ( v21 "github.com/cosmos/gaia/v21/app/upgrades/v21" ) -func TestHasExpectedChainIdSanityCheck(t *testing.T) { +func TestHasExpectedChainIDSanityCheck(t *testing.T) { gaiaApp := helpers.Setup(t) ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{}) pk := gaiaApp.ProviderKeeper // no such consumer chain - consumerId := "0" - require.False(t, v21.HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + consumerID := "0" + require.False(t, v21.HasExpectedChainIDSanityCheck(ctx, pk, consumerID, "chain-1")) // consumer chain does not have `chain-1` id - pk.SetConsumerChainId(ctx, consumerId, "chain-2") - require.False(t, v21.HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + pk.SetConsumerChainId(ctx, consumerID, "chain-2") + require.False(t, v21.HasExpectedChainIDSanityCheck(ctx, pk, consumerID, "chain-1")) - pk.SetConsumerChainId(ctx, consumerId, "chain-1") - require.True(t, v21.HasExpectedChainIdSanityCheck(ctx, pk, consumerId, "chain-1")) + pk.SetConsumerChainId(ctx, consumerID, "chain-1") + require.True(t, v21.HasExpectedChainIDSanityCheck(ctx, pk, consumerID, "chain-1")) } diff --git a/go.sum b/go.sum index 35d5f3c795f..032bda8c16b 100644 --- a/go.sum +++ b/go.sum @@ -445,8 +445,6 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157 h1:KzH6KYAF3+psJ7KJKQihuY0oXL3NSgfS5VPAN525bZ8= github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157/go.mod h1:8Ke3cbEBBMImBkWPfF1bxPFg5ZqYOxZPjpnh0ItxQMQ= -github.com/cosmos/interchain-security/v6 v6.1.0 h1:ycTpT+If90nSEvRVu86ThPJxNtcmnOMjJmFC9ptd/yo= -github.com/cosmos/interchain-security/v6 v6.1.0/go.mod h1:+5zIZEzkL4yNHB/UWXCu75t6GeEgEmWHbz5OnBWiL0o= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= From b595d5c2113789cebdf8298dc5194dde576982fa Mon Sep 17 00:00:00 2001 From: MSalopek Date: Fri, 4 Oct 2024 17:45:37 +0200 Subject: [PATCH 09/10] bump ics version to v6.2.0-rc0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ee407907ede..d0816fdc3f4 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/cosmos/ibc-go/v8 v8.5.1 - github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157 + github.com/cosmos/interchain-security/v6 v6.2.0-rc0 github.com/google/gofuzz v1.2.0 github.com/gorilla/mux v1.8.1 github.com/ory/dockertest/v3 v3.11.0 diff --git a/go.sum b/go.sum index 032bda8c16b..47033b4d4dd 100644 --- a/go.sum +++ b/go.sum @@ -443,8 +443,8 @@ github.com/cosmos/ibc-go/v8 v8.5.1 h1:3JleEMKBjRKa3FeTKt4fjg22za/qygLBo7mDkoYTNB github.com/cosmos/ibc-go/v8 v8.5.1/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= -github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157 h1:KzH6KYAF3+psJ7KJKQihuY0oXL3NSgfS5VPAN525bZ8= -github.com/cosmos/interchain-security/v6 v6.0.0-20241003083905-f56af4c46157/go.mod h1:8Ke3cbEBBMImBkWPfF1bxPFg5ZqYOxZPjpnh0ItxQMQ= +github.com/cosmos/interchain-security/v6 v6.2.0-rc0 h1:RjGfEDSnOlsgXG4g5FSr5PBUE4V5N1wfCH09vLqrMDE= +github.com/cosmos/interchain-security/v6 v6.2.0-rc0/go.mod h1:8Ke3cbEBBMImBkWPfF1bxPFg5ZqYOxZPjpnh0ItxQMQ= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= From 3926e935e647f87ac5dab79ee4fcffbb29bacc3f Mon Sep 17 00:00:00 2001 From: MSalopek Date: Fri, 4 Oct 2024 18:09:22 +0200 Subject: [PATCH 10/10] downgrade error to log (upgrade works only on mainnet) --- app/upgrades/v21/upgrades.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index ae2f16aeb1f..b7dcb599b18 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -53,7 +53,9 @@ func CreateUpgradeHandler( ctx.Logger().Info("allocating rewards of Neutron and Stride unaccounted denoms") err = AllocateNeutronAndStrideUnaccountedDenoms(ctx, keepers.ProviderKeeper, keepers.BankKeeper, keepers.AccountKeeper) if err != nil { - return vm, errorsmod.Wrapf(err, "could not allocate rewards of Neutron and Stride unaccounted denoms") + // migration can only work on cosmoshub-4 + // all testchains except for mainnet export fork will fail this + ctx.Logger().Error("Error allocating rewards of Neutron and Stride unaccounted denoms:", "message", err.Error()) } err = InitializeConstitutionCollection(ctx, *keepers.GovKeeper)