From 7fb7975914928679db2d3fb1da288c16c7414299 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Wed, 3 Apr 2024 12:43:28 +0200
Subject: [PATCH 1/4] Expand test to include slashing
---
tests/e2e/steps_partial_set_security.go | 145 +++++++++++++++++++++---
1 file changed, 129 insertions(+), 16 deletions(-)
diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go
index b9536caa0c..6243b3faba 100644
--- a/tests/e2e/steps_partial_set_security.go
+++ b/tests/e2e/steps_partial_set_security.go
@@ -182,15 +182,94 @@ func stepsOptInChain() []Step {
},
},
{
- Action: OptOutAction{
+ // DowntimeSlash for alice on consumer
+ Action: DowntimeSlashAction{
Chain: ChainID("consu"),
- Validator: ValidatorID("bob"),
+ Validator: ValidatorID("alice"),
+ },
+ // powers are not affected yet on either chain
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 100,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 100,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
+ {
+ // relay the slash packet
+ Action: RelayPacketsAction{
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
+ Channel: 0,
+ },
+ // alice's power is reduced on the provider
+ State: State{
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
+ {
+ // relay the vsc packet that contains the slashed power for alice
+ Action: RelayPacketsAction{
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
+ Channel: 0,
},
+ // alice's power is reduced on the provider
State: State{
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ // alice should definitely not be in power on the consumer
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
+ {
+ // unjail alice
+ Action: UnjailValidatorAction{
+ Provider: ChainID("provi"),
+ Validator: ValidatorID("alice"),
+ },
+ // alices power is restored on the provider
+ State: State{
+ ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 100,
- // "bob" has not yet opted out from the consumer chain because the VSCPacket has not yet been relayed
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ // still 0 power on the consumer
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
ValidatorID("bob"): 200,
ValidatorID("carol"): 300,
},
@@ -198,52 +277,86 @@ func stepsOptInChain() []Step {
},
},
{
+ // relay the vsc packet that puts alice back into power on the consumer
Action: RelayPacketsAction{
ChainA: ChainID("provi"),
ChainB: ChainID("consu"),
Port: "provider",
Channel: 0,
},
+ // alice's power is restored on the consumer
State: State{
ChainID("consu"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 100,
- // bob has now opted out
- ValidatorID("bob"): 0,
+ ValidatorID("bob"): 200,
ValidatorID("carol"): 300,
},
},
},
},
- {
- // re opt-in "bob"
- Action: OptInAction{
+ { // slash alice for downtime again
+ Action: DowntimeSlashAction{
Chain: ChainID("consu"),
- Validator: ValidatorID("bob"),
+ Validator: ValidatorID("alice"),
},
+ // alice's power is not yet reduced, the packet needs to be relayed
State: State{
ChainID("consu"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 100,
- // "bob" has not yet been opted in from the consumer chain because the VSCPacket has not yet been relayed
- ValidatorID("bob"): 0,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 100,
+ ValidatorID("bob"): 200,
ValidatorID("carol"): 300,
},
},
},
},
{
+ // relay the slash packet
Action: RelayPacketsAction{
- ChainA: ChainID("provi"),
- ChainB: ChainID("consu"),
- Port: "provider",
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
+ Channel: 0,
+ },
+ // alice's power is reduced on the provider
+ State: State{
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
+ {
+ // relay the vsc packet that contains the slashed power for alice
+ Action: RelayPacketsAction{
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
Channel: 0,
},
+ // alice's power is reduced on the consumer
State: State{
ChainID("consu"): ChainState{
ValPowers: &map[ValidatorID]uint{
- ValidatorID("alice"): 100,
- // bob has now opted in
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
ValidatorID("bob"): 200,
ValidatorID("carol"): 300,
},
From de9772c66fa8c9a063224668780f8433f7bb7018 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Wed, 3 Apr 2024 12:47:24 +0200
Subject: [PATCH 2/4] Add back existing steps
---
tests/e2e/steps_partial_set_security.go | 69 +++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go
index 6243b3faba..5c87a0effb 100644
--- a/tests/e2e/steps_partial_set_security.go
+++ b/tests/e2e/steps_partial_set_security.go
@@ -181,6 +181,75 @@ func stepsOptInChain() []Step {
},
},
},
+ {
+ Action: OptOutAction{
+ Chain: ChainID("consu"),
+ Validator: ValidatorID("bob"),
+ },
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 100,
+ // "bob" has not yet opted out from the consumer chain because the VSCPacket has not yet been relayed
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
+ {
+ Action: RelayPacketsAction{
+ ChainA: ChainID("provi"),
+ ChainB: ChainID("consu"),
+ Port: "provider",
+ Channel: 0,
+ },
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 100,
+ // bob has now opted out
+ ValidatorID("bob"): 0,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
+ {
+ // re opt-in "bob"
+ Action: OptInAction{
+ Chain: ChainID("consu"),
+ Validator: ValidatorID("bob"),
+ },
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 100,
+ // "bob" has not yet been opted in to the consumer chain because the VSCPacket has not yet been relayed
+ ValidatorID("bob"): 0,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
+ {
+ Action: RelayPacketsAction{
+ ChainA: ChainID("provi"),
+ ChainB: ChainID("consu"),
+ Port: "provider",
+ Channel: 0,
+ },
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 100,
+ // bob is in power on the consumer
+ ValidatorID("bob"): 200,
+ ValidatorID("carol"): 300,
+ },
+ },
+ },
+ },
{
// DowntimeSlash for alice on consumer
Action: DowntimeSlashAction{
From 6d6a79e04529f01fe11673333d9ac78656af60b9 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Wed, 3 Apr 2024 12:53:29 +0200
Subject: [PATCH 3/4] Add downtime to top N test
---
tests/e2e/steps_partial_set_security.go | 208 ++++++++++++++++++++++++
1 file changed, 208 insertions(+)
diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go
index 5c87a0effb..65c4183a4d 100644
--- a/tests/e2e/steps_partial_set_security.go
+++ b/tests/e2e/steps_partial_set_security.go
@@ -658,6 +658,214 @@ func stepsTopNChain() []Step {
},
},
},
+ // opt alice back in
+ {
+ Action: OptInAction{
+ Chain: ChainID("consu"),
+ Validator: ValidatorID("alice"),
+ },
+ State: State{},
+ },
+ {
+ Action: RelayPacketsAction{
+ ChainA: ChainID("provi"),
+ ChainB: ChainID("consu"),
+ Port: "provider",
+ Channel: 0,
+ },
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ // "alice" has now opted in
+ ValidatorID("alice"): 200,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ {
+ // DowntimeSlash for alice on consumer
+ Action: DowntimeSlashAction{
+ Chain: ChainID("consu"),
+ Validator: ValidatorID("alice"),
+ },
+ // powers are not affected yet on either chain
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 200,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 200,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ {
+ // relay the slash packet
+ Action: RelayPacketsAction{
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
+ Channel: 0,
+ },
+ // alice's power is reduced on the provider
+ State: State{
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ {
+ // relay the vsc packet that contains the slashed power for alice
+ Action: RelayPacketsAction{
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
+ Channel: 0,
+ },
+ // alice's power is reduced on the provider
+ State: State{
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ // alice should definitely not be in power on the consumer
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ {
+ // unjail alice
+ Action: UnjailValidatorAction{
+ Provider: ChainID("provi"),
+ Validator: ValidatorID("alice"),
+ },
+ // alices power is restored on the provider
+ State: State{
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 200,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ // still 0 power on the consumer
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ {
+ // relay the vsc packet that puts alice back into power on the consumer
+ Action: RelayPacketsAction{
+ ChainA: ChainID("provi"),
+ ChainB: ChainID("consu"),
+ Port: "provider",
+ Channel: 0,
+ },
+ // alice's power is restored on the consumer
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 200,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ { // slash alice for downtime again
+ Action: DowntimeSlashAction{
+ Chain: ChainID("consu"),
+ Validator: ValidatorID("alice"),
+ },
+ // alice's power is not yet reduced, the packet needs to be relayed
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 200,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 200,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ {
+ // relay the slash packet
+ Action: RelayPacketsAction{
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
+ Channel: 0,
+ },
+ // alice's power is reduced on the provider
+ State: State{
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
+ {
+ // relay the vsc packet that contains the slashed power for alice
+ Action: RelayPacketsAction{
+ ChainA: ChainID("consu"),
+ ChainB: ChainID("provi"),
+ Port: "consumer",
+ Channel: 0,
+ },
+ // alice's power is reduced on the consumer
+ State: State{
+ ChainID("consu"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ ChainID("provi"): ChainState{
+ ValPowers: &map[ValidatorID]uint{
+ ValidatorID("alice"): 0,
+ ValidatorID("bob"): 300,
+ ValidatorID("carol"): 500,
+ },
+ },
+ },
+ },
}
return s
From 99baf3d35176951b7cd61be966f3fd39df32e08b Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Wed, 3 Apr 2024 13:43:58 +0200
Subject: [PATCH 4/4] Fix nits
---
tests/e2e/steps_partial_set_security.go | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go
index 65c4183a4d..751a710499 100644
--- a/tests/e2e/steps_partial_set_security.go
+++ b/tests/e2e/steps_partial_set_security.go
@@ -294,7 +294,7 @@ func stepsOptInChain() []Step {
},
},
{
- // relay the vsc packet that contains the slashed power for alice
+ // relay the VSCPacket that contains the slashed power for alice
Action: RelayPacketsAction{
ChainA: ChainID("consu"),
ChainB: ChainID("provi"),
@@ -346,7 +346,7 @@ func stepsOptInChain() []Step {
},
},
{
- // relay the vsc packet that puts alice back into power on the consumer
+ // relay the VSCPacket that puts alice back into power on the consumer
Action: RelayPacketsAction{
ChainA: ChainID("provi"),
ChainB: ChainID("consu"),
@@ -364,7 +364,8 @@ func stepsOptInChain() []Step {
},
},
},
- { // slash alice for downtime again
+ {
+ // slash alice for downtime again
Action: DowntimeSlashAction{
Chain: ChainID("consu"),
Validator: ValidatorID("alice"),
@@ -407,7 +408,7 @@ func stepsOptInChain() []Step {
},
},
{
- // relay the vsc packet that contains the slashed power for alice
+ // relay the VSCPacket that contains the slashed power for alice
Action: RelayPacketsAction{
ChainA: ChainID("consu"),
ChainB: ChainID("provi"),
@@ -728,7 +729,7 @@ func stepsTopNChain() []Step {
},
},
{
- // relay the vsc packet that contains the slashed power for alice
+ // relay the VSCPacket that contains the slashed power for alice
Action: RelayPacketsAction{
ChainA: ChainID("consu"),
ChainB: ChainID("provi"),
@@ -780,7 +781,7 @@ func stepsTopNChain() []Step {
},
},
{
- // relay the vsc packet that puts alice back into power on the consumer
+ // relay the VSCPacket that puts alice back into power on the consumer
Action: RelayPacketsAction{
ChainA: ChainID("provi"),
ChainB: ChainID("consu"),
@@ -798,7 +799,8 @@ func stepsTopNChain() []Step {
},
},
},
- { // slash alice for downtime again
+ {
+ // slash alice for downtime again
Action: DowntimeSlashAction{
Chain: ChainID("consu"),
Validator: ValidatorID("alice"),
@@ -841,7 +843,7 @@ func stepsTopNChain() []Step {
},
},
{
- // relay the vsc packet that contains the slashed power for alice
+ // relay the VSCPacket that contains the slashed power for alice
Action: RelayPacketsAction{
ChainA: ChainID("consu"),
ChainB: ChainID("provi"),