Browse Source

minimal

pull/8127/head
tycho garen 3 years ago
committed by M. J. Fromberger
parent
commit
4ced364442
3 changed files with 17 additions and 9 deletions
  1. +4
    -2
      internal/consensus/invalid_test.go
  2. +8
    -3
      internal/consensus/reactor.go
  3. +5
    -4
      internal/consensus/state.go

+ 4
- 2
internal/consensus/invalid_test.go View File

@ -91,9 +91,11 @@ func TestReactorInvalidPrecommit(t *testing.T) {
t.Fatal("test condition did not fire")
}
case <-ctx.Done():
if _, ok := <-signal; !ok {
select {
case <-signal:
// pass
default:
t.Fatal("test condition did not fire after timeout")
return
}
case <-signal:
// test passed


+ 8
- 3
internal/consensus/reactor.go View File

@ -865,10 +865,15 @@ func (r *Reactor) queryMaj23Routine(ctx context.Context, ps *PeerState) {
return
}
rs := r.getRoundState()
prs := ps.GetRoundState()
// TODO create more reliable coppies of these
// structures so the following go routines don't race
rs := r.state.GetRoundState()
prs := ps.GetRoundState()
select {
case <-ctx.Done():
return
default:
}
wg := &sync.WaitGroup{}
@ -1027,7 +1032,7 @@ func (r *Reactor) processPeerUpdate(ctx context.Context, peerUpdate p2p.PeerUpda
// Send our state to the peer. If we're block-syncing, broadcast a
// RoundStepMessage later upon SwitchToConsensus().
if !r.WaitSync() {
go func() { _ = r.sendNewRoundStepMessage(ctx, ps.peerID) }()
_ = r.sendNewRoundStepMessage(ctx, ps.peerID)
}
}()


+ 5
- 4
internal/consensus/state.go View File

@ -286,9 +286,9 @@ func (cs *State) GetRoundState() *cstypes.RoundState {
cs.mtx.RLock()
defer cs.mtx.RUnlock()
// NOTE: this might be dodgy, as RoundState itself isn't thread
// safe as it contains a number of pointers and is explicitly
// not thread safe.
// NOTE: this is probably be dodgy, as RoundState isn't thread
// safe as it contains a number of pointers which make the
// resulting object shared anyway
rs := cs.RoundState // copy
return &rs
}
@ -351,8 +351,9 @@ func (cs *State) SetPrivValidator(ctx context.Context, priv types.PrivValidator)
// testing.
func (cs *State) SetTimeoutTicker(timeoutTicker TimeoutTicker) {
cs.mtx.Lock()
defer cs.mtx.Unlock()
cs.timeoutTicker = timeoutTicker
cs.mtx.Unlock()
}
// LoadCommit loads the commit for a given height.


Loading…
Cancel
Save