From 677fa68da250499f5e7b7e2c04e75b707125e233 Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Mon, 18 Oct 2021 15:03:20 +0530 Subject: [PATCH 01/15] conflicts --- CHANGELOG.md | 4 ++++ x/bank/keeper/keeper.go | 8 ++++++++ x/bank/keeper/keeper_test.go | 1 + 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d44eee903daa..c1f8840f4310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Improvements + +* [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10393) Add `HasSupply` method to bank keeper to ensure that input denom actually exists on chain. + ### Bug Fixes * [\#10414](https://github.com/cosmos/cosmos-sdk/pull/10414) Use `sdk.GetConfig().GetFullBIP44Path()` instead `sdk.FullFundraiserPath` to generate key diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index cc8ded240136..482c002870bd 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -25,6 +25,7 @@ type Keeper interface { ExportGenesis(sdk.Context) *types.GenesisState GetSupply(ctx sdk.Context, denom string) sdk.Coin + HasSupply(ctx sdk.Context, denom string) bool GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bool) GetDenomMetaData(ctx sdk.Context, denom string) (types.Metadata, bool) @@ -214,6 +215,13 @@ func (k BaseKeeper) GetSupply(ctx sdk.Context, denom string) sdk.Coin { } } +// HasSupply checks if the supply coin exists in store. +func (k BaseKeeper) HasSupply(ctx sdk.Context, denom string) bool { + store := ctx.KVStore(k.storeKey) + supplyStore := prefix.NewStore(store, types.SupplyKey) + return supplyStore.Has([]byte(denom)) +} + // GetDenomMetaData retrieves the denomination metadata. returns the metadata and true if the denom exists, // false otherwise. func (k BaseKeeper) GetDenomMetaData(ctx sdk.Context, denom string) (types.Metadata, bool) { diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index f9074f423e92..93f355260bf8 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -1113,6 +1113,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { } // check balance and supply tracking + suite.Require().True(suite.app.BankKeeper.HasSupply(suite.ctx, "utxo")) savedSupply := suite.app.BankKeeper.GetSupply(suite.ctx, "utxo") utxoSupply := savedSupply suite.Require().Equal(utxoSupply.Amount, supply.AmountOf("utxo")) From 4fa25d046793ad8b97add99ed6a8678991f2e1ae Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Fri, 30 Jul 2021 16:47:22 +0530 Subject: [PATCH 02/15] conflicts --- CHANGELOG.md | 1 + x/genutil/client/cli/init.go | 30 +++++++++++++++++++++++++++--- x/genutil/client/cli/init_test.go | 24 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f8840f4310..513b3030cf5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10393) Add `HasSupply` method to bank keeper to ensure that input denom actually exists on chain. +* [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `staking-bond-denom` to specify the staking bond denomination value when initializing a new chain. ### Bug Fixes diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 5d26085aa79e..a4d4c869a1be 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" - "github.com/cosmos/go-bip39" "github.com/pkg/errors" "github.com/spf13/cobra" cfg "github.com/tendermint/tendermint/config" @@ -23,6 +22,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/go-bip39" ) const ( @@ -31,6 +32,9 @@ const ( // FlagSeed defines a flag to initialize the private validator key from a specific seed. FlagRecover = "recover" + + // FlagStakingBondDenom defines a flag to specify the staking token in the genesis file. + FlagStakingBondDenom = "staking-bond-denom" ) type printInfo struct { @@ -109,13 +113,32 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { genFile := config.GenesisFile() overwrite, _ := cmd.Flags().GetBool(FlagOverwrite) + stakingBondDenom, _ := cmd.Flags().GetString(FlagStakingBondDenom) + if !overwrite && tmos.FileExists(genFile) { return fmt.Errorf("genesis.json file already exists: %v", genFile) } - appState, err := json.MarshalIndent(mbm.DefaultGenesis(cdc), "", " ") + appGenState := mbm.DefaultGenesis(cdc) + + if stakingBondDenom != "" { + stakingRaw := appGenState[stakingtypes.ModuleName] + var stakingGenesis stakingtypes.GenesisState + err := clientCtx.Codec.UnmarshalJSON(stakingRaw, &stakingGenesis) + if err != nil { + return err + } + stakingGenesis.Params.BondDenom = stakingBondDenom + modifiedStakingStr, err := clientCtx.Codec.MarshalJSON(&stakingGenesis) + if err != nil { + return err + } + appGenState[stakingtypes.ModuleName] = modifiedStakingStr + } + + appState, err := json.MarshalIndent(appGenState, "", " ") if err != nil { - return errors.Wrap(err, "Failed to marshall default genesis state") + return errors.Wrap(err, "Failed to marshal default genesis state") } genDoc := &types.GenesisDoc{} @@ -149,6 +172,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file") cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") + cmd.Flags().String(FlagStakingBondDenom, "", "genesis file staking bond denomination, if left blank default value is 'stake'") return cmd } diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index c35368b296b3..352dabfe272f 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -117,6 +117,30 @@ func TestInitRecover(t *testing.T) { require.NoError(t, cmd.ExecuteContext(ctx)) } +func TestInitStakingBondDenom(t *testing.T) { + home := t.TempDir() + logger := log.NewNopLogger() + cfg, err := genutiltest.CreateDefaultTendermintConfig(home) + require.NoError(t, err) + + serverCtx := server.NewContext(viper.New(), cfg, logger) + interfaceRegistry := types.NewInterfaceRegistry() + marshaler := codec.NewProtoCodec(interfaceRegistry) + clientCtx := client.Context{}. + WithCodec(marshaler). + WithLegacyAmino(makeCodec()). + WithHomeDir(home) + + ctx := context.Background() + ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) + ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx) + + cmd := genutilcli.InitCmd(testMbm, home) + + cmd.SetArgs([]string{"appnode-test", fmt.Sprintf("--%s=%s --%s=testtoken", cli.HomeFlag, home, genutilcli.FlagStakingBondDenom)}) + require.NoError(t, cmd.ExecuteContext(ctx)) +} + func TestEmptyState(t *testing.T) { home := t.TempDir() logger := log.NewNopLogger() From a4ad11eec99eec6d321082f9bda0c4804724778f Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 28 Jun 2021 10:40:44 -0400 Subject: [PATCH 03/15] conflicts --- CHANGELOG.md | 4 + docs/core/proto-docs.md | 52 +- proto/cosmos/bank/v1beta1/query.proto | 39 +- x/bank/keeper/grpc_query.go | 58 ++ x/bank/keeper/grpc_query_test.go | 94 ++- x/bank/types/query.pb.go | 892 ++++++++++++++++++++++++-- x/bank/types/query.pb.gw.go | 116 ++++ 7 files changed, 1181 insertions(+), 74 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 513b3030cf5e..e453291ed962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Features + +* [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. + ### Improvements * [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10393) Add `HasSupply` method to bank keeper to ensure that input denom actually exists on chain. diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 7d876f4e91c0..b4028a933896 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -89,12 +89,15 @@ - [GenesisState](#cosmos.bank.v1beta1.GenesisState) - [cosmos/bank/v1beta1/query.proto](#cosmos/bank/v1beta1/query.proto) + - [DenomOwner](#cosmos.bank.v1beta1.DenomOwner) - [QueryAllBalancesRequest](#cosmos.bank.v1beta1.QueryAllBalancesRequest) - [QueryAllBalancesResponse](#cosmos.bank.v1beta1.QueryAllBalancesResponse) - [QueryBalanceRequest](#cosmos.bank.v1beta1.QueryBalanceRequest) - [QueryBalanceResponse](#cosmos.bank.v1beta1.QueryBalanceResponse) - [QueryDenomMetadataRequest](#cosmos.bank.v1beta1.QueryDenomMetadataRequest) - [QueryDenomMetadataResponse](#cosmos.bank.v1beta1.QueryDenomMetadataResponse) + - [QueryDenomOwnersRequest](#cosmos.bank.v1beta1.QueryDenomOwnersRequest) + - [QueryDenomOwnersResponse](#cosmos.bank.v1beta1.QueryDenomOwnersResponse) - [QueryDenomsMetadataRequest](#cosmos.bank.v1beta1.QueryDenomsMetadataRequest) - [QueryDenomsMetadataResponse](#cosmos.bank.v1beta1.QueryDenomsMetadataResponse) - [QueryParamsRequest](#cosmos.bank.v1beta1.QueryParamsRequest) @@ -1717,6 +1720,19 @@ GenesisState defines the bank module's genesis state. + + +### DenomOwner + +DenomOwner defines structure representing an account that owns or holds a +particular denominated token. It contains the account address and account +balance of the denominated token. + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | address defines the address that owns a particular denomination. | +| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | balance is the balance of the denominated coin for an account. | + ### QueryAllBalancesRequest @@ -1812,6 +1828,40 @@ method. + + +### QueryDenomOwnersRequest +QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query, +which queries for a paginated set of all account holders of a particular +denomination. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | denom defines the coin denomination to query all account holders for. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | + + + + + + + + +### QueryDenomOwnersResponse +QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom_owners` | [DenomOwner](#cosmos.bank.v1beta1.DenomOwner) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + ### QueryDenomsMetadataRequest @@ -1956,6 +2006,7 @@ Query defines the gRPC querier service. | `Params` | [QueryParamsRequest](#cosmos.bank.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.bank.v1beta1.QueryParamsResponse) | Params queries the parameters of x/bank module. | GET|/cosmos/bank/v1beta1/params| | `DenomMetadata` | [QueryDenomMetadataRequest](#cosmos.bank.v1beta1.QueryDenomMetadataRequest) | [QueryDenomMetadataResponse](#cosmos.bank.v1beta1.QueryDenomMetadataResponse) | DenomsMetadata queries the client metadata of a given coin denomination. | GET|/cosmos/bank/v1beta1/denoms_metadata/{denom}| | `DenomsMetadata` | [QueryDenomsMetadataRequest](#cosmos.bank.v1beta1.QueryDenomsMetadataRequest) | [QueryDenomsMetadataResponse](#cosmos.bank.v1beta1.QueryDenomsMetadataResponse) | DenomsMetadata queries the client metadata for all registered coin denominations. | GET|/cosmos/bank/v1beta1/denoms_metadata| +| `DenomOwners` | [QueryDenomOwnersRequest](#cosmos.bank.v1beta1.QueryDenomOwnersRequest) | [QueryDenomOwnersResponse](#cosmos.bank.v1beta1.QueryDenomOwnersResponse) | DenomOwners queries for all account addresses that own a particular token denomination. | GET|/cosmos/bank/v1beta1/denom_owners/{denom}| @@ -8303,4 +8354,3 @@ Since: cosmos-sdk 0.43 | bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | | string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | | bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | - diff --git a/proto/cosmos/bank/v1beta1/query.proto b/proto/cosmos/bank/v1beta1/query.proto index 520ba0696412..3313a3b7c5ae 100644 --- a/proto/cosmos/bank/v1beta1/query.proto +++ b/proto/cosmos/bank/v1beta1/query.proto @@ -41,10 +41,17 @@ service Query { option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata/{denom}"; } - // DenomsMetadata queries the client metadata for all registered coin denominations. + // DenomsMetadata queries the client metadata for all registered coin + // denominations. rpc DenomsMetadata(QueryDenomsMetadataRequest) returns (QueryDenomsMetadataResponse) { option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata"; } + + // DenomOwners queries for all account addresses that own a particular token + // denomination. + rpc DenomOwners(QueryDenomOwnersRequest) returns (QueryDenomOwnersResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/denom_owners/{denom}"; + } } // QueryBalanceRequest is the request type for the Query/Balance RPC method. @@ -161,3 +168,33 @@ message QueryDenomMetadataResponse { // metadata describes and provides all the client information for the requested token. Metadata metadata = 1 [(gogoproto.nullable) = false]; } + +// QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query, +// which queries for a paginated set of all account holders of a particular +// denomination. +message QueryDenomOwnersRequest { + // denom defines the coin denomination to query all account holders for. + string denom = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// DenomOwner defines structure representing an account that owns or holds a +// particular denominated token. It contains the account address and account +// balance of the denominated token. +message DenomOwner { + // address defines the address that owns a particular denomination. + string address = 1; + + // balance is the balance of the denominated coin for an account. + cosmos.base.v1beta1.Coin balance = 2 [(gogoproto.nullable) = false]; +} + +// QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. +message QueryDenomOwnersResponse { + repeated DenomOwner denom_owners = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 02655aa2f595..53c192954f6a 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -164,3 +164,61 @@ func (k BaseKeeper) DenomMetadata(c context.Context, req *types.QueryDenomMetada Metadata: metadata, }, nil } + +func (k BaseKeeper) DenomOwners( + goCtx context.Context, + req *types.QueryDenomOwnersRequest, +) (*types.QueryDenomOwnersResponse, error) { + + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + if req.Denom == "" { + return nil, status.Error(codes.InvalidArgument, "empty denom") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + balancesStore := prefix.NewStore(store, types.BalancesPrefix) + + var denomOwners []*types.DenomOwner + pageRes, err := query.FilteredPaginate( + balancesStore, + req.Pagination, + func(key []byte, value []byte, accumulate bool) (bool, error) { + var balance sdk.Coin + if err := k.cdc.Unmarshal(value, &balance); err != nil { + return false, err + } + + if req.Denom != balance.Denom { + return false, nil + } + + if accumulate { + address, err := types.AddressFromBalancesStore(key) + if err != nil { + return false, err + } + + denomOwners = append( + denomOwners, + &types.DenomOwner{ + Address: address.String(), + Balance: balance, + }, + ) + } + + return true, nil + }, + ) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryDenomOwnersResponse{DenomOwners: denomOwners, Pagination: pageRes}, nil +} diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index 181506a6d7fb..4593d8585b4a 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -5,13 +5,12 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/simapp" - - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) func (suite *IntegrationTestSuite) TestQueryBalance() { @@ -305,3 +304,92 @@ func (suite *IntegrationTestSuite) QueryDenomMetadataRequest() { }) } } + +func (suite *IntegrationTestSuite) TestGRPCDenomOwners() { + ctx := suite.ctx + + authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) + suite.Require().NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) + + for i := 0; i < 10; i++ { + acc := authKeeper.NewAccountWithAddress(ctx, authtypes.NewModuleAddress(fmt.Sprintf("account-%d", i))) + authKeeper.SetAccount(ctx, acc) + + bal := sdk.NewCoins(sdk.NewCoin( + sdk.DefaultBondDenom, + sdk.TokensFromConsensusPower(initialPower/10, sdk.DefaultPowerReduction), + )) + suite.Require().NoError(keeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, acc.GetAddress(), bal)) + } + + testCases := map[string]struct { + req *types.QueryDenomOwnersRequest + expPass bool + numAddrs int + hasNext bool + total uint64 + }{ + "empty request": { + req: &types.QueryDenomOwnersRequest{}, + expPass: false, + }, + "invalid denom": { + req: &types.QueryDenomOwnersRequest{ + Denom: "foo", + }, + expPass: true, + numAddrs: 0, + hasNext: false, + total: 0, + }, + "valid request - page 1": { + req: &types.QueryDenomOwnersRequest{ + Denom: sdk.DefaultBondDenom, + Pagination: &query.PageRequest{ + Limit: 6, + CountTotal: true, + }, + }, + expPass: true, + numAddrs: 6, + hasNext: true, + total: 10, + }, + "valid request - page 2": { + req: &types.QueryDenomOwnersRequest{ + Denom: sdk.DefaultBondDenom, + Pagination: &query.PageRequest{ + Offset: 6, + Limit: 10, + CountTotal: true, + }, + }, + expPass: true, + numAddrs: 4, + hasNext: false, + total: 10, + }, + } + + for name, tc := range testCases { + suite.Run(name, func() { + resp, err := suite.queryClient.DenomOwners(gocontext.Background(), tc.req) + if tc.expPass { + suite.NoError(err) + suite.NotNil(resp) + suite.Len(resp.DenomOwners, tc.numAddrs) + suite.Equal(tc.total, resp.Pagination.Total) + + if tc.hasNext { + suite.NotNil(resp.Pagination.NextKey) + } else { + suite.Nil(resp.Pagination.NextKey) + } + } else { + suite.Require().Error(err) + } + }) + } + + suite.Require().True(true) +} diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index 2b9432192388..af6b3fee0003 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -685,6 +685,174 @@ func (m *QueryDenomMetadataResponse) GetMetadata() Metadata { return Metadata{} } +// QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query, +// which queries for a paginated set of all account holders of a particular +// denomination. +type QueryDenomOwnersRequest struct { + // denom defines the coin denomination to query all account holders for. + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryDenomOwnersRequest) Reset() { *m = QueryDenomOwnersRequest{} } +func (m *QueryDenomOwnersRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDenomOwnersRequest) ProtoMessage() {} +func (*QueryDenomOwnersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{14} +} +func (m *QueryDenomOwnersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomOwnersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomOwnersRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryDenomOwnersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomOwnersRequest.Merge(m, src) +} +func (m *QueryDenomOwnersRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomOwnersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomOwnersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomOwnersRequest proto.InternalMessageInfo + +func (m *QueryDenomOwnersRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *QueryDenomOwnersRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// DenomOwner defines structure representing an account that owns or holds a +// particular denominated token. It contains the account address and account +// balance of the denominated token. +type DenomOwner struct { + // address defines the address that owns a particular denomination. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // balance is the balance of the denominated coin for an account. + Balance types.Coin `protobuf:"bytes,2,opt,name=balance,proto3" json:"balance"` +} + +func (m *DenomOwner) Reset() { *m = DenomOwner{} } +func (m *DenomOwner) String() string { return proto.CompactTextString(m) } +func (*DenomOwner) ProtoMessage() {} +func (*DenomOwner) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{15} +} +func (m *DenomOwner) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DenomOwner) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DenomOwner.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DenomOwner) XXX_Merge(src proto.Message) { + xxx_messageInfo_DenomOwner.Merge(m, src) +} +func (m *DenomOwner) XXX_Size() int { + return m.Size() +} +func (m *DenomOwner) XXX_DiscardUnknown() { + xxx_messageInfo_DenomOwner.DiscardUnknown(m) +} + +var xxx_messageInfo_DenomOwner proto.InternalMessageInfo + +func (m *DenomOwner) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *DenomOwner) GetBalance() types.Coin { + if m != nil { + return m.Balance + } + return types.Coin{} +} + +// QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. +type QueryDenomOwnersResponse struct { + DenomOwners []*DenomOwner `protobuf:"bytes,1,rep,name=denom_owners,json=denomOwners,proto3" json:"denom_owners,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryDenomOwnersResponse) Reset() { *m = QueryDenomOwnersResponse{} } +func (m *QueryDenomOwnersResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDenomOwnersResponse) ProtoMessage() {} +func (*QueryDenomOwnersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{16} +} +func (m *QueryDenomOwnersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomOwnersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomOwnersResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryDenomOwnersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomOwnersResponse.Merge(m, src) +} +func (m *QueryDenomOwnersResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomOwnersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomOwnersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomOwnersResponse proto.InternalMessageInfo + +func (m *QueryDenomOwnersResponse) GetDenomOwners() []*DenomOwner { + if m != nil { + return m.DenomOwners + } + return nil +} + +func (m *QueryDenomOwnersResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryBalanceRequest)(nil), "cosmos.bank.v1beta1.QueryBalanceRequest") proto.RegisterType((*QueryBalanceResponse)(nil), "cosmos.bank.v1beta1.QueryBalanceResponse") @@ -700,64 +868,73 @@ func init() { proto.RegisterType((*QueryDenomsMetadataResponse)(nil), "cosmos.bank.v1beta1.QueryDenomsMetadataResponse") proto.RegisterType((*QueryDenomMetadataRequest)(nil), "cosmos.bank.v1beta1.QueryDenomMetadataRequest") proto.RegisterType((*QueryDenomMetadataResponse)(nil), "cosmos.bank.v1beta1.QueryDenomMetadataResponse") + proto.RegisterType((*QueryDenomOwnersRequest)(nil), "cosmos.bank.v1beta1.QueryDenomOwnersRequest") + proto.RegisterType((*DenomOwner)(nil), "cosmos.bank.v1beta1.DenomOwner") + proto.RegisterType((*QueryDenomOwnersResponse)(nil), "cosmos.bank.v1beta1.QueryDenomOwnersResponse") } func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) } var fileDescriptor_9c6fc1939682df13 = []byte{ - // 825 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x6f, 0xd3, 0x58, - 0x14, 0xcd, 0xeb, 0x4c, 0xd3, 0xf4, 0x46, 0x33, 0x8b, 0xd7, 0x8c, 0x26, 0x75, 0xa7, 0xc9, 0xc8, - 0x9d, 0x69, 0xd3, 0x92, 0xda, 0x4d, 0x8b, 0x54, 0xc1, 0x06, 0x35, 0x45, 0xb0, 0x40, 0xa8, 0x21, - 0xb0, 0x42, 0x42, 0xe8, 0x25, 0x31, 0x26, 0x6a, 0xe2, 0xe7, 0xe6, 0x39, 0x88, 0xaa, 0xaa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0x4c, 0xec, 0xf3, 0x49, 0x26, 0x76, 0x7b, 0x71, 0xe0, 0x57, - 0xf5, 0xa1, 0x68, 0xcb, 0x3f, 0xae, 0x95, 0x38, 0xff, 0xe7, 0xb8, 0xf6, 0x33, 0x00, 0x00, 0xff, - 0xff, 0xa0, 0xfe, 0xe2, 0x92, 0x11, 0x0b, 0x00, 0x00, + // 917 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x4f, 0x3b, 0x45, + 0x18, 0xee, 0xa0, 0x94, 0xf2, 0x56, 0x3d, 0x0c, 0x35, 0x96, 0x45, 0x5a, 0xb3, 0x28, 0xb4, 0x50, + 0x76, 0x29, 0x98, 0x10, 0xbc, 0x18, 0x8a, 0xd1, 0x83, 0x31, 0xd4, 0xea, 0xc9, 0xc4, 0x90, 0x69, + 0xbb, 0xae, 0x0d, 0xed, 0xce, 0xd2, 0xd9, 0x8a, 0x84, 0x90, 0x18, 0x13, 0x13, 0x4f, 0x6a, 0xe2, + 0xc1, 0x83, 0x31, 0xc1, 0x8b, 0x46, 0x3f, 0x09, 0x07, 0x0f, 0x44, 0x2f, 0x9e, 0xd4, 0x80, 0x07, + 0x3f, 0x86, 0xe9, 0xfc, 0xd9, 0xee, 0xb6, 0xdb, 0xed, 0x1e, 0xfa, 0x3b, 0xd1, 0x9d, 0x7d, 0xff, + 0x3c, 0xcf, 0x33, 0x33, 0xef, 0xb3, 0x40, 0xb1, 0x45, 0x59, 0x8f, 0x32, 0xb3, 0x49, 0x9c, 0x73, + 0xf3, 0x93, 0x6a, 0xd3, 0xf2, 0x48, 0xd5, 0xbc, 0x18, 0x58, 0xfd, 0x2b, 0xc3, 0xed, 0x53, 0x8f, + 0xe2, 0x15, 0x11, 0x60, 0x0c, 0x03, 0x0c, 0x19, 0xa0, 0x6d, 0xfb, 0x59, 0xcc, 0x12, 0xd1, 0x7e, + 0xae, 0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3, 0x50, 0x40, 0xdf, 0x3c, 0x16, 0x52, 0xf7, + 0x8f, 0x85, 0xd4, 0x9f, 0x8f, 0x85, 0xd4, 0x07, 0xe5, 0xd8, 0x6f, 0xaf, 0x4f, 0x45, 0x6d, 0xfe, + 0x09, 0xd6, 0x4c, 0xf3, 0xff, 0x2f, 0x0e, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x75, 0x2d, 0x5e, + 0xd9, 0x37, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -784,8 +961,12 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // DenomsMetadata queries the client metadata of a given coin denomination. DenomMetadata(ctx context.Context, in *QueryDenomMetadataRequest, opts ...grpc.CallOption) (*QueryDenomMetadataResponse, error) - // DenomsMetadata queries the client metadata for all registered coin denominations. + // DenomsMetadata queries the client metadata for all registered coin + // denominations. DenomsMetadata(ctx context.Context, in *QueryDenomsMetadataRequest, opts ...grpc.CallOption) (*QueryDenomsMetadataResponse, error) + // DenomOwners queries for all account addresses that own a particular token + // denomination. + DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error) } type queryClient struct { @@ -859,6 +1040,15 @@ func (c *queryClient) DenomsMetadata(ctx context.Context, in *QueryDenomsMetadat return out, nil } +func (c *queryClient) DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error) { + out := new(QueryDenomOwnersResponse) + err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/DenomOwners", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Balance queries the balance of a single coin for a single account. @@ -873,8 +1063,12 @@ type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // DenomsMetadata queries the client metadata of a given coin denomination. DenomMetadata(context.Context, *QueryDenomMetadataRequest) (*QueryDenomMetadataResponse, error) - // DenomsMetadata queries the client metadata for all registered coin denominations. + // DenomsMetadata queries the client metadata for all registered coin + // denominations. DenomsMetadata(context.Context, *QueryDenomsMetadataRequest) (*QueryDenomsMetadataResponse, error) + // DenomOwners queries for all account addresses that own a particular token + // denomination. + DenomOwners(context.Context, *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -902,6 +1096,9 @@ func (*UnimplementedQueryServer) DenomMetadata(ctx context.Context, req *QueryDe func (*UnimplementedQueryServer) DenomsMetadata(ctx context.Context, req *QueryDenomsMetadataRequest) (*QueryDenomsMetadataResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DenomsMetadata not implemented") } +func (*UnimplementedQueryServer) DenomOwners(ctx context.Context, req *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DenomOwners not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1033,6 +1230,24 @@ func _Query_DenomsMetadata_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Query_DenomOwners_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDenomOwnersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DenomOwners(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.bank.v1beta1.Query/DenomOwners", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DenomOwners(ctx, req.(*QueryDenomOwnersRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.bank.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -1065,6 +1280,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "DenomsMetadata", Handler: _Query_DenomsMetadata_Handler, }, + { + MethodName: "DenomOwners", + Handler: _Query_DenomOwners_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/bank/v1beta1/query.proto", @@ -1583,6 +1802,137 @@ func (m *QueryDenomMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *QueryDenomOwnersRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryDenomOwnersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomOwnersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DenomOwner) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DenomOwner) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DenomOwner) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Balance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDenomOwnersResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryDenomOwnersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomOwnersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.DenomOwners) > 0 { + for iNdEx := len(m.DenomOwners) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DenomOwners[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1792,20 +2142,71 @@ func (m *QueryDenomMetadataResponse) Size() (n int) { return n } -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryBalanceRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { +func (m *QueryDenomOwnersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *DenomOwner) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Balance.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryDenomOwnersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.DenomOwners) > 0 { + for _, e := range m.DenomOwners { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryBalanceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { return ErrIntOverflowQuery } if iNdEx >= l { @@ -3111,6 +3512,359 @@ func (m *QueryDenomMetadataResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryDenomOwnersRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryDenomOwnersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomOwnersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DenomOwner) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DenomOwner: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DenomOwner: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryDenomOwnersResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryDenomOwnersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomOwnersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomOwners", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomOwners = append(m.DenomOwners, &DenomOwner{}) + if err := m.DenomOwners[len(m.DenomOwners)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bank/types/query.pb.gw.go b/x/bank/types/query.pb.gw.go index 4cd12b258912..c9b15fdda0de 100644 --- a/x/bank/types/query.pb.gw.go +++ b/x/bank/types/query.pb.gw.go @@ -373,6 +373,78 @@ func local_request_Query_DenomsMetadata_0(ctx context.Context, marshaler runtime } +var ( + filter_Query_DenomOwners_0 = &utilities.DoubleArray{Encoding: map[string]int{"denom": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_DenomOwners_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomOwnersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DenomOwners_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DenomOwners(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DenomOwners_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomOwnersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DenomOwners_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DenomOwners(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -519,6 +591,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_DenomOwners_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DenomOwners_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DenomOwners_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -700,6 +792,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_DenomOwners_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_DenomOwners_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DenomOwners_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -717,6 +829,8 @@ var ( pattern_Query_DenomMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "denoms_metadata", "denom"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_DenomsMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "bank", "v1beta1", "denoms_metadata"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_DenomOwners_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "denom_owners", "denom"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -733,4 +847,6 @@ var ( forward_Query_DenomMetadata_0 = runtime.ForwardResponseMessage forward_Query_DenomsMetadata_0 = runtime.ForwardResponseMessage + + forward_Query_DenomOwners_0 = runtime.ForwardResponseMessage ) From 410b3be23440fccd0486063a78d38f019ec59a8e Mon Sep 17 00:00:00 2001 From: atheeshp <59333759+atheeshp@users.noreply.github.com> Date: Mon, 9 Aug 2021 21:48:19 +0530 Subject: [PATCH 04/15] conflicts --- CHANGELOG.md | 2 +- client/context.go | 10 --- docs/ru/readme.md | 12 +--- x/auth/client/testutil/suite.go | 111 ++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 21 deletions(-) mode change 100644 => 100755 docs/ru/readme.md diff --git a/CHANGELOG.md b/CHANGELOG.md index e453291ed962..742883c22927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,11 +40,11 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. - ### Improvements * [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10393) Add `HasSupply` method to bank keeper to ensure that input denom actually exists on chain. * [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `staking-bond-denom` to specify the staking bond denomination value when initializing a new chain. +* [\#9837](https://github.com/cosmos/cosmos-sdk/issues/9837) `--generate-only` flag will accept the keyname now. ### Bug Fixes diff --git a/client/context.go b/client/context.go index eedbdf6fdb65..e49a335cc8b1 100644 --- a/client/context.go +++ b/client/context.go @@ -11,7 +11,6 @@ import ( "gopkg.in/yaml.v2" "github.com/gogo/protobuf/proto" - "github.com/pkg/errors" rpcclient "github.com/tendermint/tendermint/rpc/client" "github.com/cosmos/cosmos-sdk/codec" @@ -338,15 +337,6 @@ func GetFromFields(kr keyring.Keyring, from string, genOnly bool) (sdk.AccAddres return nil, "", 0, nil } - if genOnly { - addr, err := sdk.AccAddressFromBech32(from) - if err != nil { - return nil, "", 0, errors.Wrap(err, "must provide a valid Bech32 address in generate-only mode") - } - - return addr, "", 0, nil - } - var info keyring.Info if addr, err := sdk.AccAddressFromBech32(from); err == nil { info, err = kr.KeyByAddress(addr) diff --git a/docs/ru/readme.md b/docs/ru/readme.md old mode 100644 new mode 100755 index 6168cbe76500..e6906b2b89b3 --- a/docs/ru/readme.md +++ b/docs/ru/readme.md @@ -1,11 +1,3 @@ ---- -parent: - order: false ---- +# Cosmos SDK Documentation (Russian) -# RU - -::: warning -**DEPRECATED** -This documentation is not complete and it's outdated. Please use the English version. -::: +A Russian translation of the Cosmos SDK documentation is not available for this version. If you would like to help with translating, please see [Internationalization](https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOCS_README.md#internationalization). A `v0.39` version of the documentation can be found [here](https://github.com/cosmos/cosmos-sdk/tree/v0.39.3/docs/ru). diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 626e0130f42a..dfaecb8bb76e 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -30,6 +30,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx/signing" authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli" bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -106,6 +107,116 @@ func (s *IntegrationTestSuite) TestCLIValidateSignatures() { s.Require().EqualError(err, "signatures validation failed") } +func (s *IntegrationTestSuite) TestCLISignGenOnly() { + val := s.network.Validators[0] + val2 := s.network.Validators[1] + + info, err := val.ClientCtx.Keyring.KeyByAddress(val.Address) + s.Require().NoError(err) + keyName := info.GetName() + + account, err := val.ClientCtx.AccountRetriever.GetAccount(val.ClientCtx, info.GetAddress()) + s.Require().NoError(err) + + sendTokens := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))) + args := []string{ + keyName, // from keyname + val2.Address.String(), + sendTokens.String(), + fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), // shouldn't break if we use keyname with --generate-only flag + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + } + generatedStd, err := clitestutil.ExecTestCLICmd(val.ClientCtx, bank.NewSendTxCmd(), args) + s.Require().NoError(err) + opFile := testutil.WriteToNewTempFile(s.T(), generatedStd.String()) + + commonArgs := []string{ + fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), + fmt.Sprintf("--%s=%s", flags.FlagHome, strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)), + fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), + } + + cases := []struct { + name string + args []string + expErr bool + errMsg string + }{ + { + "offline mode with account-number, sequence and keyname (valid)", + []string{ + opFile.Name(), + fmt.Sprintf("--%s=true", flags.FlagOffline), + fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName), + fmt.Sprintf("--%s=%d", flags.FlagAccountNumber, account.GetAccountNumber()), + fmt.Sprintf("--%s=%d", flags.FlagSequence, account.GetSequence()), + }, + false, + "", + }, + { + "offline mode with account-number, sequence and address key (valid)", + []string{ + opFile.Name(), + fmt.Sprintf("--%s=true", flags.FlagOffline), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%d", flags.FlagAccountNumber, account.GetAccountNumber()), + fmt.Sprintf("--%s=%d", flags.FlagSequence, account.GetSequence()), + }, + false, + "", + }, + { + "offline mode without account-number and keyname (invalid)", + []string{ + opFile.Name(), + fmt.Sprintf("--%s=true", flags.FlagOffline), + fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName), + fmt.Sprintf("--%s=%d", flags.FlagSequence, account.GetSequence()), + }, + true, + `required flag(s) "account-number" not set`, + }, + { + "offline mode without sequence and keyname (invalid)", + []string{ + opFile.Name(), + fmt.Sprintf("--%s=true", flags.FlagOffline), + fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName), + fmt.Sprintf("--%s=%d", flags.FlagAccountNumber, account.GetAccountNumber()), + }, + true, + `required flag(s) "sequence" not set`, + }, + { + "offline mode without account-number, sequence and keyname (invalid)", + []string{ + opFile.Name(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName), + fmt.Sprintf("--%s=true", flags.FlagOffline), + }, + true, + `required flag(s) "account-number", "sequence" not set`, + }, + } + + for _, tc := range cases { + cmd := authcli.GetSignCommand() + tmcli.PrepareBaseCmd(cmd, "", "") + out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.errMsg) + } else { + s.Require().NoError(err) + signedTx := testutil.WriteToNewTempFile(s.T(), out.String()) + _, err := TxBroadcastExec(val.ClientCtx, signedTx.Name()) + s.Require().NoError(err) + } + } +} + func (s *IntegrationTestSuite) TestCLISignBatch() { val := s.network.Validators[0] var sendTokens = sdk.NewCoins( From ac74e8df7ed76e3e0420832f3641e8f21d46c110 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Mon, 8 Nov 2021 23:49:13 +0000 Subject: [PATCH 05/15] conflicts --- CHANGELOG.md | 1 + store/cachekv/store.go | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 742883c22927..c30e8c2420e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. ### Improvements +* [\#10486](https://github.com/cosmos/cosmos-sdk/pull/10486) store/cachekv's `Store.Write` conservatively looks up keys, but also uses the [map clearing idiom](https://bencher.orijtech.com/perfclinic/mapclearing/) to reduce the RAM usage, CPU time usage, and garbage collection pressure from clearing maps, instead of allocating new maps. * [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10393) Add `HasSupply` method to bank keeper to ensure that input denom actually exists on chain. * [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `staking-bond-denom` to specify the staking bond denomination value when initializing a new chain. * [\#9837](https://github.com/cosmos/cosmos-sdk/issues/9837) `--generate-only` flag will accept the keyname now. diff --git a/store/cachekv/store.go b/store/cachekv/store.go index fa9a601d4779..3e9afff83bc9 100644 --- a/store/cachekv/store.go +++ b/store/cachekv/store.go @@ -118,22 +118,34 @@ func (store *Store) Write() { // TODO: Consider allowing usage of Batch, which would allow the write to // at least happen atomically. for _, key := range keys { - cacheValue := store.cache[key] - - switch { - case store.isDeleted(key): + if store.isDeleted(key) { + // We use []byte(key) instead of conv.UnsafeStrToBytes because we cannot + // be sure if the underlying store might do a save with the byteslice or + // not. Once we get confirmation that .Delete is guaranteed not to + // save the byteslice, then we can assume only a read-only copy is sufficient. store.parent.Delete([]byte(key)) - case cacheValue.value == nil: - // Skip, it already doesn't exist in parent. - default: + continue + } + + cacheValue := store.cache[key] + if cacheValue.value != nil { + // It already exists in the parent, hence delete it. store.parent.Set([]byte(key), cacheValue.value) } } - // Clear the cache - store.cache = make(map[string]*cValue) - store.deleted = make(map[string]struct{}) - store.unsortedCache = make(map[string]struct{}) + // Clear the cache using the map clearing idiom + // and not allocating fresh objects. + // Please see https://bencher.orijtech.com/perfclinic/mapclearing/ + for key := range store.cache { + delete(store.cache, key) + } + for key := range store.deleted { + delete(store.deleted, key) + } + for key := range store.unsortedCache { + delete(store.unsortedCache, key) + } store.sortedCache = dbm.NewMemDB() } From e9522e5ddca67f4d9589d96b0a0af7c2a34391ad Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Tue, 31 Aug 2021 01:07:31 -0400 Subject: [PATCH 06/15] fix --- CHANGELOG.md | 2 ++ x/auth/keeper/account.go | 6 ++++++ x/auth/keeper/keeper.go | 3 +++ x/auth/spec/04_keepers.md | 3 +++ x/bank/keeper/send.go | 8 ++++---- x/bank/types/expected_keepers.go | 1 + 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c30e8c2420e9..96bf07a01646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `AuthKeeper` interface in `x/auth` now includes a function `HasAccount`. * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. ### Improvements @@ -99,6 +100,7 @@ Security Release. No breaking changes related to 0.44.x. ### Improvements +* (x/bank) [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `BankKeeper.SendCoins` now takes less execution time. * (deps) [\#9956](https://github.com/cosmos/cosmos-sdk/pull/9956) Bump Tendermint to [v0.34.12](https://github.com/tendermint/tendermint/releases/tag/v0.34.12). ### Deprecated diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index a26ea6427bc4..7474e93a5469 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -25,6 +25,12 @@ func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc types.AccountI) types.Ac return acc } +// HasAccount implements AccountKeeperI. +func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool { + store := ctx.KVStore(ak.key) + return store.Has(types.AddressStoreKey(addr)) +} + // GetAccount implements AccountKeeperI. func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI { store := ctx.KVStore(ak.key) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index b690c33c37ce..a73f97dc3446 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -22,6 +22,9 @@ type AccountKeeperI interface { // Return a new account with the next account number. Does not save the new account to the store. NewAccount(sdk.Context, types.AccountI) types.AccountI + // Check if an account exists in the store. + HasAccount(sdk.Context, sdk.AccAddress) bool + // Retrieve an account from the store. GetAccount(sdk.Context, sdk.AccAddress) types.AccountI diff --git a/x/auth/spec/04_keepers.md b/x/auth/spec/04_keepers.md index 8e4466cd68ab..fcd995447542 100644 --- a/x/auth/spec/04_keepers.md +++ b/x/auth/spec/04_keepers.md @@ -20,6 +20,9 @@ type AccountKeeperI interface { // Return a new account with the next account number. Does not save the new account to the store. NewAccount(sdk.Context, types.AccountI) types.AccountI + // Check if an account exists in the store. + HasAccount(sdk.Context, sdk.AccAddress) bool + // Retrieve an account from the store. GetAccount(sdk.Context, sdk.AccAddress) types.AccountI diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 369fa631c447..80fdb555b332 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -118,8 +118,8 @@ func (k BaseSendKeeper) InputOutputCoins(ctx sdk.Context, inputs []types.Input, // // NOTE: This should ultimately be removed in favor a more flexible approach // such as delegated fee messages. - acc := k.ak.GetAccount(ctx, outAddress) - if acc == nil { + accExists := k.ak.HasAccount(ctx, outAddress) + if !accExists { defer telemetry.IncrCounter(1, "new", "account") k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, outAddress)) } @@ -145,8 +145,8 @@ func (k BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAd // // NOTE: This should ultimately be removed in favor a more flexible approach // such as delegated fee messages. - acc := k.ak.GetAccount(ctx, toAddr) - if acc == nil { + accExists := k.ak.HasAccount(ctx, toAddr) + if !accExists { defer telemetry.IncrCounter(1, "new", "account") k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, toAddr)) } diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 7307864b86e6..23ca020a34b0 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -13,6 +13,7 @@ type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI GetAllAccounts(ctx sdk.Context) []types.AccountI + HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool SetAccount(ctx sdk.Context, acc types.AccountI) IterateAccounts(ctx sdk.Context, process func(types.AccountI) bool) From 4a2510744e3fb1f865b245bbaaf32d3beac2e398 Mon Sep 17 00:00:00 2001 From: Tyler <48813565+technicallyty@users.noreply.github.com> Date: Mon, 19 Jul 2021 08:20:27 -0700 Subject: [PATCH 07/15] conflicts --- CHANGELOG.md | 1 + client/keys/rename.go | 67 +++++++++++++++++++++++ client/keys/rename_test.go | 98 ++++++++++++++++++++++++++++++++++ client/keys/root.go | 1 + client/keys/root_test.go | 2 +- crypto/keyring/keyring.go | 52 +++++++++++++++--- crypto/keyring/keyring_test.go | 85 +++++++++++++++++++++++++++++ 7 files changed, 298 insertions(+), 8 deletions(-) create mode 100644 client/keys/rename.go create mode 100644 client/keys/rename_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 96bf07a01646..734efe8e57f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (client/keys) [\#9407](https://github.com/cosmos/cosmos-sdk/pull/9601) Added `keys rename` CLI command and `Keyring.Rename` interface method to rename a key in the keyring. * [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `AuthKeeper` interface in `x/auth` now includes a function `HasAccount`. * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. ### Improvements diff --git a/client/keys/rename.go b/client/keys/rename.go new file mode 100644 index 000000000000..2c5f11263de0 --- /dev/null +++ b/client/keys/rename.go @@ -0,0 +1,67 @@ +package keys + +import ( + "bufio" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/input" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/spf13/cobra" +) + +// RenameKeyCommand renames a key from the key store. +func RenameKeyCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "rename ", + Short: "Rename an existing key", + Long: `Rename a key from the Keybase backend. + +Note that renaming offline or ledger keys will rename +only the public key references stored locally, i.e. +private keys stored in a ledger device cannot be renamed with the CLI. +`, + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + buf := bufio.NewReader(cmd.InOrStdin()) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + oldName, newName := args[0], args[1] + + info, err := clientCtx.Keyring.Key(oldName) + if err != nil { + return err + } + + // confirm rename, unless -y is passed + if skip, _ := cmd.Flags().GetBool(flagYes); !skip { + prompt := fmt.Sprintf("Key reference will be renamed from %s to %s. Continue?", args[0], args[1]) + if yes, err := input.GetConfirmation(prompt, buf, cmd.ErrOrStderr()); err != nil { + return err + } else if !yes { + return nil + } + } + + if err := clientCtx.Keyring.Rename(oldName, newName); err != nil { + return err + } + + if info.GetType() == keyring.TypeLedger || info.GetType() == keyring.TypeOffline { + cmd.PrintErrln("Public key reference renamed") + return nil + } + + cmd.PrintErrln(fmt.Sprintf("Key was successfully renamed from %s to %s", oldName, newName)) + + return nil + }, + } + + cmd.Flags().BoolP(flagYes, "y", false, "Skip confirmation prompt when renaming offline or ledger key references") + + return cmd +} diff --git a/client/keys/rename_test.go b/client/keys/rename_test.go new file mode 100644 index 000000000000..37d15ecba25e --- /dev/null +++ b/client/keys/rename_test.go @@ -0,0 +1,98 @@ +package keys + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "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" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func Test_runRenameCmd(t *testing.T) { + // temp keybase + kbHome := t.TempDir() + cmd := RenameKeyCommand() + cmd.Flags().AddFlagSet(Commands(kbHome).PersistentFlags()) + mockIn := testutil.ApplyMockIODiscardOutErr(cmd) + + yesF, _ := cmd.Flags().GetBool(flagYes) + require.False(t, yesF) + + fakeKeyName1 := "runRenameCmd_Key1" + fakeKeyName2 := "runRenameCmd_Key2" + + path := sdk.GetConfig().GetFullBIP44Path() + + kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn) + require.NoError(t, err) + + // put fakeKeyName1 in keyring + _, err = kb.NewAccount(fakeKeyName1, testutil.TestMnemonic, "", path, hd.Secp256k1) + require.NoError(t, err) + + clientCtx := client.Context{}. + WithKeyringDir(kbHome). + WithKeyring(kb) + + ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) + + // rename a key 'blah' which doesnt exist + cmd.SetArgs([]string{"blah", "blaah", fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome)}) + err = cmd.ExecuteContext(ctx) + require.Error(t, err) + require.EqualError(t, err, "blah.info: key not found") + + // User confirmation missing + cmd.SetArgs([]string{ + fakeKeyName1, + "nokey", + fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome), + fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), + }) + err = cmd.Execute() + require.Error(t, err) + require.Equal(t, "EOF", err.Error()) + + oldKey, err := kb.Key(fakeKeyName1) + require.NoError(t, err) + + // add a confirmation + cmd.SetArgs([]string{ + fakeKeyName1, + fakeKeyName2, + fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome), + fmt.Sprintf("--%s=true", flagYes), + fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), + }) + require.NoError(t, cmd.Execute()) + + // key1 is gone + _, err = kb.Key(fakeKeyName1) + require.Error(t, err) + + // key2 exists now + renamedKey, err := kb.Key(fakeKeyName2) + require.NoError(t, err) + + require.Equal(t, oldKey.GetPubKey(), renamedKey.GetPubKey()) + require.Equal(t, oldKey.GetType(), renamedKey.GetType()) + require.Equal(t, oldKey.GetAddress(), renamedKey.GetAddress()) + require.Equal(t, oldKey.GetAlgo(), renamedKey.GetAlgo()) + + // try to rename key1 but it doesnt exist anymore so error + cmd.SetArgs([]string{ + fakeKeyName1, + fakeKeyName2, + fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome), + fmt.Sprintf("--%s=true", flagYes), + fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), + }) + require.Error(t, cmd.Execute()) +} diff --git a/client/keys/root.go b/client/keys/root.go index 938a0d53a14c..e8b1ef156987 100644 --- a/client/keys/root.go +++ b/client/keys/root.go @@ -45,6 +45,7 @@ The pass backend requires GnuPG: https://gnupg.org/ ListKeysCmd(), ShowKeysCmd(), DeleteKeyCommand(), + RenameKeyCommand(), ParseKeyStringCommand(), MigrateCommand(), ) diff --git a/client/keys/root_test.go b/client/keys/root_test.go index b6c2f5f88f48..f66ae9265de6 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, 9, len(rootCommands.Commands())) + assert.Equal(t, 10, len(rootCommands.Commands())) } diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index f96c8635243c..8619c9f48482 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -41,6 +41,9 @@ const ( keyringFileDirName = "keyring-file" keyringTestDirName = "keyring-test" passKeyringPrefix = "keyring-%s" + + // temporary pass phrase for exporting a key during a key rename + passPhrase = "temp" ) var ( @@ -64,6 +67,9 @@ type Keyring interface { Delete(uid string) error DeleteByAddress(address sdk.Address) error + // Rename an existing key from the Keyring + Rename(from string, to string) error + // NewMnemonic generates a new mnemonic, derives a hierarchical deterministic key from it, and // persists the key to storage. Returns the generated mnemonic and the key Info. // It returns an error if it fails to generate a key for the given algo type, or if @@ -288,8 +294,10 @@ func (ks keystore) ExportPrivKeyArmorByAddress(address sdk.Address, encryptPassp } func (ks keystore) ImportPrivKey(uid, armor, passphrase string) error { - if _, err := ks.Key(uid); err == nil { - return fmt.Errorf("cannot overwrite key: %s", uid) + if k, err := ks.Key(uid); err == nil { + if uid == k.GetName() { + return fmt.Errorf("cannot overwrite key: %s", uid) + } } privKey, algo, err := crypto.UnarmorDecryptPrivKey(armor, passphrase) @@ -429,6 +437,30 @@ func (ks keystore) DeleteByAddress(address sdk.Address) error { return nil } +func (ks keystore) Rename(oldName, newName string) error { + _, err := ks.Key(newName) + if err == nil { + return fmt.Errorf("rename failed: %s already exists in the keyring", newName) + } + + armor, err := ks.ExportPrivKeyArmor(oldName, passPhrase) + if err != nil { + return err + } + + err = ks.ImportPrivKey(newName, armor, passPhrase) + if err != nil { + return err + } + + err = ks.Delete(oldName) + if err != nil { + return err + } + + return nil +} + func (ks keystore) Delete(uid string) error { info, err := ks.Key(uid) if err != nil { @@ -786,16 +818,22 @@ func (ks keystore) writeInfo(info Info) error { } // existsInDb returns true if key is in DB. Error is returned only when we have error -// different thant ErrKeyNotFound +// different than ErrKeyNotFound func (ks keystore) existsInDb(info Info) (bool, error) { - if _, err := ks.db.Get(addrHexKeyAsString(info.GetAddress())); err == nil { - return true, nil // address lookup succeeds - info exists + if item, err := ks.db.Get(addrHexKeyAsString(info.GetAddress())); err == nil { + if item.Key == info.GetName() { + return true, nil // address lookup succeeds - info exists + } + return false, nil } else if err != keyring.ErrKeyNotFound { return false, err // received unexpected error - returns error } - if _, err := ks.db.Get(infoKey(info.GetName())); err == nil { - return true, nil // uid lookup succeeds - info exists + if item, err := ks.db.Get(infoKey(info.GetName())); err == nil { + if item.Key == info.GetName() { + return true, nil // uid lookup succeeds - info exists + } + return false, nil } else if err != keyring.ErrKeyNotFound { return false, err // received unexpected error - returns } diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index 2f8e928e7a7e..c2a0df70a7d9 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -1153,6 +1153,72 @@ func TestBackendConfigConstructors(t *testing.T) { require.Equal(t, "keyring-test", backend.PassPrefix) } +func TestRenameKey(t *testing.T) { + testCases := []struct { + name string + run func(Keyring) + }{ + { + name: "rename a key", + run: func(kr Keyring) { + oldKeyUID, newKeyUID := "old", "new" + oldKeyInfo := newKeyInfo(t, kr, oldKeyUID) + err := kr.Rename(oldKeyUID, newKeyUID) // rename from "old" to "new" + require.NoError(t, err) + newInfo, err := kr.Key(newKeyUID) // new key should be in keyring + require.NoError(t, err) + requireEqualRenamedKey(t, newInfo, oldKeyInfo) // oldinfo and newinfo should be the same + oldKeyInfo, err = kr.Key(oldKeyUID) // old key should be gone from keyring + require.Error(t, err) + }, + }, + { + name: "cant rename a key that doesnt exist", + run: func(kr Keyring) { + err := kr.Rename("bogus", "bogus2") + require.Error(t, err) + }, + }, + { + name: "cant rename a key to an already existing key name", + run: func(kr Keyring) { + key1, key2 := "existingKey", "existingKey2" // create 2 keys + newKeyInfo(t, kr, key1) + newKeyInfo(t, kr, key2) + err := kr.Rename(key2, key1) + require.Equal(t, fmt.Errorf("rename failed: %s already exists in the keyring", key1), err) + assertKeysExist(t, kr, key1, key2) // keys should still exist after failed rename + }, + }, + { + name: "cant rename key to itself", + run: func(kr Keyring) { + keyName := "keyName" + newKeyInfo(t, kr, keyName) + err := kr.Rename(keyName, keyName) + require.Equal(t, fmt.Errorf("rename failed: %s already exists in the keyring", keyName), err) + assertKeysExist(t, kr, keyName) + }, + }, + } + + for _, tc := range testCases { + tc := tc + kr := newKeyring(t, "testKeyring") + t.Run(tc.name, func(t *testing.T) { + tc.run(kr) + }) + } +} + +func requireEqualRenamedKey(t *testing.T, newKey, oldKey Info) { + require.NotEqual(t, newKey.GetName(), oldKey.GetName()) + require.Equal(t, newKey.GetAddress(), oldKey.GetAddress()) + require.Equal(t, newKey.GetPubKey(), oldKey.GetPubKey()) + require.Equal(t, newKey.GetAlgo(), oldKey.GetAlgo()) + require.Equal(t, newKey.GetType(), oldKey.GetType()) +} + func requireEqualInfo(t *testing.T, key Info, mnemonic Info) { require.Equal(t, key.GetName(), mnemonic.GetName()) require.Equal(t, key.GetAddress(), mnemonic.GetAddress()) @@ -1161,4 +1227,23 @@ func requireEqualInfo(t *testing.T, key Info, mnemonic Info) { require.Equal(t, key.GetType(), mnemonic.GetType()) } +func newKeyring(t *testing.T, name string) Keyring { + kr, err := New(name, "test", t.TempDir(), nil) + require.NoError(t, err) + return kr +} + +func newKeyInfo(t *testing.T, kr Keyring, name string) Info { + keyInfo, _, err := kr.NewMnemonic(name, English, sdk.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) + require.NoError(t, err) + return keyInfo +} + +func assertKeysExist(t *testing.T, kr Keyring, names ...string) { + for _, n := range names { + _, err := kr.Key(n) + require.NoError(t, err) + } +} + func accAddr(info Info) sdk.AccAddress { return info.GetAddress() } From 5541a8d10e2a38e0f7c9edc3b3b618d4611a1926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Tue, 14 Sep 2021 18:12:49 +0200 Subject: [PATCH 08/15] conflicts --- CHANGELOG.md | 1 + x/bank/keeper/keeper.go | 9 ++++++++- x/bank/keeper/keeper_test.go | 25 ++++++++++++++----------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 734efe8e57f5..8f470ad6703d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (x/bank) [\#10134](https://github.com/cosmos/cosmos-sdk/pull/10134) Add `HasDenomMetadata` function to bank `Keeper` to check if a client coin denom metadata exists in state. * (client/keys) [\#9407](https://github.com/cosmos/cosmos-sdk/pull/9601) Added `keys rename` CLI command and `Keyring.Rename` interface method to rename a key in the keyring. * [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `AuthKeeper` interface in `x/auth` now includes a function `HasAccount`. * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 482c002870bd..d3c1b5f8fce2 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -29,6 +29,7 @@ type Keeper interface { GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bool) GetDenomMetaData(ctx sdk.Context, denom string) (types.Metadata, bool) + HasDenomMetaData(ctx sdk.Context, denom string) bool SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metadata) IterateAllDenomMetaData(ctx sdk.Context, cb func(types.Metadata) bool) @@ -74,7 +75,6 @@ func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.P supply = supply.Add(sdk.NewCoin(string(key), amount)) return nil }) - if err != nil { return nil, nil, err } @@ -239,6 +239,13 @@ func (k BaseKeeper) GetDenomMetaData(ctx sdk.Context, denom string) (types.Metad return metadata, true } +// HasDenomMetaData checks if the denomination metadata exists in store. +func (k BaseKeeper) HasDenomMetaData(ctx sdk.Context, denom string) bool { + store := ctx.KVStore(k.storeKey) + store = prefix.NewStore(store, types.DenomMetadataPrefix) + return store.Has([]byte(denom)) +} + // GetAllDenomMetaData retrieves all denominations metadata func (k BaseKeeper) GetAllDenomMetaData(ctx sdk.Context) []types.Metadata { denomMetaData := make([]types.Metadata, 0) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 93f355260bf8..a720b08765d9 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -1002,6 +1002,8 @@ func (suite *IntegrationTestSuite) TestSetDenomMetaData() { actualMetadata, found := app.BankKeeper.GetDenomMetaData(ctx, metadata[1].Base) suite.Require().True(found) + found = app.BankKeeper.HasDenomMetaData(ctx, metadata[1].Base) + suite.Require().True(found) suite.Require().Equal(metadata[1].GetBase(), actualMetadata.GetBase()) suite.Require().Equal(metadata[1].GetDisplay(), actualMetadata.GetDisplay()) suite.Require().Equal(metadata[1].GetDescription(), actualMetadata.GetDescription()) @@ -1134,18 +1136,19 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { } func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata { - return []types.Metadata{{ - Name: "Cosmos Hub Atom", - Symbol: "ATOM", - Description: "The native staking token of the Cosmos Hub.", - DenomUnits: []*types.DenomUnit{ - {"uatom", uint32(0), []string{"microatom"}}, - {"matom", uint32(3), []string{"milliatom"}}, - {"atom", uint32(6), nil}, + return []types.Metadata{ + { + Name: "Cosmos Hub Atom", + Symbol: "ATOM", + Description: "The native staking token of the Cosmos Hub.", + DenomUnits: []*types.DenomUnit{ + {"uatom", uint32(0), []string{"microatom"}}, + {"matom", uint32(3), []string{"milliatom"}}, + {"atom", uint32(6), nil}, + }, + Base: "uatom", + Display: "atom", }, - Base: "uatom", - Display: "atom", - }, { Name: "Token", Symbol: "TOKEN", From 9cfa8d716fae6ba042e0272e3444f79a1ea7c332 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Tue, 7 Sep 2021 10:37:02 -0400 Subject: [PATCH 09/15] perf: Improve the speed of coins.String() (#10076) ## Description Speedup coins.String() and coin.String() In my local benchmarks, this >2x improves the time for balances with 1 coin, and further improves speed for strings with many balances. I did not benchmark on the two coin usecase --- ### 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 - n/a - [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) - covered by existing - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - seems sufficiently clear - [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) --- CHANGELOG.md | 1 + types/coin.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f470ad6703d..c6c9d14247a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -102,6 +102,7 @@ Security Release. No breaking changes related to 0.44.x. ### Improvements +* (types) [\#10076](https://github.com/cosmos/cosmos-sdk/pull/10076) Significantly speedup and lower allocations for `Coins.String()`. * (x/bank) [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `BankKeeper.SendCoins` now takes less execution time. * (deps) [\#9956](https://github.com/cosmos/cosmos-sdk/pull/9956) Bump Tendermint to [v0.34.12](https://github.com/tendermint/tendermint/releases/tag/v0.34.12). diff --git a/types/coin.go b/types/coin.go index 81afb173e29e..d4d22642d21b 100644 --- a/types/coin.go +++ b/types/coin.go @@ -34,7 +34,7 @@ func NewInt64Coin(denom string, amount int64) Coin { // String provides a human-readable representation of a coin func (coin Coin) String() string { - return fmt.Sprintf("%v%v", coin.Amount, coin.Denom) + return fmt.Sprintf("%v%s", coin.Amount, coin.Denom) } // Validate returns an error if the Coin has a negative amount or if @@ -190,13 +190,18 @@ func (coins Coins) MarshalJSON() ([]byte, error) { func (coins Coins) String() string { if len(coins) == 0 { return "" + } else if len(coins) == 1 { + return coins[0].String() } - out := "" - for _, coin := range coins { - out += fmt.Sprintf("%v,", coin.String()) + // Build the string with a string builder + var out strings.Builder + for _, coin := range coins[:len(coins)-1] { + out.WriteString(coin.String()) + out.WriteByte(',') } - return out[:len(out)-1] + out.WriteString(coins[len(coins)-1].String()) + return out.String() } // Validate checks that the Coins are sorted, have positive amount, with a valid and unique From dc298a0f752e440387eb6865a86d61b17923a787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= Date: Sun, 14 Nov 2021 18:06:51 +0100 Subject: [PATCH 10/15] changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6c9d14247a8..86eea0195a86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. ### Improvements +* (types) [\#10076](https://github.com/cosmos/cosmos-sdk/pull/10076) Significantly speedup and lower allocations for `Coins.String()`. +* (x/bank) [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `BankKeeper.SendCoins` now takes less execution time. * [\#10486](https://github.com/cosmos/cosmos-sdk/pull/10486) store/cachekv's `Store.Write` conservatively looks up keys, but also uses the [map clearing idiom](https://bencher.orijtech.com/perfclinic/mapclearing/) to reduce the RAM usage, CPU time usage, and garbage collection pressure from clearing maps, instead of allocating new maps. * [\#10393](https://github.com/cosmos/cosmos-sdk/pull/10393) Add `HasSupply` method to bank keeper to ensure that input denom actually exists on chain. * [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `staking-bond-denom` to specify the staking bond denomination value when initializing a new chain. @@ -102,8 +104,6 @@ Security Release. No breaking changes related to 0.44.x. ### Improvements -* (types) [\#10076](https://github.com/cosmos/cosmos-sdk/pull/10076) Significantly speedup and lower allocations for `Coins.String()`. -* (x/bank) [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `BankKeeper.SendCoins` now takes less execution time. * (deps) [\#9956](https://github.com/cosmos/cosmos-sdk/pull/9956) Bump Tendermint to [v0.34.12](https://github.com/tendermint/tendermint/releases/tag/v0.34.12). ### Deprecated From d6d146a7a783de1ae4047d8c3fd14614af585647 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Tue, 31 Aug 2021 01:07:31 -0400 Subject: [PATCH 11/15] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86eea0195a86..abdf30ac93bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. ### Improvements +* [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `AuthKeeper` interface in `x/auth` now includes a function `HasAccount`. * (types) [\#10076](https://github.com/cosmos/cosmos-sdk/pull/10076) Significantly speedup and lower allocations for `Coins.String()`. * (x/bank) [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `BankKeeper.SendCoins` now takes less execution time. * [\#10486](https://github.com/cosmos/cosmos-sdk/pull/10486) store/cachekv's `Store.Write` conservatively looks up keys, but also uses the [map clearing idiom](https://bencher.orijtech.com/perfclinic/mapclearing/) to reduce the RAM usage, CPU time usage, and garbage collection pressure from clearing maps, instead of allocating new maps. @@ -104,6 +105,7 @@ Security Release. No breaking changes related to 0.44.x. ### Improvements +* (x/bank) [\#10022](https://github.com/cosmos/cosmos-sdk/pull/10022) `BankKeeper.SendCoins` now takes less execution time. * (deps) [\#9956](https://github.com/cosmos/cosmos-sdk/pull/9956) Bump Tendermint to [v0.34.12](https://github.com/tendermint/tendermint/releases/tag/v0.34.12). ### Deprecated From fa732ae46d119d0f4cdc53fc430d52c74ac4e663 Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Fri, 9 Jul 2021 20:08:25 +0530 Subject: [PATCH 12/15] changelog --- CHANGELOG.md | 1 + store/types/gas.go | 14 +++++++++++++- store/types/gas_test.go | 15 +++++++++++++-- x/auth/ante/setup_test.go | 6 ++++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abdf30ac93bd..f998afaee417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * [\#10414](https://github.com/cosmos/cosmos-sdk/pull/10414) Use `sdk.GetConfig().GetFullBIP44Path()` instead `sdk.FullFundraiserPath` to generate key +* [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. ## [v0.44.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.3) - 2021-10-21 diff --git a/store/types/gas.go b/store/types/gas.go index bf44e717d095..dc7e44b3c2e4 100644 --- a/store/types/gas.go +++ b/store/types/gas.go @@ -41,6 +41,7 @@ type ErrorGasOverflow struct { type GasMeter interface { GasConsumed() Gas GasConsumedToLimit() Gas + GasRemaining() Gas Limit() Gas ConsumeGas(amount Gas, descriptor string) RefundGas(amount Gas, descriptor string) @@ -66,6 +67,13 @@ func (g *basicGasMeter) GasConsumed() Gas { return g.consumed } +func (g *basicGasMeter) GasRemaining() Gas { + if g.IsPastLimit() { + return 0 + } + return g.limit - g.consumed +} + func (g *basicGasMeter) Limit() Gas { return g.limit } @@ -145,8 +153,12 @@ func (g *infiniteGasMeter) GasConsumedToLimit() Gas { return g.consumed } +func (g *infiniteGasMeter) GasRemaining() Gas { + return math.MaxUint64 +} + func (g *infiniteGasMeter) Limit() Gas { - return 0 + return math.MaxUint64 } func (g *infiniteGasMeter) ConsumeGas(amount Gas, descriptor string) { diff --git a/store/types/gas_test.go b/store/types/gas_test.go index 8a02df4cfa18..f4b5a6abe5ba 100644 --- a/store/types/gas_test.go +++ b/store/types/gas_test.go @@ -10,13 +10,16 @@ import ( func TestInfiniteGasMeter(t *testing.T) { t.Parallel() meter := NewInfiniteGasMeter() - require.Equal(t, uint64(0), meter.Limit()) + require.Equal(t, uint64(math.MaxUint64), meter.Limit()) + require.Equal(t, uint64(math.MaxUint64), meter.GasRemaining()) require.Equal(t, uint64(0), meter.GasConsumed()) require.Equal(t, uint64(0), meter.GasConsumedToLimit()) meter.ConsumeGas(10, "consume 10") + require.Equal(t, uint64(math.MaxUint64), meter.GasRemaining()) require.Equal(t, uint64(10), meter.GasConsumed()) require.Equal(t, uint64(10), meter.GasConsumedToLimit()) meter.RefundGas(1, "refund 1") + require.Equal(t, uint64(math.MaxUint64), meter.GasRemaining()) require.Equal(t, uint64(9), meter.GasConsumed()) require.False(t, meter.IsPastLimit()) require.False(t, meter.IsOutOfGas()) @@ -48,6 +51,7 @@ func TestGasMeter(t *testing.T) { used += usage require.NotPanics(t, func() { meter.ConsumeGas(usage, "") }, "Not exceeded limit but panicked. tc #%d, usage #%d", tcnum, unum) require.Equal(t, used, meter.GasConsumed(), "Gas consumption not match. tc #%d, usage #%d", tcnum, unum) + require.Equal(t, tc.limit-used, meter.GasRemaining(), "Gas left not match. tc #%d, usage #%d", tcnum, unum) require.Equal(t, used, meter.GasConsumedToLimit(), "Gas consumption (to limit) not match. tc #%d, usage #%d", tcnum, unum) require.False(t, meter.IsPastLimit(), "Not exceeded limit but got IsPastLimit() true") if unum < len(tc.usage)-1 { @@ -60,13 +64,20 @@ func TestGasMeter(t *testing.T) { require.Panics(t, func() { meter.ConsumeGas(1, "") }, "Exceeded but not panicked. tc #%d", tcnum) require.Equal(t, meter.GasConsumedToLimit(), meter.Limit(), "Gas consumption (to limit) not match limit") require.Equal(t, meter.GasConsumed(), meter.Limit()+1, "Gas consumption not match limit+1") + require.Equal(t, uint64(0), meter.GasRemaining()) require.NotPanics(t, func() { meter.RefundGas(1, "refund 1") }) - require.Equal(t, meter.GasConsumed(), meter.Limit(), "Gas consumption not match limit+1") + require.Equal(t, meter.GasConsumed(), meter.Limit(), "Gas consumption not match with limit") + require.Equal(t, uint64(0), meter.GasRemaining()) require.Panics(t, func() { meter.RefundGas(meter.GasConsumed()+1, "refund greater than consumed") }) + require.NotPanics(t, func() { meter.RefundGas(meter.GasConsumed(), "refund consumed gas") }) + require.Equal(t, meter.Limit(), meter.GasRemaining()) + meter2 := NewGasMeter(math.MaxUint64) + require.Equal(t, uint64(math.MaxUint64), meter2.GasRemaining()) meter2.ConsumeGas(Gas(math.MaxUint64/2), "consume half max uint64") + require.Equal(t, Gas(math.MaxUint64-(math.MaxUint64/2)), meter2.GasRemaining()) require.Panics(t, func() { meter2.ConsumeGas(Gas(math.MaxUint64/2)+2, "panic") }) } } diff --git a/x/auth/ante/setup_test.go b/x/auth/ante/setup_test.go index 4942665cac04..86c633d899fa 100644 --- a/x/auth/ante/setup_test.go +++ b/x/auth/ante/setup_test.go @@ -1,6 +1,8 @@ package ante_test import ( + "math" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,8 +35,8 @@ func (suite *AnteTestSuite) TestSetup() { // Set height to non-zero value for GasMeter to be set suite.ctx = suite.ctx.WithBlockHeight(1) - // Context GasMeter Limit not set - suite.Require().Equal(uint64(0), suite.ctx.GasMeter().Limit(), "GasMeter set with limit before setup") + // Context GasMeter Limit set to MaxUint64 + suite.Require().Equal(uint64(math.MaxUint64), suite.ctx.GasMeter().Limit(), "GasMeter set with limit other than MaxUint64 before setup") newCtx, err := antehandler(suite.ctx, tx, false) suite.Require().Nil(err, "SetUpContextDecorator returned error") From 00e90260dc52201789abda72a09a3ebf5c6323e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Mon, 5 Jul 2021 08:36:35 -0400 Subject: [PATCH 13/15] changelog --- CHANGELOG.md | 1 + types/int.go | 7 ++++++- types/int_test.go | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f998afaee417..1bda3d6545a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10414](https://github.com/cosmos/cosmos-sdk/pull/10414) Use `sdk.GetConfig().GetFullBIP44Path()` instead `sdk.FullFundraiserPath` to generate key * [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. +* (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt` ## [v0.44.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.3) - 2021-10-21 diff --git a/types/int.go b/types/int.go index 0708cda58112..04b808fbc69d 100644 --- a/types/int.go +++ b/types/int.go @@ -101,8 +101,13 @@ func NewIntFromUint64(n uint64) Int { return Int{b} } -// NewIntFromBigInt constructs Int from big.Int +// NewIntFromBigInt constructs Int from big.Int. If the provided big.Int is nil, +// it returns an empty instance. This function panics if the bit length is > 256. func NewIntFromBigInt(i *big.Int) Int { + if i == nil { + return Int{} + } + if i.BitLen() > maxBitLen { panic("NewIntFromBigInt() out of bound") } diff --git a/types/int_test.go b/types/int_test.go index 359c4859b6dc..a6ec8c6d48bd 100644 --- a/types/int_test.go +++ b/types/int_test.go @@ -91,6 +91,9 @@ func (s *intTestSuite) TestIntPanic() { s.Require().Panics(func() { intmax.Add(sdk.OneInt()) }) s.Require().Panics(func() { intmin.Sub(sdk.OneInt()) }) + s.Require().NotPanics(func() { sdk.NewIntFromBigInt(nil) }) + s.Require().True(sdk.NewIntFromBigInt(nil).IsNil()) + // Division-by-zero check s.Require().Panics(func() { i1.Quo(sdk.NewInt(0)) }) From ea6e4557542b16ec3048d2d39e18fde11e74306b Mon Sep 17 00:00:00 2001 From: Sai Kumar <17549398+gsk967@users.noreply.github.com> Date: Thu, 11 Nov 2021 16:07:33 +0530 Subject: [PATCH 14/15] changelog --- CHANGELOG.md | 3 +- x/bank/types/query.pb.go | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bda3d6545a4..4d147e49ede7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,10 +55,11 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* [\#10394](https://github.com/cosmos/cosmos-sdk/issues/10394) Fixes issue related to grpc-gateway of account balance by + ibc-denom. * [\#10414](https://github.com/cosmos/cosmos-sdk/pull/10414) Use `sdk.GetConfig().GetFullBIP44Path()` instead `sdk.FullFundraiserPath` to generate key * [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. * (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt` - ## [v0.44.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.3) - 2021-10-21 ### Improvements diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index af6b3fee0003..8e5b1c194b5c 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -876,6 +876,7 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) } var fileDescriptor_9c6fc1939682df13 = []byte{ +<<<<<<< HEAD // 917 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x4f, 0x3b, 0x45, 0x18, 0xee, 0xa0, 0x94, 0xf2, 0x56, 0x3d, 0x0c, 0x35, 0x96, 0x45, 0x5a, 0xb3, 0x28, 0xb4, 0x50, @@ -935,6 +936,69 @@ var fileDescriptor_9c6fc1939682df13 = []byte{ 0x8f, 0x85, 0xd4, 0x9f, 0x8f, 0x85, 0xd4, 0x07, 0xe5, 0xd8, 0x6f, 0xaf, 0x4f, 0x45, 0x6d, 0xfe, 0x09, 0xd6, 0x4c, 0xf3, 0xff, 0x2f, 0x0e, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x75, 0x2d, 0x5e, 0xd9, 0x37, 0x0d, 0x00, 0x00, +======= + // 953 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0xce, 0x14, 0x36, 0x6d, 0x5f, 0x80, 0xc3, 0x6c, 0x10, 0xad, 0xcb, 0x26, 0xc8, 0x0b, 0xdb, + 0x76, 0xb7, 0xb5, 0xdb, 0x2c, 0x12, 0x2c, 0x17, 0xd4, 0x2c, 0x82, 0x03, 0x42, 0x5b, 0xbc, 0x9c, + 0x90, 0x50, 0x35, 0x49, 0x8c, 0xb1, 0x9a, 0x78, 0xbc, 0x19, 0x87, 0x25, 0xaa, 0x56, 0x42, 0x9c, + 0x38, 0x01, 0x12, 0x17, 0x24, 0x84, 0x58, 0x2e, 0x20, 0x38, 0xf3, 0x47, 0xf4, 0xc0, 0x61, 0x45, + 0x2f, 0x9c, 0x00, 0xb5, 0x1c, 0xf8, 0x33, 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, 0x8f, + 0xa3, 0xd6, 0xec, 0x04, 0x59, 0xfd, 0xd3, 0xb0, 0x0b, 0xdb, 0x23, 0xae, 0x17, 0x25, 0x2e, 0x8b, + 0xee, 0x64, 0xe2, 0x92, 0xd2, 0x88, 0x23, 0xdd, 0x29, 0x63, 0xad, 0xbe, 0x23, 0xf0, 0x54, 0x7a, + 0xd4, 0xd0, 0x79, 0x99, 0x27, 0x67, 0x9f, 0xb1, 0x57, 0xdc, 0x01, 0xb1, 0xee, 0x48, 0xac, 0xd7, + 0xe8, 0xf3, 0x45, 0xb0, 0xd2, 0x6f, 0x08, 0x54, 0x12, 0xad, 0x2d, 0xef, 0xca, 0x4f, 0x37, 0xfe, + 0xbc, 0x2b, 0x9f, 0xd1, 0x2f, 0xcd, 0x7d, 0x09, 0xed, 0x06, 0xdd, 0x9e, 0x0d, 0x0d, 0x5b, 0xa9, + 0xd6, 0xb0, 0x79, 0xfb, 0xf4, 0xbc, 0x46, 0x1e, 0x9d, 0xd7, 0xc8, 0x9f, 0xe7, 0x35, 0xf2, 0xc5, + 0x45, 0xad, 0xf4, 0xe8, 0xa2, 0x56, 0xfa, 0xed, 0xa2, 0x56, 0x7a, 0x77, 0x3b, 0xf7, 0xb3, 0xec, + 0x23, 0x15, 0x5b, 0x7e, 0x9d, 0xb5, 0xca, 0xf2, 0xef, 0xca, 0xcd, 0x7f, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x40, 0x2b, 0xe5, 0x20, 0xa1, 0x0d, 0x00, 0x00, +>>>>>>> 99c5230fa... fix: query account balance by ibc denom (#10394) } // Reference imports to suppress errors if they are not otherwise used. From 49c8b5f365fff4f871bfadabbf992d80c7d14d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= Date: Sun, 14 Nov 2021 18:29:22 +0100 Subject: [PATCH 15/15] fix --- client/docs/swagger-ui/swagger.yaml | 237 ++++++++++++++++++++-------- 1 file changed, 168 insertions(+), 69 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 4419c7b9f62a..73e16c53e936 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -4623,6 +4623,7 @@ paths: /cosmos/auth/v1beta1/accounts: get: summary: Accounts returns all the existing accounts + description: 'Since: cosmos-sdk 0.43' operationId: Accounts responses: '200': @@ -4829,6 +4830,9 @@ paths: description: >- QueryAccountsResponse is the response type for the Query/Accounts RPC method. + + + Since: cosmos-sdk 0.43 default: description: An unexpected error response schema: @@ -5070,6 +5074,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -5810,13 +5817,16 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean format: boolean tags: - Query - '/cosmos/bank/v1beta1/balances/{address}/{denom}': + '/cosmos/bank/v1beta1/balances/{address}/by_denom': get: summary: Balance queries the balance of a single coin for a single account. operationId: Balance @@ -5874,8 +5884,8 @@ paths: type: string - name: denom description: denom is the coin denom to query balances for. - in: path - required: true + in: query + required: false type: string tags: - Query @@ -6028,6 +6038,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -6104,6 +6117,7 @@ paths: displayed in clients. name: type: string + description: 'Since: cosmos-sdk 0.43' title: 'name defines the name of the token (eg: Cosmos Atom)' symbol: type: string @@ -6112,18 +6126,9 @@ paths: (eg: ATOM). This can be the same as the display. - uri: - type: string - description: >- - URI to a document (on or off-chain) that contains - additional information. Optional. - uri_hash: - type: string - description: >- - URIHash is a sha256 hash of a document pointed by URI. - It's used to verify that - the document didn't change. Optional. + + Since: cosmos-sdk 0.43 description: |- Metadata represents a struct that describes a basic token. @@ -6227,6 +6232,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -6299,6 +6307,7 @@ paths: displayed in clients. name: type: string + description: 'Since: cosmos-sdk 0.43' title: 'name defines the name of the token (eg: Cosmos Atom)' symbol: type: string @@ -6307,18 +6316,9 @@ paths: ATOM). This can be the same as the display. - uri: - type: string - description: >- - URI to a document (on or off-chain) that contains - additional information. Optional. - uri_hash: - type: string - description: >- - URIHash is a sha256 hash of a document pointed by URI. - It's used to verify that - the document didn't change. Optional. + + Since: cosmos-sdk 0.43 description: |- Metadata represents a struct that describes a basic token. @@ -6445,7 +6445,10 @@ paths: signatures required by gogoproto. title: supply is the supply of the coins pagination: - description: pagination defines the pagination in the response. + description: |- + pagination defines the pagination in the response. + + Since: cosmos-sdk 0.43 type: object properties: next_key: @@ -6541,6 +6544,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -8204,6 +8210,7 @@ paths: title: Module is the type for VersionInfo cosmos_sdk_version: type: string + title: 'Since: cosmos-sdk 0.43' description: VersionInfo is the type for the GetNodeInfoResponse message. description: >- GetNodeInfoResponse is the request type for the Query/GetNodeInfo @@ -9072,6 +9079,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -9549,6 +9559,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -10203,6 +10216,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -10661,6 +10677,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -11889,6 +11908,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -12669,6 +12691,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -13214,6 +13239,10 @@ paths: description: >- WeightedVoteOption defines a unit of vote for vote split. + + + Since: cosmos-sdk 0.43 + title: 'Since: cosmos-sdk 0.43' description: >- Vote defines a vote on a governance proposal. @@ -13488,6 +13517,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -13558,6 +13590,10 @@ paths: description: >- WeightedVoteOption defines a unit of vote for vote split. + + + Since: cosmos-sdk 0.43 + title: 'Since: cosmos-sdk 0.43' description: >- Vote defines a vote on a governance proposal. @@ -14202,6 +14238,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -14639,6 +14678,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -15047,6 +15089,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -15387,6 +15432,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -15986,6 +16034,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -18157,6 +18208,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -19008,6 +19062,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -19875,6 +19932,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -20418,6 +20478,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -21807,6 +21870,7 @@ paths: /cosmos/upgrade/v1beta1/module_versions: get: summary: ModuleVersions queries the list of module versions from state. + description: 'Since: cosmos-sdk 0.43' operationId: ModuleVersions responses: '200': @@ -21826,7 +21890,10 @@ paths: type: string format: uint64 title: consensus version of the app module - description: ModuleVersion specifies a module and its consensus version. + description: |- + ModuleVersion specifies a module and its consensus version. + + Since: cosmos-sdk 0.43 description: >- module_versions is a list of module names with their consensus versions. @@ -21835,6 +21902,9 @@ paths: Query/ModuleVersions RPC method. + + + Since: cosmos-sdk 0.43 default: description: An unexpected error response schema: @@ -22037,11 +22107,18 @@ paths: - Query '/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}': get: - summary: |- + summary: >- UpgradedConsensusState queries the consensus state that will serve + as a trusted kernel for the next version of this chain. It will only be + stored at the last height of this chain. + UpgradedConsensusState RPC not supported with legacy querier + + This rpc is deprecated now that IBC has its own replacement + + (https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) operationId: UpgradedConsensusState responses: '200': @@ -22052,6 +22129,7 @@ paths: upgraded_consensus_state: type: string format: byte + title: 'Since: cosmos-sdk 0.43' description: >- QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState @@ -22735,6 +22813,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -23410,6 +23491,9 @@ paths: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 in: query required: false type: boolean @@ -25070,6 +25154,9 @@ definitions: description: >- QueryAccountsResponse is the response type for the Query/Accounts RPC method. + + + Since: cosmos-sdk 0.43 cosmos.auth.v1beta1.QueryParamsResponse: type: object properties: @@ -25137,6 +25224,9 @@ definitions: description: >- reverse is set to true if results are to be returned in the descending order. + + + Since: cosmos-sdk 0.43 description: |- message SomeRequest { Foo some_parameter = 1; @@ -25598,6 +25688,7 @@ definitions: displayed in clients. name: type: string + description: 'Since: cosmos-sdk 0.43' title: 'name defines the name of the token (eg: Cosmos Atom)' symbol: type: string @@ -25606,18 +25697,9 @@ definitions: can be the same as the display. - uri: - type: string - description: >- - URI to a document (on or off-chain) that contains additional - information. Optional. - uri_hash: - type: string - description: >- - URIHash is a sha256 hash of a document pointed by URI. It's used to - verify that - the document didn't change. Optional. + + Since: cosmos-sdk 0.43 description: |- Metadata represents a struct that describes a basic token. @@ -25756,6 +25838,7 @@ definitions: displayed in clients. name: type: string + description: 'Since: cosmos-sdk 0.43' title: 'name defines the name of the token (eg: Cosmos Atom)' symbol: type: string @@ -25764,18 +25847,9 @@ definitions: This can be the same as the display. - uri: - type: string - description: >- - URI to a document (on or off-chain) that contains additional - information. Optional. - uri_hash: - type: string - description: >- - URIHash is a sha256 hash of a document pointed by URI. It's used - to verify that - the document didn't change. Optional. + + Since: cosmos-sdk 0.43 description: |- Metadata represents a struct that describes a basic token. @@ -25895,6 +25969,7 @@ definitions: displayed in clients. name: type: string + description: 'Since: cosmos-sdk 0.43' title: 'name defines the name of the token (eg: Cosmos Atom)' symbol: type: string @@ -25903,18 +25978,9 @@ definitions: ATOM). This can be the same as the display. - uri: - type: string - description: >- - URI to a document (on or off-chain) that contains additional - information. Optional. - uri_hash: - type: string - description: >- - URIHash is a sha256 hash of a document pointed by URI. It's used - to verify that - the document didn't change. Optional. + + Since: cosmos-sdk 0.43 description: |- Metadata represents a struct that describes a basic token. @@ -26009,7 +26075,10 @@ definitions: signatures required by gogoproto. title: supply is the supply of the coins pagination: - description: pagination defines the pagination in the response. + description: |- + pagination defines the pagination in the response. + + Since: cosmos-sdk 0.43 type: object properties: next_key: @@ -27436,6 +27505,7 @@ definitions: title: Module is the type for VersionInfo cosmos_sdk_version: type: string + title: 'Since: cosmos-sdk 0.43' description: VersionInfo is the type for the GetNodeInfoResponse message. description: >- GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC @@ -27875,6 +27945,7 @@ definitions: title: Module is the type for VersionInfo cosmos_sdk_version: type: string + title: 'Since: cosmos-sdk 0.43' description: VersionInfo is the type for the GetNodeInfoResponse message. tendermint.crypto.PublicKey: type: object @@ -31988,7 +32059,11 @@ definitions: - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. weight: type: string - description: WeightedVoteOption defines a unit of vote for vote split. + description: |- + WeightedVoteOption defines a unit of vote for vote split. + + Since: cosmos-sdk 0.43 + title: 'Since: cosmos-sdk 0.43' description: |- Vote defines a vote on a governance proposal. A Vote consists of a proposal ID, the voter, and the vote option. @@ -32048,7 +32123,11 @@ definitions: - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. weight: type: string - description: WeightedVoteOption defines a unit of vote for vote split. + description: |- + WeightedVoteOption defines a unit of vote for vote split. + + Since: cosmos-sdk 0.43 + title: 'Since: cosmos-sdk 0.43' description: |- Vote defines a vote on a governance proposal. A Vote consists of a proposal ID, the voter, and the vote option. @@ -32156,7 +32235,11 @@ definitions: - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. weight: type: string - description: WeightedVoteOption defines a unit of vote for vote split. + description: |- + WeightedVoteOption defines a unit of vote for vote split. + + Since: cosmos-sdk 0.43 + title: 'Since: cosmos-sdk 0.43' description: |- Vote defines a vote on a governance proposal. A Vote consists of a proposal ID, the voter, and the vote option. @@ -32208,7 +32291,10 @@ definitions: - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. weight: type: string - description: WeightedVoteOption defines a unit of vote for vote split. + description: |- + WeightedVoteOption defines a unit of vote for vote split. + + Since: cosmos-sdk 0.43 cosmos.mint.v1beta1.Params: type: object properties: @@ -37563,7 +37649,10 @@ definitions: tx_bytes: type: string format: byte - description: tx_bytes is the raw transaction. + description: |- + tx_bytes is the raw transaction. + + Since: cosmos-sdk 0.43 description: |- SimulateRequest is the request type for the Service.Simulate RPC method. @@ -38825,7 +38914,10 @@ definitions: type: string format: uint64 title: consensus version of the app module - description: ModuleVersion specifies a module and its consensus version. + description: |- + ModuleVersion specifies a module and its consensus version. + + Since: cosmos-sdk 0.43 cosmos.upgrade.v1beta1.Plan: type: object properties: @@ -39281,7 +39373,10 @@ definitions: type: string format: uint64 title: consensus version of the app module - description: ModuleVersion specifies a module and its consensus version. + description: |- + ModuleVersion specifies a module and its consensus version. + + Since: cosmos-sdk 0.43 description: >- module_versions is a list of module names with their consensus versions. @@ -39290,12 +39385,16 @@ definitions: Query/ModuleVersions RPC method. + + + Since: cosmos-sdk 0.43 cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse: type: object properties: upgraded_consensus_state: type: string format: byte + title: 'Since: cosmos-sdk 0.43' description: >- QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState