Merge pull request #1222 from filecoin-project/feat/support-multi-storage-miner-init
Support multi storage directories in miner init
This commit is contained in:
commit
e326a444b1
@ -34,6 +34,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
"github.com/filecoin-project/lotus/markets/utils"
|
"github.com/filecoin-project/lotus/markets/utils"
|
||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
"github.com/filecoin-project/lotus/node/modules"
|
"github.com/filecoin-project/lotus/node/modules"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
@ -77,6 +78,10 @@ var initCmd = &cli.Command{
|
|||||||
Name: "pre-sealed-sectors",
|
Name: "pre-sealed-sectors",
|
||||||
Usage: "specify set of presealed sectors for starting as a genesis miner",
|
Usage: "specify set of presealed sectors for starting as a genesis miner",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "pre-sealed-metadata",
|
||||||
|
Usage: "specify the metadata file for the presealed sectors",
|
||||||
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "nosync",
|
Name: "nosync",
|
||||||
Usage: "don't check full-node sync status",
|
Usage: "don't check full-node sync status",
|
||||||
@ -220,13 +225,13 @@ var initCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir string, maddr address.Address, mds dtypes.MetadataDS) error {
|
func migratePreSealMeta(ctx context.Context, api lapi.FullNode, metadata string, maddr address.Address, mds dtypes.MetadataDS) error {
|
||||||
presealDir, err := homedir.Expand(presealDir)
|
metadata, err := homedir.Expand(metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("expanding preseal dir: %w", err)
|
return xerrors.Errorf("expanding preseal dir: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(filepath.Join(presealDir, "pre-seal-"+maddr.String()+".json"))
|
b, err := ioutil.ReadFile(metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("reading preseal metadata: %w", err)
|
return xerrors.Errorf("reading preseal metadata: %w", err)
|
||||||
}
|
}
|
||||||
@ -369,7 +374,22 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sbcfg, err := modules.SectorBuilderConfig(sectorbuilder.SimplePath(lr.Path()), 2, false, false)(mds, api)
|
c, err := lr.Config()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg, ok := c.(*config.StorageMiner)
|
||||||
|
if !ok {
|
||||||
|
return xerrors.Errorf("invalid config from repo, got: %T", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
scfg := sectorbuilder.SimplePath(lr.Path())
|
||||||
|
if len(cfg.SectorBuilder.Storage) > 0 {
|
||||||
|
scfg = cfg.SectorBuilder.Storage
|
||||||
|
}
|
||||||
|
|
||||||
|
sbcfg, err := modules.SectorBuilderConfig(scfg, 2, false, false)(mds, api)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting genesis miner sector builder config: %w", err)
|
return xerrors.Errorf("getting genesis miner sector builder config: %w", err)
|
||||||
}
|
}
|
||||||
@ -396,7 +416,10 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if pssb := cctx.String("pre-sealed-sectors"); pssb != "" {
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if pssb := cctx.String("pre-sealed-metadata"); pssb != "" {
|
||||||
pssb, err := homedir.Expand(pssb)
|
pssb, err := homedir.Expand(pssb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -409,9 +432,6 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := configureStorageMiner(ctx, api, a, peerid); err != nil {
|
if err := configureStorageMiner(ctx, api, a, peerid); err != nil {
|
||||||
return xerrors.Errorf("failed to configure storage miner: %w", err)
|
return xerrors.Errorf("failed to configure storage miner: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ Create the genesis block and start up the first node:
|
|||||||
Set up the genesis miner:
|
Set up the genesis miner:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./lotus-storage-miner init --genesis-miner --actor=t0101 --sector-size=1024 --pre-sealed-sectors=~/.genesis-sectors --nosync
|
./lotus-storage-miner init --genesis-miner --actor=t0101 --sector-size=1024 --pre-sealed-sectors=~/.genesis-sectors --pre-sealed-metadata=~/.genesis-sectors/pre-seal-t0101.json --nosync
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, finally, start up the miner:
|
Now, finally, start up the miner:
|
||||||
|
@ -142,7 +142,8 @@ func (api *api) SpawnStorage(fullNodeRepo string) (nodeInfo, error) {
|
|||||||
|
|
||||||
initArgs := []string{"init", "--nosync"}
|
initArgs := []string{"init", "--nosync"}
|
||||||
if fullNodeRepo == api.running[1].meta.Repo {
|
if fullNodeRepo == api.running[1].meta.Repo {
|
||||||
initArgs = []string{"init", "--actor=t0101", "--genesis-miner", "--pre-sealed-sectors=" + filepath.Join(fullNodeRepo, "preseal")}
|
presealPrefix := filepath.Join(fullNodeRepo, "preseal")
|
||||||
|
initArgs = []string{"init", "--actor=t0101", "--genesis-miner", "--pre-sealed-sectors=" + presealPrefix, "--pre-sealed-metadata=" + filepath.Join(presealPrefix, "pre-seal-t0101.json")}
|
||||||
}
|
}
|
||||||
|
|
||||||
id := atomic.AddInt32(&api.cmds, 1)
|
id := atomic.AddInt32(&api.cmds, 1)
|
||||||
|
@ -4,4 +4,4 @@ set -o xtrace
|
|||||||
|
|
||||||
export TRUST_PARAMS=1
|
export TRUST_PARAMS=1
|
||||||
|
|
||||||
go run -tags=debug ./cmd/lotus-storage-miner init --actor=t0101 --genesis-miner --pre-sealed-sectors=~/.genesis-sectors
|
go run -tags=debug ./cmd/lotus-storage-miner init --actor=t0101 --genesis-miner --pre-sealed-sectors=~/.genesis-sectors --pre-sealed-metadata=~/.genesis-sectors/pre-seal-t0101.json
|
||||||
|
@ -86,12 +86,12 @@ mdt0111=$(mktemp -d)
|
|||||||
mdt0222=$(mktemp -d)
|
mdt0222=$(mktemp -d)
|
||||||
mdt0333=$(mktemp -d)
|
mdt0333=$(mktemp -d)
|
||||||
|
|
||||||
env LOTUS_PATH="${ldt0111}" LOTUS_STORAGE_PATH="${mdt0111}" ./lotus-storage-miner init --genesis-miner --actor=t0111 --pre-sealed-sectors="${sdt0111}" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
env LOTUS_PATH="${ldt0111}" LOTUS_STORAGE_PATH="${mdt0111}" ./lotus-storage-miner init --genesis-miner --actor=t0111 --pre-sealed-sectors="${sdt0111}" --pre-sealed-metadata="${sdt0111}/pre-seal-t0111.json" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
||||||
env LOTUS_PATH="${ldt0111}" LOTUS_STORAGE_PATH="${mdt0111}" ./lotus-storage-miner run --nosync &
|
env LOTUS_PATH="${ldt0111}" LOTUS_STORAGE_PATH="${mdt0111}" ./lotus-storage-miner run --nosync &
|
||||||
mpid=$!
|
mpid=$!
|
||||||
|
|
||||||
env LOTUS_PATH="${ldt0222}" LOTUS_STORAGE_PATH="${mdt0222}" ./lotus-storage-miner init --actor=t0222 --pre-sealed-sectors="${sdt0222}" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
env LOTUS_PATH="${ldt0222}" LOTUS_STORAGE_PATH="${mdt0222}" ./lotus-storage-miner init --actor=t0222 --pre-sealed-sectors="${sdt0222}" --pre-sealed-metadata="${sdt0222}/pre-seal-t0222.json" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
||||||
env LOTUS_PATH="${ldt0333}" LOTUS_STORAGE_PATH="${mdt0333}" ./lotus-storage-miner init --actor=t0333 --pre-sealed-sectors="${sdt0333}" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
env LOTUS_PATH="${ldt0333}" LOTUS_STORAGE_PATH="${mdt0333}" ./lotus-storage-miner init --actor=t0333 --pre-sealed-sectors="${sdt0333}" --pre-sealed-metadata="${sdt0333}/pre-seal-t0333.json" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
||||||
|
|
||||||
kill $mpid
|
kill $mpid
|
||||||
wait $mpid
|
wait $mpid
|
||||||
|
Loading…
Reference in New Issue
Block a user