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.

2169 lines
74 KiB

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