Skip to content

Commit d7989f1

Browse files
mergify[bot]catShaarkcrodriguezvega
authored
chore: improve DenomTrace grpc (backport #1342) (#1502)
* 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 <[email protected]> * Update modules/apps/transfer/keeper/grpc_query_test.go Co-authored-by: Carlos Rodriguez <[email protected]> * Update CHANGELOG.md Co-authored-by: Damian Nolan <[email protected]> * use TrimPrefix() in DenomTrace() * update migration doc Co-authored-by: Carlos Rodriguez <[email protected]> Co-authored-by: Damian Nolan <[email protected]> (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 <[email protected]> Co-authored-by: crodriguezvega <[email protected]>
1 parent f10135d commit d7989f1

9 files changed

Lines changed: 68 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4747

4848
### Improvements
4949

50+
* (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`.
5051
* (modules/core/04-channel) [\#1160](https://github.com/cosmos/ibc-go/pull/1160) Improve `uint64 -> string` performance in `Logger`.
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.
5253
* (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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ method
391391

392392
| Field | Type | Label | Description |
393393
| ----- | ---- | ----- | ----------- |
394-
| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. |
394+
| `hash` | [string](#string) | | hash (in hex format) or denom (full denom with ibc prefix) of the denomination trace information. |
395395

396396

397397

docs/migrations/v3-to-v4.md

Lines changed: 31 additions & 0 deletions
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"github.com/cosmos/ibc-go/v2/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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,50 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() {
2121
expPass bool
2222
}{
2323
{
24-
"invalid hex hash",
24+
"success: correct ibc denom",
2525
func() {
26+
expTrace.Path = "transfer/channelToA/transfer/channelToB"
27+
expTrace.BaseDenom = "uatom"
28+
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
29+
2630
req = &types.QueryDenomTraceRequest{
27-
Hash: "!@#!@#!",
31+
Hash: expTrace.IBCDenom(),
2832
}
2933
},
30-
false,
34+
true,
3135
},
3236
{
33-
"not found denom trace",
37+
"success: correct hex hash",
3438
func() {
3539
expTrace.Path = "transfer/channelToA/transfer/channelToB"
3640
expTrace.BaseDenom = "uatom"
41+
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
42+
3743
req = &types.QueryDenomTraceRequest{
3844
Hash: expTrace.Hash().String(),
3945
}
4046
},
47+
true,
48+
},
49+
{
50+
"failure: invalid hash",
51+
func() {
52+
req = &types.QueryDenomTraceRequest{
53+
Hash: "!@#!@#!",
54+
}
55+
},
4156
false,
4257
},
4358
{
44-
"success",
59+
"failure: not found denom trace",
4560
func() {
4661
expTrace.Path = "transfer/channelToA/transfer/channelToB"
4762
expTrace.BaseDenom = "uatom"
48-
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace)
49-
5063
req = &types.QueryDenomTraceRequest{
51-
Hash: expTrace.Hash().String(),
64+
Hash: expTrace.IBCDenom(),
5265
}
5366
},
54-
true,
67+
false,
5568
},
5669
}
5770

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)