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.

1974 lines
67 KiB

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