diff --git a/api/api_storage.go b/api/api_storage.go index 3fa2ab6d0..e01f859cf 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -19,7 +19,7 @@ const ( Unsealed // sealing / queued PreCommitting // on chain pre-commit - PreCommitted // waiting for seed + WaitSeed // waiting for seed Committing CommitWait // waiting for message to land on chain Proving @@ -61,7 +61,7 @@ var SectorStates = []string{ Packing: "Packing", Unsealed: "Unsealed", PreCommitting: "PreCommitting", - PreCommitted: "PreCommitted", + WaitSeed: "WaitSeed", Committing: "Committing", CommitWait: "CommitWait", Proving: "Proving", diff --git a/storage/sealing/fsm.go b/storage/sealing/fsm.go index 5c37020d2..7459b7487 100644 --- a/storage/sealing/fsm.go +++ b/storage/sealing/fsm.go @@ -36,10 +36,10 @@ var fsmPlanners = []func(events []statemachine.Event, state *SectorInfo) error{ on(SectorSealFailed{}, api.SealFailed), ), api.PreCommitting: planOne( - on(SectorPreCommitted{}, api.PreCommitted), + on(SectorPreCommitted{}, api.WaitSeed), on(SectorPreCommitFailed{}, api.PreCommitFailed), ), - api.PreCommitted: planOne( + api.WaitSeed: planOne( on(SectorSeedReady{}, api.Committing), on(SectorPreCommitFailed{}, api.PreCommitFailed), ), @@ -87,7 +87,7 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta * PreCommitting <--> PreCommitFailed | | ^ | v | - *<- PreCommitted ------/ + *<- WaitSeed ----------/ | ||| | vvv v--> SealCommitFailed *<- Committing @@ -115,8 +115,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta return m.handleUnsealed, nil case api.PreCommitting: return m.handlePreCommitting, nil - case api.PreCommitted: - return m.handlePreCommitted, nil + case api.WaitSeed: + return m.handleWaitSeed, nil case api.Committing: return m.handleCommitting, nil case api.CommitWait: @@ -172,7 +172,7 @@ func planCommitting(events []statemachine.Event, state *SectorInfo) error { e.apply(state) state.State = api.Committing return nil - case SectorSealCommitFailed: + case SectorComputeProofFailed: state.State = api.SealCommitFailed case SectorSealFailed: state.State = api.CommitFailed diff --git a/storage/sealing/fsm_events.go b/storage/sealing/fsm_events.go index 8392d13e7..662379e9a 100644 --- a/storage/sealing/fsm_events.go +++ b/storage/sealing/fsm_events.go @@ -96,7 +96,7 @@ func (evt SectorSeedReady) apply(state *SectorInfo) { state.Seed = evt.seed } -type SectorSealCommitFailed struct{ error } +type SectorComputeProofFailed struct{ error } type SectorCommitFailed struct{ error } type SectorCommitted struct { message cid.Cid diff --git a/storage/sealing/fsm_test.go b/storage/sealing/fsm_test.go index a76a547dc..2dada5470 100644 --- a/storage/sealing/fsm_test.go +++ b/storage/sealing/fsm_test.go @@ -41,7 +41,7 @@ func TestHappyPath(t *testing.T) { require.Equal(m.t, m.state.State, api.PreCommitting) m.planSingle(SectorPreCommitted{}) - require.Equal(m.t, m.state.State, api.PreCommitted) + require.Equal(m.t, m.state.State, api.WaitSeed) m.planSingle(SectorSeedReady{}) require.Equal(m.t, m.state.State, api.Committing) @@ -67,7 +67,7 @@ func TestSeedRevert(t *testing.T) { require.Equal(m.t, m.state.State, api.PreCommitting) m.planSingle(SectorPreCommitted{}) - require.Equal(m.t, m.state.State, api.PreCommitted) + require.Equal(m.t, m.state.State, api.WaitSeed) m.planSingle(SectorSeedReady{}) require.Equal(m.t, m.state.State, api.Committing) diff --git a/storage/sealing/sealing.go b/storage/sealing/sealing.go index 5b8ce1bb5..5a486f6ef 100644 --- a/storage/sealing/sealing.go +++ b/storage/sealing/sealing.go @@ -6,7 +6,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-sectorbuilder" - "github.com/filecoin-project/lotus/lib/padreader" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/namespace" @@ -14,9 +13,11 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/lib/padreader" "github.com/filecoin-project/lotus/lib/statemachine" ) @@ -37,6 +38,7 @@ type sealingApi interface { // TODO: trim down StateWaitMsg(context.Context, cid.Cid) (*api.MsgWait, error) // TODO: removeme eventually StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error) + StateMarketStorageDeal(context.Context, uint64, *types.TipSet) (*actors.OnChainDeal, error) MpoolPushMessage(context.Context, *types.Message) (*types.SignedMessage, error) diff --git a/storage/sealing/states.go b/storage/sealing/states.go index 1bebdb243..ad4a8f542 100644 --- a/storage/sealing/states.go +++ b/storage/sealing/states.go @@ -97,7 +97,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf return ctx.Send(SectorPreCommitted{message: smsg.Cid()}) } -func (m *Sealing) handlePreCommitted(ctx statemachine.Context, sector SectorInfo) error { +func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) error { // would be ideal to just use the events.Called handler, but it wouldnt be able to handle individual message timeouts log.Info("Sector precommitted: ", sector.SectorID) mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.PreCommitMessage) @@ -147,7 +147,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.SB(), sector.Seed.SB(), sector.pieceInfos(), sector.rspco()) if err != nil { - return ctx.Send(SectorSealCommitFailed{xerrors.Errorf("computing seal proof failed: %w", err)}) + return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)}) } // TODO: Consider splitting states and persist proof for faster recovery diff --git a/storage/sealing/types.go b/storage/sealing/types.go index 6e248050e..096e83d08 100644 --- a/storage/sealing/types.go +++ b/storage/sealing/types.go @@ -49,7 +49,7 @@ func (p *Piece) ppi() (out sectorbuilder.PublicPieceInfo) { type SectorInfo struct { State api.SectorState SectorID uint64 - Nonce uint64 + Nonce uint64 // TODO: remove // Packing @@ -63,7 +63,7 @@ type SectorInfo struct { PreCommitMessage *cid.Cid - // PreCommitted + // WaitSeed Seed SealSeed // Committing