From ee7c251a90a11d3536b2b99b06c273cd9a299cf1 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Mon, 18 Dec 2023 15:09:52 -0500 Subject: [PATCH 1/3] Merge pull request #11533 from filecoin-project/asr/speedup-fork-sync feat: syncer: optimize syncFork for one-epoch forks --- chain/sync.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/chain/sync.go b/chain/sync.go index 1b9a302f7..c61c9f310 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -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, 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{incoming, incomingParents}, nil + } + // 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? tips, err := syncer.Exchange.GetBlocks(ctx, incoming.Parents(), int(build.ForkLengthThreshold)) From b1c0d3cce5bf060a8c25372d69e15b39c11eb0eb Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 19 Dec 2023 16:39:52 -0500 Subject: [PATCH 2/3] fix: sync: do not include incoming in return of syncFork (#11541) --- chain/sync.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/sync.go b/chain/sync.go index c61c9f310..4dccc2036 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -896,7 +896,7 @@ func (syncer *Syncer) syncFork(ctx context.Context, incoming *types.TipSet, know 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, incoming.Parents()} + // in this case, we need to return {incoming.Parents()} incomingParents, err := syncer.store.LoadTipSet(ctx, incomingParentsTsk) if err != nil { // fallback onto the network @@ -912,7 +912,7 @@ func (syncer *Syncer) syncFork(ctx context.Context, incoming *types.TipSet, know incomingParents = tips[0] } - return []*types.TipSet{incoming, incomingParents}, nil + 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. From d612a857cc0a92af10ad1c2afbf25ace9eb8570c Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 4 Jan 2024 07:42:30 -0800 Subject: [PATCH 3/3] Merge pull request #11550 from filecoin-project/fix/worker-multipart-post-err fix: wdpost: fix vanilla proof indexes --- storage/sealer/worker_local.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/storage/sealer/worker_local.go b/storage/sealer/worker_local.go index 9f2f2efdc..7fc494955 100644 --- a/storage/sealer/worker_local.go +++ b/storage/sealer/worker_local.go @@ -664,7 +664,7 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe var wg sync.WaitGroup wg.Add(len(sectors)) - vproofs := make([][]byte, 0, len(sectors)) + vproofs := make([][]byte, len(sectors)) for i, s := range sectors { if l.challengeThrottle != nil { @@ -702,8 +702,7 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe return } - //vproofs[i] = vanilla // todo substitutes?? - vproofs = append(vproofs, vanilla) + vproofs[i] = vanilla }(i, s) } wg.Wait() @@ -717,6 +716,22 @@ func (l *LocalWorker) GenerateWindowPoStAdv(ctx context.Context, ppt abi.Registe 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) r := storiface.WindowPoStResult{ PoStProofs: res,