diff --git a/go.mod b/go.mod index e3e6bd8ad..8bc99cefb 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/DataDog/zstd v1.4.5 github.com/GeertJohan/go.rice v1.0.3 github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee + github.com/KarpelesLab/reflink v1.0.1 github.com/Kubuxu/imtui v0.0.0-20210401140320-41663d68d0fa github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d github.com/alecthomas/jsonschema v0.0.0-20200530073317-71f438968921 @@ -37,6 +38,7 @@ require ( github.com/filecoin-project/go-bitfield v0.2.4 github.com/filecoin-project/go-cbor-util v0.0.1 github.com/filecoin-project/go-commp-utils v0.1.3 + github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 github.com/filecoin-project/go-crypto v0.0.1 github.com/filecoin-project/go-data-transfer/v2 v2.0.0-rc7 github.com/filecoin-project/go-fil-commcid v0.1.0 @@ -168,7 +170,6 @@ require ( require ( github.com/GeertJohan/go.incremental v1.0.0 // indirect - github.com/KarpelesLab/reflink v1.0.1 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/StackExchange/wmi v1.2.1 // indirect @@ -194,7 +195,6 @@ require ( github.com/etclabscore/go-jsonschema-walk v0.0.6 // indirect github.com/filecoin-project/go-amt-ipld/v2 v2.1.0 // indirect github.com/filecoin-project/go-amt-ipld/v3 v3.1.0 // indirect - github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 // indirect github.com/filecoin-project/go-ds-versioning v0.1.2 // indirect github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect diff --git a/provider/lpffi/sdr_funcs.go b/provider/lpffi/sdr_funcs.go index 1fdc28144..ec8c7f906 100644 --- a/provider/lpffi/sdr_funcs.go +++ b/provider/lpffi/sdr_funcs.go @@ -4,12 +4,11 @@ import ( "context" "encoding/json" "fmt" - "github.com/KarpelesLab/reflink" - proof2 "github.com/filecoin-project/go-state-types/proof" "io" "os" "path/filepath" + "github.com/KarpelesLab/reflink" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" @@ -17,6 +16,7 @@ import ( ffi "github.com/filecoin-project/filecoin-ffi" commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/go-state-types/abi" + proof2 "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/lotus/provider/lpproof" "github.com/filecoin-project/lotus/storage/paths" diff --git a/provider/lpproof/treed_build.go b/provider/lpproof/treed_build.go index 07e4d12fd..00d13114c 100644 --- a/provider/lpproof/treed_build.go +++ b/provider/lpproof/treed_build.go @@ -1,7 +1,6 @@ package lpproof import ( - "github.com/filecoin-project/lotus/storage/sealer/fr32" "io" "math/bits" "os" @@ -17,6 +16,8 @@ import ( commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/go-state-types/abi" + + "github.com/filecoin-project/lotus/storage/sealer/fr32" ) const nodeSize = 32 diff --git a/provider/lpseal/task_sdr.go b/provider/lpseal/task_sdr.go index 06f852260..d8bf907f8 100644 --- a/provider/lpseal/task_sdr.go +++ b/provider/lpseal/task_sdr.go @@ -3,12 +3,12 @@ package lpseal import ( "bytes" "context" - "github.com/filecoin-project/go-commp-utils/nonffi" - "github.com/ipfs/go-cid" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-commp-utils/nonffi" "github.com/filecoin-project/go-commp-utils/zerocomm" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/crypto" @@ -81,7 +81,7 @@ func (s *SDRTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done bo err = s.db.Select(ctx, &pieces, ` SELECT piece_index, piece_cid, piece_size FROM sectors_sdr_initial_pieces - WHERE sp_id = $1 AND sector_number = $2`, sectorParams.SpID, sectorParams.SectorNumber) + WHERE sp_id = $1 AND sector_number = $2 ORDER BY piece_index asc`, sectorParams.SpID, sectorParams.SectorNumber) if err != nil { return false, xerrors.Errorf("getting pieces: %w", err) } diff --git a/provider/lpseal/task_submit_precommit.go b/provider/lpseal/task_submit_precommit.go index 68f04c6c8..09c9379ac 100644 --- a/provider/lpseal/task_submit_precommit.go +++ b/provider/lpseal/task_submit_precommit.go @@ -102,9 +102,35 @@ func (s *SubmitPrecommitTask) Do(taskID harmonytask.TaskID, stillOwned func() bo SectorNumber: abi.SectorNumber(sectorParams.SectorNumber), SealedCID: sealedCID, SealRandEpoch: sectorParams.TicketEpoch, - DealIDs: nil, Expiration: expiration, }) + + { + var pieces []struct { + PieceIndex int64 `db:"piece_index"` + PieceCID string `db:"piece_cid"` + PieceSize int64 `db:"piece_size"` + + F05DealID int64 `db:"f05_deal_id"` + } + + err = s.db.Select(ctx, &pieces, ` + SELECT piece_index, piece_cid, piece_size, f05_deal_id + FROM sectors_sdr_initial_pieces + WHERE sp_id = $1 AND sector_number = $2 ORDER BY piece_index asc`, sectorParams.SpID, sectorParams.SectorNumber) + if err != nil { + return false, xerrors.Errorf("getting pieces: %w", err) + } + + if len(pieces) > 0 { + params.Sectors[0].UnsealedCid = &unsealedCID + + for _, p := range pieces { + params.Sectors[0].DealIDs = append(params.Sectors[0].DealIDs, abi.DealID(p.F05DealID)) + } + } + } + var pbuf bytes.Buffer if err := params.MarshalCBOR(&pbuf); err != nil { return false, xerrors.Errorf("serializing params: %w", err) diff --git a/provider/lpseal/task_trees.go b/provider/lpseal/task_trees.go index dc96d1637..322e872bb 100644 --- a/provider/lpseal/task_trees.go +++ b/provider/lpseal/task_trees.go @@ -2,22 +2,22 @@ package lpseal import ( "context" - "github.com/filecoin-project/go-commp-utils/nonffi" - "github.com/filecoin-project/go-padreader" - "github.com/filecoin-project/lotus/storage/pipeline/lib/nullreader" - "github.com/ipfs/go-cid" "io" "net/http" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + "github.com/filecoin-project/go-commp-utils/nonffi" "github.com/filecoin-project/go-commp-utils/zerocomm" + "github.com/filecoin-project/go-padreader" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/lib/harmony/harmonydb" "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" ) @@ -74,7 +74,7 @@ func (t *TreesTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done err = t.db.Select(ctx, &pieces, ` SELECT piece_index, piece_cid, piece_size, data_url, data_headers, data_raw_size FROM sectors_sdr_initial_pieces - WHERE sp_id = $1 AND sector_number = $2`, sectorParams.SpID, sectorParams.SectorNumber) + WHERE sp_id = $1 AND sector_number = $2 ORDER BY piece_index asc`, sectorParams.SpID, sectorParams.SectorNumber) if err != nil { return false, xerrors.Errorf("getting pieces: %w", err) }