Skip to content

Commit

Permalink
make repo not depend on ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Nov 1, 2022
1 parent 60cbf74 commit b766e6f
Show file tree
Hide file tree
Showing 27 changed files with 163 additions and 171 deletions.
10 changes: 5 additions & 5 deletions cmd/lotus-miner/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ var initCmd = &cli.Command{
return err
}

var localPaths []paths.LocalPath
var localPaths []storiface.LocalPath

if pssb := cctx.StringSlice("pre-sealed-sectors"); len(pssb) != 0 {
log.Infof("Setting up storage config with presealed sectors: %v", pssb)
Expand All @@ -228,14 +228,14 @@ var initCmd = &cli.Command{
if err != nil {
return err
}
localPaths = append(localPaths, paths.LocalPath{
localPaths = append(localPaths, storiface.LocalPath{
Path: psp,
})
}
}

if !cctx.Bool("no-local-storage") {
b, err := json.MarshalIndent(&paths.LocalStorageMeta{
b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 10,
CanSeal: true,
Expand All @@ -249,12 +249,12 @@ var initCmd = &cli.Command{
return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
}

localPaths = append(localPaths, paths.LocalPath{
localPaths = append(localPaths, storiface.LocalPath{
Path: lr.Path(),
})
}

if err := lr.SetStorage(func(sc *paths.StorageConfig) {
if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
Expand Down
14 changes: 7 additions & 7 deletions cmd/lotus-miner/init_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/filecoin-project/lotus/lib/backupds"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

var restoreCmd = &cli.Command{
Expand All @@ -52,7 +52,7 @@ var restoreCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
log.Info("Initializing lotus miner using a backup")

var storageCfg *paths.StorageConfig
var storageCfg *storiface.StorageConfig
if cctx.IsSet("storage-config") {
cf, err := homedir.Expand(cctx.String("storage-config"))
if err != nil {
Expand All @@ -64,7 +64,7 @@ var restoreCmd = &cli.Command{
return xerrors.Errorf("reading storage config: %w", err)
}

storageCfg = &paths.StorageConfig{}
storageCfg = &storiface.StorageConfig{}
err = json.Unmarshal(cfb, storageCfg)
if err != nil {
return xerrors.Errorf("cannot unmarshal json for storage config: %w", err)
Expand Down Expand Up @@ -95,7 +95,7 @@ var restoreCmd = &cli.Command{
},
}

func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *paths.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error {
func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *storiface.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error {
if cctx.NArg() != 1 {
return lcli.IncorrectNumArgs(cctx)
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfi
if strConfig != nil {
log.Info("Restoring storage path config")

err = lr.SetStorage(func(scfg *paths.StorageConfig) {
err = lr.SetStorage(func(scfg *storiface.StorageConfig) {
*scfg = *strConfig
})
if err != nil {
Expand All @@ -223,8 +223,8 @@ func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfi
} else {
log.Warn("--storage-config NOT SET. NO SECTOR PATHS WILL BE CONFIGURED")
// setting empty config to allow miner to be started
if err := lr.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{})
if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, storiface.LocalPath{})
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-miner/init_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
lcli "github.com/filecoin-project/lotus/cli"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

const (
Expand Down Expand Up @@ -78,7 +78,7 @@ var serviceCmd = &cli.Command{
return xerrors.Errorf("please provide Lotus markets repo path via flag %s", FlagMarketsRepo)
}

if err := restore(ctx, cctx, repoPath, &paths.StorageConfig{}, func(cfg *config.StorageMiner) error {
if err := restore(ctx, cctx, repoPath, &storiface.StorageConfig{}, func(cfg *config.StorageMiner) error {
cfg.Subsystems.EnableMarkets = es.Contains(MarketsService)
cfg.Subsystems.EnableMining = false
cfg.Subsystems.EnableSealing = false
Expand Down
3 changes: 1 addition & 2 deletions cmd/lotus-miner/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/lib/tablewriter"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
Expand Down Expand Up @@ -148,7 +147,7 @@ over time
}
}

cfg := &paths.LocalStorageMeta{
cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: cctx.Uint64("weight"),
CanSeal: cctx.Bool("seal"),
Expand Down
3 changes: 1 addition & 2 deletions cmd/lotus-seed/seed/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper/basicfs"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
Expand Down Expand Up @@ -126,7 +125,7 @@ func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.Sect
}

{
b, err := json.MarshalIndent(&paths.LocalStorageMeta{
b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 0, // read-only
CanSeal: false,
Expand Down
8 changes: 4 additions & 4 deletions cmd/lotus-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,10 @@ var runCmd = &cli.Command{
return err
}

var localPaths []paths.LocalPath
var localPaths []storiface.LocalPath

if !cctx.Bool("no-local-storage") {
b, err := json.MarshalIndent(&paths.LocalStorageMeta{
b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 10,
CanSeal: true,
Expand All @@ -464,12 +464,12 @@ var runCmd = &cli.Command{
return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
}

localPaths = append(localPaths, paths.LocalPath{
localPaths = append(localPaths, storiface.LocalPath{
Path: lr.Path(),
})
}

if err := lr.SetStorage(func(sc *paths.StorageConfig) {
if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/lotus-worker/sealworker/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func (w *Worker) StorageAddLocal(ctx context.Context, path string) error {
return xerrors.Errorf("opening local path: %w", err)
}

if err := w.Storage.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: path})
if err := w.Storage.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = append(sc.StoragePaths, storiface.LocalPath{Path: path})
}); err != nil {
return xerrors.Errorf("get storage config: %w", err)
}
Expand Down Expand Up @@ -127,8 +127,8 @@ func (w *Worker) StorageDetachLocal(ctx context.Context, path string) error {

// drop from the persisted storage.json
var found bool
if err := w.Storage.SetStorage(func(sc *paths.StorageConfig) {
out := make([]paths.LocalPath, 0, len(sc.StoragePaths))
if err := w.Storage.SetStorage(func(sc *storiface.StorageConfig) {
out := make([]storiface.LocalPath, 0, len(sc.StoragePaths))
for _, storagePath := range sc.StoragePaths {
if storagePath.Path != path {
out = append(out, storagePath)
Expand Down
3 changes: 1 addition & 2 deletions cmd/lotus-worker/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"golang.org/x/xerrors"

lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand Down Expand Up @@ -103,7 +102,7 @@ var storageAttachCmd = &cli.Command{
}
}

cfg := &paths.LocalStorageMeta{
cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: cctx.Uint64("weight"),
CanSeal: cctx.Bool("seal"),
Expand Down
10 changes: 5 additions & 5 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,11 @@ func (n *Ensemble) Start() *Ensemble {
psd := m.PresealDir
noPaths := m.options.noStorage

err := lr.SetStorage(func(sc *paths.StorageConfig) {
err := lr.SetStorage(func(sc *storiface.StorageConfig) {
if noPaths {
sc.StoragePaths = []paths.LocalPath{}
sc.StoragePaths = []storiface.LocalPath{}
}
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: psd})
sc.StoragePaths = append(sc.StoragePaths, storiface.LocalPath{Path: psd})
})

require.NoError(n.t, err)
Expand Down Expand Up @@ -737,8 +737,8 @@ func (n *Ensemble) Start() *Ensemble {
require.NoError(n.t, err)

if m.options.noStorage {
err := lr.SetStorage(func(sc *paths.StorageConfig) {
sc.StoragePaths = []paths.LocalPath{}
err := lr.SetStorage(func(sc *storiface.StorageConfig) {
sc.StoragePaths = []storiface.LocalPath{}
})
require.NoError(n.t, err)
}
Expand Down
5 changes: 2 additions & 3 deletions itests/kit/node_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/miner"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)
Expand Down Expand Up @@ -175,7 +174,7 @@ func (tm *TestMiner) FlushSealingBatches(ctx context.Context) {

const metaFile = "sectorstore.json"

func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*paths.LocalStorageMeta)) storiface.ID {
func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*storiface.LocalStorageMeta)) storiface.ID {
p := t.TempDir()

if err := os.MkdirAll(p, 0755); err != nil {
Expand All @@ -189,7 +188,7 @@ func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*pa
require.NoError(t, err)
}

cfg := &paths.LocalStorageMeta{
cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 10,
CanSeal: false,
Expand Down
5 changes: 2 additions & 3 deletions itests/kit/node_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)

Expand All @@ -38,7 +37,7 @@ type TestWorker struct {
options nodeOpts
}

func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*paths.LocalStorageMeta)) storiface.ID {
func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*storiface.LocalStorageMeta)) storiface.ID {
p := t.TempDir()

if err := os.MkdirAll(p, 0755); err != nil {
Expand All @@ -52,7 +51,7 @@ func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*p
require.NoError(t, err)
}

cfg := &paths.LocalStorageMeta{
cfg := &storiface.LocalStorageMeta{
ID: storiface.ID(uuid.New().String()),
Weight: 10,
CanSeal: false,
Expand Down
7 changes: 3 additions & 4 deletions itests/path_detach_redeclare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)
Expand Down Expand Up @@ -74,7 +73,7 @@ func TestPathDetachRedeclare(t *testing.T) {
checkSectors(ctx, t, client, miner, 2, 2)

// attach a new path
newId := miner.AddStorage(ctx, t, func(cfg *paths.LocalStorageMeta) {
newId := miner.AddStorage(ctx, t, func(cfg *storiface.LocalStorageMeta) {
cfg.CanStore = true
})

Expand Down Expand Up @@ -194,7 +193,7 @@ func TestPathDetachRedeclareWorker(t *testing.T) {
checkSectors(ctx, t, client, miner, 2, 2)

// attach a new path
newId := sealw.AddStorage(ctx, t, func(cfg *paths.LocalStorageMeta) {
newId := sealw.AddStorage(ctx, t, func(cfg *storiface.LocalStorageMeta) {
cfg.CanStore = true
})

Expand Down Expand Up @@ -239,7 +238,7 @@ func TestPathDetachRedeclareWorker(t *testing.T) {
require.Len(t, local, 0)

// add a new one again, and move the sectors there
newId = sealw.AddStorage(ctx, t, func(cfg *paths.LocalStorageMeta) {
newId = sealw.AddStorage(ctx, t, func(cfg *storiface.LocalStorageMeta) {
cfg.CanStore = true
})

Expand Down
Loading

0 comments on commit b766e6f

Please sign in to comment.