diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index fc1ccd6137..f633cf70ad 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -93,14 +93,14 @@ func (k Keeper) DistributeToProviderValidatorSet(ctx sdk.Context) error { ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeFeeDistribution, + ccv.EventTypeFeeDistribution, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeDistributionCurrentHeight, strconv.Itoa(int(curHeight))), - sdk.NewAttribute(types.AttributeDistributionNextHeight, strconv.Itoa(int(curHeight+k.GetBlocksPerDistributionTransmission(ctx)))), - sdk.NewAttribute(types.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))), - sdk.NewAttribute(types.AttributeDistributionTotal, fpTokens.String()), - sdk.NewAttribute(types.AttributeDistributionToConsumer, consRedistrTokens.String()), - sdk.NewAttribute(types.AttributeDistributionToProvider, remainingTokens.String()), + sdk.NewAttribute(ccv.AttributeDistributionCurrentHeight, strconv.Itoa(int(curHeight))), + sdk.NewAttribute(ccv.AttributeDistributionNextHeight, strconv.Itoa(int(curHeight+k.GetBlocksPerDistributionTransmission(ctx)))), + sdk.NewAttribute(ccv.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))), + sdk.NewAttribute(ccv.AttributeDistributionTotal, fpTokens.String()), + sdk.NewAttribute(ccv.AttributeDistributionToConsumer, consRedistrTokens.String()), + sdk.NewAttribute(ccv.AttributeDistributionToProvider, remainingTokens.String()), ), ) diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go index 646cdd2f1a..00e1770b1d 100644 --- a/x/ccv/consumer/keeper/relay.go +++ b/x/ccv/consumer/keeper/relay.go @@ -11,7 +11,6 @@ import ( channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" "github.com/cosmos/interchain-security/x/ccv/consumer/types" - consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" utils "github.com/cosmos/interchain-security/x/ccv/utils" abci "github.com/tendermint/tendermint/abci/types" @@ -42,8 +41,8 @@ func (k Keeper) OnRecvVSCPacket(ctx sdk.Context, packet channeltypes.Packet, new // emit first VSC packet to signal that CCV is working ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeFirstVSCPacket, - sdk.NewAttribute(sdk.AttributeKeyModule, consumertypes.ModuleName), + ccv.EventTypeFirstVSCPacket, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(channeltypes.AttributeKeySrcChannel, packet.SourceChannel), sdk.NewAttribute(channeltypes.AttributeKeySrcPort, packet.SourcePort), sdk.NewAttribute(channeltypes.AttributeKeyDstChannel, packet.DestinationChannel), @@ -126,12 +125,12 @@ func (k Keeper) SendVSCMaturedPackets(ctx sdk.Context) error { k.DeletePacketMaturityTime(ctx, vscId) ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeSendMaturedVSCPacket, + ccv.EventTypeSendMaturedVSCPacket, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(consumertypes.AttributeChainID, ctx.ChainID()), - sdk.NewAttribute(consumertypes.AttributeConsumerHeight, strconv.Itoa(int(ctx.BlockHeight()))), - sdk.NewAttribute(consumertypes.AttributeValSetUpdateID, strconv.Itoa(int(vscId))), - sdk.NewAttribute(consumertypes.AttributeTimestamp, strconv.Itoa(int(currentTime))), + sdk.NewAttribute(ccv.AttributeChainID, ctx.ChainID()), + sdk.NewAttribute(ccv.AttributeConsumerHeight, strconv.Itoa(int(ctx.BlockHeight()))), + sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(vscId))), + sdk.NewAttribute(ccv.AttributeTimestamp, strconv.Itoa(int(currentTime))), ), ) } else { @@ -189,11 +188,11 @@ func (k Keeper) SendSlashPacket(ctx sdk.Context, validator abci.Validator, valse // will instead take place in SendPendingSlashRequests ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeSendSlashPacket, - sdk.NewAttribute(sdk.AttributeKeyModule, consumertypes.ModuleName), - sdk.NewAttribute(types.AttributeValAddress, sdk.ConsAddress(validator.Address).String()), - sdk.NewAttribute(types.AttributeValSetUpdateID, strconv.Itoa(int(valsetUpdateID))), - sdk.NewAttribute(types.AttributeInfraction, infraction.String()), + ccv.EventTypeSendSlashPacket, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(ccv.AttributeValidatorAddress, sdk.ConsAddress(validator.Address).String()), + sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(valsetUpdateID))), + sdk.NewAttribute(ccv.AttributeInfractionType, infraction.String()), ), ) } @@ -236,11 +235,11 @@ func (k Keeper) SendPendingSlashRequests(ctx sdk.Context) { ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeSendSlashPacket, - sdk.NewAttribute(sdk.AttributeKeyModule, consumertypes.ModuleName), - sdk.NewAttribute(types.AttributeValAddress, sdk.ConsAddress(slashReq.Packet.Validator.Address).String()), - sdk.NewAttribute(types.AttributeValSetUpdateID, strconv.Itoa(int(slashReq.Packet.ValsetUpdateId))), - sdk.NewAttribute(types.AttributeInfraction, slashReq.Packet.Infraction.String()), + ccv.EventTypeSendSlashPacket, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(ccv.AttributeValidatorAddress, sdk.ConsAddress(slashReq.Packet.Validator.Address).String()), + sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(slashReq.Packet.ValsetUpdateId))), + sdk.NewAttribute(ccv.AttributeInfractionType, slashReq.Packet.Infraction.String()), ), ) } diff --git a/x/ccv/consumer/types/events.go b/x/ccv/consumer/types/events.go deleted file mode 100644 index cc9f05bf9a..0000000000 --- a/x/ccv/consumer/types/events.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -// CCV events -const ( - EventTypeFirstVSCPacket = "ccv_first_vsc_packet" - EventTypeFeeDistribution = "ccv_fee_distribution" - EventTypeSendSlashPacket = "ccv_send_slash_packet" - EventTypeSendMaturedVSCPacket = "ccv_send_maturec_vsc_packet" - - AttributeDistributionCurrentHeight = "current_distribution_height" - AttributeDistributionNextHeight = "next_distribution_height" - AttributeDistributionFraction = "distribution_fraction" - AttributeDistributionTotal = "total" - AttributeDistributionToConsumer = "consumer_amount" - AttributeDistributionToProvider = "provider_amount" - - AttributeValAddress = "validator_address" - AttributeValSetUpdateID = "valset_update_id" - AttributeInfraction = "infraction" - AttributeTimestamp = "timestamp" - AttributeConsumerHeight = "consumer_height" - AttributeChainID = "chain_id" -) diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 4a27d809df..9ba043ed48 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "strconv" "time" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" @@ -94,6 +95,20 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, chainID string, if lockUbdOnTimeout { k.SetLockUnbondingOnTimeout(ctx, chainID) } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + clienttypes.EventTypeCreateClient, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(ccv.AttributeChainID, chainID), + sdk.NewAttribute(clienttypes.AttributeKeyClientID, clientID), + sdk.NewAttribute(ccv.AttributeInitialHeight, initialHeight.String()), + sdk.NewAttribute(ccv.AttributeInitializationTimeout, strconv.Itoa(int(ts.UnixNano()))), + sdk.NewAttribute(ccv.AttributeTrustingPeriod, clientState.TrustingPeriod.String()), + sdk.NewAttribute(ccv.AttributeUnbondingPeriod, clientState.UnbondingPeriod.String()), + ), + ) + return nil } diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 5d24d1944a..73b66bbc98 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -313,8 +313,8 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas sdk.NewEvent( ccv.EventExecuteConsumerChainSlash, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(ccv.AttributeValidatorAddres, consAddr.String()), - sdk.NewAttribute(ccv.AttributeInfraction, data.Infraction.String()), + sdk.NewAttribute(ccv.AttributeValidatorAddress, consAddr.String()), + sdk.NewAttribute(ccv.AttributeInfractionType, data.Infraction.String()), sdk.NewAttribute(ccv.AttributeInfractionHeight, strconv.Itoa(int(infractionHeight))), sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(data.ValsetUpdateId))), ), diff --git a/x/ccv/types/events.go b/x/ccv/types/events.go index 495c5fd71b..791056f110 100644 --- a/x/ccv/types/events.go +++ b/x/ccv/types/events.go @@ -6,17 +6,34 @@ const ( EventTypePacket = "ccv_packet" EventTypeChannelClose = "channel_closed" - EventTypeConsumerChainAdded = "ccv_consumer_added" - EventTypeFeeTransferChannelOpened = "ccv_fee_channel_opened" - EventExecuteConsumerChainSlash = "ccv_execute_consumer_chain_slash" + EventTypeConsumerChainAdded = "consumer_added" + EventTypeFeeTransferChannelOpened = "fee_channel_opened" + EventExecuteConsumerChainSlash = "execute_consumer_chain_slash" + EventTypeFirstVSCPacket = "first_vsc_packet" + EventTypeFeeDistribution = "fee_distribution" + EventTypeSendSlashPacket = "send_slash_packet" + EventTypeSendMaturedVSCPacket = "send_matured_vsc_packet" AttributeKeyAckSuccess = "success" AttributeKeyAck = "acknowledgement" AttributeKeyAckError = "error" - AttributeChainID = "chain_id" - AttributeValidatorAddres = "validator_address" - AttributeInfraction = "infraction" - AttributeInfractionHeight = "infraction_height" - AttributeValSetUpdateID = "valset_update_id" + AttributeChainID = "chain_id" + AttributeValidatorAddress = "validator_address" + AttributeInfractionType = "infraction_type" + AttributeInfractionHeight = "infraction_height" + AttributeConsumerHeight = "consumer_height" + AttributeValSetUpdateID = "valset_update_id" + AttributeTimestamp = "timestamp" + AttributeInitialHeight = "initial_height" + AttributeInitializationTimeout = "initialization_timeout" + AttributeTrustingPeriod = "trusting_period" + AttributeUnbondingPeriod = "unbonding_period" + + AttributeDistributionCurrentHeight = "current_distribution_height" + AttributeDistributionNextHeight = "next_distribution_height" + AttributeDistributionFraction = "distribution_fraction" + AttributeDistributionTotal = "total" + AttributeDistributionToConsumer = "consumer_amount" + AttributeDistributionToProvider = "provider_amount" )