lpseal: Working SDR!

This commit is contained in:
Łukasz Magiera 2023-12-19 12:50:27 +01:00
parent 04f5a595e4
commit e19b5333c3
2 changed files with 18 additions and 4 deletions

View File

@ -74,7 +74,7 @@ func (l *storageProvider) AcquireSector(ctx context.Context, sector storiface.Se
} }
func (sb *SealCalls) GenerateSDR(ctx context.Context, sector storiface.SectorRef, ticket abi.SealRandomness, commKcid cid.Cid) error { func (sb *SealCalls) GenerateSDR(ctx context.Context, sector storiface.SectorRef, ticket abi.SealRandomness, commKcid cid.Cid) error {
paths, releaseSector, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTCache, storiface.FTNone, storiface.PathSealing) paths, releaseSector, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTNone, storiface.FTCache, storiface.PathSealing)
if err != nil { if err != nil {
return xerrors.Errorf("acquiring sector paths: %w", err) return xerrors.Errorf("acquiring sector paths: %w", err)
} }

View File

@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-commp-utils/zerocomm" "github.com/filecoin-project/go-commp-utils/zerocomm"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/harmony/harmonydb" "github.com/filecoin-project/lotus/lib/harmony/harmonydb"
@ -17,6 +18,8 @@ import (
"golang.org/x/xerrors" "golang.org/x/xerrors"
) )
var isDevnet = build.BlockDelaySecs < 30
type SDRAPI interface { type SDRAPI interface {
ChainHead(context.Context) (*types.TipSet, error) ChainHead(context.Context) (*types.TipSet, error)
StateGetRandomnessFromTickets(context.Context, crypto.DomainSeparationTag, abi.ChainEpoch, []byte, types.TipSetKey) (abi.Randomness, error) StateGetRandomnessFromTickets(context.Context, crypto.DomainSeparationTag, abi.ChainEpoch, []byte, types.TipSetKey) (abi.Randomness, error)
@ -45,13 +48,13 @@ func NewSDRTask(api SDRAPI, db *harmonydb.DB, sp *SealPoller, sc *lpffi.SealCall
func (s *SDRTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done bool, err error) { func (s *SDRTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done bool, err error) {
ctx := context.Background() ctx := context.Background()
var sectorParams struct { var sectorParamsArr []struct {
SpID int64 `db:"sp_id"` SpID int64 `db:"sp_id"`
SectorNumber int64 `db:"sector_number"` SectorNumber int64 `db:"sector_number"`
RegSealProof abi.RegisteredSealProof `db:"reg_seal_proof"` RegSealProof abi.RegisteredSealProof `db:"reg_seal_proof"`
} }
err = s.db.Select(ctx, &sectorParams, ` err = s.db.Select(ctx, &sectorParamsArr, `
SELECT sp_id, sector_number, reg_seal_proof SELECT sp_id, sector_number, reg_seal_proof
FROM sectors_sdr_pipeline FROM sectors_sdr_pipeline
WHERE task_id_sdr = $1`, taskID) WHERE task_id_sdr = $1`, taskID)
@ -59,6 +62,11 @@ func (s *SDRTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done bo
return false, xerrors.Errorf("getting sector params: %w", err) return false, xerrors.Errorf("getting sector params: %w", err)
} }
if len(sectorParamsArr) != 1 {
return false, xerrors.Errorf("expected 1 sector params, got %d", len(sectorParamsArr))
}
sectorParams := sectorParamsArr[0]
var pieces []struct { var pieces []struct {
PieceIndex int64 `db:"piece_index"` PieceIndex int64 `db:"piece_index"`
PieceCID string `db:"piece_cid"` PieceCID string `db:"piece_cid"`
@ -151,7 +159,7 @@ func (s *SDRTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.TaskEn
} }
func (s *SDRTask) TypeDetails() harmonytask.TaskTypeDetails { func (s *SDRTask) TypeDetails() harmonytask.TaskTypeDetails {
return harmonytask.TaskTypeDetails{ res := harmonytask.TaskTypeDetails{
Max: s.maxSDR, Max: s.maxSDR,
Name: "SDR", Name: "SDR",
Cost: resources.Resources{ // todo offset for prefetch? Cost: resources.Resources{ // todo offset for prefetch?
@ -162,6 +170,12 @@ func (s *SDRTask) TypeDetails() harmonytask.TaskTypeDetails {
MaxFailures: 0, MaxFailures: 0,
Follows: nil, Follows: nil,
} }
if isDevnet {
res.Cost.Ram = 1 << 30
}
return res
} }
func (s *SDRTask) Adder(taskFunc harmonytask.AddTaskFunc) { func (s *SDRTask) Adder(taskFunc harmonytask.AddTaskFunc) {