From db5d700b0029c2e81e3725cd997100d4305695b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Fri, 7 Jan 2022 16:22:53 +0100 Subject: [PATCH 1/4] 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 --- CHANGELOG.md | 76 +++++++++++++++++++++++ modules/core/04-channel/keeper/packet.go | 29 +++++++-- modules/core/04-channel/keeper/timeout.go | 10 ++- 3 files changed, 109 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 858c438fdbc..85ad86511bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,82 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +<<<<<<< HEAD +======= +## [Unreleased] + +### Dependencies + +* [\#404](https://github.com/cosmos/ibc-go/pull/404) Bump Go version to 1.17 + +### API Breaking + +* (transfer) [\#675](https://github.com/cosmos/ibc-go/pull/675) Transfer `NewKeeper` now takes in an ICS4Wrapper. The ICS4Wrapper may be the IBC Channel Keeper when ICS20 is not used in a middleware stack. The ICS4Wrapper is required for applications wishing to connect middleware to ICS20. +* (core) [\#650](https://github.com/cosmos/ibc-go/pull/650) Modify `OnChanOpenTry` IBC application module callback to return the negotiated app version. The version passed into the `MsgChanOpenTry` has been deprecated and will be ignored by core IBC. +* (core) [\#629](https://github.com/cosmos/ibc-go/pull/629) Removes the `GetProofSpecs` from the ClientState interface. This function was previously unused by core IBC. +* (transfer) [\#517](https://github.com/cosmos/ibc-go/pull/517) Separates the ICS 26 callback functions from `AppModule` into a new type `IBCModule` for ICS 20 transfer. +* (modules/core/02-client) [\#536](https://github.com/cosmos/ibc-go/pull/536) `GetSelfConsensusState` return type changed from bool to error. +* (channel) [\#644](https://github.com/cosmos/ibc-go/pull/644) Removes `CounterpartyHops` function from the ChannelKeeper. + +### State Machine Breaking + +### 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. +* (channel) [\647](https://github.com/cosmos/ibc-go/pull/647) Reorganizes channel handshake handling to set channel state after IBC application callbacks. + +### Features + +* [\#432](https://github.com/cosmos/ibc-go/pull/432) Introduce `MockIBCApp` struct to the mock module. Allows the mock module to be reused to perform custom logic on each IBC App interface function. This might be useful when testing out IBC applications written as middleware. +* [\#380](https://github.com/cosmos/ibc-go/pull/380) Adding the Interchain Accounts module v1 + +### Bug Fixes + +## [v2.0.2](https://github.com/cosmos/ibc-go/releases/tag/v2.0.2) - 2021-12-15 + +### Dependencies + +* [\#589](https://github.com/cosmos/ibc-go/pull/589) Bump SDK version to v0.44.5 + +### Bug Fixes + +* (modules/core) [\#603](https://github.com/cosmos/ibc-go/pull/603) Fix module name emitted as part of `OnChanOpenInit` event. Replacing `connection` module name with `channel`. + +## [v2.0.1](https://github.com/cosmos/ibc-go/releases/tag/v2.0.1) - 2021-12-05 + +### Dependencies + +* [\#567](https://github.com/cosmos/ibc-go/pull/567) Bump SDK version to v0.44.4 + +### Improvements + +* (02-client) [\#568](https://github.com/cosmos/ibc-go/pull/568) In IBC `transfer` cli command use local clock time as reference for relative timestamp timeout if greater than the block timestamp queried from the latest consensus state corresponding to the counterparty channel. +* [\#583](https://github.com/cosmos/ibc-go/pull/583) Move third_party/proto/confio/proofs.proto to third_party/proto/proofs.proto to enable proto service reflection. Migrate `buf` from v1beta1 to v1. + +### Bug Fixes + +* (02-client) [\#500](https://github.com/cosmos/ibc-go/pull/500) Fix IBC `update-client proposal` cli command to expect correct number of args. + +## [v2.0.0](https://github.com/cosmos/ibc-go/releases/tag/v2.0.0) - 2021-11-09 + +### Dependencies + +* [\#489](https://github.com/cosmos/ibc-go/pull/489) Bump Tendermint to v0.34.14 +* [\#503](https://github.com/cosmos/ibc-go/pull/503) Bump SDK version to v0.44.3 + +### API Breaking + +* (core) [\#227](https://github.com/cosmos/ibc-go/pull/227) Remove sdk.Result from application callbacks +* (transfer) [\#350](https://github.com/cosmos/ibc-go/pull/350) Change FungibleTokenPacketData to use a string for the Amount field. This enables token transfers with amounts previously restricted by uint64. Up to the maximum uint256 value is supported. + +### Features + +* [\#384](https://github.com/cosmos/ibc-go/pull/384) Added `NegotiateAppVersion` method to `IBCModule` interface supported by a gRPC query service in `05-port`. This provides routing of requests to the desired application module callback, which in turn performs application version negotiation. + +>>>>>>> 087bc5d (improve 04-channel logging (#692)) ## [v1.2.5](https://github.com/cosmos/ibc-go/releases/tag/v1.2.5) - 2021-12-15 ### Dependencies 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) From f421609ee574154f80d1baefc7929299f4d11f21 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sat, 8 Jan 2022 22:21:56 +0100 Subject: [PATCH 2/4] fix conflicts --- CHANGELOG.md | 74 +++++----------------------------------------------- 1 file changed, 7 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85ad86511bd..66cdfb1f8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,78 +38,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ ======= ## [Unreleased] -### Dependencies - -* [\#404](https://github.com/cosmos/ibc-go/pull/404) Bump Go version to 1.17 - -### API Breaking - -* (transfer) [\#675](https://github.com/cosmos/ibc-go/pull/675) Transfer `NewKeeper` now takes in an ICS4Wrapper. The ICS4Wrapper may be the IBC Channel Keeper when ICS20 is not used in a middleware stack. The ICS4Wrapper is required for applications wishing to connect middleware to ICS20. -* (core) [\#650](https://github.com/cosmos/ibc-go/pull/650) Modify `OnChanOpenTry` IBC application module callback to return the negotiated app version. The version passed into the `MsgChanOpenTry` has been deprecated and will be ignored by core IBC. -* (core) [\#629](https://github.com/cosmos/ibc-go/pull/629) Removes the `GetProofSpecs` from the ClientState interface. This function was previously unused by core IBC. -* (transfer) [\#517](https://github.com/cosmos/ibc-go/pull/517) Separates the ICS 26 callback functions from `AppModule` into a new type `IBCModule` for ICS 20 transfer. -* (modules/core/02-client) [\#536](https://github.com/cosmos/ibc-go/pull/536) `GetSelfConsensusState` return type changed from bool to error. -* (channel) [\#644](https://github.com/cosmos/ibc-go/pull/644) Removes `CounterpartyHops` function from the ChannelKeeper. - -### State Machine Breaking +## [v1.2.6](https://github.com/cosmos/ibc-go/releases/tag/v1.2.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. -* [\#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. -* (channel) [\647](https://github.com/cosmos/ibc-go/pull/647) Reorganizes channel handshake handling to set channel state after IBC application callbacks. - -### Features - -* [\#432](https://github.com/cosmos/ibc-go/pull/432) Introduce `MockIBCApp` struct to the mock module. Allows the mock module to be reused to perform custom logic on each IBC App interface function. This might be useful when testing out IBC applications written as middleware. -* [\#380](https://github.com/cosmos/ibc-go/pull/380) Adding the Interchain Accounts module v1 - -### Bug Fixes - -## [v2.0.2](https://github.com/cosmos/ibc-go/releases/tag/v2.0.2) - 2021-12-15 - -### Dependencies - -* [\#589](https://github.com/cosmos/ibc-go/pull/589) Bump SDK version to v0.44.5 - -### Bug Fixes - -* (modules/core) [\#603](https://github.com/cosmos/ibc-go/pull/603) Fix module name emitted as part of `OnChanOpenInit` event. Replacing `connection` module name with `channel`. - -## [v2.0.1](https://github.com/cosmos/ibc-go/releases/tag/v2.0.1) - 2021-12-05 - -### Dependencies - -* [\#567](https://github.com/cosmos/ibc-go/pull/567) Bump SDK version to v0.44.4 - -### Improvements - -* (02-client) [\#568](https://github.com/cosmos/ibc-go/pull/568) In IBC `transfer` cli command use local clock time as reference for relative timestamp timeout if greater than the block timestamp queried from the latest consensus state corresponding to the counterparty channel. -* [\#583](https://github.com/cosmos/ibc-go/pull/583) Move third_party/proto/confio/proofs.proto to third_party/proto/proofs.proto to enable proto service reflection. Migrate `buf` from v1beta1 to v1. - -### Bug Fixes -* (02-client) [\#500](https://github.com/cosmos/ibc-go/pull/500) Fix IBC `update-client proposal` cli command to expect correct number of args. - -## [v2.0.0](https://github.com/cosmos/ibc-go/releases/tag/v2.0.0) - 2021-11-09 - -### Dependencies - -* [\#489](https://github.com/cosmos/ibc-go/pull/489) Bump Tendermint to v0.34.14 -* [\#503](https://github.com/cosmos/ibc-go/pull/503) Bump SDK version to v0.44.3 - -### API Breaking - -* (core) [\#227](https://github.com/cosmos/ibc-go/pull/227) Remove sdk.Result from application callbacks -* (transfer) [\#350](https://github.com/cosmos/ibc-go/pull/350) Change FungibleTokenPacketData to use a string for the Amount field. This enables token transfers with amounts previously restricted by uint64. Up to the maximum uint256 value is supported. - -### Features - -* [\#384](https://github.com/cosmos/ibc-go/pull/384) Added `NegotiateAppVersion` method to `IBCModule` interface supported by a gRPC query service in `05-port`. This provides routing of requests to the desired application module callback, which in turn performs application version negotiation. - ->>>>>>> 087bc5d (improve 04-channel logging (#692)) ## [v1.2.5](https://github.com/cosmos/ibc-go/releases/tag/v1.2.5) - 2021-12-15 ### Dependencies @@ -167,6 +101,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#386](https://github.com/cosmos/ibc-go/pull/386) Bump [tendermint](github.com/tendermint/tendermint) from v0.34.12 to v0.34.13. +## [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 From c5174a5c9cd34db5d895c4e1e0d5653b82db0551 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sat, 8 Jan 2022 22:22:28 +0100 Subject: [PATCH 3/4] forgot to remove something --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66cdfb1f8e6..a7e47145fec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,10 +34,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog -<<<<<<< HEAD -======= -## [Unreleased] - ## [v1.2.6](https://github.com/cosmos/ibc-go/releases/tag/v1.2.6) - 2021-01-12 ### Improvements From 5911f40a0fa4950d4126c2d638cf8119cefa844d Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sat, 8 Jan 2022 22:51:18 +0100 Subject: [PATCH 4/4] now really fix the broken link --- docs/ibc/relayer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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