fix(x/slashing): Emit slashing event with the correct reason in SlashWithInfractionReason (#16784)
This commit is contained in:
@@ -88,13 +88,21 @@ func (k Keeper) SlashWithInfractionReason(ctx context.Context, consAddr sdk.Cons
|
||||
return err
|
||||
}
|
||||
|
||||
reasonAttr := sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueUnspecified)
|
||||
switch infraction {
|
||||
case stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN:
|
||||
reasonAttr = sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueDoubleSign)
|
||||
case stakingtypes.Infraction_INFRACTION_DOWNTIME:
|
||||
reasonAttr = sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueMissingSignature)
|
||||
}
|
||||
|
||||
sdkCtx := sdk.UnwrapSDKContext(ctx)
|
||||
sdkCtx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
types.EventTypeSlash,
|
||||
sdk.NewAttribute(types.AttributeKeyAddress, consAddr.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyPower, fmt.Sprintf("%d", power)),
|
||||
sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueDoubleSign),
|
||||
reasonAttr,
|
||||
sdk.NewAttribute(types.AttributeKeyBurnedCoins, coinsBurned.String()),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ const (
|
||||
AttributeKeyMissedBlocks = "missed_blocks"
|
||||
AttributeKeyBurnedCoins = "burned_coins"
|
||||
|
||||
AttributeValueUnspecified = "unspecified"
|
||||
AttributeValueDoubleSign = "double_sign"
|
||||
AttributeValueMissingSignature = "missing_signature"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user