From 56cbc7e1febd8849b7e2b693144eff8e8a9081b7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 12 Jan 2022 13:17:10 +0100 Subject: [PATCH] improve 04-channel logging (backport #692) (#695) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * improve 04-channel logging (#692) ## Description closes: #674 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [x] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [x] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [x] Updated relevant documentation (`docs/`) or specification (`x//spec/`) - [x] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [x] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [x] Re-reviewed `Files changed` in the Github PR explorer - [x] Review `Codecov Report` in the comment section below once CI passes (cherry picked from commit 087bc5d77a194f8ea0010942017060357fb62f12) # Conflicts: # CHANGELOG.md * fix conflicts * fix broken link Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Carlos Rodriguez --- CHANGELOG.md | 6 +++++ docs/ibc/relayer.md | 2 +- modules/core/04-channel/keeper/packet.go | 29 +++++++++++++++++++---- modules/core/04-channel/keeper/timeout.go | 10 ++++++-- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70c28b4d0ee..234cc222922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## [v1.1.6](https://github.com/cosmos/ibc-go/releases/tag/v1.1.6) - 2021-01-12 + +### Improvements + +* (channel) [\#692](https://github.com/cosmos/ibc-go/pull/692) Minimize channel logging by only emitting the packet sequence, source port/channel, destination port/channel upon packet receives, acknowledgements and timeouts. + ## [v1.1.5](https://github.com/cosmos/ibc-go/releases/tag/v1.1.5) - 2021-12-15 ### Dependencies diff --git a/docs/ibc/relayer.md b/docs/ibc/relayer.md index 29699d7cb3c..b1688320326 100644 --- a/docs/ibc/relayer.md +++ b/docs/ibc/relayer.md @@ -14,7 +14,7 @@ order: 4 Events are emitted for every transaction processed by the base application to indicate the execution of some logic clients may want to be aware of. This is extremely useful when relaying IBC packets. Any message that uses IBC will emit events for the corresponding TAO logic executed as defined in -the [IBC events spec](https://github.com/cosmos/ibc-go/blob/main/modules/core/spec/06_events.md). +the [IBC events spec](../../modules/core/spec/06_events.md). In the SDK, it can be assumed that for every message there is an event emitted with the type `message`, attribute key `action`, and an attribute value representing the type of message sent diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 38b40e5b795..a31f511f074 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -2,7 +2,6 @@ package keeper import ( "bytes" - "fmt" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -135,6 +134,7 @@ func (k Keeper) SendPacket( "dst_port", packet.GetDestPort(), "dst_channel", packet.GetDestChannel(), ) + return nil } @@ -281,7 +281,14 @@ func (k Keeper) RecvPacket( } // log that a packet has been received & executed - k.Logger(ctx).Info("packet received", "packet", fmt.Sprintf("%v", packet)) + k.Logger(ctx).Info( + "packet received", + "sequence", packet.GetSequence(), + "src_port", packet.GetSourcePort(), + "src_channel", packet.GetSourceChannel(), + "dst_port", packet.GetDestPort(), + "dst_channel", packet.GetDestChannel(), + ) // emit an event that the relayer can query for EmitRecvPacketEvent(ctx, packet, channel) @@ -345,7 +352,14 @@ func (k Keeper) WriteAcknowledgement( ) // log that a packet acknowledgement has been written - k.Logger(ctx).Info("acknowledged written", "packet", fmt.Sprintf("%v", packet)) + k.Logger(ctx).Info( + "acknowledgement written", + "sequence", packet.GetSequence, + "src_port", packet.GetSourcePort(), + "src_channel", packet.GetSourceChannel(), + "dst_port", packet.GetDestPort(), + "dst_channel", packet.GetDestChannel(), + ) EmitWriteAcknowledgementEvent(ctx, packet, channel, acknowledgement) @@ -472,7 +486,14 @@ func (k Keeper) AcknowledgePacket( k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) // log that a packet has been acknowledged - k.Logger(ctx).Info("packet acknowledged", "packet", fmt.Sprintf("%v", packet)) + k.Logger(ctx).Info( + "packet acknowledged", + "sequence", packet.GetSequence, + "src_port", packet.GetSourcePort(), + "src_channel", packet.GetSourceChannel(), + "dst_port", packet.GetDestPort(), + "dst_channel", packet.GetDestChannel(), + ) // emit an event marking that we have processed the acknowledgement EmitAcknowledgePacketEvent(ctx, packet, channel) diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 93fa9eca4fe..06f75c6feef 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -2,7 +2,6 @@ package keeper import ( "bytes" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -157,7 +156,14 @@ func (k Keeper) TimeoutExecuted( k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) } - k.Logger(ctx).Info("packet timed-out", "packet", fmt.Sprintf("%v", packet)) + k.Logger(ctx).Info( + "packet timed-out", + "sequence", packet.GetSequence(), + "src_port", packet.GetSourcePort(), + "src_channel", packet.GetSourceChannel(), + "dst_port", packet.GetDestPort(), + "dst_channel", packet.GetDestChannel(), + ) // emit an event marking that we have processed the timeout EmitTimeoutPacketEvent(ctx, packet, channel)