Skip to content

Commit

Permalink
Moved events
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Oct 11, 2023
1 parent 8d62477 commit de3bef2
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 60 deletions.
2 changes: 1 addition & 1 deletion x/ccv/consumer/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (am AppModule) OnChanOpenAck(

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeFeeTransferChannelOpened,
consumertypes.EventTypeFeeTransferChannelOpened,
sdk.NewAttribute(sdk.AttributeKeyModule, consumertypes.ModuleName),
sdk.NewAttribute(channeltypes.AttributeKeyChannelID, channelID),
sdk.NewAttribute(channeltypes.AttributeKeyPortID, transfertypes.PortID),
Expand Down
12 changes: 6 additions & 6 deletions x/ccv/consumer/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error {
currentHeight := ctx.BlockHeight()
ctx.EventManager().EmitEvent(
sdk.NewEvent(
ccv.EventTypeFeeDistribution,
types.EventTypeFeeDistribution,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(ccv.AttributeDistributionCurrentHeight, strconv.Itoa(int(currentHeight))),
sdk.NewAttribute(ccv.AttributeDistributionNextHeight, strconv.Itoa(int(currentHeight+k.GetBlocksPerDistributionTransmission(ctx)))),
sdk.NewAttribute(ccv.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))),
sdk.NewAttribute(ccv.AttributeDistributionTotal, allBalances.String()),
sdk.NewAttribute(ccv.AttributeDistributionToProvider, sentCoins.String()),
sdk.NewAttribute(types.AttributeDistributionCurrentHeight, strconv.Itoa(int(currentHeight))),
sdk.NewAttribute(types.AttributeDistributionNextHeight, strconv.Itoa(int(currentHeight+k.GetBlocksPerDistributionTransmission(ctx)))),
sdk.NewAttribute(types.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))),
sdk.NewAttribute(types.AttributeDistributionTotal, allBalances.String()),
sdk.NewAttribute(types.AttributeDistributionToProvider, sentCoins.String()),
),
)

Expand Down
8 changes: 4 additions & 4 deletions x/ccv/consumer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ func (k Keeper) QueueVSCMaturedPackets(ctx sdk.Context) {

ctx.EventManager().EmitEvent(
sdk.NewEvent(
ccv.EventTypeVSCMatured,
types.EventTypeVSCMatured,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(ccv.AttributeChainID, ctx.ChainID()),
sdk.NewAttribute(ccv.AttributeConsumerHeight, strconv.Itoa(int(ctx.BlockHeight()))),
sdk.NewAttribute(types.AttributeConsumerHeight, strconv.Itoa(int(ctx.BlockHeight()))),
sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(maturityTime.VscId))),
sdk.NewAttribute(ccv.AttributeTimestamp, ctx.BlockTime().String()),
sdk.NewAttribute(types.AttributeTimestamp, ctx.BlockTime().String()),
),
)
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func (k Keeper) QueueSlashPacket(ctx sdk.Context, validator abci.Validator, vals

ctx.EventManager().EmitEvent(
sdk.NewEvent(
ccv.EventTypeConsumerSlashRequest,
types.EventTypeConsumerSlashRequest,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(ccv.AttributeValidatorAddress, sdk.ConsAddress(validator.Address).String()),
sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(valsetUpdateID))),
Expand Down
18 changes: 18 additions & 0 deletions x/ccv/consumer/types/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package types

const (
AttributeConsumerHeight = "consumer_height"
AttributeTimestamp = "timestamp"

EventTypeFeeDistribution = "fee_distribution"
EventTypeVSCMatured = "vsc_matured"
EventTypeConsumerSlashRequest = "consumer_slash_request"
EventTypeFeeTransferChannelOpened = "fee_transfer_channel_opened"

//#nosec G101 -- (false positive) this is not a hardcoded credential
AttributeDistributionCurrentHeight = "current_distribution_height"
AttributeDistributionNextHeight = "next_distribution_height"
AttributeDistributionFraction = "distribution_fraction"
AttributeDistributionTotal = "total"
AttributeDistributionToProvider = "provider_amount"
)
7 changes: 3 additions & 4 deletions x/ccv/provider/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
)

type msgServer struct {
Expand Down Expand Up @@ -100,9 +99,9 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
ccvtypes.EventTypeAssignConsumerKey,
sdk.NewAttribute(ccvtypes.AttributeProviderValidatorAddress, msg.ProviderAddr),
sdk.NewAttribute(ccvtypes.AttributeConsumerConsensusPubKey, consumerTMPublicKey.String()),
types.EventTypeAssignConsumerKey,
sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr),
sdk.NewAttribute(types.AttributeConsumerConsensusPubKey, consumerTMPublicKey.String()),
),
})

Expand Down
18 changes: 9 additions & 9 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi

ctx.EventManager().EmitEvent(
sdk.NewEvent(
ccv.EventTypeConsumerClientCreated,
types.EventTypeConsumerClientCreated,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(ccv.AttributeChainID, chainID),
sdk.NewAttribute(clienttypes.AttributeKeyClientID, clientID),
sdk.NewAttribute(ccv.AttributeInitialHeight, prop.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()),
sdk.NewAttribute(types.AttributeInitialHeight, prop.InitialHeight.String()),
sdk.NewAttribute(types.AttributeInitializationTimeout, strconv.Itoa(int(ts.UnixNano()))),
sdk.NewAttribute(types.AttributeTrustingPeriod, clientState.TrustingPeriod.String()),
sdk.NewAttribute(types.AttributeUnbondingPeriod, clientState.UnbondingPeriod.String()),
),
)

Expand Down Expand Up @@ -612,8 +612,8 @@ func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, p *types.Chan
}
k.SetConsumerRewardDenom(ctx, denomToAdd)
ctx.EventManager().EmitEvent(sdk.NewEvent(
ccv.EventTypeAddConsumerRewardDenom,
sdk.NewAttribute(ccv.AttributeConsumerRewardDenom, denomToAdd),
types.EventTypeAddConsumerRewardDenom,
sdk.NewAttribute(types.AttributeConsumerRewardDenom, denomToAdd),
))
}
for _, denomToRemove := range p.DenomsToRemove {
Expand All @@ -624,8 +624,8 @@ func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, p *types.Chan
}
k.DeleteConsumerRewardDenom(ctx, denomToRemove)
ctx.EventManager().EmitEvent(sdk.NewEvent(
ccv.EventTypeRemoveConsumerRewardDenom,
sdk.NewAttribute(ccv.AttributeConsumerRewardDenom, denomToRemove),
types.EventTypeRemoveConsumerRewardDenom,
sdk.NewAttribute(types.AttributeConsumerRewardDenom, denomToRemove),
))
}
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 @@ -426,11 +426,11 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas

ctx.EventManager().EmitEvent(
sdk.NewEvent(
ccv.EventTypeExecuteConsumerChainSlash,
providertypes.EventTypeExecuteConsumerChainSlash,
sdk.NewAttribute(sdk.AttributeKeyModule, providertypes.ModuleName),
sdk.NewAttribute(ccv.AttributeValidatorAddress, providerConsAddr.String()),
sdk.NewAttribute(ccv.AttributeInfractionType, data.Infraction.String()),
sdk.NewAttribute(ccv.AttributeInfractionHeight, strconv.Itoa(int(infractionHeight))),
sdk.NewAttribute(providertypes.AttributeInfractionHeight, strconv.Itoa(int(infractionHeight))),
sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(data.ValsetUpdateId))),
),
)
Expand Down
18 changes: 18 additions & 0 deletions x/ccv/provider/types/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package types

// Provider events
const (
EventTypeConsumerClientCreated = "consumer_client_created"
EventTypeAssignConsumerKey = "assign_consumer_key"
EventTypeAddConsumerRewardDenom = "add_consumer_reward_denom"
EventTypeRemoveConsumerRewardDenom = "remove_consumer_reward_denom"
EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash"
AttributeInfractionHeight = "infraction_height"
AttributeInitialHeight = "initial_height"
AttributeInitializationTimeout = "initialization_timeout"
AttributeTrustingPeriod = "trusting_period"
AttributeUnbondingPeriod = "unbonding_period"
AttributeProviderValidatorAddress = "provider_validator_address"
AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key"
AttributeConsumerRewardDenom = "consumer_reward_denom"
)
41 changes: 7 additions & 34 deletions x/ccv/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,17 @@ package types

// CCV events
const (
EventTypeTimeout = "timeout"
EventTypePacket = "ccv_packet"
EventTypeChannelEstablished = "channel_established"
EventTypeFeeTransferChannelOpened = "fee_transfer_channel_opened"
EventTypeConsumerClientCreated = "consumer_client_created"
EventTypeAssignConsumerKey = "assign_consumer_key"
EventTypeAddConsumerRewardDenom = "add_consumer_reward_denom"
EventTypeRemoveConsumerRewardDenom = "remove_consumer_reward_denom"

EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash"
EventTypeFeeDistribution = "fee_distribution"
EventTypeConsumerSlashRequest = "consumer_slash_request"
EventTypeVSCMatured = "vsc_matured"
EventTypeTimeout = "timeout"
EventTypePacket = "ccv_packet"
EventTypeChannelEstablished = "channel_established"

AttributeKeyAckSuccess = "success"
AttributeKeyAck = "acknowledgement"
AttributeKeyAckError = "error"

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"
AttributeProviderValidatorAddress = "provider_validator_address"
AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key"

AttributeDistributionCurrentHeight = "current_distribution_height"
//#nosec G101 -- (false positive) this is not a hardcoded credential
AttributeDistributionNextHeight = "next_distribution_height"
AttributeDistributionFraction = "distribution_fraction"
AttributeDistributionTotal = "total"
AttributeDistributionToProvider = "provider_amount"
AttributeChainID = "chain_id"
AttributeValidatorAddress = "validator_address"
AttributeInfractionType = "infraction_type"

AttributeConsumerRewardDenom = "consumer_reward_denom"
AttributeValSetUpdateID = "valset_update_id"
)

0 comments on commit de3bef2

Please sign in to comment.