From 4caf9ad8f118445dc3e9735de8de8d3e0c18d839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 14 Jan 2025 22:08:45 +0100 Subject: [PATCH] storage: Recompute bad supra C1 --- lib/paths/local.go | 72 +++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/lib/paths/local.go b/lib/paths/local.go index da1a2fc11..ca4d18b5a 100644 --- a/lib/paths/local.go +++ b/lib/paths/local.go @@ -1178,49 +1178,55 @@ func (st *Local) supraPoRepVanillaProof(src storiface.SectorPaths, sr storiface. // first see if commit-phase1-output is there commitPhase1OutputPath := filepath.Join(src.Cache, CommitPhase1OutputFileSupra) - if _, err := os.Stat(commitPhase1OutputPath); err != nil { - if !os.IsNotExist(err) { - return nil, xerrors.Errorf("stat commit phase1 output: %w", err) - } - parentsPath, err := ParentsForProof(sr.ProofType) - if err != nil { - return nil, xerrors.Errorf("parents for proof: %w", err) - } + for { + if _, err := os.Stat(commitPhase1OutputPath); err != nil { + if !os.IsNotExist(err) { + return nil, xerrors.Errorf("stat commit phase1 output: %w", err) + } - // not found, compute it - res := supraffi.C1(bm.BlockOffset, bm.BatchSectors, bm.NumInPipeline, replicaID[:], seed, ticket, src.Cache, parentsPath, src.Sealed, uint64(ssize)) - if res != 0 { - return nil, xerrors.Errorf("c1 failed: %d", res) + parentsPath, err := ParentsForProof(sr.ProofType) + if err != nil { + return nil, xerrors.Errorf("parents for proof: %w", err) + } + + // not found, compute it + res := supraffi.C1(bm.BlockOffset, bm.BatchSectors, bm.NumInPipeline, replicaID[:], seed, ticket, src.Cache, parentsPath, src.Sealed, uint64(ssize)) + if res != 0 { + return nil, xerrors.Errorf("c1 failed: %d", res) + } + + // check again + if _, err := os.Stat(commitPhase1OutputPath); err != nil { + return nil, xerrors.Errorf("stat commit phase1 output after compute: %w", err) + } } - // check again - if _, err := os.Stat(commitPhase1OutputPath); err != nil { - return nil, xerrors.Errorf("stat commit phase1 output after compute: %w", err) + // read the output + rawOut, err := os.ReadFile(commitPhase1OutputPath) + if err != nil { + return nil, xerrors.Errorf("read commit phase1 output: %w", err) } - } - // read the output - rawOut, err := os.ReadFile(commitPhase1OutputPath) - if err != nil { - return nil, xerrors.Errorf("read commit phase1 output: %w", err) - } + // decode + dec, err := cuproof.DecodeCommit1OutRaw(bytes.NewReader(rawOut)) + if err != nil { + log.Errorw("failed to decode commit phase1 output, will retry", "err", err) + time.Sleep(1 * time.Second) + continue + } - // decode - dec, err := cuproof.DecodeCommit1OutRaw(bytes.NewReader(rawOut)) - if err != nil { - return nil, xerrors.Errorf("decode commit phase1 output: %w", err) - } + log.Infow("supraPoRepVanillaProof", "sref", sr, "replicaID", replicaID, "seed", seed, "ticket", ticket, "decrepl", dec.ReplicaID, "decr", dec.CommR, "decd", dec.CommD) - log.Infow("supraPoRepVanillaProof", "sref", sr, "replicaID", replicaID, "seed", seed, "ticket", ticket, "decrepl", dec.ReplicaID, "decr", dec.CommR, "decd", dec.CommD) + // out is json, so we need to marshal it back + out, err := json.Marshal(dec) + if err != nil { + log.Errorw("failed to decode commit phase1 output", "err", err) + time.Sleep(1 * time.Second) + } - // out is json, so we need to marshal it back - out, err := json.Marshal(dec) - if err != nil { - return nil, xerrors.Errorf("marshal commit phase1 output: %w", err) + return out, nil } - - return out, nil } var _ Store = &Local{}