From 6833be86d1744136b56822f19407567ec60a81b3 Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Tue, 20 Jul 2021 15:51:42 +0530 Subject: [PATCH 1/7] fix: feegrant grant cli bug (#9720) ## Description feegrant grant cli granter now accepts key name as well as address in general and accepts only address in `--generate-only` mode Closes: #9659 --- ### 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)) - [x] 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 - [ ] 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) (cherry picked from commit 085ab0669a0df6fce5c2322e7c61f25ae743fed0) # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 11 ++++++++++ x/feegrant/client/cli/tx.go | 6 +----- x/feegrant/client/testutil/suite.go | 31 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f93d61b9de63..74dd72bf86f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,11 +49,22 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +<<<<<<< HEAD * (bank) [\#9687](https://github.com/cosmos/cosmos-sdk/issues/9687) fixes [\#9159](https://github.com/cosmos/cosmos-sdk/issues/9159). Added migration to prune balances with zero coins. ### CLI Breaking Changes * [\#9621](https://github.com/cosmos/cosmos-sdk/pull/9621) Rollback [\#9371](https://github.com/cosmos/cosmos-sdk/pull/9371) and log warning if there's an empty value for min-gas-price in app.toml +======= +* [\#9720](https://github.com/cosmos/cosmos-sdk/pull/9720) Feegrant grant cli granter now accepts key name as well as address in general and accepts only address in --generate-only mode +* [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. +* [\#9639](https://github.com/cosmos/cosmos-sdk/pull/9639) Check store keys length before accessing them by making sure that `key` is of length `m+1` (for `key[n:m]`) +* (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt` +* (x/genutil) [\#9574](https://github.com/cosmos/cosmos-sdk/pull/9575) Actually use the `gentx` client tx flags (like `--keyring-dir`) +* (x/distribution) [\#9599](https://github.com/cosmos/cosmos-sdk/pull/9599) Withdraw rewards event now includes a value attribute even if there are 0 rewards (due to situations like 100% commission). +* (x/genutil) [\#9638](https://github.com/cosmos/cosmos-sdk/pull/9638) Added missing validator key save when recovering from mnemonic +* (server) [#9704](https://github.com/cosmos/cosmos-sdk/pull/9704) Start GRPCWebServer in goroutine, avoid blocking other services from starting. +>>>>>>> 085ab0669 (fix: feegrant grant cli bug (#9720)) ## [v0.43.0-rc0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0-rc0) - 2021-06-25 diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index ec2a5b0f6d4b..44b673d809b0 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -46,7 +46,7 @@ func GetTxCmd() *cobra.Command { // NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantAllowance transaction. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant [granter] [grantee]", + Use: "grant [granter_key_or_address] [grantee]", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( @@ -63,10 +63,6 @@ Examples: ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - _, err := sdk.AccAddressFromBech32(args[0]) - if err != nil { - return err - } cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index c539cf84766f..47724a38cae5 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -256,6 +257,10 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { alreadyExistedGrantee := s.addedGrantee clientCtx := val.ClientCtx + fromAddr, fromName, _, err := client.GetFromFields(clientCtx.Keyring, granter.String(), clientCtx.GenerateOnly) + s.Require().Equal(fromAddr, granter) + s.Require().NoError(err) + commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), @@ -295,6 +300,19 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), true, 0, nil, }, + { + "wrong granter key name", + append( + []string{ + "invalid_granter", + "cosmos16dun6ehcc86e03wreqqww89ey569wuj4em572w", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + true, 0, nil, + }, { "valid basic fee grant", append( @@ -308,6 +326,19 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), false, 0, &sdk.TxResponse{}, }, + { + "valid basic fee grant with granter key name", + append( + []string{ + fromName, + "cosmos16dun6ehcc86e03wreqqww89ey569wuj4em572w", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, fromName), + }, + commonFlags..., + ), + false, 0, &sdk.TxResponse{}, + }, { "valid basic fee grant with amino", append( From d1eb01d799a88663d71b8a1a02256b046ef85061 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 20 Jul 2021 17:51:23 +0530 Subject: [PATCH 2/7] fix conflicts --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74dd72bf86f9..3dfe2793cd4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,13 +49,11 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes -<<<<<<< HEAD * (bank) [\#9687](https://github.com/cosmos/cosmos-sdk/issues/9687) fixes [\#9159](https://github.com/cosmos/cosmos-sdk/issues/9159). Added migration to prune balances with zero coins. ### CLI Breaking Changes * [\#9621](https://github.com/cosmos/cosmos-sdk/pull/9621) Rollback [\#9371](https://github.com/cosmos/cosmos-sdk/pull/9371) and log warning if there's an empty value for min-gas-price in app.toml -======= * [\#9720](https://github.com/cosmos/cosmos-sdk/pull/9720) Feegrant grant cli granter now accepts key name as well as address in general and accepts only address in --generate-only mode * [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. * [\#9639](https://github.com/cosmos/cosmos-sdk/pull/9639) Check store keys length before accessing them by making sure that `key` is of length `m+1` (for `key[n:m]`) @@ -64,7 +62,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/distribution) [\#9599](https://github.com/cosmos/cosmos-sdk/pull/9599) Withdraw rewards event now includes a value attribute even if there are 0 rewards (due to situations like 100% commission). * (x/genutil) [\#9638](https://github.com/cosmos/cosmos-sdk/pull/9638) Added missing validator key save when recovering from mnemonic * (server) [#9704](https://github.com/cosmos/cosmos-sdk/pull/9704) Start GRPCWebServer in goroutine, avoid blocking other services from starting. ->>>>>>> 085ab0669 (fix: feegrant grant cli bug (#9720)) ## [v0.43.0-rc0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0-rc0) - 2021-06-25 From 1f3a8962f3f1486ffce5b08231b874d39bd4b222 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 20 Jul 2021 18:03:19 +0530 Subject: [PATCH 3/7] fix changelog --- CHANGELOG.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dfe2793cd4d..4d0241f44044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,19 +49,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* [\#9720](https://github.com/cosmos/cosmos-sdk/pull/9720) Feegrant grant cli granter now accepts key name as well as address in general and accepts only address in --generate-only mode * (bank) [\#9687](https://github.com/cosmos/cosmos-sdk/issues/9687) fixes [\#9159](https://github.com/cosmos/cosmos-sdk/issues/9159). Added migration to prune balances with zero coins. ### CLI Breaking Changes * [\#9621](https://github.com/cosmos/cosmos-sdk/pull/9621) Rollback [\#9371](https://github.com/cosmos/cosmos-sdk/pull/9371) and log warning if there's an empty value for min-gas-price in app.toml -* [\#9720](https://github.com/cosmos/cosmos-sdk/pull/9720) Feegrant grant cli granter now accepts key name as well as address in general and accepts only address in --generate-only mode -* [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. -* [\#9639](https://github.com/cosmos/cosmos-sdk/pull/9639) Check store keys length before accessing them by making sure that `key` is of length `m+1` (for `key[n:m]`) -* (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt` -* (x/genutil) [\#9574](https://github.com/cosmos/cosmos-sdk/pull/9575) Actually use the `gentx` client tx flags (like `--keyring-dir`) -* (x/distribution) [\#9599](https://github.com/cosmos/cosmos-sdk/pull/9599) Withdraw rewards event now includes a value attribute even if there are 0 rewards (due to situations like 100% commission). -* (x/genutil) [\#9638](https://github.com/cosmos/cosmos-sdk/pull/9638) Added missing validator key save when recovering from mnemonic -* (server) [#9704](https://github.com/cosmos/cosmos-sdk/pull/9704) Start GRPCWebServer in goroutine, avoid blocking other services from starting. ## [v0.43.0-rc0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0-rc0) - 2021-06-25 From 8daef5b35ce7989207f3d7f5edc62344eb71b4ce Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Jul 2021 19:08:26 +0530 Subject: [PATCH 4/7] try fixing lint issue --- server/grpc/gogoreflection/fix_registration.go | 11 +++++------ server/grpc/gogoreflection/serverreflection.go | 2 +- x/auth/tx/service.go | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/server/grpc/gogoreflection/fix_registration.go b/server/grpc/gogoreflection/fix_registration.go index 6575f782d3aa..512ea8b27e4d 100644 --- a/server/grpc/gogoreflection/fix_registration.go +++ b/server/grpc/gogoreflection/fix_registration.go @@ -8,8 +8,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" // required so it does register the gogoproto file descriptor gogoproto "github.com/gogo/protobuf/proto" - - "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" // nolint: staticcheck dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" _ "github.com/regen-network/cosmos-proto" // look above ) @@ -86,7 +85,7 @@ func getFileDescriptor(filePath string) []byte { return fd } - return proto.FileDescriptor(filePath) + return proto.FileDescriptor(filePath) // nolint: staticcheck } func getMessageType(name string) reflect.Type { @@ -95,7 +94,7 @@ func getMessageType(name string) reflect.Type { return typ } - return proto.MessageType(name) + return proto.MessageType(name) // nolint: staticcheck } func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc { @@ -107,7 +106,7 @@ func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc { } // check into proto registry - for id, desc := range proto.RegisteredExtensions(m) { + for id, desc := range proto.RegisteredExtensions(m) { // nolint: staticcheck if id == extID { return &gogoproto.ExtensionDesc{ ExtendedType: desc.ExtendedType, @@ -133,7 +132,7 @@ func getExtensionsNumbers(m proto.Message) []int32 { return out } - protoExts := proto.RegisteredExtensions(m) + protoExts := proto.RegisteredExtensions(m) // nolint: staticcheck out = make([]int32, 0, len(protoExts)) for id := range protoExts { out = append(out, id) diff --git a/server/grpc/gogoreflection/serverreflection.go b/server/grpc/gogoreflection/serverreflection.go index 102a8d2aaeff..b80004635a72 100644 --- a/server/grpc/gogoreflection/serverreflection.go +++ b/server/grpc/gogoreflection/serverreflection.go @@ -47,7 +47,7 @@ import ( "sort" "sync" - "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" // nolint: staticcheck dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index d91fdcccf1c2..a0deedae6aa2 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -6,7 +6,7 @@ import ( "strings" gogogrpc "github.com/gogo/protobuf/grpc" - "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" // nolint: staticcheck "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" From 7d2578964038b7c90bfbb5b5af0d0788a31d5d56 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Jul 2021 20:31:19 +0530 Subject: [PATCH 5/7] remove staticcheck comments --- server/grpc/gogoreflection/fix_registration.go | 10 +++++----- server/grpc/gogoreflection/serverreflection.go | 2 +- x/auth/tx/service.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/grpc/gogoreflection/fix_registration.go b/server/grpc/gogoreflection/fix_registration.go index 512ea8b27e4d..17cf36adbd9d 100644 --- a/server/grpc/gogoreflection/fix_registration.go +++ b/server/grpc/gogoreflection/fix_registration.go @@ -8,7 +8,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" // required so it does register the gogoproto file descriptor gogoproto "github.com/gogo/protobuf/proto" - "github.com/golang/protobuf/proto" // nolint: staticcheck + "github.com/golang/protobuf/proto" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" _ "github.com/regen-network/cosmos-proto" // look above ) @@ -85,7 +85,7 @@ func getFileDescriptor(filePath string) []byte { return fd } - return proto.FileDescriptor(filePath) // nolint: staticcheck + return proto.FileDescriptor(filePath) } func getMessageType(name string) reflect.Type { @@ -94,7 +94,7 @@ func getMessageType(name string) reflect.Type { return typ } - return proto.MessageType(name) // nolint: staticcheck + return proto.MessageType(name) } func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc { @@ -106,7 +106,7 @@ func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc { } // check into proto registry - for id, desc := range proto.RegisteredExtensions(m) { // nolint: staticcheck + for id, desc := range proto.RegisteredExtensions(m) { if id == extID { return &gogoproto.ExtensionDesc{ ExtendedType: desc.ExtendedType, @@ -132,7 +132,7 @@ func getExtensionsNumbers(m proto.Message) []int32 { return out } - protoExts := proto.RegisteredExtensions(m) // nolint: staticcheck + protoExts := proto.RegisteredExtensions(m) out = make([]int32, 0, len(protoExts)) for id := range protoExts { out = append(out, id) diff --git a/server/grpc/gogoreflection/serverreflection.go b/server/grpc/gogoreflection/serverreflection.go index b80004635a72..102a8d2aaeff 100644 --- a/server/grpc/gogoreflection/serverreflection.go +++ b/server/grpc/gogoreflection/serverreflection.go @@ -47,7 +47,7 @@ import ( "sort" "sync" - "github.com/golang/protobuf/proto" // nolint: staticcheck + "github.com/golang/protobuf/proto" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index a0deedae6aa2..d91fdcccf1c2 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -6,7 +6,7 @@ import ( "strings" gogogrpc "github.com/gogo/protobuf/grpc" - "github.com/golang/protobuf/proto" // nolint: staticcheck + "github.com/golang/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" From 87e434a5e62308a1815a3e5d77ba3cea572d3023 Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Thu, 29 Jul 2021 10:59:57 +0530 Subject: [PATCH 6/7] Update server/grpc/gogoreflection/fix_registration.go --- server/grpc/gogoreflection/fix_registration.go | 1 - 1 file changed, 1 deletion(-) diff --git a/server/grpc/gogoreflection/fix_registration.go b/server/grpc/gogoreflection/fix_registration.go index 1ba9bc4dec2b..488f5dd358a3 100644 --- a/server/grpc/gogoreflection/fix_registration.go +++ b/server/grpc/gogoreflection/fix_registration.go @@ -5,7 +5,6 @@ import ( "compress/gzip" "fmt" "reflect" - // nolint: staticcheck _ "github.com/gogo/protobuf/gogoproto" // required so it does register the gogoproto file descriptor gogoproto "github.com/gogo/protobuf/proto" From d17f9a6487213c7fd4e5f5d3a772f4fb7e76a60b Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Thu, 29 Jul 2021 11:00:14 +0530 Subject: [PATCH 7/7] Update server/grpc/gogoreflection/fix_registration.go --- server/grpc/gogoreflection/fix_registration.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/grpc/gogoreflection/fix_registration.go b/server/grpc/gogoreflection/fix_registration.go index 488f5dd358a3..ab7750574845 100644 --- a/server/grpc/gogoreflection/fix_registration.go +++ b/server/grpc/gogoreflection/fix_registration.go @@ -8,6 +8,8 @@ import ( _ "github.com/gogo/protobuf/gogoproto" // required so it does register the gogoproto file descriptor gogoproto "github.com/gogo/protobuf/proto" + + // nolint: staticcheck "github.com/golang/protobuf/proto" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" _ "github.com/regen-network/cosmos-proto" // look above