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.

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