diff --git a/cbor_gen.go b/cbor_gen.go index b2bd03971..1b05f00e0 100644 --- a/cbor_gen.go +++ b/cbor_gen.go @@ -425,22 +425,6 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error { return err } - // t.Nonce (uint64) (uint64) - if len("Nonce") > cbg.MaxLength { - return xerrors.Errorf("Value in field \"Nonce\" was too long") - } - - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Nonce")))); err != nil { - return err - } - if _, err := w.Write([]byte("Nonce")); err != nil { - return err - } - - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil { - return err - } - // t.SectorType (abi.RegisteredProof) (int64) if len("SectorType") > cbg.MaxLength { return xerrors.Errorf("Value in field \"SectorType\" was too long") @@ -645,6 +629,29 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error { } } + // t.PreCommitTipSet (sealing.TipSetToken) (slice) + if len("PreCommitTipSet") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"PreCommitTipSet\" was too long") + } + + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("PreCommitTipSet")))); err != nil { + return err + } + if _, err := w.Write([]byte("PreCommitTipSet")); err != nil { + return err + } + + if len(t.PreCommitTipSet) > cbg.ByteArrayMaxLen { + return xerrors.Errorf("Byte array in field t.PreCommitTipSet was too long") + } + + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.PreCommitTipSet)))); err != nil { + return err + } + if _, err := w.Write(t.PreCommitTipSet); err != nil { + return err + } + // t.SeedValue (abi.InteractiveSealRandomness) (slice) if len("SeedValue") > cbg.MaxLength { return xerrors.Errorf("Value in field \"SeedValue\" was too long") @@ -855,21 +862,6 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { } t.SectorNumber = abi.SectorNumber(extra) - } - // t.Nonce (uint64) (uint64) - case "Nonce": - - { - - maj, extra, err = cbg.CborReadHeader(br) - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") - } - t.Nonce = uint64(extra) - } // t.SectorType (abi.RegisteredProof) (int64) case "SectorType": @@ -912,9 +904,11 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { if maj != cbg.MajArray { return fmt.Errorf("expected cbor array") } + if extra > 0 { t.Pieces = make([]Piece, extra) } + for i := 0; i < int(extra); i++ { var v Piece @@ -1080,6 +1074,24 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { } } + // t.PreCommitTipSet (sealing.TipSetToken) (slice) + case "PreCommitTipSet": + + maj, extra, err = cbg.CborReadHeader(br) + if err != nil { + return err + } + + if extra > cbg.ByteArrayMaxLen { + return fmt.Errorf("t.PreCommitTipSet: byte array too large (%d)", extra) + } + if maj != cbg.MajByteString { + return fmt.Errorf("expected byte array") + } + t.PreCommitTipSet = make([]byte, extra) + if _, err := io.ReadFull(br, t.PreCommitTipSet); err != nil { + return err + } // t.SeedValue (abi.InteractiveSealRandomness) (slice) case "SeedValue": @@ -1215,9 +1227,11 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { if maj != cbg.MajArray { return fmt.Errorf("expected cbor array") } + if extra > 0 { t.Log = make([]Log, extra) } + for i := 0; i < int(extra); i++ { var v Log diff --git a/fsm.go b/fsm.go index e99f452ff..5f3f25c87 100644 --- a/fsm.go +++ b/fsm.go @@ -82,6 +82,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto ), ComputeProofFailed: planOne( on(SectorRetryComputeProof{}, Committing), + on(SectorSealPreCommitFailed{}, SealFailed), ), CommitFailed: planOne( on(SectorSealPreCommitFailed{}, SealFailed), diff --git a/fsm_events.go b/fsm_events.go index a9d2de87f..76106e0cd 100644 --- a/fsm_events.go +++ b/fsm_events.go @@ -185,7 +185,9 @@ func (evt SectorRetryWaitSeed) apply(state *SectorInfo) {} type SectorRetryComputeProof struct{} -func (evt SectorRetryComputeProof) apply(state *SectorInfo) {} +func (evt SectorRetryComputeProof) apply(state *SectorInfo) { + state.InvalidProofs++ +} type SectorRetryInvalidProof struct{} diff --git a/states.go b/states.go index 7ef6d32a1..04f4f1a40 100644 --- a/states.go +++ b/states.go @@ -224,12 +224,12 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) } c2in, err := m.sealer.SealCommit1(ctx.Context(), m.minerSector(sector.SectorNumber), sector.TicketValue, sector.SeedValue, sector.pieceInfos(), cids) if err != nil { - return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)}) + return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed(1): %w", err)}) } proof, err := m.sealer.SealCommit2(ctx.Context(), m.minerSector(sector.SectorNumber), c2in) if err != nil { - return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)}) + return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed(2): %w", err)}) } tok, _, err := m.api.ChainHead(ctx.Context()) diff --git a/states_failed.go b/states_failed.go index 73212d1f5..f5a496661 100644 --- a/states_failed.go +++ b/states_failed.go @@ -116,6 +116,10 @@ func (m *Sealing) handleComputeProofFailed(ctx statemachine.Context, sector Sect return err } + if sector.InvalidProofs > 1 { + return ctx.Send(SectorSealPreCommitFailed{xerrors.Errorf("consecutive compute fails")}) + } + return ctx.Send(SectorRetryComputeProof{}) } diff --git a/types.go b/types.go index 7f60d0a70..08f55f572 100644 --- a/types.go +++ b/types.go @@ -48,8 +48,7 @@ type Log struct { type SectorInfo struct { State SectorState - SectorNumber abi.SectorNumber // TODO: this field's name should be changed to SectorNumber - Nonce uint64 // TODO: remove + SectorNumber abi.SectorNumber SectorType abi.RegisteredProof @@ -75,7 +74,7 @@ type SectorInfo struct { // Committing CommitMessage *cid.Cid - InvalidProofs uint64 // failed proof computations (doesn't validate with proof inputs) + InvalidProofs uint64 // failed proof computations (doesn't validate with proof inputs; can't compute) // Faults FaultReportMsg *cid.Cid