2020-01-15 20:49:11 +00:00
|
|
|
package sealing
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-11-07 07:57:10 +00:00
|
|
|
|
2020-02-12 00:58:55 +00:00
|
|
|
commcid "github.com/filecoin-project/go-fil-commcid"
|
2020-02-02 19:36:15 +00:00
|
|
|
"github.com/filecoin-project/go-sectorbuilder/fs"
|
2020-02-08 02:18:32 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-02-12 07:44:20 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
2020-02-11 03:31:28 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
2019-11-01 13:58:48 +00:00
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
2019-11-08 20:11:56 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-01-13 17:44:59 +00:00
|
|
|
"github.com/filecoin-project/lotus/lib/statemachine"
|
2019-11-01 13:58:48 +00:00
|
|
|
)
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) error {
|
2019-11-06 23:09:48 +00:00
|
|
|
log.Infow("performing filling up rest of the sector...", "sector", sector.SectorID)
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
var allocated abi.UnpaddedPieceSize
|
2019-11-07 18:22:59 +00:00
|
|
|
for _, piece := range sector.Pieces {
|
|
|
|
allocated += piece.Size
|
|
|
|
}
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
ubytes := abi.PaddedPieceSize(m.sb.SectorSize()).Unpadded()
|
2019-11-07 18:43:15 +00:00
|
|
|
|
|
|
|
if allocated > ubytes {
|
2020-01-10 02:11:00 +00:00
|
|
|
return xerrors.Errorf("too much data in sector: %d > %d", allocated, ubytes)
|
2019-11-07 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 18:43:15 +00:00
|
|
|
fillerSizes, err := fillersFromRem(ubytes - allocated)
|
2019-11-06 23:09:48 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return err
|
2019-11-06 23:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(fillerSizes) > 0 {
|
|
|
|
log.Warnf("Creating %d filler pieces for sector %d", len(fillerSizes), sector.SectorID)
|
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
pieces, err := m.pledgeSector(ctx.Context(), sector.SectorID, sector.existingPieces(), fillerSizes...)
|
2019-11-06 23:09:48 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return xerrors.Errorf("filling up the sector (%v): %w", fillerSizes, err)
|
2019-11-06 23:09:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorPacked{pieces: pieces})
|
2019-11-06 23:09:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) error {
|
2020-01-22 19:47:29 +00:00
|
|
|
if err := checkPieces(ctx.Context(), sector, m.api); err != nil { // Sanity check state
|
2020-01-23 15:38:01 +00:00
|
|
|
switch err.(type) {
|
2020-01-23 16:02:55 +00:00
|
|
|
case *ErrApi:
|
2020-01-23 15:38:01 +00:00
|
|
|
log.Errorf("handleUnsealed: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
2020-01-23 16:02:55 +00:00
|
|
|
case *ErrInvalidDeals:
|
2020-01-23 15:38:01 +00:00
|
|
|
return ctx.Send(SectorPackingFailed{xerrors.Errorf("invalid deals in sector: %w", err)})
|
2020-01-23 16:02:55 +00:00
|
|
|
case *ErrExpiredDeals: // Probably not much we can do here, maybe re-pack the sector?
|
2020-01-23 15:38:01 +00:00
|
|
|
return ctx.Send(SectorPackingFailed{xerrors.Errorf("expired deals in sector: %w", err)})
|
|
|
|
default:
|
|
|
|
return xerrors.Errorf("checkPieces sanity check error: %w", err)
|
|
|
|
}
|
2020-01-22 19:47:29 +00:00
|
|
|
}
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
log.Infow("performing sector replication...", "sector", sector.SectorID)
|
2020-01-10 02:11:00 +00:00
|
|
|
ticket, err := m.tktFn(ctx.Context())
|
2019-11-07 18:22:59 +00:00
|
|
|
if err != nil {
|
2020-01-22 21:16:45 +00:00
|
|
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("getting ticket failed: %w", err)})
|
2019-11-07 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-13 16:34:21 +00:00
|
|
|
rspco, err := m.sb.SealPreCommit(ctx.Context(), sector.SectorID, *ticket, sector.pieceInfos())
|
2019-11-01 13:58:48 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("seal pre commit failed: %w", err)})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorSealed{
|
|
|
|
commD: rspco.CommD[:],
|
|
|
|
commR: rspco.CommR[:],
|
|
|
|
ticket: SealTicket{
|
2020-02-12 07:44:20 +00:00
|
|
|
BlockHeight: abi.ChainEpoch(ticket.BlockHeight),
|
2019-11-07 18:22:59 +00:00
|
|
|
TicketBytes: ticket.TicketBytes[:],
|
2020-01-10 02:11:00 +00:00
|
|
|
},
|
2019-12-03 23:42:22 +00:00
|
|
|
})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error {
|
2020-01-22 19:47:29 +00:00
|
|
|
if err := checkSeal(ctx.Context(), m.maddr, sector, m.api); err != nil {
|
2020-01-23 15:38:01 +00:00
|
|
|
switch err.(type) {
|
2020-01-23 16:02:55 +00:00
|
|
|
case *ErrApi:
|
2020-01-23 15:38:01 +00:00
|
|
|
log.Errorf("handlePreCommitting: api error, not proceeding: %+v", err)
|
|
|
|
return nil
|
2020-01-23 16:02:55 +00:00
|
|
|
case *ErrBadCommD: // TODO: Should this just back to packing? (not really needed since handleUnsealed will do that too)
|
2020-01-23 15:38:01 +00:00
|
|
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("bad CommD error: %w", err)})
|
2020-01-23 16:02:55 +00:00
|
|
|
case *ErrExpiredTicket:
|
2020-01-23 15:38:01 +00:00
|
|
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("bad CommD error: %w", err)})
|
|
|
|
default:
|
|
|
|
return xerrors.Errorf("checkSeal sanity check error: %w", err)
|
|
|
|
}
|
2020-01-22 19:47:29 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 00:24:24 +00:00
|
|
|
params := &miner.SectorPreCommitInfo{
|
2020-02-14 21:38:30 +00:00
|
|
|
Expiration: 0,
|
|
|
|
SectorNumber: sector.SectorID,
|
2020-02-12 00:58:55 +00:00
|
|
|
|
2020-02-14 21:38:30 +00:00
|
|
|
SealedCID: commcid.ReplicaCommitmentV1ToCID(sector.CommR),
|
|
|
|
SealEpoch: sector.Ticket.BlockHeight,
|
|
|
|
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
enc, aerr := actors.SerializeParams(params)
|
|
|
|
if aerr != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorPreCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", aerr)})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: m.maddr,
|
|
|
|
From: m.worker,
|
2020-02-12 07:44:20 +00:00
|
|
|
Method: builtin.MethodsMiner.PreCommitSector,
|
2019-11-01 13:58:48 +00:00
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
|
|
|
|
GasLimit: types.NewInt(1000000 /* i dont know help */),
|
|
|
|
GasPrice: types.NewInt(1),
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info("submitting precommit for sector: ", sector.SectorID)
|
2020-01-10 02:11:00 +00:00
|
|
|
smsg, err := m.api.MpoolPushMessage(ctx.Context(), msg)
|
2019-11-01 13:58:48 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorPreCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorPreCommitted{message: smsg.Cid()})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 22:04:46 +00:00
|
|
|
func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) error {
|
2019-11-01 13:58:48 +00:00
|
|
|
// would be ideal to just use the events.Called handler, but it wouldnt be able to handle individual message timeouts
|
2019-11-07 07:57:10 +00:00
|
|
|
log.Info("Sector precommitted: ", sector.SectorID)
|
2020-01-10 02:11:00 +00:00
|
|
|
mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.PreCommitMessage)
|
2019-11-01 13:58:48 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorPreCommitFailed{err})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if mw.Receipt.ExitCode != 0 {
|
|
|
|
log.Error("sector precommit failed: ", mw.Receipt.ExitCode)
|
2019-12-06 02:40:57 +00:00
|
|
|
err := xerrors.Errorf("sector precommit failed: %d", mw.Receipt.ExitCode)
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorPreCommitFailed{err})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
2019-11-07 07:57:10 +00:00
|
|
|
log.Info("precommit message landed on chain: ", sector.SectorID)
|
2019-11-01 13:58:48 +00:00
|
|
|
|
2019-11-02 15:07:18 +00:00
|
|
|
randHeight := mw.TipSet.Height() + build.InteractivePoRepDelay - 1 // -1 because of how the messages are applied
|
2019-11-05 14:03:59 +00:00
|
|
|
log.Infof("precommit for sector %d made it on chain, will start proof computation at height %d", sector.SectorID, randHeight)
|
2019-11-01 13:58:48 +00:00
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
err = m.events.ChainAt(func(ectx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
2020-01-10 02:11:00 +00:00
|
|
|
rand, err := m.api.ChainGetRandomness(ectx, ts.Key(), int64(randHeight))
|
2019-11-08 18:15:13 +00:00
|
|
|
if err != nil {
|
2019-12-03 23:42:22 +00:00
|
|
|
err = xerrors.Errorf("failed to get randomness for computing seal proof: %w", err)
|
2019-11-08 18:15:13 +00:00
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
ctx.Send(SectorFatalError{error: err})
|
2019-12-03 23:42:22 +00:00
|
|
|
return err
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
ctx.Send(SectorSeedReady{seed: SealSeed{
|
|
|
|
BlockHeight: randHeight,
|
|
|
|
TicketBytes: rand,
|
|
|
|
}})
|
2019-12-08 15:59:25 +00:00
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
return nil
|
2019-11-05 14:03:59 +00:00
|
|
|
}, func(ctx context.Context, ts *types.TipSet) error {
|
2019-11-01 13:58:48 +00:00
|
|
|
log.Warn("revert in interactive commit sector step")
|
2019-12-06 02:40:57 +00:00
|
|
|
// TODO: need to cancel running process and restart...
|
2019-11-01 13:58:48 +00:00
|
|
|
return nil
|
2019-12-08 15:14:40 +00:00
|
|
|
}, build.InteractivePoRepConfidence, mw.TipSet.Height()+build.InteractivePoRepDelay)
|
2019-11-01 13:58:48 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Warn("waitForPreCommitMessage ChainAt errored: ", err)
|
|
|
|
}
|
|
|
|
|
2019-12-03 23:42:22 +00:00
|
|
|
return nil
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) error {
|
2019-11-01 13:58:48 +00:00
|
|
|
log.Info("scheduling seal proof computation...")
|
|
|
|
|
2020-01-13 16:34:21 +00:00
|
|
|
proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.SB(), sector.Seed.SB(), sector.pieceInfos(), sector.rspco())
|
2019-11-01 23:43:54 +00:00
|
|
|
if err != nil {
|
2020-01-20 22:04:46 +00:00
|
|
|
return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)})
|
2019-11-01 23:43:54 +00:00
|
|
|
}
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
// TODO: Consider splitting states and persist proof for faster recovery
|
|
|
|
|
2020-02-12 07:44:20 +00:00
|
|
|
params := &miner.ProveCommitSectorParams{
|
|
|
|
SectorNumber: sector.SectorID,
|
2020-02-13 00:15:33 +00:00
|
|
|
Proof: abi.SealProof{ProofBytes: proof},
|
2020-02-12 07:44:20 +00:00
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
2020-02-12 07:44:20 +00:00
|
|
|
enc, aerr := actors.SerializeParams(params)
|
2019-11-01 13:58:48 +00:00
|
|
|
if aerr != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", aerr)})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: m.maddr,
|
|
|
|
From: m.worker,
|
2020-02-12 07:44:20 +00:00
|
|
|
Method: builtin.MethodsMiner.ProveCommitSector,
|
2019-11-01 13:58:48 +00:00
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
|
|
|
|
GasLimit: types.NewInt(1000000 /* i dont know help */),
|
|
|
|
GasPrice: types.NewInt(1),
|
|
|
|
}
|
|
|
|
|
2020-01-16 02:53:59 +00:00
|
|
|
// TODO: check seed / ticket are up to date
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
smsg, err := m.api.MpoolPushMessage(ctx.Context(), msg)
|
2019-11-01 13:58:48 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorCommitted{
|
|
|
|
proof: proof,
|
|
|
|
message: smsg.Cid(),
|
2019-12-06 02:40:57 +00:00
|
|
|
})
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Sealing) handleCommitWait(ctx statemachine.Context, sector SectorInfo) error {
|
2019-12-06 02:40:57 +00:00
|
|
|
if sector.CommitMessage == nil {
|
|
|
|
log.Errorf("sector %d entered commit wait state without a message cid", sector.SectorID)
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorCommitFailed{xerrors.Errorf("entered commit wait with no commit cid")})
|
2019-12-06 02:40:57 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.CommitMessage)
|
2019-11-01 13:58:48 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorCommitFailed{xerrors.Errorf("failed to wait for porep inclusion: %w", err)})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if mw.Receipt.ExitCode != 0 {
|
2020-01-23 10:02:20 +00:00
|
|
|
return ctx.Send(SectorCommitFailed{xerrors.Errorf("submitting sector proof failed (exit=%d, msg=%s) (t:%x; s:%x(%d); p:%x)", mw.Receipt.ExitCode, sector.CommitMessage, sector.Ticket.TicketBytes, sector.Seed.TicketBytes, sector.Seed.BlockHeight, sector.Proof)})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorProving{})
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
2019-12-06 14:06:42 +00:00
|
|
|
|
2020-01-29 21:25:06 +00:00
|
|
|
func (m *Sealing) handleFinalizeSector(ctx statemachine.Context, sector SectorInfo) error {
|
2020-01-29 22:37:31 +00:00
|
|
|
// TODO: Maybe wait for some finality
|
|
|
|
|
2020-01-29 21:25:06 +00:00
|
|
|
if err := m.sb.FinalizeSector(ctx.Context(), sector.SectorID); err != nil {
|
2020-02-02 19:36:15 +00:00
|
|
|
if !xerrors.Is(err, fs.ErrNoSuitablePath) {
|
|
|
|
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("finalize sector: %w", err)})
|
|
|
|
}
|
|
|
|
log.Warnf("finalize sector: %v", err)
|
2020-01-29 22:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.sb.DropStaged(ctx.Context(), sector.SectorID); err != nil {
|
2020-02-02 19:36:15 +00:00
|
|
|
return ctx.Send(SectorFinalizeFailed{xerrors.Errorf("drop staged: %w", err)})
|
2020-01-29 21:25:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ctx.Send(SectorFinalized{})
|
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Sealing) handleFaulty(ctx statemachine.Context, sector SectorInfo) error {
|
2019-12-06 14:06:42 +00:00
|
|
|
// TODO: check if the fault has already been reported, and that this sector is even valid
|
|
|
|
|
|
|
|
// TODO: coalesce faulty sector reporting
|
2020-02-14 00:24:24 +00:00
|
|
|
bf := abi.NewBitField()
|
|
|
|
bf.Set(uint64(sector.SectorID))
|
2019-12-06 14:06:42 +00:00
|
|
|
|
2020-02-12 07:44:20 +00:00
|
|
|
enc, aerr := actors.SerializeParams(&miner.DeclareTemporaryFaultsParams{
|
2020-02-14 00:24:24 +00:00
|
|
|
SectorNumbers: bf,
|
2020-02-12 07:44:20 +00:00
|
|
|
Duration: 99999999, // TODO: This is very unlikely to be the correct number
|
|
|
|
})
|
2019-12-06 14:06:42 +00:00
|
|
|
if aerr != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return xerrors.Errorf("failed to serialize declare fault params: %w", aerr)
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msg := &types.Message{
|
|
|
|
To: m.maddr,
|
|
|
|
From: m.worker,
|
2020-02-12 07:44:20 +00:00
|
|
|
Method: builtin.MethodsMiner.DeclareTemporaryFaults,
|
2019-12-06 14:06:42 +00:00
|
|
|
Params: enc,
|
|
|
|
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
|
|
|
|
GasLimit: types.NewInt(1000000 /* i dont know help */),
|
|
|
|
GasPrice: types.NewInt(1),
|
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
smsg, err := m.api.MpoolPushMessage(ctx.Context(), msg)
|
2019-12-06 14:06:42 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return xerrors.Errorf("failed to push declare faults message to network: %w", err)
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorFaultReported{reportMsg: smsg.Cid()})
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
func (m *Sealing) handleFaultReported(ctx statemachine.Context, sector SectorInfo) error {
|
2019-12-06 14:06:42 +00:00
|
|
|
if sector.FaultReportMsg == nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return xerrors.Errorf("entered fault reported state without a FaultReportMsg cid")
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
mw, err := m.api.StateWaitMsg(ctx.Context(), *sector.FaultReportMsg)
|
2019-12-06 14:06:42 +00:00
|
|
|
if err != nil {
|
2020-01-10 02:11:00 +00:00
|
|
|
return xerrors.Errorf("failed to wait for fault declaration: %w", err)
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if mw.Receipt.ExitCode != 0 {
|
|
|
|
log.Errorf("UNHANDLED: declaring sector fault failed (exit=%d, msg=%s) (id: %d)", mw.Receipt.ExitCode, *sector.FaultReportMsg, sector.SectorID)
|
2020-01-10 02:11:00 +00:00
|
|
|
return xerrors.Errorf("UNHANDLED: submitting fault declaration failed (exit %d)", mw.Receipt.ExitCode)
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
2020-01-10 02:11:00 +00:00
|
|
|
return ctx.Send(SectorFaultedFinal{})
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|