From 17ba2eb7ca6d86f60ed945148c2b495255e4e90f Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Thu, 17 Jun 2021 13:27:32 +0200 Subject: [PATCH 1/3] perf: MsgTypeUrl optimization (#9530) ## Description Tiny optimization: no need to do string formatting to prefix a string with one character. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- types/tx_msg.go | 4 +--- types/tx_msg_test.go | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/types/tx_msg.go b/types/tx_msg.go index d7f15e83f078..42d01fdc55ee 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -1,8 +1,6 @@ package types import ( - fmt "fmt" - "github.com/gogo/protobuf/proto" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -79,5 +77,5 @@ type TxEncoder func(tx Tx) ([]byte, error) // MsgTypeURL returns the TypeURL of a `sdk.Msg`. func MsgTypeURL(msg Msg) string { - return fmt.Sprintf("/%s", proto.MessageName(msg)) + return "/" + proto.MessageName(msg) } diff --git a/types/tx_msg_test.go b/types/tx_msg_test.go index 7a55c7d63e64..bf7763b02913 100644 --- a/types/tx_msg_test.go +++ b/types/tx_msg_test.go @@ -29,3 +29,7 @@ func (s *testMsgSuite) TestMsg() { s.Require().Nil(msg.ValidateBasic()) s.Require().NotPanics(func() { msg.GetSignBytes() }) } + +func (s *testMsgSuite) TestMsgTypeURL() { + s.Require().Equal("/testdata.TestMsg", sdk.MsgTypeURL(new(testdata.TestMsg))) +} From 0e64fa77d1173b485421e0dd4d4e95af462cef96 Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Thu, 17 Jun 2021 20:34:33 +0530 Subject: [PATCH 2/3] docs: Add docs for setting store loader (#9526) ## Description Closes: #9503 Add documentation for setting StoreLoader as part of in-place store migration. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct `docs:` prefix in the PR title - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [ ] followed the [documentation writing guidelines](https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOC_WRITING_GUIDELINES.md) - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [x] confirmed the correct `docs:` prefix in the PR title - [ ] confirmed all author checklist items have been addressed - [x] confirmed that this PR only changes documentation - [x] reviewed content for consistency - [x] reviewed content for thoroughness - [x] reviewed content for spelling and grammar - [ ] tested instructions (if applicable) --- docs/building-modules/upgrade.md | 2 +- docs/core/upgrade.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/building-modules/upgrade.md b/docs/building-modules/upgrade.md index 53864fa58b96..2f9eaa98f339 100644 --- a/docs/building-modules/upgrade.md +++ b/docs/building-modules/upgrade.md @@ -8,7 +8,7 @@ In-place store migrations allow your modules to upgrade to new versions that inc ## Prerequisite Readings -- [In-Place Store Migration](../core-concepts/upgrade.md) {prereq} +- [In-Place Store Migration](../core/upgrade.md) {prereq} ## Consensus Version diff --git a/docs/core/upgrade.md b/docs/core/upgrade.md index 4e48e10b9d7e..c37d813871c7 100644 --- a/docs/core/upgrade.md +++ b/docs/core/upgrade.md @@ -82,6 +82,29 @@ To learn more about configuring migration scripts for your modules, see the [Mig You can introduce entirely new modules to the application during an upgrade. New modules are recognized because they have not yet been registered in `x/upgrade`'s `VersionMap` store. In this case, `RunMigrations` calls the `InitGenesis` function from the corresponding module to set up its initial state. +### Add StoreUpgrades for New Modules + +All chains preparing to run in-place store migrations will need to manually add store upgrades for new modules and then configure the store loader to apply those upgrades. This ensures that the new module's stores are added to the multistore before the migrations begin. + +```golang +upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() +if err != nil { + panic(err) +} + +if upgradeInfo.Name == "my-plan" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{ + // add store upgrades for new modules + // Example: + // Added: []string{"foo", "bar"}, + // ... + } + + // configure store loader that checks if version == upgradeHeight and applies store upgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) +} +``` + ## Overwriting Genesis Functions The Cosmos SDK offers modules that the application developer can import in their app. These modules often have an `InitGenesis` function already defined. From 0ae07fe69cf2fd48b10ebb554516f9fa8294bb81 Mon Sep 17 00:00:00 2001 From: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Date: Thu, 17 Jun 2021 18:50:37 -0700 Subject: [PATCH 3/3] fix: duplicate vesting and format (#9535) ## Description This pull request fixes the duplicate `vesting` command displayed with `--help` for the `tx` command. It also removes line breaks for consistent formatting across all commands and it fixes a minor typo. ## Manual Test ``` make build ``` ``` ./build/simd tx -h ``` ``` ./build/simd tx vesting -h ``` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - *n/a* - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - *n/a* - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - *n/a* - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- client/keys/root.go | 1 - client/keys/root_test.go | 2 +- server/util.go | 2 -- simapp/simd/cmd/root.go | 4 ---- x/auth/client/cli/decode.go | 2 +- 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/client/keys/root.go b/client/keys/root.go index 92c78c3abeab..938a0d53a14c 100644 --- a/client/keys/root.go +++ b/client/keys/root.go @@ -44,7 +44,6 @@ The pass backend requires GnuPG: https://gnupg.org/ ImportKeyCommand(), ListKeysCmd(), ShowKeysCmd(), - flags.LineBreak, DeleteKeyCommand(), ParseKeyStringCommand(), MigrateCommand(), diff --git a/client/keys/root_test.go b/client/keys/root_test.go index f66ae9265de6..b6c2f5f88f48 100644 --- a/client/keys/root_test.go +++ b/client/keys/root_test.go @@ -11,5 +11,5 @@ func TestCommands(t *testing.T) { assert.NotNil(t, rootCommands) // Commands are registered - assert.Equal(t, 10, len(rootCommands.Commands())) + assert.Equal(t, 9, len(rootCommands.Commands())) } diff --git a/server/util.go b/server/util.go index 68f1c4828166..e39bb712c87c 100644 --- a/server/util.go +++ b/server/util.go @@ -264,10 +264,8 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type rootCmd.AddCommand( startCmd, UnsafeResetAllCmd(), - flags.LineBreak, tendermintCmd, ExportCmd(appExport, defaultNodeHome), - flags.LineBreak, version.NewVersionCommand(), ) } diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index e37944f09d55..bb736b61d622 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -28,7 +28,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" - vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" @@ -151,12 +150,9 @@ func txCommand() *cobra.Command { authcmd.GetMultiSignCommand(), authcmd.GetMultiSignBatchCmd(), authcmd.GetValidateSignaturesCommand(), - flags.LineBreak, authcmd.GetBroadcastCommand(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), - flags.LineBreak, - vestingcli.GetTxCmd(), ) simapp.ModuleBasics.AddTxCommands(cmd) diff --git a/x/auth/client/cli/decode.go b/x/auth/client/cli/decode.go index e1807efb099e..6af5bb5c38ac 100644 --- a/x/auth/client/cli/decode.go +++ b/x/auth/client/cli/decode.go @@ -17,7 +17,7 @@ const flagHex = "hex" func GetDecodeCommand() *cobra.Command { cmd := &cobra.Command{ Use: "decode [amino-byte-string]", - Short: "Decode an binary encoded transaction string.", + Short: "Decode a binary encoded transaction string", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx := client.GetClientContextFromCmd(cmd)