You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2118 lines
72 KiB

9 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
fix TestFullRound1 race (Refs #846) ``` ================== WARNING: DATA RACE Write at 0x00c42d7605f0 by goroutine 844: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:465 +0x59e I[11-14|22:37:28.781] Added to prevote vote="Vote{0:646753DCE124 1/02/1(Prevote) E9B19636DCDB {/CAD5FA805E8C.../}}" prevotes="VoteSet{H:1 R:2 T:1 +2/3:<nil> BA{2:X_} map[]}" github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1229 +0x16a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1135 +0x721 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1087 +0x153 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1114 +0xa34 github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1423 +0xdd6 github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1317 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:565 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:523 +0x6d2 Previous read at 0x00c42d7605f0 by goroutine 654: github.com/tendermint/tendermint/consensus.validatePrevote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/common_test.go:149 +0x57 github.com/tendermint/tendermint/consensus.TestFullRound1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state_test.go:256 +0x3c5 testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c Goroutine 844 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).startRoutines() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:258 +0x8c github.com/tendermint/tendermint/consensus.startTestRound() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/common_test.go:118 +0x63 github.com/tendermint/tendermint/consensus.TestFullRound1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state_test.go:247 +0x1fb testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c Goroutine 654 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:789 +0x568 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1004 +0xa7 testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c testing.runTests() /usr/local/go/src/testing/testing.go:1002 +0x521 testing.(*M).Run() /usr/local/go/src/testing/testing.go:921 +0x206 main.main() github.com/tendermint/tendermint/consensus/_test/_testmain.go:106 +0x1d3 ================== ```
7 years ago
fix TestFullRound1 race (Refs #846) ``` ================== WARNING: DATA RACE Write at 0x00c42d7605f0 by goroutine 844: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:465 +0x59e I[11-14|22:37:28.781] Added to prevote vote="Vote{0:646753DCE124 1/02/1(Prevote) E9B19636DCDB {/CAD5FA805E8C.../}}" prevotes="VoteSet{H:1 R:2 T:1 +2/3:<nil> BA{2:X_} map[]}" github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1229 +0x16a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1135 +0x721 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1087 +0x153 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1114 +0xa34 github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1423 +0xdd6 github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1317 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:565 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:523 +0x6d2 Previous read at 0x00c42d7605f0 by goroutine 654: github.com/tendermint/tendermint/consensus.validatePrevote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/common_test.go:149 +0x57 github.com/tendermint/tendermint/consensus.TestFullRound1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state_test.go:256 +0x3c5 testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c Goroutine 844 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).startRoutines() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:258 +0x8c github.com/tendermint/tendermint/consensus.startTestRound() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/common_test.go:118 +0x63 github.com/tendermint/tendermint/consensus.TestFullRound1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state_test.go:247 +0x1fb testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c Goroutine 654 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:789 +0x568 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1004 +0xa7 testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c testing.runTests() /usr/local/go/src/testing/testing.go:1002 +0x521 testing.(*M).Run() /usr/local/go/src/testing/testing.go:921 +0x206 main.main() github.com/tendermint/tendermint/consensus/_test/_testmain.go:106 +0x1d3 ================== ```
7 years ago
fix TestFullRound1 race (Refs #846) ``` ================== WARNING: DATA RACE Write at 0x00c42d7605f0 by goroutine 844: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:465 +0x59e I[11-14|22:37:28.781] Added to prevote vote="Vote{0:646753DCE124 1/02/1(Prevote) E9B19636DCDB {/CAD5FA805E8C.../}}" prevotes="VoteSet{H:1 R:2 T:1 +2/3:<nil> BA{2:X_} map[]}" github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1229 +0x16a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1135 +0x721 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1087 +0x153 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1114 +0xa34 github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1423 +0xdd6 github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1317 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:565 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:523 +0x6d2 Previous read at 0x00c42d7605f0 by goroutine 654: github.com/tendermint/tendermint/consensus.validatePrevote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/common_test.go:149 +0x57 github.com/tendermint/tendermint/consensus.TestFullRound1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state_test.go:256 +0x3c5 testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c Goroutine 844 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).startRoutines() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:258 +0x8c github.com/tendermint/tendermint/consensus.startTestRound() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/common_test.go:118 +0x63 github.com/tendermint/tendermint/consensus.TestFullRound1() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state_test.go:247 +0x1fb testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c Goroutine 654 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:789 +0x568 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1004 +0xa7 testing.tRunner() /usr/local/go/src/testing/testing.go:746 +0x16c testing.runTests() /usr/local/go/src/testing/testing.go:1002 +0x521 testing.(*M).Run() /usr/local/go/src/testing/testing.go:921 +0x206 main.main() github.com/tendermint/tendermint/consensus/_test/_testmain.go:106 +0x1d3 ================== ```
7 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
cs: reset triggered timeout precommit (#3310) * Reset TriggeredTimeoutPrecommit as part of updateToState * Add failing test and fix * fix DATA RACE in TestResetTimeoutPrecommitUponNewHeight ``` WARNING: DATA RACE Read at 0x00c001691d28 by goroutine 691: github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:133 +0x121 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c001691d28 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:562 +0x5b2 github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd Goroutine 691 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1119 +0xa8 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 testing.runTests() testing.(*M).Run() /usr/local/go/src/testing/testing.go:1034 +0x2ee main.main() _testmain.go:216 +0x332 ``` * fix another DATA RACE by locking consensus ``` WARNING: DATA RACE Read at 0x00c009b835a8 by goroutine 871: github.com/tendermint/tendermint/consensus.(*ConsensusState).createProposalBlock() /go/src/github.com/tendermint/tendermint/consensus/state.go:955 +0x7c github.com/tendermint/tendermint/consensus.decideProposal() /go/src/github.com/tendermint/tendermint/consensus/common_test.go:127 +0x53 github.com/tendermint/tendermint/consensus.TestResetTimeoutPrecommitUponNewHeight() /go/src/github.com/tendermint/tendermint/consensus/state_test.go:1389 +0x958 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Previous write at 0x00c009b835a8 by goroutine 931: github.com/tendermint/tendermint/consensus.(*ConsensusState).updateHeight() /go/src/github.com/tendermint/tendermint/consensus/state.go:446 +0xb7 github.com/tendermint/tendermint/consensus.(*ConsensusState).updateToState() /go/src/github.com/tendermint/tendermint/consensus/state.go:542 +0x22f github.com/tendermint/tendermint/consensus.(*ConsensusState).finalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1340 +0x141e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryFinalizeCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1255 +0x66e github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:1201 +0x135 github.com/tendermint/tendermint/consensus.(*ConsensusState).enterCommit() /go/src/github.com/tendermint/tendermint/consensus/state.go:1232 +0x94b github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1657 +0x132e github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /go/src/github.com/tendermint/tendermint/consensus/state.go:1503 +0x8f github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:694 +0xa1e github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:642 +0x948 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:655 +0x7dd ``` * Fix failing test * Delete profile.out * fix data races
6 years ago
9 years ago
9 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
  1. package consensus
  2. import (
  3. "bytes"
  4. "context"
  5. "fmt"
  6. "testing"
  7. "time"
  8. "github.com/stretchr/testify/assert"
  9. "github.com/stretchr/testify/require"
  10. "github.com/tendermint/tendermint/abci/example/kvstore"
  11. "github.com/tendermint/tendermint/crypto/tmhash"
  12. cstypes "github.com/tendermint/tendermint/internal/consensus/types"
  13. "github.com/tendermint/tendermint/internal/eventbus"
  14. "github.com/tendermint/tendermint/libs/log"
  15. tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
  16. tmrand "github.com/tendermint/tendermint/libs/rand"
  17. tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
  18. "github.com/tendermint/tendermint/types"
  19. )
  20. /*
  21. ProposeSuite
  22. x * TestProposerSelection0 - round robin ordering, round 0
  23. x * TestProposerSelection2 - round robin ordering, round 2++
  24. x * TestEnterProposeNoValidator - timeout into prevote round
  25. x * TestEnterPropose - finish propose without timing out (we have the proposal)
  26. x * TestBadProposal - 2 vals, bad proposal (bad block state hash), should prevote and precommit nil
  27. x * TestOversizedBlock - block with too many txs should be rejected
  28. FullRoundSuite
  29. x * TestFullRound1 - 1 val, full successful round
  30. x * TestFullRoundNil - 1 val, full round of nil
  31. x * TestFullRound2 - 2 vals, both required for full round
  32. LockSuite
  33. x * TestLockNoPOL - 2 vals, 4 rounds. one val locked, precommits nil every round except first.
  34. x * TestLockPOLRelock - 4 vals, one precommits, other 3 polka at next round, so we unlock and precomit the polka
  35. x * TestLockPOLUnlock - 4 vals, one precommits, other 3 polka nil at next round, so we unlock and precomit nil
  36. x * TestLockPOLSafety1 - 4 vals. We shouldn't change lock based on polka at earlier round
  37. x * TestLockPOLSafety2 - 4 vals. After unlocking, we shouldn't relock based on polka at earlier round
  38. * TestNetworkLock - once +1/3 precommits, network should be locked
  39. * TestNetworkLockPOL - once +1/3 precommits, the block with more recent polka is committed
  40. SlashingSuite
  41. x * TestSlashingPrevotes - a validator prevoting twice in a round gets slashed
  42. x * TestSlashingPrecommits - a validator precomitting twice in a round gets slashed
  43. CatchupSuite
  44. * TestCatchup - if we might be behind and we've seen any 2/3 prevotes, round skip to new round, precommit, or prevote
  45. HaltSuite
  46. x * TestHalt1 - if we see +2/3 precommits after timing out into new round, we should still commit
  47. */
  48. //----------------------------------------------------------------------------------------------------
  49. // ProposeSuite
  50. func TestStateProposerSelection0(t *testing.T) {
  51. ctx, cancel := context.WithCancel(context.Background())
  52. defer cancel()
  53. config := configSetup(t)
  54. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  55. require.NoError(t, err)
  56. height, round := cs1.Height, cs1.Round
  57. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  58. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  59. startTestRound(ctx, cs1, height, round)
  60. // Wait for new round so proposer is set.
  61. ensureNewRound(newRoundCh, height, round)
  62. // Commit a block and ensure proposer for the next height is correct.
  63. prop := cs1.GetRoundState().Validators.GetProposer()
  64. pv, err := cs1.privValidator.GetPubKey(ctx)
  65. require.NoError(t, err)
  66. address := pv.Address()
  67. if !bytes.Equal(prop.Address, address) {
  68. t.Fatalf("expected proposer to be validator %d. Got %X", 0, prop.Address)
  69. }
  70. // Wait for complete proposal.
  71. ensureNewProposal(proposalCh, height, round)
  72. rs := cs1.GetRoundState()
  73. signAddVotes(
  74. ctx,
  75. config,
  76. cs1,
  77. tmproto.PrecommitType,
  78. rs.ProposalBlock.Hash(),
  79. rs.ProposalBlockParts.Header(),
  80. vss[1:]...,
  81. )
  82. // Wait for new round so next validator is set.
  83. ensureNewRound(newRoundCh, height+1, 0)
  84. prop = cs1.GetRoundState().Validators.GetProposer()
  85. pv1, err := vss[1].GetPubKey(ctx)
  86. require.NoError(t, err)
  87. addr := pv1.Address()
  88. if !bytes.Equal(prop.Address, addr) {
  89. panic(fmt.Sprintf("expected proposer to be validator %d. Got %X", 1, prop.Address))
  90. }
  91. }
  92. // Now let's do it all again, but starting from round 2 instead of 0
  93. func TestStateProposerSelection2(t *testing.T) {
  94. config := configSetup(t)
  95. ctx, cancel := context.WithCancel(context.Background())
  96. defer cancel()
  97. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4) // test needs more work for more than 3 validators
  98. require.NoError(t, err)
  99. height := cs1.Height
  100. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  101. // this time we jump in at round 2
  102. incrementRound(vss[1:]...)
  103. incrementRound(vss[1:]...)
  104. var round int32 = 2
  105. startTestRound(ctx, cs1, height, round)
  106. ensureNewRound(newRoundCh, height, round) // wait for the new round
  107. // everyone just votes nil. we get a new proposer each round
  108. for i := int32(0); int(i) < len(vss); i++ {
  109. prop := cs1.GetRoundState().Validators.GetProposer()
  110. pvk, err := vss[int(i+round)%len(vss)].GetPubKey(ctx)
  111. require.NoError(t, err)
  112. addr := pvk.Address()
  113. correctProposer := addr
  114. if !bytes.Equal(prop.Address, correctProposer) {
  115. panic(fmt.Sprintf(
  116. "expected RoundState.Validators.GetProposer() to be validator %d. Got %X",
  117. int(i+2)%len(vss),
  118. prop.Address))
  119. }
  120. rs := cs1.GetRoundState()
  121. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, rs.ProposalBlockParts.Header(), vss[1:]...)
  122. ensureNewRound(newRoundCh, height, i+round+1) // wait for the new round event each round
  123. incrementRound(vss[1:]...)
  124. }
  125. }
  126. // a non-validator should timeout into the prevote round
  127. func TestStateEnterProposeNoPrivValidator(t *testing.T) {
  128. config := configSetup(t)
  129. ctx, cancel := context.WithCancel(context.Background())
  130. defer cancel()
  131. cs, _, err := randState(ctx, config, log.TestingLogger(), 1)
  132. require.NoError(t, err)
  133. cs.SetPrivValidator(nil)
  134. height, round := cs.Height, cs.Round
  135. // Listen for propose timeout event
  136. timeoutCh := subscribe(ctx, t, cs.eventBus, types.EventQueryTimeoutPropose)
  137. startTestRound(ctx, cs, height, round)
  138. // if we're not a validator, EnterPropose should timeout
  139. ensureNewTimeout(timeoutCh, height, round, cs.config.TimeoutPropose.Nanoseconds())
  140. if cs.GetRoundState().Proposal != nil {
  141. t.Error("Expected to make no proposal, since no privValidator")
  142. }
  143. }
  144. // a validator should not timeout of the prevote round (TODO: unless the block is really big!)
  145. func TestStateEnterProposeYesPrivValidator(t *testing.T) {
  146. config := configSetup(t)
  147. ctx, cancel := context.WithCancel(context.Background())
  148. defer cancel()
  149. cs, _, err := randState(ctx, config, log.TestingLogger(), 1)
  150. require.NoError(t, err)
  151. height, round := cs.Height, cs.Round
  152. // Listen for propose timeout event
  153. timeoutCh := subscribe(ctx, t, cs.eventBus, types.EventQueryTimeoutPropose)
  154. proposalCh := subscribe(ctx, t, cs.eventBus, types.EventQueryCompleteProposal)
  155. cs.enterNewRound(height, round)
  156. cs.startRoutines(ctx, 3)
  157. ensureNewProposal(proposalCh, height, round)
  158. // Check that Proposal, ProposalBlock, ProposalBlockParts are set.
  159. rs := cs.GetRoundState()
  160. if rs.Proposal == nil {
  161. t.Error("rs.Proposal should be set")
  162. }
  163. if rs.ProposalBlock == nil {
  164. t.Error("rs.ProposalBlock should be set")
  165. }
  166. if rs.ProposalBlockParts.Total() == 0 {
  167. t.Error("rs.ProposalBlockParts should be set")
  168. }
  169. // if we're a validator, enterPropose should not timeout
  170. ensureNoNewTimeout(timeoutCh, cs.config.TimeoutPropose.Nanoseconds())
  171. }
  172. func TestStateBadProposal(t *testing.T) {
  173. config := configSetup(t)
  174. ctx, cancel := context.WithCancel(context.Background())
  175. defer cancel()
  176. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 2)
  177. require.NoError(t, err)
  178. height, round := cs1.Height, cs1.Round
  179. vs2 := vss[1]
  180. partSize := types.BlockPartSizeBytes
  181. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  182. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  183. propBlock, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2)
  184. // make the second validator the proposer by incrementing round
  185. round++
  186. incrementRound(vss[1:]...)
  187. // make the block bad by tampering with statehash
  188. stateHash := propBlock.AppHash
  189. if len(stateHash) == 0 {
  190. stateHash = make([]byte, 32)
  191. }
  192. stateHash[0] = (stateHash[0] + 1) % 255
  193. propBlock.AppHash = stateHash
  194. propBlockParts := propBlock.MakePartSet(partSize)
  195. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  196. proposal := types.NewProposal(vs2.Height, round, -1, blockID)
  197. p := proposal.ToProto()
  198. if err := vs2.SignProposal(ctx, config.ChainID(), p); err != nil {
  199. t.Fatal("failed to sign bad proposal", err)
  200. }
  201. proposal.Signature = p.Signature
  202. // set the proposal block
  203. if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
  204. t.Fatal(err)
  205. }
  206. // start the machine
  207. startTestRound(ctx, cs1, height, round)
  208. // wait for proposal
  209. ensureProposal(proposalCh, height, round, blockID)
  210. // wait for prevote
  211. ensurePrevote(voteCh, height, round)
  212. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  213. // add bad prevote from vs2 and wait for it
  214. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
  215. ensurePrevote(voteCh, height, round)
  216. // wait for precommit
  217. ensurePrecommit(voteCh, height, round)
  218. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  219. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
  220. }
  221. func TestStateOversizedBlock(t *testing.T) {
  222. config := configSetup(t)
  223. ctx, cancel := context.WithCancel(context.Background())
  224. defer cancel()
  225. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 2)
  226. require.NoError(t, err)
  227. cs1.state.ConsensusParams.Block.MaxBytes = 2000
  228. height, round := cs1.Height, cs1.Round
  229. vs2 := vss[1]
  230. partSize := types.BlockPartSizeBytes
  231. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  232. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  233. propBlock, _ := cs1.createProposalBlock()
  234. propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)}
  235. propBlock.Header.DataHash = propBlock.Data.Hash()
  236. // make the second validator the proposer by incrementing round
  237. round++
  238. incrementRound(vss[1:]...)
  239. propBlockParts := propBlock.MakePartSet(partSize)
  240. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  241. proposal := types.NewProposal(height, round, -1, blockID)
  242. p := proposal.ToProto()
  243. if err := vs2.SignProposal(ctx, config.ChainID(), p); err != nil {
  244. t.Fatal("failed to sign bad proposal", err)
  245. }
  246. proposal.Signature = p.Signature
  247. totalBytes := 0
  248. for i := 0; i < int(propBlockParts.Total()); i++ {
  249. part := propBlockParts.GetPart(i)
  250. totalBytes += len(part.Bytes)
  251. }
  252. if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
  253. t.Fatal(err)
  254. }
  255. // start the machine
  256. startTestRound(ctx, cs1, height, round)
  257. t.Log("Block Sizes", "Limit", cs1.state.ConsensusParams.Block.MaxBytes, "Current", totalBytes)
  258. // c1 should log an error with the block part message as it exceeds the consensus params. The
  259. // block is not added to cs.ProposalBlock so the node timeouts.
  260. ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  261. // and then should send nil prevote and precommit regardless of whether other validators prevote and
  262. // precommit on it
  263. ensurePrevote(voteCh, height, round)
  264. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  265. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
  266. ensurePrevote(voteCh, height, round)
  267. ensurePrecommit(voteCh, height, round)
  268. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  269. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
  270. }
  271. //----------------------------------------------------------------------------------------------------
  272. // FullRoundSuite
  273. // propose, prevote, and precommit a block
  274. func TestStateFullRound1(t *testing.T) {
  275. config := configSetup(t)
  276. logger := log.TestingLogger()
  277. ctx, cancel := context.WithCancel(context.Background())
  278. defer cancel()
  279. cs, vss, err := randState(ctx, config, logger, 1)
  280. require.NoError(t, err)
  281. height, round := cs.Height, cs.Round
  282. // NOTE: buffer capacity of 0 ensures we can validate prevote and last commit
  283. // before consensus can move to the next height (and cause a race condition)
  284. if err := cs.eventBus.Stop(); err != nil {
  285. t.Error(err)
  286. }
  287. eventBus := eventbus.NewDefault(logger.With("module", "events"))
  288. cs.SetEventBus(eventBus)
  289. if err := eventBus.Start(ctx); err != nil {
  290. t.Error(err)
  291. }
  292. voteCh := subscribe(ctx, t, cs.eventBus, types.EventQueryVote)
  293. propCh := subscribe(ctx, t, cs.eventBus, types.EventQueryCompleteProposal)
  294. newRoundCh := subscribe(ctx, t, cs.eventBus, types.EventQueryNewRound)
  295. // Maybe it would be better to call explicitly startRoutines(4)
  296. startTestRound(ctx, cs, height, round)
  297. ensureNewRound(newRoundCh, height, round)
  298. ensureNewProposal(propCh, height, round)
  299. propBlockHash := cs.GetRoundState().ProposalBlock.Hash()
  300. ensurePrevote(voteCh, height, round) // wait for prevote
  301. validatePrevote(ctx, t, cs, round, vss[0], propBlockHash)
  302. ensurePrecommit(voteCh, height, round) // wait for precommit
  303. // we're going to roll right into new height
  304. ensureNewRound(newRoundCh, height+1, 0)
  305. validateLastPrecommit(ctx, t, cs, vss[0], propBlockHash)
  306. }
  307. // nil is proposed, so prevote and precommit nil
  308. func TestStateFullRoundNil(t *testing.T) {
  309. config := configSetup(t)
  310. ctx, cancel := context.WithCancel(context.Background())
  311. defer cancel()
  312. cs, vss, err := randState(ctx, config, log.TestingLogger(), 1)
  313. require.NoError(t, err)
  314. height, round := cs.Height, cs.Round
  315. voteCh := subscribe(ctx, t, cs.eventBus, types.EventQueryVote)
  316. cs.enterPrevote(height, round)
  317. cs.startRoutines(ctx, 4)
  318. ensurePrevote(voteCh, height, round) // prevote
  319. ensurePrecommit(voteCh, height, round) // precommit
  320. // should prevote and precommit nil
  321. validatePrevoteAndPrecommit(ctx, t, cs, round, -1, vss[0], nil, nil)
  322. }
  323. // run through propose, prevote, precommit commit with two validators
  324. // where the first validator has to wait for votes from the second
  325. func TestStateFullRound2(t *testing.T) {
  326. config := configSetup(t)
  327. ctx, cancel := context.WithCancel(context.Background())
  328. defer cancel()
  329. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 2)
  330. require.NoError(t, err)
  331. vs2 := vss[1]
  332. height, round := cs1.Height, cs1.Round
  333. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  334. newBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlock)
  335. // start round and wait for propose and prevote
  336. startTestRound(ctx, cs1, height, round)
  337. ensurePrevote(voteCh, height, round) // prevote
  338. // we should be stuck in limbo waiting for more prevotes
  339. rs := cs1.GetRoundState()
  340. propBlockHash, propPartSetHeader := rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header()
  341. // prevote arrives from vs2:
  342. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propPartSetHeader, vs2)
  343. ensurePrevote(voteCh, height, round) // prevote
  344. ensurePrecommit(voteCh, height, round) // precommit
  345. // the proposed block should now be locked and our precommit added
  346. validatePrecommit(ctx, t, cs1, 0, 0, vss[0], propBlockHash, propBlockHash)
  347. // we should be stuck in limbo waiting for more precommits
  348. // precommit arrives from vs2:
  349. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlockHash, propPartSetHeader, vs2)
  350. ensurePrecommit(voteCh, height, round)
  351. // wait to finish commit, propose in next height
  352. ensureNewBlock(newBlockCh, height)
  353. }
  354. //------------------------------------------------------------------------------------------
  355. // LockSuite
  356. // two validators, 4 rounds.
  357. // two vals take turns proposing. val1 locks on first one, precommits nil on everything else
  358. func TestStateLockNoPOL(t *testing.T) {
  359. config := configSetup(t)
  360. ctx, cancel := context.WithCancel(context.Background())
  361. defer cancel()
  362. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 2)
  363. require.NoError(t, err)
  364. vs2 := vss[1]
  365. height, round := cs1.Height, cs1.Round
  366. partSize := types.BlockPartSizeBytes
  367. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  368. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  369. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  370. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  371. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  372. /*
  373. Round1 (cs1, B) // B B // B B2
  374. */
  375. // start round and wait for prevote
  376. cs1.enterNewRound(height, round)
  377. cs1.startRoutines(ctx, 0)
  378. ensureNewRound(newRoundCh, height, round)
  379. ensureNewProposal(proposalCh, height, round)
  380. roundState := cs1.GetRoundState()
  381. theBlockHash := roundState.ProposalBlock.Hash()
  382. thePartSetHeader := roundState.ProposalBlockParts.Header()
  383. ensurePrevote(voteCh, height, round) // prevote
  384. // we should now be stuck in limbo forever, waiting for more prevotes
  385. // prevote arrives from vs2:
  386. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, theBlockHash, thePartSetHeader, vs2)
  387. ensurePrevote(voteCh, height, round) // prevote
  388. ensurePrecommit(voteCh, height, round) // precommit
  389. // the proposed block should now be locked and our precommit added
  390. validatePrecommit(ctx, t, cs1, round, round, vss[0], theBlockHash, theBlockHash)
  391. // we should now be stuck in limbo forever, waiting for more precommits
  392. // lets add one for a different block
  393. hash := make([]byte, len(theBlockHash))
  394. copy(hash, theBlockHash)
  395. hash[0] = (hash[0] + 1) % 255
  396. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, hash, thePartSetHeader, vs2)
  397. ensurePrecommit(voteCh, height, round) // precommit
  398. // (note we're entering precommit for a second time this round)
  399. // but with invalid args. then we enterPrecommitWait, and the timeout to new round
  400. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  401. ///
  402. round++ // moving to the next round
  403. ensureNewRound(newRoundCh, height, round)
  404. t.Log("#### ONTO ROUND 1")
  405. /*
  406. Round2 (cs1, B) // B B2
  407. */
  408. incrementRound(vs2)
  409. // now we're on a new round and not the proposer, so wait for timeout
  410. ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  411. rs := cs1.GetRoundState()
  412. if rs.ProposalBlock != nil {
  413. panic("Expected proposal block to be nil")
  414. }
  415. // wait to finish prevote
  416. ensurePrevote(voteCh, height, round)
  417. // we should have prevoted our locked block
  418. validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash())
  419. // add a conflicting prevote from the other validator
  420. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2)
  421. ensurePrevote(voteCh, height, round)
  422. // now we're going to enter prevote again, but with invalid args
  423. // and then prevote wait, which should timeout. then wait for precommit
  424. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  425. ensurePrecommit(voteCh, height, round) // precommit
  426. // the proposed block should still be locked and our precommit added
  427. // we should precommit nil and be locked on the proposal
  428. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash)
  429. // add conflicting precommit from vs2
  430. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2)
  431. ensurePrecommit(voteCh, height, round)
  432. // (note we're entering precommit for a second time this round, but with invalid args
  433. // then we enterPrecommitWait and timeout into NewRound
  434. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  435. round++ // entering new round
  436. ensureNewRound(newRoundCh, height, round)
  437. t.Log("#### ONTO ROUND 2")
  438. /*
  439. Round3 (vs2, _) // B, B2
  440. */
  441. incrementRound(vs2)
  442. ensureNewProposal(proposalCh, height, round)
  443. rs = cs1.GetRoundState()
  444. // now we're on a new round and are the proposer
  445. if !bytes.Equal(rs.ProposalBlock.Hash(), rs.LockedBlock.Hash()) {
  446. panic(fmt.Sprintf(
  447. "Expected proposal block to be locked block. Got %v, Expected %v",
  448. rs.ProposalBlock,
  449. rs.LockedBlock))
  450. }
  451. ensurePrevote(voteCh, height, round) // prevote
  452. validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash())
  453. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, hash, rs.ProposalBlock.MakePartSet(partSize).Header(), vs2)
  454. ensurePrevote(voteCh, height, round)
  455. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  456. ensurePrecommit(voteCh, height, round) // precommit
  457. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but be locked on proposal
  458. signAddVotes(
  459. ctx,
  460. config,
  461. cs1,
  462. tmproto.PrecommitType,
  463. hash,
  464. rs.ProposalBlock.MakePartSet(partSize).Header(),
  465. vs2) // NOTE: conflicting precommits at same height
  466. ensurePrecommit(voteCh, height, round)
  467. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  468. // needed so generated block is different than locked block
  469. cs2, _, err := randState(ctx, config, log.TestingLogger(), 2)
  470. require.NoError(t, err)
  471. // before we time out into new round, set next proposal block
  472. prop, propBlock := decideProposal(ctx, cs2, vs2, vs2.Height, vs2.Round+1)
  473. if prop == nil || propBlock == nil {
  474. t.Fatal("Failed to create proposal block with vs2")
  475. }
  476. incrementRound(vs2)
  477. round++ // entering new round
  478. ensureNewRound(newRoundCh, height, round)
  479. t.Log("#### ONTO ROUND 3")
  480. /*
  481. Round4 (vs2, C) // B C // B C
  482. */
  483. // now we're on a new round and not the proposer
  484. // so set the proposal block
  485. if err := cs1.SetProposalAndBlock(prop, propBlock, propBlock.MakePartSet(partSize), ""); err != nil {
  486. t.Fatal(err)
  487. }
  488. ensureNewProposal(proposalCh, height, round)
  489. ensurePrevote(voteCh, height, round) // prevote
  490. // prevote for locked block (not proposal)
  491. validatePrevote(ctx, t, cs1, 3, vss[0], cs1.LockedBlock.Hash())
  492. // prevote for proposed block
  493. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
  494. ensurePrevote(voteCh, height, round)
  495. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  496. ensurePrecommit(voteCh, height, round)
  497. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but locked on proposal
  498. signAddVotes(
  499. ctx,
  500. config,
  501. cs1,
  502. tmproto.PrecommitType,
  503. propBlock.Hash(),
  504. propBlock.MakePartSet(partSize).Header(),
  505. vs2) // NOTE: conflicting precommits at same height
  506. ensurePrecommit(voteCh, height, round)
  507. }
  508. // 4 vals in two rounds,
  509. // in round one: v1 precommits, other 3 only prevote so the block isn't committed
  510. // in round two: v1 prevotes the same block that the node is locked on
  511. // the others prevote a new block hence v1 changes lock and precommits the new block with the others
  512. func TestStateLockPOLRelock(t *testing.T) {
  513. config := configSetup(t)
  514. logger := log.TestingLogger()
  515. ctx, cancel := context.WithCancel(context.Background())
  516. defer cancel()
  517. cs1, vss, err := randState(ctx, config, logger, 4)
  518. require.NoError(t, err)
  519. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  520. height, round := cs1.Height, cs1.Round
  521. partSize := types.BlockPartSizeBytes
  522. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  523. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  524. pv1, err := cs1.privValidator.GetPubKey(ctx)
  525. require.NoError(t, err)
  526. addr := pv1.Address()
  527. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  528. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  529. newBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlockHeader)
  530. // everything done from perspective of cs1
  531. /*
  532. Round1 (cs1, B) // B B B B// B nil B nil
  533. eg. vs2 and vs4 didn't see the 2/3 prevotes
  534. */
  535. // start round and wait for propose and prevote
  536. startTestRound(ctx, cs1, height, round)
  537. ensureNewRound(newRoundCh, height, round)
  538. ensureNewProposal(proposalCh, height, round)
  539. rs := cs1.GetRoundState()
  540. theBlockHash := rs.ProposalBlock.Hash()
  541. theBlockParts := rs.ProposalBlockParts.Header()
  542. ensurePrevote(voteCh, height, round) // prevote
  543. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4)
  544. ensurePrecommit(voteCh, height, round) // our precommit
  545. // the proposed block should now be locked and our precommit added
  546. validatePrecommit(ctx, t, cs1, round, round, vss[0], theBlockHash, theBlockHash)
  547. // add precommits from the rest
  548. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  549. // before we timeout to the new round set the new proposal
  550. cs2, err := newState(ctx, logger, cs1.state, vs2, kvstore.NewApplication())
  551. require.NoError(t, err)
  552. prop, propBlock := decideProposal(ctx, cs2, vs2, vs2.Height, vs2.Round+1)
  553. if prop == nil || propBlock == nil {
  554. t.Fatal("Failed to create proposal block with vs2")
  555. }
  556. propBlockParts := propBlock.MakePartSet(partSize)
  557. propBlockHash := propBlock.Hash()
  558. require.NotEqual(t, propBlockHash, theBlockHash)
  559. incrementRound(vs2, vs3, vs4)
  560. // timeout to new round
  561. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  562. round++ // moving to the next round
  563. //XXX: this isnt guaranteed to get there before the timeoutPropose ...
  564. if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil {
  565. t.Fatal(err)
  566. }
  567. ensureNewRound(newRoundCh, height, round)
  568. t.Log("### ONTO ROUND 1")
  569. /*
  570. Round2 (vs2, C) // B C C C // C C C _)
  571. cs1 changes lock!
  572. */
  573. // now we're on a new round and not the proposer
  574. // but we should receive the proposal
  575. ensureNewProposal(proposalCh, height, round)
  576. // go to prevote, node should prevote for locked block (not the new proposal) - this is relocking
  577. ensurePrevote(voteCh, height, round)
  578. validatePrevote(ctx, t, cs1, round, vss[0], theBlockHash)
  579. // now lets add prevotes from everyone else for the new block
  580. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4)
  581. ensurePrecommit(voteCh, height, round)
  582. // we should have unlocked and locked on the new block, sending a precommit for this new block
  583. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlockHash, propBlockHash)
  584. // more prevote creating a majority on the new block and this is then committed
  585. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlockHash, propBlockParts.Header(), vs2, vs3)
  586. ensureNewBlockHeader(newBlockCh, height, propBlockHash)
  587. ensureNewRound(newRoundCh, height+1, 0)
  588. }
  589. // 4 vals, one precommits, other 3 polka at next round, so we unlock and precomit the polka
  590. func TestStateLockPOLUnlock(t *testing.T) {
  591. config := configSetup(t)
  592. ctx, cancel := context.WithCancel(context.Background())
  593. defer cancel()
  594. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  595. require.NoError(t, err)
  596. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  597. height, round := cs1.Height, cs1.Round
  598. partSize := types.BlockPartSizeBytes
  599. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  600. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  601. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  602. unlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryUnlock)
  603. pv1, err := cs1.privValidator.GetPubKey(ctx)
  604. require.NoError(t, err)
  605. addr := pv1.Address()
  606. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  607. // everything done from perspective of cs1
  608. /*
  609. Round1 (cs1, B) // B B B B // B nil B nil
  610. eg. didn't see the 2/3 prevotes
  611. */
  612. // start round and wait for propose and prevote
  613. startTestRound(ctx, cs1, height, round)
  614. ensureNewRound(newRoundCh, height, round)
  615. ensureNewProposal(proposalCh, height, round)
  616. rs := cs1.GetRoundState()
  617. theBlockHash := rs.ProposalBlock.Hash()
  618. theBlockParts := rs.ProposalBlockParts.Header()
  619. ensurePrevote(voteCh, height, round)
  620. validatePrevote(ctx, t, cs1, round, vss[0], theBlockHash)
  621. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4)
  622. ensurePrecommit(voteCh, height, round)
  623. // the proposed block should now be locked and our precommit added
  624. validatePrecommit(ctx, t, cs1, round, round, vss[0], theBlockHash, theBlockHash)
  625. // add precommits from the rest
  626. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs4)
  627. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3)
  628. // before we time out into new round, set next proposal block
  629. prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1)
  630. propBlockParts := propBlock.MakePartSet(partSize)
  631. // timeout to new round
  632. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  633. rs = cs1.GetRoundState()
  634. lockedBlockHash := rs.LockedBlock.Hash()
  635. incrementRound(vs2, vs3, vs4)
  636. round++ // moving to the next round
  637. ensureNewRound(newRoundCh, height, round)
  638. t.Log("#### ONTO ROUND 1")
  639. /*
  640. Round2 (vs2, C) // B nil nil nil // nil nil nil _
  641. cs1 unlocks!
  642. */
  643. //XXX: this isnt guaranteed to get there before the timeoutPropose ...
  644. if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil {
  645. t.Fatal(err)
  646. }
  647. ensureNewProposal(proposalCh, height, round)
  648. // go to prevote, prevote for locked block (not proposal)
  649. ensurePrevote(voteCh, height, round)
  650. validatePrevote(ctx, t, cs1, round, vss[0], lockedBlockHash)
  651. // now lets add prevotes from everyone else for nil (a polka!)
  652. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  653. // the polka makes us unlock and precommit nil
  654. ensureNewUnlock(unlockCh, height, round)
  655. ensurePrecommit(voteCh, height, round)
  656. // we should have unlocked and committed nil
  657. // NOTE: since we don't relock on nil, the lock round is -1
  658. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  659. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3)
  660. ensureNewRound(newRoundCh, height, round+1)
  661. }
  662. // 4 vals, v1 locks on proposed block in the first round but the other validators only prevote
  663. // In the second round, v1 misses the proposal but sees a majority prevote an unknown block so
  664. // v1 should unlock and precommit nil. In the third round another block is proposed, all vals
  665. // prevote and now v1 can lock onto the third block and precommit that
  666. func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) {
  667. config := configSetup(t)
  668. logger := log.TestingLogger()
  669. ctx, cancel := context.WithCancel(context.Background())
  670. defer cancel()
  671. cs1, vss, err := randState(ctx, config, logger, 4)
  672. require.NoError(t, err)
  673. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  674. height, round := cs1.Height, cs1.Round
  675. partSize := types.BlockPartSizeBytes
  676. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  677. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  678. pv1, err := cs1.privValidator.GetPubKey(ctx)
  679. require.NoError(t, err)
  680. addr := pv1.Address()
  681. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  682. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  683. // everything done from perspective of cs1
  684. /*
  685. Round0 (cs1, A) // A A A A// A nil nil nil
  686. */
  687. // start round and wait for propose and prevote
  688. startTestRound(ctx, cs1, height, round)
  689. ensureNewRound(newRoundCh, height, round)
  690. ensureNewProposal(proposalCh, height, round)
  691. rs := cs1.GetRoundState()
  692. firstBlockHash := rs.ProposalBlock.Hash()
  693. firstBlockParts := rs.ProposalBlockParts.Header()
  694. ensurePrevote(voteCh, height, round) // prevote
  695. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, firstBlockHash, firstBlockParts, vs2, vs3, vs4)
  696. ensurePrecommit(voteCh, height, round) // our precommit
  697. // the proposed block should now be locked and our precommit added
  698. validatePrecommit(ctx, t, cs1, round, round, vss[0], firstBlockHash, firstBlockHash)
  699. // add precommits from the rest
  700. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  701. // before we timeout to the new round set the new proposal
  702. cs2, err := newState(ctx, logger, cs1.state, vs2, kvstore.NewApplication())
  703. require.NoError(t, err)
  704. prop, propBlock := decideProposal(ctx, cs2, vs2, vs2.Height, vs2.Round+1)
  705. if prop == nil || propBlock == nil {
  706. t.Fatal("Failed to create proposal block with vs2")
  707. }
  708. secondBlockParts := propBlock.MakePartSet(partSize)
  709. secondBlockHash := propBlock.Hash()
  710. require.NotEqual(t, secondBlockHash, firstBlockHash)
  711. incrementRound(vs2, vs3, vs4)
  712. // timeout to new round
  713. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  714. round++ // moving to the next round
  715. ensureNewRound(newRoundCh, height, round)
  716. t.Log("### ONTO ROUND 1")
  717. /*
  718. Round1 (vs2, B) // A B B B // nil nil nil nil)
  719. */
  720. // now we're on a new round but v1 misses the proposal
  721. // go to prevote, node should prevote for locked block (not the new proposal) - this is relocking
  722. ensurePrevote(voteCh, height, round)
  723. validatePrevote(ctx, t, cs1, round, vss[0], firstBlockHash)
  724. // now lets add prevotes from everyone else for the new block
  725. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, secondBlockHash, secondBlockParts.Header(), vs2, vs3, vs4)
  726. ensurePrecommit(voteCh, height, round)
  727. // we should have unlocked and locked on the new block, sending a precommit for this new block
  728. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  729. if err := cs1.SetProposalAndBlock(prop, propBlock, secondBlockParts, "some peer"); err != nil {
  730. t.Fatal(err)
  731. }
  732. // more prevote creating a majority on the new block and this is then committed
  733. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  734. // before we timeout to the new round set the new proposal
  735. cs3, err := newState(ctx, logger, cs1.state, vs3, kvstore.NewApplication())
  736. require.NoError(t, err)
  737. prop, propBlock = decideProposal(ctx, cs3, vs3, vs3.Height, vs3.Round+1)
  738. if prop == nil || propBlock == nil {
  739. t.Fatal("Failed to create proposal block with vs2")
  740. }
  741. thirdPropBlockParts := propBlock.MakePartSet(partSize)
  742. thirdPropBlockHash := propBlock.Hash()
  743. require.NotEqual(t, secondBlockHash, thirdPropBlockHash)
  744. incrementRound(vs2, vs3, vs4)
  745. // timeout to new round
  746. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  747. round++ // moving to the next round
  748. ensureNewRound(newRoundCh, height, round)
  749. t.Log("### ONTO ROUND 2")
  750. /*
  751. Round2 (vs3, C) // C C C C // C nil nil nil)
  752. */
  753. if err := cs1.SetProposalAndBlock(prop, propBlock, thirdPropBlockParts, "some peer"); err != nil {
  754. t.Fatal(err)
  755. }
  756. ensurePrevote(voteCh, height, round)
  757. // we are no longer locked to the first block so we should be able to prevote
  758. validatePrevote(ctx, t, cs1, round, vss[0], thirdPropBlockHash)
  759. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, thirdPropBlockHash, thirdPropBlockParts.Header(), vs2, vs3, vs4)
  760. ensurePrecommit(voteCh, height, round)
  761. // we have a majority, now vs1 can change lock to the third block
  762. validatePrecommit(ctx, t, cs1, round, round, vss[0], thirdPropBlockHash, thirdPropBlockHash)
  763. }
  764. // 4 vals
  765. // a polka at round 1 but we miss it
  766. // then a polka at round 2 that we lock on
  767. // then we see the polka from round 1 but shouldn't unlock
  768. func TestStateLockPOLSafety1(t *testing.T) {
  769. config := configSetup(t)
  770. ctx, cancel := context.WithCancel(context.Background())
  771. defer cancel()
  772. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  773. require.NoError(t, err)
  774. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  775. height, round := cs1.Height, cs1.Round
  776. partSize := types.BlockPartSizeBytes
  777. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  778. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  779. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  780. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  781. pv1, err := cs1.privValidator.GetPubKey(ctx)
  782. require.NoError(t, err)
  783. addr := pv1.Address()
  784. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  785. // start round and wait for propose and prevote
  786. startTestRound(ctx, cs1, cs1.Height, round)
  787. ensureNewRound(newRoundCh, height, round)
  788. ensureNewProposal(proposalCh, height, round)
  789. rs := cs1.GetRoundState()
  790. propBlock := rs.ProposalBlock
  791. ensurePrevote(voteCh, height, round)
  792. validatePrevote(ctx, t, cs1, round, vss[0], propBlock.Hash())
  793. // the others sign a polka but we don't see it
  794. prevotes := signVotes(ctx, config, tmproto.PrevoteType,
  795. propBlock.Hash(), propBlock.MakePartSet(partSize).Header(),
  796. vs2, vs3, vs4)
  797. t.Logf("old prop hash %v", fmt.Sprintf("%X", propBlock.Hash()))
  798. // we do see them precommit nil
  799. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  800. // cs1 precommit nil
  801. ensurePrecommit(voteCh, height, round)
  802. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  803. t.Log("### ONTO ROUND 1")
  804. prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1)
  805. propBlockHash := propBlock.Hash()
  806. propBlockParts := propBlock.MakePartSet(partSize)
  807. incrementRound(vs2, vs3, vs4)
  808. round++ // moving to the next round
  809. ensureNewRound(newRoundCh, height, round)
  810. //XXX: this isnt guaranteed to get there before the timeoutPropose ...
  811. if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil {
  812. t.Fatal(err)
  813. }
  814. /*Round2
  815. // we timeout and prevote our lock
  816. // a polka happened but we didn't see it!
  817. */
  818. ensureNewProposal(proposalCh, height, round)
  819. rs = cs1.GetRoundState()
  820. if rs.LockedBlock != nil {
  821. panic("we should not be locked!")
  822. }
  823. t.Logf("new prop hash %v", fmt.Sprintf("%X", propBlockHash))
  824. // go to prevote, prevote for proposal block
  825. ensurePrevote(voteCh, height, round)
  826. validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash)
  827. // now we see the others prevote for it, so we should lock on it
  828. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4)
  829. ensurePrecommit(voteCh, height, round)
  830. // we should have precommitted
  831. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlockHash, propBlockHash)
  832. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  833. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  834. incrementRound(vs2, vs3, vs4)
  835. round++ // moving to the next round
  836. ensureNewRound(newRoundCh, height, round)
  837. t.Log("### ONTO ROUND 2")
  838. /*Round3
  839. we see the polka from round 1 but we shouldn't unlock!
  840. */
  841. // timeout of propose
  842. ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  843. // finish prevote
  844. ensurePrevote(voteCh, height, round)
  845. // we should prevote what we're locked on
  846. validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash)
  847. newStepCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRoundStep)
  848. // before prevotes from the previous round are added
  849. // add prevotes from the earlier round
  850. addVotes(cs1, prevotes...)
  851. t.Log("Done adding prevotes!")
  852. ensureNoNewRoundStep(newStepCh)
  853. }
  854. // 4 vals.
  855. // polka P0 at R0, P1 at R1, and P2 at R2,
  856. // we lock on P0 at R0, don't see P1, and unlock using P2 at R2
  857. // then we should make sure we don't lock using P1
  858. // What we want:
  859. // dont see P0, lock on P1 at R1, dont unlock using P0 at R2
  860. func TestStateLockPOLSafety2(t *testing.T) {
  861. config := configSetup(t)
  862. ctx, cancel := context.WithCancel(context.Background())
  863. defer cancel()
  864. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  865. require.NoError(t, err)
  866. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  867. height, round := cs1.Height, cs1.Round
  868. partSize := types.BlockPartSizeBytes
  869. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  870. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  871. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  872. unlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryUnlock)
  873. pv1, err := cs1.privValidator.GetPubKey(ctx)
  874. require.NoError(t, err)
  875. addr := pv1.Address()
  876. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  877. // the block for R0: gets polkad but we miss it
  878. // (even though we signed it, shhh)
  879. _, propBlock0 := decideProposal(ctx, cs1, vss[0], height, round)
  880. propBlockHash0 := propBlock0.Hash()
  881. propBlockParts0 := propBlock0.MakePartSet(partSize)
  882. propBlockID0 := types.BlockID{Hash: propBlockHash0, PartSetHeader: propBlockParts0.Header()}
  883. // the others sign a polka but we don't see it
  884. prevotes := signVotes(ctx, config, tmproto.PrevoteType, propBlockHash0, propBlockParts0.Header(), vs2, vs3, vs4)
  885. // the block for round 1
  886. prop1, propBlock1 := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1)
  887. propBlockHash1 := propBlock1.Hash()
  888. propBlockParts1 := propBlock1.MakePartSet(partSize)
  889. incrementRound(vs2, vs3, vs4)
  890. round++ // moving to the next round
  891. t.Log("### ONTO Round 1")
  892. // jump in at round 1
  893. startTestRound(ctx, cs1, height, round)
  894. ensureNewRound(newRoundCh, height, round)
  895. if err := cs1.SetProposalAndBlock(prop1, propBlock1, propBlockParts1, "some peer"); err != nil {
  896. t.Fatal(err)
  897. }
  898. ensureNewProposal(proposalCh, height, round)
  899. ensurePrevote(voteCh, height, round)
  900. validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash1)
  901. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash1, propBlockParts1.Header(), vs2, vs3, vs4)
  902. ensurePrecommit(voteCh, height, round)
  903. // the proposed block should now be locked and our precommit added
  904. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlockHash1, propBlockHash1)
  905. // add precommits from the rest
  906. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs4)
  907. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlockHash1, propBlockParts1.Header(), vs3)
  908. incrementRound(vs2, vs3, vs4)
  909. // timeout of precommit wait to new round
  910. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  911. round++ // moving to the next round
  912. // in round 2 we see the polkad block from round 0
  913. newProp := types.NewProposal(height, round, 0, propBlockID0)
  914. p := newProp.ToProto()
  915. if err := vs3.SignProposal(ctx, config.ChainID(), p); err != nil {
  916. t.Fatal(err)
  917. }
  918. newProp.Signature = p.Signature
  919. if err := cs1.SetProposalAndBlock(newProp, propBlock0, propBlockParts0, "some peer"); err != nil {
  920. t.Fatal(err)
  921. }
  922. // Add the pol votes
  923. addVotes(cs1, prevotes...)
  924. ensureNewRound(newRoundCh, height, round)
  925. t.Log("### ONTO Round 2")
  926. /*Round2
  927. // now we see the polka from round 1, but we shouldnt unlock
  928. */
  929. ensureNewProposal(proposalCh, height, round)
  930. ensureNoNewUnlock(unlockCh)
  931. ensurePrevote(voteCh, height, round)
  932. validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash1)
  933. }
  934. // 4 vals.
  935. // polka P0 at R0 for B0. We lock B0 on P0 at R0. P0 unlocks value at R1.
  936. // What we want:
  937. // P0 proposes B0 at R3.
  938. func TestProposeValidBlock(t *testing.T) {
  939. config := configSetup(t)
  940. ctx, cancel := context.WithCancel(context.Background())
  941. defer cancel()
  942. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  943. require.NoError(t, err)
  944. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  945. height, round := cs1.Height, cs1.Round
  946. partSize := types.BlockPartSizeBytes
  947. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  948. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  949. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  950. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  951. unlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryUnlock)
  952. pv1, err := cs1.privValidator.GetPubKey(ctx)
  953. require.NoError(t, err)
  954. addr := pv1.Address()
  955. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  956. // start round and wait for propose and prevote
  957. startTestRound(ctx, cs1, cs1.Height, round)
  958. ensureNewRound(newRoundCh, height, round)
  959. ensureNewProposal(proposalCh, height, round)
  960. rs := cs1.GetRoundState()
  961. propBlock := rs.ProposalBlock
  962. propBlockHash := propBlock.Hash()
  963. ensurePrevote(voteCh, height, round)
  964. validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash)
  965. // the others sign a polka
  966. signAddVotes(ctx, config, cs1, tmproto.PrevoteType,
  967. propBlockHash, propBlock.MakePartSet(partSize).Header(), vs2,
  968. vs3, vs4)
  969. ensurePrecommit(voteCh, height, round)
  970. // we should have precommitted
  971. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlockHash, propBlockHash)
  972. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  973. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  974. incrementRound(vs2, vs3, vs4)
  975. round++ // moving to the next round
  976. ensureNewRound(newRoundCh, height, round)
  977. t.Log("### ONTO ROUND 2")
  978. // timeout of propose
  979. ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  980. ensurePrevote(voteCh, height, round)
  981. validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash)
  982. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  983. ensureNewUnlock(unlockCh, height, round)
  984. ensurePrecommit(voteCh, height, round)
  985. // we should have precommitted
  986. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  987. incrementRound(vs2, vs3, vs4)
  988. incrementRound(vs2, vs3, vs4)
  989. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  990. round += 2 // moving to the next round
  991. ensureNewRound(newRoundCh, height, round)
  992. t.Log("### ONTO ROUND 3")
  993. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  994. round++ // moving to the next round
  995. ensureNewRound(newRoundCh, height, round)
  996. t.Log("### ONTO ROUND 4")
  997. ensureNewProposal(proposalCh, height, round)
  998. rs = cs1.GetRoundState()
  999. assert.True(t, bytes.Equal(rs.ProposalBlock.Hash(), propBlockHash))
  1000. assert.True(t, bytes.Equal(rs.ProposalBlock.Hash(), rs.ValidBlock.Hash()))
  1001. assert.True(t, rs.Proposal.POLRound == rs.ValidRound)
  1002. assert.True(t, bytes.Equal(rs.Proposal.BlockID.Hash, rs.ValidBlock.Hash()))
  1003. }
  1004. // What we want:
  1005. // P0 miss to lock B but set valid block to B after receiving delayed prevote.
  1006. func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
  1007. config := configSetup(t)
  1008. ctx, cancel := context.WithCancel(context.Background())
  1009. defer cancel()
  1010. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1011. require.NoError(t, err)
  1012. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1013. height, round := cs1.Height, cs1.Round
  1014. partSize := types.BlockPartSizeBytes
  1015. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1016. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1017. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1018. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1019. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1020. require.NoError(t, err)
  1021. addr := pv1.Address()
  1022. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1023. // start round and wait for propose and prevote
  1024. startTestRound(ctx, cs1, cs1.Height, round)
  1025. ensureNewRound(newRoundCh, height, round)
  1026. ensureNewProposal(proposalCh, height, round)
  1027. rs := cs1.GetRoundState()
  1028. propBlock := rs.ProposalBlock
  1029. propBlockHash := propBlock.Hash()
  1030. propBlockParts := propBlock.MakePartSet(partSize)
  1031. ensurePrevote(voteCh, height, round)
  1032. validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash)
  1033. // vs2 send prevote for propBlock
  1034. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2)
  1035. // vs3 send prevote nil
  1036. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs3)
  1037. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  1038. ensurePrecommit(voteCh, height, round)
  1039. // we should have precommitted
  1040. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1041. rs = cs1.GetRoundState()
  1042. assert.True(t, rs.ValidBlock == nil)
  1043. assert.True(t, rs.ValidBlockParts == nil)
  1044. assert.True(t, rs.ValidRound == -1)
  1045. // vs2 send (delayed) prevote for propBlock
  1046. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs4)
  1047. ensureNewValidBlock(validBlockCh, height, round)
  1048. rs = cs1.GetRoundState()
  1049. assert.True(t, bytes.Equal(rs.ValidBlock.Hash(), propBlockHash))
  1050. assert.True(t, rs.ValidBlockParts.Header().Equals(propBlockParts.Header()))
  1051. assert.True(t, rs.ValidRound == round)
  1052. }
  1053. // What we want:
  1054. // P0 miss to lock B as Proposal Block is missing, but set valid block to B after
  1055. // receiving delayed Block Proposal.
  1056. func TestSetValidBlockOnDelayedProposal(t *testing.T) {
  1057. config := configSetup(t)
  1058. ctx, cancel := context.WithCancel(context.Background())
  1059. defer cancel()
  1060. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1061. require.NoError(t, err)
  1062. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1063. height, round := cs1.Height, cs1.Round
  1064. partSize := types.BlockPartSizeBytes
  1065. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1066. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1067. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1068. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1069. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1070. require.NoError(t, err)
  1071. addr := pv1.Address()
  1072. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1073. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1074. round++ // move to round in which P0 is not proposer
  1075. incrementRound(vs2, vs3, vs4)
  1076. startTestRound(ctx, cs1, cs1.Height, round)
  1077. ensureNewRound(newRoundCh, height, round)
  1078. ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1079. ensurePrevote(voteCh, height, round)
  1080. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  1081. prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1)
  1082. propBlockHash := propBlock.Hash()
  1083. propBlockParts := propBlock.MakePartSet(partSize)
  1084. // vs2, vs3 and vs4 send prevote for propBlock
  1085. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4)
  1086. ensureNewValidBlock(validBlockCh, height, round)
  1087. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  1088. ensurePrecommit(voteCh, height, round)
  1089. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1090. if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil {
  1091. t.Fatal(err)
  1092. }
  1093. ensureNewProposal(proposalCh, height, round)
  1094. rs := cs1.GetRoundState()
  1095. assert.True(t, bytes.Equal(rs.ValidBlock.Hash(), propBlockHash))
  1096. assert.True(t, rs.ValidBlockParts.Header().Equals(propBlockParts.Header()))
  1097. assert.True(t, rs.ValidRound == round)
  1098. }
  1099. // 4 vals, 3 Nil Precommits at P0
  1100. // What we want:
  1101. // P0 waits for timeoutPrecommit before starting next round
  1102. func TestWaitingTimeoutOnNilPolka(t *testing.T) {
  1103. config := configSetup(t)
  1104. ctx, cancel := context.WithCancel(context.Background())
  1105. defer cancel()
  1106. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1107. require.NoError(t, err)
  1108. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1109. height, round := cs1.Height, cs1.Round
  1110. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1111. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1112. // start round
  1113. startTestRound(ctx, cs1, height, round)
  1114. ensureNewRound(newRoundCh, height, round)
  1115. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  1116. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1117. ensureNewRound(newRoundCh, height, round+1)
  1118. }
  1119. // 4 vals, 3 Prevotes for nil from the higher round.
  1120. // What we want:
  1121. // P0 waits for timeoutPropose in the next round before entering prevote
  1122. func TestWaitingTimeoutProposeOnNewRound(t *testing.T) {
  1123. config := configSetup(t)
  1124. ctx, cancel := context.WithCancel(context.Background())
  1125. defer cancel()
  1126. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1127. require.NoError(t, err)
  1128. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1129. height, round := cs1.Height, cs1.Round
  1130. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1131. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1132. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1133. require.NoError(t, err)
  1134. addr := pv1.Address()
  1135. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1136. // start round
  1137. startTestRound(ctx, cs1, height, round)
  1138. ensureNewRound(newRoundCh, height, round)
  1139. ensurePrevote(voteCh, height, round)
  1140. incrementRound(vss[1:]...)
  1141. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  1142. round++ // moving to the next round
  1143. ensureNewRound(newRoundCh, height, round)
  1144. rs := cs1.GetRoundState()
  1145. assert.True(t, rs.Step == cstypes.RoundStepPropose) // P0 does not prevote before timeoutPropose expires
  1146. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1147. ensurePrevote(voteCh, height, round)
  1148. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  1149. }
  1150. // 4 vals, 3 Precommits for nil from the higher round.
  1151. // What we want:
  1152. // P0 jump to higher round, precommit and start precommit wait
  1153. func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) {
  1154. config := configSetup(t)
  1155. ctx, cancel := context.WithCancel(context.Background())
  1156. defer cancel()
  1157. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1158. require.NoError(t, err)
  1159. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1160. height, round := cs1.Height, cs1.Round
  1161. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1162. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1163. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1164. require.NoError(t, err)
  1165. addr := pv1.Address()
  1166. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1167. // start round
  1168. startTestRound(ctx, cs1, height, round)
  1169. ensureNewRound(newRoundCh, height, round)
  1170. ensurePrevote(voteCh, height, round)
  1171. incrementRound(vss[1:]...)
  1172. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  1173. round++ // moving to the next round
  1174. ensureNewRound(newRoundCh, height, round)
  1175. ensurePrecommit(voteCh, height, round)
  1176. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1177. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1178. round++ // moving to the next round
  1179. ensureNewRound(newRoundCh, height, round)
  1180. }
  1181. // 4 vals, 3 Prevotes for nil in the current round.
  1182. // What we want:
  1183. // P0 wait for timeoutPropose to expire before sending prevote.
  1184. func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) {
  1185. config := configSetup(t)
  1186. ctx, cancel := context.WithCancel(context.Background())
  1187. defer cancel()
  1188. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1189. require.NoError(t, err)
  1190. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1191. height, round := cs1.Height, int32(1)
  1192. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1193. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1194. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1195. require.NoError(t, err)
  1196. addr := pv1.Address()
  1197. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1198. // start round in which PO is not proposer
  1199. startTestRound(ctx, cs1, height, round)
  1200. ensureNewRound(newRoundCh, height, round)
  1201. incrementRound(vss[1:]...)
  1202. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
  1203. ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1204. ensurePrevote(voteCh, height, round)
  1205. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  1206. }
  1207. // What we want:
  1208. // P0 emit NewValidBlock event upon receiving 2/3+ Precommit for B but hasn't received block B yet
  1209. func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) {
  1210. config := configSetup(t)
  1211. ctx, cancel := context.WithCancel(context.Background())
  1212. defer cancel()
  1213. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1214. require.NoError(t, err)
  1215. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1216. height, round := cs1.Height, int32(1)
  1217. incrementRound(vs2, vs3, vs4)
  1218. partSize := types.BlockPartSizeBytes
  1219. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1220. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1221. _, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round)
  1222. propBlockHash := propBlock.Hash()
  1223. propBlockParts := propBlock.MakePartSet(partSize)
  1224. // start round in which PO is not proposer
  1225. startTestRound(ctx, cs1, height, round)
  1226. ensureNewRound(newRoundCh, height, round)
  1227. // vs2, vs3 and vs4 send precommit for propBlock
  1228. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4)
  1229. ensureNewValidBlock(validBlockCh, height, round)
  1230. rs := cs1.GetRoundState()
  1231. assert.True(t, rs.Step == cstypes.RoundStepCommit)
  1232. assert.True(t, rs.ProposalBlock == nil)
  1233. assert.True(t, rs.ProposalBlockParts.Header().Equals(propBlockParts.Header()))
  1234. }
  1235. // What we want:
  1236. // P0 receives 2/3+ Precommit for B for round 0, while being in round 1. It emits NewValidBlock event.
  1237. // After receiving block, it executes block and moves to the next height.
  1238. func TestCommitFromPreviousRound(t *testing.T) {
  1239. config := configSetup(t)
  1240. ctx, cancel := context.WithCancel(context.Background())
  1241. defer cancel()
  1242. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1243. require.NoError(t, err)
  1244. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1245. height, round := cs1.Height, int32(1)
  1246. partSize := types.BlockPartSizeBytes
  1247. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1248. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1249. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1250. prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round)
  1251. propBlockHash := propBlock.Hash()
  1252. propBlockParts := propBlock.MakePartSet(partSize)
  1253. // start round in which PO is not proposer
  1254. startTestRound(ctx, cs1, height, round)
  1255. ensureNewRound(newRoundCh, height, round)
  1256. // vs2, vs3 and vs4 send precommit for propBlock for the previous round
  1257. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4)
  1258. ensureNewValidBlock(validBlockCh, height, round)
  1259. rs := cs1.GetRoundState()
  1260. assert.True(t, rs.Step == cstypes.RoundStepCommit)
  1261. assert.True(t, rs.CommitRound == vs2.Round)
  1262. assert.True(t, rs.ProposalBlock == nil)
  1263. assert.True(t, rs.ProposalBlockParts.Header().Equals(propBlockParts.Header()))
  1264. if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil {
  1265. t.Fatal(err)
  1266. }
  1267. ensureNewProposal(proposalCh, height, round)
  1268. ensureNewRound(newRoundCh, height+1, 0)
  1269. }
  1270. type fakeTxNotifier struct {
  1271. ch chan struct{}
  1272. }
  1273. func (n *fakeTxNotifier) TxsAvailable() <-chan struct{} {
  1274. return n.ch
  1275. }
  1276. func (n *fakeTxNotifier) Notify() {
  1277. n.ch <- struct{}{}
  1278. }
  1279. // 2 vals precommit votes for a block but node times out waiting for the third. Move to next round
  1280. // and third precommit arrives which leads to the commit of that header and the correct
  1281. // start of the next round
  1282. func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) {
  1283. config := configSetup(t)
  1284. ctx, cancel := context.WithCancel(context.Background())
  1285. defer cancel()
  1286. config.Consensus.SkipTimeoutCommit = false
  1287. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1288. require.NoError(t, err)
  1289. cs1.txNotifier = &fakeTxNotifier{ch: make(chan struct{})}
  1290. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1291. height, round := cs1.Height, cs1.Round
  1292. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1293. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1294. precommitTimeoutCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1295. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1296. newBlockHeader := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlockHeader)
  1297. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1298. require.NoError(t, err)
  1299. addr := pv1.Address()
  1300. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1301. // start round and wait for propose and prevote
  1302. startTestRound(ctx, cs1, height, round)
  1303. ensureNewRound(newRoundCh, height, round)
  1304. ensureNewProposal(proposalCh, height, round)
  1305. rs := cs1.GetRoundState()
  1306. theBlockHash := rs.ProposalBlock.Hash()
  1307. theBlockParts := rs.ProposalBlockParts.Header()
  1308. ensurePrevote(voteCh, height, round)
  1309. validatePrevote(ctx, t, cs1, round, vss[0], theBlockHash)
  1310. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4)
  1311. ensurePrecommit(voteCh, height, round)
  1312. // the proposed block should now be locked and our precommit added
  1313. validatePrecommit(ctx, t, cs1, round, round, vss[0], theBlockHash, theBlockHash)
  1314. // add precommits
  1315. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2)
  1316. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3)
  1317. // wait till timeout occurs
  1318. ensurePrecommitTimeout(precommitTimeoutCh)
  1319. ensureNewRound(newRoundCh, height, round+1)
  1320. // majority is now reached
  1321. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs4)
  1322. ensureNewBlockHeader(newBlockHeader, height, theBlockHash)
  1323. cs1.txNotifier.(*fakeTxNotifier).Notify()
  1324. ensureNewTimeout(timeoutProposeCh, height+1, round, cs1.config.Propose(round).Nanoseconds())
  1325. rs = cs1.GetRoundState()
  1326. assert.False(
  1327. t,
  1328. rs.TriggeredTimeoutPrecommit,
  1329. "triggeredTimeoutPrecommit should be false at the beginning of each round")
  1330. }
  1331. func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) {
  1332. config := configSetup(t)
  1333. ctx, cancel := context.WithCancel(context.Background())
  1334. defer cancel()
  1335. config.Consensus.SkipTimeoutCommit = false
  1336. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1337. require.NoError(t, err)
  1338. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1339. height, round := cs1.Height, cs1.Round
  1340. partSize := types.BlockPartSizeBytes
  1341. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1342. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1343. newBlockHeader := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlockHeader)
  1344. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1345. require.NoError(t, err)
  1346. addr := pv1.Address()
  1347. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1348. // start round and wait for propose and prevote
  1349. startTestRound(ctx, cs1, height, round)
  1350. ensureNewRound(newRoundCh, height, round)
  1351. ensureNewProposal(proposalCh, height, round)
  1352. rs := cs1.GetRoundState()
  1353. theBlockHash := rs.ProposalBlock.Hash()
  1354. theBlockParts := rs.ProposalBlockParts.Header()
  1355. ensurePrevote(voteCh, height, round)
  1356. validatePrevote(ctx, t, cs1, round, vss[0], theBlockHash)
  1357. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4)
  1358. ensurePrecommit(voteCh, height, round)
  1359. validatePrecommit(ctx, t, cs1, round, round, vss[0], theBlockHash, theBlockHash)
  1360. // add precommits
  1361. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2)
  1362. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3)
  1363. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs4)
  1364. ensureNewBlockHeader(newBlockHeader, height, theBlockHash)
  1365. prop, propBlock := decideProposal(ctx, cs1, vs2, height+1, 0)
  1366. propBlockParts := propBlock.MakePartSet(partSize)
  1367. if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil {
  1368. t.Fatal(err)
  1369. }
  1370. ensureNewProposal(proposalCh, height+1, 0)
  1371. rs = cs1.GetRoundState()
  1372. assert.False(
  1373. t,
  1374. rs.TriggeredTimeoutPrecommit,
  1375. "triggeredTimeoutPrecommit should be false at the beginning of each height")
  1376. }
  1377. //------------------------------------------------------------------------------------------
  1378. // SlashingSuite
  1379. // TODO: Slashing
  1380. /*
  1381. func TestStateSlashingPrevotes(t *testing.T) {
  1382. cs1, vss := randState(2)
  1383. vs2 := vss[1]
  1384. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1385. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1386. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1387. voteCh := subscribeToVoter(ctx, t, cs1, cs1.privValidator.GetAddress())
  1388. // start round and wait for propose and prevote
  1389. startTestRound(cs1, cs1.Height, 0)
  1390. <-newRoundCh
  1391. re := <-proposalCh
  1392. <-voteCh // prevote
  1393. rs := re.(types.EventDataRoundState).RoundState.(*cstypes.RoundState)
  1394. // we should now be stuck in limbo forever, waiting for more prevotes
  1395. // add one for a different block should cause us to go into prevote wait
  1396. hash := rs.ProposalBlock.Hash()
  1397. hash[0] = byte(hash[0]+1) % 255
  1398. signAddVotes(cs1, tmproto.PrevoteType, hash, rs.ProposalBlockParts.Header(), vs2)
  1399. <-timeoutWaitCh
  1400. // NOTE: we have to send the vote for different block first so we don't just go into precommit round right
  1401. // away and ignore more prevotes (and thus fail to slash!)
  1402. // add the conflicting vote
  1403. signAddVotes(cs1, tmproto.PrevoteType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vs2)
  1404. // XXX: Check for existence of Dupeout info
  1405. }
  1406. func TestStateSlashingPrecommits(t *testing.T) {
  1407. cs1, vss := randState(2)
  1408. vs2 := vss[1]
  1409. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1410. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1411. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1412. voteCh := subscribeToVoter(ctx, t, cs1, cs1.privValidator.GetAddress())
  1413. // start round and wait for propose and prevote
  1414. startTestRound(cs1, cs1.Height, 0)
  1415. <-newRoundCh
  1416. re := <-proposalCh
  1417. <-voteCh // prevote
  1418. // add prevote from vs2
  1419. signAddVotes(cs1, tmproto.PrevoteType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vs2)
  1420. <-voteCh // precommit
  1421. // we should now be stuck in limbo forever, waiting for more prevotes
  1422. // add one for a different block should cause us to go into prevote wait
  1423. hash := rs.ProposalBlock.Hash()
  1424. hash[0] = byte(hash[0]+1) % 255
  1425. signAddVotes(cs1, tmproto.PrecommitType, hash, rs.ProposalBlockParts.Header(), vs2)
  1426. // NOTE: we have to send the vote for different block first so we don't just go into precommit round right
  1427. // away and ignore more prevotes (and thus fail to slash!)
  1428. // add precommit from vs2
  1429. signAddVotes(cs1, tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vs2)
  1430. // XXX: Check for existence of Dupeout info
  1431. }
  1432. */
  1433. //------------------------------------------------------------------------------------------
  1434. // CatchupSuite
  1435. //------------------------------------------------------------------------------------------
  1436. // HaltSuite
  1437. // 4 vals.
  1438. // we receive a final precommit after going into next round, but others might have gone to commit already!
  1439. func TestStateHalt1(t *testing.T) {
  1440. config := configSetup(t)
  1441. ctx, cancel := context.WithCancel(context.Background())
  1442. defer cancel()
  1443. cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
  1444. require.NoError(t, err)
  1445. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1446. height, round := cs1.Height, cs1.Round
  1447. partSize := types.BlockPartSizeBytes
  1448. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1449. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1450. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1451. newBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlock)
  1452. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1453. require.NoError(t, err)
  1454. addr := pv1.Address()
  1455. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1456. // start round and wait for propose and prevote
  1457. startTestRound(ctx, cs1, height, round)
  1458. ensureNewRound(newRoundCh, height, round)
  1459. ensureNewProposal(proposalCh, height, round)
  1460. rs := cs1.GetRoundState()
  1461. propBlock := rs.ProposalBlock
  1462. propBlockParts := propBlock.MakePartSet(partSize)
  1463. ensurePrevote(voteCh, height, round)
  1464. signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), propBlockParts.Header(), vs2, vs3, vs4)
  1465. ensurePrecommit(voteCh, height, round)
  1466. // the proposed block should now be locked and our precommit added
  1467. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlock.Hash(), propBlock.Hash())
  1468. // add precommits from the rest
  1469. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2) // didnt receive proposal
  1470. signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlock.Hash(), propBlockParts.Header(), vs3)
  1471. // we receive this later, but vs3 might receive it earlier and with ours will go to commit!
  1472. precommit4 := signVote(ctx, vs4, config, tmproto.PrecommitType, propBlock.Hash(), propBlockParts.Header())
  1473. incrementRound(vs2, vs3, vs4)
  1474. // timeout to new round
  1475. ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1476. round++ // moving to the next round
  1477. ensureNewRound(newRoundCh, height, round)
  1478. rs = cs1.GetRoundState()
  1479. t.Log("### ONTO ROUND 1")
  1480. /*Round2
  1481. // we timeout and prevote our lock
  1482. // a polka happened but we didn't see it!
  1483. */
  1484. // go to prevote, prevote for locked block
  1485. ensurePrevote(voteCh, height, round)
  1486. validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash())
  1487. // now we receive the precommit from the previous round
  1488. addVotes(cs1, precommit4)
  1489. // receiving that precommit should take us straight to commit
  1490. ensureNewBlock(newBlockCh, height)
  1491. ensureNewRound(newRoundCh, height+1, 0)
  1492. }
  1493. func TestStateOutputsBlockPartsStats(t *testing.T) {
  1494. config := configSetup(t)
  1495. ctx, cancel := context.WithCancel(context.Background())
  1496. defer cancel()
  1497. // create dummy peer
  1498. cs, _, err := randState(ctx, config, log.TestingLogger(), 1)
  1499. require.NoError(t, err)
  1500. peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
  1501. require.NoError(t, err)
  1502. // 1) new block part
  1503. parts := types.NewPartSetFromData(tmrand.Bytes(100), 10)
  1504. msg := &BlockPartMessage{
  1505. Height: 1,
  1506. Round: 0,
  1507. Part: parts.GetPart(0),
  1508. }
  1509. cs.ProposalBlockParts = types.NewPartSetFromHeader(parts.Header())
  1510. cs.handleMsg(msgInfo{msg, peerID})
  1511. statsMessage := <-cs.statsMsgQueue
  1512. require.Equal(t, msg, statsMessage.Msg, "")
  1513. require.Equal(t, peerID, statsMessage.PeerID, "")
  1514. // sending the same part from different peer
  1515. cs.handleMsg(msgInfo{msg, "peer2"})
  1516. // sending the part with the same height, but different round
  1517. msg.Round = 1
  1518. cs.handleMsg(msgInfo{msg, peerID})
  1519. // sending the part from the smaller height
  1520. msg.Height = 0
  1521. cs.handleMsg(msgInfo{msg, peerID})
  1522. // sending the part from the bigger height
  1523. msg.Height = 3
  1524. cs.handleMsg(msgInfo{msg, peerID})
  1525. select {
  1526. case <-cs.statsMsgQueue:
  1527. t.Errorf("should not output stats message after receiving the known block part!")
  1528. case <-time.After(50 * time.Millisecond):
  1529. }
  1530. }
  1531. func TestStateOutputVoteStats(t *testing.T) {
  1532. config := configSetup(t)
  1533. ctx, cancel := context.WithCancel(context.Background())
  1534. defer cancel()
  1535. cs, vss, err := randState(ctx, config, log.TestingLogger(), 2)
  1536. require.NoError(t, err)
  1537. // create dummy peer
  1538. peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
  1539. require.NoError(t, err)
  1540. randBytes := tmrand.Bytes(tmhash.Size)
  1541. vote := signVote(ctx, vss[1], config, tmproto.PrecommitType, randBytes, types.PartSetHeader{})
  1542. voteMessage := &VoteMessage{vote}
  1543. cs.handleMsg(msgInfo{voteMessage, peerID})
  1544. statsMessage := <-cs.statsMsgQueue
  1545. require.Equal(t, voteMessage, statsMessage.Msg, "")
  1546. require.Equal(t, peerID, statsMessage.PeerID, "")
  1547. // sending the same part from different peer
  1548. cs.handleMsg(msgInfo{&VoteMessage{vote}, "peer2"})
  1549. // sending the vote for the bigger height
  1550. incrementHeight(vss[1])
  1551. vote = signVote(ctx, vss[1], config, tmproto.PrecommitType, randBytes, types.PartSetHeader{})
  1552. cs.handleMsg(msgInfo{&VoteMessage{vote}, peerID})
  1553. select {
  1554. case <-cs.statsMsgQueue:
  1555. t.Errorf("should not output stats message after receiving the known vote or vote from bigger height")
  1556. case <-time.After(50 * time.Millisecond):
  1557. }
  1558. }
  1559. func TestSignSameVoteTwice(t *testing.T) {
  1560. config := configSetup(t)
  1561. ctx, cancel := context.WithCancel(context.Background())
  1562. defer cancel()
  1563. _, vss, err := randState(ctx, config, log.TestingLogger(), 2)
  1564. require.NoError(t, err)
  1565. randBytes := tmrand.Bytes(tmhash.Size)
  1566. vote := signVote(
  1567. ctx,
  1568. vss[1],
  1569. config,
  1570. tmproto.PrecommitType,
  1571. randBytes,
  1572. types.PartSetHeader{Total: 10, Hash: randBytes},
  1573. )
  1574. vote2 := signVote(
  1575. ctx,
  1576. vss[1],
  1577. config,
  1578. tmproto.PrecommitType,
  1579. randBytes,
  1580. types.PartSetHeader{Total: 10, Hash: randBytes},
  1581. )
  1582. require.Equal(t, vote, vote2)
  1583. }
  1584. // subscribe subscribes test client to the given query and returns a channel with cap = 1.
  1585. func subscribe(
  1586. ctx context.Context,
  1587. t *testing.T,
  1588. eventBus *eventbus.EventBus,
  1589. q tmpubsub.Query,
  1590. ) <-chan tmpubsub.Message {
  1591. t.Helper()
  1592. sub, err := eventBus.SubscribeWithArgs(ctx, tmpubsub.SubscribeArgs{
  1593. ClientID: testSubscriber,
  1594. Query: q,
  1595. })
  1596. if err != nil {
  1597. t.Fatalf("Failed to subscribe %q to %v: %v", testSubscriber, q, err)
  1598. }
  1599. ch := make(chan tmpubsub.Message)
  1600. go func() {
  1601. for {
  1602. next, err := sub.Next(ctx)
  1603. if err != nil {
  1604. if ctx.Err() != nil {
  1605. return
  1606. }
  1607. t.Errorf("Subscription for %v unexpectedly terminated: %v", q, err)
  1608. return
  1609. }
  1610. ch <- next
  1611. }
  1612. }()
  1613. return ch
  1614. }