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.

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