From 61fafb49b65a0a93e1ebd402de426f353371deab Mon Sep 17 00:00:00 2001 From: mmsqe Date: Sat, 4 Jan 2025 21:59:20 +0800 Subject: [PATCH 1/4] fix(x/upgrade): register missing implementation for SoftwareUpgradeProposal to avoid no concrete type registered for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error --- CHANGELOG.md | 1 + x/upgrade/types/codec.go | 6 +++++- x/upgrade/types/proposal.go | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 x/upgrade/types/proposal.go diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d68750ee8c..5187acd05eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (query) [23002](https://github.com/cosmos/cosmos-sdk/pull/23002) Fix collection filtered pagination. * (x/auth/tx) [#23148](https://github.com/cosmos/cosmos-sdk/pull/23148) Avoid panic from intoAnyV2 when v1.PublicKey is optional. +* (x/upgrade) [#23177](https://github.com/cosmos/cosmos-sdk/pull/23177) Register missing implementation for SoftwareUpgradeProposal to avoid no concrete type registered for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error. ### API Breaking Changes diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index 0ab589acf313..abfd8a85600b 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -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" @@ -23,6 +24,9 @@ func RegisterInterfaces(registrar registry.InterfaceRegistrar) { &MsgSoftwareUpgrade{}, &MsgCancelUpgrade{}, ) - + registrar.RegisterImplementations( + (*v1beta1.Content)(nil), + &SoftwareUpgradeProposal{}, + ) msgservice.RegisterMsgServiceDesc(registrar, &_Msg_serviceDesc) } diff --git a/x/upgrade/types/proposal.go b/x/upgrade/types/proposal.go new file mode 100644 index 000000000000..0df833c9f73f --- /dev/null +++ b/x/upgrade/types/proposal.go @@ -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) } From 067bf9c29241b9a69b1326970b6070b53663dc1c Mon Sep 17 00:00:00 2001 From: mmsqe Date: Sat, 4 Jan 2025 22:00:20 +0800 Subject: [PATCH 2/4] doc --- CHANGELOG.md | 2 +- UPGRADING.md | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5187acd05eb7..b6d7f9d56896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (query) [23002](https://github.com/cosmos/cosmos-sdk/pull/23002) Fix collection filtered pagination. * (x/auth/tx) [#23148](https://github.com/cosmos/cosmos-sdk/pull/23148) Avoid panic from intoAnyV2 when v1.PublicKey is optional. -* (x/upgrade) [#23177](https://github.com/cosmos/cosmos-sdk/pull/23177) Register missing implementation for SoftwareUpgradeProposal to avoid no concrete type registered for type URL /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal against interface *v1beta1.Content error. +* (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. ### API Breaking Changes diff --git a/UPGRADING.md b/UPGRADING.md index 2c3e6c858e73..8aa5e9497a96 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -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, + }, } ``` From f1f48230c1c51d06d9f87423315d54d254c80d44 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 10 Jan 2025 09:11:34 +0800 Subject: [PATCH 3/4] add test --- x/upgrade/types/codec_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 x/upgrade/types/codec_test.go diff --git a/x/upgrade/types/codec_test.go b/x/upgrade/types/codec_test.go new file mode 100644 index 000000000000..27198d1d12bf --- /dev/null +++ b/x/upgrade/types/codec_test.go @@ -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))) +} From 2b98de24ca1956843da97be965c7b001dcafe5a3 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 10 Jan 2025 17:03:47 +0800 Subject: [PATCH 4/4] Apply suggestions from code review --- CHANGELOG.md | 1 - x/upgrade/CHANGELOG.md | 3 +++ x/upgrade/go.mod | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed46159ccb13..54aeafc0a989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,7 +56,6 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (x/auth/tx) [#23170](https://github.com/cosmos/cosmos-sdk/pull/23170) Avoid panic from newWrapperFromDecodedTx when AuthInfo.Fee is optional in decodedTx. * (x/auth/tx) [23144](https://github.com/cosmos/cosmos-sdk/pull/23144) Add missing CacheWithValue for ExtensionOptions. * (x/auth/tx) [#23148](https://github.com/cosmos/cosmos-sdk/pull/23148) Avoid panic from intoAnyV2 when v1.PublicKey is optional. -* (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. ### API Breaking Changes diff --git a/x/upgrade/CHANGELOG.md b/x/upgrade/CHANGELOG.md index 1886aedd8f67..4e0521d3443a 100644 --- a/x/upgrade/CHANGELOG.md +++ b/x/upgrade/CHANGELOG.md @@ -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 diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index 01a4c7e3ec60..baf6244379de 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -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 @@ -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