Merge pull request #30 from filecoin-project/fix/no-precommit-recover
checkCommit: handle missing precommits
This commit is contained in:
commit
77fc23c4d1
@ -29,6 +29,7 @@ type ErrPrecommitOnChain struct{ error }
|
|||||||
|
|
||||||
type ErrBadSeed struct{ error }
|
type ErrBadSeed struct{ error }
|
||||||
type ErrInvalidProof struct{ error }
|
type ErrInvalidProof struct{ error }
|
||||||
|
type ErrNoPrecommit struct{ error }
|
||||||
|
|
||||||
func checkPieces(ctx context.Context, si SectorInfo, api SealingAPI) error {
|
func checkPieces(ctx context.Context, si SectorInfo, api SealingAPI) error {
|
||||||
tok, height, err := api.ChainHead(ctx)
|
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)
|
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 {
|
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)}
|
return &ErrBadSeed{xerrors.Errorf("seed epoch doesn't match on chain info: %d != %d", pci.PreCommitEpoch+miner.PreCommitChallengeDelay, si.SeedEpoch)}
|
||||||
}
|
}
|
||||||
|
1
fsm.go
1
fsm.go
@ -96,6 +96,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
|
|||||||
on(SectorRetryWaitSeed{}, WaitSeed),
|
on(SectorRetryWaitSeed{}, WaitSeed),
|
||||||
on(SectorRetryComputeProof{}, Committing),
|
on(SectorRetryComputeProof{}, Committing),
|
||||||
on(SectorRetryInvalidProof{}, Committing),
|
on(SectorRetryInvalidProof{}, Committing),
|
||||||
|
on(SectorRetryPreCommitWait{}, PreCommitWait),
|
||||||
),
|
),
|
||||||
FinalizeFailed: planOne(
|
FinalizeFailed: planOne(
|
||||||
on(SectorRetryFinalize{}, FinalizeSector),
|
on(SectorRetryFinalize{}, FinalizeSector),
|
||||||
|
@ -201,6 +201,10 @@ type SectorRetryWaitSeed struct{}
|
|||||||
|
|
||||||
func (evt SectorRetryWaitSeed) apply(state *SectorInfo) {}
|
func (evt SectorRetryWaitSeed) apply(state *SectorInfo) {}
|
||||||
|
|
||||||
|
type SectorRetryPreCommitWait struct{}
|
||||||
|
|
||||||
|
func (evt SectorRetryPreCommitWait) apply(state *SectorInfo) {}
|
||||||
|
|
||||||
type SectorRetryComputeProof struct{}
|
type SectorRetryComputeProof struct{}
|
||||||
|
|
||||||
func (evt SectorRetryComputeProof) apply(state *SectorInfo) {
|
func (evt SectorRetryComputeProof) apply(state *SectorInfo) {
|
||||||
|
@ -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())
|
rand, err := m.api.ChainGetRandomness(ectx, tok, crypto.DomainSeparationTag_InteractiveSealChallengeSeed, randHeight, buf.Bytes())
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +177,9 @@ func (m *Sealing) handleCommitFailed(ctx statemachine.Context, sector SectorInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ctx.Send(SectorRetryInvalidProof{})
|
return ctx.Send(SectorRetryInvalidProof{})
|
||||||
|
case *ErrPrecommitOnChain:
|
||||||
|
log.Errorf("no precommit on chain, will retry: %+v", err)
|
||||||
|
return ctx.Send(SectorRetryPreCommitWait{})
|
||||||
default:
|
default:
|
||||||
return xerrors.Errorf("checkCommit sanity check error: %w", err)
|
return xerrors.Errorf("checkCommit sanity check error: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user