diff --git a/consensus/reactor.go b/consensus/reactor.go index a1d7f025e..62535388e 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -437,7 +437,6 @@ func makeRoundStepMessages(rs *cstypes.RoundState) (nrsMsg *NewRoundStepMessage, if rs.Step == cstypes.RoundStepCommit { csMsg = &CommitStepMessage{ Height: rs.Height, - Time: rs.CommitTime, BlockPartsHeader: rs.ProposalBlockParts.Header(), BlockParts: rs.ProposalBlockParts.BitArray(), } @@ -956,14 +955,6 @@ func (ps *PeerState) GetHeight() int64 { return ps.PRS.Height } -// GetLastBlockTime returns an atomic snapshot of the PeerRoundState's last -// block time used by the evidence reactor when sending evidence. -func (ps *PeerState) GetLastBlockTime() time.Time { - ps.mtx.Lock() - defer ps.mtx.Unlock() - return ps.PRS.LastBlockTime -} - // SetHasProposal sets the given proposal as known for the peer. func (ps *PeerState) SetHasProposal(proposal *types.Proposal) { ps.mtx.Lock() @@ -1271,7 +1262,6 @@ func (ps *PeerState) ApplyCommitStepMessage(msg *CommitStepMessage) { ps.PRS.ProposalBlockPartsHeader = msg.BlockPartsHeader ps.PRS.ProposalBlockParts = msg.BlockParts - ps.PRS.LastBlockTime = msg.Time } // ApplyProposalPOLMessage updates the peer state for the new proposal POL. @@ -1395,14 +1385,13 @@ func (m *NewRoundStepMessage) String() string { // CommitStepMessage is sent when a block is committed. type CommitStepMessage struct { Height int64 - Time time.Time BlockPartsHeader types.PartSetHeader BlockParts *cmn.BitArray } // String returns a string representation. func (m *CommitStepMessage) String() string { - return fmt.Sprintf("[CommitStep H:%v T:%v BP:%v BA:%v]", m.Height, m.Time, m.BlockPartsHeader, m.BlockParts) + return fmt.Sprintf("[CommitStep H:%v BP:%v BA:%v]", m.Height, m.BlockPartsHeader, m.BlockParts) } //------------------------------------- diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 8e3ab3456..2758f3fab 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -25,7 +25,6 @@ import ( "github.com/tendermint/tendermint/p2p" sm "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" ) func init() { @@ -267,36 +266,6 @@ func TestReactorRecordsVotesAndBlockParts(t *testing.T) { assert.Equal(t, true, ps.BlockPartsSent() > 0, "number of votes sent should have increased") } -// Test we record last block times from other peers. -func TestReactorRecordsLastBlockTime(t *testing.T) { - timeStart := tmtime.Now() - - N := 4 - css := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter) - reactors, eventChans, eventBuses := startConsensusNet(t, css, N) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) - - // Wait a couple of blocks. - timeoutWaitGroup(t, N, func(j int) { - <-eventChans[j] - }, css) - timeoutWaitGroup(t, N, func(j int) { - <-eventChans[j] - }, css) - - // Get peer - peer := reactors[1].Switch.Peers().List()[0] - // Get peer state - ps := peer.Get(types.PeerStateKey).(*PeerState) - - assert.NotNil(t, ps.GetLastBlockTime()) - assert.True(t, ps.GetLastBlockTime().After(timeStart), - "LastBlockTime should be some time after the time we started tests (%v), got %v", - timeStart, - ps.GetLastBlockTime(), - ) -} - //------------------------------------------------------------- // ensure we can make blocks despite cycling a validator set diff --git a/consensus/types/peer_round_state.go b/consensus/types/peer_round_state.go index 991f27ca4..e42395bc3 100644 --- a/consensus/types/peer_round_state.go +++ b/consensus/types/peer_round_state.go @@ -14,7 +14,6 @@ import ( // NOTE: Read-only when returned by PeerState.GetRoundState(). type PeerRoundState struct { Height int64 `json:"height"` // Height peer is at - LastBlockTime time.Time `json:"last_block_time"` // Time the last block was created at. Round int `json:"round"` // Round peer is at, -1 if unknown. Step RoundStepType `json:"step"` // Step peer is at StartTime time.Time `json:"start_time"` // Estimated start of round 0 at this height @@ -39,7 +38,7 @@ func (prs PeerRoundState) String() string { // StringIndented returns a string representation of the PeerRoundState func (prs PeerRoundState) StringIndented(indent string) string { return fmt.Sprintf(`PeerRoundState{ -%s %v/%v/%v @%v (last block time @%v) +%s %v/%v/%v @%v %s Proposal %v -> %v %s POL %v (round %v) %s Prevotes %v @@ -47,7 +46,7 @@ func (prs PeerRoundState) StringIndented(indent string) string { %s LastCommit %v (round %v) %s Catchup %v (round %v) %s}`, - indent, prs.Height, prs.Round, prs.Step, prs.StartTime, prs.LastBlockTime, + indent, prs.Height, prs.Round, prs.Step, prs.StartTime, indent, prs.ProposalBlockPartsHeader, prs.ProposalBlockParts, indent, prs.ProposalPOL, prs.ProposalPOLRound, indent, prs.Prevotes, diff --git a/evidence/reactor.go b/evidence/reactor.go index 5384fe40f..dcff8c403 100644 --- a/evidence/reactor.go +++ b/evidence/reactor.go @@ -153,29 +153,17 @@ func (evR *EvidenceReactor) broadcastEvidenceRoutine(peer p2p.Peer) { // Returns the message to send the peer, or nil if the evidence is invalid for the peer. // If message is nil, return true if we should sleep and try again. func (evR EvidenceReactor) checkSendEvidenceMessage(peer p2p.Peer, ev types.Evidence) (msg EvidenceMessage, retry bool) { - - // make sure the peer is up to date - evHeight := ev.Height() peerState, ok := peer.Get(types.PeerStateKey).(PeerState) if !ok { evR.Logger.Info("Found peer without PeerState", "peer", peer) return nil, true } - // NOTE: We only send evidence to peers where - // peerHeight - maxAge < evidenceHeight < peerHeight - maxAge := evR.evpool.State().ConsensusParams.EvidenceParams.MaxAge + // NOTE: We only send evidence to peers where evidenceHeight < peerHeight peerHeight := peerState.GetHeight() - peerLastBlockTime := peerState.GetLastBlockTime() - if peerHeight < evHeight { + if peerHeight < ev.Height() { // peer is behind. sleep while he catches up return nil, true - } else if peerLastBlockTime.Sub(ev.Time()) > maxAge { - // evidence is too old, skip - // NOTE: if evidence is too old for an honest peer, - // then we're behind and either it already got committed or it never will! - evR.Logger.Info("Not sending peer old evidence", "peerHeight", peerHeight, "evHeight", evHeight, "maxAge", maxAge, "peer", peer) - return nil, false } // send evidence @@ -186,7 +174,6 @@ func (evR EvidenceReactor) checkSendEvidenceMessage(peer p2p.Peer, ev types.Evid // PeerState describes the state of a peer. type PeerState interface { GetHeight() int64 - GetLastBlockTime() time.Time } //----------------------------------------------------------------------------- diff --git a/evidence/reactor_test.go b/evidence/reactor_test.go index 677897e03..ea948f032 100644 --- a/evidence/reactor_test.go +++ b/evidence/reactor_test.go @@ -14,7 +14,6 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" ) // evidenceLogger is a TestingLogger which uses a different @@ -133,7 +132,7 @@ func TestReactorBroadcastEvidence(t *testing.T) { // set the peer height on each reactor for _, r := range reactors { for _, peer := range r.Switch.Peers().List() { - ps := testPeerState{height, tmtime.Now()} + ps := testPeerState{height} peer.Set(types.PeerStateKey, ps) } } @@ -146,7 +145,6 @@ func TestReactorBroadcastEvidence(t *testing.T) { type testPeerState struct { height int64 - time time.Time } var _ PeerState = (*testPeerState)(nil) @@ -155,10 +153,6 @@ func (ps testPeerState) GetHeight() int64 { return ps.height } -func (ps testPeerState) GetLastBlockTime() time.Time { - return ps.time -} - func TestReactorSelectiveBroadcast(t *testing.T) { config := cfg.TestConfig() @@ -173,7 +167,7 @@ func TestReactorSelectiveBroadcast(t *testing.T) { // make reactors from statedb reactors := makeAndConnectEvidenceReactors(config, []dbm.DB{stateDB1, stateDB2}) peer := reactors[0].Switch.Peers().List()[0] - ps := testPeerState{height2, tmtime.Now()} + ps := testPeerState{height2} peer.Set(types.PeerStateKey, ps) // send a bunch of valid evidence to the first reactor's evpool