Files
tendermint/test/p2p/dsrr/test_peer.sh
T
dongsamandGitHub e30b125725 consensus: double-sign risk reduction (ADR-51) (#5147)
Implementation spec of Double Signing Risk Reduction [ADR-51](https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-051-double-signing-risk-reduction.md) by B-Harvest
- Add `DoubleSignCheckHeight` config variable to ConsensusConfig for "How many blocks looks back to check existence of the node's consensus votes when before joining consensus"
- Add `consensus.double_sign_check_height` to `config.toml` and `tendermint node` as flag for set `DoubleSignCheckHeight`
- Set default `consensus.double_sign_check_height` to `0`  ( it could be adjustable in this PR, disable when 0  )

Refs

- [ADR-51](https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-051-double-signing-risk-reduction.md)
- [https://github.com/tendermint/tendermint/issues/4059](https://github.com/tendermint/tendermint/issues/4059)
- [https://github.com/tendermint/tendermint/pull/4262](https://github.com/tendermint/tendermint/pull/4262)
2020-08-27 08:57:36 +04:00

66 lines
2.4 KiB
Bash

#! /bin/bash
set -eu
set -o pipefail
DOCKER_IMAGE=$1
NETWORK_NAME=$2
IPV=$3
ID=$4
N=$5
PROXY_APP=$6
ASSERT_NODE_UP=1
ASSERT_NODE_DOWN=0
###########################s####################################
# this runs on each peer:
# kill peer
# bring it back online with double_sign_check_height 10
# wait node is not run by double sign risk reduction
#
# kill peer
# bring it back online with double_sign_check_height 1
# pass double sign risk reduction, wait for it to sync and check the app hash
#
# kill peer
# bring it back online with double_sign_check_height 0
# wait for it to sync and check the app hash
###############################################################
echo "Testing double sign risk reduction on node $ID"
# kill peer
set +e
docker rm -vf local_testnet_$ID
set -e
PERSISTENT_PEERS="$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)"
for j in `seq 2 $N`; do
PERSISTENT_PEERS="$PERSISTENT_PEERS,$(test/p2p/address.sh $IPV $j 26656 $DOCKER_IMAGE)"
done
# bring it back online with double_sign_check_height 10
# wait node is not run by double sign risk reduction
DSCH=10
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe --consensus.double_sign_check_height $DSCH"
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/dsrr/check_peer.sh $IPV $ID $ASSERT_NODE_DOWN"
docker stop local_testnet_$ID
docker rm local_testnet_$ID
# bring it back online with double_sign_check_height 1
# pass double sign risk reduction, wait for it to sync and check the app hash
DSCH=1
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe --consensus.double_sign_check_height $DSCH"
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/dsrr/check_peer.sh $IPV $ID $ASSERT_NODE_UP"
docker stop local_testnet_$ID
docker rm local_testnet_$ID
DSCH=0
# bring it back online with double_sign_check_height 0
# double sign risk reduction is not activated, wait for it to sync and check the app hash
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe --consensus.double_sign_check_height $DSCH"
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/dsrr/check_peer.sh $IPV $ID $ASSERT_NODE_UP"
echo ""
echo "PASS"
echo ""