Auto-retry failed finalize

This commit is contained in:
Łukasz Magiera 2020-06-03 23:42:13 +02:00
parent 7fc7221348
commit 1f5aa7fb7d
4 changed files with 25 additions and 3 deletions

6
fsm.go
View File

@ -66,6 +66,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
FinalizeSector: planOne(
on(SectorFinalized{}, Proving),
on(SectorFinalizeFailed{}, FinalizeFailed),
),
Proving: planOne(
@ -92,6 +93,9 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
on(SectorRetryComputeProof{}, Committing),
on(SectorRetryInvalidProof{}, Committing),
),
FinalizeFailed: planOne(
on(SectorRetryFinalize{}, FinalizeSector),
),
Faulty: planOne(
on(SectorFaultReported{}, FaultReported),
@ -207,6 +211,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta
return m.handleComputeProofFailed, nil
case CommitFailed:
return m.handleCommitFailed, nil
case FinalizeFailed:
return m.handleFinalizeFailed, nil
// Faults
case Faulty:

View File

@ -164,6 +164,10 @@ type SectorFinalized struct{}
func (evt SectorFinalized) apply(*SectorInfo) {}
type SectorRetryFinalize struct{}
func (evt SectorRetryFinalize) apply(*SectorInfo) {}
type SectorFinalizeFailed struct{ error }
func (evt SectorFinalizeFailed) FormatError(xerrors.Printer) (next error) { return evt.error }

View File

@ -24,7 +24,9 @@ const (
ComputeProofFailed SectorState = "ComputeProofFailed"
CommitFailed SectorState = "CommitFailed"
PackingFailed SectorState = "PackingFailed"
Faulty SectorState = "Faulty" // sector is corrupted or gone for some reason
FaultReported SectorState = "FaultReported" // sector has been declared as a fault on chain
FaultedFinal SectorState = "FaultedFinal" // fault declared on chain
FinalizeFailed SectorState = "FinalizeFailed"
Faulty SectorState = "Faulty" // sector is corrupted or gone for some reason
FaultReported SectorState = "FaultReported" // sector has been declared as a fault on chain
FaultedFinal SectorState = "FaultedFinal" // fault declared on chain
)

View File

@ -183,3 +183,13 @@ func (m *Sealing) handleCommitFailed(ctx statemachine.Context, sector SectorInfo
return ctx.Send(SectorRetryComputeProof{})
}
func (m *Sealing) handleFinalizeFailed(ctx statemachine.Context, sector SectorInfo) error {
// TODO: Check sector files
if err := failedCooldown(ctx, sector); err != nil {
return err
}
return ctx.Send(SectorRetryFinalize{})
}