Browse Source

avoid deadlock

pull/8091/head
tycho garen 3 years ago
parent
commit
ecb3a50b47
2 changed files with 5 additions and 5 deletions
  1. +0
    -1
      internal/consensus/common_test.go
  2. +5
    -4
      internal/consensus/state.go

+ 0
- 1
internal/consensus/common_test.go View File

@ -224,7 +224,6 @@ func sortVValidatorStubsByPower(ctx context.Context, t *testing.T, vss []*valida
func startTestRound(ctx context.Context, cs *State, height int64, round int32) { func startTestRound(ctx context.Context, cs *State, height int64, round int32) {
cs.enterNewRound(ctx, height, round) cs.enterNewRound(ctx, height, round)
cs.startRoutines(ctx, 0)
} }
// Create proposal block from cs1 but sign it with vs. // Create proposal block from cs1 but sign it with vs.


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

@ -931,9 +931,6 @@ func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) {
// state transitions on complete-proposal, 2/3-any, 2/3-one // state transitions on complete-proposal, 2/3-any, 2/3-one
func (cs *State) handleMsg(ctx context.Context, mi msgInfo) { func (cs *State) handleMsg(ctx context.Context, mi msgInfo) {
cs.mtx.Lock()
defer cs.mtx.Unlock()
var ( var (
added bool added bool
err error err error
@ -2079,7 +2076,11 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal, recvTime time.Time
// TODO: We can check if Proposal is for a different block as this is a sign of misbehavior! // TODO: We can check if Proposal is for a different block as this is a sign of misbehavior!
if cs.ProposalBlockParts == nil { if cs.ProposalBlockParts == nil {
cs.metrics.MarkBlockGossipStarted() cs.metrics.MarkBlockGossipStarted()
cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartSetHeader)
func() {
cs.mtx.Lock()
defer cs.mtx.Unlock()
cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartSetHeader)
}()
} }
cs.logger.Info("received proposal", "proposal", proposal) cs.logger.Info("received proposal", "proposal", proposal)


Loading…
Cancel
Save