-
Notifications
You must be signed in to change notification settings - Fork 629
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
perform a no-op on redundant relay messages #268
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0ffbcec
create initial changes for delivertx handling
colin-axner 990d6a8
handle closed channel no-ops, fix tests
colin-axner 59ad180
self review nits
colin-axner f45469f
Merge branch 'main' into colin/245-delivertx-redundant-relay
colin-axner 31a55f4
add changelog
colin-axner beb3d46
Merge branch 'colin/245-delivertx-redundant-relay' of github.com:cosm…
colin-axner d7443a5
fix merge conflict
colin-axner 560ad17
add events for no op messages
colin-axner c23ae39
add back comment
colin-axner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package keeper | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/modules/core/04-channel/types" | ||
"github.com/cosmos/ibc-go/modules/core/exported" | ||
) | ||
|
||
// EmitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet | ||
// is received for a certain sequence and for all duplicate receives. | ||
func EmitRecvPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeRecvPacket, | ||
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())), // DEPRECATED | ||
sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), | ||
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), | ||
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), | ||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), | ||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), | ||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), | ||
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), | ||
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), | ||
sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), | ||
// we only support 1-hop packets now, and that is the most important hop for a relayer | ||
// (is it going to a chain I am connected to) | ||
sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time | ||
// a packet is acknowledged for a certain sequence and for all duplicate acknowledgements. | ||
func EmitAcknowledgePacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeAcknowledgePacket, | ||
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), | ||
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), | ||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), | ||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), | ||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), | ||
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), | ||
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), | ||
sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), | ||
// we only support 1-hop packets now, and that is the most important hop for a relayer | ||
// (is it going to a chain I am connected to) | ||
sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitTimeoutPacketEvent emits a timeout packet event. It will be emitted both the first time a packet | ||
// is timed out for a certain sequence and for all duplicate timeouts. | ||
func EmitTimeoutPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeTimeoutPacket, | ||
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), | ||
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), | ||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), | ||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), | ||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), | ||
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), | ||
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), | ||
sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If a packet is timed out on an ordered channel, all future timeout packets need to be timed out via timeout on close (since the channel is closed). I want this "channel closed" error message to be sent to relayers only when the relay isn't redundant (packet commitment doesn't exist). Thus I moved it below the redundant check
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.
This is so if there's a redundant timeout for the first timed out packet on an ORDERED channel, the relayer gets a no-op rather than this error?
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.
That's correct. When I did the change though I was thinking more packets would return a no op here. I'm fine to revert this in order to keep consistency with the spec. Thoughts?