-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add initial double signing simulation (#402)
* add initial double signing simulation * wip * update double sign tests * WIP: play with hermes builds * add unofficial hermes image in build * add provider double sign * run all tests in parallel * add new container for double sign tests * rm unnecessary default value in doublesign script * update after reviews * bump double sign timeout Co-authored-by: Jehan <[email protected]> Co-authored-by: Daniel T <[email protected]> Co-authored-by: Jehan Tremback <[email protected]>
- Loading branch information
1 parent
80b751c
commit a2536c1
Showing
8 changed files
with
281 additions
and
9 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
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,125 @@ | ||
package main | ||
|
||
// simulates double signing on provider and consumer chains | ||
func stepsDoubleSign(consumerName, doubleSignChain, doubleSignValidator string) []Step { | ||
return []Step{ | ||
// provider double sign | ||
{ | ||
action: doublesignSlashAction{ | ||
chain: chainID("provi"), | ||
validator: validatorID("carol"), | ||
}, | ||
state: State{ | ||
// slash on provider | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
// not slashed on consumer yet | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 500, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
// relay power change to consumer | ||
action: relayPacketsAction{ | ||
chain: chainID("provi"), | ||
port: "provider", | ||
channel: 0, | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
action: doublesignSlashAction{ | ||
chain: chainID("consu"), | ||
validator: validatorID("bob"), | ||
}, | ||
state: State{ | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
action: relayPacketsAction{ | ||
chain: chainID("provi"), | ||
port: "provider", | ||
channel: 0, | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 0, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 500, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
// relay power change to consumer | ||
action: relayPacketsAction{ | ||
chain: chainID("provi"), | ||
port: "provider", | ||
channel: 0, | ||
}, | ||
state: State{ | ||
chainID("provi"): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 0, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
chainID(consumerName): ChainState{ | ||
ValPowers: &map[validatorID]uint{ | ||
validatorID("alice"): 500, | ||
validatorID("bob"): 0, | ||
validatorID("carol"): 0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
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,36 @@ | ||
#!/bin/bash | ||
set -eux | ||
|
||
# The gaiad binary | ||
BIN=$1 | ||
|
||
VAL_ID=$2 | ||
|
||
# The chain ID | ||
CHAIN_ID=$3 | ||
|
||
# chain's IP address prefix; 7.7.7, 7.7.8... | ||
# see chain config for details | ||
CHAIN_PREFIX=$4 | ||
|
||
# create directory for double signing node | ||
mkdir /$CHAIN_ID/validatorsybil | ||
cp -r /$CHAIN_ID/validator$VAL_ID/* /$CHAIN_ID/validatorsybil | ||
|
||
# clear state in validatorsybil | ||
echo '{"height": "0","round": 0,"step": 0,"signature":"","signbytes":""}' > /$CHAIN_ID/validatorsybil/data/priv_validator_state.json | ||
|
||
# add new node key to sybil | ||
# key was generated using gaiad init | ||
# if the node key is not unique, double signing cannot be achieved | ||
# and errors such as this can be seen in the terminal | ||
# 5:54PM ERR found conflicting vote from ourselves; did you unsafe_reset a validator? height=1961 module=consensus round=0 type=2 | ||
# 5:54PM ERR failed to process message err="conflicting votes from validator C888306A908A217B9A943D1DAD8790044D0947A4" | ||
echo '{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"tj55by/yYwruSz4NxsOG9y9k2WrPvKLXKQdz/9jL9Uptmi647OYpcisjwf92TyA+wCUYVDOgW7D53Q+638l9/w=="}}' > /$CHAIN_ID/validatorsybil/config/node_key.json | ||
|
||
# does not use persistent peers; will do a lookup in genesis.json to find peers | ||
ARGS="--address tcp://$CHAIN_PREFIX.252:26655 --rpc.laddr tcp://$CHAIN_PREFIX.252:26658 --grpc.address $CHAIN_PREFIX.252:9091 --log_level trace --p2p.laddr tcp://$CHAIN_PREFIX.252:26656 --grpc-web.enable=false" | ||
|
||
# start double signing node - it should not talk to the node with the same key | ||
ip netns exec $CHAIN_ID-sybil $BIN $ARGS --home /$CHAIN_ID/validatorsybil start &> /$CHAIN_ID/validatorsybil/logs & | ||
|
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