diff --git a/api/api_storage.go b/api/api_storage.go index 5785ede1fdd..6eabd256f7f 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -67,6 +67,9 @@ type StorageMiner interface { // sectors can be created. SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPieceSize, r storage.Data, d PieceDealInfo) (SectorOffset, error) //perm:admin + // Add a new unassigned sector + SectorTryCreateNewSector(ctx context.Context) (abi.SectorNumber, error) //perm:admin + SectorsUnsealPiece(ctx context.Context, sector storage.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, commd *cid.Cid) error //perm:admin // List all staged sectors diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 7542ac36726..98b5bbb4cfa 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -819,6 +819,8 @@ type StorageMinerStruct struct { SectorTerminatePending func(p0 context.Context) ([]abi.SectorID, error) `perm:"admin"` + SectorTryCreateNewSector func(p0 context.Context) (abi.SectorNumber, error) `perm:"admin"` + SectorsList func(p0 context.Context) ([]abi.SectorNumber, error) `perm:"read"` SectorsListInStates func(p0 context.Context, p1 []SectorState) ([]abi.SectorNumber, error) `perm:"read"` @@ -4848,6 +4850,17 @@ func (s *StorageMinerStub) SectorTerminatePending(p0 context.Context) ([]abi.Sec return *new([]abi.SectorID), ErrNotSupported } +func (s *StorageMinerStruct) SectorTryCreateNewSector(p0 context.Context) (abi.SectorNumber, error) { + if s.Internal.SectorTryCreateNewSector == nil { + return *new(abi.SectorNumber), ErrNotSupported + } + return s.Internal.SectorTryCreateNewSector(p0) +} + +func (s *StorageMinerStub) SectorTryCreateNewSector(p0 context.Context) (abi.SectorNumber, error) { + return *new(abi.SectorNumber), ErrNotSupported +} + func (s *StorageMinerStruct) SectorsList(p0 context.Context) ([]abi.SectorNumber, error) { if s.Internal.SectorsList == nil { return *new([]abi.SectorNumber), ErrNotSupported diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index 1aa964f7ec3..277ec444f1b 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -55,6 +55,7 @@ var sectorsCmd = &cli.Command{ sectorsSnapAbortCmd, sectorsStartSealCmd, sectorsSealDelayCmd, + sectorsNewSector, sectorsCapacityCollateralCmd, sectorsBatching, sectorsRefreshPieceMatchingCmd, @@ -1588,6 +1589,25 @@ var sectorsStartSealCmd = &cli.Command{ }, } +var sectorsNewSector = &cli.Command{ + Name: "new-sector", + Usage: "Manually create a new sector", + Action: func(cctx *cli.Context) error { + nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) + if err != nil { + return err + } + defer closer() + ctx := lcli.ReqContext(cctx) + + sector, err := nodeApi.SectorTryCreateNewSector(ctx) //.SectorStartSealing(ctx, abi.SectorNumber(id)) + println("new sector creation is in progress %s", sector) + println("errro: %s", err) + + return err + }, +} + var sectorsSealDelayCmd = &cli.Command{ Name: "set-seal-delay", Usage: "Set the time, in minutes, that a new sector waits for deals before sealing starts", diff --git a/extern/storage-sealing/input.go b/extern/storage-sealing/input.go index 945de51b732..99fe5c770a4 100644 --- a/extern/storage-sealing/input.go +++ b/extern/storage-sealing/input.go @@ -641,6 +641,21 @@ func (m *Sealing) createSector(ctx context.Context, cfg sealiface.Config, sp abi return sid, err } +func (m *Sealing) SectorTryCreateNewSector(ctx context.Context) (abi.SectorNumber, error) { + sp, err := m.currentSealProof(ctx) + if err != nil { + return 0, xerrors.Errorf("failed to get current seal proof: %w", err) + } + + cfg, err := m.getConfig() + if err != nil { + return 0, xerrors.Errorf("getting storage config: %w", err) + } + sid, err := m.createSector(ctx, cfg, sp) + + return sid, err +} + func (m *Sealing) tryGetDealSector(ctx context.Context, sp abi.RegisteredSealProof, ef expFn) error { m.startupWait.Wait() @@ -710,7 +725,7 @@ func (m *Sealing) tryGetDealSector(ctx context.Context, sp abi.RegisteredSealPro func (m *Sealing) StartPacking(sid abi.SectorNumber) error { m.startupWait.Wait() - + println("starting to seal deal sector", "sector", sid, "trigger", "user") log.Infow("starting to seal deal sector", "sector", sid, "trigger", "user") return m.sectors.Send(uint64(sid), SectorStartPacking{}) } diff --git a/node/impl/storminer.go b/node/impl/storminer.go index f34761d891a..d9aead7649c 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -410,6 +410,10 @@ func (sm *StorageMinerAPI) SectorMatchPendingPiecesToOpenSectors(ctx context.Con return sm.Miner.SectorMatchPendingPiecesToOpenSectors(ctx) } +func (sm *StorageMinerAPI) SectorTryCreateNewSector(ctx context.Context) (abi.SectorNumber, error) { + return sm.Miner.SectorTryCreateNewSector(ctx) +} + func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]lminer.SubmitWindowedPoStParams, error) { var ts *types.TipSet var err error diff --git a/storage/miner_sealing.go b/storage/miner_sealing.go index 59a587fdcfd..069b52019da 100644 --- a/storage/miner_sealing.go +++ b/storage/miner_sealing.go @@ -75,6 +75,10 @@ func (m *Miner) SectorMatchPendingPiecesToOpenSectors(ctx context.Context) error return m.sealing.MatchPendingPiecesToOpenSectors(ctx) } +func (m *Miner) SectorTryCreateNewSector(ctx context.Context) (abi.SectorNumber, error) { + return m.sealing.SectorTryCreateNewSector(ctx) +} + func (m *Miner) MarkForUpgrade(ctx context.Context, id abi.SectorNumber, snap bool) error { if snap { return m.sealing.MarkForSnapUpgrade(ctx, id)