Skip to content

Commit 17d7e9a

Browse files
Add packet_connection attribute to packet lifecycle methods (#8458)
* Add packet_connection attribute to packet lifecycle methods Added to: * SendPacket * ReceivePacket * WriteAcknowledgement * AcknowledgePacket * Add CHANGELOG * Update CHANGELOG.md Co-authored-by: colin axnér <[email protected]> Co-authored-by: colin axnér <[email protected]>
1 parent 896eee2 commit 17d7e9a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4242

4343
### Improvements
4444

45+
* (x/ibc) [\#8458](https://github.com/cosmos/cosmos-sdk/pull/8458) Add `packet_connection` attribute to ibc events to enable relayer filtering
4546
* (x/bank) [\#8479](https://github.com/cosmos/cosmos-sdk/pull/8479) Adittional client denom metadata validation for `base` and `display` denoms.
4647
* (x/ibc) [\#8404](https://github.com/cosmos/cosmos-sdk/pull/8404) Reorder IBC `ChanOpenAck` and `ChanOpenConfirm` handler execution to perform core handler first, followed by application callbacks.
4748
* [\#8396](https://github.com/cosmos/cosmos-sdk/pull/8396) Add support for ARM platform

x/ibc/core/04-channel/keeper/packet.go

+12
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ func (k Keeper) SendPacket(
129129
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()),
130130
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()),
131131
sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()),
132+
// we only support 1-hop packets now, and that is the most important hop for a relayer
133+
// (is it going to a chain I am connected to)
134+
sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]),
132135
),
133136
sdk.NewEvent(
134137
sdk.EventTypeMessage,
@@ -289,6 +292,9 @@ func (k Keeper) RecvPacket(
289292
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()),
290293
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()),
291294
sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()),
295+
// we only support 1-hop packets now, and that is the most important hop for a relayer
296+
// (is it going to a chain I am connected to)
297+
sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]),
292298
),
293299
sdk.NewEvent(
294300
sdk.EventTypeMessage,
@@ -370,6 +376,9 @@ func (k Keeper) WriteAcknowledgement(
370376
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()),
371377
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()),
372378
sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)),
379+
// we only support 1-hop packets now, and that is the most important hop for a relayer
380+
// (is it going to a chain I am connected to)
381+
sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]),
373382
),
374383
sdk.NewEvent(
375384
sdk.EventTypeMessage,
@@ -505,6 +514,9 @@ func (k Keeper) AcknowledgePacket(
505514
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()),
506515
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()),
507516
sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()),
517+
// we only support 1-hop packets now, and that is the most important hop for a relayer
518+
// (is it going to a chain I am connected to)
519+
sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]),
508520
),
509521
sdk.NewEvent(
510522
sdk.EventTypeMessage,

x/ibc/core/04-channel/types/events.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const (
3030
AttributeKeyDstPort = "packet_dst_port"
3131
AttributeKeyDstChannel = "packet_dst_channel"
3232
AttributeKeyChannelOrdering = "packet_channel_ordering"
33+
AttributeKeyConnection = "packet_connection"
3334
)
3435

3536
// IBC channel events vars

0 commit comments

Comments
 (0)