81ba6ab6f0
* feat: lp mig - first few steps * lp mig: default tasks * code comments * docs * lp-mig-progress * shared * comments and todos * fix: curio: rename lotus-provider to curio (#11645) * rename provider to curio * install gotext * fix lint errors, mod tidy * fix typo * fix API_INFO and add gotext to circleCI * add back gotext * add gotext after remerge * lp: channels doc * finish easy-migration TODOs * out generate * merging and more renames * avoid make-all * minor doc stuff * cu: make gen * make gen fix * make gen * tryfix * go mod tidy * minor ez migration fixes * ez setup - ui cleanups * better error message * guided setup colors * better path to saveconfigtolayer * loadconfigwithupgrades fix * readMiner oops * guided - homedir * err if miner is running * prompt error should exit * process already running, miner_id sectors in migration * dont prompt for language a second time * check miner stopped * unlock repo * render and sql oops * curio easyMig - some fixes * easyMigration runs successfully * lint * review fixes * fix backup path * fixes1 * fixes2 * fixes 3 --------- Co-authored-by: LexLuthr <88259624+LexLuthr@users.noreply.github.com> Co-authored-by: LexLuthr <lexluthr@protocol.ai>
136 lines
3.4 KiB
Go
136 lines
3.4 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"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/chain/actors/builtin/miner"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
lcli "github.com/filecoin-project/lotus/cli"
|
|
"github.com/filecoin-project/lotus/cmd/curio/deps"
|
|
"github.com/filecoin-project/lotus/curiosrc/seal"
|
|
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
|
)
|
|
|
|
var sealCmd = &cli.Command{
|
|
Name: "seal",
|
|
Usage: "Manage the sealing pipeline",
|
|
Subcommands: []*cli.Command{
|
|
sealStartCmd,
|
|
},
|
|
}
|
|
|
|
var sealStartCmd = &cli.Command{
|
|
Name: "start",
|
|
Usage: "Start new sealing operations manually",
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "actor",
|
|
Usage: "Specify actor address to start sealing sectors for",
|
|
Required: true,
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "now",
|
|
Usage: "Start sealing sectors for all actors now (not on schedule)",
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "cc",
|
|
Usage: "Start sealing new CC sectors",
|
|
},
|
|
&cli.IntFlag{
|
|
Name: "count",
|
|
Usage: "Number of sectors to start",
|
|
Value: 1,
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "synthetic",
|
|
Usage: "Use synthetic PoRep",
|
|
Value: false, // todo implement synthetic
|
|
},
|
|
&cli.StringSliceFlag{
|
|
Name: "layers",
|
|
Usage: "list of layers to be interpreted (atop defaults). Default: base",
|
|
},
|
|
},
|
|
Action: func(cctx *cli.Context) error {
|
|
if !cctx.Bool("now") {
|
|
return xerrors.Errorf("schedule not implemented, use --now")
|
|
}
|
|
if !cctx.IsSet("actor") {
|
|
return cli.ShowCommandHelp(cctx, "start")
|
|
}
|
|
if !cctx.Bool("cc") {
|
|
return xerrors.Errorf("only CC sectors supported for now")
|
|
}
|
|
|
|
act, err := address.NewFromString(cctx.String("actor"))
|
|
if err != nil {
|
|
return xerrors.Errorf("parsing --actor: %w", err)
|
|
}
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
dep, err := deps.GetDepsCLI(ctx, cctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
/*
|
|
create table sectors_sdr_pipeline (
|
|
sp_id bigint not null,
|
|
sector_number bigint not null,
|
|
|
|
-- at request time
|
|
create_time timestamp not null,
|
|
reg_seal_proof int not null,
|
|
comm_d_cid text not null,
|
|
|
|
[... other not relevant fields]
|
|
*/
|
|
|
|
mid, err := address.IDFromAddress(act)
|
|
if err != nil {
|
|
return xerrors.Errorf("getting miner id: %w", err)
|
|
}
|
|
|
|
mi, err := dep.Full.StateMinerInfo(ctx, act, types.EmptyTSK)
|
|
if err != nil {
|
|
return xerrors.Errorf("getting miner info: %w", err)
|
|
}
|
|
|
|
nv, err := dep.Full.StateNetworkVersion(ctx, types.EmptyTSK)
|
|
if err != nil {
|
|
return xerrors.Errorf("getting network version: %w", err)
|
|
}
|
|
|
|
wpt := mi.WindowPoStProofType
|
|
spt, err := miner.PreferredSealProofTypeFromWindowPoStType(nv, wpt, cctx.Bool("synthetic"))
|
|
if err != nil {
|
|
return xerrors.Errorf("getting seal proof type: %w", err)
|
|
}
|
|
|
|
num, err := seal.AllocateSectorNumbers(ctx, dep.Full, dep.DB, act, cctx.Int("count"), func(tx *harmonydb.Tx, numbers []abi.SectorNumber) (bool, error) {
|
|
for _, n := range numbers {
|
|
_, err := tx.Exec("insert into sectors_sdr_pipeline (sp_id, sector_number, reg_seal_proof) values ($1, $2, $3)", mid, n, spt)
|
|
if err != nil {
|
|
return false, xerrors.Errorf("inserting into sectors_sdr_pipeline: %w", err)
|
|
}
|
|
}
|
|
return true, nil
|
|
})
|
|
if err != nil {
|
|
return xerrors.Errorf("allocating sector numbers: %w", err)
|
|
}
|
|
|
|
for _, number := range num {
|
|
fmt.Println(number)
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|