Skip to content

Commit 56cbc7e

Browse files
mergify[bot]colin-axnercrodriguezvega
authoredJan 12, 2022
improve 04-channel logging (backport #692) (#695)
* 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/<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 (cherry picked from commit 087bc5d) # 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 <crodveg@gmail.com>
1 parent 6c79014 commit 56cbc7e

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed
 

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
3434

3535
# Changelog
3636

37+
## [v1.1.6](https://github.com/cosmos/ibc-go/releases/tag/v1.1.6) - 2021-01-12
38+
39+
### Improvements
40+
41+
* (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.
42+
3743
## [v1.1.5](https://github.com/cosmos/ibc-go/releases/tag/v1.1.5) - 2021-12-15
3844

3945
### Dependencies

‎docs/ibc/relayer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ order: 4
1414
Events are emitted for every transaction processed by the base application to indicate the execution
1515
of some logic clients may want to be aware of. This is extremely useful when relaying IBC packets.
1616
Any message that uses IBC will emit events for the corresponding TAO logic executed as defined in
17-
the [IBC events spec](https://github.com/cosmos/ibc-go/blob/main/modules/core/spec/06_events.md).
17+
the [IBC events spec](../../modules/core/spec/06_events.md).
1818

1919
In the SDK, it can be assumed that for every message there is an event emitted with the type `message`,
2020
attribute key `action`, and an attribute value representing the type of message sent

‎modules/core/04-channel/keeper/packet.go

+25-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package keeper
22

33
import (
44
"bytes"
5-
"fmt"
65
"time"
76

87
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -135,6 +134,7 @@ func (k Keeper) SendPacket(
135134
"dst_port", packet.GetDestPort(),
136135
"dst_channel", packet.GetDestChannel(),
137136
)
137+
138138
return nil
139139
}
140140

@@ -281,7 +281,14 @@ func (k Keeper) RecvPacket(
281281
}
282282

283283
// log that a packet has been received & executed
284-
k.Logger(ctx).Info("packet received", "packet", fmt.Sprintf("%v", packet))
284+
k.Logger(ctx).Info(
285+
"packet received",
286+
"sequence", packet.GetSequence(),
287+
"src_port", packet.GetSourcePort(),
288+
"src_channel", packet.GetSourceChannel(),
289+
"dst_port", packet.GetDestPort(),
290+
"dst_channel", packet.GetDestChannel(),
291+
)
285292

286293
// emit an event that the relayer can query for
287294
EmitRecvPacketEvent(ctx, packet, channel)
@@ -345,7 +352,14 @@ func (k Keeper) WriteAcknowledgement(
345352
)
346353

347354
// log that a packet acknowledgement has been written
348-
k.Logger(ctx).Info("acknowledged written", "packet", fmt.Sprintf("%v", packet))
355+
k.Logger(ctx).Info(
356+
"acknowledgement written",
357+
"sequence", packet.GetSequence,
358+
"src_port", packet.GetSourcePort(),
359+
"src_channel", packet.GetSourceChannel(),
360+
"dst_port", packet.GetDestPort(),
361+
"dst_channel", packet.GetDestChannel(),
362+
)
349363

350364
EmitWriteAcknowledgementEvent(ctx, packet, channel, acknowledgement)
351365

@@ -472,7 +486,14 @@ func (k Keeper) AcknowledgePacket(
472486
k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
473487

474488
// log that a packet has been acknowledged
475-
k.Logger(ctx).Info("packet acknowledged", "packet", fmt.Sprintf("%v", packet))
489+
k.Logger(ctx).Info(
490+
"packet acknowledged",
491+
"sequence", packet.GetSequence,
492+
"src_port", packet.GetSourcePort(),
493+
"src_channel", packet.GetSourceChannel(),
494+
"dst_port", packet.GetDestPort(),
495+
"dst_channel", packet.GetDestChannel(),
496+
)
476497

477498
// emit an event marking that we have processed the acknowledgement
478499
EmitAcknowledgePacketEvent(ctx, packet, channel)

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package keeper
22

33
import (
44
"bytes"
5-
"fmt"
65

76
sdk "github.com/cosmos/cosmos-sdk/types"
87
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@@ -157,7 +156,14 @@ func (k Keeper) TimeoutExecuted(
157156
k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel)
158157
}
159158

160-
k.Logger(ctx).Info("packet timed-out", "packet", fmt.Sprintf("%v", packet))
159+
k.Logger(ctx).Info(
160+
"packet timed-out",
161+
"sequence", packet.GetSequence(),
162+
"src_port", packet.GetSourcePort(),
163+
"src_channel", packet.GetSourceChannel(),
164+
"dst_port", packet.GetDestPort(),
165+
"dst_channel", packet.GetDestChannel(),
166+
)
161167

162168
// emit an event marking that we have processed the timeout
163169
EmitTimeoutPacketEvent(ctx, packet, channel)

0 commit comments

Comments
 (0)