diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cec73de10..4311819bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (x/slashing) [#16784](https://github.com/cosmos/cosmos-sdk/pull/16784) Emit event with the correct reason in SlashWithInfractionReason. * (x/auth/vesting) [#16733](https://github.com/cosmos/cosmos-sdk/pull/16733) panic on overflowing and negative EndTimes when creating a PeriodicVestingAccount * [#16547](https://github.com/cosmos/cosmos-sdk/pull/16547) Ensure a transaction's gas limit cannot exceed the block gas limit. * (x/auth/types) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. diff --git a/x/slashing/keeper/keeper.go b/x/slashing/keeper/keeper.go index 8d3eba35f2..b710e78e3f 100644 --- a/x/slashing/keeper/keeper.go +++ b/x/slashing/keeper/keeper.go @@ -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()), ), ) diff --git a/x/slashing/types/events.go b/x/slashing/types/events.go index 600e59932e..af115fee53 100644 --- a/x/slashing/types/events.go +++ b/x/slashing/types/events.go @@ -13,6 +13,7 @@ const ( AttributeKeyMissedBlocks = "missed_blocks" AttributeKeyBurnedCoins = "burned_coins" + AttributeValueUnspecified = "unspecified" AttributeValueDoubleSign = "double_sign" AttributeValueMissingSignature = "missing_signature" )