Skip to content

Commit

Permalink
Merge pull request #8127 from Agoric/mfig-vibc-write-open-init
Browse files Browse the repository at this point in the history
fix(vibc): accommodate ibc-go v3 breaking changes
  • Loading branch information
michaelfig authored and mhofman committed Aug 7, 2023
2 parents aec2a4e + 0ecfcb0 commit 565d3e7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
3 changes: 1 addition & 2 deletions golang/cosmos/x/vibc/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ type channelOpenAckEvent struct {
Event string `json:"event"` // channelOpenAck
PortID string `json:"portID"`
ChannelID string `json:"channelID"`
CounterpartyChannelID string `json:"counterpartyChannelID"`
CounterpartyVersion string `json:"counterpartyVersion"`
Counterparty channeltypes.Counterparty `json:"counterparty"`
ConnectionHops []string `json:"connectionHops"`
Expand All @@ -247,12 +246,12 @@ func (im IBCModule) OnChanOpenAck(
// returns an empty channel object that we can still use without crashing.
channel, _ := im.keeper.GetChannel(ctx, portID, channelID)

channel.Counterparty.ChannelId = counterpartyChannelID
event := channelOpenAckEvent{
Type: "IBC_EVENT",
Event: "channelOpenAck",
PortID: portID,
ChannelID: channelID,
CounterpartyChannelID: counterpartyChannelID,
CounterpartyVersion: counterpartyVersion,
Counterparty: channel.Counterparty,
ConnectionHops: channel.ConnectionHops,
Expand Down
16 changes: 1 addition & 15 deletions golang/cosmos/x/vibc/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ func (k Keeper) ChanOpenInit(ctx sdk.Context, order channeltypes.Order, connecti
return err
}

// We need to emit a channel event to notify the relayer.
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory),
),
})
k.channelKeeper.WriteOpenInitChannel(ctx, portID, channelID, order, connectionHops, counterparty, version)
return nil
}

Expand Down Expand Up @@ -157,14 +151,6 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error {
if err != nil {
return err
}

// We need to emit a channel event to notify the relayer.
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory),
),
})
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion golang/cosmos/x/vibc/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type ChannelKeeper interface {
WriteAcknowledgement(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
ChanOpenInit(ctx sdk.Context, order channel.Order, connectionHops []string, portID string,
portCap *capability.Capability, counterparty channel.Counterparty, version string) (string, *capability.Capability, error)

WriteOpenInitChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
connectionHops []string, counterparty channel.Counterparty, version string)
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
}
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/docs/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ You can omit any of the methods and those events will simply be ignored. All the
`onReceive()` is the most important method. Each time the remote end sends a packet, your `onReceive()` method will be called with the data inside that packet (currently as a String due to inter-vat marshalling limitations, but ideally as an ArrayBuffer with a custom `toString(encoding='latin1')` method so that it can contain arbitrary bytes).

The return value of `onReceive()` is nominally a Promise for ACK data of the message (that will eventually appear on the other side as resolution of the Promise returned by `connection.send()`).
For IBC, this Promise must be resolved within the same block as receiving the message, and if it does not resolve (or resolves to an empty value `''`, which is not supported by [Cosmos ibc-go](https://github.com/cosmos/ibc-go)) then the implementation will automatically send a trivial `'\x01'` ACK. This behavior may be different for other network implementations.
For IBC, if the ACK data settles to an empty value `''` then the implementation will automatically send a trivial `'\x01'` ACK, because empty ACKs are not supported by [Cosmos ibc-go](https://github.com/cosmos/ibc-go). This behavior may be different for other network implementations.
It is recommended to avoid ACK data where possible.

## Closing the Connection
Expand Down

0 comments on commit 565d3e7

Please sign in to comment.