Skip to content

Commit

Permalink
add pending slash request clearing events
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Nov 10, 2022
1 parent 9327b7e commit da1f89c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
10 changes: 10 additions & 0 deletions x/ccv/consumer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ func (k Keeper) SendVSCMaturedPackets(ctx sdk.Context) error {
return err
}
k.DeletePacketMaturityTime(ctx, vscId)
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.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))),
),
)
} else {
break
}
Expand Down
10 changes: 7 additions & 3 deletions x/ccv/consumer/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package types

// CCV events
const (
EventTypeFirstVSCPacket = "ccv_first_vsc_packet"
EventTypeFeeDistribution = "ccv_fee_distribution"
EventTypeSendSlashPacket = "ccv_send_slash_packet"
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"
Expand All @@ -16,4 +17,7 @@ const (
AttributeValAddress = "validator_address"
AttributeValSetUpdateID = "valset_update_id"
AttributeInfraction = "infraction"
AttributeTimestamp = "timestamp"
AttributeConsumerHeight = "consumer_height"
AttributeChainID = "chain_id"
)
12 changes: 12 additions & 0 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"fmt"
"strconv"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -308,6 +309,17 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas
}
k.slashingKeeper.JailUntil(ctx, consAddr, jailTime)

ctx.EventManager().EmitEvent(
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.AttributeInfractionHeight, strconv.Itoa(int(infractionHeight))),
sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(data.ValsetUpdateId))),
),
)

return true, nil
}

Expand Down
7 changes: 6 additions & 1 deletion x/ccv/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ const (

EventTypeConsumerChainAdded = "ccv_consumer_added"
EventTypeFeeTransferChannelOpened = "ccv_fee_channel_opened"
EventExecuteConsumerChainSlash = "ccv_execute_consumer_chain_slash"

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

AttributeChainID = "chain_id"
AttributeChainID = "chain_id"
AttributeValidatorAddres = "validator_address"
AttributeInfraction = "infraction"
AttributeInfractionHeight = "infraction_height"
AttributeValSetUpdateID = "valset_update_id"
)

0 comments on commit da1f89c

Please sign in to comment.