fix(x/slashing): Emit slashing event with the correct reason in SlashWithInfractionReason (backport #16784) (#16792)
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
0bbfc654a3
commit
ce08c799e1
@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (x/auth/vesting) [#16733](https://github.com/cosmos/cosmos-sdk/pull/16733) Panic on overflowing and negative EndTimes when creating a PeriodicVestingAccount.
|
||||
* (baseapp) [#16700](https://github.com/cosmos/cosmos-sdk/pull/16700) Fix consensus failure in returning no response to malformed transactions.
|
||||
* (baseapp) [#16596](https://github.com/cosmos/cosmos-sdk/pull/16596) Return error during ExtendVote and VerifyVoteExtension if the request height is earlier than `VoteExtensionsEnableHeight`.
|
||||
* (x/slashing) [#16784](https://github.com/cosmos/cosmos-sdk/pull/16784) Emit event with the correct reason in SlashWithInfractionReason.
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user