Skip to content

Commit

Permalink
fix(x/upgrade): register missing implementation for SoftwareUpgradePr…
Browse files Browse the repository at this point in the history
…oposal (#23179)
  • Loading branch information
mmsqe authored Jan 14, 2025
1 parent 4466ea5 commit 5581225
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 13 deletions.
20 changes: 17 additions & 3 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,23 @@ Accounts's AccountNumber will be used as a global account number tracking replac
```go
import authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
...
err := authkeeper.MigrateAccountNumberUnsafe(ctx, &app.AuthKeeper)
if err != nil {
return nil, err
app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx context.Context, _ upgradetypes.Plan, fromVM appmodule.VersionMap) (appmodule.VersionMap, error) {
if err := authkeeper.MigrateAccountNumberUnsafe(ctx, &app.AuthKeeper); err != nil {
return nil, err
}
return app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
},
)
```

Add `x/accounts` store while upgrading to v0.52.x:

```go
storetypes.StoreUpgrades{
Added: []string{
accounts.StoreKey,
},
}
```

Expand Down
7 changes: 0 additions & 7 deletions simapp/v2/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/runtime/v2"
"cosmossdk.io/x/accounts"
bankv2types "cosmossdk.io/x/bank/v2/types"
epochstypes "cosmossdk.io/x/epochs/types"
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
)

Expand Down Expand Up @@ -37,12 +34,8 @@ func (app *SimApp[T]) RegisterUpgradeHandlers() {
if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{
Added: []string{
accounts.StoreKey,
protocolpooltypes.StoreKey,
epochstypes.StoreKey,
bankv2types.ModuleName,
},
Deleted: []string{"crisis"}, // The SDK discontinued the crisis module in v0.52.0
}

app.SetStoreLoader(runtime.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
2 changes: 1 addition & 1 deletion tests/systemtests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestChainUpgrade(t *testing.T) {

const (
upgradeHeight int64 = 22
upgradeName = "v052-to-v054" // must match UpgradeName in simapp/upgrades.go
upgradeName = "v052-to-v2" // must match UpgradeName in simapp/upgrades.go
)

systest.Sut.StartChain(t, fmt.Sprintf("--comet.halt-height=%d", upgradeHeight+1))
Expand Down
3 changes: 3 additions & 0 deletions x/upgrade/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Bug Fixes
* (x/upgrade) [#23179](https://github.com/cosmos/cosmos-sdk/pull/23179) Register missing implementation for SoftwareUpgradeProposal to avoid no concrete type registered for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error.

## [v0.2.0-rc.1](https://github.com/cosmos/cosmos-sdk/releases/tag/x/upgrade/v0.2.0-rc.1) - 2024-12-18

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion x/upgrade/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
cosmossdk.io/log v1.5.0
cosmossdk.io/store v1.10.0-rc.1
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a
cosmossdk.io/x/tx v1.0.0
github.com/cometbft/cometbft v1.0.0
github.com/cometbft/cometbft/api v1.0.0
github.com/cosmos/cosmos-proto v1.0.0-beta.5
Expand Down Expand Up @@ -46,7 +47,6 @@ require (
cosmossdk.io/schema v1.0.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down
6 changes: 5 additions & 1 deletion x/upgrade/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
"cosmossdk.io/core/registry"
coretransaction "cosmossdk.io/core/transaction"
"cosmossdk.io/x/gov/types/v1beta1"

"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/types/msgservice"
Expand All @@ -23,6 +24,9 @@ func RegisterInterfaces(registrar registry.InterfaceRegistrar) {
&MsgSoftwareUpgrade{},
&MsgCancelUpgrade{},
)

registrar.RegisterImplementations(
(*v1beta1.Content)(nil),
&SoftwareUpgradeProposal{},
)
msgservice.RegisterMsgServiceDesc(registrar, &_Msg_serviceDesc)
}
33 changes: 33 additions & 0 deletions x/upgrade/types/codec_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package types

import (
"testing"

proto "github.com/cosmos/gogoproto/proto"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"github.com/stretchr/testify/require"

"cosmossdk.io/x/gov/types/v1beta1"
"cosmossdk.io/x/tx/signing"

codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/codec/types"
)

func TestInterfaceRegistrationOfContent(t *testing.T) {
opts := codectestutil.CodecOptions{}
registrar, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: opts.GetAddressCodec(),
ValidatorAddressCodec: opts.GetValidatorCodec(),
},
})
require.NoError(t, err)
RegisterInterfaces(registrar)
val := &gogoprotoany.Any{
TypeUrl: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal",
Value: []byte{},
}
require.NoError(t, registrar.UnpackAny(val, new(v1beta1.Content)))
}
21 changes: 21 additions & 0 deletions x/upgrade/types/proposal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package types

import (
"cosmossdk.io/x/gov/types"
"cosmossdk.io/x/gov/types/v1beta1"
)

// GetTitle returns the proposal title
func (sp *SoftwareUpgradeProposal) GetTitle() string { return sp.Title }

// GetDescription returns the proposal description
func (sp *SoftwareUpgradeProposal) GetDescription() string { return sp.Description }

// ProposalRoute returns the proposal router key
func (sp *SoftwareUpgradeProposal) ProposalRoute() string { return types.RouterKey }

// ProposalType is "Text"
func (sp *SoftwareUpgradeProposal) ProposalType() string { return v1beta1.ProposalTypeText }

// ValidateBasic validates the content's title and description of the proposal
func (sp *SoftwareUpgradeProposal) ValidateBasic() error { return v1beta1.ValidateAbstract(sp) }

0 comments on commit 5581225

Please sign in to comment.