Skip to content

Commit

Permalink
Merge pull request #4712 from filecoin-project/fix/commitfailed-checks
Browse files Browse the repository at this point in the history
Check (pre)commit receipt before other checks in failed states
  • Loading branch information
magik6k authored Nov 18, 2020
2 parents 3536ec9 + cde0e58 commit 0033587
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions extern/storage-sealing/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
),
PreCommitFailed: planOne(
on(SectorRetryPreCommit{}, PreCommitting),
on(SectorRetryPreCommitWait{}, PreCommitWait),
on(SectorRetryWaitSeed{}, WaitSeed),
on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed),
on(SectorPreCommitLanded{}, WaitSeed),
Expand All @@ -125,6 +126,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
on(SectorChainPreCommitFailed{}, PreCommitFailed),
on(SectorRetryPreCommit{}, PreCommitting),
on(SectorRetryCommitWait{}, CommitWait),
on(SectorRetrySubmitCommit{}, SubmitCommit),
on(SectorDealsExpired{}, DealsExpired),
on(SectorInvalidDealIDs{}, RecoverDealIDs),
on(SectorTicketExpired{}, Removing),
Expand Down
56 changes: 56 additions & 0 deletions extern/storage-sealing/states_failed.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,34 @@ func (m *Sealing) handlePreCommitFailed(ctx statemachine.Context, sector SectorI
return nil
}

if sector.PreCommitMessage != nil {
mw, err := m.api.StateSearchMsg(ctx.Context(), *sector.PreCommitMessage)
if err != nil {
// API error
if err := failedCooldown(ctx, sector); err != nil {
return err
}

return ctx.Send(SectorRetryPreCommitWait{})
}

if mw == nil {
// API error in precommit
return ctx.Send(SectorRetryPreCommitWait{})
}

switch mw.Receipt.ExitCode {
case exitcode.Ok:
// API error in PreCommitWait
return ctx.Send(SectorRetryPreCommitWait{})
case exitcode.SysErrOutOfGas:
// API error in PreCommitWait AND gas estimator guessed a wrong number in PreCommit
return ctx.Send(SectorRetryPreCommit{})
default:
// something else went wrong
}
}

if err := checkPrecommit(ctx.Context(), m.Address(), sector, tok, height, m.api); err != nil {
switch err.(type) {
case *ErrApi:
Expand Down Expand Up @@ -160,6 +188,34 @@ func (m *Sealing) handleCommitFailed(ctx statemachine.Context, sector SectorInfo
return nil
}

if sector.CommitMessage != nil {
mw, err := m.api.StateSearchMsg(ctx.Context(), *sector.CommitMessage)
if err != nil {
// API error
if err := failedCooldown(ctx, sector); err != nil {
return err
}

return ctx.Send(SectorRetryCommitWait{})
}

if mw == nil {
// API error in commit
return ctx.Send(SectorRetryCommitWait{})
}

switch mw.Receipt.ExitCode {
case exitcode.Ok:
// API error in CcommitWait
return ctx.Send(SectorRetryCommitWait{})
case exitcode.SysErrOutOfGas:
// API error in CommitWait AND gas estimator guessed a wrong number in SubmitCommit
return ctx.Send(SectorRetrySubmitCommit{})
default:
// something else went wrong
}
}

if err := checkPrecommit(ctx.Context(), m.maddr, sector, tok, height, m.api); err != nil {
switch err.(type) {
case *ErrApi:
Expand Down

0 comments on commit 0033587

Please sign in to comment.