Skip to content

Commit

Permalink
improve 04-channel logging (#692)
Browse files Browse the repository at this point in the history
## 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/<module>/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
  • Loading branch information
colin-axner committed Jan 7, 2022
1 parent 3ff0927 commit 087bc5d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### 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.
* [\#383](https://github.com/cosmos/ibc-go/pull/383) Adds helper functions for merging and splitting middleware versions from the underlying app version.
* (modules/core/05-port) [\#288](https://github.com/cosmos/ibc-go/issues/288) Making the 05-port keeper function IsBound public. The IsBound function checks if the provided portID is already binded to a module.
* (channel) [\#644](https://github.com/cosmos/ibc-go/pull/644) Adds `GetChannelConnection` to the ChannelKeeper. This function returns the connectionID and connection state associated with a channel.
Expand Down
29 changes: 25 additions & 4 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"bytes"
"fmt"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -135,6 +134,7 @@ func (k Keeper) SendPacket(
"dst_port", packet.GetDestPort(),
"dst_channel", packet.GetDestChannel(),
)

return nil
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions modules/core/04-channel/keeper/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"bytes"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 087bc5d

Please sign in to comment.