Add API and CLI to unseal sector (#10626)

This commit is contained in:
Shrenuj Bansal 2023-04-17 12:12:15 -04:00 committed by GitHub
parent 3f74840b67
commit 0befed7200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 97 additions and 0 deletions

View File

@ -129,6 +129,8 @@ type StorageMiner interface {
SectorMatchPendingPiecesToOpenSectors(ctx context.Context) error //perm:admin
// SectorAbortUpgrade can be called on sectors that are in the process of being upgraded to abort it
SectorAbortUpgrade(context.Context, abi.SectorNumber) error //perm:admin
// SectorUnseal unseals the provided sector
SectorUnseal(ctx context.Context, number abi.SectorNumber) error //perm:admin
// SectorNumAssignerMeta returns sector number assigner metadata - reserved/allocated
SectorNumAssignerMeta(ctx context.Context) (NumAssignerMeta, error) //perm:read

View File

@ -1085,6 +1085,8 @@ type StorageMinerMethods struct {
SectorTerminatePending func(p0 context.Context) ([]abi.SectorID, error) `perm:"admin"`
SectorUnseal func(p0 context.Context, p1 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"`
@ -6424,6 +6426,17 @@ func (s *StorageMinerStub) SectorTerminatePending(p0 context.Context) ([]abi.Sec
return *new([]abi.SectorID), ErrNotSupported
}
func (s *StorageMinerStruct) SectorUnseal(p0 context.Context, p1 abi.SectorNumber) error {
if s.Internal.SectorUnseal == nil {
return ErrNotSupported
}
return s.Internal.SectorUnseal(p0, p1)
}
func (s *StorageMinerStub) SectorUnseal(p0 context.Context, p1 abi.SectorNumber) error {
return ErrNotSupported
}
func (s *StorageMinerStruct) SectorsList(p0 context.Context) ([]abi.SectorNumber, error) {
if s.Internal.SectorsList == nil {
return *new([]abi.SectorNumber), ErrNotSupported

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -67,6 +67,7 @@ var sectorsCmd = &cli.Command{
sectorsBatching,
sectorsRefreshPieceMatchingCmd,
sectorsCompactPartitionsCmd,
sectorsUnsealCmd,
},
}
@ -2254,3 +2255,27 @@ var sectorsNumbersFreeCmd = &cli.Command{
return minerAPI.SectorNumFree(ctx, cctx.Args().First())
},
}
var sectorsUnsealCmd = &cli.Command{
Name: "unseal",
Usage: "unseal a sector",
ArgsUsage: "[sector number]",
Action: func(cctx *cli.Context) error {
minerAPI, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 {
return lcli.IncorrectNumArgs(cctx)
}
sectorNum, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
if err != nil {
return xerrors.Errorf("could not parse sector number: %w", err)
}
return minerAPI.SectorUnseal(ctx, abi.SectorNumber(sectorNum))
},
}

View File

@ -159,6 +159,7 @@
* [SectorTerminate](#SectorTerminate)
* [SectorTerminateFlush](#SectorTerminateFlush)
* [SectorTerminatePending](#SectorTerminatePending)
* [SectorUnseal](#SectorUnseal)
* [Sectors](#Sectors)
* [SectorsList](#SectorsList)
* [SectorsListInStates](#SectorsListInStates)
@ -3415,6 +3416,21 @@ Response:
]
```
### SectorUnseal
SectorUnseal unseals the provided sector
Perms: admin
Inputs:
```json
[
9
]
```
Response: `{}`
## Sectors

View File

@ -1671,6 +1671,7 @@ COMMANDS:
batching manage batch sector operations
match-pending-pieces force a refreshed match of pending pieces to open sectors without manually waiting for more deals
compact-partitions removes dead sectors from partitions and reduces the number of partitions used if possible
unseal unseal a sector
help, h Shows a list of commands or help for one command
OPTIONS:
@ -2086,6 +2087,19 @@ OPTIONS:
```
### lotus-miner sectors unseal
```
NAME:
lotus-miner sectors unseal - unseal a sector
USAGE:
lotus-miner sectors unseal [command options] [sector number]
OPTIONS:
--help, -h show help (default: false)
```
## lotus-miner proving
```
NAME:

View File

@ -254,6 +254,33 @@ func (sm *StorageMinerAPI) SectorsUnsealPiece(ctx context.Context, sector storif
return sm.StorageMgr.SectorsUnsealPiece(ctx, sector, offset, size, randomness, commd)
}
func (sm *StorageMinerAPI) SectorUnseal(ctx context.Context, sectorNum abi.SectorNumber) error {
status, err := sm.Miner.SectorsStatus(ctx, sectorNum, false)
if err != nil {
return err
}
minerAddr, err := sm.ActorAddress(ctx)
if err != nil {
return err
}
minerID, err := address.IDFromAddress(minerAddr)
if err != nil {
return err
}
sector := storiface.SectorRef{
ID: abi.SectorID{
Miner: abi.ActorID(minerID),
Number: sectorNum,
},
ProofType: status.SealProof,
}
return sm.StorageMgr.SectorsUnsealPiece(ctx, sector, storiface.UnpaddedByteIndex(0), abi.UnpaddedPieceSize(0), status.Ticket.Value, status.CommD)
}
// List all staged sectors
func (sm *StorageMinerAPI) SectorsList(context.Context) ([]abi.SectorNumber, error) {
sectors, err := sm.Miner.ListSectors()