checkCommit: handle missing precommits

This commit is contained in:
Łukasz Magiera 2020-06-17 17:19:36 +02:00
parent 494c3bc487
commit b2d14380b4
5 changed files with 15 additions and 2 deletions

View File

@ -29,6 +29,7 @@ type ErrPrecommitOnChain struct{ error }
type ErrBadSeed struct{ error }
type ErrInvalidProof struct{ error }
type ErrNoPrecommit struct{ error }
func checkPieces(ctx context.Context, si SectorInfo, api SealingAPI) error {
tok, height, err := api.ChainHead(ctx)
@ -109,6 +110,10 @@ func (m *Sealing) checkCommit(ctx context.Context, si SectorInfo, proof []byte,
return xerrors.Errorf("getting precommit info: %w", err)
}
if pci == nil {
return &ErrNoPrecommit{xerrors.Errorf("precommit info not found on-chain")}
}
if pci.PreCommitEpoch+miner.PreCommitChallengeDelay != si.SeedEpoch {
return &ErrBadSeed{xerrors.Errorf("seed epoch doesn't match on chain info: %d != %d", pci.PreCommitEpoch+miner.PreCommitChallengeDelay, si.SeedEpoch)}
}

1
fsm.go
View File

@ -96,6 +96,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
on(SectorRetryWaitSeed{}, WaitSeed),
on(SectorRetryComputeProof{}, Committing),
on(SectorRetryInvalidProof{}, Committing),
on(SectorRetryPreCommitWait{}, PreCommitWait),
),
FinalizeFailed: planOne(
on(SectorRetryFinalize{}, FinalizeSector),

View File

@ -201,6 +201,10 @@ type SectorRetryWaitSeed struct{}
func (evt SectorRetryWaitSeed) apply(state *SectorInfo) {}
type SectorRetryPreCommitWait struct{}
func (evt SectorRetryPreCommitWait) apply(state *SectorInfo) {}
type SectorRetryComputeProof struct{}
func (evt SectorRetryComputeProof) apply(state *SectorInfo) {

View File

@ -214,9 +214,9 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er
}
rand, err := m.api.ChainGetRandomness(ectx, tok, crypto.DomainSeparationTag_InteractiveSealChallengeSeed, randHeight, buf.Bytes())
if err != nil {
err = xerrors.Errorf("failed to get randomness for computing seal proof: %w", err)
err = xerrors.Errorf("failed to get randomness for computing seal proof (ch %d; rh %d; tsk %x): %w", curH, randHeight, tok, err)
_ = ctx.Send(SectorFatalError{error: err})
_ = ctx.Send(SectorChainPreCommitFailed{error: err})
return err
}

View File

@ -177,6 +177,9 @@ func (m *Sealing) handleCommitFailed(ctx statemachine.Context, sector SectorInfo
}
return ctx.Send(SectorRetryInvalidProof{})
case *ErrPrecommitOnChain:
log.Errorf("no precommit on chain, will retry: %+v", err)
return ctx.Send(SectorRetryPreCommitWait{})
default:
return xerrors.Errorf("checkCommit sanity check error: %w", err)
}