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.

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