fix some races

This commit is contained in:
Łukasz Magiera 2022-01-31 20:53:25 +00:00
parent 98f4d37f1a
commit efdb854a7c
3 changed files with 26 additions and 11 deletions

View File

@ -10,14 +10,13 @@ import (
"crypto/rand"
"encoding/base64"
"encoding/json"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
"io"
"math/bits"
"os"
"runtime"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
ffi "github.com/filecoin-project/filecoin-ffi"
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
commcid "github.com/filecoin-project/go-fil-commcid"

View File

@ -134,6 +134,10 @@ func (m *Manager) generateWindowPoSt(ctx context.Context, minerID abi.ActorID, s
return nil, nil, xerrors.Errorf("generating fallback challenges: %v", err)
}
sort.Slice(postChallenges.Sectors, func(i, j int) bool {
return postChallenges.Sectors[i] < postChallenges.Sectors[j]
})
proofList := make([]ffi.PartitionProof, partitionCount)
var wg sync.WaitGroup
wg.Add(int(partitionCount))
@ -162,16 +166,17 @@ func (m *Manager) generateWindowPoSt(ctx context.Context, minerID abi.ActorID, s
}
p, sk, err := m.generatePartitionWindowPost(cctx, spt, ppt, minerID, int(partIdx), sectors, randomness)
if len(sk) > 0 {
log.Errorf("generateWindowPost part:%d, skipped:%d, err: %+v", partIdx, len(sk), err)
if err != nil || len(sk) > 0 {
log.Errorf("generateWindowPost part:%d, skipped:%d, sectors: %d, err: %+v", partIdx, len(sk), len(sectors), err)
flk.Lock()
skipped = append(skipped, sk...)
if err != nil {
retErr = multierror.Append(retErr, xerrors.Errorf("partitionCount:%d err:%+v", partIdx, err))
return
}
flk.Unlock()
}
if err != nil {
retErr = multierror.Append(retErr, xerrors.Errorf("partitionCount:%d err:%+v", partIdx, err))
return
}
proofList[partIdx] = ffi.PartitionProof(p)
}(partIdx)

View File

@ -568,21 +568,32 @@ func (l *LocalWorker) GenerateWindowPoSt(ctx context.Context, ppt abi.Registered
// todo context with tighter deadline (+config)
vanilla, err := l.storage.GenerateSingleVanillaProof(ctx, mid, s, ppt)
slk.Lock()
defer slk.Unlock()
if err != nil || vanilla == nil {
slk.Lock()
skipped = append(skipped, abi.SectorID{
Miner: mid,
Number: s.SectorNumber,
})
slk.Unlock()
log.Errorf("get sector: %d, vanilla: %s, err: %s", s.SectorNumber, vanilla, err)
return
}
vproofs[i] = vanilla
}(i, s)
}
wg.Wait()
var at = 0
for i := range vproofs {
if vproofs[i] != nil {
vproofs[at] = vproofs[i]
at++
}
}
vproofs = vproofs[:at]
res, err := sb.GenerateWindowPoStWithVanilla(ctx, ppt, mid, randomness, vproofs, partitionIdx)
return storiface.WindowPoStResult{