-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use new port router with OnAcknowledgementPacket #7108
Changes from all commits
210e801
97c6b76
60826e5
f696ae6
01b64e5
623afd2
a3ad8d3
a451b5c
431f804
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,13 +239,32 @@ func (LegacyIBCModule) OnRecvPacket( | |
} | ||
|
||
// OnAcknowledgementPacket implements the IBCModule interface | ||
func (LegacyIBCModule) OnAcknowledgementPacket( | ||
func (im *LegacyIBCModule) OnAcknowledgementPacket( | ||
ctx sdk.Context, | ||
channelVersion string, | ||
packet channeltypes.Packet, | ||
acknowledgement []byte, | ||
relayer sdk.AccAddress, | ||
) error { | ||
for i := len(im.cbs) - 1; i >= 0; i-- { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this ended up looking super clean with these 2 interfaces for wrapping, nice job! |
||
var ( | ||
cbVersion = channelVersion | ||
cbAck = acknowledgement | ||
) | ||
|
||
if wrapper, ok := im.cbs[i].(VersionWrapper); ok { | ||
cbVersion, channelVersion = wrapper.UnwrapVersionSafe(ctx, packet.SourcePort, packet.SourceChannel, cbVersion) | ||
} | ||
|
||
if wrapper, ok := im.cbs[i].(AcknowledgementWrapper); ok { | ||
cbAck, acknowledgement = wrapper.UnwrapAcknowledgement(ctx, packet.SourcePort, packet.SourceChannel, cbAck) | ||
} | ||
|
||
err := im.cbs[i].OnAcknowledgementPacket(ctx, cbVersion, packet, cbAck, relayer) | ||
if err != nil { | ||
return errorsmod.Wrap(err, "acknowledge packet callback failed") | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,12 +131,29 @@ type VersionWrapper interface { | |
WrapVersion(cbVersion, underlyingAppVersion string) string | ||
// UnwrapVersionUnsafe is required in order to remove middleware wiring and the ICS4Wrapper | ||
// while maintaining backwards compatibility. It will be removed in the future. | ||
// Applications should unwrap the provided version with into their application version. | ||
// Applications should unwrap the provided version with into their application version. | ||
// and the underlying application version. If they are unsuccessful they should return an error. | ||
// UnwrapVersionUnsafe will be used during opening handshakes and channel upgrades when the version | ||
// is still being negotiated. | ||
UnwrapVersionUnsafe(string) (cbVersion, underlyingAppVersion string, err error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can add a type assertion for ics27 |
||
// UnwrapVersionSafe(ctx sdk.Context, portID, channelID, version string) (appVersion, version string) | ||
// UnwrapVersionSafe is required in order to remove middleware wiring and the ICS4Wrapper | ||
// while maintaining backwards compatibility. It will be removed in the future. | ||
// Applications should unwrap the provided version into their application version. | ||
// They should use the context and associated portID and channelID to safely do so. | ||
// UnwrapVersionSafe will be used during packet processing to provide callbacks | ||
// their application version. | ||
UnwrapVersionSafe(ctx sdk.Context, portID, channelID, version string) (cbVersion, underlyingAppVersion string) | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// AcknowledgementWrapper is an optional interface which should be implemented by middlewares which wrap the acknowledgement | ||
// to ensure backwards compatibility. | ||
type AcknowledgementWrapper interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can add a type assertion for ics29 |
||
// UnwrapAcknowledgement is required in order to remove middleware wiring and the ICS4Wrapper | ||
// while maintaining backwards compatibility. It will be removed in the future. | ||
// Applications should unwrap the underlying app acknowledgement using the context | ||
// and the given portID and channelID. They should return their application acknowledgement | ||
// as the bytes it expects to decode in OnAcknowledgement. | ||
UnwrapAcknowledgement(ctx sdk.Context, portID, channelID string, acknowledgment []byte) (cbAcknowledgement, underlyingAppAcknowledgement []byte) | ||
} | ||
|
||
// UpgradableModule defines the callbacks required to perform a channel upgrade. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: we return ack we unmarshaled as our ack. This is because it expects to unmarshal this value in
OnAcknowledgement