-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add light client attack to e2e tests (#1249)
* Add light client attack to e2e tests * Add details about the attack types * Rename validatorAddress to validatorPrivateKeyAddress * Add URL to CometMock to flag * Improve wording for light client attack run * Add submitting equivocation proposals and change consu->consumerName
- Loading branch information
1 parent
24b89ed
commit 57b96ca
Showing
4 changed files
with
244 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package main | ||
|
||
// Steps that make carol double sign on the provider, and bob double sign on a single consumer | ||
func stepsLightClientAttackOnProviderAndConsumer(consumerName string) []Step { | ||
return []Step{ | ||
{ | ||
// provider double sign | ||
action: lightClientEquivocationAttackAction{ | ||
chain: chainID("provi"), | ||
validator: validatorID("carol"), | ||
}, | ||
state: State{ | ||
// slash on provider | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, // from 500 to 0 | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 495, // not tombstoned on consumerName yet | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
// relay power change to consumerName | ||
action: relayPacketsAction{ | ||
chainA: chainID("provi"), | ||
chainB: chainID(consumerName), | ||
port: "provider", | ||
channel: 0, // consumerName channel | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, // tombstoning visible on consumerName | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
// consumer double sign | ||
// provider will only log the double sign slash | ||
// stepsSubmitEquivocationProposal will cause the double sign slash to be executed | ||
action: lightClientEquivocationAttackAction{ | ||
chain: chainID(consumerName), | ||
validator: validatorID("bob"), | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
action: relayPacketsAction{ | ||
chainA: chainID("provi"), | ||
chainB: chainID(consumerName), | ||
port: "provider", | ||
channel: 0, | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, // not tombstoned | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, // not tombstoned | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
// consumer learns about the double sign | ||
action: relayPacketsAction{ | ||
chainA: chainID("provi"), | ||
chainB: chainID(consumerName), | ||
port: "provider", | ||
channel: 0, | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 509, | ||
validatorID("bob"): 500, // not tombstoned | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |