Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps!: Bump ICS #3292

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
no_valupdates_genutil "github.com/cosmos/interchain-security/v5/x/ccv/no_valupdates_genutil"
no_valupdates_staking "github.com/cosmos/interchain-security/v5/x/ccv/no_valupdates_staking"
icsproviderclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"

"cosmossdk.io/x/evidence"
Expand Down Expand Up @@ -138,10 +137,6 @@ func newBasicManagerFromManager(app *GaiaApp) module.BasicManager {
govtypes.ModuleName: gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
icsproviderclient.ConsumerAdditionProposalHandler,
icsproviderclient.ConsumerRemovalProposalHandler,
icsproviderclient.ConsumerModificationProposalHandler,
icsproviderclient.ChangeRewardDenomsProposalHandler,
},
),
})
Expand Down
145 changes: 143 additions & 2 deletions app/upgrades/v20/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"context"

providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
"github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"

errorsmod "cosmossdk.io/errors"
upgradetypes "cosmossdk.io/x/upgrade/types"

codec "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

"github.com/cosmos/gaia/v20/app/keepers"
Expand Down Expand Up @@ -62,6 +65,12 @@ func CreateUpgradeHandler(
return vm, errorsmod.Wrapf(err, "initializing LastProviderConsensusValSet during migration")
}

ctx.Logger().Info("Migrating ICS legacy proposals...")
err = MigrateICSLegacyProposals(ctx, *keepers.GovKeeper)
if err != nil {
return vm, errorsmod.Wrapf(err, "migrating ICS legacy proposals during migration")
}

ctx.Logger().Info("Upgrade v20 complete")
return vm, nil
}
Expand Down Expand Up @@ -110,7 +119,7 @@ func InitializeLastProviderConsensusValidatorSet(
}

// create consensus validators for the staking validators
lastValidators := []types.ConsensusValidator{}
lastValidators := []providertypes.ConsensusValidator{}
for _, val := range vals {
consensusVal, err := providerKeeper.CreateProviderConsensusValidator(ctx, val)
if err != nil {
Expand All @@ -123,3 +132,135 @@ func InitializeLastProviderConsensusValidatorSet(
providerKeeper.SetLastProviderConsensusValSet(ctx, lastValidators)
return nil
}

// MigrateICSLegacyProposals migrates ICS legacy proposals
func MigrateICSLegacyProposals(ctx sdk.Context, govKeeper govkeeper.Keeper) error {
return govKeeper.Proposals.Walk(ctx, nil, func(key uint64, proposal govtypes.Proposal) (stop bool, err error) {
err = MigrateProposal(ctx, govKeeper, proposal)
if err != nil {
return true, errorsmod.Wrapf(err, "migrating proposal %d", key)
}
return false, nil
})
}

// MigrateProposal migrates a proposal by converting legacy messages to new messages.
func MigrateProposal(ctx sdk.Context, govKeeper govkeeper.Keeper, proposal govtypes.Proposal) error {
for idx, msg := range proposal.GetMessages() {
sdkLegacyMsg, isLegacyProposal := msg.GetCachedValue().(*govtypes.MsgExecLegacyContent)
if !isLegacyProposal {
continue
}
content, err := govtypes.LegacyContentFromMessage(sdkLegacyMsg)
if err != nil {
continue
}

msgAdd, ok := content.(*providertypes.ConsumerAdditionProposal)
if ok {
anyMsg, err := MigrateLegacyConsumerAddition(*msgAdd, govKeeper.GetAuthority())
if err != nil {
return err
}
proposal.Messages[idx] = anyMsg
continue // skip the rest of the loop
}

msgRemove, ok := content.(*providertypes.ConsumerRemovalProposal)
if ok {
anyMsg, err := MigrateLegacyConsumerRemoval(*msgRemove, govKeeper.GetAuthority())
if err != nil {
return err
}
proposal.Messages[idx] = anyMsg
continue // skip the rest of the loop
}

msgMod, ok := content.(*providertypes.ConsumerModificationProposal)
if ok {
anyMsg, err := MigrateConsumerModificationProposal(*msgMod, govKeeper.GetAuthority())
if err != nil {
return err
}
proposal.Messages[idx] = anyMsg
continue // skip the rest of the loop
}

msgChangeRewardDenoms, ok := content.(*providertypes.ChangeRewardDenomsProposal)
if ok {
anyMsg, err := MigrateChangeRewardDenomsProposal(*msgChangeRewardDenoms, govKeeper.GetAuthority())
if err != nil {
return err
}
proposal.Messages[idx] = anyMsg
continue // skip the rest of the loop
}
}
return govKeeper.SetProposal(ctx, proposal)
}

// MigrateLegacyConsumerAddition converts a ConsumerAdditionProposal to a MsgConsumerAdditionProposal
// and returns it as `Any` suitable to replace the legacy message.
// `authority` contains the signer address
func MigrateLegacyConsumerAddition(msg providertypes.ConsumerAdditionProposal, authority string) (*codec.Any, error) {
sdkMsg := providertypes.MsgConsumerAddition{
ChainId: msg.ChainId,
InitialHeight: msg.InitialHeight,
GenesisHash: msg.GenesisHash,
BinaryHash: msg.BinaryHash,
SpawnTime: msg.SpawnTime,
UnbondingPeriod: msg.UnbondingPeriod,
CcvTimeoutPeriod: msg.CcvTimeoutPeriod,
TransferTimeoutPeriod: msg.TransferTimeoutPeriod,
ConsumerRedistributionFraction: msg.ConsumerRedistributionFraction,
BlocksPerDistributionTransmission: msg.BlocksPerDistributionTransmission,
HistoricalEntries: msg.HistoricalEntries,
DistributionTransmissionChannel: msg.DistributionTransmissionChannel,
Top_N: msg.Top_N,
ValidatorsPowerCap: msg.ValidatorsPowerCap,
ValidatorSetCap: msg.ValidatorSetCap,
Allowlist: msg.Allowlist,
Denylist: msg.Denylist,
Authority: authority,
MinStake: msg.MinStake,
AllowInactiveVals: msg.AllowInactiveVals,
}
return codec.NewAnyWithValue(&sdkMsg)
}

// MigrateLegacyConsumerRemoval converts a ConsumerRemovalProposal to a MsgConsumerRemovalProposal
// and returns it as `Any` suitable to replace the legacy message.
// `authority` contains the signer address
func MigrateLegacyConsumerRemoval(msg providertypes.ConsumerRemovalProposal, authority string) (*codec.Any, error) {
sdkMsg := providertypes.MsgConsumerRemoval{
ChainId: msg.ChainId,
StopTime: msg.StopTime,
Authority: authority,
}
return codec.NewAnyWithValue(&sdkMsg)
}

// MigrateConsumerModificationProposal converts a ConsumerModificationProposal to a MsgConsumerModificationProposal
// and returns it as `Any` suitable to replace the legacy message.
// `authority` contains the signer address
func MigrateConsumerModificationProposal(msg providertypes.ConsumerModificationProposal, authority string) (*codec.Any, error) {
sdkMsg := providertypes.MsgConsumerModification{
ChainId: msg.ChainId,
Allowlist: msg.Allowlist,
Denylist: msg.Denylist,
Authority: authority,
}
return codec.NewAnyWithValue(&sdkMsg)
}

// MigrateChangeRewardDenomsProposal converts a ChangeRewardDenomsProposal to a MigrateChangeRewardDenomsProposal
// and returns it as `Any` suitable to replace the legacy message.
// `authority` contains the signer address
func MigrateChangeRewardDenomsProposal(msg providertypes.ChangeRewardDenomsProposal, authority string) (*codec.Any, error) {
sdkMsg := providertypes.MsgChangeRewardDenoms{
DenomsToAdd: msg.GetDenomsToAdd(),
DenomsToRemove: msg.GetDenomsToRemove(),
Authority: authority,
}
return codec.NewAnyWithValue(&sdkMsg)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.0
github.com/cosmos/ibc-go/v8 v8.4.0
github.com/cosmos/interchain-security/v5 v5.0.0-20240806104629-29327696b8e6
github.com/cosmos/interchain-security/v5 v5.0.0-20240823135732-3a0c55f65769
github.com/google/gofuzz v1.2.0
github.com/gorilla/mux v1.8.1
github.com/ory/dockertest/v3 v3.11.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZD
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/interchain-security/v5 v5.0.0-20240806104629-29327696b8e6 h1:aFwnbEdeMUaQg9ZU+Pm8fE3CzZM2gG5jSeAvYOd+hoU=
github.com/cosmos/interchain-security/v5 v5.0.0-20240806104629-29327696b8e6/go.mod h1:sT6a/OIwwkXuH9fBzt5IBa4lrlWO8etgQ+b59pIE8k4=
github.com/cosmos/interchain-security/v5 v5.0.0-20240823135732-3a0c55f65769 h1:R1ncQp/CwgV/u2fWebEWdp/o3IiINb3RuWEg4ATrEGQ=
github.com/cosmos/interchain-security/v5 v5.0.0-20240823135732-3a0c55f65769/go.mod h1:y3LdR1GPxF8SMFRb/V38OWGZNwEriJDFlka/hoH1GEk=
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=
Expand Down
14 changes: 0 additions & 14 deletions tests/e2e/e2e_gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,6 @@ func (s *IntegrationTestSuite) GovCommunityPoolSpend() {
)
}

func (s *IntegrationTestSuite) submitLegacyGovProposal(chainAAPIEndpoint, sender string, proposalID int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string, withDeposit bool) {
s.T().Logf("Submitting Gov Proposal: %s", proposalType)
// min deposit of 1000uatom is required in e2e tests, otherwise the gov antehandler causes the proposal to be dropped
sflags := submitFlags
if withDeposit {
sflags = append(sflags, "--deposit=1000uatom")
}
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, "submit-legacy-proposal", sflags, govtypesv1beta1.StatusDepositPeriod)
s.T().Logf("Depositing Gov Proposal: %s", proposalType)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, "deposit", depositFlags, govtypesv1beta1.StatusVotingPeriod)
s.T().Logf("Voting Gov Proposal: %s", proposalType)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, voteCommand, voteFlags, govtypesv1beta1.StatusPassed)
}

// NOTE: in SDK >= v0.47 the submit-proposal does not have a --deposit flag
// Instead, the depoist is added to the "deposit" field of the proposal JSON (usually stored as a file)
// you can use `gaiad tx gov draft-proposal` to create a proposal file that you can use
Expand Down
140 changes: 0 additions & 140 deletions tests/e2e/e2e_ics_test.go

This file was deleted.

Loading
Loading