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.

2649 lines
94 KiB

9 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
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
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
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
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
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
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
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
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. tmquery "github.com/tendermint/tendermint/internal/pubsub/query"
  16. "github.com/tendermint/tendermint/libs/log"
  17. tmrand "github.com/tendermint/tendermint/libs/rand"
  18. tmtime "github.com/tendermint/tendermint/libs/time"
  19. tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
  20. "github.com/tendermint/tendermint/types"
  21. )
  22. /*
  23. ProposeSuite
  24. x * TestProposerSelection0 - round robin ordering, round 0
  25. x * TestProposerSelection2 - round robin ordering, round 2++
  26. x * TestEnterProposeNoValidator - timeout into prevote round
  27. x * TestEnterPropose - finish propose without timing out (we have the proposal)
  28. x * TestBadProposal - 2 vals, bad proposal (bad block state hash), should prevote and precommit nil
  29. x * TestOversizedBlock - block with too many txs should be rejected
  30. FullRoundSuite
  31. x * TestFullRound1 - 1 val, full successful round
  32. x * TestFullRoundNil - 1 val, full round of nil
  33. x * TestFullRound2 - 2 vals, both required for full round
  34. LockSuite
  35. x * TestStateLock_NoPOL - 2 vals, 4 rounds. one val locked, precommits nil every round except first.
  36. x * TestStateLock_POLUpdateLock - 4 vals, one precommits,
  37. other 3 polka at next round, so we unlock and precomit the polka
  38. x * TestStateLock_POLRelock - 4 vals, polka in round 1 and polka in round 2.
  39. Ensure validator updates locked round.
  40. x_*_TestStateLock_POLDoesNotUnlock 4 vals, one precommits, other 3 polka nil at
  41. next round, so we precommit nil but maintain lock
  42. x * TestStateLock_MissingProposalWhenPOLSeenDoesNotUpdateLock - 4 vals, 1 misses proposal but sees POL.
  43. x * TestStateLock_MissingProposalWhenPOLSeenDoesNotUnlock - 4 vals, 1 misses proposal but sees POL.
  44. x * TestStateLock_POLSafety1 - 4 vals. We shouldn't change lock based on polka at earlier round
  45. x * TestStateLock_POLSafety2 - 4 vals. After unlocking, we shouldn't relock based on polka at earlier round
  46. x_*_TestState_PrevotePOLFromPreviousRound 4 vals, prevote a proposal if a POL was seen for it in a previous round.
  47. * TestNetworkLock - once +1/3 precommits, network should be locked
  48. * TestNetworkLockPOL - once +1/3 precommits, the block with more recent polka is committed
  49. SlashingSuite
  50. x * TestStateSlashing_Prevotes - a validator prevoting twice in a round gets slashed
  51. x * TestStateSlashing_Precommits - a validator precomitting twice in a round gets slashed
  52. CatchupSuite
  53. * TestCatchup - if we might be behind and we've seen any 2/3 prevotes, round skip to new round, precommit, or prevote
  54. HaltSuite
  55. x * TestHalt1 - if we see +2/3 precommits after timing out into new round, we should still commit
  56. */
  57. //----------------------------------------------------------------------------------------------------
  58. // ProposeSuite
  59. func TestStateProposerSelection0(t *testing.T) {
  60. ctx, cancel := context.WithCancel(context.Background())
  61. defer cancel()
  62. config := configSetup(t)
  63. logger := log.NewNopLogger()
  64. cs1, vss := makeState(ctx, t, config, logger, 4)
  65. height, round := cs1.Height, cs1.Round
  66. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  67. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  68. startTestRound(ctx, cs1, height, round)
  69. // Wait for new round so proposer is set.
  70. ensureNewRound(t, newRoundCh, height, round)
  71. // Commit a block and ensure proposer for the next height is correct.
  72. prop := cs1.GetRoundState().Validators.GetProposer()
  73. pv, err := cs1.privValidator.GetPubKey(ctx)
  74. require.NoError(t, err)
  75. address := pv.Address()
  76. require.Truef(t, bytes.Equal(prop.Address, address), "expected proposer to be validator %d. Got %X", 0, prop.Address)
  77. // Wait for complete proposal.
  78. ensureNewProposal(t, proposalCh, height, round)
  79. rs := cs1.GetRoundState()
  80. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{
  81. Hash: rs.ProposalBlock.Hash(),
  82. PartSetHeader: rs.ProposalBlockParts.Header(),
  83. }, vss[1:]...)
  84. // Wait for new round so next validator is set.
  85. ensureNewRound(t, newRoundCh, height+1, 0)
  86. prop = cs1.GetRoundState().Validators.GetProposer()
  87. pv1, err := vss[1].GetPubKey(ctx)
  88. require.NoError(t, err)
  89. addr := pv1.Address()
  90. require.True(t, bytes.Equal(prop.Address, addr), "expected proposer to be validator %d. Got %X", 1, prop.Address)
  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. logger := log.NewNopLogger()
  96. ctx, cancel := context.WithCancel(context.Background())
  97. defer cancel()
  98. cs1, vss := makeState(ctx, t, config, logger, 4) // test needs more work for more than 3 validators
  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(t, 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. require.True(t, bytes.Equal(prop.Address, correctProposer),
  115. "expected RoundState.Validators.GetProposer() to be validator %d. Got %X",
  116. int(i+2)%len(vss),
  117. prop.Address)
  118. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vss[1:]...)
  119. ensureNewRound(t, newRoundCh, height, i+round+1) // wait for the new round event each round
  120. incrementRound(vss[1:]...)
  121. }
  122. }
  123. // a non-validator should timeout into the prevote round
  124. func TestStateEnterProposeNoPrivValidator(t *testing.T) {
  125. config := configSetup(t)
  126. logger := log.NewNopLogger()
  127. ctx, cancel := context.WithCancel(context.Background())
  128. defer cancel()
  129. cs, _ := makeState(ctx, t, config, logger, 1)
  130. cs.SetPrivValidator(ctx, nil)
  131. height, round := cs.Height, cs.Round
  132. // Listen for propose timeout event
  133. timeoutCh := subscribe(ctx, t, cs.eventBus, types.EventQueryTimeoutPropose)
  134. startTestRound(ctx, cs, height, round)
  135. // if we're not a validator, EnterPropose should timeout
  136. ensureNewTimeout(t, timeoutCh, height, round, cs.config.TimeoutPropose.Nanoseconds())
  137. if cs.GetRoundState().Proposal != nil {
  138. t.Error("Expected to make no proposal, since no privValidator")
  139. }
  140. }
  141. // a validator should not timeout of the prevote round (TODO: unless the block is really big!)
  142. func TestStateEnterProposeYesPrivValidator(t *testing.T) {
  143. config := configSetup(t)
  144. logger := log.NewNopLogger()
  145. ctx, cancel := context.WithCancel(context.Background())
  146. defer cancel()
  147. cs, _ := makeState(ctx, t, config, logger, 1)
  148. height, round := cs.Height, cs.Round
  149. // Listen for propose timeout event
  150. timeoutCh := subscribe(ctx, t, cs.eventBus, types.EventQueryTimeoutPropose)
  151. proposalCh := subscribe(ctx, t, cs.eventBus, types.EventQueryCompleteProposal)
  152. cs.enterNewRound(ctx, height, round)
  153. cs.startRoutines(ctx, 3)
  154. ensureNewProposal(t, proposalCh, height, round)
  155. // Check that Proposal, ProposalBlock, ProposalBlockParts are set.
  156. rs := cs.GetRoundState()
  157. if rs.Proposal == nil {
  158. t.Error("rs.Proposal should be set")
  159. }
  160. if rs.ProposalBlock == nil {
  161. t.Error("rs.ProposalBlock should be set")
  162. }
  163. if rs.ProposalBlockParts.Total() == 0 {
  164. t.Error("rs.ProposalBlockParts should be set")
  165. }
  166. // if we're a validator, enterPropose should not timeout
  167. ensureNoNewTimeout(t, timeoutCh, cs.config.TimeoutPropose.Nanoseconds())
  168. }
  169. func TestStateBadProposal(t *testing.T) {
  170. config := configSetup(t)
  171. logger := log.NewNopLogger()
  172. ctx, cancel := context.WithCancel(context.Background())
  173. defer cancel()
  174. cs1, vss := makeState(ctx, t, config, logger, 2)
  175. height, round := cs1.Height, cs1.Round
  176. vs2 := vss[1]
  177. partSize := types.BlockPartSizeBytes
  178. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  179. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  180. propBlock, _, err := cs1.createProposalBlock(ctx) // changeProposer(t, cs1, vs2)
  181. require.NoError(t, err)
  182. // make the second validator the proposer by incrementing round
  183. round++
  184. incrementRound(vss[1:]...)
  185. // make the block bad by tampering with statehash
  186. stateHash := propBlock.AppHash
  187. if len(stateHash) == 0 {
  188. stateHash = make([]byte, 32)
  189. }
  190. stateHash[0] = (stateHash[0] + 1) % 255
  191. propBlock.AppHash = stateHash
  192. propBlockParts, err := propBlock.MakePartSet(partSize)
  193. require.NoError(t, err)
  194. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  195. proposal := types.NewProposal(vs2.Height, round, -1, blockID, propBlock.Header.Time)
  196. p := proposal.ToProto()
  197. err = vs2.SignProposal(ctx, config.ChainID(), p)
  198. require.NoError(t, err)
  199. proposal.Signature = p.Signature
  200. // set the proposal block
  201. err = cs1.SetProposalAndBlock(ctx, proposal, propBlock, propBlockParts, "some peer")
  202. require.NoError(t, err)
  203. // start the machine
  204. startTestRound(ctx, cs1, height, round)
  205. // wait for proposal
  206. ensureProposal(t, proposalCh, height, round, blockID)
  207. // wait for prevote
  208. ensurePrevoteMatch(t, voteCh, height, round, nil)
  209. // add bad prevote from vs2 and wait for it
  210. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2)
  211. ensurePrevote(t, voteCh, height, round)
  212. // wait for precommit
  213. ensurePrecommit(t, voteCh, height, round)
  214. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  215. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs2)
  216. }
  217. func TestStateOversizedBlock(t *testing.T) {
  218. config := configSetup(t)
  219. logger := log.NewNopLogger()
  220. ctx, cancel := context.WithCancel(context.Background())
  221. defer cancel()
  222. cs1, vss := makeState(ctx, t, config, logger, 2)
  223. cs1.state.ConsensusParams.Block.MaxBytes = 2000
  224. height, round := cs1.Height, cs1.Round
  225. vs2 := vss[1]
  226. partSize := types.BlockPartSizeBytes
  227. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  228. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  229. propBlock, _, err := cs1.createProposalBlock(ctx)
  230. require.NoError(t, err)
  231. propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)}
  232. propBlock.Header.DataHash = propBlock.Data.Hash()
  233. // make the second validator the proposer by incrementing round
  234. round++
  235. incrementRound(vss[1:]...)
  236. propBlockParts, err := propBlock.MakePartSet(partSize)
  237. require.NoError(t, err)
  238. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  239. proposal := types.NewProposal(height, round, -1, blockID, propBlock.Header.Time)
  240. p := proposal.ToProto()
  241. err = vs2.SignProposal(ctx, config.ChainID(), p)
  242. require.NoError(t, err)
  243. proposal.Signature = p.Signature
  244. totalBytes := 0
  245. for i := 0; i < int(propBlockParts.Total()); i++ {
  246. part := propBlockParts.GetPart(i)
  247. totalBytes += len(part.Bytes)
  248. }
  249. err = cs1.SetProposalAndBlock(ctx, proposal, propBlock, propBlockParts, "some peer")
  250. require.NoError(t, err)
  251. // start the machine
  252. startTestRound(ctx, cs1, height, round)
  253. t.Log("Block Sizes", "Limit", cs1.state.ConsensusParams.Block.MaxBytes, "Current", totalBytes)
  254. // c1 should log an error with the block part message as it exceeds the consensus params. The
  255. // block is not added to cs.ProposalBlock so the node timeouts.
  256. ensureNewTimeout(t, timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  257. // and then should send nil prevote and precommit regardless of whether other validators prevote and
  258. // precommit on it
  259. ensurePrevoteMatch(t, voteCh, height, round, nil)
  260. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2)
  261. ensurePrevote(t, voteCh, height, round)
  262. ensurePrecommit(t, voteCh, height, round)
  263. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  264. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs2)
  265. }
  266. //----------------------------------------------------------------------------------------------------
  267. // FullRoundSuite
  268. // propose, prevote, and precommit a block
  269. func TestStateFullRound1(t *testing.T) {
  270. config := configSetup(t)
  271. logger := log.NewNopLogger()
  272. ctx, cancel := context.WithCancel(context.Background())
  273. defer cancel()
  274. cs, vss := makeState(ctx, t, config, logger, 1)
  275. height, round := cs.Height, cs.Round
  276. voteCh := subscribe(ctx, t, cs.eventBus, types.EventQueryVote)
  277. propCh := subscribe(ctx, t, cs.eventBus, types.EventQueryCompleteProposal)
  278. newRoundCh := subscribe(ctx, t, cs.eventBus, types.EventQueryNewRound)
  279. // Maybe it would be better to call explicitly startRoutines(4)
  280. startTestRound(ctx, cs, height, round)
  281. ensureNewRound(t, newRoundCh, height, round)
  282. propBlock := ensureNewProposal(t, propCh, height, round)
  283. ensurePrevoteMatch(t, voteCh, height, round, propBlock.Hash) // wait for prevote
  284. ensurePrecommit(t, voteCh, height, round) // wait for precommit
  285. // we're going to roll right into new height
  286. ensureNewRound(t, newRoundCh, height+1, 0)
  287. validateLastPrecommit(ctx, t, cs, vss[0], propBlock.Hash)
  288. }
  289. // nil is proposed, so prevote and precommit nil
  290. func TestStateFullRoundNil(t *testing.T) {
  291. config := configSetup(t)
  292. logger := log.NewNopLogger()
  293. ctx, cancel := context.WithCancel(context.Background())
  294. defer cancel()
  295. cs, _ := makeState(ctx, t, config, logger, 1)
  296. height, round := cs.Height, cs.Round
  297. voteCh := subscribe(ctx, t, cs.eventBus, types.EventQueryVote)
  298. cs.enterPrevote(ctx, height, round)
  299. cs.startRoutines(ctx, 4)
  300. ensurePrevoteMatch(t, voteCh, height, round, nil) // prevote
  301. ensurePrecommitMatch(t, voteCh, height, round, nil) // precommit
  302. }
  303. // run through propose, prevote, precommit commit with two validators
  304. // where the first validator has to wait for votes from the second
  305. func TestStateFullRound2(t *testing.T) {
  306. config := configSetup(t)
  307. logger := log.NewNopLogger()
  308. ctx, cancel := context.WithCancel(context.Background())
  309. defer cancel()
  310. cs1, vss := makeState(ctx, t, config, logger, 2)
  311. vs2 := vss[1]
  312. height, round := cs1.Height, cs1.Round
  313. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  314. newBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlock)
  315. // start round and wait for propose and prevote
  316. startTestRound(ctx, cs1, height, round)
  317. ensurePrevote(t, voteCh, height, round) // prevote
  318. // we should be stuck in limbo waiting for more prevotes
  319. rs := cs1.GetRoundState()
  320. blockID := types.BlockID{Hash: rs.ProposalBlock.Hash(), PartSetHeader: rs.ProposalBlockParts.Header()}
  321. // prevote arrives from vs2:
  322. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2)
  323. ensurePrevote(t, voteCh, height, round) // prevote
  324. ensurePrecommit(t, voteCh, height, round) // precommit
  325. // the proposed block should now be locked and our precommit added
  326. validatePrecommit(ctx, t, cs1, 0, 0, vss[0], blockID.Hash, blockID.Hash)
  327. // we should be stuck in limbo waiting for more precommits
  328. // precommit arrives from vs2:
  329. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs2)
  330. ensurePrecommit(t, voteCh, height, round)
  331. // wait to finish commit, propose in next height
  332. ensureNewBlock(t, newBlockCh, height)
  333. }
  334. //------------------------------------------------------------------------------------------
  335. // LockSuite
  336. // two validators, 4 rounds.
  337. // two vals take turns proposing. val1 locks on first one, precommits nil on everything else
  338. func TestStateLock_NoPOL(t *testing.T) {
  339. config := configSetup(t)
  340. logger := log.NewNopLogger()
  341. ctx, cancel := context.WithCancel(context.Background())
  342. defer cancel()
  343. cs1, vss := makeState(ctx, t, config, logger, 2)
  344. vs2 := vss[1]
  345. height, round := cs1.Height, cs1.Round
  346. partSize := types.BlockPartSizeBytes
  347. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  348. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  349. voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote)
  350. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  351. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  352. /*
  353. Round1 (cs1, B) // B B // B B2
  354. */
  355. // start round and wait for prevote
  356. cs1.enterNewRound(ctx, height, round)
  357. cs1.startRoutines(ctx, 0)
  358. ensureNewRound(t, newRoundCh, height, round)
  359. ensureNewProposal(t, proposalCh, height, round)
  360. roundState := cs1.GetRoundState()
  361. initialBlockID := types.BlockID{
  362. Hash: roundState.ProposalBlock.Hash(),
  363. PartSetHeader: roundState.ProposalBlockParts.Header(),
  364. }
  365. ensurePrevote(t, voteCh, height, round) // prevote
  366. // we should now be stuck in limbo forever, waiting for more prevotes
  367. // prevote arrives from vs2:
  368. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), initialBlockID, vs2)
  369. ensurePrevote(t, voteCh, height, round) // prevote
  370. validatePrevote(ctx, t, cs1, round, vss[0], initialBlockID.Hash)
  371. // the proposed block should now be locked and our precommit added
  372. ensurePrecommit(t, voteCh, height, round)
  373. validatePrecommit(ctx, t, cs1, round, round, vss[0], initialBlockID.Hash, initialBlockID.Hash)
  374. // we should now be stuck in limbo forever, waiting for more precommits
  375. // lets add one for a different block
  376. hash := make([]byte, len(initialBlockID.Hash))
  377. copy(hash, initialBlockID.Hash)
  378. hash[0] = (hash[0] + 1) % 255
  379. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{
  380. Hash: hash,
  381. PartSetHeader: initialBlockID.PartSetHeader,
  382. }, vs2)
  383. ensurePrecommit(t, voteCh, height, round) // precommit
  384. // (note we're entering precommit for a second time this round)
  385. // but with invalid args. then we enterPrecommitWait, and the timeout to new round
  386. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  387. ///
  388. round++ // moving to the next round
  389. ensureNewRound(t, newRoundCh, height, round)
  390. t.Log("#### ONTO ROUND 1")
  391. /*
  392. Round2 (cs1, B) // B B2
  393. */
  394. incrementRound(vs2)
  395. // now we're on a new round and not the proposer, so wait for timeout
  396. ensureNewTimeout(t, timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  397. rs := cs1.GetRoundState()
  398. require.Nil(t, rs.ProposalBlock, "Expected proposal block to be nil")
  399. // we should have prevoted nil since we did not see a proposal in the round.
  400. ensurePrevote(t, voteCh, height, round)
  401. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  402. // add a conflicting prevote from the other validator
  403. partSet, err := rs.LockedBlock.MakePartSet(partSize)
  404. require.NoError(t, err)
  405. conflictingBlockID := types.BlockID{Hash: hash, PartSetHeader: partSet.Header()}
  406. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), conflictingBlockID, vs2)
  407. ensurePrevote(t, voteCh, height, round)
  408. // now we're going to enter prevote again, but with invalid args
  409. // and then prevote wait, which should timeout. then wait for precommit
  410. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  411. // the proposed block should still be locked block.
  412. // we should precommit nil and be locked on the proposal.
  413. ensurePrecommit(t, voteCh, height, round)
  414. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, initialBlockID.Hash)
  415. // add conflicting precommit from vs2
  416. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), conflictingBlockID, vs2)
  417. ensurePrecommit(t, voteCh, height, round)
  418. // (note we're entering precommit for a second time this round, but with invalid args
  419. // then we enterPrecommitWait and timeout into NewRound
  420. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  421. round++ // entering new round
  422. ensureNewRound(t, newRoundCh, height, round)
  423. t.Log("#### ONTO ROUND 2")
  424. /*
  425. Round3 (vs2, _) // B, B2
  426. */
  427. incrementRound(vs2)
  428. ensureNewProposal(t, proposalCh, height, round)
  429. rs = cs1.GetRoundState()
  430. // now we're on a new round and are the proposer
  431. require.True(t, bytes.Equal(rs.ProposalBlock.Hash(), rs.LockedBlock.Hash()),
  432. "Expected proposal block to be locked block. Got %v, Expected %v",
  433. rs.ProposalBlock,
  434. rs.LockedBlock)
  435. ensurePrevote(t, voteCh, height, round) // prevote
  436. validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash())
  437. partSet, err = rs.ProposalBlock.MakePartSet(partSize)
  438. require.NoError(t, err)
  439. newBlockID := types.BlockID{Hash: hash, PartSetHeader: partSet.Header()}
  440. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), newBlockID, vs2)
  441. ensurePrevote(t, voteCh, height, round)
  442. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  443. ensurePrecommit(t, voteCh, height, round) // precommit
  444. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, initialBlockID.Hash) // precommit nil but be locked on proposal
  445. signAddVotes(
  446. ctx,
  447. t,
  448. cs1,
  449. tmproto.PrecommitType,
  450. config.ChainID(),
  451. newBlockID,
  452. vs2) // NOTE: conflicting precommits at same height
  453. ensurePrecommit(t, voteCh, height, round)
  454. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  455. cs2, _ := makeState(ctx, t, config, logger, 2) // needed so generated block is different than locked block
  456. // before we time out into new round, set next proposal block
  457. prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round+1)
  458. require.NotNil(t, propBlock, "Failed to create proposal block with vs2")
  459. require.NotNil(t, prop, "Failed to create proposal block with vs2")
  460. propBlockID := types.BlockID{
  461. Hash: propBlock.Hash(),
  462. PartSetHeader: partSet.Header(),
  463. }
  464. incrementRound(vs2)
  465. round++ // entering new round
  466. ensureNewRound(t, newRoundCh, height, round)
  467. t.Log("#### ONTO ROUND 3")
  468. /*
  469. Round4 (vs2, C) // B C // B C
  470. */
  471. // now we're on a new round and not the proposer
  472. // so set the proposal block
  473. bps3, err := propBlock.MakePartSet(partSize)
  474. require.NoError(t, err)
  475. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, bps3, "")
  476. require.NoError(t, err)
  477. ensureNewProposal(t, proposalCh, height, round)
  478. // prevote for nil since we did not see a proposal for our locked block in the round.
  479. ensurePrevote(t, voteCh, height, round)
  480. validatePrevote(ctx, t, cs1, 3, vss[0], nil)
  481. // prevote for proposed block
  482. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), propBlockID, vs2)
  483. ensurePrevote(t, voteCh, height, round)
  484. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  485. ensurePrecommit(t, voteCh, height, round)
  486. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, initialBlockID.Hash) // precommit nil but locked on proposal
  487. signAddVotes(
  488. ctx,
  489. t,
  490. cs1,
  491. tmproto.PrecommitType,
  492. config.ChainID(),
  493. propBlockID,
  494. vs2) // NOTE: conflicting precommits at same height
  495. ensurePrecommit(t, voteCh, height, round)
  496. }
  497. // TestStateLock_POLUpdateLock tests that a validator updates its locked
  498. // block if the following conditions are met within a round:
  499. // 1. The validator received a valid proposal for the block
  500. // 2. The validator received prevotes representing greater than 2/3 of the voting
  501. // power on the network for the block.
  502. func TestStateLock_POLUpdateLock(t *testing.T) {
  503. config := configSetup(t)
  504. logger := log.NewNopLogger()
  505. ctx, cancel := context.WithCancel(context.Background())
  506. defer cancel()
  507. cs1, vss := makeState(ctx, t, config, logger, 4)
  508. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  509. height, round := cs1.Height, cs1.Round
  510. partSize := types.BlockPartSizeBytes
  511. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  512. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  513. pv1, err := cs1.privValidator.GetPubKey(ctx)
  514. require.NoError(t, err)
  515. addr := pv1.Address()
  516. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  517. lockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryLock)
  518. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  519. /*
  520. Round 0:
  521. cs1 creates a proposal for block B.
  522. Send a prevote for B from each of the validators to cs1.
  523. Send a precommit for nil from all of the validators to cs1.
  524. This ensures that cs1 will lock on B in this round but not precommit it.
  525. */
  526. t.Log("### Starting Round 0")
  527. // start round and wait for propose and prevote
  528. startTestRound(ctx, cs1, height, round)
  529. ensureNewRound(t, newRoundCh, height, round)
  530. ensureNewProposal(t, proposalCh, height, round)
  531. rs := cs1.GetRoundState()
  532. initialBlockID := types.BlockID{
  533. Hash: rs.ProposalBlock.Hash(),
  534. PartSetHeader: rs.ProposalBlockParts.Header(),
  535. }
  536. ensurePrevote(t, voteCh, height, round)
  537. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), initialBlockID, vs2, vs3, vs4)
  538. // check that the validator generates a Lock event.
  539. ensureLock(t, lockCh, height, round)
  540. // the proposed block should now be locked and our precommit added.
  541. ensurePrecommit(t, voteCh, height, round)
  542. validatePrecommit(ctx, t, cs1, round, round, vss[0], initialBlockID.Hash, initialBlockID.Hash)
  543. // add precommits from the rest of the validators.
  544. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  545. // timeout to new round.
  546. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  547. /*
  548. Round 1:
  549. Create a block, D and send a proposal for it to cs1
  550. Send a prevote for D from each of the validators to cs1.
  551. Send a precommit for nil from all of the validtors to cs1.
  552. Check that cs1 is now locked on the new block, D and no longer on the old block.
  553. */
  554. t.Log("### Starting Round 1")
  555. incrementRound(vs2, vs3, vs4)
  556. round++
  557. // Generate a new proposal block.
  558. cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication())
  559. require.NoError(t, err)
  560. propR1, propBlockR1 := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round)
  561. propBlockR1Parts, err := propBlockR1.MakePartSet(partSize)
  562. require.NoError(t, err)
  563. propBlockR1Hash := propBlockR1.Hash()
  564. r1BlockID := types.BlockID{
  565. Hash: propBlockR1Hash,
  566. PartSetHeader: propBlockR1Parts.Header(),
  567. }
  568. require.NotEqual(t, propBlockR1Hash, initialBlockID.Hash)
  569. err = cs1.SetProposalAndBlock(ctx, propR1, propBlockR1, propBlockR1Parts, "some peer")
  570. require.NoError(t, err)
  571. ensureNewRound(t, newRoundCh, height, round)
  572. // ensure that the validator receives the proposal.
  573. ensureNewProposal(t, proposalCh, height, round)
  574. // Prevote our nil since the proposal does not match our locked block.
  575. ensurePrevoteMatch(t, voteCh, height, round, nil)
  576. // Add prevotes from the remainder of the validators for the new locked block.
  577. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), r1BlockID, vs2, vs3, vs4)
  578. // Check that we lock on a new block.
  579. ensureLock(t, lockCh, height, round)
  580. ensurePrecommit(t, voteCh, height, round)
  581. // We should now be locked on the new block and prevote it since we saw a sufficient amount
  582. // prevote for the block.
  583. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlockR1Hash, propBlockR1Hash)
  584. }
  585. // TestStateLock_POLRelock tests that a validator updates its locked round if
  586. // it receives votes representing over 2/3 of the voting power on the network
  587. // for a block that it is already locked in.
  588. func TestStateLock_POLRelock(t *testing.T) {
  589. ctx, cancel := context.WithCancel(context.Background())
  590. defer cancel()
  591. config := configSetup(t)
  592. logger := log.NewNopLogger()
  593. cs1, vss := makeState(ctx, t, config, logger, 4)
  594. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  595. height, round := cs1.Height, cs1.Round
  596. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  597. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  598. pv1, err := cs1.privValidator.GetPubKey(ctx)
  599. require.NoError(t, err)
  600. addr := pv1.Address()
  601. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  602. lockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryLock)
  603. relockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryRelock)
  604. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  605. /*
  606. Round 0:
  607. cs1 creates a proposal for block B.
  608. Send a prevote for B from each of the validators to cs1.
  609. Send a precommit for nil from all of the validators to cs1.
  610. This ensures that cs1 will lock on B in this round but not precommit it.
  611. */
  612. t.Log("### Starting Round 0")
  613. startTestRound(ctx, cs1, height, round)
  614. ensureNewRound(t, newRoundCh, height, round)
  615. ensureNewProposal(t, proposalCh, height, round)
  616. rs := cs1.GetRoundState()
  617. theBlock := rs.ProposalBlock
  618. theBlockParts := rs.ProposalBlockParts
  619. blockID := types.BlockID{
  620. Hash: rs.ProposalBlock.Hash(),
  621. PartSetHeader: rs.ProposalBlockParts.Header(),
  622. }
  623. ensurePrevote(t, voteCh, height, round)
  624. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  625. // check that the validator generates a Lock event.
  626. ensureLock(t, lockCh, height, round)
  627. // the proposed block should now be locked and our precommit added.
  628. ensurePrecommit(t, voteCh, height, round)
  629. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  630. // add precommits from the rest of the validators.
  631. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  632. // timeout to new round.
  633. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  634. /*
  635. Round 1:
  636. Create a proposal for block B, the same block from round 1.
  637. Send a prevote for B from each of the validators to cs1.
  638. Send a precommit for nil from all of the validtors to cs1.
  639. Check that cs1 updates its 'locked round' value to the current round.
  640. */
  641. t.Log("### Starting Round 1")
  642. incrementRound(vs2, vs3, vs4)
  643. round++
  644. propR1 := types.NewProposal(height, round, cs1.ValidRound, blockID, theBlock.Header.Time)
  645. p := propR1.ToProto()
  646. err = vs2.SignProposal(ctx, cs1.state.ChainID, p)
  647. require.NoError(t, err)
  648. propR1.Signature = p.Signature
  649. err = cs1.SetProposalAndBlock(ctx, propR1, theBlock, theBlockParts, "")
  650. require.NoError(t, err)
  651. ensureNewRound(t, newRoundCh, height, round)
  652. // ensure that the validator receives the proposal.
  653. ensureNewProposal(t, proposalCh, height, round)
  654. // Prevote our locked block since it matches the propsal seen in this round.
  655. ensurePrevote(t, voteCh, height, round)
  656. validatePrevote(ctx, t, cs1, round, vss[0], blockID.Hash)
  657. // Add prevotes from the remainder of the validators for the locked block.
  658. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  659. // Check that we relock.
  660. ensureRelock(t, relockCh, height, round)
  661. ensurePrecommit(t, voteCh, height, round)
  662. // We should now be locked on the same block but with an updated locked round.
  663. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  664. }
  665. // TestStateLock_PrevoteNilWhenLockedAndMissProposal tests that a validator prevotes nil
  666. // if it is locked on a block and misses the proposal in a round.
  667. func TestStateLock_PrevoteNilWhenLockedAndMissProposal(t *testing.T) {
  668. ctx, cancel := context.WithCancel(context.Background())
  669. defer cancel()
  670. config := configSetup(t)
  671. logger := log.NewNopLogger()
  672. cs1, vss := makeState(ctx, t, config, logger, 4)
  673. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  674. height, round := cs1.Height, cs1.Round
  675. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  676. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  677. pv1, err := cs1.privValidator.GetPubKey(context.Background())
  678. require.NoError(t, err)
  679. addr := pv1.Address()
  680. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  681. lockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryLock)
  682. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  683. /*
  684. Round 0:
  685. cs1 creates a proposal for block B.
  686. Send a prevote for B from each of the validators to cs1.
  687. Send a precommit for nil from all of the validators to cs1.
  688. This ensures that cs1 will lock on B in this round but not precommit it.
  689. */
  690. t.Log("### Starting Round 0")
  691. startTestRound(ctx, cs1, height, round)
  692. ensureNewRound(t, newRoundCh, height, round)
  693. ensureNewProposal(t, proposalCh, height, round)
  694. rs := cs1.GetRoundState()
  695. blockID := types.BlockID{
  696. Hash: rs.ProposalBlock.Hash(),
  697. PartSetHeader: rs.ProposalBlockParts.Header(),
  698. }
  699. ensurePrevote(t, voteCh, height, round)
  700. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  701. // check that the validator generates a Lock event.
  702. ensureLock(t, lockCh, height, round)
  703. // the proposed block should now be locked and our precommit added.
  704. ensurePrecommit(t, voteCh, height, round)
  705. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  706. // add precommits from the rest of the validators.
  707. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  708. // timeout to new round.
  709. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  710. /*
  711. Round 1:
  712. Send a prevote for nil from each of the validators to cs1.
  713. Send a precommit for nil from all of the validtors to cs1.
  714. Check that cs1 prevotes nil instead of its locked block, but ensure
  715. that it maintains its locked block.
  716. */
  717. t.Log("### Starting Round 1")
  718. incrementRound(vs2, vs3, vs4)
  719. round++
  720. ensureNewRound(t, newRoundCh, height, round)
  721. // Prevote our nil.
  722. ensurePrevote(t, voteCh, height, round)
  723. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  724. // Add prevotes from the remainder of the validators nil.
  725. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  726. ensurePrecommit(t, voteCh, height, round)
  727. // We should now be locked on the same block but with an updated locked round.
  728. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, blockID.Hash)
  729. }
  730. // TestStateLock_PrevoteNilWhenLockedAndMissProposal tests that a validator prevotes nil
  731. // if it is locked on a block and misses the proposal in a round.
  732. func TestStateLock_PrevoteNilWhenLockedAndDifferentProposal(t *testing.T) {
  733. ctx, cancel := context.WithCancel(context.Background())
  734. defer cancel()
  735. logger := log.NewNopLogger()
  736. config := configSetup(t)
  737. /*
  738. All of the assertions in this test occur on the `cs1` validator.
  739. The test sends signed votes from the other validators to cs1 and
  740. cs1's state is then examined to verify that it now matches the expected
  741. state.
  742. */
  743. cs1, vss := makeState(ctx, t, config, logger, 4)
  744. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  745. height, round := cs1.Height, cs1.Round
  746. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  747. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  748. pv1, err := cs1.privValidator.GetPubKey(context.Background())
  749. require.NoError(t, err)
  750. addr := pv1.Address()
  751. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  752. lockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryLock)
  753. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  754. /*
  755. Round 0:
  756. cs1 creates a proposal for block B.
  757. Send a prevote for B from each of the validators to cs1.
  758. Send a precommit for nil from all of the validators to cs1.
  759. This ensures that cs1 will lock on B in this round but not precommit it.
  760. */
  761. t.Log("### Starting Round 0")
  762. startTestRound(ctx, cs1, height, round)
  763. ensureNewRound(t, newRoundCh, height, round)
  764. ensureNewProposal(t, proposalCh, height, round)
  765. rs := cs1.GetRoundState()
  766. blockID := types.BlockID{
  767. Hash: rs.ProposalBlock.Hash(),
  768. PartSetHeader: rs.ProposalBlockParts.Header(),
  769. }
  770. ensurePrevote(t, voteCh, height, round)
  771. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  772. // check that the validator generates a Lock event.
  773. ensureLock(t, lockCh, height, round)
  774. // the proposed block should now be locked and our precommit added.
  775. ensurePrecommit(t, voteCh, height, round)
  776. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  777. // add precommits from the rest of the validators.
  778. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  779. // timeout to new round.
  780. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  781. /*
  782. Round 1:
  783. Create a proposal for a new block.
  784. Send a prevote for nil from each of the validators to cs1.
  785. Send a precommit for nil from all of the validtors to cs1.
  786. Check that cs1 prevotes nil instead of its locked block, but ensure
  787. that it maintains its locked block.
  788. */
  789. t.Log("### Starting Round 1")
  790. incrementRound(vs2, vs3, vs4)
  791. round++
  792. cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication())
  793. propR1, propBlockR1 := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round)
  794. propBlockR1Parts, err := propBlockR1.MakePartSet(types.BlockPartSizeBytes)
  795. require.NoError(t, err)
  796. propBlockR1Hash := propBlockR1.Hash()
  797. require.NotEqual(t, propBlockR1Hash, blockID.Hash)
  798. err = cs1.SetProposalAndBlock(ctx, propR1, propBlockR1, propBlockR1Parts, "some peer")
  799. require.NoError(t, err)
  800. ensureNewRound(t, newRoundCh, height, round)
  801. ensureNewProposal(t, proposalCh, height, round)
  802. // Prevote our nil.
  803. ensurePrevote(t, voteCh, height, round)
  804. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  805. // Add prevotes from the remainder of the validators for nil.
  806. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  807. // We should now be locked on the same block but prevote nil.
  808. ensurePrecommit(t, voteCh, height, round)
  809. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, blockID.Hash)
  810. }
  811. // TestStateLock_POLDoesNotUnlock tests that a validator maintains its locked block
  812. // despite receiving +2/3 nil prevotes and nil precommits from other validators.
  813. // Tendermint used to 'unlock' its locked block when greater than 2/3 prevotes
  814. // for a nil block were seen. This behavior has been removed and this test ensures
  815. // that it has been completely removed.
  816. func TestStateLock_POLDoesNotUnlock(t *testing.T) {
  817. config := configSetup(t)
  818. logger := log.NewNopLogger()
  819. ctx, cancel := context.WithCancel(context.Background())
  820. defer cancel()
  821. /*
  822. All of the assertions in this test occur on the `cs1` validator.
  823. The test sends signed votes from the other validators to cs1 and
  824. cs1's state is then examined to verify that it now matches the expected
  825. state.
  826. */
  827. cs1, vss := makeState(ctx, t, config, logger, 4)
  828. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  829. height, round := cs1.Height, cs1.Round
  830. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  831. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  832. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  833. lockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryLock)
  834. pv1, err := cs1.privValidator.GetPubKey(context.Background())
  835. require.NoError(t, err)
  836. addr := pv1.Address()
  837. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  838. /*
  839. Round 0:
  840. Create a block, B
  841. Send a prevote for B from each of the validators to `cs1`.
  842. Send a precommit for B from one of the validtors to `cs1`.
  843. This ensures that cs1 will lock on B in this round.
  844. */
  845. t.Log("#### ONTO ROUND 0")
  846. // start round and wait for propose and prevote
  847. startTestRound(ctx, cs1, height, round)
  848. ensureNewRound(t, newRoundCh, height, round)
  849. ensureNewProposal(t, proposalCh, height, round)
  850. rs := cs1.GetRoundState()
  851. blockID := types.BlockID{
  852. Hash: rs.ProposalBlock.Hash(),
  853. PartSetHeader: rs.ProposalBlockParts.Header(),
  854. }
  855. ensurePrevoteMatch(t, voteCh, height, round, blockID.Hash)
  856. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  857. // the validator should have locked a block in this round.
  858. ensureLock(t, lockCh, height, round)
  859. ensurePrecommit(t, voteCh, height, round)
  860. // the proposed block should now be locked and our should be for this locked block.
  861. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  862. // Add precommits from the other validators.
  863. // We only issue 1/2 Precommits for the block in this round.
  864. // This ensures that the validator being tested does not commit the block.
  865. // We do not want the validator to commit the block because we want the test
  866. // test to proceeds to the next consensus round.
  867. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs4)
  868. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs3)
  869. // timeout to new round
  870. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  871. /*
  872. Round 1:
  873. Send a prevote for nil from >2/3 of the validators to `cs1`.
  874. Check that cs1 maintains its lock on B but precommits nil.
  875. Send a precommit for nil from >2/3 of the validators to `cs1`.
  876. */
  877. t.Log("#### ONTO ROUND 1")
  878. round++
  879. incrementRound(vs2, vs3, vs4)
  880. cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication())
  881. prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round)
  882. propBlockParts, err := propBlock.MakePartSet(types.BlockPartSizeBytes)
  883. require.NoError(t, err)
  884. require.NotEqual(t, propBlock.Hash(), blockID.Hash)
  885. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlockParts, "")
  886. require.NoError(t, err)
  887. ensureNewRound(t, newRoundCh, height, round)
  888. ensureNewProposal(t, proposalCh, height, round)
  889. // Prevote for nil since the proposed block does not match our locked block.
  890. ensurePrevoteMatch(t, voteCh, height, round, nil)
  891. // add >2/3 prevotes for nil from all other validators
  892. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  893. ensurePrecommit(t, voteCh, height, round)
  894. // verify that we haven't update our locked block since the first round
  895. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, blockID.Hash)
  896. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  897. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  898. /*
  899. Round 2:
  900. The validator cs1 saw >2/3 precommits for nil in the previous round.
  901. Send the validator >2/3 prevotes for nil and ensure that it did not
  902. unlock its block at the end of the previous round.
  903. */
  904. t.Log("#### ONTO ROUND 2")
  905. round++
  906. incrementRound(vs2, vs3, vs4)
  907. cs3 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication())
  908. prop, propBlock = decideProposal(ctx, t, cs3, vs3, vs3.Height, vs3.Round)
  909. propBlockParts, err = propBlock.MakePartSet(types.BlockPartSizeBytes)
  910. require.NoError(t, err)
  911. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlockParts, "")
  912. require.NoError(t, err)
  913. ensureNewRound(t, newRoundCh, height, round)
  914. ensureNewProposal(t, proposalCh, height, round)
  915. // Prevote for nil since the proposal does not match our locked block.
  916. ensurePrevote(t, voteCh, height, round)
  917. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  918. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  919. ensurePrecommit(t, voteCh, height, round)
  920. // verify that we haven't update our locked block since the first round
  921. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, blockID.Hash)
  922. }
  923. // TestStateLock_MissingProposalWhenPOLSeenDoesNotUnlock tests that observing
  924. // a two thirds majority for a block does not cause a validator to upate its lock on the
  925. // new block if a proposal was not seen for that block.
  926. func TestStateLock_MissingProposalWhenPOLSeenDoesNotUpdateLock(t *testing.T) {
  927. config := configSetup(t)
  928. logger := log.NewNopLogger()
  929. ctx, cancel := context.WithCancel(context.Background())
  930. defer cancel()
  931. cs1, vss := makeState(ctx, t, config, logger, 4)
  932. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  933. height, round := cs1.Height, cs1.Round
  934. partSize := types.BlockPartSizeBytes
  935. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  936. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  937. pv1, err := cs1.privValidator.GetPubKey(ctx)
  938. require.NoError(t, err)
  939. addr := pv1.Address()
  940. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  941. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  942. /*
  943. Round 0:
  944. cs1 creates a proposal for block B.
  945. Send a prevote for B from each of the validators to cs1.
  946. Send a precommit for nil from all of the validators to cs1.
  947. This ensures that cs1 will lock on B in this round but not precommit it.
  948. */
  949. t.Log("### Starting Round 0")
  950. startTestRound(ctx, cs1, height, round)
  951. ensureNewRound(t, newRoundCh, height, round)
  952. ensureNewProposal(t, proposalCh, height, round)
  953. rs := cs1.GetRoundState()
  954. firstBlockID := types.BlockID{
  955. Hash: rs.ProposalBlock.Hash(),
  956. PartSetHeader: rs.ProposalBlockParts.Header(),
  957. }
  958. ensurePrevote(t, voteCh, height, round) // prevote
  959. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), firstBlockID, vs2, vs3, vs4)
  960. ensurePrecommit(t, voteCh, height, round) // our precommit
  961. // the proposed block should now be locked and our precommit added
  962. validatePrecommit(ctx, t, cs1, round, round, vss[0], firstBlockID.Hash, firstBlockID.Hash)
  963. // add precommits from the rest
  964. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  965. // timeout to new round
  966. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  967. /*
  968. Round 1:
  969. Create a new block, D but do not send it to cs1.
  970. Send a prevote for D from each of the validators to cs1.
  971. Check that cs1 does not update its locked block to this missed block D.
  972. */
  973. t.Log("### Starting Round 1")
  974. incrementRound(vs2, vs3, vs4)
  975. round++
  976. cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication())
  977. require.NoError(t, err)
  978. prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round)
  979. require.NotNil(t, propBlock, "Failed to create proposal block with vs2")
  980. require.NotNil(t, prop, "Failed to create proposal block with vs2")
  981. partSet, err := propBlock.MakePartSet(partSize)
  982. require.NoError(t, err)
  983. secondBlockID := types.BlockID{
  984. Hash: propBlock.Hash(),
  985. PartSetHeader: partSet.Header(),
  986. }
  987. require.NotEqual(t, secondBlockID.Hash, firstBlockID.Hash)
  988. ensureNewRound(t, newRoundCh, height, round)
  989. // prevote for nil since the proposal was not seen.
  990. ensurePrevoteMatch(t, voteCh, height, round, nil)
  991. // now lets add prevotes from everyone else for the new block
  992. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), secondBlockID, vs2, vs3, vs4)
  993. ensurePrecommit(t, voteCh, height, round)
  994. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, firstBlockID.Hash)
  995. }
  996. // TestStateLock_DoesNotLockOnOldProposal tests that observing
  997. // a two thirds majority for a block does not cause a validator to lock on the
  998. // block if a proposal was not seen for that block in the current round, but
  999. // was seen in a previous round.
  1000. func TestStateLock_DoesNotLockOnOldProposal(t *testing.T) {
  1001. ctx, cancel := context.WithCancel(context.Background())
  1002. defer cancel()
  1003. config := configSetup(t)
  1004. logger := log.NewNopLogger()
  1005. cs1, vss := makeState(ctx, t, config, logger, 4)
  1006. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1007. height, round := cs1.Height, cs1.Round
  1008. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1009. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1010. pv1, err := cs1.privValidator.GetPubKey(context.Background())
  1011. require.NoError(t, err)
  1012. addr := pv1.Address()
  1013. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1014. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1015. /*
  1016. Round 0:
  1017. cs1 creates a proposal for block B.
  1018. Send a prevote for nil from each of the validators to cs1.
  1019. Send a precommit for nil from all of the validators to cs1.
  1020. This ensures that cs1 will not lock on B.
  1021. */
  1022. t.Log("### Starting Round 0")
  1023. startTestRound(ctx, cs1, height, round)
  1024. ensureNewRound(t, newRoundCh, height, round)
  1025. ensureNewProposal(t, proposalCh, height, round)
  1026. rs := cs1.GetRoundState()
  1027. firstBlockID := types.BlockID{
  1028. Hash: rs.ProposalBlock.Hash(),
  1029. PartSetHeader: rs.ProposalBlockParts.Header(),
  1030. }
  1031. ensurePrevote(t, voteCh, height, round)
  1032. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1033. // The proposed block should not have been locked.
  1034. ensurePrecommit(t, voteCh, height, round)
  1035. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1036. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1037. incrementRound(vs2, vs3, vs4)
  1038. // timeout to new round
  1039. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1040. /*
  1041. Round 1:
  1042. No proposal new proposal is created.
  1043. Send a prevote for B, the block from round 0, from each of the validators to cs1.
  1044. Send a precommit for nil from all of the validators to cs1.
  1045. cs1 saw a POL for the block it saw in round 0. We ensure that it does not
  1046. lock on this block, since it did not see a proposal for it in this round.
  1047. */
  1048. t.Log("### Starting Round 1")
  1049. round++
  1050. ensureNewRound(t, newRoundCh, height, round)
  1051. ensurePrevote(t, voteCh, height, round)
  1052. validatePrevote(ctx, t, cs1, round, vss[0], nil) // All validators prevote for the old block.
  1053. // All validators prevote for the old block.
  1054. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), firstBlockID, vs2, vs3, vs4)
  1055. // Make sure that cs1 did not lock on the block since it did not receive a proposal for it.
  1056. ensurePrecommit(t, voteCh, height, round)
  1057. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1058. }
  1059. // 4 vals
  1060. // a polka at round 1 but we miss it
  1061. // then a polka at round 2 that we lock on
  1062. // then we see the polka from round 1 but shouldn't unlock
  1063. func TestStateLock_POLSafety1(t *testing.T) {
  1064. config := configSetup(t)
  1065. logger := log.NewNopLogger()
  1066. ctx, cancel := context.WithCancel(context.Background())
  1067. defer cancel()
  1068. cs1, vss := makeState(ctx, t, config, logger, 4)
  1069. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1070. height, round := cs1.Height, cs1.Round
  1071. partSize := types.BlockPartSizeBytes
  1072. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1073. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1074. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1075. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1076. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1077. require.NoError(t, err)
  1078. addr := pv1.Address()
  1079. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1080. // start round and wait for propose and prevote
  1081. startTestRound(ctx, cs1, cs1.Height, round)
  1082. ensureNewRound(t, newRoundCh, height, round)
  1083. ensureNewProposal(t, proposalCh, height, round)
  1084. rs := cs1.GetRoundState()
  1085. propBlock := rs.ProposalBlock
  1086. ensurePrevoteMatch(t, voteCh, height, round, propBlock.Hash())
  1087. partSet, err := propBlock.MakePartSet(partSize)
  1088. require.NoError(t, err)
  1089. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: partSet.Header()}
  1090. // the others sign a polka but we don't see it
  1091. prevotes := signVotes(ctx, t, tmproto.PrevoteType, config.ChainID(),
  1092. blockID,
  1093. vs2, vs3, vs4)
  1094. // we do see them precommit nil
  1095. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1096. // cs1 precommit nil
  1097. ensurePrecommit(t, voteCh, height, round)
  1098. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1099. t.Log("### ONTO ROUND 1")
  1100. incrementRound(vs2, vs3, vs4)
  1101. round++ // moving to the next round
  1102. cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication())
  1103. prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round)
  1104. propBlockParts, err := propBlock.MakePartSet(partSize)
  1105. require.NoError(t, err)
  1106. r2BlockID := types.BlockID{
  1107. Hash: propBlock.Hash(),
  1108. PartSetHeader: propBlockParts.Header(),
  1109. }
  1110. ensureNewRound(t, newRoundCh, height, round)
  1111. //XXX: this isnt guaranteed to get there before the timeoutPropose ...
  1112. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlockParts, "some peer")
  1113. require.NoError(t, err)
  1114. /*Round2
  1115. // we timeout and prevote our lock
  1116. // a polka happened but we didn't see it!
  1117. */
  1118. ensureNewProposal(t, proposalCh, height, round)
  1119. rs = cs1.GetRoundState()
  1120. require.Nil(t, rs.LockedBlock, "we should not be locked!")
  1121. t.Logf("new prop hash %v", fmt.Sprintf("%X", propBlock.Hash()))
  1122. // go to prevote, prevote for proposal block
  1123. ensurePrevoteMatch(t, voteCh, height, round, r2BlockID.Hash)
  1124. // now we see the others prevote for it, so we should lock on it
  1125. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), r2BlockID, vs2, vs3, vs4)
  1126. ensurePrecommit(t, voteCh, height, round)
  1127. // we should have precommitted
  1128. validatePrecommit(ctx, t, cs1, round, round, vss[0], r2BlockID.Hash, r2BlockID.Hash)
  1129. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1130. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1131. incrementRound(vs2, vs3, vs4)
  1132. round++ // moving to the next round
  1133. ensureNewRound(t, newRoundCh, height, round)
  1134. t.Log("### ONTO ROUND 2")
  1135. /*Round3
  1136. we see the polka from round 1 but we shouldn't unlock!
  1137. */
  1138. // timeout of propose
  1139. ensureNewTimeout(t, timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1140. // finish prevote
  1141. ensurePrevoteMatch(t, voteCh, height, round, nil)
  1142. newStepCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRoundStep)
  1143. // before prevotes from the previous round are added
  1144. // add prevotes from the earlier round
  1145. addVotes(cs1, prevotes...)
  1146. ensureNoNewRoundStep(t, newStepCh)
  1147. }
  1148. // 4 vals.
  1149. // polka P0 at R0, P1 at R1, and P2 at R2,
  1150. // we lock on P0 at R0, don't see P1, and unlock using P2 at R2
  1151. // then we should make sure we don't lock using P1
  1152. // What we want:
  1153. // dont see P0, lock on P1 at R1, dont unlock using P0 at R2
  1154. func TestStateLock_POLSafety2(t *testing.T) {
  1155. config := configSetup(t)
  1156. logger := log.NewNopLogger()
  1157. ctx, cancel := context.WithCancel(context.Background())
  1158. defer cancel()
  1159. cs1, vss := makeState(ctx, t, config, logger, 4)
  1160. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1161. height, round := cs1.Height, cs1.Round
  1162. partSize := types.BlockPartSizeBytes
  1163. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1164. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1165. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1166. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1167. require.NoError(t, err)
  1168. addr := pv1.Address()
  1169. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1170. // the block for R0: gets polkad but we miss it
  1171. // (even though we signed it, shhh)
  1172. _, propBlock0 := decideProposal(ctx, t, cs1, vss[0], height, round)
  1173. propBlockHash0 := propBlock0.Hash()
  1174. propBlockParts0, err := propBlock0.MakePartSet(partSize)
  1175. require.NoError(t, err)
  1176. propBlockID0 := types.BlockID{Hash: propBlockHash0, PartSetHeader: propBlockParts0.Header()}
  1177. // the others sign a polka but we don't see it
  1178. prevotes := signVotes(ctx, t, tmproto.PrevoteType, config.ChainID(), propBlockID0, vs2, vs3, vs4)
  1179. // the block for round 1
  1180. prop1, propBlock1 := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round+1)
  1181. propBlockParts1, err := propBlock1.MakePartSet(partSize)
  1182. require.NoError(t, err)
  1183. propBlockID1 := types.BlockID{Hash: propBlock1.Hash(), PartSetHeader: propBlockParts1.Header()}
  1184. incrementRound(vs2, vs3, vs4)
  1185. round++ // moving to the next round
  1186. t.Log("### ONTO Round 1")
  1187. // jump in at round 1
  1188. startTestRound(ctx, cs1, height, round)
  1189. ensureNewRound(t, newRoundCh, height, round)
  1190. err = cs1.SetProposalAndBlock(ctx, prop1, propBlock1, propBlockParts1, "some peer")
  1191. require.NoError(t, err)
  1192. ensureNewProposal(t, proposalCh, height, round)
  1193. ensurePrevoteMatch(t, voteCh, height, round, propBlockID1.Hash)
  1194. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), propBlockID1, vs2, vs3, vs4)
  1195. ensurePrecommit(t, voteCh, height, round)
  1196. // the proposed block should now be locked and our precommit added
  1197. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlockID1.Hash, propBlockID1.Hash)
  1198. // add precommits from the rest
  1199. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs4)
  1200. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), propBlockID1, vs3)
  1201. incrementRound(vs2, vs3, vs4)
  1202. // timeout of precommit wait to new round
  1203. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1204. round++ // moving to the next round
  1205. // in round 2 we see the polkad block from round 0
  1206. newProp := types.NewProposal(height, round, 0, propBlockID0, propBlock0.Header.Time)
  1207. p := newProp.ToProto()
  1208. err = vs3.SignProposal(ctx, config.ChainID(), p)
  1209. require.NoError(t, err)
  1210. newProp.Signature = p.Signature
  1211. err = cs1.SetProposalAndBlock(ctx, newProp, propBlock0, propBlockParts0, "some peer")
  1212. require.NoError(t, err)
  1213. // Add the pol votes
  1214. addVotes(cs1, prevotes...)
  1215. ensureNewRound(t, newRoundCh, height, round)
  1216. t.Log("### ONTO Round 2")
  1217. /*Round2
  1218. // now we see the polka from round 1, but we shouldnt unlock
  1219. */
  1220. ensureNewProposal(t, proposalCh, height, round)
  1221. ensurePrevote(t, voteCh, height, round)
  1222. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  1223. }
  1224. // TestState_PrevotePOLFromPreviousRound tests that a validator will prevote
  1225. // for a block if it is locked on a different block but saw a POL for the block
  1226. // it is not locked on in a previous round.
  1227. func TestState_PrevotePOLFromPreviousRound(t *testing.T) {
  1228. ctx, cancel := context.WithCancel(context.Background())
  1229. defer cancel()
  1230. config := configSetup(t)
  1231. logger := log.NewNopLogger()
  1232. cs1, vss := makeState(ctx, t, config, logger, 4)
  1233. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1234. height, round := cs1.Height, cs1.Round
  1235. partSize := types.BlockPartSizeBytes
  1236. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1237. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1238. pv1, err := cs1.privValidator.GetPubKey(context.Background())
  1239. require.NoError(t, err)
  1240. addr := pv1.Address()
  1241. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1242. lockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryLock)
  1243. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1244. /*
  1245. Round 0:
  1246. cs1 creates a proposal for block B.
  1247. Send a prevote for B from each of the validators to cs1.
  1248. Send a precommit for nil from all of the validators to cs1.
  1249. This ensures that cs1 will lock on B in this round but not precommit it.
  1250. */
  1251. t.Log("### Starting Round 0")
  1252. startTestRound(ctx, cs1, height, round)
  1253. ensureNewRound(t, newRoundCh, height, round)
  1254. ensureNewProposal(t, proposalCh, height, round)
  1255. rs := cs1.GetRoundState()
  1256. r0BlockID := types.BlockID{
  1257. Hash: rs.ProposalBlock.Hash(),
  1258. PartSetHeader: rs.ProposalBlockParts.Header(),
  1259. }
  1260. ensurePrevote(t, voteCh, height, round)
  1261. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), r0BlockID, vs2, vs3, vs4)
  1262. // check that the validator generates a Lock event.
  1263. ensureLock(t, lockCh, height, round)
  1264. // the proposed block should now be locked and our precommit added.
  1265. ensurePrecommit(t, voteCh, height, round)
  1266. validatePrecommit(ctx, t, cs1, round, round, vss[0], r0BlockID.Hash, r0BlockID.Hash)
  1267. // add precommits from the rest of the validators.
  1268. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1269. // timeout to new round.
  1270. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1271. /*
  1272. Round 1:
  1273. Create a block, D but do not send a proposal for it to cs1.
  1274. Send a prevote for D from each of the validators to cs1 so that cs1 sees a POL.
  1275. Send a precommit for nil from all of the validtors to cs1.
  1276. cs1 has now seen greater than 2/3 of the voting power prevote D in this round
  1277. but cs1 did not see the proposal for D in this round so it will not prevote or precommit it.
  1278. */
  1279. t.Log("### Starting Round 1")
  1280. incrementRound(vs2, vs3, vs4)
  1281. round++
  1282. // Generate a new proposal block.
  1283. cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication())
  1284. cs2.ValidRound = 1
  1285. propR1, propBlockR1 := decideProposal(ctx, t, cs2, vs2, vs2.Height, round)
  1286. t.Log(propR1.POLRound)
  1287. propBlockR1Parts, err := propBlockR1.MakePartSet(partSize)
  1288. require.NoError(t, err)
  1289. r1BlockID := types.BlockID{
  1290. Hash: propBlockR1.Hash(),
  1291. PartSetHeader: propBlockR1Parts.Header(),
  1292. }
  1293. require.NotEqual(t, r1BlockID.Hash, r0BlockID.Hash)
  1294. ensureNewRound(t, newRoundCh, height, round)
  1295. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), r1BlockID, vs2, vs3, vs4)
  1296. ensurePrevote(t, voteCh, height, round)
  1297. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  1298. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1299. ensurePrecommit(t, voteCh, height, round)
  1300. // timeout to new round.
  1301. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1302. /*
  1303. Create a new proposal for D, the same block from Round 1.
  1304. cs1 already saw greater than 2/3 of the voting power on the network vote for
  1305. D in a previous round, so it should prevote D once it receives a proposal for it.
  1306. cs1 does not need to receive prevotes from other validators before the proposal
  1307. in this round. It will still prevote the block.
  1308. Send cs1 prevotes for nil and check that it still prevotes its locked block
  1309. and not the block that it prevoted.
  1310. */
  1311. t.Log("### Starting Round 2")
  1312. incrementRound(vs2, vs3, vs4)
  1313. round++
  1314. propR2 := types.NewProposal(height, round, 1, r1BlockID, propBlockR1.Header.Time)
  1315. p := propR2.ToProto()
  1316. err = vs3.SignProposal(ctx, cs1.state.ChainID, p)
  1317. require.NoError(t, err)
  1318. propR2.Signature = p.Signature
  1319. // cs1 receives a proposal for D, the block that received a POL in round 1.
  1320. err = cs1.SetProposalAndBlock(ctx, propR2, propBlockR1, propBlockR1Parts, "")
  1321. require.NoError(t, err)
  1322. ensureNewRound(t, newRoundCh, height, round)
  1323. ensureNewProposal(t, proposalCh, height, round)
  1324. // We should now prevote this block, despite being locked on the block from
  1325. // round 0.
  1326. ensurePrevote(t, voteCh, height, round)
  1327. validatePrevote(ctx, t, cs1, round, vss[0], r1BlockID.Hash)
  1328. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1329. // cs1 did not receive a POL within this round, so it should remain locked
  1330. // on the block from round 0.
  1331. ensurePrecommit(t, voteCh, height, round)
  1332. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, r0BlockID.Hash)
  1333. }
  1334. // 4 vals.
  1335. // polka P0 at R0 for B0. We lock B0 on P0 at R0.
  1336. // What we want:
  1337. // P0 proposes B0 at R3.
  1338. func TestProposeValidBlock(t *testing.T) {
  1339. cfg := configSetup(t)
  1340. logger := log.NewNopLogger()
  1341. ctx, cancel := context.WithCancel(context.Background())
  1342. defer cancel()
  1343. cs1, vss := makeState(ctx, t, cfg, logger, 4)
  1344. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1345. height, round := cs1.Height, cs1.Round
  1346. partSize := types.BlockPartSizeBytes
  1347. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1348. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1349. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1350. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1351. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1352. require.NoError(t, err)
  1353. addr := pv1.Address()
  1354. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1355. // start round and wait for propose and prevote
  1356. startTestRound(ctx, cs1, cs1.Height, round)
  1357. ensureNewRound(t, newRoundCh, height, round)
  1358. ensureNewProposal(t, proposalCh, height, round)
  1359. rs := cs1.GetRoundState()
  1360. propBlock := rs.ProposalBlock
  1361. partSet, err := propBlock.MakePartSet(partSize)
  1362. require.NoError(t, err)
  1363. blockID := types.BlockID{
  1364. Hash: propBlock.Hash(),
  1365. PartSetHeader: partSet.Header(),
  1366. }
  1367. ensurePrevoteMatch(t, voteCh, height, round, blockID.Hash)
  1368. // the others sign a polka
  1369. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, cfg.ChainID(), blockID, vs2, vs3, vs4)
  1370. ensurePrecommit(t, voteCh, height, round)
  1371. // we should have precommitted the proposed block in this round.
  1372. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  1373. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, cfg.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1374. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1375. incrementRound(vs2, vs3, vs4)
  1376. round++ // moving to the next round
  1377. ensureNewRound(t, newRoundCh, height, round)
  1378. t.Log("### ONTO ROUND 1")
  1379. // timeout of propose
  1380. ensureNewTimeout(t, timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1381. // We did not see a valid proposal within this round, so prevote nil.
  1382. ensurePrevoteMatch(t, voteCh, height, round, nil)
  1383. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, cfg.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1384. ensurePrecommit(t, voteCh, height, round)
  1385. // we should have precommitted nil during this round because we received
  1386. // >2/3 precommits for nil from the other validators.
  1387. validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, blockID.Hash)
  1388. incrementRound(vs2, vs3, vs4)
  1389. incrementRound(vs2, vs3, vs4)
  1390. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, cfg.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1391. round += 2 // increment by multiple rounds
  1392. ensureNewRound(t, newRoundCh, height, round)
  1393. t.Log("### ONTO ROUND 3")
  1394. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1395. round++ // moving to the next round
  1396. ensureNewRound(t, newRoundCh, height, round)
  1397. ensureNewProposal(t, proposalCh, height, round)
  1398. rs = cs1.GetRoundState()
  1399. assert.True(t, bytes.Equal(rs.ProposalBlock.Hash(), blockID.Hash))
  1400. assert.True(t, bytes.Equal(rs.ProposalBlock.Hash(), rs.ValidBlock.Hash()))
  1401. assert.True(t, rs.Proposal.POLRound == rs.ValidRound)
  1402. assert.True(t, bytes.Equal(rs.Proposal.BlockID.Hash, rs.ValidBlock.Hash()))
  1403. }
  1404. // What we want:
  1405. // P0 miss to lock B but set valid block to B after receiving delayed prevote.
  1406. func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
  1407. config := configSetup(t)
  1408. logger := log.NewNopLogger()
  1409. ctx, cancel := context.WithCancel(context.Background())
  1410. defer cancel()
  1411. cs1, vss := makeState(ctx, t, config, logger, 4)
  1412. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1413. height, round := cs1.Height, cs1.Round
  1414. partSize := types.BlockPartSizeBytes
  1415. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1416. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1417. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1418. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1419. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1420. require.NoError(t, err)
  1421. addr := pv1.Address()
  1422. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1423. // start round and wait for propose and prevote
  1424. startTestRound(ctx, cs1, cs1.Height, round)
  1425. ensureNewRound(t, newRoundCh, height, round)
  1426. ensureNewProposal(t, proposalCh, height, round)
  1427. rs := cs1.GetRoundState()
  1428. propBlock := rs.ProposalBlock
  1429. partSet, err := propBlock.MakePartSet(partSize)
  1430. require.NoError(t, err)
  1431. blockID := types.BlockID{
  1432. Hash: propBlock.Hash(),
  1433. PartSetHeader: partSet.Header(),
  1434. }
  1435. ensurePrevoteMatch(t, voteCh, height, round, blockID.Hash)
  1436. // vs2 send prevote for propBlock
  1437. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2)
  1438. // vs3 send prevote nil
  1439. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs3)
  1440. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  1441. ensurePrecommit(t, voteCh, height, round)
  1442. // we should have precommitted
  1443. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1444. rs = cs1.GetRoundState()
  1445. assert.True(t, rs.ValidBlock == nil)
  1446. assert.True(t, rs.ValidBlockParts == nil)
  1447. assert.True(t, rs.ValidRound == -1)
  1448. // vs2 send (delayed) prevote for propBlock
  1449. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs4)
  1450. ensureNewValidBlock(t, validBlockCh, height, round)
  1451. rs = cs1.GetRoundState()
  1452. assert.True(t, bytes.Equal(rs.ValidBlock.Hash(), blockID.Hash))
  1453. assert.True(t, rs.ValidBlockParts.Header().Equals(blockID.PartSetHeader))
  1454. assert.True(t, rs.ValidRound == round)
  1455. }
  1456. // What we want:
  1457. // P0 miss to lock B as Proposal Block is missing, but set valid block to B after
  1458. // receiving delayed Block Proposal.
  1459. func TestSetValidBlockOnDelayedProposal(t *testing.T) {
  1460. config := configSetup(t)
  1461. logger := log.NewNopLogger()
  1462. ctx, cancel := context.WithCancel(context.Background())
  1463. defer cancel()
  1464. cs1, vss := makeState(ctx, t, config, logger, 4)
  1465. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1466. height, round := cs1.Height, cs1.Round
  1467. partSize := types.BlockPartSizeBytes
  1468. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1469. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1470. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1471. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1472. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1473. require.NoError(t, err)
  1474. addr := pv1.Address()
  1475. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1476. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1477. round++ // move to round in which P0 is not proposer
  1478. incrementRound(vs2, vs3, vs4)
  1479. startTestRound(ctx, cs1, cs1.Height, round)
  1480. ensureNewRound(t, newRoundCh, height, round)
  1481. ensureNewTimeout(t, timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1482. ensurePrevoteMatch(t, voteCh, height, round, nil)
  1483. prop, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round+1)
  1484. partSet, err := propBlock.MakePartSet(partSize)
  1485. require.NoError(t, err)
  1486. blockID := types.BlockID{
  1487. Hash: propBlock.Hash(),
  1488. PartSetHeader: partSet.Header(),
  1489. }
  1490. // vs2, vs3 and vs4 send prevote for propBlock
  1491. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  1492. ensureNewValidBlock(t, validBlockCh, height, round)
  1493. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
  1494. ensurePrecommit(t, voteCh, height, round)
  1495. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1496. partSet, err = propBlock.MakePartSet(partSize)
  1497. require.NoError(t, err)
  1498. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, partSet, "some peer")
  1499. require.NoError(t, err)
  1500. ensureNewProposal(t, proposalCh, height, round)
  1501. rs := cs1.GetRoundState()
  1502. assert.True(t, bytes.Equal(rs.ValidBlock.Hash(), blockID.Hash))
  1503. assert.True(t, rs.ValidBlockParts.Header().Equals(blockID.PartSetHeader))
  1504. assert.True(t, rs.ValidRound == round)
  1505. }
  1506. // 4 vals, 3 Nil Precommits at P0
  1507. // What we want:
  1508. // P0 waits for timeoutPrecommit before starting next round
  1509. func TestWaitingTimeoutOnNilPolka(t *testing.T) {
  1510. ctx, cancel := context.WithCancel(context.Background())
  1511. defer cancel()
  1512. config := configSetup(t)
  1513. logger := log.NewNopLogger()
  1514. cs1, vss := makeState(ctx, t, config, logger, 4)
  1515. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1516. height, round := cs1.Height, cs1.Round
  1517. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1518. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1519. // start round
  1520. startTestRound(ctx, cs1, height, round)
  1521. ensureNewRound(t, newRoundCh, height, round)
  1522. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1523. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1524. ensureNewRound(t, newRoundCh, height, round+1)
  1525. }
  1526. // 4 vals, 3 Prevotes for nil from the higher round.
  1527. // What we want:
  1528. // P0 waits for timeoutPropose in the next round before entering prevote
  1529. func TestWaitingTimeoutProposeOnNewRound(t *testing.T) {
  1530. config := configSetup(t)
  1531. logger := log.NewNopLogger()
  1532. ctx, cancel := context.WithCancel(context.Background())
  1533. defer cancel()
  1534. cs1, vss := makeState(ctx, t, config, logger, 4)
  1535. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1536. height, round := cs1.Height, cs1.Round
  1537. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1538. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1539. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1540. require.NoError(t, err)
  1541. addr := pv1.Address()
  1542. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1543. // start round
  1544. startTestRound(ctx, cs1, height, round)
  1545. ensureNewRound(t, newRoundCh, height, round)
  1546. ensurePrevote(t, voteCh, height, round)
  1547. incrementRound(vss[1:]...)
  1548. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1549. round++ // moving to the next round
  1550. ensureNewRound(t, newRoundCh, height, round)
  1551. rs := cs1.GetRoundState()
  1552. assert.True(t, rs.Step == cstypes.RoundStepPropose) // P0 does not prevote before timeoutPropose expires
  1553. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1554. ensurePrevoteMatch(t, voteCh, height, round, nil)
  1555. }
  1556. // 4 vals, 3 Precommits for nil from the higher round.
  1557. // What we want:
  1558. // P0 jump to higher round, precommit and start precommit wait
  1559. func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) {
  1560. config := configSetup(t)
  1561. logger := log.NewNopLogger()
  1562. ctx, cancel := context.WithCancel(context.Background())
  1563. defer cancel()
  1564. cs1, vss := makeState(ctx, t, config, logger, 4)
  1565. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1566. height, round := cs1.Height, cs1.Round
  1567. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1568. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1569. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1570. require.NoError(t, err)
  1571. addr := pv1.Address()
  1572. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1573. // start round
  1574. startTestRound(ctx, cs1, height, round)
  1575. ensureNewRound(t, newRoundCh, height, round)
  1576. ensurePrevote(t, voteCh, height, round)
  1577. incrementRound(vss[1:]...)
  1578. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1579. round++ // moving to the next round
  1580. ensureNewRound(t, newRoundCh, height, round)
  1581. ensurePrecommit(t, voteCh, height, round)
  1582. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1583. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1584. round++ // moving to the next round
  1585. ensureNewRound(t, newRoundCh, height, round)
  1586. }
  1587. // 4 vals, 3 Prevotes for nil in the current round.
  1588. // What we want:
  1589. // P0 wait for timeoutPropose to expire before sending prevote.
  1590. func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) {
  1591. config := configSetup(t)
  1592. logger := log.NewNopLogger()
  1593. ctx, cancel := context.WithCancel(context.Background())
  1594. defer cancel()
  1595. cs1, vss := makeState(ctx, t, config, logger, 4)
  1596. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1597. height, round := cs1.Height, int32(1)
  1598. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1599. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1600. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1601. require.NoError(t, err)
  1602. addr := pv1.Address()
  1603. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1604. // start round in which PO is not proposer
  1605. startTestRound(ctx, cs1, height, round)
  1606. ensureNewRound(t, newRoundCh, height, round)
  1607. incrementRound(vss[1:]...)
  1608. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1609. ensureNewTimeout(t, timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1610. ensurePrevoteMatch(t, voteCh, height, round, nil)
  1611. }
  1612. // What we want:
  1613. // P0 emit NewValidBlock event upon receiving 2/3+ Precommit for B but hasn't received block B yet
  1614. func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) {
  1615. config := configSetup(t)
  1616. logger := log.NewNopLogger()
  1617. ctx, cancel := context.WithCancel(context.Background())
  1618. defer cancel()
  1619. cs1, vss := makeState(ctx, t, config, logger, 4)
  1620. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1621. height, round := cs1.Height, int32(1)
  1622. incrementRound(vs2, vs3, vs4)
  1623. partSize := types.BlockPartSizeBytes
  1624. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1625. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1626. _, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round)
  1627. partSet, err := propBlock.MakePartSet(partSize)
  1628. require.NoError(t, err)
  1629. blockID := types.BlockID{
  1630. Hash: propBlock.Hash(),
  1631. PartSetHeader: partSet.Header(),
  1632. }
  1633. // start round in which PO is not proposer
  1634. startTestRound(ctx, cs1, height, round)
  1635. ensureNewRound(t, newRoundCh, height, round)
  1636. // vs2, vs3 and vs4 send precommit for propBlock
  1637. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs2, vs3, vs4)
  1638. ensureNewValidBlock(t, validBlockCh, height, round)
  1639. rs := cs1.GetRoundState()
  1640. assert.True(t, rs.Step == cstypes.RoundStepCommit)
  1641. assert.True(t, rs.ProposalBlock == nil)
  1642. assert.True(t, rs.ProposalBlockParts.Header().Equals(blockID.PartSetHeader))
  1643. }
  1644. // What we want:
  1645. // P0 receives 2/3+ Precommit for B for round 0, while being in round 1. It emits NewValidBlock event.
  1646. // After receiving block, it executes block and moves to the next height.
  1647. func TestCommitFromPreviousRound(t *testing.T) {
  1648. config := configSetup(t)
  1649. logger := log.NewNopLogger()
  1650. ctx, cancel := context.WithCancel(context.Background())
  1651. defer cancel()
  1652. cs1, vss := makeState(ctx, t, config, logger, 4)
  1653. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1654. height, round := cs1.Height, int32(1)
  1655. partSize := types.BlockPartSizeBytes
  1656. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1657. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1658. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1659. prop, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round)
  1660. partSet, err := propBlock.MakePartSet(partSize)
  1661. require.NoError(t, err)
  1662. blockID := types.BlockID{
  1663. Hash: propBlock.Hash(),
  1664. PartSetHeader: partSet.Header(),
  1665. }
  1666. // start round in which PO is not proposer
  1667. startTestRound(ctx, cs1, height, round)
  1668. ensureNewRound(t, newRoundCh, height, round)
  1669. // vs2, vs3 and vs4 send precommit for propBlock for the previous round
  1670. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs2, vs3, vs4)
  1671. ensureNewValidBlock(t, validBlockCh, height, round)
  1672. rs := cs1.GetRoundState()
  1673. assert.True(t, rs.Step == cstypes.RoundStepCommit)
  1674. assert.True(t, rs.CommitRound == vs2.Round)
  1675. assert.True(t, rs.ProposalBlock == nil)
  1676. assert.True(t, rs.ProposalBlockParts.Header().Equals(blockID.PartSetHeader))
  1677. partSet, err = propBlock.MakePartSet(partSize)
  1678. require.NoError(t, err)
  1679. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, partSet, "some peer")
  1680. require.NoError(t, err)
  1681. ensureNewProposal(t, proposalCh, height, round)
  1682. ensureNewRound(t, newRoundCh, height+1, 0)
  1683. }
  1684. type fakeTxNotifier struct {
  1685. ch chan struct{}
  1686. }
  1687. func (n *fakeTxNotifier) TxsAvailable() <-chan struct{} {
  1688. return n.ch
  1689. }
  1690. func (n *fakeTxNotifier) Notify() {
  1691. n.ch <- struct{}{}
  1692. }
  1693. // 2 vals precommit votes for a block but node times out waiting for the third. Move to next round
  1694. // and third precommit arrives which leads to the commit of that header and the correct
  1695. // start of the next round
  1696. func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) {
  1697. config := configSetup(t)
  1698. logger := log.NewNopLogger()
  1699. ctx, cancel := context.WithCancel(context.Background())
  1700. defer cancel()
  1701. config.Consensus.SkipTimeoutCommit = false
  1702. cs1, vss := makeState(ctx, t, config, logger, 4)
  1703. cs1.txNotifier = &fakeTxNotifier{ch: make(chan struct{})}
  1704. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1705. height, round := cs1.Height, cs1.Round
  1706. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1707. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1708. precommitTimeoutCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1709. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1710. newBlockHeader := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlockHeader)
  1711. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1712. require.NoError(t, err)
  1713. addr := pv1.Address()
  1714. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1715. // start round and wait for propose and prevote
  1716. startTestRound(ctx, cs1, height, round)
  1717. ensureNewRound(t, newRoundCh, height, round)
  1718. ensureNewProposal(t, proposalCh, height, round)
  1719. rs := cs1.GetRoundState()
  1720. blockID := types.BlockID{
  1721. Hash: rs.ProposalBlock.Hash(),
  1722. PartSetHeader: rs.ProposalBlockParts.Header(),
  1723. }
  1724. ensurePrevoteMatch(t, voteCh, height, round, blockID.Hash)
  1725. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  1726. ensurePrecommit(t, voteCh, height, round)
  1727. // the proposed block should now be locked and our precommit added
  1728. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  1729. // add precommits
  1730. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2)
  1731. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs3)
  1732. // wait till timeout occurs
  1733. ensureNewTimeout(t, precommitTimeoutCh, height, round, cs1.config.TimeoutPrecommit.Nanoseconds())
  1734. ensureNewRound(t, newRoundCh, height, round+1)
  1735. // majority is now reached
  1736. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs4)
  1737. ensureNewBlockHeader(t, newBlockHeader, height, blockID.Hash)
  1738. cs1.txNotifier.(*fakeTxNotifier).Notify()
  1739. ensureNewTimeout(t, timeoutProposeCh, height+1, round, cs1.config.Propose(round).Nanoseconds())
  1740. rs = cs1.GetRoundState()
  1741. assert.False(
  1742. t,
  1743. rs.TriggeredTimeoutPrecommit,
  1744. "triggeredTimeoutPrecommit should be false at the beginning of each round")
  1745. }
  1746. func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) {
  1747. config := configSetup(t)
  1748. logger := log.NewNopLogger()
  1749. ctx, cancel := context.WithCancel(context.Background())
  1750. defer cancel()
  1751. config.Consensus.SkipTimeoutCommit = false
  1752. cs1, vss := makeState(ctx, t, config, logger, 4)
  1753. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1754. height, round := cs1.Height, cs1.Round
  1755. partSize := types.BlockPartSizeBytes
  1756. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1757. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1758. newBlockHeader := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlockHeader)
  1759. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1760. require.NoError(t, err)
  1761. addr := pv1.Address()
  1762. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1763. // start round and wait for propose and prevote
  1764. startTestRound(ctx, cs1, height, round)
  1765. ensureNewRound(t, newRoundCh, height, round)
  1766. ensureNewProposal(t, proposalCh, height, round)
  1767. rs := cs1.GetRoundState()
  1768. blockID := types.BlockID{
  1769. Hash: rs.ProposalBlock.Hash(),
  1770. PartSetHeader: rs.ProposalBlockParts.Header(),
  1771. }
  1772. ensurePrevoteMatch(t, voteCh, height, round, blockID.Hash)
  1773. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  1774. ensurePrecommit(t, voteCh, height, round)
  1775. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  1776. // add precommits
  1777. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2)
  1778. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs3)
  1779. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs4)
  1780. ensureNewBlockHeader(t, newBlockHeader, height, blockID.Hash)
  1781. prop, propBlock := decideProposal(ctx, t, cs1, vs2, height+1, 0)
  1782. propBlockParts, err := propBlock.MakePartSet(partSize)
  1783. require.NoError(t, err)
  1784. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlockParts, "some peer")
  1785. require.NoError(t, err)
  1786. ensureNewProposal(t, proposalCh, height+1, 0)
  1787. rs = cs1.GetRoundState()
  1788. assert.False(
  1789. t,
  1790. rs.TriggeredTimeoutPrecommit,
  1791. "triggeredTimeoutPrecommit should be false at the beginning of each height")
  1792. }
  1793. //------------------------------------------------------------------------------------------
  1794. // CatchupSuite
  1795. //------------------------------------------------------------------------------------------
  1796. // HaltSuite
  1797. // 4 vals.
  1798. // we receive a final precommit after going into next round, but others might have gone to commit already!
  1799. func TestStateHalt1(t *testing.T) {
  1800. cfg := configSetup(t)
  1801. logger := log.NewNopLogger()
  1802. ctx, cancel := context.WithCancel(context.Background())
  1803. defer cancel()
  1804. cs1, vss := makeState(ctx, t, cfg, logger, 4)
  1805. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1806. height, round := cs1.Height, cs1.Round
  1807. partSize := types.BlockPartSizeBytes
  1808. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1809. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1810. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1811. newBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlock)
  1812. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1813. require.NoError(t, err)
  1814. addr := pv1.Address()
  1815. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1816. // start round and wait for propose and prevote
  1817. startTestRound(ctx, cs1, height, round)
  1818. ensureNewRound(t, newRoundCh, height, round)
  1819. ensureNewProposal(t, proposalCh, height, round)
  1820. rs := cs1.GetRoundState()
  1821. propBlock := rs.ProposalBlock
  1822. partSet, err := propBlock.MakePartSet(partSize)
  1823. require.NoError(t, err)
  1824. blockID := types.BlockID{
  1825. Hash: propBlock.Hash(),
  1826. PartSetHeader: partSet.Header(),
  1827. }
  1828. ensurePrevote(t, voteCh, height, round)
  1829. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, cfg.ChainID(), blockID, vs2, vs3, vs4)
  1830. ensurePrecommit(t, voteCh, height, round)
  1831. // the proposed block should now be locked and our precommit added
  1832. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlock.Hash(), propBlock.Hash())
  1833. // add precommits from the rest
  1834. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, cfg.ChainID(), types.BlockID{}, vs2) // didnt receive proposal
  1835. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, cfg.ChainID(), blockID, vs3)
  1836. // we receive this later, but vs3 might receive it earlier and with ours will go to commit!
  1837. precommit4 := signVote(ctx, t, vs4, tmproto.PrecommitType, cfg.ChainID(), blockID)
  1838. incrementRound(vs2, vs3, vs4)
  1839. // timeout to new round
  1840. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1841. round++ // moving to the next round
  1842. ensureNewRound(t, newRoundCh, height, round)
  1843. t.Log("### ONTO ROUND 1")
  1844. /*Round2
  1845. // we timeout and prevote
  1846. // a polka happened but we didn't see it!
  1847. */
  1848. // prevote for nil since we did not receive a proposal in this round.
  1849. ensurePrevoteMatch(t, voteCh, height, round, rs.LockedBlock.Hash())
  1850. // now we receive the precommit from the previous round
  1851. addVotes(cs1, precommit4)
  1852. // receiving that precommit should take us straight to commit
  1853. ensureNewBlock(t, newBlockCh, height)
  1854. ensureNewRound(t, newRoundCh, height+1, 0)
  1855. }
  1856. func TestStateOutputsBlockPartsStats(t *testing.T) {
  1857. config := configSetup(t)
  1858. logger := log.NewNopLogger()
  1859. ctx, cancel := context.WithCancel(context.Background())
  1860. defer cancel()
  1861. // create dummy peer
  1862. cs, _ := makeState(ctx, t, config, logger, 1)
  1863. peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
  1864. require.NoError(t, err)
  1865. // 1) new block part
  1866. parts := types.NewPartSetFromData(tmrand.Bytes(100), 10)
  1867. msg := &BlockPartMessage{
  1868. Height: 1,
  1869. Round: 0,
  1870. Part: parts.GetPart(0),
  1871. }
  1872. cs.ProposalBlockParts = types.NewPartSetFromHeader(parts.Header())
  1873. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1874. statsMessage := <-cs.statsMsgQueue
  1875. require.Equal(t, msg, statsMessage.Msg, "")
  1876. require.Equal(t, peerID, statsMessage.PeerID, "")
  1877. // sending the same part from different peer
  1878. cs.handleMsg(ctx, msgInfo{msg, "peer2", tmtime.Now()})
  1879. // sending the part with the same height, but different round
  1880. msg.Round = 1
  1881. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1882. // sending the part from the smaller height
  1883. msg.Height = 0
  1884. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1885. // sending the part from the bigger height
  1886. msg.Height = 3
  1887. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1888. select {
  1889. case <-cs.statsMsgQueue:
  1890. t.Errorf("should not output stats message after receiving the known block part!")
  1891. case <-time.After(50 * time.Millisecond):
  1892. }
  1893. }
  1894. func TestStateOutputVoteStats(t *testing.T) {
  1895. config := configSetup(t)
  1896. logger := log.NewNopLogger()
  1897. ctx, cancel := context.WithCancel(context.Background())
  1898. defer cancel()
  1899. cs, vss := makeState(ctx, t, config, logger, 2)
  1900. // create dummy peer
  1901. peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
  1902. require.NoError(t, err)
  1903. randBytes := tmrand.Bytes(tmhash.Size)
  1904. blockID := types.BlockID{
  1905. Hash: randBytes,
  1906. }
  1907. vote := signVote(ctx, t, vss[1], tmproto.PrecommitType, config.ChainID(), blockID)
  1908. voteMessage := &VoteMessage{vote}
  1909. cs.handleMsg(ctx, msgInfo{voteMessage, peerID, tmtime.Now()})
  1910. statsMessage := <-cs.statsMsgQueue
  1911. require.Equal(t, voteMessage, statsMessage.Msg, "")
  1912. require.Equal(t, peerID, statsMessage.PeerID, "")
  1913. // sending the same part from different peer
  1914. cs.handleMsg(ctx, msgInfo{&VoteMessage{vote}, "peer2", tmtime.Now()})
  1915. // sending the vote for the bigger height
  1916. incrementHeight(vss[1])
  1917. vote = signVote(ctx, t, vss[1], tmproto.PrecommitType, config.ChainID(), blockID)
  1918. cs.handleMsg(ctx, msgInfo{&VoteMessage{vote}, peerID, tmtime.Now()})
  1919. select {
  1920. case <-cs.statsMsgQueue:
  1921. t.Errorf("should not output stats message after receiving the known vote or vote from bigger height")
  1922. case <-time.After(50 * time.Millisecond):
  1923. }
  1924. }
  1925. func TestSignSameVoteTwice(t *testing.T) {
  1926. config := configSetup(t)
  1927. logger := log.NewNopLogger()
  1928. ctx, cancel := context.WithCancel(context.Background())
  1929. defer cancel()
  1930. _, vss := makeState(ctx, t, config, logger, 2)
  1931. randBytes := tmrand.Bytes(tmhash.Size)
  1932. vote := signVote(
  1933. ctx,
  1934. t,
  1935. vss[1],
  1936. tmproto.PrecommitType,
  1937. config.ChainID(),
  1938. types.BlockID{
  1939. Hash: randBytes,
  1940. PartSetHeader: types.PartSetHeader{Total: 10, Hash: randBytes},
  1941. },
  1942. )
  1943. vote2 := signVote(
  1944. ctx,
  1945. t,
  1946. vss[1],
  1947. tmproto.PrecommitType,
  1948. config.ChainID(),
  1949. types.BlockID{
  1950. Hash: randBytes,
  1951. PartSetHeader: types.PartSetHeader{Total: 10, Hash: randBytes},
  1952. },
  1953. )
  1954. require.Equal(t, vote, vote2)
  1955. }
  1956. // TestStateTimestamp_ProposalNotMatch tests that a validator does not prevote a
  1957. // proposed block if the timestamp in the block does not matche the timestamp in the
  1958. // corresponding proposal message.
  1959. func TestStateTimestamp_ProposalNotMatch(t *testing.T) {
  1960. config := configSetup(t)
  1961. logger := log.NewNopLogger()
  1962. ctx, cancel := context.WithCancel(context.Background())
  1963. defer cancel()
  1964. cs1, vss := makeState(ctx, t, config, logger, 4)
  1965. height, round := cs1.Height, cs1.Round
  1966. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1967. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1968. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1969. require.NoError(t, err)
  1970. addr := pv1.Address()
  1971. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1972. propBlock, _, err := cs1.createProposalBlock(ctx)
  1973. require.NoError(t, err)
  1974. round++
  1975. incrementRound(vss[1:]...)
  1976. propBlockParts, err := propBlock.MakePartSet(types.BlockPartSizeBytes)
  1977. require.NoError(t, err)
  1978. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  1979. // Create a proposal with a timestamp that does not match the timestamp of the block.
  1980. proposal := types.NewProposal(vs2.Height, round, -1, blockID, propBlock.Header.Time.Add(time.Millisecond))
  1981. p := proposal.ToProto()
  1982. err = vs2.SignProposal(ctx, config.ChainID(), p)
  1983. require.NoError(t, err)
  1984. proposal.Signature = p.Signature
  1985. require.NoError(t, cs1.SetProposalAndBlock(ctx, proposal, propBlock, propBlockParts, "some peer"))
  1986. startTestRound(ctx, cs1, height, round)
  1987. ensureProposal(t, proposalCh, height, round, blockID)
  1988. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  1989. // ensure that the validator prevotes nil.
  1990. ensurePrevote(t, voteCh, height, round)
  1991. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  1992. ensurePrecommit(t, voteCh, height, round)
  1993. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1994. }
  1995. // TestStateTimestamp_ProposalMatch tests that a validator prevotes a
  1996. // proposed block if the timestamp in the block matches the timestamp in the
  1997. // corresponding proposal message.
  1998. func TestStateTimestamp_ProposalMatch(t *testing.T) {
  1999. config := configSetup(t)
  2000. logger := log.NewNopLogger()
  2001. ctx, cancel := context.WithCancel(context.Background())
  2002. defer cancel()
  2003. cs1, vss := makeState(ctx, t, config, logger, 4)
  2004. height, round := cs1.Height, cs1.Round
  2005. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  2006. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  2007. pv1, err := cs1.privValidator.GetPubKey(ctx)
  2008. require.NoError(t, err)
  2009. addr := pv1.Address()
  2010. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  2011. propBlock, _, err := cs1.createProposalBlock(ctx)
  2012. require.NoError(t, err)
  2013. round++
  2014. incrementRound(vss[1:]...)
  2015. propBlockParts, err := propBlock.MakePartSet(types.BlockPartSizeBytes)
  2016. require.NoError(t, err)
  2017. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  2018. // Create a proposal with a timestamp that matches the timestamp of the block.
  2019. proposal := types.NewProposal(vs2.Height, round, -1, blockID, propBlock.Header.Time)
  2020. p := proposal.ToProto()
  2021. err = vs2.SignProposal(ctx, config.ChainID(), p)
  2022. require.NoError(t, err)
  2023. proposal.Signature = p.Signature
  2024. require.NoError(t, cs1.SetProposalAndBlock(ctx, proposal, propBlock, propBlockParts, "some peer"))
  2025. startTestRound(ctx, cs1, height, round)
  2026. ensureProposal(t, proposalCh, height, round, blockID)
  2027. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  2028. // ensure that the validator prevotes the block.
  2029. ensurePrevote(t, voteCh, height, round)
  2030. validatePrevote(ctx, t, cs1, round, vss[0], propBlock.Hash())
  2031. ensurePrecommit(t, voteCh, height, round)
  2032. validatePrecommit(ctx, t, cs1, round, 1, vss[0], propBlock.Hash(), propBlock.Hash())
  2033. }
  2034. // subscribe subscribes test client to the given query and returns a channel with cap = 1.
  2035. func subscribe(
  2036. ctx context.Context,
  2037. t *testing.T,
  2038. eventBus *eventbus.EventBus,
  2039. q *tmquery.Query,
  2040. ) <-chan tmpubsub.Message {
  2041. t.Helper()
  2042. sub, err := eventBus.SubscribeWithArgs(ctx, tmpubsub.SubscribeArgs{
  2043. ClientID: testSubscriber,
  2044. Query: q,
  2045. })
  2046. require.NoErrorf(t, err, "Failed to subscribe %q to %v: %v", testSubscriber, q, err)
  2047. ch := make(chan tmpubsub.Message)
  2048. go func() {
  2049. for {
  2050. next, err := sub.Next(ctx)
  2051. if err != nil {
  2052. if ctx.Err() != nil {
  2053. return
  2054. }
  2055. t.Errorf("Subscription for %v unexpectedly terminated: %v", q, err)
  2056. return
  2057. }
  2058. select {
  2059. case ch <- next:
  2060. case <-ctx.Done():
  2061. return
  2062. }
  2063. }
  2064. }()
  2065. return ch
  2066. }