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.

2745 lines
97 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
3 years ago
3 years ago
3 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. func TestFinalizeBlockCalled(t *testing.T) {
  1539. for _, testCase := range []struct {
  1540. name string
  1541. voteNil bool
  1542. expectCalled bool
  1543. }{
  1544. {
  1545. name: "finalze block called when block committed",
  1546. voteNil: false,
  1547. expectCalled: true,
  1548. },
  1549. {
  1550. name: "not called when block not committed",
  1551. voteNil: true,
  1552. expectCalled: false,
  1553. },
  1554. } {
  1555. t.Run(testCase.name, func(t *testing.T) {
  1556. config := configSetup(t)
  1557. ctx, cancel := context.WithCancel(context.Background())
  1558. defer cancel()
  1559. m := abcimocks.NewBaseMock()
  1560. m.On("ProcessProposal", mock.Anything).Return(abcitypes.ResponseProcessProposal{Accept: true})
  1561. m.On("VerifyVoteExtension", mock.Anything).Return(abcitypes.ResponseVerifyVoteExtension{
  1562. Result: abcitypes.ResponseVerifyVoteExtension_ACCEPT,
  1563. })
  1564. m.On("FinalizeBlock", mock.Anything).Return(abcitypes.ResponseFinalizeBlock{}).Maybe()
  1565. cs1, vss := makeState(ctx, t, makeStateArgs{config: config, application: m})
  1566. height, round := cs1.Height, cs1.Round
  1567. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  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. startTestRound(ctx, cs1, cs1.Height, round)
  1574. ensureNewRound(t, newRoundCh, height, round)
  1575. ensureNewProposal(t, proposalCh, height, round)
  1576. rs := cs1.GetRoundState()
  1577. blockID := types.BlockID{}
  1578. nextRound := round + 1
  1579. nextHeight := height
  1580. if !testCase.voteNil {
  1581. nextRound = 0
  1582. nextHeight = height + 1
  1583. blockID = types.BlockID{
  1584. Hash: rs.ProposalBlock.Hash(),
  1585. PartSetHeader: rs.ProposalBlockParts.Header(),
  1586. }
  1587. }
  1588. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vss[1:]...)
  1589. ensurePrevoteMatch(t, voteCh, height, round, rs.ProposalBlock.Hash())
  1590. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vss[1:]...)
  1591. ensurePrecommit(t, voteCh, height, round)
  1592. ensureNewRound(t, newRoundCh, nextHeight, nextRound)
  1593. m.AssertExpectations(t)
  1594. if !testCase.expectCalled {
  1595. m.AssertNotCalled(t, "FinalizeBlock", mock.Anything)
  1596. } else {
  1597. m.AssertCalled(t, "FinalizeBlock", mock.Anything)
  1598. }
  1599. })
  1600. }
  1601. }
  1602. // 4 vals, 3 Nil Precommits at P0
  1603. // What we want:
  1604. // P0 waits for timeoutPrecommit before starting next round
  1605. func TestWaitingTimeoutOnNilPolka(t *testing.T) {
  1606. ctx, cancel := context.WithCancel(context.Background())
  1607. defer cancel()
  1608. config := configSetup(t)
  1609. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1610. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1611. height, round := cs1.Height, cs1.Round
  1612. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1613. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1614. // start round
  1615. startTestRound(ctx, cs1, height, round)
  1616. ensureNewRound(t, newRoundCh, height, round)
  1617. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1618. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1619. ensureNewRound(t, newRoundCh, height, round+1)
  1620. }
  1621. // 4 vals, 3 Prevotes for nil from the higher round.
  1622. // What we want:
  1623. // P0 waits for timeoutPropose in the next round before entering prevote
  1624. func TestWaitingTimeoutProposeOnNewRound(t *testing.T) {
  1625. config := configSetup(t)
  1626. ctx, cancel := context.WithCancel(context.Background())
  1627. defer cancel()
  1628. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1629. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1630. height, round := cs1.Height, cs1.Round
  1631. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1632. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1633. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1634. require.NoError(t, err)
  1635. addr := pv1.Address()
  1636. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1637. // start round
  1638. startTestRound(ctx, cs1, height, round)
  1639. ensureNewRound(t, newRoundCh, height, round)
  1640. ensurePrevote(t, voteCh, height, round)
  1641. incrementRound(vss[1:]...)
  1642. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1643. round++ // moving to the next round
  1644. ensureNewRound(t, newRoundCh, height, round)
  1645. rs := cs1.GetRoundState()
  1646. assert.True(t, rs.Step == cstypes.RoundStepPropose) // P0 does not prevote before timeoutPropose expires
  1647. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1648. ensurePrevoteMatch(t, voteCh, height, round, nil)
  1649. }
  1650. // 4 vals, 3 Precommits for nil from the higher round.
  1651. // What we want:
  1652. // P0 jump to higher round, precommit and start precommit wait
  1653. func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) {
  1654. config := configSetup(t)
  1655. ctx, cancel := context.WithCancel(context.Background())
  1656. defer cancel()
  1657. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1658. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1659. height, round := cs1.Height, cs1.Round
  1660. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1661. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1662. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1663. require.NoError(t, err)
  1664. addr := pv1.Address()
  1665. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1666. // start round
  1667. startTestRound(ctx, cs1, height, round)
  1668. ensureNewRound(t, newRoundCh, height, round)
  1669. ensurePrevote(t, voteCh, height, round)
  1670. incrementRound(vss[1:]...)
  1671. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1672. round++ // moving to the next round
  1673. ensureNewRound(t, newRoundCh, height, round)
  1674. ensurePrecommit(t, voteCh, height, round)
  1675. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  1676. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1677. round++ // moving to the next round
  1678. ensureNewRound(t, newRoundCh, height, round)
  1679. }
  1680. // 4 vals, 3 Prevotes for nil in the current round.
  1681. // What we want:
  1682. // P0 wait for timeoutPropose to expire before sending prevote.
  1683. func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) {
  1684. config := configSetup(t)
  1685. ctx, cancel := context.WithCancel(context.Background())
  1686. defer cancel()
  1687. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1688. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1689. height, round := cs1.Height, int32(1)
  1690. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1691. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1692. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1693. require.NoError(t, err)
  1694. addr := pv1.Address()
  1695. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1696. // start round in which PO is not proposer
  1697. startTestRound(ctx, cs1, height, round)
  1698. ensureNewRound(t, newRoundCh, height, round)
  1699. incrementRound(vss[1:]...)
  1700. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
  1701. ensureNewTimeout(t, timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
  1702. ensurePrevoteMatch(t, voteCh, height, round, nil)
  1703. }
  1704. // What we want:
  1705. // P0 emit NewValidBlock event upon receiving 2/3+ Precommit for B but hasn't received block B yet
  1706. func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) {
  1707. config := configSetup(t)
  1708. ctx, cancel := context.WithCancel(context.Background())
  1709. defer cancel()
  1710. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1711. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1712. height, round := cs1.Height, int32(1)
  1713. incrementRound(vs2, vs3, vs4)
  1714. partSize := types.BlockPartSizeBytes
  1715. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1716. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1717. _, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round)
  1718. partSet, err := propBlock.MakePartSet(partSize)
  1719. require.NoError(t, err)
  1720. blockID := types.BlockID{
  1721. Hash: propBlock.Hash(),
  1722. PartSetHeader: partSet.Header(),
  1723. }
  1724. // start round in which PO is not proposer
  1725. startTestRound(ctx, cs1, height, round)
  1726. ensureNewRound(t, newRoundCh, height, round)
  1727. // vs2, vs3 and vs4 send precommit for propBlock
  1728. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs2, vs3, vs4)
  1729. ensureNewValidBlock(t, validBlockCh, height, round)
  1730. rs := cs1.GetRoundState()
  1731. assert.True(t, rs.Step == cstypes.RoundStepCommit)
  1732. assert.True(t, rs.ProposalBlock == nil)
  1733. assert.True(t, rs.ProposalBlockParts.Header().Equals(blockID.PartSetHeader))
  1734. }
  1735. // What we want:
  1736. // P0 receives 2/3+ Precommit for B for round 0, while being in round 1. It emits NewValidBlock event.
  1737. // After receiving block, it executes block and moves to the next height.
  1738. func TestCommitFromPreviousRound(t *testing.T) {
  1739. config := configSetup(t)
  1740. ctx, cancel := context.WithCancel(context.Background())
  1741. defer cancel()
  1742. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1743. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1744. height, round := cs1.Height, int32(1)
  1745. partSize := types.BlockPartSizeBytes
  1746. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1747. validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock)
  1748. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1749. prop, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round)
  1750. partSet, err := propBlock.MakePartSet(partSize)
  1751. require.NoError(t, err)
  1752. blockID := types.BlockID{
  1753. Hash: propBlock.Hash(),
  1754. PartSetHeader: partSet.Header(),
  1755. }
  1756. // start round in which PO is not proposer
  1757. startTestRound(ctx, cs1, height, round)
  1758. ensureNewRound(t, newRoundCh, height, round)
  1759. // vs2, vs3 and vs4 send precommit for propBlock for the previous round
  1760. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs2, vs3, vs4)
  1761. ensureNewValidBlock(t, validBlockCh, height, round)
  1762. rs := cs1.GetRoundState()
  1763. assert.True(t, rs.Step == cstypes.RoundStepCommit)
  1764. assert.True(t, rs.CommitRound == vs2.Round)
  1765. assert.True(t, rs.ProposalBlock == nil)
  1766. assert.True(t, rs.ProposalBlockParts.Header().Equals(blockID.PartSetHeader))
  1767. partSet, err = propBlock.MakePartSet(partSize)
  1768. require.NoError(t, err)
  1769. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, partSet, "some peer")
  1770. require.NoError(t, err)
  1771. ensureNewProposal(t, proposalCh, height, round)
  1772. ensureNewRound(t, newRoundCh, height+1, 0)
  1773. }
  1774. type fakeTxNotifier struct {
  1775. ch chan struct{}
  1776. }
  1777. func (n *fakeTxNotifier) TxsAvailable() <-chan struct{} {
  1778. return n.ch
  1779. }
  1780. func (n *fakeTxNotifier) Notify() {
  1781. n.ch <- struct{}{}
  1782. }
  1783. // 2 vals precommit votes for a block but node times out waiting for the third. Move to next round
  1784. // and third precommit arrives which leads to the commit of that header and the correct
  1785. // start of the next round
  1786. func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) {
  1787. config := configSetup(t)
  1788. ctx, cancel := context.WithCancel(context.Background())
  1789. defer cancel()
  1790. config.Consensus.SkipTimeoutCommit = false
  1791. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1792. cs1.txNotifier = &fakeTxNotifier{ch: make(chan struct{})}
  1793. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1794. height, round := cs1.Height, cs1.Round
  1795. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1796. timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
  1797. precommitTimeoutCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1798. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1799. newBlockHeader := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlockHeader)
  1800. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1801. require.NoError(t, err)
  1802. addr := pv1.Address()
  1803. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1804. // start round and wait for propose and prevote
  1805. startTestRound(ctx, cs1, height, round)
  1806. ensureNewRound(t, newRoundCh, height, round)
  1807. ensureNewProposal(t, proposalCh, height, round)
  1808. rs := cs1.GetRoundState()
  1809. blockID := types.BlockID{
  1810. Hash: rs.ProposalBlock.Hash(),
  1811. PartSetHeader: rs.ProposalBlockParts.Header(),
  1812. }
  1813. ensurePrevoteMatch(t, voteCh, height, round, blockID.Hash)
  1814. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  1815. ensurePrecommit(t, voteCh, height, round)
  1816. // the proposed block should now be locked and our precommit added
  1817. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  1818. // add precommits
  1819. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2)
  1820. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs3)
  1821. // wait till timeout occurs
  1822. ensureNewTimeout(t, precommitTimeoutCh, height, round, cs1.config.TimeoutPrecommit.Nanoseconds())
  1823. ensureNewRound(t, newRoundCh, height, round+1)
  1824. // majority is now reached
  1825. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs4)
  1826. ensureNewBlockHeader(t, newBlockHeader, height, blockID.Hash)
  1827. cs1.txNotifier.(*fakeTxNotifier).Notify()
  1828. ensureNewTimeout(t, timeoutProposeCh, height+1, round, cs1.config.Propose(round).Nanoseconds())
  1829. rs = cs1.GetRoundState()
  1830. assert.False(
  1831. t,
  1832. rs.TriggeredTimeoutPrecommit,
  1833. "triggeredTimeoutPrecommit should be false at the beginning of each round")
  1834. }
  1835. func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) {
  1836. config := configSetup(t)
  1837. ctx, cancel := context.WithCancel(context.Background())
  1838. defer cancel()
  1839. config.Consensus.SkipTimeoutCommit = false
  1840. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1841. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1842. height, round := cs1.Height, cs1.Round
  1843. partSize := types.BlockPartSizeBytes
  1844. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1845. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1846. newBlockHeader := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlockHeader)
  1847. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1848. require.NoError(t, err)
  1849. addr := pv1.Address()
  1850. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1851. // start round and wait for propose and prevote
  1852. startTestRound(ctx, cs1, height, round)
  1853. ensureNewRound(t, newRoundCh, height, round)
  1854. ensureNewProposal(t, proposalCh, height, round)
  1855. rs := cs1.GetRoundState()
  1856. blockID := types.BlockID{
  1857. Hash: rs.ProposalBlock.Hash(),
  1858. PartSetHeader: rs.ProposalBlockParts.Header(),
  1859. }
  1860. ensurePrevoteMatch(t, voteCh, height, round, blockID.Hash)
  1861. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  1862. ensurePrecommit(t, voteCh, height, round)
  1863. validatePrecommit(ctx, t, cs1, round, round, vss[0], blockID.Hash, blockID.Hash)
  1864. // add precommits
  1865. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2)
  1866. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs3)
  1867. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs4)
  1868. ensureNewBlockHeader(t, newBlockHeader, height, blockID.Hash)
  1869. prop, propBlock := decideProposal(ctx, t, cs1, vs2, height+1, 0)
  1870. propBlockParts, err := propBlock.MakePartSet(partSize)
  1871. require.NoError(t, err)
  1872. err = cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlockParts, "some peer")
  1873. require.NoError(t, err)
  1874. ensureNewProposal(t, proposalCh, height+1, 0)
  1875. rs = cs1.GetRoundState()
  1876. assert.False(
  1877. t,
  1878. rs.TriggeredTimeoutPrecommit,
  1879. "triggeredTimeoutPrecommit should be false at the beginning of each height")
  1880. }
  1881. //------------------------------------------------------------------------------------------
  1882. // CatchupSuite
  1883. //------------------------------------------------------------------------------------------
  1884. // HaltSuite
  1885. // 4 vals.
  1886. // we receive a final precommit after going into next round, but others might have gone to commit already!
  1887. func TestStateHalt1(t *testing.T) {
  1888. config := configSetup(t)
  1889. ctx, cancel := context.WithCancel(context.Background())
  1890. defer cancel()
  1891. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  1892. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  1893. height, round := cs1.Height, cs1.Round
  1894. partSize := types.BlockPartSizeBytes
  1895. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  1896. timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
  1897. newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
  1898. newBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewBlock)
  1899. pv1, err := cs1.privValidator.GetPubKey(ctx)
  1900. require.NoError(t, err)
  1901. addr := pv1.Address()
  1902. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  1903. // start round and wait for propose and prevote
  1904. startTestRound(ctx, cs1, height, round)
  1905. ensureNewRound(t, newRoundCh, height, round)
  1906. ensureNewProposal(t, proposalCh, height, round)
  1907. rs := cs1.GetRoundState()
  1908. propBlock := rs.ProposalBlock
  1909. partSet, err := propBlock.MakePartSet(partSize)
  1910. require.NoError(t, err)
  1911. blockID := types.BlockID{
  1912. Hash: propBlock.Hash(),
  1913. PartSetHeader: partSet.Header(),
  1914. }
  1915. ensurePrevote(t, voteCh, height, round)
  1916. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  1917. ensurePrecommit(t, voteCh, height, round)
  1918. // the proposed block should now be locked and our precommit added
  1919. validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlock.Hash(), propBlock.Hash())
  1920. // add precommits from the rest
  1921. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2) // didnt receive proposal
  1922. signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), blockID, vs3)
  1923. // we receive this later, but vs3 might receive it earlier and with ours will go to commit!
  1924. precommit4 := signVote(ctx, t, vs4, tmproto.PrecommitType, config.ChainID(), blockID)
  1925. incrementRound(vs2, vs3, vs4)
  1926. // timeout to new round
  1927. ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
  1928. round++ // moving to the next round
  1929. ensureNewRound(t, newRoundCh, height, round)
  1930. t.Log("### ONTO ROUND 1")
  1931. /*Round2
  1932. // we timeout and prevote
  1933. // a polka happened but we didn't see it!
  1934. */
  1935. // prevote for nil since we did not receive a proposal in this round.
  1936. ensurePrevoteMatch(t, voteCh, height, round, rs.LockedBlock.Hash())
  1937. // now we receive the precommit from the previous round
  1938. addVotes(cs1, precommit4)
  1939. // receiving that precommit should take us straight to commit
  1940. ensureNewBlock(t, newBlockCh, height)
  1941. ensureNewRound(t, newRoundCh, height+1, 0)
  1942. }
  1943. func TestStateOutputsBlockPartsStats(t *testing.T) {
  1944. config := configSetup(t)
  1945. ctx, cancel := context.WithCancel(context.Background())
  1946. defer cancel()
  1947. // create dummy peer
  1948. cs, _ := makeState(ctx, t, makeStateArgs{config: config, validators: 1})
  1949. peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
  1950. require.NoError(t, err)
  1951. // 1) new block part
  1952. parts := types.NewPartSetFromData(tmrand.Bytes(100), 10)
  1953. msg := &BlockPartMessage{
  1954. Height: 1,
  1955. Round: 0,
  1956. Part: parts.GetPart(0),
  1957. }
  1958. cs.ProposalBlockParts = types.NewPartSetFromHeader(parts.Header())
  1959. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1960. statsMessage := <-cs.statsMsgQueue
  1961. require.Equal(t, msg, statsMessage.Msg, "")
  1962. require.Equal(t, peerID, statsMessage.PeerID, "")
  1963. // sending the same part from different peer
  1964. cs.handleMsg(ctx, msgInfo{msg, "peer2", tmtime.Now()})
  1965. // sending the part with the same height, but different round
  1966. msg.Round = 1
  1967. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1968. // sending the part from the smaller height
  1969. msg.Height = 0
  1970. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1971. // sending the part from the bigger height
  1972. msg.Height = 3
  1973. cs.handleMsg(ctx, msgInfo{msg, peerID, tmtime.Now()})
  1974. select {
  1975. case <-cs.statsMsgQueue:
  1976. t.Errorf("should not output stats message after receiving the known block part!")
  1977. case <-time.After(50 * time.Millisecond):
  1978. }
  1979. }
  1980. func TestStateOutputVoteStats(t *testing.T) {
  1981. config := configSetup(t)
  1982. ctx, cancel := context.WithCancel(context.Background())
  1983. defer cancel()
  1984. cs, vss := makeState(ctx, t, makeStateArgs{config: config, validators: 2})
  1985. // create dummy peer
  1986. peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
  1987. require.NoError(t, err)
  1988. randBytes := tmrand.Bytes(tmhash.Size)
  1989. blockID := types.BlockID{
  1990. Hash: randBytes,
  1991. }
  1992. vote := signVote(ctx, t, vss[1], tmproto.PrecommitType, config.ChainID(), blockID)
  1993. voteMessage := &VoteMessage{vote}
  1994. cs.handleMsg(ctx, msgInfo{voteMessage, peerID, tmtime.Now()})
  1995. statsMessage := <-cs.statsMsgQueue
  1996. require.Equal(t, voteMessage, statsMessage.Msg, "")
  1997. require.Equal(t, peerID, statsMessage.PeerID, "")
  1998. // sending the same part from different peer
  1999. cs.handleMsg(ctx, msgInfo{&VoteMessage{vote}, "peer2", tmtime.Now()})
  2000. // sending the vote for the bigger height
  2001. incrementHeight(vss[1])
  2002. vote = signVote(ctx, t, vss[1], tmproto.PrecommitType, config.ChainID(), blockID)
  2003. cs.handleMsg(ctx, msgInfo{&VoteMessage{vote}, peerID, tmtime.Now()})
  2004. select {
  2005. case <-cs.statsMsgQueue:
  2006. t.Errorf("should not output stats message after receiving the known vote or vote from bigger height")
  2007. case <-time.After(50 * time.Millisecond):
  2008. }
  2009. }
  2010. func TestSignSameVoteTwice(t *testing.T) {
  2011. config := configSetup(t)
  2012. ctx, cancel := context.WithCancel(context.Background())
  2013. defer cancel()
  2014. _, vss := makeState(ctx, t, makeStateArgs{config: config, validators: 2})
  2015. randBytes := tmrand.Bytes(tmhash.Size)
  2016. vote := signVote(
  2017. ctx,
  2018. t,
  2019. vss[1],
  2020. tmproto.PrecommitType,
  2021. config.ChainID(),
  2022. types.BlockID{
  2023. Hash: randBytes,
  2024. PartSetHeader: types.PartSetHeader{Total: 10, Hash: randBytes},
  2025. },
  2026. )
  2027. vote2 := signVote(
  2028. ctx,
  2029. t,
  2030. vss[1],
  2031. tmproto.PrecommitType,
  2032. config.ChainID(),
  2033. types.BlockID{
  2034. Hash: randBytes,
  2035. PartSetHeader: types.PartSetHeader{Total: 10, Hash: randBytes},
  2036. },
  2037. )
  2038. require.Equal(t, vote, vote2)
  2039. }
  2040. // TestStateTimestamp_ProposalNotMatch tests that a validator does not prevote a
  2041. // proposed block if the timestamp in the block does not matche the timestamp in the
  2042. // corresponding proposal message.
  2043. func TestStateTimestamp_ProposalNotMatch(t *testing.T) {
  2044. config := configSetup(t)
  2045. ctx, cancel := context.WithCancel(context.Background())
  2046. defer cancel()
  2047. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  2048. height, round := cs1.Height, cs1.Round
  2049. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  2050. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  2051. pv1, err := cs1.privValidator.GetPubKey(ctx)
  2052. require.NoError(t, err)
  2053. addr := pv1.Address()
  2054. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  2055. propBlock, _, err := cs1.createProposalBlock(ctx)
  2056. require.NoError(t, err)
  2057. round++
  2058. incrementRound(vss[1:]...)
  2059. propBlockParts, err := propBlock.MakePartSet(types.BlockPartSizeBytes)
  2060. require.NoError(t, err)
  2061. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  2062. // Create a proposal with a timestamp that does not match the timestamp of the block.
  2063. proposal := types.NewProposal(vs2.Height, round, -1, blockID, propBlock.Header.Time.Add(time.Millisecond))
  2064. p := proposal.ToProto()
  2065. err = vs2.SignProposal(ctx, config.ChainID(), p)
  2066. require.NoError(t, err)
  2067. proposal.Signature = p.Signature
  2068. require.NoError(t, cs1.SetProposalAndBlock(ctx, proposal, propBlock, propBlockParts, "some peer"))
  2069. startTestRound(ctx, cs1, height, round)
  2070. ensureProposal(t, proposalCh, height, round, blockID)
  2071. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  2072. // ensure that the validator prevotes nil.
  2073. ensurePrevote(t, voteCh, height, round)
  2074. validatePrevote(ctx, t, cs1, round, vss[0], nil)
  2075. ensurePrecommit(t, voteCh, height, round)
  2076. validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
  2077. }
  2078. // TestStateTimestamp_ProposalMatch tests that a validator prevotes a
  2079. // proposed block if the timestamp in the block matches the timestamp in the
  2080. // corresponding proposal message.
  2081. func TestStateTimestamp_ProposalMatch(t *testing.T) {
  2082. config := configSetup(t)
  2083. ctx, cancel := context.WithCancel(context.Background())
  2084. defer cancel()
  2085. cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
  2086. height, round := cs1.Height, cs1.Round
  2087. vs2, vs3, vs4 := vss[1], vss[2], vss[3]
  2088. proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal)
  2089. pv1, err := cs1.privValidator.GetPubKey(ctx)
  2090. require.NoError(t, err)
  2091. addr := pv1.Address()
  2092. voteCh := subscribeToVoter(ctx, t, cs1, addr)
  2093. propBlock, _, err := cs1.createProposalBlock(ctx)
  2094. require.NoError(t, err)
  2095. round++
  2096. incrementRound(vss[1:]...)
  2097. propBlockParts, err := propBlock.MakePartSet(types.BlockPartSizeBytes)
  2098. require.NoError(t, err)
  2099. blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
  2100. // Create a proposal with a timestamp that matches the timestamp of the block.
  2101. proposal := types.NewProposal(vs2.Height, round, -1, blockID, propBlock.Header.Time)
  2102. p := proposal.ToProto()
  2103. err = vs2.SignProposal(ctx, config.ChainID(), p)
  2104. require.NoError(t, err)
  2105. proposal.Signature = p.Signature
  2106. require.NoError(t, cs1.SetProposalAndBlock(ctx, proposal, propBlock, propBlockParts, "some peer"))
  2107. startTestRound(ctx, cs1, height, round)
  2108. ensureProposal(t, proposalCh, height, round, blockID)
  2109. signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4)
  2110. // ensure that the validator prevotes the block.
  2111. ensurePrevote(t, voteCh, height, round)
  2112. validatePrevote(ctx, t, cs1, round, vss[0], propBlock.Hash())
  2113. ensurePrecommit(t, voteCh, height, round)
  2114. validatePrecommit(ctx, t, cs1, round, 1, vss[0], propBlock.Hash(), propBlock.Hash())
  2115. }
  2116. // subscribe subscribes test client to the given query and returns a channel with cap = 1.
  2117. func subscribe(
  2118. ctx context.Context,
  2119. t *testing.T,
  2120. eventBus *eventbus.EventBus,
  2121. q *tmquery.Query,
  2122. ) <-chan tmpubsub.Message {
  2123. t.Helper()
  2124. sub, err := eventBus.SubscribeWithArgs(ctx, tmpubsub.SubscribeArgs{
  2125. ClientID: testSubscriber,
  2126. Query: q,
  2127. })
  2128. require.NoErrorf(t, err, "Failed to subscribe %q to %v: %v", testSubscriber, q, err)
  2129. ch := make(chan tmpubsub.Message)
  2130. go func() {
  2131. for {
  2132. next, err := sub.Next(ctx)
  2133. if err != nil {
  2134. if ctx.Err() != nil {
  2135. return
  2136. }
  2137. t.Errorf("Subscription for %v unexpectedly terminated: %v", q, err)
  2138. return
  2139. }
  2140. select {
  2141. case ch <- next:
  2142. case <-ctx.Done():
  2143. return
  2144. }
  2145. }
  2146. }()
  2147. return ch
  2148. }