diff --git a/extern/storage-sealing/fsm_test.go b/extern/storage-sealing/fsm_test.go index b1e53133c..474ea1966 100644 --- a/extern/storage-sealing/fsm_test.go +++ b/extern/storage-sealing/fsm_test.go @@ -3,6 +3,8 @@ package sealing import ( "testing" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/specs-actors/actors/abi" logging "github.com/ipfs/go-log/v2" "github.com/stretchr/testify/require" @@ -25,8 +27,14 @@ type test struct { } func TestHappyPath(t *testing.T) { + ma, _ := address.NewIDAddress(55151) m := test{ - s: &Sealing{}, + s: &Sealing{ + maddr: ma, + stats: SectorStats{ + bySector: map[abi.SectorID]statSectorState{}, + }, + }, t: t, state: &SectorInfo{State: Packing}, } @@ -60,8 +68,14 @@ func TestHappyPath(t *testing.T) { } func TestSeedRevert(t *testing.T) { + ma, _ := address.NewIDAddress(55151) m := test{ - s: &Sealing{}, + s: &Sealing{ + maddr: ma, + stats: SectorStats{ + bySector: map[abi.SectorID]statSectorState{}, + }, + }, t: t, state: &SectorInfo{State: Packing}, } @@ -101,8 +115,14 @@ func TestSeedRevert(t *testing.T) { } func TestPlanCommittingHandlesSectorCommitFailed(t *testing.T) { + ma, _ := address.NewIDAddress(55151) m := test{ - s: &Sealing{}, + s: &Sealing{ + maddr: ma, + stats: SectorStats{ + bySector: map[abi.SectorID]statSectorState{}, + }, + }, t: t, state: &SectorInfo{State: Committing}, } diff --git a/extern/storage-sealing/sealiface/config.go b/extern/storage-sealing/sealiface/config.go new file mode 100644 index 000000000..ad0b12c40 --- /dev/null +++ b/extern/storage-sealing/sealiface/config.go @@ -0,0 +1,16 @@ +package sealiface + +import "time" + +// this has to be in a separate package to not make lotus API depend on filecoin-ffi + +type Config struct { + // 0 = no limit + MaxWaitDealsSectors uint64 + + // includes failed, 0 = no limit + MaxSealingSectors uint64 + + WaitDealsDelay time.Duration +} + diff --git a/extern/storage-sealing/sealing.go b/extern/storage-sealing/sealing.go index 3a6bb8e5f..006118e58 100644 --- a/extern/storage-sealing/sealing.go +++ b/extern/storage-sealing/sealing.go @@ -35,16 +35,6 @@ type SectorLocation struct { Partition uint64 } -type Config struct { - // 0 = no limit - MaxWaitDealsSectors uint64 - - // includes failed, 0 = no limit - MaxSealingSectors uint64 - - WaitDealsDelay time.Duration -} - var ErrSectorAllocated = errors.New("sectorNumber is allocated, but PreCommit info wasn't found on chain") type SealingAPI interface { diff --git a/extern/storage-sealing/types.go b/extern/storage-sealing/types.go index 1e7c9f76c..a9c2a7203 100644 --- a/extern/storage-sealing/types.go +++ b/extern/storage-sealing/types.go @@ -12,6 +12,7 @@ import ( "github.com/filecoin-project/specs-storage/storage" sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" + "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" ) // Piece is a tuple of piece and deal info @@ -186,7 +187,7 @@ type MessageReceipt struct { GasUsed int64 } -type GetSealingConfigFunc func() (Config, error) +type GetSealingConfigFunc func() (sealiface.Config, error) func (mr *MessageReceipt) Equals(o *MessageReceipt) bool { return mr.ExitCode == o.ExitCode && bytes.Equal(mr.Return, o.Return) && mr.GasUsed == o.GasUsed diff --git a/node/modules/dtypes/miner.go b/node/modules/dtypes/miner.go index 600d19dc7..d559a2de1 100644 --- a/node/modules/dtypes/miner.go +++ b/node/modules/dtypes/miner.go @@ -8,8 +8,9 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-fil-markets/storagemarket" - sealing "github.com/filecoin-project/lotus/extern/storage-sealing" "github.com/filecoin-project/specs-actors/actors/abi" + + "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" ) type MinerAddress address.Address @@ -57,10 +58,10 @@ type ConsiderOfflineRetrievalDealsConfigFunc func() (bool, error) type SetConsiderOfflineRetrievalDealsConfigFunc func(bool) error // SetSealingDelay sets how long a sector waits for more deals before sealing begins. -type SetSealingConfigFunc func(sealing.Config) error +type SetSealingConfigFunc func(sealiface.Config) error // GetSealingDelay returns how long a sector waits for more deals before sealing begins. -type GetSealingConfigFunc func() (sealing.Config, error) +type GetSealingConfigFunc func() (sealiface.Config, error) // SetExpectedSealDurationFunc is a function which is used to set how long sealing is expected to take. // Deals that would need to start earlier than this duration will be rejected. diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index e0cbb434e..3be869f0f 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -48,6 +48,7 @@ import ( "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/stores" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" + "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" @@ -594,7 +595,7 @@ func NewSetConsiderOfflineRetrievalDealsConfigFunc(r repo.LockedRepo) (dtypes.Se } func NewSetSealConfigFunc(r repo.LockedRepo) (dtypes.SetSealingConfigFunc, error) { - return func(cfg sealing.Config) (err error) { + return func(cfg sealiface.Config) (err error) { err = mutateCfg(r, func(c *config.StorageMiner) { c.Sealing = config.SealingConfig{ MaxWaitDealsSectors: cfg.MaxWaitDealsSectors, @@ -607,9 +608,9 @@ func NewSetSealConfigFunc(r repo.LockedRepo) (dtypes.SetSealingConfigFunc, error } func NewGetSealConfigFunc(r repo.LockedRepo) (dtypes.GetSealingConfigFunc, error) { - return func() (out sealing.Config, err error) { + return func() (out sealiface.Config, err error) { err = readCfg(r, func(cfg *config.StorageMiner) { - out = sealing.Config{ + out = sealiface.Config{ MaxWaitDealsSectors: cfg.Sealing.MaxWaitDealsSectors, MaxSealingSectors: cfg.Sealing.MaxSealingSectors, WaitDealsDelay: time.Duration(cfg.Sealing.WaitDealsDelay),