From 306fbfe05b857b755cbff1bc86f5ba76bac7e920 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Fri, 24 Feb 2023 08:39:26 +0100 Subject: [PATCH 1/2] chore: make event emission functions unexported --- modules/apps/29-fee/keeper/escrow.go | 6 +-- modules/apps/29-fee/keeper/events.go | 16 +++--- modules/apps/29-fee/keeper/msg_server.go | 4 +- modules/core/02-client/keeper/client.go | 8 +-- modules/core/02-client/keeper/events.go | 54 +++++++++---------- modules/core/02-client/keeper/proposal.go | 4 +- modules/core/03-connection/keeper/events.go | 16 +++--- .../core/03-connection/keeper/handshake.go | 8 +-- modules/core/04-channel/keeper/events.go | 48 ++++++++--------- modules/core/04-channel/keeper/handshake.go | 12 ++--- modules/core/04-channel/keeper/packet.go | 14 ++--- modules/core/04-channel/keeper/timeout.go | 8 +-- 12 files changed, 99 insertions(+), 99 deletions(-) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index d32ec6baae4..d533a4ebf33 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -39,7 +39,7 @@ func (k Keeper) escrowPacketFee(ctx sdk.Context, packetID channeltypes.PacketId, packetFees := types.NewPacketFees(fees) k.SetFeesInEscrow(ctx, packetID, packetFees) - EmitIncentivizedPacketEvent(ctx, packetID, packetFees) + emitIncentivizedPacketEvent(ctx, packetID, packetFees) return nil } @@ -168,9 +168,9 @@ func (k Keeper) distributeFee(ctx sdk.Context, receiver, refundAccAddress sdk.Ac return // if sending to the refund address fails, no-op } - EmitDistributeFeeEvent(ctx, refundAccAddress.String(), fee) + emitDistributeFeeEvent(ctx, refundAccAddress.String(), fee) } else { - EmitDistributeFeeEvent(ctx, receiver.String(), fee) + emitDistributeFeeEvent(ctx, receiver.String(), fee) } // write the cache diff --git a/modules/apps/29-fee/keeper/events.go b/modules/apps/29-fee/keeper/events.go index 310421d24dc..e367482649e 100644 --- a/modules/apps/29-fee/keeper/events.go +++ b/modules/apps/29-fee/keeper/events.go @@ -9,9 +9,9 @@ import ( channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ) -// EmitIncentivizedPacketEvent emits an event containing information on the total amount of fees incentivizing +// emitIncentivizedPacketEvent emits an event containing information on the total amount of fees incentivizing // a specific packet. It should be emitted on every fee escrowed for the given packetID. -func EmitIncentivizedPacketEvent(ctx sdk.Context, packetID channeltypes.PacketId, packetFees types.PacketFees) { +func emitIncentivizedPacketEvent(ctx sdk.Context, packetID channeltypes.PacketId, packetFees types.PacketFees) { var ( totalRecvFees sdk.Coins totalAckFees sdk.Coins @@ -44,8 +44,8 @@ func EmitIncentivizedPacketEvent(ctx sdk.Context, packetID channeltypes.PacketId }) } -// EmitRegisterPayeeEvent emits an event containing information of a registered payee for a relayer on a particular channel -func EmitRegisterPayeeEvent(ctx sdk.Context, relayer, payee, channelID string) { +// emitRegisterPayeeEvent emits an event containing information of a registered payee for a relayer on a particular channel +func emitRegisterPayeeEvent(ctx sdk.Context, relayer, payee, channelID string) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRegisterPayee, @@ -60,8 +60,8 @@ func EmitRegisterPayeeEvent(ctx sdk.Context, relayer, payee, channelID string) { }) } -// EmitRegisterCounterpartyPayeeEvent emits an event containing information of a registered counterparty payee for a relayer on a particular channel -func EmitRegisterCounterpartyPayeeEvent(ctx sdk.Context, relayer, counterpartyPayee, channelID string) { +// emitRegisterCounterpartyPayeeEvent emits an event containing information of a registered counterparty payee for a relayer on a particular channel +func emitRegisterCounterpartyPayeeEvent(ctx sdk.Context, relayer, counterpartyPayee, channelID string) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRegisterCounterpartyPayee, @@ -76,8 +76,8 @@ func EmitRegisterCounterpartyPayeeEvent(ctx sdk.Context, relayer, counterpartyPa }) } -// EmitDistributeFeeEvent emits an event containing a distribution fee and receiver address -func EmitDistributeFeeEvent(ctx sdk.Context, receiver string, fee sdk.Coins) { +// emitDistributeFeeEvent emits an event containing a distribution fee and receiver address +func emitDistributeFeeEvent(ctx sdk.Context, receiver string, fee sdk.Coins) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeDistributeFee, diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 96a2ece8b55..063c00e7feb 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -42,7 +42,7 @@ func (k Keeper) RegisterPayee(goCtx context.Context, msg *types.MsgRegisterPayee k.Logger(ctx).Info("registering payee address for relayer", "relayer", msg.Relayer, "payee", msg.Payee, "channel", msg.ChannelId) - EmitRegisterPayeeEvent(ctx, msg.Relayer, msg.Payee, msg.ChannelId) + emitRegisterPayeeEvent(ctx, msg.Relayer, msg.Payee, msg.ChannelId) return &types.MsgRegisterPayeeResponse{}, nil } @@ -68,7 +68,7 @@ func (k Keeper) RegisterCounterpartyPayee(goCtx context.Context, msg *types.MsgR k.Logger(ctx).Info("registering counterparty payee for relayer", "relayer", msg.Relayer, "counterparty payee", msg.CounterpartyPayee, "channel", msg.ChannelId) - EmitRegisterCounterpartyPayeeEvent(ctx, msg.Relayer, msg.CounterpartyPayee, msg.ChannelId) + emitRegisterCounterpartyPayeeEvent(ctx, msg.Relayer, msg.CounterpartyPayee, msg.ChannelId) return &types.MsgRegisterCounterpartyPayeeResponse{}, nil } diff --git a/modules/core/02-client/keeper/client.go b/modules/core/02-client/keeper/client.go index fd260d65d98..6a0695768bc 100644 --- a/modules/core/02-client/keeper/client.go +++ b/modules/core/02-client/keeper/client.go @@ -39,7 +39,7 @@ func (k Keeper) CreateClient( []metrics.Label{telemetry.NewLabel(types.LabelClientType, clientState.ClientType())}, ) - EmitCreateClientEvent(ctx, clientID, clientState) + emitCreateClientEvent(ctx, clientID, clientState) return clientID, nil } @@ -77,7 +77,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exporte }, ) - EmitSubmitMisbehaviourEvent(ctx, clientID, clientState) + emitSubmitMisbehaviourEvent(ctx, clientID, clientState) return nil } @@ -97,7 +97,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exporte ) // emitting events in the keeper emits for both begin block and handler client updates - EmitUpdateClientEvent(ctx, clientID, clientState.ClientType(), consensusHeights, k.cdc, clientMsg) + emitUpdateClientEvent(ctx, clientID, clientState.ClientType(), consensusHeights, k.cdc, clientMsg) return nil } @@ -135,7 +135,7 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e }, ) - EmitUpgradeClientEvent(ctx, clientID, upgradedClient) + emitUpgradeClientEvent(ctx, clientID, upgradedClient) return nil } diff --git a/modules/core/02-client/keeper/events.go b/modules/core/02-client/keeper/events.go index 6c08858648e..932cdc65c9f 100644 --- a/modules/core/02-client/keeper/events.go +++ b/modules/core/02-client/keeper/events.go @@ -14,8 +14,23 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" ) -// EmitCreateClientEvent emits a create client event -func EmitCreateClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { +// EmitUpgradeChainEvent emits an upgrade chain event. +func EmitUpgradeChainEvent(ctx sdk.Context, height int64) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeUpgradeChain, + sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)), + sdk.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) +} + +// emitCreateClientEvent emits a create client event +func emitCreateClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCreateClient, @@ -30,8 +45,8 @@ 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) { +// 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. @@ -65,8 +80,8 @@ func EmitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string, }) } -// EmitUpdateClientEvent emits an upgrade client event -func EmitUpgradeClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { +// emitUpgradeClientEvent emits an upgrade client event +func emitUpgradeClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeUpgradeClient, @@ -81,8 +96,8 @@ func EmitUpgradeClientEvent(ctx sdk.Context, clientID string, clientState export }) } -// EmitUpdateClientProposalEvent emits an update client proposal event -func EmitUpdateClientProposalEvent(ctx sdk.Context, clientID, clientType string) { +// emitUpdateClientProposalEvent emits an update client proposal event +func emitUpdateClientProposalEvent(ctx sdk.Context, clientID, clientType string) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeUpdateClientProposal, @@ -96,8 +111,8 @@ func EmitUpdateClientProposalEvent(ctx sdk.Context, clientID, clientType string) }) } -// EmitUpgradeClientProposalEvent emits an upgrade client proposal event -func EmitUpgradeClientProposalEvent(ctx sdk.Context, title string, height int64) { +// emitUpgradeClientProposalEvent emits an upgrade client proposal event +func emitUpgradeClientProposalEvent(ctx sdk.Context, title string, height int64) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeUpgradeClientProposal, @@ -111,8 +126,8 @@ func EmitUpgradeClientProposalEvent(ctx sdk.Context, title string, height int64) }) } -// EmitSubmitMisbehaviourEvent emits a client misbehaviour event -func EmitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { +// emitSubmitMisbehaviourEvent emits a client misbehaviour event +func emitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSubmitMisbehaviour, @@ -125,18 +140,3 @@ func EmitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientState e ), }) } - -// EmitUpgradeChainEvent emits an upgrade chain event. -func EmitUpgradeChainEvent(ctx sdk.Context, height int64) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUpgradeChain, - sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)), - sdk.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} diff --git a/modules/core/02-client/keeper/proposal.go b/modules/core/02-client/keeper/proposal.go index a8c0d072ab3..9457b785ee9 100644 --- a/modules/core/02-client/keeper/proposal.go +++ b/modules/core/02-client/keeper/proposal.go @@ -63,7 +63,7 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo }() // emitting events in the keeper for proposal updates to clients - EmitUpdateClientProposalEvent(ctx, p.SubjectClientId, substituteClientState.ClientType()) + emitUpdateClientProposalEvent(ctx, p.SubjectClientId, substituteClientState.ClientType()) return nil } @@ -96,7 +96,7 @@ func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) } // emitting an event for handling client upgrade proposal - EmitUpgradeClientProposalEvent(ctx, p.Title, p.Plan.Height) + emitUpgradeClientProposalEvent(ctx, p.Title, p.Plan.Height) return nil } diff --git a/modules/core/03-connection/keeper/events.go b/modules/core/03-connection/keeper/events.go index cf7eefb69bc..e9e5a575990 100644 --- a/modules/core/03-connection/keeper/events.go +++ b/modules/core/03-connection/keeper/events.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" ) -// EmitConnectionOpenInitEvent emits a connection open init event -func EmitConnectionOpenInitEvent(ctx sdk.Context, connectionID string, clientID string, counterparty types.Counterparty) { +// emitConnectionOpenInitEvent emits a connection open init event +func emitConnectionOpenInitEvent(ctx sdk.Context, connectionID string, clientID string, counterparty types.Counterparty) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeConnectionOpenInit, @@ -23,8 +23,8 @@ func EmitConnectionOpenInitEvent(ctx sdk.Context, connectionID string, clientID }) } -// EmitConnectionOpenTryEvent emits a connection open try event -func EmitConnectionOpenTryEvent(ctx sdk.Context, connectionID string, clientID string, counterparty types.Counterparty) { +// emitConnectionOpenTryEvent emits a connection open try event +func emitConnectionOpenTryEvent(ctx sdk.Context, connectionID string, clientID string, counterparty types.Counterparty) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeConnectionOpenTry, @@ -40,8 +40,8 @@ func EmitConnectionOpenTryEvent(ctx sdk.Context, connectionID string, clientID s }) } -// EmitConnectionOpenAckEvent emits a connection open acknowledge event -func EmitConnectionOpenAckEvent(ctx sdk.Context, connectionID string, connectionEnd types.ConnectionEnd) { +// emitConnectionOpenAckEvent emits a connection open acknowledge event +func emitConnectionOpenAckEvent(ctx sdk.Context, connectionID string, connectionEnd types.ConnectionEnd) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeConnectionOpenAck, @@ -57,8 +57,8 @@ func EmitConnectionOpenAckEvent(ctx sdk.Context, connectionID string, connection }) } -// EmitConnectionOpenConfirmEvent emits a connection open confirm event -func EmitConnectionOpenConfirmEvent(ctx sdk.Context, connectionID string, connectionEnd types.ConnectionEnd) { +// emitConnectionOpenConfirmEvent emits a connection open confirm event +func emitConnectionOpenConfirmEvent(ctx sdk.Context, connectionID string, connectionEnd types.ConnectionEnd) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeConnectionOpenConfirm, diff --git a/modules/core/03-connection/keeper/handshake.go b/modules/core/03-connection/keeper/handshake.go index 93fe4a9bf6d..425bbf83805 100644 --- a/modules/core/03-connection/keeper/handshake.go +++ b/modules/core/03-connection/keeper/handshake.go @@ -47,7 +47,7 @@ func (k Keeper) ConnOpenInit( telemetry.IncrCounter(1, "ibc", "connection", "open-init") }() - EmitConnectionOpenInitEvent(ctx, connectionID, clientID, counterparty) + emitConnectionOpenInitEvent(ctx, connectionID, clientID, counterparty) return connectionID, nil } @@ -142,7 +142,7 @@ func (k Keeper) ConnOpenTry( telemetry.IncrCounter(1, "ibc", "connection", "open-try") }() - EmitConnectionOpenTryEvent(ctx, connectionID, clientID, counterparty) + emitConnectionOpenTryEvent(ctx, connectionID, clientID, counterparty) return connectionID, nil } @@ -241,7 +241,7 @@ func (k Keeper) ConnOpenAck( connection.Counterparty.ConnectionId = counterpartyConnectionID k.SetConnection(ctx, connectionID, connection) - EmitConnectionOpenAckEvent(ctx, connectionID, connection) + emitConnectionOpenAckEvent(ctx, connectionID, connection) return nil } @@ -291,7 +291,7 @@ func (k Keeper) ConnOpenConfirm( telemetry.IncrCounter(1, "ibc", "connection", "open-confirm") }() - EmitConnectionOpenConfirmEvent(ctx, connectionID, connection) + emitConnectionOpenConfirmEvent(ctx, connectionID, connection) return nil } diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index ddefecc697e..81304721b74 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -10,8 +10,8 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" ) -// EmitChannelOpenInitEvent emits a channel open init event -func EmitChannelOpenInitEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { +// emitChannelOpenInitEvent emits a channel open init event +func emitChannelOpenInitEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeChannelOpenInit, @@ -29,8 +29,8 @@ func EmitChannelOpenInitEvent(ctx sdk.Context, portID string, channelID string, }) } -// EmitChannelOpenTryEvent emits a channel open try event -func EmitChannelOpenTryEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { +// emitChannelOpenTryEvent emits a channel open try event +func emitChannelOpenTryEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeChannelOpenTry, @@ -48,8 +48,8 @@ func EmitChannelOpenTryEvent(ctx sdk.Context, portID string, channelID string, c }) } -// EmitChannelOpenAckEvent emits a channel open acknowledge event -func EmitChannelOpenAckEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { +// emitChannelOpenAckEvent emits a channel open acknowledge event +func emitChannelOpenAckEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeChannelOpenAck, @@ -66,8 +66,8 @@ func EmitChannelOpenAckEvent(ctx sdk.Context, portID string, channelID string, c }) } -// EmitChannelOpenConfirmEvent emits a channel open confirm event -func EmitChannelOpenConfirmEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { +// emitChannelOpenConfirmEvent emits a channel open confirm event +func emitChannelOpenConfirmEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeChannelOpenConfirm, @@ -84,8 +84,8 @@ func EmitChannelOpenConfirmEvent(ctx sdk.Context, portID string, channelID strin }) } -// EmitChannelCloseInitEvent emits a channel close init event -func EmitChannelCloseInitEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { +// emitChannelCloseInitEvent emits a channel close init event +func emitChannelCloseInitEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeChannelCloseInit, @@ -102,8 +102,8 @@ func EmitChannelCloseInitEvent(ctx sdk.Context, portID string, channelID string, }) } -// EmitChannelCloseConfirmEvent emits a channel close confirm event -func EmitChannelCloseConfirmEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { +// emitChannelCloseConfirmEvent emits a channel close confirm event +func emitChannelCloseConfirmEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeChannelCloseConfirm, @@ -120,9 +120,9 @@ func EmitChannelCloseConfirmEvent(ctx sdk.Context, portID string, channelID stri }) } -// EmitSendPacketEvent emits an event with packet data along with other packet information for relayer +// emitSendPacketEvent emits an event with packet data along with other packet information for relayer // to pick up and relay to other chain -func EmitSendPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel, timeoutHeight exported.Height) { +func emitSendPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel, timeoutHeight exported.Height) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSendPacket, @@ -147,9 +147,9 @@ func EmitSendPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types }) } -// EmitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet +// emitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet // is received for a certain sequence and for all duplicate receives. -func EmitRecvPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { +func emitRecvPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRecvPacket, @@ -174,8 +174,8 @@ func EmitRecvPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types }) } -// EmitWriteAcknowledgementEvent emits an event that the relayer can query for -func EmitWriteAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel, acknowledgement []byte) { +// emitWriteAcknowledgementEvent emits an event that the relayer can query for +func emitWriteAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel, acknowledgement []byte) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeWriteAck, @@ -201,9 +201,9 @@ func EmitWriteAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, cha }) } -// EmitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time +// emitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time // a packet is acknowledged for a certain sequence and for all duplicate acknowledgements. -func EmitAcknowledgePacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { +func emitAcknowledgePacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAcknowledgePacket, @@ -226,9 +226,9 @@ func EmitAcknowledgePacketEvent(ctx sdk.Context, packet exported.PacketI, channe }) } -// EmitTimeoutPacketEvent emits a timeout packet event. It will be emitted both the first time a packet +// emitTimeoutPacketEvent emits a timeout packet event. It will be emitted both the first time a packet // is timed out for a certain sequence and for all duplicate timeouts. -func EmitTimeoutPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { +func emitTimeoutPacketEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeTimeoutPacket, @@ -248,8 +248,8 @@ func EmitTimeoutPacketEvent(ctx sdk.Context, packet exported.PacketI, channel ty }) } -// EmitChannelClosedEvent emits a channel closed event. -func EmitChannelClosedEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { +// emitChannelClosedEvent emits a channel closed event. +func emitChannelClosedEvent(ctx sdk.Context, packet exported.PacketI, channel types.Channel) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeChannelClosed, diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index 922b681f104..bb2495c9656 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -89,7 +89,7 @@ func (k Keeper) WriteOpenInitChannel( telemetry.IncrCounter(1, "ibc", "channel", "open-init") }() - EmitChannelOpenInitEvent(ctx, portID, channelID, channel) + emitChannelOpenInitEvent(ctx, portID, channelID, channel) } // ChanOpenTry is called by a module to accept the first step of a channel opening @@ -202,7 +202,7 @@ func (k Keeper) WriteOpenTryChannel( telemetry.IncrCounter(1, "ibc", "channel", "open-try") }() - EmitChannelOpenTryEvent(ctx, portID, channelID, channel) + emitChannelOpenTryEvent(ctx, portID, channelID, channel) } // ChanOpenAck is called by the handshake-originating module to acknowledge the @@ -287,7 +287,7 @@ func (k Keeper) WriteOpenAckChannel( telemetry.IncrCounter(1, "ibc", "channel", "open-ack") }() - EmitChannelOpenAckEvent(ctx, portID, channelID, channel) + emitChannelOpenAckEvent(ctx, portID, channelID, channel) } // ChanOpenConfirm is called by the counterparty module to close their end of the @@ -367,7 +367,7 @@ func (k Keeper) WriteOpenConfirmChannel( telemetry.IncrCounter(1, "ibc", "channel", "open-confirm") }() - EmitChannelOpenConfirmEvent(ctx, portID, channelID, channel) + emitChannelOpenConfirmEvent(ctx, portID, channelID, channel) } // Closing Handshake @@ -417,7 +417,7 @@ func (k Keeper) ChanCloseInit( channel.State = types.CLOSED k.SetChannel(ctx, portID, channelID, channel) - EmitChannelCloseInitEvent(ctx, portID, channelID, channel) + emitChannelCloseInitEvent(ctx, portID, channelID, channel) return nil } @@ -482,7 +482,7 @@ func (k Keeper) ChanCloseConfirm( channel.State = types.CLOSED k.SetChannel(ctx, portID, channelID, channel) - EmitChannelCloseConfirmEvent(ctx, portID, channelID, channel) + emitChannelCloseConfirmEvent(ctx, portID, channelID, channel) return nil } diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 7268c37c574..2e283194326 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -102,7 +102,7 @@ func (k Keeper) SendPacket( k.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - EmitSendPacketEvent(ctx, packet, channel, timeoutHeight) + emitSendPacketEvent(ctx, packet, channel, timeoutHeight) k.Logger(ctx).Info( "packet sent", @@ -210,7 +210,7 @@ func (k Keeper) RecvPacket( // check if the packet receipt has been received already for unordered channels _, found := k.GetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if found { - EmitRecvPacketEvent(ctx, packet, channel) + emitRecvPacketEvent(ctx, packet, channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -234,7 +234,7 @@ func (k Keeper) RecvPacket( } if packet.GetSequence() < nextSequenceRecv { - EmitRecvPacketEvent(ctx, packet, channel) + emitRecvPacketEvent(ctx, packet, channel) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -269,7 +269,7 @@ func (k Keeper) RecvPacket( ) // emit an event that the relayer can query for - EmitRecvPacketEvent(ctx, packet, channel) + emitRecvPacketEvent(ctx, packet, channel) return nil } @@ -344,7 +344,7 @@ func (k Keeper) WriteAcknowledgement( "dst_channel", packet.GetDestChannel(), ) - EmitWriteAcknowledgementEvent(ctx, packet, channel, bz) + emitWriteAcknowledgementEvent(ctx, packet, channel, bz) return nil } @@ -417,7 +417,7 @@ func (k Keeper) AcknowledgePacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitAcknowledgePacketEvent(ctx, packet, channel) + emitAcknowledgePacketEvent(ctx, packet, channel) // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -479,7 +479,7 @@ func (k Keeper) AcknowledgePacket( ) // emit an event marking that we have processed the acknowledgement - EmitAcknowledgePacketEvent(ctx, packet, channel) + emitAcknowledgePacketEvent(ctx, packet, channel) return nil } diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 3ea9e48317e..ed82d3ccae1 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -75,7 +75,7 @@ func (k Keeper) TimeoutPacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitTimeoutPacketEvent(ctx, packet, channel) + emitTimeoutPacketEvent(ctx, packet, channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -168,10 +168,10 @@ func (k Keeper) TimeoutExecuted( ) // emit an event marking that we have processed the timeout - EmitTimeoutPacketEvent(ctx, packet, channel) + emitTimeoutPacketEvent(ctx, packet, channel) if channel.Ordering == types.ORDERED && channel.State == types.CLOSED { - EmitChannelClosedEvent(ctx, packet, channel) + emitChannelClosedEvent(ctx, packet, channel) } return nil @@ -224,7 +224,7 @@ func (k Keeper) TimeoutOnClose( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - EmitTimeoutPacketEvent(ctx, packet, channel) + emitTimeoutPacketEvent(ctx, packet, channel) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to From 6098f0a43b163e2ff3b9428ced00d77bae1e8474 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Mon, 27 Feb 2023 21:34:46 +0100 Subject: [PATCH 2/2] review comment --- modules/core/02-client/keeper/events.go | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/core/02-client/keeper/events.go b/modules/core/02-client/keeper/events.go index 932cdc65c9f..9b0bb6841ba 100644 --- a/modules/core/02-client/keeper/events.go +++ b/modules/core/02-client/keeper/events.go @@ -14,21 +14,6 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" ) -// EmitUpgradeChainEvent emits an upgrade chain event. -func EmitUpgradeChainEvent(ctx sdk.Context, height int64) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUpgradeChain, - sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)), - sdk.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) -} - // emitCreateClientEvent emits a create client event func emitCreateClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { ctx.EventManager().EmitEvents(sdk.Events{ @@ -140,3 +125,18 @@ func emitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientState e ), }) } + +// EmitUpgradeChainEvent emits an upgrade chain event. +func EmitUpgradeChainEvent(ctx sdk.Context, height int64) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeUpgradeChain, + sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)), + sdk.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) +}