Skip to content

Commit f76423e

Browse files
chattonmergify[bot]
authored andcommitted
Emit channel close event on ordered channel close (#1464)
(cherry picked from commit 9ed5ca4) # Conflicts: # CHANGELOG.md
1 parent 959036b commit f76423e

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,20 @@ Ref: https://keepachangelog.com/en/1.0.0/
5050
* (modules/core/04-channel) [\#1160](https://github.com/cosmos/ibc-go/pull/1160) Improve `uint64 -> string` performance in `Logger`.
5151
* (modules/core/keeper) [\#1284](https://github.com/cosmos/ibc-go/pull/1284) Add sanity check for the keepers passed into `ibckeeper.NewKeeper`. `ibckeeper.NewKeeper` now panics if any of the keepers passed in is empty.
5252
* (transfer) [\#1414](https://github.com/cosmos/ibc-go/pull/1414) Emitting Sender address from `fungible_token_packet` events in `OnRecvPacket` and `OnAcknowledgementPacket`.
53+
* (modules/core/04-channel) [\#1464](https://github.com/cosmos/ibc-go/pull/1464) Emit a channel close event when an ordered channel is closed.
5354

5455
### Features
5556

57+
<<<<<<< HEAD
58+
=======
59+
* [\#276](https://github.com/cosmos/ibc-go/pull/276) Adding the Fee Middleware module v1
60+
* (apps/29-fee) [\#1229](https://github.com/cosmos/ibc-go/pull/1229) Adding CLI commands for getting all unrelayed incentivized packets and packet by packet-id.
61+
* (apps/29-fee) [\#1224](https://github.com/cosmos/ibc-go/pull/1224) Adding Query/CounterpartyAddress and CLI to ICS29 fee middleware
62+
* (apps/29-fee) [\#1225](https://github.com/cosmos/ibc-go/pull/1225) Adding Query/FeeEnabledChannel and Query/FeeEnabledChannels with CLIs to ICS29 fee middleware.
63+
* (modules/apps/29-fee) [\#1230](https://github.com/cosmos/ibc-go/pull/1230) Adding CLI command for getting incentivized packets for a specific channel-id.
64+
* (modules/apps/transfer) [\#1416](https://github.com/cosmos/ibc-go/pull/1416) Adding gRPC endpoint for getting an escrow account for a given port-id and channel-id.
65+
66+
>>>>>>> 9ed5ca4 (Emit channel close event on ordered channel close (#1464))
5667
### Bug Fixes
5768

5869
* (modules/core/04-channel) [\#1130](https://github.com/cosmos/ibc-go/pull/1130) Call `packet.GetSequence()` rather than passing func in `WriteAcknowledgement` log output

modules/core/04-channel/keeper/events.go

+15
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,18 @@ func EmitTimeoutPacketEvent(ctx sdk.Context, packet exported.PacketI, channel ty
137137
),
138138
})
139139
}
140+
141+
// EmitChannelClosedEvent emits a channel closed event.
142+
func EmitChannelClosedEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) {
143+
ctx.EventManager().EmitEvents(sdk.Events{
144+
sdk.NewEvent(
145+
types.EventTypeChannelClosed,
146+
sdk.NewAttribute(types.AttributeKeyPortID, packet.GetSourcePort()),
147+
sdk.NewAttribute(types.AttributeKeyChannelID, packet.GetSourceChannel()),
148+
sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId),
149+
sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId),
150+
sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]),
151+
sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()),
152+
),
153+
})
154+
}

modules/core/04-channel/keeper/timeout.go

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ func (k Keeper) TimeoutExecuted(
169169
// emit an event marking that we have processed the timeout
170170
EmitTimeoutPacketEvent(ctx, packet, channel)
171171

172+
if channel.Ordering == types.ORDERED && channel.State == types.CLOSED {
173+
EmitChannelClosedEvent(ctx, packet, channel)
174+
}
175+
172176
return nil
173177
}
174178

modules/core/04-channel/types/events.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var (
4747
EventTypeChannelOpenConfirm = "channel_open_confirm"
4848
EventTypeChannelCloseInit = "channel_close_init"
4949
EventTypeChannelCloseConfirm = "channel_close_confirm"
50+
EventTypeChannelClosed = "channel_close"
5051

5152
AttributeValueCategory = fmt.Sprintf("%s_%s", host.ModuleName, SubModuleName)
5253
)

0 commit comments

Comments
 (0)