fix some races
This commit is contained in:
parent
98f4d37f1a
commit
efdb854a7c
@ -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"
|
||||
|
17
extern/sector-storage/manager_post.go
vendored
17
extern/sector-storage/manager_post.go
vendored
@ -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)
|
||||
|
15
extern/sector-storage/worker_local.go
vendored
15
extern/sector-storage/worker_local.go
vendored
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user