diff --git a/provider/lpffi/sdr_funcs.go b/provider/lpffi/sdr_funcs.go index d5c2f03fb..955f88a33 100644 --- a/provider/lpffi/sdr_funcs.go +++ b/provider/lpffi/sdr_funcs.go @@ -7,14 +7,17 @@ import ( ffi "github.com/filecoin-project/filecoin-ffi" commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/provider/lpproof" "github.com/filecoin-project/lotus/storage/paths" "github.com/filecoin-project/lotus/storage/pipeline/lib/nullreader" + "github.com/filecoin-project/lotus/storage/sealer/proofpaths" "github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" "io" "os" + "path/filepath" ) var log = logging.Logger("lpffi") @@ -109,6 +112,21 @@ func (sb *SealCalls) GenerateSDR(ctx context.Context, sector storiface.SectorRef return nil } +func (sb *SealCalls) TreeD(ctx context.Context, sector storiface.SectorRef, size abi.PaddedPieceSize, data io.Reader) (cid.Cid, error) { + maybeUns := storiface.FTNone + // todo sectors with data + + paths, releaseSector, err := sb.sectors.AcquireSector(ctx, sector, maybeUns, storiface.FTCache, storiface.PathSealing) + if err != nil { + return cid.Undef, xerrors.Errorf("acquiring sector paths: %w", err) + } + defer releaseSector() + + log.Errorw("oest.idos.hbisor.bpisro.pisro.bpisro.bxsrobpyxsrbpoyxsrgbopyx treed", "paths", paths.Cache) + + return lpproof.BuildTreeD(data, filepath.Join(paths.Cache, proofpaths.TreeDName), size) +} + func (sb *SealCalls) TreeRC(ctx context.Context, sector storiface.SectorRef, unsealed cid.Cid) (cid.Cid, cid.Cid, error) { p1o, err := sb.makePhase1Out(unsealed, sector.ProofType) if err != nil { diff --git a/provider/lpseal/task_sdr.go b/provider/lpseal/task_sdr.go index 86efedafb..f5a92a7e1 100644 --- a/provider/lpseal/task_sdr.go +++ b/provider/lpseal/task_sdr.go @@ -123,7 +123,7 @@ func (s *SDRTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done bo n, err := s.db.Exec(ctx, `UPDATE sectors_sdr_pipeline SET after_sdr = true, ticket_epoch = $3, ticket_value = $4 WHERE sp_id = $1 AND sector_number = $2`, - sectorParams.SpID, sectorParams.SectorNumber, ticketEpoch, ticket) + sectorParams.SpID, sectorParams.SectorNumber, ticketEpoch, []byte(ticket)) if err != nil { return false, xerrors.Errorf("store sdr success: updating pipeline: %w", err) } diff --git a/provider/lpseal/task_trees.go b/provider/lpseal/task_trees.go index 610f280f0..a0d27a6ec 100644 --- a/provider/lpseal/task_trees.go +++ b/provider/lpseal/task_trees.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/lotus/lib/harmony/harmonytask" "github.com/filecoin-project/lotus/lib/harmony/resources" "github.com/filecoin-project/lotus/provider/lpffi" + "github.com/filecoin-project/lotus/storage/pipeline/lib/nullreader" "github.com/filecoin-project/lotus/storage/sealer/storiface" "golang.org/x/xerrors" ) @@ -86,12 +87,21 @@ func (t *TreesTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done ProofType: sectorParams.RegSealProof, } + // D + treeUnsealed, err := t.sc.TreeD(ctx, sref, abi.PaddedPieceSize(ssize), nullreader.NewNullReader(abi.PaddedPieceSize(ssize).Unpadded())) + if err != nil { + return false, xerrors.Errorf("computing tree d: %w", err) + } + + // R / C sealed, unsealed, err := t.sc.TreeRC(ctx, sref, commd) if err != nil { return false, xerrors.Errorf("computing tree r and c: %w", err) } - // todo tree d!! (?) + if unsealed != treeUnsealed { + return false, xerrors.Errorf("tree-d and tree-r/c unsealed CIDs disagree") + } n, err := t.db.Exec(ctx, `UPDATE sectors_sdr_pipeline SET after_tree_r = true, after_tree_c = true, after_tree_d = true, tree_r_cid = $1, tree_d_cid = $3 diff --git a/storage/sealer/proofpaths/cachefiles.go b/storage/sealer/proofpaths/cachefiles.go index 24b29e9f5..d624e0777 100644 --- a/storage/sealer/proofpaths/cachefiles.go +++ b/storage/sealer/proofpaths/cachefiles.go @@ -6,7 +6,8 @@ import ( "github.com/filecoin-project/go-state-types/abi" ) -var dataFilePrefix = "sc-02-data-" +const dataFilePrefix = "sc-02-data-" +const TreeDName = dataFilePrefix + "tree-d.dat" func LayerFileName(layer int) string { return fmt.Sprintf("%slayer-%d.dat", dataFilePrefix, layer)