Skip to content

Commit

Permalink
chore : add selected channel version to MsgChanOpenInitResponse and M…
Browse files Browse the repository at this point in the history
…sgChanOpenTryResponse (backport #1279) (#1374)

* chore : add selected channel version to MsgChanOpenInitResponse and MsgChanOpenTryResponse (#1279)

## Description
 - Add a version field to MsgChannelOpenInitResponse and MsgChannelOpenTryResponse in proto and gen proto
 - Set the selected channel version in the [MsgChannelOpenInitResponse](https://github.com/notional-labs/ibc-go/blob/ed7a082565fadb9ce27067fa1efb56c23fafc8ef/modules/core/keeper/msg_server.go#L197) and [MsgChannelOpenTryResponse](https://github.com/notional-labs/ibc-go/blob/ed7a082565fadb9ce27067fa1efb56c23fafc8ef/modules/core/keeper/msg_server.go#L237)

---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing)
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [ ] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Review `Codecov Report` in the comment section below once CI passes

closes: #1204
(cherry picked from commit a187803)

# Conflicts:
#	CHANGELOG.md
#	modules/core/04-channel/types/tx.pb.go

* fix conflict

* regenerate proto file

* go mod tidy

Co-authored-by: vuong <56973102+nguyenvuong1122000@users.noreply.github.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
3 people authored May 19, 2022
1 parent fa3526a commit c55d71f
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 83 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

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

### Features
Expand Down
6 changes: 6 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,7 @@ MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `channel_id` | [string](#string) | | |
| `version` | [string](#string) | | |



Expand Down Expand Up @@ -1933,6 +1934,11 @@ value will be ignored by core IBC.
MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `version` | [string](#string) | | |





Expand Down
2 changes: 2 additions & 0 deletions modules/core/04-channel/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func EmitChannelOpenInitEvent(ctx sdk.Context, portID string, channelID string,
sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId),
sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId),
sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]),
sdk.NewAttribute(types.AttributeVersion, channel.Version),
),
})

Expand All @@ -41,6 +42,7 @@ func EmitChannelOpenTryEvent(ctx sdk.Context, portID string, channelID string, c
sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId),
sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId),
sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]),
sdk.NewAttribute(types.AttributeVersion, channel.Version),
),
})
ctx.EventManager().EmitEvents(sdk.Events{
Expand Down
1 change: 1 addition & 0 deletions modules/core/04-channel/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
AttributeKeyConnectionID = "connection_id"
AttributeKeyPortID = "port_id"
AttributeKeyChannelID = "channel_id"
AttributeVersion = "version"
AttributeCounterpartyPortID = "counterparty_port_id"
AttributeCounterpartyChannelID = "counterparty_channel_id"

Expand Down
265 changes: 184 additions & 81 deletions modules/core/04-channel/types/tx.pb.go

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChan

return &channeltypes.MsgChannelOpenInitResponse{
ChannelId: channelID,
Version: msg.Channel.Version,
}, nil
}

Expand Down Expand Up @@ -232,7 +233,9 @@ func (k Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChann
// Write channel into state
k.ChannelKeeper.WriteOpenTryChannel(ctx, msg.PortId, channelID, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.Channel.Counterparty, version)

return &channeltypes.MsgChannelOpenTryResponse{}, nil
return &channeltypes.MsgChannelOpenTryResponse{
Version: version,
}, nil
}

// ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck.
Expand Down
5 changes: 4 additions & 1 deletion proto/ibc/core/channel/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ message MsgChannelOpenInit {
// MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.
message MsgChannelOpenInitResponse {
string channel_id = 1 [(gogoproto.moretags) = "yaml:\"channel_id\""];
string version = 2;
}

// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel
Expand All @@ -91,7 +92,9 @@ message MsgChannelOpenTry {
}

// MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type.
message MsgChannelOpenTryResponse {}
message MsgChannelOpenTryResponse {
string version = 1;
}

// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge
// the change of channel state to TRYOPEN on Chain B.
Expand Down

0 comments on commit c55d71f

Please sign in to comment.