From 8524a8da7fdb52e5396b360a8862d3466be9e2e8 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 26 Jun 2018 23:42:00 -0700 Subject: [PATCH] Try to fix circle... --- Gopkg.toml | 4 ---- bump | 2 ++ consensus/state.go | 13 ++++++---- foo.sh | 1 + test/p2p/basic/test.sh | 1 + test/p2p/kill_all/check_peers.sh | 4 ++-- test/p2p/peer.sh | 41 +++++++++++++++++++++++--------- types/validator_set.go | 24 +++++++++---------- 8 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 bump create mode 100644 foo.sh diff --git a/Gopkg.toml b/Gopkg.toml index dc56ae29d..18e2767a9 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -69,10 +69,6 @@ name = "github.com/stretchr/testify" version = "~1.2.1" -[[constraint]] - name = "github.com/tendermint/abci" - version = "~0.12.0" - [[constraint]] name = "github.com/tendermint/go-amino" version = "~0.10.1" diff --git a/bump b/bump new file mode 100644 index 000000000..729353f73 --- /dev/null +++ b/bump @@ -0,0 +1,2 @@ + +booop diff --git a/consensus/state.go b/consensus/state.go index 7c18d8b09..e3c9054a0 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1021,9 +1021,11 @@ func (cs *ConsensusState) enterPrevoteWait(height int64, round int) { logger.Debug(cmn.Fmt("enterPrevoteWait(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step)) return } - if !cs.Votes.Prevotes(round).HasTwoThirdsAny() { - cmn.PanicSanity(cmn.Fmt("enterPrevoteWait(%v/%v), but Prevotes does not have any +2/3 votes", height, round)) - } + /* + if !cs.Votes.Prevotes(round).HasTwoThirdsAny() { + cmn.PanicSanity(cmn.Fmt("enterPrevoteWait(%v/%v), but Prevotes does not have any +2/3 votes", height, round)) + } + */ logger.Info(cmn.Fmt("enterPrevoteWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step)) defer func() { @@ -1587,7 +1589,7 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool, if prevotes.HasTwoThirdsMajority() { cs.enterPrecommit(height, vote.Round) } else { - cs.enterPrevote(height, vote.Round) // if the vote is ahead of us + cs.enterPropose(height, vote.Round) // we can't prevote until we wait for the proposal. cs.enterPrevoteWait(height, vote.Round) } } else if cs.Proposal != nil && 0 <= cs.Proposal.POLRound && cs.Proposal.POLRound == vote.Round { @@ -1621,7 +1623,8 @@ 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.enterPrecommit(height, vote.Round) + cs.enterPrevote(height, vote.Round) + cs.enterPrevoteWait(height, vote.Round) cs.enterPrecommitWait(height, vote.Round) } default: diff --git a/foo.sh b/foo.sh new file mode 100644 index 000000000..be8b9d78d --- /dev/null +++ b/foo.sh @@ -0,0 +1 @@ +docker run -ti tester find diff --git a/test/p2p/basic/test.sh b/test/p2p/basic/test.sh index caf665122..423b5b017 100755 --- a/test/p2p/basic/test.sh +++ b/test/p2p/basic/test.sh @@ -56,6 +56,7 @@ for i in `seq 1 $N`; do # - assert block height is greater than 1 BLOCK_HEIGHT=`curl -s $addr/status | jq .result.sync_info.latest_block_height | jq fromjson` COUNT=0 + echo "$$BLOCK_HEIGHT IS $BLOCK_HEIGHT" while [ "$BLOCK_HEIGHT" -le 1 ]; do echo "Waiting for node $i to commit a block ..." sleep 1 diff --git a/test/p2p/kill_all/check_peers.sh b/test/p2p/kill_all/check_peers.sh index 87a768110..95da7484e 100644 --- a/test/p2p/kill_all/check_peers.sh +++ b/test/p2p/kill_all/check_peers.sh @@ -23,7 +23,7 @@ set -e # get the first peer's height addr=$(test/p2p/ip.sh 1):26657 -h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height) +h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") echo "1st peer is on height $h1" echo "Waiting until other peers reporting a height higher than the 1st one" @@ -33,7 +33,7 @@ for i in $(seq 2 "$NUM_OF_PEERS"); do while [[ $hi -le $h1 ]] ; do addr=$(test/p2p/ip.sh "$i"):26657 - hi=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height) + hi=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") echo "... peer $i is on height $hi" diff --git a/test/p2p/peer.sh b/test/p2p/peer.sh index 15d44ff33..a718fd49f 100644 --- a/test/p2p/peer.sh +++ b/test/p2p/peer.sh @@ -14,14 +14,33 @@ echo "starting tendermint peer ID=$ID" # start tendermint container on the network # NOTE: $NODE_FLAGS should be unescaped (no quotes). otherwise it will be # treated as one flag. -docker run -d \ - --net="$NETWORK_NAME" \ - --ip=$(test/p2p/ip.sh "$ID") \ - --name "local_testnet_$ID" \ - --entrypoint tendermint \ - -e TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core" \ - --log-driver=syslog \ - --log-opt syslog-address=udp://127.0.0.1:5514 \ - --log-opt syslog-facility=daemon \ - --log-opt tag="{{.Name}}" \ - "$DOCKER_IMAGE" node $NODE_FLAGS --log_level=debug --proxy_app="$APP_PROXY" + + + +if [[ "$ID" == "1" ]]; then + docker run \ + --net="$NETWORK_NAME" \ + --ip=$(test/p2p/ip.sh "$ID") \ + --name "local_testnet_$ID" \ + --entrypoint tendermint \ + -e TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core" \ + -e GOMAXPROCS=1 \ + --log-driver=syslog \ + --log-opt syslog-address=udp://127.0.0.1:5514 \ + --log-opt syslog-facility=daemon \ + --log-opt tag="{{.Name}}" \ + "$DOCKER_IMAGE" node $NODE_FLAGS --log_level=debug --proxy_app="$APP_PROXY" & +else + docker run -d \ + --net="$NETWORK_NAME" \ + --ip=$(test/p2p/ip.sh "$ID") \ + --name "local_testnet_$ID" \ + --entrypoint tendermint \ + -e TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core" \ + -e GOMAXPROCS=1 \ + --log-driver=syslog \ + --log-opt syslog-address=udp://127.0.0.1:5514 \ + --log-opt syslog-facility=daemon \ + --log-opt tag="{{.Name}}" \ + "$DOCKER_IMAGE" node $NODE_FLAGS --log_level=debug --proxy_app="$APP_PROXY" +fi diff --git a/types/validator_set.go b/types/validator_set.go index dc1d0e882..636c046a6 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -279,11 +279,6 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height i if precommit.Type != VoteTypePrecommit { return fmt.Errorf("Invalid commit -- not precommit @ index %v", idx) } - // NOTE: This will go away when we refactor Commit. - if !blockID.Equals(precommit.BlockID) { - return fmt.Errorf("Invalid commit -- wrong block id @ index %v: want %v got %v", - idx, blockID, precommit.BlockID) - } _, val := vals.GetByIndex(idx) // Validate signature. precommitSignBytes := precommit.SignBytes(chainID) @@ -291,7 +286,12 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height i return fmt.Errorf("Invalid commit -- invalid signature: %v", precommit) } // Good precommit! - talliedVotingPower += val.VotingPower + if blockID.Equals(precommit.BlockID) { + talliedVotingPower += val.VotingPower + } else { + // It's OK that the BlockID doesn't match. We include stray + // precommits to measure validator availability. + } } if talliedVotingPower > vals.TotalVotingPower()*2/3 { @@ -358,11 +358,6 @@ func (vals *ValidatorSet) VerifyFutureCommit(newSet *ValidatorSet, chainID strin if precommit.Type != VoteTypePrecommit { return cmn.NewError("Invalid commit -- not precommit @ index %v", idx) } - // NOTE: This will go away when we refactor Commit. - if !blockID.Equals(precommit.BlockID) { - return fmt.Errorf("Invalid commit -- wrong block id @ index %v: want %v got %v", - idx, blockID, precommit.BlockID) - } // See if this validator is in oldVals. idx, val := oldVals.GetByAddress(precommit.ValidatorAddress) if val == nil || seen[idx] { @@ -376,7 +371,12 @@ func (vals *ValidatorSet) VerifyFutureCommit(newSet *ValidatorSet, chainID strin return cmn.NewError("Invalid commit -- invalid signature: %v", precommit) } // Good precommit! - oldVotingPower += val.VotingPower + if blockID.Equals(precommit.BlockID) { + oldVotingPower += val.VotingPower + } else { + // It's OK that the BlockID doesn't match. We include stray + // precommits to measure validator availability. + } } if oldVotingPower <= oldVals.TotalVotingPower()*2/3 {