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