Skip to content

Commit

Permalink
add additional checks for equivocation governance proposals (#730)
Browse files Browse the repository at this point in the history
* add slash log functionality

* update tests

* refactor; add integration tests

* refactor after reviews

* comments

---------

Co-authored-by: Shawn <[email protected]>
  • Loading branch information
MSalopek and shaspitz authored Feb 10, 2023
1 parent 5563395 commit 2c5942d
Show file tree
Hide file tree
Showing 13 changed files with 408 additions and 140 deletions.
8 changes: 7 additions & 1 deletion tests/e2e/throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() {

// Track and increment ibc seq num for each packet, since these need to be unique.
ibcSeqNum := uint64(0)

// Construct 500 double-sign slash packets
for ibcSeqNum < 500 {
// Increment ibc seq num for each packet (starting at 1)
Expand Down Expand Up @@ -405,6 +404,13 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() {
s.Require().Fail("validator not found")
}
s.Require().False(stakingVal.Jailed)

// 4th validator should have no slash log, all the others do
if val != s.providerChain.Vals.Validators[3] {
s.Require().True(providerKeeper.GetSlashLog(s.providerCtx(), sdk.ConsAddress(val.Address)))
} else {
s.Require().False(providerKeeper.GetSlashLog(s.providerCtx(), sdk.ConsAddress(val.Address)))
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions tests/integration/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ var happyPathSteps = concatSteps(
stepsUnbond("consu"),
stepsRedelegate("consu"),
stepsDowntime("consu"),
stepsSubmitEquivocationProposal("consu", 2),
stepsRejectEquivocationProposal("consu", 2), // prop to tombstone bob is rejected
stepsDoubleSignOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer
stepsSubmitEquivocationProposal("consu", 2), // now prop to tombstone bob is submitted and accepted
stepsStopChain("consu", 3),
)

Expand All @@ -46,5 +48,5 @@ var multipleConsumers = concatSteps(
stepsMultiConsumerRedelegate("consu", "densu"),
stepsMultiConsumerDowntimeFromConsumer("consu", "densu"),
stepsMultiConsumerDowntimeFromProvider("consu", "densu"),
stepsDoubleSign("consu", "densu"), // double sign on one of the chains
stepsMultiConsumerDoubleSign("consu", "densu"), // double sign on one of the chains
)
129 changes: 16 additions & 113 deletions tests/integration/steps_double_sign.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package main

// simulates double signing on provider and vsc propagation to consumer chains
//
// Note: These steps would be affected by slash packet throttling, since the
// consumer-initiated slash steps are executed after consumer-initiated downtime
// slashes have already occurred. However slash packet throttling is
// psuedo-disabled in this test by setting the slash meter replenish
// fraction to 1.0 in the config file.
//
// only double sign on provider chain will cause slashing and tombstoning
func stepsDoubleSign(consumer1, consumer2 string) []Step {
// Steps that make carol double sign on the provider, and bob double sign on a single consumer
func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step {
return []Step{
{
// provider double sign
Expand All @@ -26,28 +18,21 @@ func stepsDoubleSign(consumer1, consumer2 string) []Step {
validatorID("carol"): 0, // from 500 to 0
},
},
chainID(consumer1): ChainState{
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 495, // not tombstoned on consumer1 yet
},
},
chainID(consumer2): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 495, // not tombstoned on consumer2 yet
validatorID("carol"): 495, // not tombstoned on consumerName yet
},
},
},
},
{
// relay power change to consumer1
// relay power change to consumerName
action: relayPacketsAction{
chain: chainID("provi"),
port: "provider",
channel: 0, // consumer1 channel
channel: 0, // consumerName channel
},
state: State{
chainID("provi"): ChainState{
Expand All @@ -57,56 +42,19 @@ func stepsDoubleSign(consumer1, consumer2 string) []Step {
validatorID("carol"): 0,
},
},
chainID(consumer1): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0, // tombstoning visible on consumer1
},
},
chainID(consumer2): ChainState{
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 495, // tombstoning NOT YET visible on consumer2
},
},
},
},
{
// relay power change to consumer2
action: relayPacketsAction{
chain: chainID("provi"),
port: "provider",
channel: 1, // consumer2 channel
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0,
},
},
chainID(consumer1): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0,
},
},
chainID(consumer2): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0, // tombstoned on consumer2
validatorID("carol"): 0, // tombstoning visible on consumerName
},
},
},
},
{
// consumer double sign
// nothing should happen - double sign from consumer is dropped
// provider will only log the double sign slash
// stepsSubmitEquivocationProposal will cause the double sign slash to be executed
action: doublesignSlashAction{
chain: chainID("consu"),
validator: validatorID("bob"),
Expand All @@ -119,14 +67,7 @@ func stepsDoubleSign(consumer1, consumer2 string) []Step {
validatorID("carol"): 0,
},
},
chainID(consumer1): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0,
},
},
chainID(consumer2): ChainState{
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
Expand All @@ -139,7 +80,7 @@ func stepsDoubleSign(consumer1, consumer2 string) []Step {
action: relayPacketsAction{
chain: chainID("provi"),
port: "provider",
channel: 0, // consumer1 channel
channel: 0,
},
state: State{
chainID("provi"): ChainState{
Expand All @@ -149,14 +90,7 @@ func stepsDoubleSign(consumer1, consumer2 string) []Step {
validatorID("carol"): 0,
},
},
chainID(consumer1): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500, // not tombstoned
validatorID("carol"): 0,
},
},
chainID(consumer2): ChainState{
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500, // not tombstoned
Expand All @@ -166,28 +100,21 @@ func stepsDoubleSign(consumer1, consumer2 string) []Step {
},
},
{
// consumer1 learns about the double sign
// consumer learns about the double sign
action: relayPacketsAction{
chain: chainID("provi"),
port: "provider",
channel: 0, // consumer1 channel
channel: 0,
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0, // not tombstoned
},
},
chainID(consumer1): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500, // not tombstoned
validatorID("carol"): 0,
},
},
chainID(consumer2): ChainState{
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500, // not tombstoned
Expand All @@ -196,29 +123,5 @@ func stepsDoubleSign(consumer1, consumer2 string) []Step {
},
},
},
{
// consumer2 learns about the double sign
action: relayPacketsAction{
chain: chainID("provi"),
port: "provider",
channel: 1, // consumer2 channel
},
state: State{
chainID(consumer1): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0,
},
},
chainID(consumer2): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0,
},
},
},
},
}
}
Loading

0 comments on commit 2c5942d

Please sign in to comment.