Skip to content

Commit

Permalink
imp(api)!: remove header from update client event
Browse files Browse the repository at this point in the history
  • Loading branch information
mattverse committed Nov 21, 2023
1 parent cab3fcd commit ace2e2a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26 deletions.
17 changes: 0 additions & 17 deletions modules/core/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keeper_test

import (
"encoding/hex"
"fmt"
"time"

Expand Down Expand Up @@ -520,22 +519,6 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() {
// first event type is "message", followed by 3 "tx" events in ante
updateEvent := result.Events[4]
suite.Require().Equal(clienttypes.EventTypeUpdateClient, updateEvent.Type)

// use a boolean to ensure the update event contains the header
contains := false
for _, attr := range updateEvent.Attributes {
if attr.Key == clienttypes.AttributeKeyHeader {
contains = true

bz, err := hex.DecodeString(attr.Value)
suite.Require().NoError(err)

emittedHeader, err := clienttypes.UnmarshalClientMessage(suite.chainA.App.AppCodec(), bz)
suite.Require().NoError(err)
suite.Require().Equal(header, emittedHeader)
}
}
suite.Require().True(contains)
}

func (suite *KeeperTestSuite) TestRecoverClient() {
Expand Down
9 changes: 1 addition & 8 deletions modules/core/02-client/keeper/events.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keeper

import (
"encoding/hex"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -32,12 +31,7 @@ func emitCreateClientEvent(ctx sdk.Context, clientID string, clientState exporte
}

// emitUpdateClientEvent emits an update client event
func emitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string, consensusHeights []exported.Height, cdc codec.BinaryCodec, clientMsg exported.ClientMessage) {
// Marshal the ClientMessage as an Any and encode the resulting bytes to hex.
// This prevents the event value from containing invalid UTF-8 characters
// which may cause data to be lost when JSON encoding/decoding.
clientMsgStr := hex.EncodeToString(types.MustMarshalClientMessage(cdc, clientMsg))

func emitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string, consensusHeights []exported.Height, _ codec.BinaryCodec, _ exported.ClientMessage) {
var consensusHeightAttr string
if len(consensusHeights) != 0 {
consensusHeightAttr = consensusHeights[0].String()
Expand All @@ -57,7 +51,6 @@ func emitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string,
// Please use AttributeKeyConsensusHeights instead.
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeightAttr),
sdk.NewAttribute(types.AttributeKeyConsensusHeights, strings.Join(consensusHeightsAttr, ",")),
sdk.NewAttribute(types.AttributeKeyHeader, clientMsgStr),
),
sdk.NewEvent(
sdk.EventTypeMessage,
Expand Down
1 change: 0 additions & 1 deletion modules/core/02-client/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const (
AttributeKeyClientType = "client_type"
AttributeKeyConsensusHeight = "consensus_height"
AttributeKeyConsensusHeights = "consensus_heights"
AttributeKeyHeader = "header"
AttributeKeyUpgradeStore = "upgrade_store"
AttributeKeyUpgradePlanHeight = "upgrade_plan_height"
AttributeKeyUpgradePlanTitle = "title"
Expand Down

0 comments on commit ace2e2a

Please sign in to comment.