fix some races
This commit is contained in:
parent
98f4d37f1a
commit
efdb854a7c
@ -10,14 +10,13 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
"io"
|
"io"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
|
|
||||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
|
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
|
||||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
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)
|
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)
|
proofList := make([]ffi.PartitionProof, partitionCount)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(int(partitionCount))
|
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)
|
p, sk, err := m.generatePartitionWindowPost(cctx, spt, ppt, minerID, int(partIdx), sectors, randomness)
|
||||||
if len(sk) > 0 {
|
if err != nil || len(sk) > 0 {
|
||||||
log.Errorf("generateWindowPost part:%d, skipped:%d, err: %+v", partIdx, len(sk), err)
|
log.Errorf("generateWindowPost part:%d, skipped:%d, sectors: %d, err: %+v", partIdx, len(sk), len(sectors), err)
|
||||||
flk.Lock()
|
flk.Lock()
|
||||||
skipped = append(skipped, sk...)
|
skipped = append(skipped, sk...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
retErr = multierror.Append(retErr, xerrors.Errorf("partitionCount:%d err:%+v", partIdx, err))
|
||||||
|
return
|
||||||
|
}
|
||||||
flk.Unlock()
|
flk.Unlock()
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
retErr = multierror.Append(retErr, xerrors.Errorf("partitionCount:%d err:%+v", partIdx, err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
proofList[partIdx] = ffi.PartitionProof(p)
|
proofList[partIdx] = ffi.PartitionProof(p)
|
||||||
}(partIdx)
|
}(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)
|
// todo context with tighter deadline (+config)
|
||||||
vanilla, err := l.storage.GenerateSingleVanillaProof(ctx, mid, s, ppt)
|
vanilla, err := l.storage.GenerateSingleVanillaProof(ctx, mid, s, ppt)
|
||||||
|
slk.Lock()
|
||||||
|
defer slk.Unlock()
|
||||||
|
|
||||||
if err != nil || vanilla == nil {
|
if err != nil || vanilla == nil {
|
||||||
slk.Lock()
|
|
||||||
skipped = append(skipped, abi.SectorID{
|
skipped = append(skipped, abi.SectorID{
|
||||||
Miner: mid,
|
Miner: mid,
|
||||||
Number: s.SectorNumber,
|
Number: s.SectorNumber,
|
||||||
})
|
})
|
||||||
slk.Unlock()
|
|
||||||
log.Errorf("get sector: %d, vanilla: %s, err: %s", s.SectorNumber, vanilla, err)
|
log.Errorf("get sector: %d, vanilla: %s, err: %s", s.SectorNumber, vanilla, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
vproofs[i] = vanilla
|
vproofs[i] = vanilla
|
||||||
}(i, s)
|
}(i, s)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
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)
|
res, err := sb.GenerateWindowPoStWithVanilla(ctx, ppt, mid, randomness, vproofs, partitionIdx)
|
||||||
|
|
||||||
return storiface.WindowPoStResult{
|
return storiface.WindowPoStResult{
|
||||||
|
Loading…
Reference in New Issue
Block a user