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.

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