Skip to content

Commit

Permalink
chore!: remove duplicate non-hexlified event attributes. (cosmos#6023)
Browse files Browse the repository at this point in the history
* chore: remote duplicate non-hexlified event attributes.

* temp: point to commit on fork.

* deps: point to interchain test commit, add changelog.

* Update CHANGELOG.md

* Update 13-v8-to-v9.md

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
DimitrisJim and crodriguezvega authored Apr 24, 2024
1 parent 5eb75b5 commit c882b82
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (core/02-client) [\#6084](https://github.com/cosmos/ibc-go/pull/6084) Removed `stakingKeeper` as an argument to `NewKeeper` and replaced with a `ConsensusHost` implementation.
* (testing) [\#6070](https://github.com/cosmos/ibc-go/pull/6070) Remove `AssertEventsLegacy` function.
* (core) [\#6138](https://github.com/cosmos/ibc-go/pull/6138) Remove `Router` reference from IBC core keeper and use instead the router on the existing `PortKeeper` reference.
* (core/04-channel) [\#6023](https://github.com/cosmos/ibc-go/pull/6023) Remove emission of non-hexlified event attributes `packet_data` and `packet_ack`.

### State Machine Breaking

Expand Down
1 change: 1 addition & 0 deletions docs/docs/05-migrations/13-v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func NewKeeper(
## Relayers

- Renaming of event attribute keys in [#5603](https://github.com/cosmos/ibc-go/pull/5603).
- Removal of duplicate non-hexlified event attributes in [#6023](https://github.com/cosmos/ibc-go/pull/6023).

## IBC Light Clients

Expand Down
5 changes: 3 additions & 2 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/cosmos/ibc-go/e2e

go 1.21

replace github.com/strangelove-ventures/interchaintest/v8 => github.com/DimitrisJim/interchaintest/v8 v8.0.0-20240419095404-2c9270423b9a

require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
Expand All @@ -12,7 +14,7 @@ require (
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-00010101000000-000000000000
github.com/cosmos/ibc-go/v8 v8.1.0
github.com/docker/docker v24.0.7+incompatible
github.com/strangelove-ventures/interchaintest/v8 v8.2.0
github.com/strangelove-ventures/interchaintest/v8 v8.2.1-0.20240419152858-c8b741617cd8
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
golang.org/x/mod v0.17.0
Expand Down Expand Up @@ -235,7 +237,6 @@ require (
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bp
github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/DimitrisJim/interchaintest/v8 v8.0.0-20240419095404-2c9270423b9a h1:Ecz2QGDNdO/Hej2Dd490Vyg1yy55/2Lt2bN81tWuSgo=
github.com/DimitrisJim/interchaintest/v8 v8.0.0-20240419095404-2c9270423b9a/go.mod h1:B1TjQjU1te0ek05LQGjDwEu1NwWpfmC3+eAEDtouY+0=
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc=
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw=
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc=
Expand Down Expand Up @@ -1052,8 +1054,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/strangelove-ventures/interchaintest/v8 v8.2.0 h1:EZXPvZXL1y/kvh9XI04A2stL+2UMvykhNUv28euRnL8=
github.com/strangelove-ventures/interchaintest/v8 v8.2.0/go.mod h1:pupV0YN3A56/u9kHj9U1F8MdDUEolBIn05F0W1q/0oI=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
Expand Down
4 changes: 0 additions & 4 deletions modules/core/04-channel/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func emitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Cha
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSendPacket,
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())), //nolint:staticcheck // DEPRECATED
sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())),
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, timeoutHeight.String()),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
Expand Down Expand Up @@ -153,7 +152,6 @@ func emitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Cha
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeRecvPacket,
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())), //nolint:staticcheck // DEPRECATED
sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())),
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
Expand All @@ -180,7 +178,6 @@ func emitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeWriteAck,
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())), //nolint:staticcheck // DEPRECATED
sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())),
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
Expand All @@ -189,7 +186,6 @@ func emitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()),
sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)), //nolint:staticcheck // DEPRECATED
sdk.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)),
// we only support 1-hop packets now, and that is the most important hop for a relayer
// (is it going to a chain I am connected to)
Expand Down
5 changes: 0 additions & 5 deletions modules/core/04-channel/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ const (
EventTypeAcknowledgePacket = "acknowledge_packet"
EventTypeTimeoutPacket = "timeout_packet"

// Deprecated: in favor of AttributeKeyDataHex
AttributeKeyData = "packet_data"
// Deprecated: in favor of AttributeKeyAckHex
AttributeKeyAck = "packet_ack"

AttributeKeyDataHex = "packet_data_hex"
AttributeKeyAckHex = "packet_ack_hex"
AttributeKeyTimeoutHeight = "packet_timeout_height"
Expand Down
19 changes: 14 additions & 5 deletions testing/events.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ibctesting

import (
"encoding/hex"
"fmt"
"slices"
"strconv"
Expand Down Expand Up @@ -84,9 +85,12 @@ func ParsePacketsFromEvents(events []abci.Event) ([]channeltypes.Packet, error)
var packet channeltypes.Packet
for _, attr := range ev.Attributes {
switch attr.Key {
case channeltypes.AttributeKeyData: //nolint:staticcheck // DEPRECATED
packet.Data = []byte(attr.Value)

case channeltypes.AttributeKeyDataHex:
data, err := hex.DecodeString(attr.Value)
if err != nil {
return ferr(err)
}
packet.Data = data
case channeltypes.AttributeKeySequence:
seq, err := strconv.ParseUint(attr.Value, 10, 64)
if err != nil {
Expand Down Expand Up @@ -143,8 +147,13 @@ func ParseAckFromEvents(events []abci.Event) ([]byte, error) {
for _, ev := range events {
if ev.Type == channeltypes.EventTypeWriteAck {
for _, attr := range ev.Attributes {
if attr.Key == channeltypes.AttributeKeyAck { //nolint:staticcheck // DEPRECATED
return []byte(attr.Value), nil
if attr.Key == channeltypes.AttributeKeyAckHex {
value, err := hex.DecodeString(attr.Value)
if err != nil {
return nil, err
}

return value, nil
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions testing/events_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ibctesting_test

import (
"encoding/hex"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -29,8 +30,8 @@ func TestParsePacketsFromEvents(t *testing.T) {
Type: channeltypes.EventTypeSendPacket,
Attributes: []abci.EventAttribute{
{
Key: channeltypes.AttributeKeyData,
Value: "data1",
Key: channeltypes.AttributeKeyDataHex,
Value: hex.EncodeToString([]byte("data1")),
},
{
Key: channeltypes.AttributeKeySequence,
Expand Down Expand Up @@ -69,8 +70,8 @@ func TestParsePacketsFromEvents(t *testing.T) {
Type: channeltypes.EventTypeSendPacket,
Attributes: []abci.EventAttribute{
{
Key: channeltypes.AttributeKeyData,
Value: "data2",
Key: channeltypes.AttributeKeyDataHex,
Value: hex.EncodeToString([]byte("data2")),
},
{
Key: channeltypes.AttributeKeySequence,
Expand Down

0 comments on commit c882b82

Please sign in to comment.