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 (#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
  • Loading branch information
vuong177 authored Apr 21, 2022
1 parent 16921d9 commit a187803
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 84 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (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.
* (modules/core/04-channel) [\#1160](https://github.com/cosmos/ibc-go/pull/1160) Improve `uint64 -> string` performance in `Logger`.
* (modules/core/04-channel) [\#1232](https://github.com/cosmos/ibc-go/pull/1232) Updating params on `NewPacketId` and moving to bottom of file.
* (modules/core/04-channel) [\#1232](https://github.com/cosmos/ibc-go/pull/1232) Updating params on `NewPacketId` and moving to bottom of file.
* (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

### 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 @@ -2809,6 +2809,7 @@ MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `channel_id` | [string](#string) | | |
| `version` | [string](#string) | | |



Expand Down Expand Up @@ -2844,6 +2845,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 a187803

Please sign in to comment.