sector import: Add missing initial fsm state transition

This commit is contained in:
Łukasz Magiera 2022-09-06 10:52:56 +02:00
parent fef7232c6b
commit 12a8ab5ac7
3 changed files with 14 additions and 3 deletions

View File

@ -182,16 +182,20 @@ func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) (abi.SectorID, erro
return abi.SectorID{}, err return abi.SectorID{}, err
} }
return sm.waitSectorStarted(ctx, sr.ID)
}
func (sm *StorageMinerAPI) waitSectorStarted(ctx context.Context, si abi.SectorID) (abi.SectorID, error) {
// wait for the sector to enter the Packing state // wait for the sector to enter the Packing state
// TODO: instead of polling implement some pubsub-type thing in storagefsm // TODO: instead of polling implement some pubsub-type thing in storagefsm
for { for {
info, err := sm.Miner.SectorsStatus(ctx, sr.ID.Number, false) info, err := sm.Miner.SectorsStatus(ctx, si.Number, false)
if err != nil { if err != nil {
return abi.SectorID{}, xerrors.Errorf("getting pledged sector info: %w", err) return abi.SectorID{}, xerrors.Errorf("getting pledged sector info: %w", err)
} }
if info.State != api.SectorState(sealing.UndefinedSectorState) { if info.State != api.SectorState(sealing.UndefinedSectorState) {
return sr.ID, nil return si, nil
} }
select { select {
@ -449,7 +453,12 @@ func (sm *StorageMinerAPI) SectorNumFree(ctx context.Context, name string) error
} }
func (sm *StorageMinerAPI) SectorReceive(ctx context.Context, meta api.RemoteSectorMeta) error { func (sm *StorageMinerAPI) SectorReceive(ctx context.Context, meta api.RemoteSectorMeta) error {
return sm.Miner.Receive(ctx, meta) if err := sm.Miner.Receive(ctx, meta); err != nil {
return err
}
_, err := sm.waitSectorStarted(ctx, meta.Sector)
return err
} }
func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]minertypes.SubmitWindowedPoStParams, error) { func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]minertypes.SubmitWindowedPoStParams, error) {

View File

@ -50,6 +50,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
UndefinedSectorState: planOne( UndefinedSectorState: planOne(
on(SectorStart{}, WaitDeals), on(SectorStart{}, WaitDeals),
on(SectorStartCC{}, Packing), on(SectorStartCC{}, Packing),
on(SectorReceive{}, ReceiveSector),
), ),
Empty: planOne( // deprecated Empty: planOne( // deprecated
on(SectorAddPiece{}, AddPiece), on(SectorAddPiece{}, AddPiece),

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
) )
// todo m.inputLk?
func (m *Sealing) Receive(ctx context.Context, meta api.RemoteSectorMeta) error { func (m *Sealing) Receive(ctx context.Context, meta api.RemoteSectorMeta) error {
si, err := m.checkSectorMeta(ctx, meta) si, err := m.checkSectorMeta(ctx, meta)
if err != nil { if err != nil {