From b51ed132f7ac13792dd9b5d7dbb7c806364fdcc9 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Wed, 27 Jun 2018 14:31:42 -0700 Subject: [PATCH] Fix test/p2p/pex circle tests; update consensus --- .gitignore | 1 + consensus/state.go | 2 +- lite/commit.go | 8 +------- lite/dbprovider.go | 4 ---- test/p2p/peer.sh | 4 +--- test/p2p/pex/test_addrbook.sh | 15 ++++++++++++--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 269066e39..9337de17b 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ scripts/cutWALUntil/cutWALUntil libs/pubsub/query/fuzz_test/output shunit2 .tendermint-lite +addrbook.json diff --git a/consensus/state.go b/consensus/state.go index e3c9054a0..4bb47045a 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1623,7 +1623,7 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool, } } else if cs.Round <= vote.Round && precommits.HasTwoThirdsAny() { cs.enterNewRound(height, vote.Round) - cs.enterPrevote(height, vote.Round) + cs.enterPropose(height, vote.Round) cs.enterPrevoteWait(height, vote.Round) cs.enterPrecommitWait(height, vote.Round) } diff --git a/lite/commit.go b/lite/commit.go index 40c3534cf..89f044177 100644 --- a/lite/commit.go +++ b/lite/commit.go @@ -65,15 +65,9 @@ func (fc FullCommit) ValidateFull(chainID string) error { } // Validate the signatures on the commit. hdr, cmt := fc.SignedHeader.Header, fc.SignedHeader.Commit - err = fc.Validators.VerifyCommit( + return fc.Validators.VerifyCommit( hdr.ChainID, cmt.BlockID, hdr.Height, cmt) - if err != nil { - return err - } - - // All good! - return nil } // Height returns the height of the header. diff --git a/lite/dbprovider.go b/lite/dbprovider.go index f39f033c3..3ee3b0620 100644 --- a/lite/dbprovider.go +++ b/lite/dbprovider.go @@ -241,10 +241,6 @@ func validatorSetKey(chainID string, height int64) []byte { return []byte(fmt.Sprintf("%s/%010d/vs", chainID, height)) } -func chainKeyPrefix(chainID string, height int64) []byte { - return []byte(fmt.Sprintf("%s/%010d/", chainID, height)) -} - var chainKeyPrefixPattern = regexp.MustCompile(`([^/]+)/([0-9]*)/`) func parseChainKeyPrefix(key []byte) (chainID string, height int64, ok bool) { diff --git a/test/p2p/peer.sh b/test/p2p/peer.sh index a718fd49f..ad04d000f 100644 --- a/test/p2p/peer.sh +++ b/test/p2p/peer.sh @@ -15,9 +15,7 @@ echo "starting tendermint peer ID=$ID" # NOTE: $NODE_FLAGS should be unescaped (no quotes). otherwise it will be # treated as one flag. - - -if [[ "$ID" == "1" ]]; then +if [[ "$ID" == "x" ]]; then # Set "x" to "1" to print to console. docker run \ --net="$NETWORK_NAME" \ --ip=$(test/p2p/ip.sh "$ID") \ diff --git a/test/p2p/pex/test_addrbook.sh b/test/p2p/pex/test_addrbook.sh index d54bcf428..9c58db30c 100644 --- a/test/p2p/pex/test_addrbook.sh +++ b/test/p2p/pex/test_addrbook.sh @@ -16,6 +16,7 @@ CLIENT_NAME="pex_addrbook_$ID" echo "1. restart peer $ID" docker stop "local_testnet_$ID" +echo "stopped local_testnet_$ID" # preserve addrbook.json docker cp "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/config/addrbook.json" "/tmp/addrbook.json" set +e #CIRCLE @@ -24,6 +25,13 @@ set -e # NOTE that we do not provide persistent_peers bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" +echo "started local_testnet_$ID" + +# if the client runs forever, it means addrbook wasn't saved or was empty +bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N" + +# Now we know that the node is up. + docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/config/addrbook.json" echo "with the following addrbook:" cat /tmp/addrbook.json @@ -31,9 +39,6 @@ cat /tmp/addrbook.json # docker exec "local_testnet_$ID" cat "/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/config/addrbook.json" echo "" -# if the client runs forever, it means addrbook wasn't saved or was empty -bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N" - echo "----------------------------------------------------------------------" echo "Testing other peers connect to us if we have neither persistent_peers nor the addrbook" echo "(assuming peers are started with pex enabled)" @@ -42,16 +47,20 @@ CLIENT_NAME="pex_no_addrbook_$ID" echo "1. restart peer $ID" docker stop "local_testnet_$ID" +echo "stopped local_testnet_$ID" set +e #CIRCLE docker rm -vf "local_testnet_$ID" set -e # NOTE that we do not provide persistent_peers bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" +echo "started local_testnet_$ID" # if the client runs forever, it means other peers have removed us from their books (which should not happen) bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N" +# Now we know that the node is up. + echo "" echo "PASS" echo ""