sealing: Some state renaming

This commit is contained in:
Łukasz Magiera 2020-01-20 23:04:46 +01:00
parent efaf2c720b
commit e4de5c55ac
7 changed files with 18 additions and 16 deletions

View File

@ -19,7 +19,7 @@ const (
Unsealed // sealing / queued Unsealed // sealing / queued
PreCommitting // on chain pre-commit PreCommitting // on chain pre-commit
PreCommitted // waiting for seed WaitSeed // waiting for seed
Committing Committing
CommitWait // waiting for message to land on chain CommitWait // waiting for message to land on chain
Proving Proving
@ -61,7 +61,7 @@ var SectorStates = []string{
Packing: "Packing", Packing: "Packing",
Unsealed: "Unsealed", Unsealed: "Unsealed",
PreCommitting: "PreCommitting", PreCommitting: "PreCommitting",
PreCommitted: "PreCommitted", WaitSeed: "WaitSeed",
Committing: "Committing", Committing: "Committing",
CommitWait: "CommitWait", CommitWait: "CommitWait",
Proving: "Proving", Proving: "Proving",

View File

@ -36,10 +36,10 @@ var fsmPlanners = []func(events []statemachine.Event, state *SectorInfo) error{
on(SectorSealFailed{}, api.SealFailed), on(SectorSealFailed{}, api.SealFailed),
), ),
api.PreCommitting: planOne( api.PreCommitting: planOne(
on(SectorPreCommitted{}, api.PreCommitted), on(SectorPreCommitted{}, api.WaitSeed),
on(SectorPreCommitFailed{}, api.PreCommitFailed), on(SectorPreCommitFailed{}, api.PreCommitFailed),
), ),
api.PreCommitted: planOne( api.WaitSeed: planOne(
on(SectorSeedReady{}, api.Committing), on(SectorSeedReady{}, api.Committing),
on(SectorPreCommitFailed{}, api.PreCommitFailed), on(SectorPreCommitFailed{}, api.PreCommitFailed),
), ),
@ -87,7 +87,7 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta
* PreCommitting <--> PreCommitFailed * PreCommitting <--> PreCommitFailed
| | ^ | | ^
| v | | v |
*<- PreCommitted ------/ *<- WaitSeed ----------/
| ||| | |||
| vvv v--> SealCommitFailed | vvv v--> SealCommitFailed
*<- Committing *<- Committing
@ -115,8 +115,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta
return m.handleUnsealed, nil return m.handleUnsealed, nil
case api.PreCommitting: case api.PreCommitting:
return m.handlePreCommitting, nil return m.handlePreCommitting, nil
case api.PreCommitted: case api.WaitSeed:
return m.handlePreCommitted, nil return m.handleWaitSeed, nil
case api.Committing: case api.Committing:
return m.handleCommitting, nil return m.handleCommitting, nil
case api.CommitWait: case api.CommitWait:
@ -172,7 +172,7 @@ func planCommitting(events []statemachine.Event, state *SectorInfo) error {
e.apply(state) e.apply(state)
state.State = api.Committing state.State = api.Committing
return nil return nil
case SectorSealCommitFailed: case SectorComputeProofFailed:
state.State = api.SealCommitFailed state.State = api.SealCommitFailed
case SectorSealFailed: case SectorSealFailed:
state.State = api.CommitFailed state.State = api.CommitFailed

View File

@ -96,7 +96,7 @@ func (evt SectorSeedReady) apply(state *SectorInfo) {
state.Seed = evt.seed state.Seed = evt.seed
} }
type SectorSealCommitFailed struct{ error } type SectorComputeProofFailed struct{ error }
type SectorCommitFailed struct{ error } type SectorCommitFailed struct{ error }
type SectorCommitted struct { type SectorCommitted struct {
message cid.Cid message cid.Cid

View File

@ -41,7 +41,7 @@ func TestHappyPath(t *testing.T) {
require.Equal(m.t, m.state.State, api.PreCommitting) require.Equal(m.t, m.state.State, api.PreCommitting)
m.planSingle(SectorPreCommitted{}) m.planSingle(SectorPreCommitted{})
require.Equal(m.t, m.state.State, api.PreCommitted) require.Equal(m.t, m.state.State, api.WaitSeed)
m.planSingle(SectorSeedReady{}) m.planSingle(SectorSeedReady{})
require.Equal(m.t, m.state.State, api.Committing) 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) require.Equal(m.t, m.state.State, api.PreCommitting)
m.planSingle(SectorPreCommitted{}) m.planSingle(SectorPreCommitted{})
require.Equal(m.t, m.state.State, api.PreCommitted) require.Equal(m.t, m.state.State, api.WaitSeed)
m.planSingle(SectorSeedReady{}) m.planSingle(SectorSeedReady{})
require.Equal(m.t, m.state.State, api.Committing) require.Equal(m.t, m.state.State, api.Committing)

View File

@ -6,7 +6,6 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-sectorbuilder" "github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/lotus/lib/padreader"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace" "github.com/ipfs/go-datastore/namespace"
@ -14,9 +13,11 @@ import (
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api" "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/events"
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/padreader"
"github.com/filecoin-project/lotus/lib/statemachine" "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 StateWaitMsg(context.Context, cid.Cid) (*api.MsgWait, error) // TODO: removeme eventually
StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error)
StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, 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) MpoolPushMessage(context.Context, *types.Message) (*types.SignedMessage, error)

View File

@ -97,7 +97,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
return ctx.Send(SectorPreCommitted{message: smsg.Cid()}) 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 // 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) log.Info("Sector precommitted: ", sector.SectorID)
mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.PreCommitMessage) 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()) proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.SB(), sector.Seed.SB(), sector.pieceInfos(), sector.rspco())
if err != nil { 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 // TODO: Consider splitting states and persist proof for faster recovery

View File

@ -49,7 +49,7 @@ func (p *Piece) ppi() (out sectorbuilder.PublicPieceInfo) {
type SectorInfo struct { type SectorInfo struct {
State api.SectorState State api.SectorState
SectorID uint64 SectorID uint64
Nonce uint64 Nonce uint64 // TODO: remove
// Packing // Packing
@ -63,7 +63,7 @@ type SectorInfo struct {
PreCommitMessage *cid.Cid PreCommitMessage *cid.Cid
// PreCommitted // WaitSeed
Seed SealSeed Seed SealSeed
// Committing // Committing