Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
b3147e2909
commit
7e7e7f7e43
|
@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
* (x/slashing, x/staking) [#14363](https://github.com/cosmos/cosmos-sdk/pull/14363) Add the infraction a validator commited type as an argument to a `SlashWithInfractionReason` keeper method.
|
||||||
* (client) [#14051](https://github.com/cosmos/cosmos-sdk/pull/14051) Add `--grpc` client option.
|
* (client) [#14051](https://github.com/cosmos/cosmos-sdk/pull/14051) Add `--grpc` client option.
|
||||||
* (x/gentutil) [#14149](https://github.com/cosmos/cosmos-sdk/pull/14149) Add `genutilcli.GenesisCoreCommand` command, which contains all genesis-related sub-commands.
|
* (x/gentutil) [#14149](https://github.com/cosmos/cosmos-sdk/pull/14149) Add `genutilcli.GenesisCoreCommand` command, which contains all genesis-related sub-commands.
|
||||||
|
|
||||||
|
@ -180,7 +181,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||||
* (x/auth) [#13877](https://github.com/cosmos/cosmos-sdk/pull/13877) Rename `AccountKeeper`'s `GetNextAccountNumber` to `NextAccountNumber`.
|
* (x/auth) [#13877](https://github.com/cosmos/cosmos-sdk/pull/13877) Rename `AccountKeeper`'s `GetNextAccountNumber` to `NextAccountNumber`.
|
||||||
* (x/evidence) [#13740](https://github.com/cosmos/cosmos-sdk/pull/13740) The `NewQueryEvidenceRequest` function now takes `hash` as a HEX encoded `string`.
|
* (x/evidence) [#13740](https://github.com/cosmos/cosmos-sdk/pull/13740) The `NewQueryEvidenceRequest` function now takes `hash` as a HEX encoded `string`.
|
||||||
* (server) [#13485](https://github.com/cosmos/cosmos-sdk/pull/13485) The `Application` service now requires the `RegisterNodeService` method to be implemented.
|
* (server) [#13485](https://github.com/cosmos/cosmos-sdk/pull/13485) The `Application` service now requires the `RegisterNodeService` method to be implemented.
|
||||||
* (x/slashing, x/staking) [#13122](https://github.com/cosmos/cosmos-sdk/pull/13122) Add the infraction a validator commited type as an argument to the `Slash` keeper method.
|
|
||||||
* [#13437](https://github.com/cosmos/cosmos-sdk/pull/13437) Add a list of modules to export argument in `ExportAppStateAndValidators`.
|
* [#13437](https://github.com/cosmos/cosmos-sdk/pull/13437) Add a list of modules to export argument in `ExportAppStateAndValidators`.
|
||||||
* (x/slashing) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/slashing/testslashing` to `x/slashing/testutil` for consistency with other modules.
|
* (x/slashing) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/slashing/testslashing` to `x/slashing/testutil` for consistency with other modules.
|
||||||
* (x/staking) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/staking/teststaking` to `x/staking/testutil` for consistency with other modules.
|
* (x/staking) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/staking/teststaking` to `x/staking/testutil` for consistency with other modules.
|
||||||
|
|
|
@ -39,7 +39,7 @@ specifications for modules. The following list is nonbinding and all sections ar
|
||||||
|
|
||||||
### Notation for key-value mapping
|
### Notation for key-value mapping
|
||||||
|
|
||||||
Within `state.md` the following notation `->` should be used to describe key to
|
Within `## State` the following notation `->` should be used to describe key to
|
||||||
value mapping:
|
value mapping:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|
|
@ -137,7 +137,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
|
||||||
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
||||||
|
|
||||||
// slash the validator by 50%
|
// slash the validator by 50%
|
||||||
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1), stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
|
||||||
|
|
||||||
// retrieve validator
|
// retrieve validator
|
||||||
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
||||||
|
@ -212,7 +212,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
|
||||||
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
||||||
|
|
||||||
// slash the validator by 50%
|
// slash the validator by 50%
|
||||||
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1), stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
|
||||||
|
|
||||||
// fetch the validator again
|
// fetch the validator again
|
||||||
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
||||||
|
@ -226,7 +226,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
|
||||||
distrKeeper.AllocateTokensToValidator(ctx, val, tokens)
|
distrKeeper.AllocateTokensToValidator(ctx, val, tokens)
|
||||||
|
|
||||||
// slash the validator by 50% again
|
// slash the validator by 50% again
|
||||||
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower/2, sdk.NewDecWithPrec(5, 1), stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower/2, sdk.NewDecWithPrec(5, 1))
|
||||||
|
|
||||||
// fetch the validator again
|
// fetch the validator again
|
||||||
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
||||||
|
@ -466,10 +466,10 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
|
||||||
distrKeeper.AllocateTokensToValidator(ctx, val, tokens)
|
distrKeeper.AllocateTokensToValidator(ctx, val, tokens)
|
||||||
|
|
||||||
// slash the validator by 50%
|
// slash the validator by 50%
|
||||||
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1), stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
|
||||||
|
|
||||||
// slash the validator by 50% again
|
// slash the validator by 50% again
|
||||||
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower/2, sdk.NewDecWithPrec(5, 1), stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower/2, sdk.NewDecWithPrec(5, 1))
|
||||||
|
|
||||||
// fetch the validator again
|
// fetch the validator again
|
||||||
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
val = stakingKeeper.Validator(ctx, valAddrs[0])
|
||||||
|
@ -535,7 +535,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
|
||||||
|
|
||||||
// slash the validator
|
// slash the validator
|
||||||
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
||||||
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1), stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
|
||||||
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
||||||
|
|
||||||
// second delegation
|
// second delegation
|
||||||
|
@ -554,7 +554,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
|
||||||
|
|
||||||
// slash the validator again
|
// slash the validator again
|
||||||
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
||||||
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1), stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
stakingKeeper.Slash(ctx, valConsAddr0, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
|
||||||
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
|
||||||
|
|
||||||
// fetch updated validator
|
// fetch updated validator
|
||||||
|
|
|
@ -172,7 +172,7 @@ func TestSlashAtNegativeHeight(t *testing.T) {
|
||||||
|
|
||||||
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, -2, 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, -2, 10, fraction)
|
||||||
|
|
||||||
// read updated state
|
// read updated state
|
||||||
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
||||||
|
@ -203,7 +203,7 @@ func TestSlashValidatorAtCurrentHeight(t *testing.T) {
|
||||||
|
|
||||||
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction)
|
||||||
|
|
||||||
// read updated state
|
// read updated state
|
||||||
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
||||||
|
@ -243,7 +243,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||||
|
|
||||||
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, fraction)
|
||||||
|
|
||||||
// end block
|
// end block
|
||||||
applyValidatorSetUpdates(t, ctx, app.StakingKeeper, 1)
|
applyValidatorSetUpdates(t, ctx, app.StakingKeeper, 1)
|
||||||
|
@ -273,7 +273,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||||
|
|
||||||
// slash validator again
|
// slash validator again
|
||||||
ctx = ctx.WithBlockHeight(13)
|
ctx = ctx.WithBlockHeight(13)
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction)
|
||||||
|
|
||||||
ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0])
|
ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0])
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
|
@ -299,7 +299,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||||
// on the unbonding delegation, but it will slash stake bonded since the infraction
|
// on the unbonding delegation, but it will slash stake bonded since the infraction
|
||||||
// this may not be the desirable behaviour, ref https://github.com/cosmos/cosmos-sdk/issues/1440
|
// this may not be the desirable behaviour, ref https://github.com/cosmos/cosmos-sdk/issues/1440
|
||||||
ctx = ctx.WithBlockHeight(13)
|
ctx = ctx.WithBlockHeight(13)
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction)
|
||||||
|
|
||||||
ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0])
|
ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0])
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
|
@ -325,7 +325,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||||
// on the unbonding delegation, but it will slash stake bonded since the infraction
|
// on the unbonding delegation, but it will slash stake bonded since the infraction
|
||||||
// this may not be the desirable behaviour, ref https://github.com/cosmos/cosmos-sdk/issues/1440
|
// this may not be the desirable behaviour, ref https://github.com/cosmos/cosmos-sdk/issues/1440
|
||||||
ctx = ctx.WithBlockHeight(13)
|
ctx = ctx.WithBlockHeight(13)
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction)
|
||||||
|
|
||||||
ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0])
|
ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, addrDels[0], addrVals[0])
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
|
@ -383,7 +383,7 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
|
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, fraction)
|
||||||
})
|
})
|
||||||
burnAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt()
|
burnAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt()
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
|
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, math.LegacyOneDec(), types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, math.LegacyOneDec())
|
||||||
})
|
})
|
||||||
burnAmount = app.StakingKeeper.TokensFromConsensusPower(ctx, 7)
|
burnAmount = app.StakingKeeper.TokensFromConsensusPower(ctx, 7)
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
|
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, math.LegacyOneDec(), types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, math.LegacyOneDec())
|
||||||
})
|
})
|
||||||
|
|
||||||
burnAmount = sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(math.LegacyOneDec()).TruncateInt()
|
burnAmount = sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(math.LegacyOneDec()).TruncateInt()
|
||||||
|
@ -487,7 +487,7 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||||
require.Equal(t, validator.GetStatus(), types.Unbonding)
|
require.Equal(t, validator.GetStatus(), types.Unbonding)
|
||||||
|
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, math.LegacyOneDec(), types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr, 10, 10, math.LegacyOneDec())
|
||||||
})
|
})
|
||||||
|
|
||||||
// read updated pool
|
// read updated pool
|
||||||
|
@ -552,7 +552,7 @@ func TestSlashBoth(t *testing.T) {
|
||||||
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(PKs[0]))
|
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(PKs[0]))
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
consAddr0 := sdk.ConsAddress(PKs[0].Address())
|
consAddr0 := sdk.ConsAddress(PKs[0].Address())
|
||||||
app.StakingKeeper.Slash(ctx, consAddr0, 10, 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, consAddr0, 10, 10, fraction)
|
||||||
|
|
||||||
burnedNotBondedAmount := fraction.MulInt(ubdATokens).TruncateInt()
|
burnedNotBondedAmount := fraction.MulInt(ubdATokens).TruncateInt()
|
||||||
burnedBondAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt()
|
burnedBondAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt()
|
||||||
|
@ -583,11 +583,11 @@ func TestSlashAmount(t *testing.T) {
|
||||||
app, ctx, _, _ := bootstrapSlashTest(t, 10)
|
app, ctx, _, _ := bootstrapSlashTest(t, 10)
|
||||||
consAddr := sdk.ConsAddress(PKs[0].Address())
|
consAddr := sdk.ConsAddress(PKs[0].Address())
|
||||||
fraction := sdk.NewDecWithPrec(5, 1)
|
fraction := sdk.NewDecWithPrec(5, 1)
|
||||||
burnedCoins := app.StakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
burnedCoins := app.StakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction)
|
||||||
require.True(t, burnedCoins.GT(math.ZeroInt()))
|
require.True(t, burnedCoins.GT(math.ZeroInt()))
|
||||||
|
|
||||||
// test the case where the validator was not found, which should return no coins
|
// test the case where the validator was not found, which should return no coins
|
||||||
_, addrVals := generateAddresses(app, ctx, 100)
|
_, addrVals := generateAddresses(app, ctx, 100)
|
||||||
noBurned := app.StakingKeeper.Slash(ctx, sdk.ConsAddress(addrVals[0]), ctx.BlockHeight(), 10, fraction, types.Infraction_INFRACTION_UNSPECIFIED)
|
noBurned := app.StakingKeeper.Slash(ctx, sdk.ConsAddress(addrVals[0]), ctx.BlockHeight(), 10, fraction)
|
||||||
require.True(t, sdk.NewInt(0).Equal(noBurned))
|
require.True(t, sdk.NewInt(0).Equal(noBurned))
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) {
|
||||||
app.StakingKeeper.DeleteValidatorByPowerIndex(ctx, nextCliffVal)
|
app.StakingKeeper.DeleteValidatorByPowerIndex(ctx, nextCliffVal)
|
||||||
shares := app.StakingKeeper.TokensFromConsensusPower(ctx, 21)
|
shares := app.StakingKeeper.TokensFromConsensusPower(ctx, 21)
|
||||||
nextCliffVal, _ = nextCliffVal.RemoveDelShares(sdk.NewDecFromInt(shares))
|
nextCliffVal, _ = nextCliffVal.RemoveDelShares(sdk.NewDecFromInt(shares))
|
||||||
nextCliffVal = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, nextCliffVal, true)
|
_ = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, nextCliffVal, true)
|
||||||
|
|
||||||
expectedValStatus := map[int]types.BondStatus{
|
expectedValStatus := map[int]types.BondStatus{
|
||||||
9: types.Bonded, 8: types.Bonded, 7: types.Bonded, 5: types.Bonded, 4: types.Bonded,
|
9: types.Bonded, 8: types.Bonded, 7: types.Bonded, 5: types.Bonded, 4: types.Bonded,
|
||||||
|
@ -150,7 +150,7 @@ func TestSlashToZeroPowerRemoved(t *testing.T) {
|
||||||
require.Equal(t, valTokens, validator.Tokens, "\nvalidator %v\npool %v", validator, valTokens)
|
require.Equal(t, valTokens, validator.Tokens, "\nvalidator %v\npool %v", validator, valTokens)
|
||||||
|
|
||||||
// slash the validator by 100%
|
// slash the validator by 100%
|
||||||
app.StakingKeeper.Slash(ctx, sdk.ConsAddress(PKs[0].Address()), 0, 100, math.LegacyOneDec(), types.Infraction_INFRACTION_UNSPECIFIED)
|
app.StakingKeeper.Slash(ctx, sdk.ConsAddress(PKs[0].Address()), 0, 100, math.LegacyOneDec())
|
||||||
// apply TM updates
|
// apply TM updates
|
||||||
applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1)
|
applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1)
|
||||||
// validator should be unbonding
|
// validator should be unbonding
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestBasicManager(t *testing.T) {
|
||||||
|
|
||||||
wantDefaultGenesis := map[string]json.RawMessage{"mockAppModuleBasic1": json.RawMessage(``)}
|
wantDefaultGenesis := map[string]json.RawMessage{"mockAppModuleBasic1": json.RawMessage(``)}
|
||||||
|
|
||||||
mockAppModuleBasic1 := mock.NewMockAppModuleBasic(mockCtrl)
|
mockAppModuleBasic1 := mock.NewMockAppModuleWithAllExtensions(mockCtrl)
|
||||||
|
|
||||||
mockAppModuleBasic1.EXPECT().Name().AnyTimes().Return("mockAppModuleBasic1")
|
mockAppModuleBasic1.EXPECT().Name().AnyTimes().Return("mockAppModuleBasic1")
|
||||||
mockAppModuleBasic1.EXPECT().DefaultGenesis(gomock.Eq(cdc)).Times(1).Return(json.RawMessage(``))
|
mockAppModuleBasic1.EXPECT().DefaultGenesis(gomock.Eq(cdc)).Times(1).Return(json.RawMessage(``))
|
||||||
|
|
|
@ -120,7 +120,7 @@ func (k Keeper) HandleEquivocationEvidence(ctx sdk.Context, evidence *types.Equi
|
||||||
// to/by Tendermint. This value is validator.Tokens as sent to Tendermint via
|
// to/by Tendermint. This value is validator.Tokens as sent to Tendermint via
|
||||||
// ABCI, and now received as evidence. The fraction is passed in to separately
|
// ABCI, and now received as evidence. The fraction is passed in to separately
|
||||||
// to slash unbonding and rebonding delegations.
|
// to slash unbonding and rebonding delegations.
|
||||||
k.slashingKeeper.Slash(
|
k.slashingKeeper.SlashWithInfractionReason(
|
||||||
ctx,
|
ctx,
|
||||||
consAddr,
|
consAddr,
|
||||||
k.slashingKeeper.SlashFractionDoubleSign(ctx),
|
k.slashingKeeper.SlashFractionDoubleSign(ctx),
|
||||||
|
|
|
@ -157,15 +157,15 @@ func (mr *MockSlashingKeeperMockRecorder) JailUntil(arg0, arg1, arg2 interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slash mocks base method.
|
// Slash mocks base method.
|
||||||
func (m *MockSlashingKeeper) Slash(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types2.Infraction) {
|
func (m *MockSlashingKeeper) Slash(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4, arg5)
|
m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slash indicates an expected call of Slash.
|
// Slash indicates an expected call of Slash.
|
||||||
func (mr *MockSlashingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
func (mr *MockSlashingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockSlashingKeeper)(nil).Slash), arg0, arg1, arg2, arg3, arg4, arg5)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockSlashingKeeper)(nil).Slash), arg0, arg1, arg2, arg3, arg4)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SlashFractionDoubleSign mocks base method.
|
// SlashFractionDoubleSign mocks base method.
|
||||||
|
@ -182,6 +182,18 @@ func (mr *MockSlashingKeeperMockRecorder) SlashFractionDoubleSign(arg0 interface
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashFractionDoubleSign", reflect.TypeOf((*MockSlashingKeeper)(nil).SlashFractionDoubleSign), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashFractionDoubleSign", reflect.TypeOf((*MockSlashingKeeper)(nil).SlashFractionDoubleSign), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason mocks base method.
|
||||||
|
func (m *MockSlashingKeeper) SlashWithInfractionReason(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64, arg5 types2.Infraction) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason indicates an expected call of SlashWithInfractionReason.
|
||||||
|
func (mr *MockSlashingKeeperMockRecorder) SlashWithInfractionReason(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashWithInfractionReason", reflect.TypeOf((*MockSlashingKeeper)(nil).SlashWithInfractionReason), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||||
|
}
|
||||||
|
|
||||||
// Tombstone mocks base method.
|
// Tombstone mocks base method.
|
||||||
func (m *MockSlashingKeeper) Tombstone(arg0 types0.Context, arg1 types0.ConsAddress) {
|
func (m *MockSlashingKeeper) Tombstone(arg0 types0.Context, arg1 types0.ConsAddress) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
|
|
@ -25,7 +25,8 @@ type (
|
||||||
IsTombstoned(sdk.Context, sdk.ConsAddress) bool
|
IsTombstoned(sdk.Context, sdk.ConsAddress) bool
|
||||||
HasValidatorSigningInfo(sdk.Context, sdk.ConsAddress) bool
|
HasValidatorSigningInfo(sdk.Context, sdk.ConsAddress) bool
|
||||||
Tombstone(sdk.Context, sdk.ConsAddress)
|
Tombstone(sdk.Context, sdk.ConsAddress)
|
||||||
Slash(sdk.Context, sdk.ConsAddress, sdk.Dec, int64, int64, stakingtypes.Infraction)
|
Slash(sdk.Context, sdk.ConsAddress, sdk.Dec, int64, int64)
|
||||||
|
SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, sdk.Dec, int64, int64, stakingtypes.Infraction)
|
||||||
SlashFractionDoubleSign(sdk.Context) sdk.Dec
|
SlashFractionDoubleSign(sdk.Context) sdk.Dec
|
||||||
Jail(sdk.Context, sdk.ConsAddress)
|
Jail(sdk.Context, sdk.ConsAddress)
|
||||||
JailUntil(sdk.Context, sdk.ConsAddress, time.Time)
|
JailUntil(sdk.Context, sdk.ConsAddress, time.Time)
|
||||||
|
|
|
@ -284,7 +284,7 @@ for vote in block.LastCommitInfo.Votes {
|
||||||
// That's fine since this is just used to filter unbonding delegations & redelegations.
|
// That's fine since this is just used to filter unbonding delegations & redelegations.
|
||||||
distributionHeight := height - sdk.ValidatorUpdateDelay - 1
|
distributionHeight := height - sdk.ValidatorUpdateDelay - 1
|
||||||
|
|
||||||
Slash(vote.Validator.Address, distributionHeight, vote.Validator.Power, SlashFractionDowntime(), stakingtypes.Downtime)
|
SlashWithInfractionReason(vote.Validator.Address, distributionHeight, vote.Validator.Power, SlashFractionDowntime(), stakingtypes.Downtime)
|
||||||
Jail(vote.Validator.Address)
|
Jail(vote.Validator.Address)
|
||||||
|
|
||||||
signInfo.JailedUntil = block.Time.Add(DowntimeJailDuration())
|
signInfo.JailedUntil = block.Time.Add(DowntimeJailDuration())
|
||||||
|
|
|
@ -90,7 +90,7 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Addre
|
||||||
// That's fine since this is just used to filter unbonding delegations & redelegations.
|
// That's fine since this is just used to filter unbonding delegations & redelegations.
|
||||||
distributionHeight := height - sdk.ValidatorUpdateDelay - 1
|
distributionHeight := height - sdk.ValidatorUpdateDelay - 1
|
||||||
|
|
||||||
coinsBurned := k.sk.Slash(ctx, consAddr, distributionHeight, power, k.SlashFractionDowntime(ctx), stakingtypes.Infraction_INFRACTION_DOWNTIME)
|
coinsBurned := k.sk.SlashWithInfractionReason(ctx, consAddr, distributionHeight, power, k.SlashFractionDowntime(ctx), stakingtypes.Infraction_INFRACTION_DOWNTIME)
|
||||||
ctx.EventManager().EmitEvent(
|
ctx.EventManager().EmitEvent(
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeSlash,
|
types.EventTypeSlash,
|
||||||
|
|
|
@ -70,9 +70,15 @@ func (k Keeper) GetPubkey(ctx sdk.Context, a cryptotypes.Address) (cryptotypes.P
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slash attempts to slash a validator. The slash is delegated to the staking
|
// Slash attempts to slash a validator. The slash is delegated to the staking
|
||||||
// module to make the necessary validator changes.
|
// module to make the necessary validator changes. It specifies no intraction reason.
|
||||||
func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, fraction sdk.Dec, power, distributionHeight int64, infraction stakingtypes.Infraction) {
|
func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, fraction sdk.Dec, power, distributionHeight int64) {
|
||||||
coinsBurned := k.sk.Slash(ctx, consAddr, distributionHeight, power, fraction, infraction)
|
k.SlashWithInfractionReason(ctx, consAddr, fraction, power, distributionHeight, stakingtypes.Infraction_INFRACTION_UNSPECIFIED)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason attempts to slash a validator. The slash is delegated to the staking
|
||||||
|
// module to make the necessary validator changes. It specifies an intraction reason.
|
||||||
|
func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, fraction sdk.Dec, power, distributionHeight int64, infraction stakingtypes.Infraction) {
|
||||||
|
coinsBurned := k.sk.SlashWithInfractionReason(ctx, consAddr, distributionHeight, power, fraction, infraction)
|
||||||
ctx.EventManager().EmitEvent(
|
ctx.EventManager().EmitEvent(
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeSlash,
|
types.EventTypeSlash,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||||
slashingtestutil "github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
slashingtestutil "github.com/cosmos/cosmos-sdk/x/slashing/testutil"
|
||||||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var consAddr = sdk.ConsAddress(sdk.AccAddress([]byte("addr1_______________")))
|
var consAddr = sdk.ConsAddress(sdk.AccAddress([]byte("addr1_______________")))
|
||||||
|
@ -76,12 +76,12 @@ func (s *KeeperTestSuite) TestPubkey() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *KeeperTestSuite) TestJailAndSlash() {
|
func (s *KeeperTestSuite) TestJailAndSlash() {
|
||||||
s.stakingKeeper.EXPECT().Slash(s.ctx,
|
s.stakingKeeper.EXPECT().SlashWithInfractionReason(s.ctx,
|
||||||
consAddr,
|
consAddr,
|
||||||
s.ctx.BlockHeight(),
|
s.ctx.BlockHeight(),
|
||||||
sdk.TokensToConsensusPower(sdk.NewInt(1), sdk.DefaultPowerReduction),
|
sdk.TokensToConsensusPower(sdk.NewInt(1), sdk.DefaultPowerReduction),
|
||||||
s.slashingKeeper.SlashFractionDoubleSign(s.ctx),
|
s.slashingKeeper.SlashFractionDoubleSign(s.ctx),
|
||||||
types.Infraction_INFRACTION_DOUBLE_SIGN,
|
stakingtypes.Infraction_INFRACTION_UNSPECIFIED,
|
||||||
).Return(sdk.NewInt(0))
|
).Return(sdk.NewInt(0))
|
||||||
|
|
||||||
s.slashingKeeper.Slash(
|
s.slashingKeeper.Slash(
|
||||||
|
@ -90,7 +90,28 @@ func (s *KeeperTestSuite) TestJailAndSlash() {
|
||||||
s.slashingKeeper.SlashFractionDoubleSign(s.ctx),
|
s.slashingKeeper.SlashFractionDoubleSign(s.ctx),
|
||||||
sdk.TokensToConsensusPower(sdk.NewInt(1), sdk.DefaultPowerReduction),
|
sdk.TokensToConsensusPower(sdk.NewInt(1), sdk.DefaultPowerReduction),
|
||||||
s.ctx.BlockHeight(),
|
s.ctx.BlockHeight(),
|
||||||
types.Infraction_INFRACTION_DOUBLE_SIGN,
|
)
|
||||||
|
|
||||||
|
s.stakingKeeper.EXPECT().Jail(s.ctx, consAddr).Return()
|
||||||
|
s.slashingKeeper.Jail(s.ctx, consAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *KeeperTestSuite) TestJailAndSlashWithInfractionReason() {
|
||||||
|
s.stakingKeeper.EXPECT().SlashWithInfractionReason(s.ctx,
|
||||||
|
consAddr,
|
||||||
|
s.ctx.BlockHeight(),
|
||||||
|
sdk.TokensToConsensusPower(sdk.NewInt(1), sdk.DefaultPowerReduction),
|
||||||
|
s.slashingKeeper.SlashFractionDoubleSign(s.ctx),
|
||||||
|
stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN,
|
||||||
|
).Return(sdk.NewInt(0))
|
||||||
|
|
||||||
|
s.slashingKeeper.SlashWithInfractionReason(
|
||||||
|
s.ctx,
|
||||||
|
consAddr,
|
||||||
|
s.slashingKeeper.SlashFractionDoubleSign(s.ctx),
|
||||||
|
sdk.TokensToConsensusPower(sdk.NewInt(1), sdk.DefaultPowerReduction),
|
||||||
|
s.ctx.BlockHeight(),
|
||||||
|
stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN,
|
||||||
)
|
)
|
||||||
|
|
||||||
s.stakingKeeper.EXPECT().Jail(s.ctx, consAddr).Return()
|
s.stakingKeeper.EXPECT().Jail(s.ctx, consAddr).Return()
|
||||||
|
|
|
@ -334,17 +334,31 @@ func (mr *MockStakingKeeperMockRecorder) MaxValidators(arg0 interface{}) *gomock
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slash mocks base method.
|
// Slash mocks base method.
|
||||||
func (m *MockStakingKeeper) Slash(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types2.Infraction) math.Int {
|
func (m *MockStakingKeeper) Slash(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec) math.Int {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4, arg5)
|
ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4)
|
||||||
ret0, _ := ret[0].(math.Int)
|
ret0, _ := ret[0].(math.Int)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slash indicates an expected call of Slash.
|
// Slash indicates an expected call of Slash.
|
||||||
func (mr *MockStakingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
func (mr *MockStakingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockStakingKeeper)(nil).Slash), arg0, arg1, arg2, arg3, arg4, arg5)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockStakingKeeper)(nil).Slash), arg0, arg1, arg2, arg3, arg4)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason mocks base method.
|
||||||
|
func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types2.Infraction) math.Int {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||||
|
ret0, _ := ret[0].(math.Int)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason indicates an expected call of SlashWithInfractionReason.
|
||||||
|
func (mr *MockStakingKeeperMockRecorder) SlashWithInfractionReason(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashWithInfractionReason", reflect.TypeOf((*MockStakingKeeper)(nil).SlashWithInfractionReason), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unjail mocks base method.
|
// Unjail mocks base method.
|
||||||
|
|
|
@ -41,7 +41,8 @@ type StakingKeeper interface {
|
||||||
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI // get a particular validator by consensus address
|
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI // get a particular validator by consensus address
|
||||||
|
|
||||||
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
|
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
|
||||||
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, stakingtypes.Infraction) math.Int
|
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int
|
||||||
|
SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, stakingtypes.Infraction) math.Int
|
||||||
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
|
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
|
||||||
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
|
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,7 @@ import (
|
||||||
//
|
//
|
||||||
// Infraction was committed at the current height or at a past height,
|
// Infraction was committed at the current height or at a past height,
|
||||||
// not at a height in the future
|
// not at a height in the future
|
||||||
// ---
|
func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) math.Int {
|
||||||
//
|
|
||||||
// Slash implementation doesn't require the infraction (types.Infraction) to work but the IS one does. It is here to have IS satisfy the Slash signature.
|
|
||||||
func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec, _ types.Infraction) math.Int {
|
|
||||||
logger := k.Logger(ctx)
|
logger := k.Logger(ctx)
|
||||||
|
|
||||||
if slashFactor.IsNegative() {
|
if slashFactor.IsNegative() {
|
||||||
|
@ -159,6 +156,11 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh
|
||||||
return tokensToBurn
|
return tokensToBurn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason implementation doesn't require the infraction (types.Infraction) to work but is required by Interchain Security.
|
||||||
|
func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec, _ types.Infraction) math.Int {
|
||||||
|
return k.Slash(ctx, consAddr, infractionHeight, power, slashFactor)
|
||||||
|
}
|
||||||
|
|
||||||
// jail a validator
|
// jail a validator
|
||||||
func (k Keeper) Jail(ctx sdk.Context, consAddr sdk.ConsAddress) {
|
func (k Keeper) Jail(ctx sdk.Context, consAddr sdk.ConsAddress) {
|
||||||
validator := k.mustGetValidatorByConsAddr(ctx, consAddr)
|
validator := k.mustGetValidatorByConsAddr(ctx, consAddr)
|
||||||
|
|
|
@ -46,5 +46,5 @@ func (s *KeeperTestSuite) TestSlashAtFutureHeight() {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
fraction := sdk.NewDecWithPrec(5, 1)
|
fraction := sdk.NewDecWithPrec(5, 1)
|
||||||
require.Panics(func() { keeper.Slash(ctx, consAddr, 1, 10, fraction, 0) })
|
require.Panics(func() { keeper.Slash(ctx, consAddr, 1, 10, fraction) })
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,17 +403,31 @@ func (mr *MockValidatorSetMockRecorder) MaxValidators(arg0 interface{}) *gomock.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slash mocks base method.
|
// Slash mocks base method.
|
||||||
func (m *MockValidatorSet) Slash(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int {
|
func (m *MockValidatorSet) Slash(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec) math.Int {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4, arg5)
|
ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4)
|
||||||
ret0, _ := ret[0].(math.Int)
|
ret0, _ := ret[0].(math.Int)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slash indicates an expected call of Slash.
|
// Slash indicates an expected call of Slash.
|
||||||
func (mr *MockValidatorSetMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
func (mr *MockValidatorSetMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockValidatorSet)(nil).Slash), arg0, arg1, arg2, arg3, arg4, arg5)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockValidatorSet)(nil).Slash), arg0, arg1, arg2, arg3, arg4)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason mocks base method.
|
||||||
|
func (m *MockValidatorSet) SlashWithInfractionReason(arg0 types.Context, arg1 types.ConsAddress, arg2, arg3 int64, arg4 types.Dec, arg5 types1.Infraction) math.Int {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||||
|
ret0, _ := ret[0].(math.Int)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// SlashWithInfractionReason indicates an expected call of SlashWithInfractionReason.
|
||||||
|
func (mr *MockValidatorSetMockRecorder) SlashWithInfractionReason(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashWithInfractionReason", reflect.TypeOf((*MockValidatorSet)(nil).SlashWithInfractionReason), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StakingTokenSupply mocks base method.
|
// StakingTokenSupply mocks base method.
|
||||||
|
|
|
@ -61,7 +61,8 @@ type ValidatorSet interface {
|
||||||
StakingTokenSupply(sdk.Context) math.Int // total staking token supply
|
StakingTokenSupply(sdk.Context) math.Int // total staking token supply
|
||||||
|
|
||||||
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
|
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
|
||||||
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, Infraction) math.Int
|
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int
|
||||||
|
SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, Infraction) math.Int
|
||||||
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
|
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
|
||||||
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
|
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue