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.

1506 lines
45 KiB

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
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
7 years ago
10 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
10 years ago
8 years ago
10 years ago
10 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
8 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
7 years ago
7 years ago
10 years ago
7 years ago
10 years ago
10 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
10 years ago
7 years ago
10 years ago
8 years ago
7 years ago
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
8 years ago
8 years ago
8 years ago
10 years ago
10 years ago
10 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
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
10 years ago
10 years ago
8 years ago
10 years ago
10 years ago
7 years ago
10 years ago
8 years ago
10 years ago
7 years ago
7 years ago
10 years ago
10 years ago
10 years ago
7 years ago
7 years ago
8 years ago
10 years ago
8 years ago
10 years ago
10 years ago
8 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
8 years ago
7 years ago
8 years ago
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
7 years ago
7 years ago
7 years ago
7 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
7 years ago
7 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
7 years ago
10 years ago
10 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
7 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
7 years ago
10 years ago
10 years ago
fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ```
7 years ago
protect Record* peerStateStats functions by mutex Fixes #1414 DATA RACE: ``` Read at 0x00c4214ee940 by goroutine 146: github.com/tendermint/tendermint/consensus.(*peerStateStats).String() <autogenerated>:1 +0x57 fmt.(*pp).handleMethods() /usr/local/go/src/fmt/print.go:596 +0x3f4 fmt.(*pp).printArg() /usr/local/go/src/fmt/print.go:679 +0x11f fmt.(*pp).doPrintf() /usr/local/go/src/fmt/print.go:996 +0x319 fmt.Sprintf() /usr/local/go/src/fmt/print.go:196 +0x73 github.com/tendermint/tendermint/consensus.(*PeerState).StringIndented() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1426 +0x573 github.com/tendermint/tendermint/consensus.(*PeerState).String() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1419 +0x66 github.com/go-logfmt/logfmt.safeString() /home/ubuntu/go/src/github.com/go-logfmt/logfmt/encode.go:299 +0x9d github.com/go-logfmt/logfmt.writeValue() /home/ubuntu/go/src/github.com/go-logfmt/logfmt/encode.go:217 +0x5a0 github.com/go-logfmt/logfmt.(*Encoder).EncodeKeyval() /home/ubuntu/go/src/github.com/go-logfmt/logfmt/encode.go:61 +0x1dd github.com/tendermint/tmlibs/log.tmfmtLogger.Log() /home/ubuntu/go/src/github.com/tendermint/tmlibs/log/tmfmt_logger.go:107 +0x1001 github.com/tendermint/tmlibs/log.(*tmfmtLogger).Log() <autogenerated>:1 +0x93 github.com/go-kit/kit/log.(*context).Log() /home/ubuntu/go/src/github.com/go-kit/kit/log/log.go:124 +0x248 github.com/tendermint/tmlibs/log.(*tmLogger).Debug() /home/ubuntu/go/src/github.com/tendermint/tmlibs/log/tm_logger.go:64 +0x1d0 github.com/tendermint/tendermint/consensus.(*PeerState).PickSendVote() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1059 +0x242 github.com/tendermint/tendermint/consensus.(*ConsensusReactor).gossipVotesForHeight() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:789 +0x6ef github.com/tendermint/tendermint/consensus.(*ConsensusReactor).gossipVotesRoutine() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:723 +0x1039 Previous write at 0x00c4214ee940 by goroutine 21: github.com/tendermint/tendermint/consensus.(*PeerState).RecordVote() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1242 +0x15a github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Receive() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:309 +0x32e6 github.com/tendermint/tendermint/p2p.createMConnection.func1() /home/ubuntu/go/src/github.com/tendermint/tendermint/p2p/peer.go:365 +0xea github.com/tendermint/tendermint/p2p/conn.(*MConnection).recvRoutine() /home/ubuntu/go/src/github.com/tendermint/tendermint/p2p/conn/connection.go:531 +0x779 ```
7 years ago
protect Record* peerStateStats functions by mutex Fixes #1414 DATA RACE: ``` Read at 0x00c4214ee940 by goroutine 146: github.com/tendermint/tendermint/consensus.(*peerStateStats).String() <autogenerated>:1 +0x57 fmt.(*pp).handleMethods() /usr/local/go/src/fmt/print.go:596 +0x3f4 fmt.(*pp).printArg() /usr/local/go/src/fmt/print.go:679 +0x11f fmt.(*pp).doPrintf() /usr/local/go/src/fmt/print.go:996 +0x319 fmt.Sprintf() /usr/local/go/src/fmt/print.go:196 +0x73 github.com/tendermint/tendermint/consensus.(*PeerState).StringIndented() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1426 +0x573 github.com/tendermint/tendermint/consensus.(*PeerState).String() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1419 +0x66 github.com/go-logfmt/logfmt.safeString() /home/ubuntu/go/src/github.com/go-logfmt/logfmt/encode.go:299 +0x9d github.com/go-logfmt/logfmt.writeValue() /home/ubuntu/go/src/github.com/go-logfmt/logfmt/encode.go:217 +0x5a0 github.com/go-logfmt/logfmt.(*Encoder).EncodeKeyval() /home/ubuntu/go/src/github.com/go-logfmt/logfmt/encode.go:61 +0x1dd github.com/tendermint/tmlibs/log.tmfmtLogger.Log() /home/ubuntu/go/src/github.com/tendermint/tmlibs/log/tmfmt_logger.go:107 +0x1001 github.com/tendermint/tmlibs/log.(*tmfmtLogger).Log() <autogenerated>:1 +0x93 github.com/go-kit/kit/log.(*context).Log() /home/ubuntu/go/src/github.com/go-kit/kit/log/log.go:124 +0x248 github.com/tendermint/tmlibs/log.(*tmLogger).Debug() /home/ubuntu/go/src/github.com/tendermint/tmlibs/log/tm_logger.go:64 +0x1d0 github.com/tendermint/tendermint/consensus.(*PeerState).PickSendVote() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1059 +0x242 github.com/tendermint/tendermint/consensus.(*ConsensusReactor).gossipVotesForHeight() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:789 +0x6ef github.com/tendermint/tendermint/consensus.(*ConsensusReactor).gossipVotesRoutine() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:723 +0x1039 Previous write at 0x00c4214ee940 by goroutine 21: github.com/tendermint/tendermint/consensus.(*PeerState).RecordVote() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:1242 +0x15a github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Receive() github.com/tendermint/tendermint/consensus/_test/_obj_test/reactor.go:309 +0x32e6 github.com/tendermint/tendermint/p2p.createMConnection.func1() /home/ubuntu/go/src/github.com/tendermint/tendermint/p2p/peer.go:365 +0xea github.com/tendermint/tendermint/p2p/conn.(*MConnection).recvRoutine() /home/ubuntu/go/src/github.com/tendermint/tendermint/p2p/conn/connection.go:531 +0x779 ```
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
7 years ago
10 years ago
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
7 years ago
  1. package consensus
  2. import (
  3. "fmt"
  4. "reflect"
  5. "sync"
  6. "time"
  7. "github.com/pkg/errors"
  8. amino "github.com/tendermint/go-amino"
  9. cstypes "github.com/tendermint/tendermint/consensus/types"
  10. cmn "github.com/tendermint/tendermint/libs/common"
  11. tmevents "github.com/tendermint/tendermint/libs/events"
  12. "github.com/tendermint/tendermint/libs/log"
  13. "github.com/tendermint/tendermint/p2p"
  14. sm "github.com/tendermint/tendermint/state"
  15. "github.com/tendermint/tendermint/types"
  16. tmtime "github.com/tendermint/tendermint/types/time"
  17. )
  18. const (
  19. StateChannel = byte(0x20)
  20. DataChannel = byte(0x21)
  21. VoteChannel = byte(0x22)
  22. VoteSetBitsChannel = byte(0x23)
  23. maxMsgSize = 1048576 // 1MB; NOTE/TODO: keep in sync with types.PartSet sizes.
  24. blocksToContributeToBecomeGoodPeer = 10000
  25. votesToContributeToBecomeGoodPeer = 10000
  26. )
  27. //-----------------------------------------------------------------------------
  28. // ConsensusReactor defines a reactor for the consensus service.
  29. type ConsensusReactor struct {
  30. p2p.BaseReactor // BaseService + p2p.Switch
  31. conS *ConsensusState
  32. mtx sync.RWMutex
  33. fastSync bool
  34. eventBus *types.EventBus
  35. metrics *Metrics
  36. }
  37. type ReactorOption func(*ConsensusReactor)
  38. // NewConsensusReactor returns a new ConsensusReactor with the given
  39. // consensusState.
  40. func NewConsensusReactor(consensusState *ConsensusState, fastSync bool, options ...ReactorOption) *ConsensusReactor {
  41. conR := &ConsensusReactor{
  42. conS: consensusState,
  43. fastSync: fastSync,
  44. metrics: NopMetrics(),
  45. }
  46. conR.updateFastSyncingMetric()
  47. conR.BaseReactor = *p2p.NewBaseReactor("ConsensusReactor", conR)
  48. for _, option := range options {
  49. option(conR)
  50. }
  51. return conR
  52. }
  53. // OnStart implements BaseService by subscribing to events, which later will be
  54. // broadcasted to other peers and starting state if we're not in fast sync.
  55. func (conR *ConsensusReactor) OnStart() error {
  56. conR.Logger.Info("ConsensusReactor ", "fastSync", conR.FastSync())
  57. // start routine that computes peer statistics for evaluating peer quality
  58. go conR.peerStatsRoutine()
  59. conR.subscribeToBroadcastEvents()
  60. if !conR.FastSync() {
  61. err := conR.conS.Start()
  62. if err != nil {
  63. return err
  64. }
  65. }
  66. return nil
  67. }
  68. // OnStop implements BaseService by unsubscribing from events and stopping
  69. // state.
  70. func (conR *ConsensusReactor) OnStop() {
  71. conR.unsubscribeFromBroadcastEvents()
  72. conR.conS.Stop()
  73. if !conR.FastSync() {
  74. conR.conS.Wait()
  75. }
  76. }
  77. // SwitchToConsensus switches from fast_sync mode to consensus mode.
  78. // It resets the state, turns off fast_sync, and starts the consensus state-machine
  79. func (conR *ConsensusReactor) SwitchToConsensus(state sm.State, blocksSynced int) {
  80. conR.Logger.Info("SwitchToConsensus")
  81. conR.conS.reconstructLastCommit(state)
  82. // NOTE: The line below causes broadcastNewRoundStepRoutine() to
  83. // broadcast a NewRoundStepMessage.
  84. conR.conS.updateToState(state)
  85. conR.mtx.Lock()
  86. conR.fastSync = false
  87. conR.mtx.Unlock()
  88. conR.metrics.FastSyncing.Set(0)
  89. if blocksSynced > 0 {
  90. // dont bother with the WAL if we fast synced
  91. conR.conS.doWALCatchup = false
  92. }
  93. err := conR.conS.Start()
  94. if err != nil {
  95. conR.Logger.Error("Error starting conS", "err", err)
  96. return
  97. }
  98. }
  99. // GetChannels implements Reactor
  100. func (conR *ConsensusReactor) GetChannels() []*p2p.ChannelDescriptor {
  101. // TODO optimize
  102. return []*p2p.ChannelDescriptor{
  103. {
  104. ID: StateChannel,
  105. Priority: 5,
  106. SendQueueCapacity: 100,
  107. RecvMessageCapacity: maxMsgSize,
  108. },
  109. {
  110. ID: DataChannel, // maybe split between gossiping current block and catchup stuff
  111. Priority: 10, // once we gossip the whole block there's nothing left to send until next height or round
  112. SendQueueCapacity: 100,
  113. RecvBufferCapacity: 50 * 4096,
  114. RecvMessageCapacity: maxMsgSize,
  115. },
  116. {
  117. ID: VoteChannel,
  118. Priority: 5,
  119. SendQueueCapacity: 100,
  120. RecvBufferCapacity: 100 * 100,
  121. RecvMessageCapacity: maxMsgSize,
  122. },
  123. {
  124. ID: VoteSetBitsChannel,
  125. Priority: 1,
  126. SendQueueCapacity: 2,
  127. RecvBufferCapacity: 1024,
  128. RecvMessageCapacity: maxMsgSize,
  129. },
  130. }
  131. }
  132. // AddPeer implements Reactor
  133. func (conR *ConsensusReactor) AddPeer(peer p2p.Peer) {
  134. if !conR.IsRunning() {
  135. return
  136. }
  137. // Create peerState for peer
  138. peerState := NewPeerState(peer).SetLogger(conR.Logger)
  139. peer.Set(types.PeerStateKey, peerState)
  140. // Begin routines for this peer.
  141. go conR.gossipDataRoutine(peer, peerState)
  142. go conR.gossipVotesRoutine(peer, peerState)
  143. go conR.queryMaj23Routine(peer, peerState)
  144. // Send our state to peer.
  145. // If we're fast_syncing, broadcast a RoundStepMessage later upon SwitchToConsensus().
  146. if !conR.FastSync() {
  147. conR.sendNewRoundStepMessages(peer)
  148. }
  149. }
  150. // RemovePeer implements Reactor
  151. func (conR *ConsensusReactor) RemovePeer(peer p2p.Peer, reason interface{}) {
  152. if !conR.IsRunning() {
  153. return
  154. }
  155. // TODO
  156. //peer.Get(PeerStateKey).(*PeerState).Disconnect()
  157. }
  158. // Receive implements Reactor
  159. // NOTE: We process these messages even when we're fast_syncing.
  160. // Messages affect either a peer state or the consensus state.
  161. // Peer state updates can happen in parallel, but processing of
  162. // proposals, block parts, and votes are ordered by the receiveRoutine
  163. // NOTE: blocks on consensus state for proposals, block parts, and votes
  164. func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
  165. if !conR.IsRunning() {
  166. conR.Logger.Debug("Receive", "src", src, "chId", chID, "bytes", msgBytes)
  167. return
  168. }
  169. msg, err := decodeMsg(msgBytes)
  170. if err != nil {
  171. conR.Logger.Error("Error decoding message", "src", src, "chId", chID, "msg", msg, "err", err, "bytes", msgBytes)
  172. conR.Switch.StopPeerForError(src, err)
  173. return
  174. }
  175. conR.Logger.Debug("Receive", "src", src, "chId", chID, "msg", msg)
  176. // Get peer states
  177. ps := src.Get(types.PeerStateKey).(*PeerState)
  178. switch chID {
  179. case StateChannel:
  180. switch msg := msg.(type) {
  181. case *NewRoundStepMessage:
  182. ps.ApplyNewRoundStepMessage(msg)
  183. case *CommitStepMessage:
  184. ps.ApplyCommitStepMessage(msg)
  185. case *HasVoteMessage:
  186. ps.ApplyHasVoteMessage(msg)
  187. case *VoteSetMaj23Message:
  188. cs := conR.conS
  189. cs.mtx.Lock()
  190. height, votes := cs.Height, cs.Votes
  191. cs.mtx.Unlock()
  192. if height != msg.Height {
  193. return
  194. }
  195. // Peer claims to have a maj23 for some BlockID at H,R,S,
  196. err := votes.SetPeerMaj23(msg.Round, msg.Type, ps.peer.ID(), msg.BlockID)
  197. if err != nil {
  198. conR.Switch.StopPeerForError(src, err)
  199. return
  200. }
  201. // Respond with a VoteSetBitsMessage showing which votes we have.
  202. // (and consequently shows which we don't have)
  203. var ourVotes *cmn.BitArray
  204. switch msg.Type {
  205. case types.VoteTypePrevote:
  206. ourVotes = votes.Prevotes(msg.Round).BitArrayByBlockID(msg.BlockID)
  207. case types.VoteTypePrecommit:
  208. ourVotes = votes.Precommits(msg.Round).BitArrayByBlockID(msg.BlockID)
  209. default:
  210. conR.Logger.Error("Bad VoteSetBitsMessage field Type")
  211. return
  212. }
  213. src.TrySend(VoteSetBitsChannel, cdc.MustMarshalBinaryBare(&VoteSetBitsMessage{
  214. Height: msg.Height,
  215. Round: msg.Round,
  216. Type: msg.Type,
  217. BlockID: msg.BlockID,
  218. Votes: ourVotes,
  219. }))
  220. case *ProposalHeartbeatMessage:
  221. hb := msg.Heartbeat
  222. conR.Logger.Debug("Received proposal heartbeat message",
  223. "height", hb.Height, "round", hb.Round, "sequence", hb.Sequence,
  224. "valIdx", hb.ValidatorIndex, "valAddr", hb.ValidatorAddress)
  225. default:
  226. conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
  227. }
  228. case DataChannel:
  229. if conR.FastSync() {
  230. conR.Logger.Info("Ignoring message received during fastSync", "msg", msg)
  231. return
  232. }
  233. switch msg := msg.(type) {
  234. case *ProposalMessage:
  235. ps.SetHasProposal(msg.Proposal)
  236. conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()}
  237. case *ProposalPOLMessage:
  238. ps.ApplyProposalPOLMessage(msg)
  239. case *BlockPartMessage:
  240. ps.SetHasProposalBlockPart(msg.Height, msg.Round, msg.Part.Index)
  241. conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()}
  242. default:
  243. conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
  244. }
  245. case VoteChannel:
  246. if conR.FastSync() {
  247. conR.Logger.Info("Ignoring message received during fastSync", "msg", msg)
  248. return
  249. }
  250. switch msg := msg.(type) {
  251. case *VoteMessage:
  252. cs := conR.conS
  253. cs.mtx.Lock()
  254. height, valSize, lastCommitSize := cs.Height, cs.Validators.Size(), cs.LastCommit.Size()
  255. cs.mtx.Unlock()
  256. ps.EnsureVoteBitArrays(height, valSize)
  257. ps.EnsureVoteBitArrays(height-1, lastCommitSize)
  258. ps.SetHasVote(msg.Vote)
  259. cs.peerMsgQueue <- msgInfo{msg, src.ID()}
  260. default:
  261. // don't punish (leave room for soft upgrades)
  262. conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
  263. }
  264. case VoteSetBitsChannel:
  265. if conR.FastSync() {
  266. conR.Logger.Info("Ignoring message received during fastSync", "msg", msg)
  267. return
  268. }
  269. switch msg := msg.(type) {
  270. case *VoteSetBitsMessage:
  271. cs := conR.conS
  272. cs.mtx.Lock()
  273. height, votes := cs.Height, cs.Votes
  274. cs.mtx.Unlock()
  275. if height == msg.Height {
  276. var ourVotes *cmn.BitArray
  277. switch msg.Type {
  278. case types.VoteTypePrevote:
  279. ourVotes = votes.Prevotes(msg.Round).BitArrayByBlockID(msg.BlockID)
  280. case types.VoteTypePrecommit:
  281. ourVotes = votes.Precommits(msg.Round).BitArrayByBlockID(msg.BlockID)
  282. default:
  283. conR.Logger.Error("Bad VoteSetBitsMessage field Type")
  284. return
  285. }
  286. ps.ApplyVoteSetBitsMessage(msg, ourVotes)
  287. } else {
  288. ps.ApplyVoteSetBitsMessage(msg, nil)
  289. }
  290. default:
  291. // don't punish (leave room for soft upgrades)
  292. conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
  293. }
  294. default:
  295. conR.Logger.Error(fmt.Sprintf("Unknown chId %X", chID))
  296. }
  297. if err != nil {
  298. conR.Logger.Error("Error in Receive()", "err", err)
  299. }
  300. }
  301. // SetEventBus sets event bus.
  302. func (conR *ConsensusReactor) SetEventBus(b *types.EventBus) {
  303. conR.eventBus = b
  304. conR.conS.SetEventBus(b)
  305. }
  306. // FastSync returns whether the consensus reactor is in fast-sync mode.
  307. func (conR *ConsensusReactor) FastSync() bool {
  308. conR.mtx.RLock()
  309. defer conR.mtx.RUnlock()
  310. return conR.fastSync
  311. }
  312. //--------------------------------------
  313. // subscribeToBroadcastEvents subscribes for new round steps, votes and
  314. // proposal heartbeats using internal pubsub defined on state to broadcast
  315. // them to peers upon receiving.
  316. func (conR *ConsensusReactor) subscribeToBroadcastEvents() {
  317. const subscriber = "consensus-reactor"
  318. conR.conS.evsw.AddListenerForEvent(subscriber, types.EventNewRoundStep,
  319. func(data tmevents.EventData) {
  320. conR.broadcastNewRoundStepMessages(data.(*cstypes.RoundState))
  321. })
  322. conR.conS.evsw.AddListenerForEvent(subscriber, types.EventVote,
  323. func(data tmevents.EventData) {
  324. conR.broadcastHasVoteMessage(data.(*types.Vote))
  325. })
  326. conR.conS.evsw.AddListenerForEvent(subscriber, types.EventProposalHeartbeat,
  327. func(data tmevents.EventData) {
  328. conR.broadcastProposalHeartbeatMessage(data.(*types.Heartbeat))
  329. })
  330. }
  331. func (conR *ConsensusReactor) unsubscribeFromBroadcastEvents() {
  332. const subscriber = "consensus-reactor"
  333. conR.conS.evsw.RemoveListener(subscriber)
  334. }
  335. func (conR *ConsensusReactor) broadcastProposalHeartbeatMessage(hb *types.Heartbeat) {
  336. conR.Logger.Debug("Broadcasting proposal heartbeat message",
  337. "height", hb.Height, "round", hb.Round, "sequence", hb.Sequence)
  338. msg := &ProposalHeartbeatMessage{hb}
  339. conR.Switch.Broadcast(StateChannel, cdc.MustMarshalBinaryBare(msg))
  340. }
  341. func (conR *ConsensusReactor) broadcastNewRoundStepMessages(rs *cstypes.RoundState) {
  342. nrsMsg, csMsg := makeRoundStepMessages(rs)
  343. if nrsMsg != nil {
  344. conR.Switch.Broadcast(StateChannel, cdc.MustMarshalBinaryBare(nrsMsg))
  345. }
  346. if csMsg != nil {
  347. conR.Switch.Broadcast(StateChannel, cdc.MustMarshalBinaryBare(csMsg))
  348. }
  349. }
  350. // Broadcasts HasVoteMessage to peers that care.
  351. func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote) {
  352. msg := &HasVoteMessage{
  353. Height: vote.Height,
  354. Round: vote.Round,
  355. Type: vote.Type,
  356. Index: vote.ValidatorIndex,
  357. }
  358. conR.Switch.Broadcast(StateChannel, cdc.MustMarshalBinaryBare(msg))
  359. /*
  360. // TODO: Make this broadcast more selective.
  361. for _, peer := range conR.Switch.Peers().List() {
  362. ps := peer.Get(PeerStateKey).(*PeerState)
  363. prs := ps.GetRoundState()
  364. if prs.Height == vote.Height {
  365. // TODO: Also filter on round?
  366. peer.TrySend(StateChannel, struct{ ConsensusMessage }{msg})
  367. } else {
  368. // Height doesn't match
  369. // TODO: check a field, maybe CatchupCommitRound?
  370. // TODO: But that requires changing the struct field comment.
  371. }
  372. }
  373. */
  374. }
  375. func makeRoundStepMessages(rs *cstypes.RoundState) (nrsMsg *NewRoundStepMessage, csMsg *CommitStepMessage) {
  376. nrsMsg = &NewRoundStepMessage{
  377. Height: rs.Height,
  378. Round: rs.Round,
  379. Step: rs.Step,
  380. SecondsSinceStartTime: int(time.Since(rs.StartTime).Seconds()),
  381. LastCommitRound: rs.LastCommit.Round(),
  382. }
  383. if rs.Step == cstypes.RoundStepCommit {
  384. csMsg = &CommitStepMessage{
  385. Height: rs.Height,
  386. BlockPartsHeader: rs.ProposalBlockParts.Header(),
  387. BlockParts: rs.ProposalBlockParts.BitArray(),
  388. }
  389. }
  390. return
  391. }
  392. func (conR *ConsensusReactor) sendNewRoundStepMessages(peer p2p.Peer) {
  393. rs := conR.conS.GetRoundState()
  394. nrsMsg, csMsg := makeRoundStepMessages(rs)
  395. if nrsMsg != nil {
  396. peer.Send(StateChannel, cdc.MustMarshalBinaryBare(nrsMsg))
  397. }
  398. if csMsg != nil {
  399. peer.Send(StateChannel, cdc.MustMarshalBinaryBare(csMsg))
  400. }
  401. }
  402. func (conR *ConsensusReactor) gossipDataRoutine(peer p2p.Peer, ps *PeerState) {
  403. logger := conR.Logger.With("peer", peer)
  404. OUTER_LOOP:
  405. for {
  406. // Manage disconnects from self or peer.
  407. if !peer.IsRunning() || !conR.IsRunning() {
  408. logger.Info("Stopping gossipDataRoutine for peer")
  409. return
  410. }
  411. rs := conR.conS.GetRoundState()
  412. prs := ps.GetRoundState()
  413. // Send proposal Block parts?
  414. if rs.ProposalBlockParts.HasHeader(prs.ProposalBlockPartsHeader) {
  415. if index, ok := rs.ProposalBlockParts.BitArray().Sub(prs.ProposalBlockParts.Copy()).PickRandom(); ok {
  416. part := rs.ProposalBlockParts.GetPart(index)
  417. msg := &BlockPartMessage{
  418. Height: rs.Height, // This tells peer that this part applies to us.
  419. Round: rs.Round, // This tells peer that this part applies to us.
  420. Part: part,
  421. }
  422. logger.Debug("Sending block part", "height", prs.Height, "round", prs.Round)
  423. if peer.Send(DataChannel, cdc.MustMarshalBinaryBare(msg)) {
  424. ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
  425. }
  426. continue OUTER_LOOP
  427. }
  428. }
  429. // If the peer is on a previous height, help catch up.
  430. if (0 < prs.Height) && (prs.Height < rs.Height) {
  431. heightLogger := logger.With("height", prs.Height)
  432. // if we never received the commit message from the peer, the block parts wont be initialized
  433. if prs.ProposalBlockParts == nil {
  434. blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height)
  435. if blockMeta == nil {
  436. cmn.PanicCrisis(fmt.Sprintf("Failed to load block %d when blockStore is at %d",
  437. prs.Height, conR.conS.blockStore.Height()))
  438. }
  439. ps.InitProposalBlockParts(blockMeta.BlockID.PartsHeader)
  440. // continue the loop since prs is a copy and not effected by this initialization
  441. continue OUTER_LOOP
  442. }
  443. conR.gossipDataForCatchup(heightLogger, rs, prs, ps, peer)
  444. continue OUTER_LOOP
  445. }
  446. // If height and round don't match, sleep.
  447. if (rs.Height != prs.Height) || (rs.Round != prs.Round) {
  448. //logger.Info("Peer Height|Round mismatch, sleeping", "peerHeight", prs.Height, "peerRound", prs.Round, "peer", peer)
  449. time.Sleep(conR.conS.config.PeerGossipSleepDuration)
  450. continue OUTER_LOOP
  451. }
  452. // By here, height and round match.
  453. // Proposal block parts were already matched and sent if any were wanted.
  454. // (These can match on hash so the round doesn't matter)
  455. // Now consider sending other things, like the Proposal itself.
  456. // Send Proposal && ProposalPOL BitArray?
  457. if rs.Proposal != nil && !prs.Proposal {
  458. // Proposal: share the proposal metadata with peer.
  459. {
  460. msg := &ProposalMessage{Proposal: rs.Proposal}
  461. logger.Debug("Sending proposal", "height", prs.Height, "round", prs.Round)
  462. if peer.Send(DataChannel, cdc.MustMarshalBinaryBare(msg)) {
  463. ps.SetHasProposal(rs.Proposal)
  464. }
  465. }
  466. // ProposalPOL: lets peer know which POL votes we have so far.
  467. // Peer must receive ProposalMessage first.
  468. // rs.Proposal was validated, so rs.Proposal.POLRound <= rs.Round,
  469. // so we definitely have rs.Votes.Prevotes(rs.Proposal.POLRound).
  470. if 0 <= rs.Proposal.POLRound {
  471. msg := &ProposalPOLMessage{
  472. Height: rs.Height,
  473. ProposalPOLRound: rs.Proposal.POLRound,
  474. ProposalPOL: rs.Votes.Prevotes(rs.Proposal.POLRound).BitArray(),
  475. }
  476. logger.Debug("Sending POL", "height", prs.Height, "round", prs.Round)
  477. peer.Send(DataChannel, cdc.MustMarshalBinaryBare(msg))
  478. }
  479. continue OUTER_LOOP
  480. }
  481. // Nothing to do. Sleep.
  482. time.Sleep(conR.conS.config.PeerGossipSleepDuration)
  483. continue OUTER_LOOP
  484. }
  485. }
  486. func (conR *ConsensusReactor) gossipDataForCatchup(logger log.Logger, rs *cstypes.RoundState,
  487. prs *cstypes.PeerRoundState, ps *PeerState, peer p2p.Peer) {
  488. if index, ok := prs.ProposalBlockParts.Not().PickRandom(); ok {
  489. // Ensure that the peer's PartSetHeader is correct
  490. blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height)
  491. if blockMeta == nil {
  492. logger.Error("Failed to load block meta",
  493. "ourHeight", rs.Height, "blockstoreHeight", conR.conS.blockStore.Height())
  494. time.Sleep(conR.conS.config.PeerGossipSleepDuration)
  495. return
  496. } else if !blockMeta.BlockID.PartsHeader.Equals(prs.ProposalBlockPartsHeader) {
  497. logger.Info("Peer ProposalBlockPartsHeader mismatch, sleeping",
  498. "blockPartsHeader", blockMeta.BlockID.PartsHeader, "peerBlockPartsHeader", prs.ProposalBlockPartsHeader)
  499. time.Sleep(conR.conS.config.PeerGossipSleepDuration)
  500. return
  501. }
  502. // Load the part
  503. part := conR.conS.blockStore.LoadBlockPart(prs.Height, index)
  504. if part == nil {
  505. logger.Error("Could not load part", "index", index,
  506. "blockPartsHeader", blockMeta.BlockID.PartsHeader, "peerBlockPartsHeader", prs.ProposalBlockPartsHeader)
  507. time.Sleep(conR.conS.config.PeerGossipSleepDuration)
  508. return
  509. }
  510. // Send the part
  511. msg := &BlockPartMessage{
  512. Height: prs.Height, // Not our height, so it doesn't matter.
  513. Round: prs.Round, // Not our height, so it doesn't matter.
  514. Part: part,
  515. }
  516. logger.Debug("Sending block part for catchup", "round", prs.Round, "index", index)
  517. if peer.Send(DataChannel, cdc.MustMarshalBinaryBare(msg)) {
  518. ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
  519. } else {
  520. logger.Debug("Sending block part for catchup failed")
  521. }
  522. return
  523. }
  524. //logger.Info("No parts to send in catch-up, sleeping")
  525. time.Sleep(conR.conS.config.PeerGossipSleepDuration)
  526. }
  527. func (conR *ConsensusReactor) gossipVotesRoutine(peer p2p.Peer, ps *PeerState) {
  528. logger := conR.Logger.With("peer", peer)
  529. // Simple hack to throttle logs upon sleep.
  530. var sleeping = 0
  531. OUTER_LOOP:
  532. for {
  533. // Manage disconnects from self or peer.
  534. if !peer.IsRunning() || !conR.IsRunning() {
  535. logger.Info("Stopping gossipVotesRoutine for peer")
  536. return
  537. }
  538. rs := conR.conS.GetRoundState()
  539. prs := ps.GetRoundState()
  540. switch sleeping {
  541. case 1: // First sleep
  542. sleeping = 2
  543. case 2: // No more sleep
  544. sleeping = 0
  545. }
  546. //logger.Debug("gossipVotesRoutine", "rsHeight", rs.Height, "rsRound", rs.Round,
  547. // "prsHeight", prs.Height, "prsRound", prs.Round, "prsStep", prs.Step)
  548. // If height matches, then send LastCommit, Prevotes, Precommits.
  549. if rs.Height == prs.Height {
  550. heightLogger := logger.With("height", prs.Height)
  551. if conR.gossipVotesForHeight(heightLogger, rs, prs, ps) {
  552. continue OUTER_LOOP
  553. }
  554. }
  555. // Special catchup logic.
  556. // If peer is lagging by height 1, send LastCommit.
  557. if prs.Height != 0 && rs.Height == prs.Height+1 {
  558. if ps.PickSendVote(rs.LastCommit) {
  559. logger.Debug("Picked rs.LastCommit to send", "height", prs.Height)
  560. continue OUTER_LOOP
  561. }
  562. }
  563. // Catchup logic
  564. // If peer is lagging by more than 1, send Commit.
  565. if prs.Height != 0 && rs.Height >= prs.Height+2 {
  566. // Load the block commit for prs.Height,
  567. // which contains precommit signatures for prs.Height.
  568. commit := conR.conS.blockStore.LoadBlockCommit(prs.Height)
  569. if ps.PickSendVote(commit) {
  570. logger.Debug("Picked Catchup commit to send", "height", prs.Height)
  571. continue OUTER_LOOP
  572. }
  573. }
  574. if sleeping == 0 {
  575. // We sent nothing. Sleep...
  576. sleeping = 1
  577. logger.Debug("No votes to send, sleeping", "rs.Height", rs.Height, "prs.Height", prs.Height,
  578. "localPV", rs.Votes.Prevotes(rs.Round).BitArray(), "peerPV", prs.Prevotes,
  579. "localPC", rs.Votes.Precommits(rs.Round).BitArray(), "peerPC", prs.Precommits)
  580. } else if sleeping == 2 {
  581. // Continued sleep...
  582. sleeping = 1
  583. }
  584. time.Sleep(conR.conS.config.PeerGossipSleepDuration)
  585. continue OUTER_LOOP
  586. }
  587. }
  588. func (conR *ConsensusReactor) gossipVotesForHeight(logger log.Logger, rs *cstypes.RoundState, prs *cstypes.PeerRoundState, ps *PeerState) bool {
  589. // If there are lastCommits to send...
  590. if prs.Step == cstypes.RoundStepNewHeight {
  591. if ps.PickSendVote(rs.LastCommit) {
  592. logger.Debug("Picked rs.LastCommit to send")
  593. return true
  594. }
  595. }
  596. // If there are POL prevotes to send...
  597. if prs.Step <= cstypes.RoundStepPropose && prs.Round != -1 && prs.Round <= rs.Round && prs.ProposalPOLRound != -1 {
  598. if polPrevotes := rs.Votes.Prevotes(prs.ProposalPOLRound); polPrevotes != nil {
  599. if ps.PickSendVote(polPrevotes) {
  600. logger.Debug("Picked rs.Prevotes(prs.ProposalPOLRound) to send",
  601. "round", prs.ProposalPOLRound)
  602. return true
  603. }
  604. }
  605. }
  606. // If there are prevotes to send...
  607. if prs.Step <= cstypes.RoundStepPrevoteWait && prs.Round != -1 && prs.Round <= rs.Round {
  608. if ps.PickSendVote(rs.Votes.Prevotes(prs.Round)) {
  609. logger.Debug("Picked rs.Prevotes(prs.Round) to send", "round", prs.Round)
  610. return true
  611. }
  612. }
  613. // If there are precommits to send...
  614. if prs.Step <= cstypes.RoundStepPrecommitWait && prs.Round != -1 && prs.Round <= rs.Round {
  615. if ps.PickSendVote(rs.Votes.Precommits(prs.Round)) {
  616. logger.Debug("Picked rs.Precommits(prs.Round) to send", "round", prs.Round)
  617. return true
  618. }
  619. }
  620. // If there are prevotes to send...Needed because of validBlock mechanism
  621. if prs.Round != -1 && prs.Round <= rs.Round {
  622. if ps.PickSendVote(rs.Votes.Prevotes(prs.Round)) {
  623. logger.Debug("Picked rs.Prevotes(prs.Round) to send", "round", prs.Round)
  624. return true
  625. }
  626. }
  627. // If there are POLPrevotes to send...
  628. if prs.ProposalPOLRound != -1 {
  629. if polPrevotes := rs.Votes.Prevotes(prs.ProposalPOLRound); polPrevotes != nil {
  630. if ps.PickSendVote(polPrevotes) {
  631. logger.Debug("Picked rs.Prevotes(prs.ProposalPOLRound) to send",
  632. "round", prs.ProposalPOLRound)
  633. return true
  634. }
  635. }
  636. }
  637. return false
  638. }
  639. // NOTE: `queryMaj23Routine` has a simple crude design since it only comes
  640. // into play for liveness when there's a signature DDoS attack happening.
  641. func (conR *ConsensusReactor) queryMaj23Routine(peer p2p.Peer, ps *PeerState) {
  642. logger := conR.Logger.With("peer", peer)
  643. OUTER_LOOP:
  644. for {
  645. // Manage disconnects from self or peer.
  646. if !peer.IsRunning() || !conR.IsRunning() {
  647. logger.Info("Stopping queryMaj23Routine for peer")
  648. return
  649. }
  650. // Maybe send Height/Round/Prevotes
  651. {
  652. rs := conR.conS.GetRoundState()
  653. prs := ps.GetRoundState()
  654. if rs.Height == prs.Height {
  655. if maj23, ok := rs.Votes.Prevotes(prs.Round).TwoThirdsMajority(); ok {
  656. peer.TrySend(StateChannel, cdc.MustMarshalBinaryBare(&VoteSetMaj23Message{
  657. Height: prs.Height,
  658. Round: prs.Round,
  659. Type: types.VoteTypePrevote,
  660. BlockID: maj23,
  661. }))
  662. time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration)
  663. }
  664. }
  665. }
  666. // Maybe send Height/Round/Precommits
  667. {
  668. rs := conR.conS.GetRoundState()
  669. prs := ps.GetRoundState()
  670. if rs.Height == prs.Height {
  671. if maj23, ok := rs.Votes.Precommits(prs.Round).TwoThirdsMajority(); ok {
  672. peer.TrySend(StateChannel, cdc.MustMarshalBinaryBare(&VoteSetMaj23Message{
  673. Height: prs.Height,
  674. Round: prs.Round,
  675. Type: types.VoteTypePrecommit,
  676. BlockID: maj23,
  677. }))
  678. time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration)
  679. }
  680. }
  681. }
  682. // Maybe send Height/Round/ProposalPOL
  683. {
  684. rs := conR.conS.GetRoundState()
  685. prs := ps.GetRoundState()
  686. if rs.Height == prs.Height && prs.ProposalPOLRound >= 0 {
  687. if maj23, ok := rs.Votes.Prevotes(prs.ProposalPOLRound).TwoThirdsMajority(); ok {
  688. peer.TrySend(StateChannel, cdc.MustMarshalBinaryBare(&VoteSetMaj23Message{
  689. Height: prs.Height,
  690. Round: prs.ProposalPOLRound,
  691. Type: types.VoteTypePrevote,
  692. BlockID: maj23,
  693. }))
  694. time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration)
  695. }
  696. }
  697. }
  698. // Little point sending LastCommitRound/LastCommit,
  699. // These are fleeting and non-blocking.
  700. // Maybe send Height/CatchupCommitRound/CatchupCommit.
  701. {
  702. prs := ps.GetRoundState()
  703. if prs.CatchupCommitRound != -1 && 0 < prs.Height && prs.Height <= conR.conS.blockStore.Height() {
  704. commit := conR.conS.LoadCommit(prs.Height)
  705. peer.TrySend(StateChannel, cdc.MustMarshalBinaryBare(&VoteSetMaj23Message{
  706. Height: prs.Height,
  707. Round: commit.Round(),
  708. Type: types.VoteTypePrecommit,
  709. BlockID: commit.BlockID,
  710. }))
  711. time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration)
  712. }
  713. }
  714. time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration)
  715. continue OUTER_LOOP
  716. }
  717. }
  718. func (conR *ConsensusReactor) peerStatsRoutine() {
  719. for {
  720. if !conR.IsRunning() {
  721. conR.Logger.Info("Stopping peerStatsRoutine")
  722. return
  723. }
  724. select {
  725. case msg := <-conR.conS.statsMsgQueue:
  726. // Get peer
  727. peer := conR.Switch.Peers().Get(msg.PeerID)
  728. if peer == nil {
  729. conR.Logger.Debug("Attempt to update stats for non-existent peer",
  730. "peer", msg.PeerID)
  731. continue
  732. }
  733. // Get peer state
  734. ps := peer.Get(types.PeerStateKey).(*PeerState)
  735. switch msg.Msg.(type) {
  736. case *VoteMessage:
  737. if numVotes := ps.RecordVote(); numVotes%votesToContributeToBecomeGoodPeer == 0 {
  738. conR.Switch.MarkPeerAsGood(peer)
  739. }
  740. case *BlockPartMessage:
  741. if numParts := ps.RecordBlockPart(); numParts%blocksToContributeToBecomeGoodPeer == 0 {
  742. conR.Switch.MarkPeerAsGood(peer)
  743. }
  744. }
  745. case <-conR.conS.Quit():
  746. return
  747. case <-conR.Quit():
  748. return
  749. }
  750. }
  751. }
  752. // String returns a string representation of the ConsensusReactor.
  753. // NOTE: For now, it is just a hard-coded string to avoid accessing unprotected shared variables.
  754. // TODO: improve!
  755. func (conR *ConsensusReactor) String() string {
  756. // better not to access shared variables
  757. return "ConsensusReactor" // conR.StringIndented("")
  758. }
  759. // StringIndented returns an indented string representation of the ConsensusReactor
  760. func (conR *ConsensusReactor) StringIndented(indent string) string {
  761. s := "ConsensusReactor{\n"
  762. s += indent + " " + conR.conS.StringIndented(indent+" ") + "\n"
  763. for _, peer := range conR.Switch.Peers().List() {
  764. ps := peer.Get(types.PeerStateKey).(*PeerState)
  765. s += indent + " " + ps.StringIndented(indent+" ") + "\n"
  766. }
  767. s += indent + "}"
  768. return s
  769. }
  770. func (conR *ConsensusReactor) updateFastSyncingMetric() {
  771. var fastSyncing float64
  772. if conR.fastSync {
  773. fastSyncing = 1
  774. } else {
  775. fastSyncing = 0
  776. }
  777. conR.metrics.FastSyncing.Set(fastSyncing)
  778. }
  779. // ReactorMetrics sets the metrics
  780. func ReactorMetrics(metrics *Metrics) ReactorOption {
  781. return func(conR *ConsensusReactor) { conR.metrics = metrics }
  782. }
  783. //-----------------------------------------------------------------------------
  784. var (
  785. ErrPeerStateHeightRegression = errors.New("Error peer state height regression")
  786. ErrPeerStateInvalidStartTime = errors.New("Error peer state invalid startTime")
  787. )
  788. // PeerState contains the known state of a peer, including its connection and
  789. // threadsafe access to its PeerRoundState.
  790. // NOTE: THIS GETS DUMPED WITH rpc/core/consensus.go.
  791. // Be mindful of what you Expose.
  792. type PeerState struct {
  793. peer p2p.Peer
  794. logger log.Logger
  795. mtx sync.Mutex `json:"-"` // NOTE: Modify below using setters, never directly.
  796. PRS cstypes.PeerRoundState `json:"round_state"` // Exposed.
  797. Stats *peerStateStats `json:"stats"` // Exposed.
  798. }
  799. // peerStateStats holds internal statistics for a peer.
  800. type peerStateStats struct {
  801. Votes int `json:"votes"`
  802. BlockParts int `json:"block_parts"`
  803. }
  804. func (pss peerStateStats) String() string {
  805. return fmt.Sprintf("peerStateStats{votes: %d, blockParts: %d}",
  806. pss.Votes, pss.BlockParts)
  807. }
  808. // NewPeerState returns a new PeerState for the given Peer
  809. func NewPeerState(peer p2p.Peer) *PeerState {
  810. return &PeerState{
  811. peer: peer,
  812. logger: log.NewNopLogger(),
  813. PRS: cstypes.PeerRoundState{
  814. Round: -1,
  815. ProposalPOLRound: -1,
  816. LastCommitRound: -1,
  817. CatchupCommitRound: -1,
  818. },
  819. Stats: &peerStateStats{},
  820. }
  821. }
  822. // SetLogger allows to set a logger on the peer state. Returns the peer state
  823. // itself.
  824. func (ps *PeerState) SetLogger(logger log.Logger) *PeerState {
  825. ps.logger = logger
  826. return ps
  827. }
  828. // GetRoundState returns an shallow copy of the PeerRoundState.
  829. // There's no point in mutating it since it won't change PeerState.
  830. func (ps *PeerState) GetRoundState() *cstypes.PeerRoundState {
  831. ps.mtx.Lock()
  832. defer ps.mtx.Unlock()
  833. prs := ps.PRS // copy
  834. return &prs
  835. }
  836. // ToJSON returns a json of PeerState, marshalled using go-amino.
  837. func (ps *PeerState) ToJSON() ([]byte, error) {
  838. ps.mtx.Lock()
  839. defer ps.mtx.Unlock()
  840. return cdc.MarshalJSON(ps)
  841. }
  842. // GetHeight returns an atomic snapshot of the PeerRoundState's height
  843. // used by the mempool to ensure peers are caught up before broadcasting new txs
  844. func (ps *PeerState) GetHeight() int64 {
  845. ps.mtx.Lock()
  846. defer ps.mtx.Unlock()
  847. return ps.PRS.Height
  848. }
  849. // SetHasProposal sets the given proposal as known for the peer.
  850. func (ps *PeerState) SetHasProposal(proposal *types.Proposal) {
  851. ps.mtx.Lock()
  852. defer ps.mtx.Unlock()
  853. if ps.PRS.Height != proposal.Height || ps.PRS.Round != proposal.Round {
  854. return
  855. }
  856. if ps.PRS.Proposal {
  857. return
  858. }
  859. ps.PRS.Proposal = true
  860. ps.PRS.ProposalBlockPartsHeader = proposal.BlockPartsHeader
  861. ps.PRS.ProposalBlockParts = cmn.NewBitArray(proposal.BlockPartsHeader.Total)
  862. ps.PRS.ProposalPOLRound = proposal.POLRound
  863. ps.PRS.ProposalPOL = nil // Nil until ProposalPOLMessage received.
  864. }
  865. // InitProposalBlockParts initializes the peer's proposal block parts header and bit array.
  866. func (ps *PeerState) InitProposalBlockParts(partsHeader types.PartSetHeader) {
  867. ps.mtx.Lock()
  868. defer ps.mtx.Unlock()
  869. if ps.PRS.ProposalBlockParts != nil {
  870. return
  871. }
  872. ps.PRS.ProposalBlockPartsHeader = partsHeader
  873. ps.PRS.ProposalBlockParts = cmn.NewBitArray(partsHeader.Total)
  874. }
  875. // SetHasProposalBlockPart sets the given block part index as known for the peer.
  876. func (ps *PeerState) SetHasProposalBlockPart(height int64, round int, index int) {
  877. ps.mtx.Lock()
  878. defer ps.mtx.Unlock()
  879. if ps.PRS.Height != height || ps.PRS.Round != round {
  880. return
  881. }
  882. ps.PRS.ProposalBlockParts.SetIndex(index, true)
  883. }
  884. // PickSendVote picks a vote and sends it to the peer.
  885. // Returns true if vote was sent.
  886. func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool {
  887. if vote, ok := ps.PickVoteToSend(votes); ok {
  888. msg := &VoteMessage{vote}
  889. ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote)
  890. return ps.peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg))
  891. }
  892. return false
  893. }
  894. // PickVoteToSend picks a vote to send to the peer.
  895. // Returns true if a vote was picked.
  896. // NOTE: `votes` must be the correct Size() for the Height().
  897. func (ps *PeerState) PickVoteToSend(votes types.VoteSetReader) (vote *types.Vote, ok bool) {
  898. ps.mtx.Lock()
  899. defer ps.mtx.Unlock()
  900. if votes.Size() == 0 {
  901. return nil, false
  902. }
  903. height, round, type_, size := votes.Height(), votes.Round(), votes.Type(), votes.Size()
  904. // Lazily set data using 'votes'.
  905. if votes.IsCommit() {
  906. ps.ensureCatchupCommitRound(height, round, size)
  907. }
  908. ps.ensureVoteBitArrays(height, size)
  909. psVotes := ps.getVoteBitArray(height, round, type_)
  910. if psVotes == nil {
  911. return nil, false // Not something worth sending
  912. }
  913. if index, ok := votes.BitArray().Sub(psVotes).PickRandom(); ok {
  914. ps.setHasVote(height, round, type_, index)
  915. return votes.GetByIndex(index), true
  916. }
  917. return nil, false
  918. }
  919. func (ps *PeerState) getVoteBitArray(height int64, round int, type_ byte) *cmn.BitArray {
  920. if !types.IsVoteTypeValid(type_) {
  921. return nil
  922. }
  923. if ps.PRS.Height == height {
  924. if ps.PRS.Round == round {
  925. switch type_ {
  926. case types.VoteTypePrevote:
  927. return ps.PRS.Prevotes
  928. case types.VoteTypePrecommit:
  929. return ps.PRS.Precommits
  930. }
  931. }
  932. if ps.PRS.CatchupCommitRound == round {
  933. switch type_ {
  934. case types.VoteTypePrevote:
  935. return nil
  936. case types.VoteTypePrecommit:
  937. return ps.PRS.CatchupCommit
  938. }
  939. }
  940. if ps.PRS.ProposalPOLRound == round {
  941. switch type_ {
  942. case types.VoteTypePrevote:
  943. return ps.PRS.ProposalPOL
  944. case types.VoteTypePrecommit:
  945. return nil
  946. }
  947. }
  948. return nil
  949. }
  950. if ps.PRS.Height == height+1 {
  951. if ps.PRS.LastCommitRound == round {
  952. switch type_ {
  953. case types.VoteTypePrevote:
  954. return nil
  955. case types.VoteTypePrecommit:
  956. return ps.PRS.LastCommit
  957. }
  958. }
  959. return nil
  960. }
  961. return nil
  962. }
  963. // 'round': A round for which we have a +2/3 commit.
  964. func (ps *PeerState) ensureCatchupCommitRound(height int64, round int, numValidators int) {
  965. if ps.PRS.Height != height {
  966. return
  967. }
  968. /*
  969. NOTE: This is wrong, 'round' could change.
  970. e.g. if orig round is not the same as block LastCommit round.
  971. if ps.CatchupCommitRound != -1 && ps.CatchupCommitRound != round {
  972. cmn.PanicSanity(fmt.Sprintf("Conflicting CatchupCommitRound. Height: %v, Orig: %v, New: %v", height, ps.CatchupCommitRound, round))
  973. }
  974. */
  975. if ps.PRS.CatchupCommitRound == round {
  976. return // Nothing to do!
  977. }
  978. ps.PRS.CatchupCommitRound = round
  979. if round == ps.PRS.Round {
  980. ps.PRS.CatchupCommit = ps.PRS.Precommits
  981. } else {
  982. ps.PRS.CatchupCommit = cmn.NewBitArray(numValidators)
  983. }
  984. }
  985. // EnsureVoteBitArrays ensures the bit-arrays have been allocated for tracking
  986. // what votes this peer has received.
  987. // NOTE: It's important to make sure that numValidators actually matches
  988. // what the node sees as the number of validators for height.
  989. func (ps *PeerState) EnsureVoteBitArrays(height int64, numValidators int) {
  990. ps.mtx.Lock()
  991. defer ps.mtx.Unlock()
  992. ps.ensureVoteBitArrays(height, numValidators)
  993. }
  994. func (ps *PeerState) ensureVoteBitArrays(height int64, numValidators int) {
  995. if ps.PRS.Height == height {
  996. if ps.PRS.Prevotes == nil {
  997. ps.PRS.Prevotes = cmn.NewBitArray(numValidators)
  998. }
  999. if ps.PRS.Precommits == nil {
  1000. ps.PRS.Precommits = cmn.NewBitArray(numValidators)
  1001. }
  1002. if ps.PRS.CatchupCommit == nil {
  1003. ps.PRS.CatchupCommit = cmn.NewBitArray(numValidators)
  1004. }
  1005. if ps.PRS.ProposalPOL == nil {
  1006. ps.PRS.ProposalPOL = cmn.NewBitArray(numValidators)
  1007. }
  1008. } else if ps.PRS.Height == height+1 {
  1009. if ps.PRS.LastCommit == nil {
  1010. ps.PRS.LastCommit = cmn.NewBitArray(numValidators)
  1011. }
  1012. }
  1013. }
  1014. // RecordVote increments internal votes related statistics for this peer.
  1015. // It returns the total number of added votes.
  1016. func (ps *PeerState) RecordVote() int {
  1017. ps.mtx.Lock()
  1018. defer ps.mtx.Unlock()
  1019. ps.Stats.Votes++
  1020. return ps.Stats.Votes
  1021. }
  1022. // VotesSent returns the number of blocks for which peer has been sending us
  1023. // votes.
  1024. func (ps *PeerState) VotesSent() int {
  1025. ps.mtx.Lock()
  1026. defer ps.mtx.Unlock()
  1027. return ps.Stats.Votes
  1028. }
  1029. // RecordBlockPart increments internal block part related statistics for this peer.
  1030. // It returns the total number of added block parts.
  1031. func (ps *PeerState) RecordBlockPart() int {
  1032. ps.mtx.Lock()
  1033. defer ps.mtx.Unlock()
  1034. ps.Stats.BlockParts++
  1035. return ps.Stats.BlockParts
  1036. }
  1037. // BlockPartsSent returns the number of useful block parts the peer has sent us.
  1038. func (ps *PeerState) BlockPartsSent() int {
  1039. ps.mtx.Lock()
  1040. defer ps.mtx.Unlock()
  1041. return ps.Stats.BlockParts
  1042. }
  1043. // SetHasVote sets the given vote as known by the peer
  1044. func (ps *PeerState) SetHasVote(vote *types.Vote) {
  1045. ps.mtx.Lock()
  1046. defer ps.mtx.Unlock()
  1047. ps.setHasVote(vote.Height, vote.Round, vote.Type, vote.ValidatorIndex)
  1048. }
  1049. func (ps *PeerState) setHasVote(height int64, round int, type_ byte, index int) {
  1050. logger := ps.logger.With("peerH/R", fmt.Sprintf("%d/%d", ps.PRS.Height, ps.PRS.Round), "H/R", fmt.Sprintf("%d/%d", height, round))
  1051. logger.Debug("setHasVote", "type", type_, "index", index)
  1052. // NOTE: some may be nil BitArrays -> no side effects.
  1053. psVotes := ps.getVoteBitArray(height, round, type_)
  1054. if psVotes != nil {
  1055. psVotes.SetIndex(index, true)
  1056. }
  1057. }
  1058. // ApplyNewRoundStepMessage updates the peer state for the new round.
  1059. func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage) {
  1060. ps.mtx.Lock()
  1061. defer ps.mtx.Unlock()
  1062. // Ignore duplicates or decreases
  1063. if CompareHRS(msg.Height, msg.Round, msg.Step, ps.PRS.Height, ps.PRS.Round, ps.PRS.Step) <= 0 {
  1064. return
  1065. }
  1066. // Just remember these values.
  1067. psHeight := ps.PRS.Height
  1068. psRound := ps.PRS.Round
  1069. //psStep := ps.PRS.Step
  1070. psCatchupCommitRound := ps.PRS.CatchupCommitRound
  1071. psCatchupCommit := ps.PRS.CatchupCommit
  1072. startTime := tmtime.Now().Add(-1 * time.Duration(msg.SecondsSinceStartTime) * time.Second)
  1073. ps.PRS.Height = msg.Height
  1074. ps.PRS.Round = msg.Round
  1075. ps.PRS.Step = msg.Step
  1076. ps.PRS.StartTime = startTime
  1077. if psHeight != msg.Height || psRound != msg.Round {
  1078. ps.PRS.Proposal = false
  1079. ps.PRS.ProposalBlockPartsHeader = types.PartSetHeader{}
  1080. ps.PRS.ProposalBlockParts = nil
  1081. ps.PRS.ProposalPOLRound = -1
  1082. ps.PRS.ProposalPOL = nil
  1083. // We'll update the BitArray capacity later.
  1084. ps.PRS.Prevotes = nil
  1085. ps.PRS.Precommits = nil
  1086. }
  1087. if psHeight == msg.Height && psRound != msg.Round && msg.Round == psCatchupCommitRound {
  1088. // Peer caught up to CatchupCommitRound.
  1089. // Preserve psCatchupCommit!
  1090. // NOTE: We prefer to use prs.Precommits if
  1091. // pr.Round matches pr.CatchupCommitRound.
  1092. ps.PRS.Precommits = psCatchupCommit
  1093. }
  1094. if psHeight != msg.Height {
  1095. // Shift Precommits to LastCommit.
  1096. if psHeight+1 == msg.Height && psRound == msg.LastCommitRound {
  1097. ps.PRS.LastCommitRound = msg.LastCommitRound
  1098. ps.PRS.LastCommit = ps.PRS.Precommits
  1099. } else {
  1100. ps.PRS.LastCommitRound = msg.LastCommitRound
  1101. ps.PRS.LastCommit = nil
  1102. }
  1103. // We'll update the BitArray capacity later.
  1104. ps.PRS.CatchupCommitRound = -1
  1105. ps.PRS.CatchupCommit = nil
  1106. }
  1107. }
  1108. // ApplyCommitStepMessage updates the peer state for the new commit.
  1109. func (ps *PeerState) ApplyCommitStepMessage(msg *CommitStepMessage) {
  1110. ps.mtx.Lock()
  1111. defer ps.mtx.Unlock()
  1112. if ps.PRS.Height != msg.Height {
  1113. return
  1114. }
  1115. ps.PRS.ProposalBlockPartsHeader = msg.BlockPartsHeader
  1116. ps.PRS.ProposalBlockParts = msg.BlockParts
  1117. }
  1118. // ApplyProposalPOLMessage updates the peer state for the new proposal POL.
  1119. func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage) {
  1120. ps.mtx.Lock()
  1121. defer ps.mtx.Unlock()
  1122. if ps.PRS.Height != msg.Height {
  1123. return
  1124. }
  1125. if ps.PRS.ProposalPOLRound != msg.ProposalPOLRound {
  1126. return
  1127. }
  1128. // TODO: Merge onto existing ps.PRS.ProposalPOL?
  1129. // We might have sent some prevotes in the meantime.
  1130. ps.PRS.ProposalPOL = msg.ProposalPOL
  1131. }
  1132. // ApplyHasVoteMessage updates the peer state for the new vote.
  1133. func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage) {
  1134. ps.mtx.Lock()
  1135. defer ps.mtx.Unlock()
  1136. if ps.PRS.Height != msg.Height {
  1137. return
  1138. }
  1139. ps.setHasVote(msg.Height, msg.Round, msg.Type, msg.Index)
  1140. }
  1141. // ApplyVoteSetBitsMessage updates the peer state for the bit-array of votes
  1142. // it claims to have for the corresponding BlockID.
  1143. // `ourVotes` is a BitArray of votes we have for msg.BlockID
  1144. // NOTE: if ourVotes is nil (e.g. msg.Height < rs.Height),
  1145. // we conservatively overwrite ps's votes w/ msg.Votes.
  1146. func (ps *PeerState) ApplyVoteSetBitsMessage(msg *VoteSetBitsMessage, ourVotes *cmn.BitArray) {
  1147. ps.mtx.Lock()
  1148. defer ps.mtx.Unlock()
  1149. votes := ps.getVoteBitArray(msg.Height, msg.Round, msg.Type)
  1150. if votes != nil {
  1151. if ourVotes == nil {
  1152. votes.Update(msg.Votes)
  1153. } else {
  1154. otherVotes := votes.Sub(ourVotes)
  1155. hasVotes := otherVotes.Or(msg.Votes)
  1156. votes.Update(hasVotes)
  1157. }
  1158. }
  1159. }
  1160. // String returns a string representation of the PeerState
  1161. func (ps *PeerState) String() string {
  1162. return ps.StringIndented("")
  1163. }
  1164. // StringIndented returns a string representation of the PeerState
  1165. func (ps *PeerState) StringIndented(indent string) string {
  1166. ps.mtx.Lock()
  1167. defer ps.mtx.Unlock()
  1168. return fmt.Sprintf(`PeerState{
  1169. %s Key %v
  1170. %s RoundState %v
  1171. %s Stats %v
  1172. %s}`,
  1173. indent, ps.peer.ID(),
  1174. indent, ps.PRS.StringIndented(indent+" "),
  1175. indent, ps.Stats,
  1176. indent)
  1177. }
  1178. //-----------------------------------------------------------------------------
  1179. // Messages
  1180. // ConsensusMessage is a message that can be sent and received on the ConsensusReactor
  1181. type ConsensusMessage interface{}
  1182. func RegisterConsensusMessages(cdc *amino.Codec) {
  1183. cdc.RegisterInterface((*ConsensusMessage)(nil), nil)
  1184. cdc.RegisterConcrete(&NewRoundStepMessage{}, "tendermint/NewRoundStepMessage", nil)
  1185. cdc.RegisterConcrete(&CommitStepMessage{}, "tendermint/CommitStep", nil)
  1186. cdc.RegisterConcrete(&ProposalMessage{}, "tendermint/Proposal", nil)
  1187. cdc.RegisterConcrete(&ProposalPOLMessage{}, "tendermint/ProposalPOL", nil)
  1188. cdc.RegisterConcrete(&BlockPartMessage{}, "tendermint/BlockPart", nil)
  1189. cdc.RegisterConcrete(&VoteMessage{}, "tendermint/Vote", nil)
  1190. cdc.RegisterConcrete(&HasVoteMessage{}, "tendermint/HasVote", nil)
  1191. cdc.RegisterConcrete(&VoteSetMaj23Message{}, "tendermint/VoteSetMaj23", nil)
  1192. cdc.RegisterConcrete(&VoteSetBitsMessage{}, "tendermint/VoteSetBits", nil)
  1193. cdc.RegisterConcrete(&ProposalHeartbeatMessage{}, "tendermint/ProposalHeartbeat", nil)
  1194. }
  1195. func decodeMsg(bz []byte) (msg ConsensusMessage, err error) {
  1196. if len(bz) > maxMsgSize {
  1197. return msg, fmt.Errorf("Msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
  1198. }
  1199. err = cdc.UnmarshalBinaryBare(bz, &msg)
  1200. return
  1201. }
  1202. //-------------------------------------
  1203. // NewRoundStepMessage is sent for every step taken in the ConsensusState.
  1204. // For every height/round/step transition
  1205. type NewRoundStepMessage struct {
  1206. Height int64
  1207. Round int
  1208. Step cstypes.RoundStepType
  1209. SecondsSinceStartTime int
  1210. LastCommitRound int
  1211. }
  1212. // String returns a string representation.
  1213. func (m *NewRoundStepMessage) String() string {
  1214. return fmt.Sprintf("[NewRoundStep H:%v R:%v S:%v LCR:%v]",
  1215. m.Height, m.Round, m.Step, m.LastCommitRound)
  1216. }
  1217. //-------------------------------------
  1218. // CommitStepMessage is sent when a block is committed.
  1219. type CommitStepMessage struct {
  1220. Height int64
  1221. BlockPartsHeader types.PartSetHeader
  1222. BlockParts *cmn.BitArray
  1223. }
  1224. // String returns a string representation.
  1225. func (m *CommitStepMessage) String() string {
  1226. return fmt.Sprintf("[CommitStep H:%v BP:%v BA:%v]", m.Height, m.BlockPartsHeader, m.BlockParts)
  1227. }
  1228. //-------------------------------------
  1229. // ProposalMessage is sent when a new block is proposed.
  1230. type ProposalMessage struct {
  1231. Proposal *types.Proposal
  1232. }
  1233. // String returns a string representation.
  1234. func (m *ProposalMessage) String() string {
  1235. return fmt.Sprintf("[Proposal %v]", m.Proposal)
  1236. }
  1237. //-------------------------------------
  1238. // ProposalPOLMessage is sent when a previous proposal is re-proposed.
  1239. type ProposalPOLMessage struct {
  1240. Height int64
  1241. ProposalPOLRound int
  1242. ProposalPOL *cmn.BitArray
  1243. }
  1244. // String returns a string representation.
  1245. func (m *ProposalPOLMessage) String() string {
  1246. return fmt.Sprintf("[ProposalPOL H:%v POLR:%v POL:%v]", m.Height, m.ProposalPOLRound, m.ProposalPOL)
  1247. }
  1248. //-------------------------------------
  1249. // BlockPartMessage is sent when gossipping a piece of the proposed block.
  1250. type BlockPartMessage struct {
  1251. Height int64
  1252. Round int
  1253. Part *types.Part
  1254. }
  1255. // String returns a string representation.
  1256. func (m *BlockPartMessage) String() string {
  1257. return fmt.Sprintf("[BlockPart H:%v R:%v P:%v]", m.Height, m.Round, m.Part)
  1258. }
  1259. //-------------------------------------
  1260. // VoteMessage is sent when voting for a proposal (or lack thereof).
  1261. type VoteMessage struct {
  1262. Vote *types.Vote
  1263. }
  1264. // String returns a string representation.
  1265. func (m *VoteMessage) String() string {
  1266. return fmt.Sprintf("[Vote %v]", m.Vote)
  1267. }
  1268. //-------------------------------------
  1269. // HasVoteMessage is sent to indicate that a particular vote has been received.
  1270. type HasVoteMessage struct {
  1271. Height int64
  1272. Round int
  1273. Type byte
  1274. Index int
  1275. }
  1276. // String returns a string representation.
  1277. func (m *HasVoteMessage) String() string {
  1278. return fmt.Sprintf("[HasVote VI:%v V:{%v/%02d/%v}]", m.Index, m.Height, m.Round, m.Type)
  1279. }
  1280. //-------------------------------------
  1281. // VoteSetMaj23Message is sent to indicate that a given BlockID has seen +2/3 votes.
  1282. type VoteSetMaj23Message struct {
  1283. Height int64
  1284. Round int
  1285. Type byte
  1286. BlockID types.BlockID
  1287. }
  1288. // String returns a string representation.
  1289. func (m *VoteSetMaj23Message) String() string {
  1290. return fmt.Sprintf("[VSM23 %v/%02d/%v %v]", m.Height, m.Round, m.Type, m.BlockID)
  1291. }
  1292. //-------------------------------------
  1293. // VoteSetBitsMessage is sent to communicate the bit-array of votes seen for the BlockID.
  1294. type VoteSetBitsMessage struct {
  1295. Height int64
  1296. Round int
  1297. Type byte
  1298. BlockID types.BlockID
  1299. Votes *cmn.BitArray
  1300. }
  1301. // String returns a string representation.
  1302. func (m *VoteSetBitsMessage) String() string {
  1303. return fmt.Sprintf("[VSB %v/%02d/%v %v %v]", m.Height, m.Round, m.Type, m.BlockID, m.Votes)
  1304. }
  1305. //-------------------------------------
  1306. // ProposalHeartbeatMessage is sent to signal that a node is alive and waiting for transactions for a proposal.
  1307. type ProposalHeartbeatMessage struct {
  1308. Heartbeat *types.Heartbeat
  1309. }
  1310. // String returns a string representation.
  1311. func (m *ProposalHeartbeatMessage) String() string {
  1312. return fmt.Sprintf("[HEARTBEAT %v]", m.Heartbeat)
  1313. }