Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check (pre)commit receipt before other checks in failed states #4712

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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