Skip to content

Commit 10867bb

Browse files
catShaarkmergify[bot]
authored andcommitted
chore: improve DenomTrace grpc (#1342)
* change DenomTrace grpc * update CHANGELOG.md * minor * minor * minor * minor * minor * minor * Update modules/apps/transfer/keeper/grpc_query_test.go Co-authored-by: Carlos Rodriguez <carlos@interchain.io> * Update modules/apps/transfer/keeper/grpc_query_test.go Co-authored-by: Carlos Rodriguez <carlos@interchain.io> * Update CHANGELOG.md Co-authored-by: Damian Nolan <damiannolan@gmail.com> * use TrimPrefix() in DenomTrace() * update migration doc Co-authored-by: Carlos Rodriguez <carlos@interchain.io> Co-authored-by: Damian Nolan <damiannolan@gmail.com> (cherry picked from commit 23e7e7d) # Conflicts: # CHANGELOG.md # docs/ibc/proto-docs.md # docs/migrations/v3-to-v4.md # modules/apps/transfer/client/cli/query.go
1 parent 9e632cd commit 10867bb

File tree

9 files changed

+81
-15
lines changed

9 files changed

+81
-15
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
4444

4545
### Improvements
4646

47+
<<<<<<< HEAD
48+
=======
49+
* (transfer) [\#1342](https://github.com/cosmos/ibc-go/pull/1342) `DenomTrace` grpc now takes in either an `ibc denom` or a `hash` instead of only accepting a `hash`.
50+
* (modules/core/keeper) [\#1284](https://github.com/cosmos/ibc-go/pull/1284) Add sanity check for the keepers passed into `ibckeeper.NewKeeper`. `ibckeeper.NewKeeper` now panics if any of the keepers passed in is empty.
51+
* (middleware) [\#1022](https://github.com/cosmos/ibc-go/pull/1022) Add `GetAppVersion` to the ICS4Wrapper interface. This function should be used by IBC applications to obtain their own version since the version set in the channel structure may be wrapped many times by middleware.
52+
>>>>>>> 23e7e7d (chore: improve DenomTrace grpc (#1342))
4753
* (modules/core/04-channel) [\#1160](https://github.com/cosmos/ibc-go/pull/1160) Improve `uint64 -> string` performance in `Logger`.
4854
* (modules/core/keeper) [\#1284](https://github.com/cosmos/ibc-go/pull/1284) Add sanity check for the keepers passed into `ibckeeper.NewKeeper`. `ibckeeper.NewKeeper` now panics if any of the keepers passed in is empty.
4955
* (transfer) [\#1414](https://github.com/cosmos/ibc-go/pull/1414) Emitting Sender address from `fungible_token_packet` events in `OnRecvPacket` and `OnAcknowledgementPacket`.

docs/client/swagger-ui/swagger.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ paths:
235235
format: byte
236236
parameters:
237237
- name: hash
238-
description: hash (in hex format) of the denomination trace information.
238+
description: >-
239+
hash (in hex format) or denom (full denom with ibc prefix) of the
240+
denomination trace information.
239241
in: path
240242
required: true
241243
type: string

docs/ibc/proto-docs.md

+5
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,15 @@ chain parameters (with exception to latest height, frozen height, and chain-id).
539539

540540
| Field | Type | Label | Description |
541541
| ----- | ---- | ----- | ----------- |
542+
<<<<<<< HEAD
542543
| `title` | [string](#string) | | the title of the update proposal |
543544
| `description` | [string](#string) | | the description of the proposal |
544545
| `subject_client_id` | [string](#string) | | the client identifier for the client to be updated if the proposal passes |
545546
| `substitute_client_id` | [string](#string) | | the substitute client identifier for the client standing in for the subject client |
547+
=======
548+
| `hash` | [string](#string) | | hash (in hex format) or denom (full denom with ibc prefix) of the denomination trace information. |
549+
550+
>>>>>>> 23e7e7d (chore: improve DenomTrace grpc (#1342))
546551
547552

548553

docs/migrations/v3-to-v4.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Migrating from ibc-go v3 to v4
2+
3+
This document is intended to highlight significant changes which may require more information than presented in the CHANGELOG.
4+
Any changes that must be done by a user of ibc-go should be documented here.
5+
6+
There are four sections based on the four potential user groups of this document:
7+
- Chains
8+
- IBC Apps
9+
- Relayers
10+
- IBC Light Clients
11+
12+
**Note:** ibc-go supports golang semantic versioning and therefore all imports must be updated to bump the version number on major releases.
13+
```go
14+
github.com/cosmos/ibc-go/v3 -> github.com/cosmos/ibc-go/v4
15+
```
16+
17+
No genesis or in-place migrations required when upgrading from v1 or v2 of ibc-go.
18+
19+
## Chains
20+
21+
### IS04 - Channel
22+
23+
The `WriteAcknowledgement` API now takes the `exported.Acknowledgement` type instead of passing in the acknowledgement byte array directly.
24+
This is an API breaking change and as such IBC application developers will have to update any calls to `WriteAcknowledgement`.
25+
26+
The `OnChanOpenInit` application callback has been modified.
27+
The return signature now includes the application version as detailed in the latest IBC [spec changes](https://github.com/cosmos/ibc/pull/629).
28+
29+
## Relayers
30+
31+
When using the `DenomTrace` gRPC, the full IBC denomination with the `ibc/` prefix may now be passed in.

modules/apps/transfer/client/cli/query.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ import (
1111
"github.com/cosmos/ibc-go/modules/apps/transfer/types"
1212
)
1313

14-
// GetCmdQueryDenomTrace defines the command to query a a denomination trace from a given hash.
14+
// GetCmdQueryDenomTrace defines the command to query a a denomination trace from a given trace hash or ibc denom.
1515
func GetCmdQueryDenomTrace() *cobra.Command {
1616
cmd := &cobra.Command{
17+
<<<<<<< HEAD
1718
Use: "denom-trace [hash]",
1819
Short: "Query the denom trace info from a given trace hash",
1920
Long: "Query the denom trace info from a given trace hash",
2021
Example: fmt.Sprintf("%s query ibc-transfer denom-trace 27A6394C3F9FF9C9DCF5DFFADF9BB5FE9A37C7E92B006199894CF1824DF9AC7C", version.AppName),
22+
=======
23+
Use: "denom-trace [hash/denom]",
24+
Short: "Query the denom trace info from a given trace hash or ibc denom",
25+
Long: "Query the denom trace info from a given trace hash or ibc denom",
26+
Example: fmt.Sprintf("%s query ibc-transfer denom-trace [hash/denom]", version.AppName),
27+
>>>>>>> 23e7e7d (chore: improve DenomTrace grpc (#1342))
2128
Args: cobra.ExactArgs(1),
2229
RunE: func(cmd *cobra.Command, args []string) error {
2330
clientCtx, err := client.GetClientQueryContext(cmd)

modules/apps/transfer/keeper/grpc_query.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package keeper
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

78
"google.golang.org/grpc/codes"
89
"google.golang.org/grpc/status"
@@ -22,9 +23,10 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest)
2223
return nil, status.Error(codes.InvalidArgument, "empty request")
2324
}
2425

25-
hash, err := types.ParseHexHash(req.Hash)
26+
hash, err := types.ParseHexHash(strings.TrimPrefix(req.Hash, "ibc/"))
27+
2628
if err != nil {
27-
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash %s, %s", req.Hash, err))
29+
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash: %s, error: %s", hash.String(), err))
2830
}
2931

3032
ctx := sdk.UnwrapSDKContext(c)

modules/apps/transfer/keeper/grpc_query_test.go

+22-9
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,50 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() {
2020
expPass bool
2121
}{
2222
{
23-
"invalid hex hash",
23+
"success: correct ibc denom",
2424
func() {
25+
expTrace.Path = "transfer/channelToA/transfer/channelToB"
26+
expTrace.BaseDenom = "uatom"
27+
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
28+
2529
req = &types.QueryDenomTraceRequest{
26-
Hash: "!@#!@#!",
30+
Hash: expTrace.IBCDenom(),
2731
}
2832
},
29-
false,
33+
true,
3034
},
3135
{
32-
"not found denom trace",
36+
"success: correct hex hash",
3337
func() {
3438
expTrace.Path = "transfer/channelToA/transfer/channelToB"
3539
expTrace.BaseDenom = "uatom"
40+
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
41+
3642
req = &types.QueryDenomTraceRequest{
3743
Hash: expTrace.Hash().String(),
3844
}
3945
},
46+
true,
47+
},
48+
{
49+
"failure: invalid hash",
50+
func() {
51+
req = &types.QueryDenomTraceRequest{
52+
Hash: "!@#!@#!",
53+
}
54+
},
4055
false,
4156
},
4257
{
43-
"success",
58+
"failure: not found denom trace",
4459
func() {
4560
expTrace.Path = "transfer/channelToA/transfer/channelToB"
4661
expTrace.BaseDenom = "uatom"
47-
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
48-
4962
req = &types.QueryDenomTraceRequest{
50-
Hash: expTrace.Hash().String(),
63+
Hash: expTrace.IBCDenom(),
5164
}
5265
},
53-
true,
66+
false,
5467
},
5568
}
5669

modules/apps/transfer/types/query.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ibc/applications/transfer/v1/query.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ service Query {
3535
// QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC
3636
// method
3737
message QueryDenomTraceRequest {
38-
// hash (in hex format) of the denomination trace information.
38+
// hash (in hex format) or denom (full denom with ibc prefix) of the denomination trace information.
3939
string hash = 1;
4040
}
4141

0 commit comments

Comments
 (0)