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

View File

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

View File

@ -24,6 +24,8 @@ const (
ComputeProofFailed SectorState = "ComputeProofFailed" ComputeProofFailed SectorState = "ComputeProofFailed"
CommitFailed SectorState = "CommitFailed" CommitFailed SectorState = "CommitFailed"
PackingFailed SectorState = "PackingFailed" PackingFailed SectorState = "PackingFailed"
FinalizeFailed SectorState = "FinalizeFailed"
Faulty SectorState = "Faulty" // sector is corrupted or gone for some reason Faulty SectorState = "Faulty" // sector is corrupted or gone for some reason
FaultReported SectorState = "FaultReported" // sector has been declared as a fault on chain FaultReported SectorState = "FaultReported" // sector has been declared as a fault on chain
FaultedFinal SectorState = "FaultedFinal" // fault declared 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{}) 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{})
}