Merge pull request #11551 from filecoin-project/backports-v1252
chore: backports to `release/v1.25.2`
This commit is contained in:
commit
3ae362c81d
@ -886,6 +886,35 @@ func (syncer *Syncer) syncFork(ctx context.Context, incoming *types.TipSet, know
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
incomingParentsTsk := incoming.Parents()
|
||||||
|
commonParent := false
|
||||||
|
for _, incomingParent := range incomingParentsTsk.Cids() {
|
||||||
|
if known.Contains(incomingParent) {
|
||||||
|
commonParent = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if commonParent {
|
||||||
|
// known contains at least one of incoming's Parents => the common ancestor is known's Parents (incoming's Grandparents)
|
||||||
|
// in this case, we need to return {incoming.Parents()}
|
||||||
|
incomingParents, err := syncer.store.LoadTipSet(ctx, incomingParentsTsk)
|
||||||
|
if err != nil {
|
||||||
|
// fallback onto the network
|
||||||
|
tips, err := syncer.Exchange.GetBlocks(ctx, incoming.Parents(), 1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed to fetch incomingParents from the network: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(tips) == 0 {
|
||||||
|
return nil, xerrors.Errorf("network didn't return any tipsets")
|
||||||
|
}
|
||||||
|
|
||||||
|
incomingParents = tips[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return []*types.TipSet{incomingParents}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Does this mean we always ask for ForkLengthThreshold blocks from the network, even if we just need, like, 2? Yes.
|
// TODO: Does this mean we always ask for ForkLengthThreshold blocks from the network, even if we just need, like, 2? Yes.
|
||||||
// Would it not be better to ask in smaller chunks, given that an ~ForkLengthThreshold is very rare?
|
// Would it not be better to ask in smaller chunks, given that an ~ForkLengthThreshold is very rare?
|
||||||
tips, err := syncer.Exchange.GetBlocks(ctx, incoming.Parents(), int(build.ForkLengthThreshold))
|
tips, err := syncer.Exchange.GetBlocks(ctx, incoming.Parents(), int(build.ForkLengthThreshold))
|
||||||
|
@ -664,7 +664,7 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(len(sectors))
|
wg.Add(len(sectors))
|
||||||
|
|
||||||
vproofs := make([][]byte, 0, len(sectors))
|
vproofs := make([][]byte, len(sectors))
|
||||||
|
|
||||||
for i, s := range sectors {
|
for i, s := range sectors {
|
||||||
if l.challengeThrottle != nil {
|
if l.challengeThrottle != nil {
|
||||||
@ -702,8 +702,7 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//vproofs[i] = vanilla // todo substitutes??
|
vproofs[i] = vanilla
|
||||||
vproofs = append(vproofs, vanilla)
|
|
||||||
}(i, s)
|
}(i, s)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
@ -717,6 +716,22 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe
|
|||||||
return storiface.WindowPoStResult{Skipped: skipped}, nil
|
return storiface.WindowPoStResult{Skipped: skipped}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compact skipped sectors
|
||||||
|
var skippedSoFar int
|
||||||
|
for i := range vproofs {
|
||||||
|
if len(vproofs[i]) == 0 {
|
||||||
|
skippedSoFar++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if skippedSoFar > 0 {
|
||||||
|
vproofs[i-skippedSoFar] = vproofs[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vproofs = vproofs[:len(vproofs)-skippedSoFar]
|
||||||
|
|
||||||
|
// compute the PoSt!
|
||||||
res, err := sb.GenerateWindowPoStWithVanilla(ctx, ppt, mid, randomness, vproofs, partitionIdx)
|
res, err := sb.GenerateWindowPoStWithVanilla(ctx, ppt, mid, randomness, vproofs, partitionIdx)
|
||||||
r := storiface.WindowPoStResult{
|
r := storiface.WindowPoStResult{
|
||||||
PoStProofs: res,
|
PoStProofs: res,
|
||||||
|
Loading…
Reference in New Issue
Block a user