Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:sectors CLI to create a new sector #8673

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/api_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions cmd/lotus-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var sectorsCmd = &cli.Command{
sectorsSnapAbortCmd,
sectorsStartSealCmd,
sectorsSealDelayCmd,
sectorsNewSector,
sectorsCapacityCollateralCmd,
sectorsBatching,
sectorsRefreshPieceMatchingCmd,
Expand Down Expand Up @@ -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",
Expand Down
17 changes: 16 additions & 1 deletion extern/storage-sealing/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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{})
}
Expand Down
4 changes: 4 additions & 0 deletions node/impl/storminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions storage/miner_sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down