Skip to content

Commit

Permalink
move all events to ccv; add CreateClient event on provi
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Nov 10, 2022
1 parent da1f89c commit 46e45c0
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 58 deletions.
14 changes: 7 additions & 7 deletions x/ccv/consumer/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
),
)

Expand Down
35 changes: 17 additions & 18 deletions x/ccv/consumer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()),
),
)
}
Expand Down Expand Up @@ -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()),
),
)
}
Expand Down
23 changes: 0 additions & 23 deletions x/ccv/consumer/types/events.go

This file was deleted.

15 changes: 15 additions & 0 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"fmt"
"strconv"
"time"

channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
),
Expand Down
33 changes: 25 additions & 8 deletions x/ccv/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit 46e45c0

Please sign in to comment.