Skip to content

Commit

Permalink
Add packet_connection attribute to packet lifecycle methods (#8483)
Browse files Browse the repository at this point in the history
From #8458

Co-authored-by: Ethan Frey <[email protected]>
  • Loading branch information
colin-axner and ethanfrey authored Feb 4, 2021
1 parent ad46b2f commit 37e1d93
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Types of changes (Stanzas):
"State Machine Breaking" for any changes that result in a different AppState given same genesisState and txList.
Ref: https://keepachangelog.com/en/1.0.0/
-->
# Unreleased

### Improvements

* (x/ibc) [\#8458](https://github.com/cosmos/cosmos-sdk/pull/8458) Add `packet_connection` attribute to ibc events to enable relayer filtering

# Changelog

Expand Down
12 changes: 12 additions & 0 deletions x/ibc/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (k Keeper) SendPacket(
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,
Expand Down Expand Up @@ -289,6 +292,9 @@ func (k Keeper) RecvPacket(
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,
Expand Down Expand Up @@ -370,6 +376,9 @@ func (k Keeper) WriteAcknowledgement(
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()),
sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)),
// 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,
Expand Down Expand Up @@ -505,6 +514,9 @@ func (k Keeper) AcknowledgePacket(
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,
Expand Down
1 change: 1 addition & 0 deletions x/ibc/core/04-channel/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
AttributeKeyDstPort = "packet_dst_port"
AttributeKeyDstChannel = "packet_dst_channel"
AttributeKeyChannelOrdering = "packet_channel_ordering"
AttributeKeyConnection = "packet_connection"
)

// IBC channel events vars
Expand Down

0 comments on commit 37e1d93

Please sign in to comment.