From 6d18e2f447b98f049cfb3d0459aff2bbccbf591b Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 27 Oct 2017 13:59:01 +0300 Subject: [PATCH] do not send whole round state via eventHub Fixes ``` WARNING: DATA RACE Write at 0x00c4200715b8 by goroutine 24: github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrevote.func1() /go/src/github.com/tendermint/tendermint/consensus/state.go:359 +0x3f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrevote() /go/src/github.com/tendermint/tendermint/consensus/state.go:897 +0x8de github.com/tendermint/tendermint/consensus.(*ConsensusState).addProposalBlockPart() /go/src/github.com/tendermint/tendermint/consensus/state.go:1303 +0x701 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /go/src/github.com/tendermint/tendermint/consensus/state.go:560 +0x88c github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /go/src/github.com/tendermint/tendermint/consensus/state.go:525 +0x6d2 Previous read at 0x00c4200715b8 by goroutine 19: github.com/tendermint/tendermint/consensus.makeRoundStepMessages() /go/src/github.com/tendermint/tendermint/consensus/reactor.go:415 +0x192 github.com/tendermint/tendermint/consensus.(*ConsensusReactor).broadcastNewRoundStep() /go/src/github.com/tendermint/tendermint/consensus/reactor.go:377 +0x3c github.com/tendermint/tendermint/consensus.(*ConsensusReactor).broadcastNewRoundStepsAndVotes.func1() /go/src/github.com/tendermint/tendermint/consensus/reactor.go:350 +0x275 ``` --- consensus/types/state.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/consensus/types/state.go b/consensus/types/state.go index 0e6b15778..2276d00cc 100644 --- a/consensus/types/state.go +++ b/consensus/types/state.go @@ -77,10 +77,20 @@ type RoundState struct { // RoundStateEvent returns the H/R/S of the RoundState as an event. func (rs *RoundState) RoundStateEvent() types.EventDataRoundState { edrs := types.EventDataRoundState{ - Height: rs.Height, - Round: rs.Round, - Step: rs.Step.String(), - RoundState: rs, + Height: rs.Height, + Round: rs.Round, + Step: rs.Step.String(), + // send only fields needed by makeRoundStepMessages + RoundState: &RoundState{ + Height: rs.Height, + Round: rs.Round, + Step: rs.Step, + StartTime: rs.StartTime, + LastCommit: rs.LastCommit, + LockedBlock: rs.LockedBlock, // consensus/state_test.go#L398 + ProposalBlock: rs.ProposalBlock, // consensus/state_test.go#L253 + ProposalBlockParts: rs.ProposalBlockParts, + }, } return edrs }