Skip to content

Commit

Permalink
storage: Recompute bad supra C1
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jan 14, 2025
1 parent 172f5e9 commit 4caf9ad
Showing 1 changed file with 39 additions and 33 deletions.
72 changes: 39 additions & 33 deletions lib/paths/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

0 comments on commit 4caf9ad

Please sign in to comment.