Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Add tombstone field to SlashJailParameters #2433

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/docs/build/modules/02-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -2884,11 +2884,13 @@ grpcurl -plaintext -d '{"consumer_id": "0"}' localhost:9090 interchain_security.
"infraction_parameters":{
"double_sign":{
"slash_fraction":"0.050000000000000000",
"jail_duration":"9223372036.854775807s"
"jail_duration":"9223372036.854775807s",
"tombstone": true
},
"downtime":{
"slash_fraction":"0.000000000000000000",
"jail_duration":"600s"
"jail_duration":"600s",
"tombstone": false
}
},
"clientId": "07-tendermint-28"
Expand Down Expand Up @@ -3594,11 +3596,13 @@ Output:
"infraction_parameters":{
"double_sign":{
"slash_fraction":"0.050000000000000000",
"jail_duration":"9223372036.854775807s"
"jail_duration":"9223372036.854775807s",
"tombstone": true
},
"downtime":{
"slash_fraction":"0.000000000000000000",
"jail_duration":"600s"
"jail_duration":"600s",
"tombstone": false
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -574,4 +574,6 @@ message SlashJailParameters {
// for permanent jailing use 9223372036854775807 which is the largest value a time.Duration can hold (approximately 292 years)
google.protobuf.Duration jail_duration = 2
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];
// Indicates whether the validator should be tombstoned when slashed
bool tombstone = 3;
}
2 changes: 2 additions & 0 deletions testutil/keeper/unit_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,12 @@ func GetTestInfractionParameters() providertypes.InfractionParameters {
DoubleSign: &providertypes.SlashJailParameters{
JailDuration: 1200 * time.Second,
SlashFraction: math.LegacyNewDecWithPrec(5, 1), // 0.5
Tombstone: true,
},
Downtime: &providertypes.SlashJailParameters{
JailDuration: 600 * time.Second,
SlashFraction: math.LegacyNewDec(0),
Tombstone: false,
},
}
}
Expand Down
12 changes: 8 additions & 4 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,13 @@ where create_consumer.json has the following structure:
"infraction_parameters":{
"double_sign":{
"slash_fraction": "0.05",
"jail_duration": 9223372036854775807
"jail_duration": 9223372036854775807,
"tombstone": true
},
"downtime":{
"slash_fraction": "0.0001",
"jail_duration": 600000000000
"jail_duration": 600000000000,
"tombstone": false
}
},
"allowlisted_reward_denoms": {
Expand Down Expand Up @@ -369,11 +371,13 @@ where update_consumer.json has the following structure:
"infraction_parameters":{
"double_sign":{
"slash_fraction": "0.05",
"jail_duration": 9223372036854775807
"jail_duration": 9223372036854775807,
"tombstone": true
},
"downtime":{
"slash_fraction": "0.0001",
"jail_duration": 600000000000
"jail_duration": 600000000000,
"tombstone": false
}
},
"allowlisted_reward_denoms": {
Expand Down
16 changes: 11 additions & 5 deletions x/ccv/provider/keeper/consumer_equivocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,17 @@ func (k Keeper) JailAndTombstoneValidator(ctx sdk.Context, providerAddr types.Pr
return fmt.Errorf("fail to set jail duration for validator: %s: %s", providerAddr.String(), err)
}

// Tombstone the validator so that we cannot slash the validator more than once
// Note that we cannot simply use the fact that a validator is jailed to avoid slashing more than once
// because then a validator could i) perform an equivocation, ii) get jailed (e.g., through downtime)
// and in such a case the validator would not get slashed when we call `SlashValidator`.
return k.slashingKeeper.Tombstone(ctx, providerAddr.ToSdkConsAddr())
if jailingParams.Tombstone {
// Tombstone the validator so that we cannot slash the validator more than once
// Note that we cannot simply use the fact that a validator is jailed to avoid slashing more than once
// because then a validator could i) perform an equivocation, ii) get jailed (e.g., through downtime)
// and in such a case the validator would not get slashed when we call `SlashValidator`.
if err = k.slashingKeeper.Tombstone(ctx, providerAddr.ToSdkConsAddr()); err != nil {
return fmt.Errorf("fail to tombstone validator: %s: %s", providerAddr.String(), err)
}
}

return nil
}

// ComputePowerToSlash computes the power to be slashed based on the tokens in non-matured `undelegations` and
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/keeper/consumer_equivocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,10 +792,12 @@ func getTestInfractionParameters() *types.InfractionParameters {
DoubleSign: &types.SlashJailParameters{
JailDuration: 1200 * time.Second,
SlashFraction: math.LegacyNewDecWithPrec(5, 1), // 0.5
Tombstone: true,
},
Downtime: &types.SlashJailParameters{
JailDuration: 600 * time.Second,
SlashFraction: math.LegacyNewDec(0),
Tombstone: false,
},
}
}
3 changes: 3 additions & 0 deletions x/ccv/provider/keeper/infraction_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ func compareSlashJailParameters(param1, param2 *types.SlashJailParameters) bool
if param1 == nil || param2 == nil {
return false
}
if param1.Tombstone != param2.Tombstone {
return false
}
if !param1.SlashFraction.Equal(param2.SlashFraction) {
return false
}
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/types/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,12 @@ func TestMsgCreateConsumerValidateBasic(t *testing.T) {
DoubleSign: &types.SlashJailParameters{
JailDuration: time.Duration(1<<63 - 1), // max duration
SlashFraction: math.LegacyNewDecWithPrec(5, 2), // 0.05
Tombstone: true,
},
Downtime: &types.SlashJailParameters{
JailDuration: 600 * time.Second,
SlashFraction: math.LegacyNewDec(0),
Tombstone: false,
},
}, // valid infraction params
true,
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/types/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ func DefaultConsumerInfractionParameters(ctx context.Context, slashingKeeper ccv
DoubleSign: &SlashJailParameters{
JailDuration: time.Duration(1<<63 - 1), // the largest value a time.Duration can hold 9223372036854775807 (approximately 292 years)
SlashFraction: doubleSignSlashingFraction,
Tombstone: true,
},
Downtime: &SlashJailParameters{
JailDuration: jailDuration,
SlashFraction: math.LegacyNewDec(0),
Tombstone: false,
},
}, nil
}
Loading
Loading