Skip to content

Commit 67b0fbd

Browse files
authored
feat!: Add tombstone field to SlashJailParameters (#2433)
* add tombstone field to SlashJailParameters * test fix * make the tombstone field irrelevant for downtime infractions * add log when setting tomstone to true for downtime
1 parent b7a14d8 commit 67b0fbd

File tree

10 files changed

+237
-163
lines changed

10 files changed

+237
-163
lines changed

docs/docs/build/modules/02-provider.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,11 +2884,13 @@ grpcurl -plaintext -d '{"consumer_id": "0"}' localhost:9090 interchain_security.
28842884
"infraction_parameters":{
28852885
"double_sign":{
28862886
"slash_fraction":"0.050000000000000000",
2887-
"jail_duration":"9223372036.854775807s"
2887+
"jail_duration":"9223372036.854775807s",
2888+
"tombstone": true
28882889
},
28892890
"downtime":{
28902891
"slash_fraction":"0.000000000000000000",
2891-
"jail_duration":"600s"
2892+
"jail_duration":"600s",
2893+
"tombstone": false
28922894
}
28932895
},
28942896
"clientId": "07-tendermint-28"
@@ -3594,11 +3596,13 @@ Output:
35943596
"infraction_parameters":{
35953597
"double_sign":{
35963598
"slash_fraction":"0.050000000000000000",
3597-
"jail_duration":"9223372036.854775807s"
3599+
"jail_duration":"9223372036.854775807s",
3600+
"tombstone": true
35983601
},
35993602
"downtime":{
36003603
"slash_fraction":"0.000000000000000000",
3601-
"jail_duration":"600s"
3604+
"jail_duration":"600s",
3605+
"tombstone": false
36023606
}
36033607
}
36043608
}

proto/interchain_security/ccv/provider/v1/provider.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,4 +574,6 @@ message SlashJailParameters {
574574
// for permanent jailing use 9223372036854775807 which is the largest value a time.Duration can hold (approximately 292 years)
575575
google.protobuf.Duration jail_duration = 2
576576
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];
577+
// Indicates whether the validator should be tombstoned when slashed
578+
bool tombstone = 3;
577579
}

testutil/keeper/unit_test_helpers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ func GetTestInfractionParameters() providertypes.InfractionParameters {
306306
DoubleSign: &providertypes.SlashJailParameters{
307307
JailDuration: 1200 * time.Second,
308308
SlashFraction: math.LegacyNewDecWithPrec(5, 1), // 0.5
309+
Tombstone: true,
309310
},
310311
Downtime: &providertypes.SlashJailParameters{
311312
JailDuration: 600 * time.Second,
312313
SlashFraction: math.LegacyNewDec(0),
314+
Tombstone: false,
313315
},
314316
}
315317
}

x/ccv/provider/client/cli/tx.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,13 @@ where create_consumer.json has the following structure:
260260
"infraction_parameters":{
261261
"double_sign":{
262262
"slash_fraction": "0.05",
263-
"jail_duration": 9223372036854775807
263+
"jail_duration": 9223372036854775807,
264+
"tombstone": true
264265
},
265266
"downtime":{
266267
"slash_fraction": "0.0001",
267-
"jail_duration": 600000000000
268+
"jail_duration": 600000000000,
269+
"tombstone": false
268270
}
269271
},
270272
"allowlisted_reward_denoms": {
@@ -369,11 +371,13 @@ where update_consumer.json has the following structure:
369371
"infraction_parameters":{
370372
"double_sign":{
371373
"slash_fraction": "0.05",
372-
"jail_duration": 9223372036854775807
374+
"jail_duration": 9223372036854775807,
375+
"tombstone": true
373376
},
374377
"downtime":{
375378
"slash_fraction": "0.0001",
376-
"jail_duration": 600000000000
379+
"jail_duration": 600000000000,
380+
"tombstone": false
377381
}
378382
},
379383
"allowlisted_reward_denoms": {

x/ccv/provider/keeper/consumer_equivocation.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,17 @@ func (k Keeper) JailAndTombstoneValidator(ctx sdk.Context, providerAddr types.Pr
451451
return fmt.Errorf("fail to set jail duration for validator: %s: %s", providerAddr.String(), err)
452452
}
453453

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

461467
// ComputePowerToSlash computes the power to be slashed based on the tokens in non-matured `undelegations` and

x/ccv/provider/keeper/consumer_equivocation_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,12 @@ func getTestInfractionParameters() *types.InfractionParameters {
792792
DoubleSign: &types.SlashJailParameters{
793793
JailDuration: 1200 * time.Second,
794794
SlashFraction: math.LegacyNewDecWithPrec(5, 1), // 0.5
795+
Tombstone: true,
795796
},
796797
Downtime: &types.SlashJailParameters{
797798
JailDuration: 600 * time.Second,
798799
SlashFraction: math.LegacyNewDec(0),
800+
Tombstone: false,
799801
},
800802
}
801803
}

x/ccv/provider/keeper/infraction_parameters.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func (k Keeper) SetInfractionParameters(ctx sdk.Context, consumerId string, para
3333
return fmt.Errorf("failed to marshal infraction parameters (%+v) for consumer id (%s): %w", parameters, consumerId, err)
3434
}
3535

36+
if parameters.Downtime.Tombstone {
37+
k.Logger(ctx).Info("tombstone field is ignored for downtime infractions; setting it to true for consumer ID (%s) will have no effect", consumerId)
38+
}
39+
3640
store.Set(types.ConsumerIdToInfractionParametersKey(consumerId), bz)
3741

3842
return nil
@@ -250,6 +254,9 @@ func compareSlashJailParameters(param1, param2 *types.SlashJailParameters) bool
250254
if param1 == nil || param2 == nil {
251255
return false
252256
}
257+
if param1.Tombstone != param2.Tombstone {
258+
return false
259+
}
253260
if !param1.SlashFraction.Equal(param2.SlashFraction) {
254261
return false
255262
}

x/ccv/provider/types/msg_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,12 @@ func TestMsgCreateConsumerValidateBasic(t *testing.T) {
470470
DoubleSign: &types.SlashJailParameters{
471471
JailDuration: time.Duration(1<<63 - 1), // max duration
472472
SlashFraction: math.LegacyNewDecWithPrec(5, 2), // 0.05
473+
Tombstone: true,
473474
},
474475
Downtime: &types.SlashJailParameters{
475476
JailDuration: 600 * time.Second,
476477
SlashFraction: math.LegacyNewDec(0),
478+
Tombstone: false,
477479
},
478480
}, // valid infraction params
479481
true,

x/ccv/provider/types/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ func DefaultConsumerInfractionParameters(ctx context.Context, slashingKeeper ccv
4444
DoubleSign: &SlashJailParameters{
4545
JailDuration: time.Duration(1<<63 - 1), // the largest value a time.Duration can hold 9223372036854775807 (approximately 292 years)
4646
SlashFraction: doubleSignSlashingFraction,
47+
Tombstone: true,
4748
},
4849
Downtime: &SlashJailParameters{
4950
JailDuration: jailDuration,
5051
SlashFraction: math.LegacyNewDec(0),
52+
Tombstone: false,
5153
},
5254
}, nil
5355
}

0 commit comments

Comments
 (0)