Merge branch 'master' into feat/sector-recovery
This commit is contained in:
commit
85d40a318b
315
cbor_gen.go
315
cbor_gen.go
@ -73,13 +73,14 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
|
||||
return fmt.Errorf("cbor input should be of type map")
|
||||
}
|
||||
|
||||
if extra != 2 {
|
||||
return fmt.Errorf("cbor input had wrong number of fields")
|
||||
if extra > cbg.MaxLength {
|
||||
return fmt.Errorf("SealTicket: map struct too large (%d)", extra)
|
||||
}
|
||||
|
||||
var name string
|
||||
n := extra
|
||||
|
||||
// t.BlockHeight (uint64) (uint64)
|
||||
for i := uint64(0); i < n; i++ {
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
@ -90,9 +91,9 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "BlockHeight" {
|
||||
return fmt.Errorf("expected struct map entry %s to be BlockHeight", name)
|
||||
}
|
||||
switch name {
|
||||
// t.BlockHeight (uint64) (uint64)
|
||||
case "BlockHeight":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -103,19 +104,7 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
t.BlockHeight = uint64(extra)
|
||||
// t.TicketBytes ([]uint8) (slice)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "TicketBytes" {
|
||||
return fmt.Errorf("expected struct map entry %s to be TicketBytes", name)
|
||||
}
|
||||
case "TicketBytes":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -132,9 +121,14 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
|
||||
if _, err := io.ReadFull(br, t.TicketBytes); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (t *SealSeed) MarshalCBOR(w io.Writer) error {
|
||||
if t == nil {
|
||||
_, err := w.Write(cbg.CborNull)
|
||||
@ -196,13 +190,14 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
|
||||
return fmt.Errorf("cbor input should be of type map")
|
||||
}
|
||||
|
||||
if extra != 2 {
|
||||
return fmt.Errorf("cbor input had wrong number of fields")
|
||||
if extra > cbg.MaxLength {
|
||||
return fmt.Errorf("SealSeed: map struct too large (%d)", extra)
|
||||
}
|
||||
|
||||
var name string
|
||||
n := extra
|
||||
|
||||
// t.BlockHeight (uint64) (uint64)
|
||||
for i := uint64(0); i < n; i++ {
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
@ -213,9 +208,9 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "BlockHeight" {
|
||||
return fmt.Errorf("expected struct map entry %s to be BlockHeight", name)
|
||||
}
|
||||
switch name {
|
||||
// t.BlockHeight (uint64) (uint64)
|
||||
case "BlockHeight":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -226,19 +221,7 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
t.BlockHeight = uint64(extra)
|
||||
// t.TicketBytes ([]uint8) (slice)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "TicketBytes" {
|
||||
return fmt.Errorf("expected struct map entry %s to be TicketBytes", name)
|
||||
}
|
||||
case "TicketBytes":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -255,9 +238,14 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
|
||||
if _, err := io.ReadFull(br, t.TicketBytes); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (t *Piece) MarshalCBOR(w io.Writer) error {
|
||||
if t == nil {
|
||||
_, err := w.Write(cbg.CborNull)
|
||||
@ -335,13 +323,14 @@ func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
||||
return fmt.Errorf("cbor input should be of type map")
|
||||
}
|
||||
|
||||
if extra != 3 {
|
||||
return fmt.Errorf("cbor input had wrong number of fields")
|
||||
if extra > cbg.MaxLength {
|
||||
return fmt.Errorf("Piece: map struct too large (%d)", extra)
|
||||
}
|
||||
|
||||
var name string
|
||||
n := extra
|
||||
|
||||
// t.DealID (uint64) (uint64)
|
||||
for i := uint64(0); i < n; i++ {
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
@ -352,9 +341,9 @@ func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "DealID" {
|
||||
return fmt.Errorf("expected struct map entry %s to be DealID", name)
|
||||
}
|
||||
switch name {
|
||||
// t.DealID (uint64) (uint64)
|
||||
case "DealID":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -365,19 +354,7 @@ func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
t.DealID = uint64(extra)
|
||||
// t.Size (uint64) (uint64)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "Size" {
|
||||
return fmt.Errorf("expected struct map entry %s to be Size", name)
|
||||
}
|
||||
case "Size":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -388,19 +365,7 @@ func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
t.Size = uint64(extra)
|
||||
// t.CommP ([]uint8) (slice)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "CommP" {
|
||||
return fmt.Errorf("expected struct map entry %s to be CommP", name)
|
||||
}
|
||||
case "CommP":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -417,9 +382,14 @@ func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
||||
if _, err := io.ReadFull(br, t.CommP); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
||||
if t == nil {
|
||||
_, err := w.Write(cbg.CborNull)
|
||||
@ -477,7 +447,7 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.Pieces ([]storage.Piece) (slice)
|
||||
// t.Pieces ([]sealing.Piece) (slice)
|
||||
if len("Pieces") > cbg.MaxLength {
|
||||
return xerrors.Errorf("Value in field \"Pieces\" was too long")
|
||||
}
|
||||
@ -571,7 +541,7 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.Ticket (storage.SealTicket) (struct)
|
||||
// t.Ticket (sealing.SealTicket) (struct)
|
||||
if len("Ticket") > cbg.MaxLength {
|
||||
return xerrors.Errorf("Value in field \"Ticket\" was too long")
|
||||
}
|
||||
@ -609,7 +579,7 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
||||
}
|
||||
}
|
||||
|
||||
// t.Seed (storage.SealSeed) (struct)
|
||||
// t.Seed (sealing.SealSeed) (struct)
|
||||
if len("Seed") > cbg.MaxLength {
|
||||
return xerrors.Errorf("Value in field \"Seed\" was too long")
|
||||
}
|
||||
@ -705,13 +675,14 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
return fmt.Errorf("cbor input should be of type map")
|
||||
}
|
||||
|
||||
if extra != 13 {
|
||||
return fmt.Errorf("cbor input had wrong number of fields")
|
||||
if extra > cbg.MaxLength {
|
||||
return fmt.Errorf("SectorInfo: map struct too large (%d)", extra)
|
||||
}
|
||||
|
||||
var name string
|
||||
n := extra
|
||||
|
||||
// t.State (uint64) (uint64)
|
||||
for i := uint64(0); i < n; i++ {
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
@ -722,9 +693,9 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "State" {
|
||||
return fmt.Errorf("expected struct map entry %s to be State", name)
|
||||
}
|
||||
switch name {
|
||||
// t.State (uint64) (uint64)
|
||||
case "State":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -735,19 +706,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
t.State = uint64(extra)
|
||||
// t.SectorID (uint64) (uint64)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "SectorID" {
|
||||
return fmt.Errorf("expected struct map entry %s to be SectorID", name)
|
||||
}
|
||||
case "SectorID":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -758,19 +717,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
t.SectorID = uint64(extra)
|
||||
// t.Nonce (uint64) (uint64)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "Nonce" {
|
||||
return fmt.Errorf("expected struct map entry %s to be Nonce", name)
|
||||
}
|
||||
case "Nonce":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -780,20 +727,8 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
return fmt.Errorf("wrong type for uint64 field")
|
||||
}
|
||||
t.Nonce = uint64(extra)
|
||||
// t.Pieces ([]storage.Piece) (slice)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "Pieces" {
|
||||
return fmt.Errorf("expected struct map entry %s to be Pieces", name)
|
||||
}
|
||||
// t.Pieces ([]sealing.Piece) (slice)
|
||||
case "Pieces":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -821,19 +756,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
|
||||
// t.CommD ([]uint8) (slice)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "CommD" {
|
||||
return fmt.Errorf("expected struct map entry %s to be CommD", name)
|
||||
}
|
||||
case "CommD":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -851,19 +774,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
return err
|
||||
}
|
||||
// t.CommR ([]uint8) (slice)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "CommR" {
|
||||
return fmt.Errorf("expected struct map entry %s to be CommR", name)
|
||||
}
|
||||
case "CommR":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -881,19 +792,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
return err
|
||||
}
|
||||
// t.Proof ([]uint8) (slice)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "Proof" {
|
||||
return fmt.Errorf("expected struct map entry %s to be Proof", name)
|
||||
}
|
||||
case "Proof":
|
||||
|
||||
maj, extra, err = cbg.CborReadHeader(br)
|
||||
if err != nil {
|
||||
@ -910,20 +809,8 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
if _, err := io.ReadFull(br, t.Proof); err != nil {
|
||||
return err
|
||||
}
|
||||
// t.Ticket (storage.SealTicket) (struct)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "Ticket" {
|
||||
return fmt.Errorf("expected struct map entry %s to be Ticket", name)
|
||||
}
|
||||
// t.Ticket (sealing.SealTicket) (struct)
|
||||
case "Ticket":
|
||||
|
||||
{
|
||||
|
||||
@ -933,19 +820,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
|
||||
}
|
||||
// t.PreCommitMessage (cid.Cid) (struct)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "PreCommitMessage" {
|
||||
return fmt.Errorf("expected struct map entry %s to be PreCommitMessage", name)
|
||||
}
|
||||
case "PreCommitMessage":
|
||||
|
||||
{
|
||||
|
||||
@ -969,20 +844,8 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
}
|
||||
|
||||
}
|
||||
// t.Seed (storage.SealSeed) (struct)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "Seed" {
|
||||
return fmt.Errorf("expected struct map entry %s to be Seed", name)
|
||||
}
|
||||
// t.Seed (sealing.SealSeed) (struct)
|
||||
case "Seed":
|
||||
|
||||
{
|
||||
|
||||
@ -992,19 +855,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
|
||||
}
|
||||
// t.CommitMessage (cid.Cid) (struct)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "CommitMessage" {
|
||||
return fmt.Errorf("expected struct map entry %s to be CommitMessage", name)
|
||||
}
|
||||
case "CommitMessage":
|
||||
|
||||
{
|
||||
|
||||
@ -1029,19 +880,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
|
||||
}
|
||||
// t.FaultReportMsg (cid.Cid) (struct)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "FaultReportMsg" {
|
||||
return fmt.Errorf("expected struct map entry %s to be FaultReportMsg", name)
|
||||
}
|
||||
case "FaultReportMsg":
|
||||
|
||||
{
|
||||
|
||||
@ -1066,19 +905,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
|
||||
}
|
||||
// t.LastErr (string) (string)
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name = string(sval)
|
||||
}
|
||||
|
||||
if name != "LastErr" {
|
||||
return fmt.Errorf("expected struct map entry %s to be LastErr", name)
|
||||
}
|
||||
case "LastErr":
|
||||
|
||||
{
|
||||
sval, err := cbg.ReadString(br)
|
||||
@ -1088,5 +915,11 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
||||
|
||||
t.LastErr = string(sval)
|
||||
}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
11
fsm.go
11
fsm.go
@ -44,7 +44,10 @@ var fsmPlanners = []func(events []statemachine.Event, state *SectorInfo) error{
|
||||
on(SectorPreCommitFailed{}, api.PreCommitFailed),
|
||||
),
|
||||
api.Committing: planCommitting,
|
||||
api.CommitWait: planOne(on(SectorProving{}, api.Proving)),
|
||||
api.CommitWait: planOne(
|
||||
on(SectorProving{}, api.Proving),
|
||||
on(SectorCommitFailed{}, api.CommitFailed),
|
||||
),
|
||||
|
||||
api.Proving: planOne(
|
||||
on(SectorFaultReported{}, api.FaultReported),
|
||||
@ -233,11 +236,15 @@ func planOne(ts ...func() (mut mutator, next api.SectorState)) func(events []sta
|
||||
continue
|
||||
}
|
||||
|
||||
if err, iserr := events[0].User.(error); iserr {
|
||||
log.Warnf("sector %d got error event %T: %+v", state.SectorID, events[0].User, err)
|
||||
}
|
||||
|
||||
events[0].User.(mutator).apply(state)
|
||||
state.State = next
|
||||
return nil
|
||||
}
|
||||
|
||||
return xerrors.Errorf("planner for state %s received unexpected event %+v", events[0])
|
||||
return xerrors.Errorf("planner for state %s received unexpected event %+v", api.SectorStates[state.State], events[0])
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,11 @@ func (evt SectorSeedReady) apply(state *SectorInfo) {
|
||||
}
|
||||
|
||||
type SectorComputeProofFailed struct{ error }
|
||||
|
||||
type SectorCommitFailed struct{ error }
|
||||
|
||||
func (evt SectorCommitFailed) apply(*SectorInfo) {}
|
||||
|
||||
type SectorCommitted struct {
|
||||
message cid.Cid
|
||||
proof []byte
|
||||
|
@ -29,7 +29,7 @@ type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error)
|
||||
|
||||
type sealingApi interface { // TODO: trim down
|
||||
// Call a read only method on actors (no interaction with the chain required)
|
||||
StateCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error)
|
||||
StateCall(context.Context, *types.Message, *types.TipSet) (*api.MethodCall, error)
|
||||
StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error)
|
||||
StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error)
|
||||
StateMinerSectors(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error)
|
||||
@ -82,8 +82,6 @@ func New(api sealingApi, events *events.Events, maddr address.Address, worker ad
|
||||
}
|
||||
|
||||
func (m *Sealing) Run(ctx context.Context) error {
|
||||
m.events = events.NewEvents(ctx, m.api)
|
||||
|
||||
if err := m.restartSectors(ctx); err != nil {
|
||||
log.Errorf("%+v", err)
|
||||
return xerrors.Errorf("failed load sector states: %w", err)
|
||||
|
Loading…
Reference in New Issue
Block a user