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.

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