Skip to content

Commit

Permalink
add seal command
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr committed Apr 30, 2024
1 parent c98d8d0 commit f82bd5c
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
85 changes: 85 additions & 0 deletions cmd/curio/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ package main

import (
"fmt"
"net/http"
"sort"
"strconv"

"github.com/urfave/cli/v2"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/api/client"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/cmd/curio/deps"
"github.com/filecoin-project/lotus/curiosrc/market/lmrpc"
)
Expand All @@ -15,6 +22,7 @@ var marketCmd = &cli.Command{
Name: "market",
Subcommands: []*cli.Command{
marketRPCInfoCmd,
marketSealCmd,
},
}

Expand Down Expand Up @@ -68,3 +76,80 @@ var marketRPCInfoCmd = &cli.Command{
},
Name: "rpc-info",
}

var marketSealCmd = &cli.Command{
Name: "seal",
Usage: "start sealing a deal sector early",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "actor",
Usage: "Specify actor address to start sealing sectors for",
Required: true,
},
&cli.StringSliceFlag{
Name: "layers",
Usage: "list of layers to be interpreted (atop defaults). Default: base",
},
},
Action: func(cctx *cli.Context) error {
act, err := address.NewFromString(cctx.String("actor"))
if err != nil {
return xerrors.Errorf("parsing --actor: %w", err)
}

if cctx.Args().Len() > 1 {
return xerrors.Errorf("specify only one sector")
}

sec := cctx.Args().First()

sector, err := strconv.ParseUint(sec, 10, 64)
if err != nil {
return xerrors.Errorf("failed to parse the sector number: %w", err)
}

db, err := deps.MakeDB(cctx)
if err != nil {
return err
}

cfg, err := deps.GetConfig(cctx, db)
if err != nil {
return xerrors.Errorf("get config: %w", err)
}

ts, err := lmrpc.MakeTokens(cfg)
if err != nil {
return xerrors.Errorf("make tokens: %w", err)
}

info, ok := ts[act]
if !ok {
return xerrors.Errorf("no market configuration found for actor %s in the specified config layers", act)
}

ainfo := cliutil.ParseApiInfo(info)
addr, err := ainfo.DialArgs("0")
if err != nil {
return xerrors.Errorf("could not get DialArgs: %w", err)
}

type httpHead struct {
addr string
header http.Header
}

head := httpHead{
addr: addr,
header: ainfo.AuthHeader(),
}

market, closer, err := client.NewStorageMinerRPCV0(cctx.Context, head.addr, head.header)
if err != nil {
return xerrors.Errorf("failed to get market API: %w", err)
}
defer closer()

return market.SectorStartSealing(cctx.Context, abi.SectorNumber(sector))
},
}
15 changes: 15 additions & 0 deletions documentation/en/cli-curio.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ USAGE:
COMMANDS:
rpc-info
seal start sealing a deal sector early
help, h Shows a list of commands or help for one command
OPTIONS:
Expand All @@ -550,6 +551,20 @@ OPTIONS:
--help, -h show help
```

### curio market seal
```
NAME:
curio market seal - start sealing a deal sector early
USAGE:
curio market seal [command options] [arguments...]
OPTIONS:
--actor value Specify actor address to start sealing sectors for
--layers value [ --layers value ] list of layers to be interpreted (atop defaults). Default: base
--help, -h show help
```

## curio fetch-params
```
NAME:
Expand Down

0 comments on commit f82bd5c

Please sign in to comment.