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.

2672 lines
95 KiB

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