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.

2721 lines
96 KiB

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