Skip to content

Commit 45d9cae

Browse files
mergify[bot]catShaarkcrodriguezvega
authored
chore: improve DenomTrace grpc (backport #1342) (#1504)
* 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 * fix conflicts Co-authored-by: khanh <50263489+catShaark@users.noreply.github.com> Co-authored-by: crodriguezvega <carlos@interchain.io>
1 parent a7f3278 commit 45d9cae

File tree

9 files changed

+68
-19
lines changed

9 files changed

+68
-19
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4646

4747
### Improvements
4848

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`.
4950
* (modules/core/04-channel) [\#1160](https://github.com/cosmos/ibc-go/pull/1160) Improve `uint64 -> string` performance in `Logger`.
5051
* (modules/core/04-channel) [\#1279](https://github.com/cosmos/ibc-go/pull/1279) Add selected channel version to MsgChanOpenInitResponse and MsgChanOpenTryResponse. Emit channel version during OpenInit/OpenTry
5152
* (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.

docs/client/swagger-ui/swagger.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ paths:
288288
format: byte
289289
parameters:
290290
- name: hash
291-
description: hash (in hex format) of the denomination trace information.
291+
description: >-
292+
hash (in hex format) or denom (full denom with ibc prefix) of the
293+
denomination trace information.
292294
in: path
293295
required: true
294296
type: string

docs/ibc/proto-docs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ method
638638

639639
| Field | Type | Label | Description |
640640
| ----- | ---- | ----- | ----------- |
641-
| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. |
641+
| `hash` | [string](#string) | | hash (in hex format) or denom (full denom with ibc prefix) of the denomination trace information. |
642642

643643

644644

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"github.com/cosmos/ibc-go/v3/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-
Use: "denom-trace [hash]",
18-
Short: "Query the denom trace info from a given trace hash",
19-
Long: "Query the denom trace info from a given trace hash",
17+
Use: "denom-trace [hash/denom]",
18+
Short: "Query the denom trace info from a given trace hash or ibc denom",
19+
Long: "Query the denom trace info from a given trace hash or ibc denom",
2020
Example: fmt.Sprintf("%s query ibc-transfer denom-trace 27A6394C3F9FF9C9DCF5DFFADF9BB5FE9A37C7E92B006199894CF1824DF9AC7C", version.AppName),
2121
Args: cobra.ExactArgs(1),
2222
RunE: func(cmd *cobra.Command, args []string) error {

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
"github.com/cosmos/cosmos-sdk/store/prefix"
89
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -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
@@ -22,37 +22,50 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() {
2222
expPass bool
2323
}{
2424
{
25-
"invalid hex hash",
25+
"success: correct ibc denom",
2626
func() {
27+
expTrace.Path = "transfer/channelToA/transfer/channelToB"
28+
expTrace.BaseDenom = "uatom"
29+
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
30+
2731
req = &types.QueryDenomTraceRequest{
28-
Hash: "!@#!@#!",
32+
Hash: expTrace.IBCDenom(),
2933
}
3034
},
31-
false,
35+
true,
3236
},
3337
{
34-
"not found denom trace",
38+
"success: correct hex hash",
3539
func() {
3640
expTrace.Path = "transfer/channelToA/transfer/channelToB"
3741
expTrace.BaseDenom = "uatom"
42+
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
43+
3844
req = &types.QueryDenomTraceRequest{
3945
Hash: expTrace.Hash().String(),
4046
}
4147
},
48+
true,
49+
},
50+
{
51+
"failure: invalid hash",
52+
func() {
53+
req = &types.QueryDenomTraceRequest{
54+
Hash: "!@#!@#!",
55+
}
56+
},
4257
false,
4358
},
4459
{
45-
"success",
60+
"failure: not found denom trace",
4661
func() {
4762
expTrace.Path = "transfer/channelToA/transfer/channelToB"
4863
expTrace.BaseDenom = "uatom"
49-
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
50-
5164
req = &types.QueryDenomTraceRequest{
52-
Hash: expTrace.Hash().String(),
65+
Hash: expTrace.IBCDenom(),
5366
}
5467
},
55-
true,
68+
false,
5669
},
5770
}
5871

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
@@ -40,7 +40,7 @@ service Query {
4040
// QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC
4141
// method
4242
message QueryDenomTraceRequest {
43-
// hash (in hex format) of the denomination trace information.
43+
// hash (in hex format) or denom (full denom with ibc prefix) of the denomination trace information.
4444
string hash = 1;
4545
}
4646

0 commit comments

Comments
 (0)