From f582901fb3835d95d493c777aac6a63fc3ee4681 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Mon, 31 Jul 2023 22:55:58 -0600 Subject: [PATCH 1/3] fix(vibc): accommodate ibc-go v3 breaking changes --- golang/cosmos/x/vibc/keeper/keeper.go | 16 +--------------- golang/cosmos/x/vibc/types/expected_keepers.go | 3 ++- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/golang/cosmos/x/vibc/keeper/keeper.go b/golang/cosmos/x/vibc/keeper/keeper.go index cd0329498ec..465b171c2e0 100644 --- a/golang/cosmos/x/vibc/keeper/keeper.go +++ b/golang/cosmos/x/vibc/keeper/keeper.go @@ -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 } @@ -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 } diff --git a/golang/cosmos/x/vibc/types/expected_keepers.go b/golang/cosmos/x/vibc/types/expected_keepers.go index 6967e7dca4c..49dc2953ff6 100644 --- a/golang/cosmos/x/vibc/types/expected_keepers.go +++ b/golang/cosmos/x/vibc/types/expected_keepers.go @@ -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 } From 1ca6e848550e858bcffb11d09d165020cef190fe Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Wed, 2 Aug 2023 14:36:30 -0600 Subject: [PATCH 2/3] docs(SwingSet): remove mention of obsolete "need prompt ACK" for IBC network --- packages/SwingSet/docs/networking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/SwingSet/docs/networking.md b/packages/SwingSet/docs/networking.md index 8e0345bb92d..bb71c5ea869 100644 --- a/packages/SwingSet/docs/networking.md +++ b/packages/SwingSet/docs/networking.md @@ -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 From 946997192cec0ed6b07fdaa18d8f380f460ab004 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Wed, 2 Aug 2023 16:08:55 -0600 Subject: [PATCH 3/3] fix(vibc): put extraneous `CounterpartyChannelID` in `Counterparty` struct --- golang/cosmos/x/vibc/ibc.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/golang/cosmos/x/vibc/ibc.go b/golang/cosmos/x/vibc/ibc.go index 5c3e990e635..a8a73e07ed1 100644 --- a/golang/cosmos/x/vibc/ibc.go +++ b/golang/cosmos/x/vibc/ibc.go @@ -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"` @@ -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,