Skip to content
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

Emit Packet Event on SendPacket #5821

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions x/ibc/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ func (k Keeper) SendPacket(
k.SetNextSequenceSend(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), nextSequenceSend)
k.SetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), types.CommitPacket(packet.GetData()))

// Emit Event with Packet data along with other packet information for relayer to pick up
// and relay to other chain
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSendPacket,
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData().GetBytes())),
sdk.NewAttribute(types.AttributeKeyTimeout, string(packet.GetData().GetTimeoutHeight())),
sdk.NewAttribute(types.AttributeKeySequence, string(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()),
),
})

k.Logger(ctx).Info(fmt.Sprintf("packet sent %v", packet)) // TODO: use packet.String()
return nil
}
Expand Down
9 changes: 9 additions & 0 deletions x/ibc/04-channel/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ const (
AttributeKeyChannelID = "channel_id"
AttributeCounterpartyPortID = "counterparty_port_id"
AttributeCounterpartyChannelID = "counterparty_channel_id"

EventTypeSendPacket = "send_packet"
AttributeKeyData = "packet_data"
AttributeKeyTimeout = "packet_timeout"
AttributeKeySequence = "packet_sequence"
AttributeKeySrcPort = "packet_src_port"
AttributeKeySrcChannel = "packet_src_channel"
AttributeKeyDstPort = "packet_dst_port"
AttributeKeyDstChannel = "packet_dst_channel"
)

// IBC channel events vars
Expand Down