diff --git a/builtin/v12/gen/gen.go b/builtin/v12/gen/gen.go index 2317583d..dce933e6 100644 --- a/builtin/v12/gen/gen.go +++ b/builtin/v12/gen/gen.go @@ -117,7 +117,7 @@ func main() { market.WithdrawBalanceParams{}, market.PublishStorageDealsParams{}, market.PublishStorageDealsReturn{}, - market.ActivateDealsParams{}, + market.BatchActivateDealsParams{}, market.ActivateDealsResult{}, market.VerifyDealsForActivationParams{}, market.VerifyDealsForActivationReturn{}, diff --git a/builtin/v12/market/cbor_gen.go b/builtin/v12/market/cbor_gen.go index eaf5235f..38f94147 100644 --- a/builtin/v12/market/cbor_gen.go +++ b/builtin/v12/market/cbor_gen.go @@ -738,9 +738,9 @@ func (t *PublishStorageDealsReturn) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufActivateDealsParams = []byte{130} +var lengthBufBatchActivateDealsParams = []byte{130} -func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { +func (t *BatchActivateDealsParams) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -748,42 +748,34 @@ func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write(lengthBufActivateDealsParams); err != nil { + if _, err := cw.Write(lengthBufBatchActivateDealsParams); err != nil { return err } - // t.DealIDs ([]abi.DealID) (slice) - if len(t.DealIDs) > 8192 { - return xerrors.Errorf("Slice value in field t.DealIDs was too long") + // t.Sectors ([]market.SectorDeals) (slice) + if len(t.Sectors) > 8192 { + return xerrors.Errorf("Slice value in field t.Sectors was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.DealIDs))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Sectors))); err != nil { return err } - for _, v := range t.DealIDs { - - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil { + for _, v := range t.Sectors { + if err := v.MarshalCBOR(cw); err != nil { return err } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - if t.SectorExpiry >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorExpiry)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SectorExpiry-1)); err != nil { - return err - } + // t.ComputeCid (bool) (bool) + if err := cbg.WriteBool(w, t.ComputeCid); err != nil { + return err } - return nil } -func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { - *t = ActivateDealsParams{} +func (t *BatchActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { + *t = BatchActivateDealsParams{} cr := cbg.NewCborReader(r) @@ -805,7 +797,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input had wrong number of fields") } - // t.DealIDs ([]abi.DealID) (slice) + // t.Sectors ([]market.SectorDeals) (slice) maj, extra, err = cr.ReadHeader() if err != nil { @@ -813,7 +805,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 8192 { - return fmt.Errorf("t.DealIDs: array too large (%d)", extra) + return fmt.Errorf("t.Sectors: array too large (%d)", extra) } if maj != cbg.MajArray { @@ -821,7 +813,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 0 { - t.DealIDs = make([]abi.DealID, extra) + t.Sectors = make([]SectorDeals, extra) } for i := 0; i < int(extra); i++ { @@ -835,43 +827,30 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { { - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") + if err := t.Sectors[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Sectors[i]: %w", err) } - t.DealIDs[i] = abi.DealID(extra) } } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } + // t.ComputeCid (bool) (bool) - t.SectorExpiry = abi.ChainEpoch(extraI) + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.ComputeCid = false + case 21: + t.ComputeCid = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } return nil } @@ -2041,7 +2020,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufSectorDeals = []byte{131} +var lengthBufSectorDeals = []byte{132} func (t *SectorDeals) MarshalCBOR(w io.Writer) error { if t == nil { @@ -2055,6 +2034,12 @@ func (t *SectorDeals) MarshalCBOR(w io.Writer) error { return err } + // t.SectorNumber (abi.SectorNumber) (uint64) + + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { + return err + } + // t.SectorType (abi.RegisteredSealProof) (int64) if t.SectorType >= 0 { if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorType)); err != nil { @@ -2114,10 +2099,24 @@ func (t *SectorDeals) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 3 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } + // t.SectorNumber (abi.SectorNumber) (uint64) + + { + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.SectorNumber = abi.SectorNumber(extra) + + } // t.SectorType (abi.RegisteredSealProof) (int64) { maj, extra, err := cr.ReadHeader() diff --git a/builtin/v12/market/market_types.go b/builtin/v12/market/market_types.go index 0ecd21bf..be98bb59 100644 --- a/builtin/v12/market/market_types.go +++ b/builtin/v12/market/market_types.go @@ -32,6 +32,7 @@ type VerifyDealsForActivationParams struct { } type SectorDeals struct { + SectorNumber abi.SectorNumber SectorType abi.RegisteredSealProof SectorExpiry abi.ChainEpoch DealIDs []abi.DealID @@ -42,9 +43,9 @@ type VerifyDealsForActivationReturn struct { UnsealedCIDs []*cid.Cid } -type ActivateDealsParams struct { - DealIDs []abi.DealID - SectorExpiry abi.ChainEpoch +type BatchActivateDealsParams struct { + Sectors []SectorDeals + ComputeCid bool } type ActivateDealsResult struct { diff --git a/builtin/v12/market/methods.go b/builtin/v12/market/methods.go index 068e45da..3846f09e 100644 --- a/builtin/v12/market/methods.go +++ b/builtin/v12/market/methods.go @@ -15,7 +15,7 @@ var Methods = map[abi.MethodNum]builtin.MethodMeta{ 4: builtin.NewMethodMeta("PublishStorageDeals", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDeals builtin.MustGenerateFRCMethodNum("PublishStorageDeals"): builtin.NewMethodMeta("PublishStorageDealsExported", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDealsExported 5: builtin.NewMethodMeta("VerifyDealsForActivation", *new(func(*VerifyDealsForActivationParams) *VerifyDealsForActivationReturn)), // VerifyDealsForActivation - 6: builtin.NewMethodMeta("ActivateDeals", *new(func(*ActivateDealsParams) *abi.EmptyValue)), // ActivateDeals + 6: builtin.NewMethodMeta("BatchActivateDeals", *new(func(*BatchActivateDealsParams) *abi.EmptyValue)), // BatchActivateDeals 7: builtin.NewMethodMeta("OnMinerSectorsTerminate", *new(func(*OnMinerSectorsTerminateParams) *abi.EmptyValue)), // OnMinerSectorsTerminate 8: builtin.NewMethodMeta("ComputeDataCommitment", nil), // deprecated 9: builtin.NewMethodMeta("CronTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // CronTick diff --git a/builtin/v13/gen/gen.go b/builtin/v13/gen/gen.go index 624d744e..9d84b7ef 100644 --- a/builtin/v13/gen/gen.go +++ b/builtin/v13/gen/gen.go @@ -118,7 +118,7 @@ func main() { market.WithdrawBalanceParams{}, market.PublishStorageDealsParams{}, market.PublishStorageDealsReturn{}, - market.ActivateDealsParams{}, + market.BatchActivateDealsParams{}, market.ActivateDealsResult{}, market.VerifyDealsForActivationParams{}, market.VerifyDealsForActivationReturn{}, diff --git a/builtin/v13/market/cbor_gen.go b/builtin/v13/market/cbor_gen.go index 2e226d55..82dbc79b 100644 --- a/builtin/v13/market/cbor_gen.go +++ b/builtin/v13/market/cbor_gen.go @@ -831,9 +831,9 @@ func (t *PublishStorageDealsReturn) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufActivateDealsParams = []byte{130} +var lengthBufBatchActivateDealsParams = []byte{130} -func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { +func (t *BatchActivateDealsParams) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -841,42 +841,34 @@ func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write(lengthBufActivateDealsParams); err != nil { + if _, err := cw.Write(lengthBufBatchActivateDealsParams); err != nil { return err } - // t.DealIDs ([]abi.DealID) (slice) - if len(t.DealIDs) > 8192 { - return xerrors.Errorf("Slice value in field t.DealIDs was too long") + // t.Sectors ([]market.SectorDeals) (slice) + if len(t.Sectors) > 8192 { + return xerrors.Errorf("Slice value in field t.Sectors was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.DealIDs))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Sectors))); err != nil { return err } - for _, v := range t.DealIDs { - - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil { + for _, v := range t.Sectors { + if err := v.MarshalCBOR(cw); err != nil { return err } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - if t.SectorExpiry >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorExpiry)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SectorExpiry-1)); err != nil { - return err - } + // t.ComputeCid (bool) (bool) + if err := cbg.WriteBool(w, t.ComputeCid); err != nil { + return err } - return nil } -func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { - *t = ActivateDealsParams{} +func (t *BatchActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { + *t = BatchActivateDealsParams{} cr := cbg.NewCborReader(r) @@ -898,7 +890,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input had wrong number of fields") } - // t.DealIDs ([]abi.DealID) (slice) + // t.Sectors ([]market.SectorDeals) (slice) maj, extra, err = cr.ReadHeader() if err != nil { @@ -906,7 +898,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 8192 { - return fmt.Errorf("t.DealIDs: array too large (%d)", extra) + return fmt.Errorf("t.Sectors: array too large (%d)", extra) } if maj != cbg.MajArray { @@ -914,7 +906,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 0 { - t.DealIDs = make([]abi.DealID, extra) + t.Sectors = make([]SectorDeals, extra) } for i := 0; i < int(extra); i++ { @@ -928,43 +920,30 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { { - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") + if err := t.Sectors[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Sectors[i]: %w", err) } - t.DealIDs[i] = abi.DealID(extra) } } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } + // t.ComputeCid (bool) (bool) - t.SectorExpiry = abi.ChainEpoch(extraI) + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.ComputeCid = false + case 21: + t.ComputeCid = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } return nil } @@ -2243,7 +2222,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufSectorDeals = []byte{131} +var lengthBufSectorDeals = []byte{132} func (t *SectorDeals) MarshalCBOR(w io.Writer) error { if t == nil { @@ -2257,6 +2236,12 @@ func (t *SectorDeals) MarshalCBOR(w io.Writer) error { return err } + // t.SectorNumber (abi.SectorNumber) (uint64) + + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { + return err + } + // t.SectorType (abi.RegisteredSealProof) (int64) if t.SectorType >= 0 { if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorType)); err != nil { @@ -2316,10 +2301,24 @@ func (t *SectorDeals) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 3 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } + // t.SectorNumber (abi.SectorNumber) (uint64) + + { + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.SectorNumber = abi.SectorNumber(extra) + + } // t.SectorType (abi.RegisteredSealProof) (int64) { maj, extra, err := cr.ReadHeader() diff --git a/builtin/v13/market/market_types.go b/builtin/v13/market/market_types.go index 9784f538..3ae9dcc8 100644 --- a/builtin/v13/market/market_types.go +++ b/builtin/v13/market/market_types.go @@ -35,6 +35,7 @@ type VerifyDealsForActivationParams struct { } type SectorDeals struct { + SectorNumber abi.SectorNumber SectorType abi.RegisteredSealProof SectorExpiry abi.ChainEpoch DealIDs []abi.DealID @@ -45,9 +46,9 @@ type VerifyDealsForActivationReturn struct { UnsealedCIDs []*cid.Cid } -type ActivateDealsParams struct { - DealIDs []abi.DealID - SectorExpiry abi.ChainEpoch +type BatchActivateDealsParams struct { + Sectors []SectorDeals + ComputeCid bool } type ActivateDealsResult struct { diff --git a/builtin/v13/market/methods.go b/builtin/v13/market/methods.go index d485df1e..4f8ecace 100644 --- a/builtin/v13/market/methods.go +++ b/builtin/v13/market/methods.go @@ -16,7 +16,7 @@ var Methods = map[abi.MethodNum]builtin.MethodMeta{ 4: builtin.NewMethodMeta("PublishStorageDeals", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDeals builtin.MustGenerateFRCMethodNum("PublishStorageDeals"): builtin.NewMethodMeta("PublishStorageDealsExported", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDealsExported 5: builtin.NewMethodMeta("VerifyDealsForActivation", *new(func(*VerifyDealsForActivationParams) *VerifyDealsForActivationReturn)), // VerifyDealsForActivation - 6: builtin.NewMethodMeta("ActivateDeals", *new(func(*ActivateDealsParams) *abi.EmptyValue)), // ActivateDeals + 6: builtin.NewMethodMeta("BatchActivateDeals", *new(func(*BatchActivateDealsParams) *abi.EmptyValue)), // BatchActivateDeals 7: builtin.NewMethodMeta("OnMinerSectorsTerminate", *new(func(*OnMinerSectorsTerminateParams) *abi.EmptyValue)), // OnMinerSectorsTerminate 8: builtin.NewMethodMeta("ComputeDataCommitment", nil), // deprecated 9: builtin.NewMethodMeta("CronTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // CronTick diff --git a/builtin/v14/gen/gen.go b/builtin/v14/gen/gen.go index 41163833..4e4ebf79 100644 --- a/builtin/v14/gen/gen.go +++ b/builtin/v14/gen/gen.go @@ -118,7 +118,7 @@ func main() { market.WithdrawBalanceParams{}, market.PublishStorageDealsParams{}, market.PublishStorageDealsReturn{}, - market.ActivateDealsParams{}, + market.BatchActivateDealsParams{}, market.ActivateDealsResult{}, market.VerifyDealsForActivationParams{}, market.VerifyDealsForActivationReturn{}, diff --git a/builtin/v14/market/cbor_gen.go b/builtin/v14/market/cbor_gen.go index 98aa9a3b..d3e65fec 100644 --- a/builtin/v14/market/cbor_gen.go +++ b/builtin/v14/market/cbor_gen.go @@ -831,9 +831,9 @@ func (t *PublishStorageDealsReturn) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufActivateDealsParams = []byte{130} +var lengthBufBatchActivateDealsParams = []byte{130} -func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { +func (t *BatchActivateDealsParams) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -841,42 +841,34 @@ func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write(lengthBufActivateDealsParams); err != nil { + if _, err := cw.Write(lengthBufBatchActivateDealsParams); err != nil { return err } - // t.DealIDs ([]abi.DealID) (slice) - if len(t.DealIDs) > 8192 { - return xerrors.Errorf("Slice value in field t.DealIDs was too long") + // t.Sectors ([]market.SectorDeals) (slice) + if len(t.Sectors) > 8192 { + return xerrors.Errorf("Slice value in field t.Sectors was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.DealIDs))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Sectors))); err != nil { return err } - for _, v := range t.DealIDs { - - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil { + for _, v := range t.Sectors { + if err := v.MarshalCBOR(cw); err != nil { return err } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - if t.SectorExpiry >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorExpiry)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SectorExpiry-1)); err != nil { - return err - } + // t.ComputeCid (bool) (bool) + if err := cbg.WriteBool(w, t.ComputeCid); err != nil { + return err } - return nil } -func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { - *t = ActivateDealsParams{} +func (t *BatchActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { + *t = BatchActivateDealsParams{} cr := cbg.NewCborReader(r) @@ -898,7 +890,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input had wrong number of fields") } - // t.DealIDs ([]abi.DealID) (slice) + // t.Sectors ([]market.SectorDeals) (slice) maj, extra, err = cr.ReadHeader() if err != nil { @@ -906,7 +898,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 8192 { - return fmt.Errorf("t.DealIDs: array too large (%d)", extra) + return fmt.Errorf("t.Sectors: array too large (%d)", extra) } if maj != cbg.MajArray { @@ -914,7 +906,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 0 { - t.DealIDs = make([]abi.DealID, extra) + t.Sectors = make([]SectorDeals, extra) } for i := 0; i < int(extra); i++ { @@ -928,43 +920,30 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { { - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") + if err := t.Sectors[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Sectors[i]: %w", err) } - t.DealIDs[i] = abi.DealID(extra) } } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } + // t.ComputeCid (bool) (bool) - t.SectorExpiry = abi.ChainEpoch(extraI) + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.ComputeCid = false + case 21: + t.ComputeCid = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } return nil } @@ -2243,7 +2222,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufSectorDeals = []byte{131} +var lengthBufSectorDeals = []byte{132} func (t *SectorDeals) MarshalCBOR(w io.Writer) error { if t == nil { @@ -2257,6 +2236,12 @@ func (t *SectorDeals) MarshalCBOR(w io.Writer) error { return err } + // t.SectorNumber (abi.SectorNumber) (uint64) + + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { + return err + } + // t.SectorType (abi.RegisteredSealProof) (int64) if t.SectorType >= 0 { if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorType)); err != nil { @@ -2316,10 +2301,24 @@ func (t *SectorDeals) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 3 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } + // t.SectorNumber (abi.SectorNumber) (uint64) + + { + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.SectorNumber = abi.SectorNumber(extra) + + } // t.SectorType (abi.RegisteredSealProof) (int64) { maj, extra, err := cr.ReadHeader() diff --git a/builtin/v14/market/market_types.go b/builtin/v14/market/market_types.go index 882cafb6..2b07ec67 100644 --- a/builtin/v14/market/market_types.go +++ b/builtin/v14/market/market_types.go @@ -35,6 +35,7 @@ type VerifyDealsForActivationParams struct { } type SectorDeals struct { + SectorNumber abi.SectorNumber SectorType abi.RegisteredSealProof SectorExpiry abi.ChainEpoch DealIDs []abi.DealID @@ -45,9 +46,9 @@ type VerifyDealsForActivationReturn struct { UnsealedCIDs []*cid.Cid } -type ActivateDealsParams struct { - DealIDs []abi.DealID - SectorExpiry abi.ChainEpoch +type BatchActivateDealsParams struct { + Sectors []SectorDeals + ComputeCid bool } type ActivateDealsResult struct { diff --git a/builtin/v14/market/methods.go b/builtin/v14/market/methods.go index 18b2e129..e2fafd71 100644 --- a/builtin/v14/market/methods.go +++ b/builtin/v14/market/methods.go @@ -16,7 +16,7 @@ var Methods = map[abi.MethodNum]builtin.MethodMeta{ 4: builtin.NewMethodMeta("PublishStorageDeals", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDeals builtin.MustGenerateFRCMethodNum("PublishStorageDeals"): builtin.NewMethodMeta("PublishStorageDealsExported", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDealsExported 5: builtin.NewMethodMeta("VerifyDealsForActivation", *new(func(*VerifyDealsForActivationParams) *VerifyDealsForActivationReturn)), // VerifyDealsForActivation - 6: builtin.NewMethodMeta("ActivateDeals", *new(func(*ActivateDealsParams) *abi.EmptyValue)), // ActivateDeals + 6: builtin.NewMethodMeta("BatchActivateDeals", *new(func(*BatchActivateDealsParams) *abi.EmptyValue)), // BatchActivateDeals 7: builtin.NewMethodMeta("OnMinerSectorsTerminate", *new(func(*OnMinerSectorsTerminateParams) *abi.EmptyValue)), // OnMinerSectorsTerminate 8: builtin.NewMethodMeta("ComputeDataCommitment", nil), // deprecated 9: builtin.NewMethodMeta("CronTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // CronTick diff --git a/builtin/v15/gen/gen.go b/builtin/v15/gen/gen.go index a80d9904..ba98afc9 100644 --- a/builtin/v15/gen/gen.go +++ b/builtin/v15/gen/gen.go @@ -118,7 +118,7 @@ func main() { market.WithdrawBalanceParams{}, market.PublishStorageDealsParams{}, market.PublishStorageDealsReturn{}, - market.ActivateDealsParams{}, + market.BatchActivateDealsParams{}, market.ActivateDealsResult{}, market.VerifyDealsForActivationParams{}, market.VerifyDealsForActivationReturn{}, diff --git a/builtin/v15/market/cbor_gen.go b/builtin/v15/market/cbor_gen.go index efa1a870..9e1f8044 100644 --- a/builtin/v15/market/cbor_gen.go +++ b/builtin/v15/market/cbor_gen.go @@ -831,9 +831,9 @@ func (t *PublishStorageDealsReturn) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufActivateDealsParams = []byte{130} +var lengthBufBatchActivateDealsParams = []byte{130} -func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { +func (t *BatchActivateDealsParams) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -841,42 +841,34 @@ func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write(lengthBufActivateDealsParams); err != nil { + if _, err := cw.Write(lengthBufBatchActivateDealsParams); err != nil { return err } - // t.DealIDs ([]abi.DealID) (slice) - if len(t.DealIDs) > 8192 { - return xerrors.Errorf("Slice value in field t.DealIDs was too long") + // t.Sectors ([]market.SectorDeals) (slice) + if len(t.Sectors) > 8192 { + return xerrors.Errorf("Slice value in field t.Sectors was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.DealIDs))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Sectors))); err != nil { return err } - for _, v := range t.DealIDs { - - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil { + for _, v := range t.Sectors { + if err := v.MarshalCBOR(cw); err != nil { return err } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - if t.SectorExpiry >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorExpiry)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SectorExpiry-1)); err != nil { - return err - } + // t.ComputeCid (bool) (bool) + if err := cbg.WriteBool(w, t.ComputeCid); err != nil { + return err } - return nil } -func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { - *t = ActivateDealsParams{} +func (t *BatchActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { + *t = BatchActivateDealsParams{} cr := cbg.NewCborReader(r) @@ -898,7 +890,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input had wrong number of fields") } - // t.DealIDs ([]abi.DealID) (slice) + // t.Sectors ([]market.SectorDeals) (slice) maj, extra, err = cr.ReadHeader() if err != nil { @@ -906,7 +898,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 8192 { - return fmt.Errorf("t.DealIDs: array too large (%d)", extra) + return fmt.Errorf("t.Sectors: array too large (%d)", extra) } if maj != cbg.MajArray { @@ -914,7 +906,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 0 { - t.DealIDs = make([]abi.DealID, extra) + t.Sectors = make([]SectorDeals, extra) } for i := 0; i < int(extra); i++ { @@ -928,43 +920,30 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { { - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") + if err := t.Sectors[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Sectors[i]: %w", err) } - t.DealIDs[i] = abi.DealID(extra) } } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } + // t.ComputeCid (bool) (bool) - t.SectorExpiry = abi.ChainEpoch(extraI) + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.ComputeCid = false + case 21: + t.ComputeCid = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } return nil } @@ -2243,7 +2222,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufSectorDeals = []byte{131} +var lengthBufSectorDeals = []byte{132} func (t *SectorDeals) MarshalCBOR(w io.Writer) error { if t == nil { @@ -2257,6 +2236,12 @@ func (t *SectorDeals) MarshalCBOR(w io.Writer) error { return err } + // t.SectorNumber (abi.SectorNumber) (uint64) + + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { + return err + } + // t.SectorType (abi.RegisteredSealProof) (int64) if t.SectorType >= 0 { if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorType)); err != nil { @@ -2316,10 +2301,24 @@ func (t *SectorDeals) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 3 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } + // t.SectorNumber (abi.SectorNumber) (uint64) + + { + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.SectorNumber = abi.SectorNumber(extra) + + } // t.SectorType (abi.RegisteredSealProof) (int64) { maj, extra, err := cr.ReadHeader() diff --git a/builtin/v15/market/market_types.go b/builtin/v15/market/market_types.go index 8bbd1fd6..4212ee99 100644 --- a/builtin/v15/market/market_types.go +++ b/builtin/v15/market/market_types.go @@ -35,6 +35,7 @@ type VerifyDealsForActivationParams struct { } type SectorDeals struct { + SectorNumber abi.SectorNumber SectorType abi.RegisteredSealProof SectorExpiry abi.ChainEpoch DealIDs []abi.DealID @@ -45,9 +46,9 @@ type VerifyDealsForActivationReturn struct { UnsealedCIDs []*cid.Cid } -type ActivateDealsParams struct { - DealIDs []abi.DealID - SectorExpiry abi.ChainEpoch +type BatchActivateDealsParams struct { + Sectors []SectorDeals + ComputeCid bool } type ActivateDealsResult struct { diff --git a/builtin/v15/market/methods.go b/builtin/v15/market/methods.go index aeebacda..7fca74e1 100644 --- a/builtin/v15/market/methods.go +++ b/builtin/v15/market/methods.go @@ -16,7 +16,7 @@ var Methods = map[abi.MethodNum]builtin.MethodMeta{ 4: builtin.NewMethodMeta("PublishStorageDeals", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDeals builtin.MustGenerateFRCMethodNum("PublishStorageDeals"): builtin.NewMethodMeta("PublishStorageDealsExported", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDealsExported 5: builtin.NewMethodMeta("VerifyDealsForActivation", *new(func(*VerifyDealsForActivationParams) *VerifyDealsForActivationReturn)), // VerifyDealsForActivation - 6: builtin.NewMethodMeta("ActivateDeals", *new(func(*ActivateDealsParams) *abi.EmptyValue)), // ActivateDeals + 6: builtin.NewMethodMeta("BatchActivateDeals", *new(func(*BatchActivateDealsParams) *abi.EmptyValue)), // BatchActivateDeals 7: builtin.NewMethodMeta("OnMinerSectorsTerminate", *new(func(*OnMinerSectorsTerminateParams) *abi.EmptyValue)), // OnMinerSectorsTerminate 8: builtin.NewMethodMeta("ComputeDataCommitment", nil), // deprecated 9: builtin.NewMethodMeta("CronTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // CronTick diff --git a/builtin/v16/gen/gen.go b/builtin/v16/gen/gen.go index 37c32971..343a0547 100644 --- a/builtin/v16/gen/gen.go +++ b/builtin/v16/gen/gen.go @@ -119,7 +119,7 @@ func main() { market.WithdrawBalanceParams{}, market.PublishStorageDealsParams{}, market.PublishStorageDealsReturn{}, - market.ActivateDealsParams{}, + market.BatchActivateDealsParams{}, market.ActivateDealsResult{}, market.VerifyDealsForActivationParams{}, market.VerifyDealsForActivationReturn{}, diff --git a/builtin/v16/market/cbor_gen.go b/builtin/v16/market/cbor_gen.go index 2ec1f14d..405da732 100644 --- a/builtin/v16/market/cbor_gen.go +++ b/builtin/v16/market/cbor_gen.go @@ -831,9 +831,9 @@ func (t *PublishStorageDealsReturn) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufActivateDealsParams = []byte{130} +var lengthBufBatchActivateDealsParams = []byte{130} -func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { +func (t *BatchActivateDealsParams) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -841,42 +841,34 @@ func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write(lengthBufActivateDealsParams); err != nil { + if _, err := cw.Write(lengthBufBatchActivateDealsParams); err != nil { return err } - // t.DealIDs ([]abi.DealID) (slice) - if len(t.DealIDs) > 8192 { - return xerrors.Errorf("Slice value in field t.DealIDs was too long") + // t.Sectors ([]market.SectorDeals) (slice) + if len(t.Sectors) > 8192 { + return xerrors.Errorf("Slice value in field t.Sectors was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.DealIDs))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Sectors))); err != nil { return err } - for _, v := range t.DealIDs { - - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil { + for _, v := range t.Sectors { + if err := v.MarshalCBOR(cw); err != nil { return err } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - if t.SectorExpiry >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorExpiry)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SectorExpiry-1)); err != nil { - return err - } + // t.ComputeCid (bool) (bool) + if err := cbg.WriteBool(w, t.ComputeCid); err != nil { + return err } - return nil } -func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { - *t = ActivateDealsParams{} +func (t *BatchActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { + *t = BatchActivateDealsParams{} cr := cbg.NewCborReader(r) @@ -898,7 +890,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input had wrong number of fields") } - // t.DealIDs ([]abi.DealID) (slice) + // t.Sectors ([]market.SectorDeals) (slice) maj, extra, err = cr.ReadHeader() if err != nil { @@ -906,7 +898,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 8192 { - return fmt.Errorf("t.DealIDs: array too large (%d)", extra) + return fmt.Errorf("t.Sectors: array too large (%d)", extra) } if maj != cbg.MajArray { @@ -914,7 +906,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 0 { - t.DealIDs = make([]abi.DealID, extra) + t.Sectors = make([]SectorDeals, extra) } for i := 0; i < int(extra); i++ { @@ -928,43 +920,30 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { { - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") + if err := t.Sectors[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Sectors[i]: %w", err) } - t.DealIDs[i] = abi.DealID(extra) } } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } + // t.ComputeCid (bool) (bool) - t.SectorExpiry = abi.ChainEpoch(extraI) + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.ComputeCid = false + case 21: + t.ComputeCid = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } return nil } @@ -2243,7 +2222,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufSectorDeals = []byte{131} +var lengthBufSectorDeals = []byte{132} func (t *SectorDeals) MarshalCBOR(w io.Writer) error { if t == nil { @@ -2257,6 +2236,12 @@ func (t *SectorDeals) MarshalCBOR(w io.Writer) error { return err } + // t.SectorNumber (abi.SectorNumber) (uint64) + + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { + return err + } + // t.SectorType (abi.RegisteredSealProof) (int64) if t.SectorType >= 0 { if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorType)); err != nil { @@ -2316,10 +2301,24 @@ func (t *SectorDeals) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 3 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } + // t.SectorNumber (abi.SectorNumber) (uint64) + + { + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.SectorNumber = abi.SectorNumber(extra) + + } // t.SectorType (abi.RegisteredSealProof) (int64) { maj, extra, err := cr.ReadHeader() diff --git a/builtin/v16/market/market_types.go b/builtin/v16/market/market_types.go index 2c95fb5d..4cd23057 100644 --- a/builtin/v16/market/market_types.go +++ b/builtin/v16/market/market_types.go @@ -35,6 +35,7 @@ type VerifyDealsForActivationParams struct { } type SectorDeals struct { + SectorNumber abi.SectorNumber SectorType abi.RegisteredSealProof SectorExpiry abi.ChainEpoch DealIDs []abi.DealID @@ -45,9 +46,9 @@ type VerifyDealsForActivationReturn struct { UnsealedCIDs []*cid.Cid } -type ActivateDealsParams struct { - DealIDs []abi.DealID - SectorExpiry abi.ChainEpoch +type BatchActivateDealsParams struct { + Sectors []SectorDeals + ComputeCid bool } type ActivateDealsResult struct { diff --git a/builtin/v16/market/methods.go b/builtin/v16/market/methods.go index 328b8e6b..14f93111 100644 --- a/builtin/v16/market/methods.go +++ b/builtin/v16/market/methods.go @@ -16,7 +16,7 @@ var Methods = map[abi.MethodNum]builtin.MethodMeta{ 4: builtin.NewMethodMeta("PublishStorageDeals", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDeals builtin.MustGenerateFRCMethodNum("PublishStorageDeals"): builtin.NewMethodMeta("PublishStorageDealsExported", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDealsExported 5: builtin.NewMethodMeta("VerifyDealsForActivation", *new(func(*VerifyDealsForActivationParams) *VerifyDealsForActivationReturn)), // VerifyDealsForActivation - 6: builtin.NewMethodMeta("ActivateDeals", *new(func(*ActivateDealsParams) *abi.EmptyValue)), // ActivateDeals + 6: builtin.NewMethodMeta("BatchActivateDeals", *new(func(*BatchActivateDealsParams) *abi.EmptyValue)), // BatchActivateDeals 7: builtin.NewMethodMeta("OnMinerSectorsTerminate", *new(func(*OnMinerSectorsTerminateParams) *abi.EmptyValue)), // OnMinerSectorsTerminate 8: builtin.NewMethodMeta("ComputeDataCommitment", nil), // deprecated 9: builtin.NewMethodMeta("CronTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // CronTick diff --git a/builtin/v17/gen/gen.go b/builtin/v17/gen/gen.go index 4184f1fd..915e23bb 100644 --- a/builtin/v17/gen/gen.go +++ b/builtin/v17/gen/gen.go @@ -119,7 +119,7 @@ func main() { market.WithdrawBalanceParams{}, market.PublishStorageDealsParams{}, market.PublishStorageDealsReturn{}, - market.ActivateDealsParams{}, + market.BatchActivateDealsParams{}, market.ActivateDealsResult{}, market.VerifyDealsForActivationParams{}, market.VerifyDealsForActivationReturn{}, diff --git a/builtin/v17/market/cbor_gen.go b/builtin/v17/market/cbor_gen.go index e7e001f5..b3549b41 100644 --- a/builtin/v17/market/cbor_gen.go +++ b/builtin/v17/market/cbor_gen.go @@ -831,9 +831,9 @@ func (t *PublishStorageDealsReturn) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufActivateDealsParams = []byte{130} +var lengthBufBatchActivateDealsParams = []byte{130} -func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { +func (t *BatchActivateDealsParams) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -841,42 +841,34 @@ func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write(lengthBufActivateDealsParams); err != nil { + if _, err := cw.Write(lengthBufBatchActivateDealsParams); err != nil { return err } - // t.DealIDs ([]abi.DealID) (slice) - if len(t.DealIDs) > 8192 { - return xerrors.Errorf("Slice value in field t.DealIDs was too long") + // t.Sectors ([]market.SectorDeals) (slice) + if len(t.Sectors) > 8192 { + return xerrors.Errorf("Slice value in field t.Sectors was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.DealIDs))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Sectors))); err != nil { return err } - for _, v := range t.DealIDs { - - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil { + for _, v := range t.Sectors { + if err := v.MarshalCBOR(cw); err != nil { return err } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - if t.SectorExpiry >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorExpiry)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SectorExpiry-1)); err != nil { - return err - } + // t.ComputeCid (bool) (bool) + if err := cbg.WriteBool(w, t.ComputeCid); err != nil { + return err } - return nil } -func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { - *t = ActivateDealsParams{} +func (t *BatchActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { + *t = BatchActivateDealsParams{} cr := cbg.NewCborReader(r) @@ -898,7 +890,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input had wrong number of fields") } - // t.DealIDs ([]abi.DealID) (slice) + // t.Sectors ([]market.SectorDeals) (slice) maj, extra, err = cr.ReadHeader() if err != nil { @@ -906,7 +898,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 8192 { - return fmt.Errorf("t.DealIDs: array too large (%d)", extra) + return fmt.Errorf("t.Sectors: array too large (%d)", extra) } if maj != cbg.MajArray { @@ -914,7 +906,7 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 0 { - t.DealIDs = make([]abi.DealID, extra) + t.Sectors = make([]SectorDeals, extra) } for i := 0; i < int(extra); i++ { @@ -928,43 +920,30 @@ func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) (err error) { { - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") + if err := t.Sectors[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Sectors[i]: %w", err) } - t.DealIDs[i] = abi.DealID(extra) } } } - // t.SectorExpiry (abi.ChainEpoch) (int64) - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } + // t.ComputeCid (bool) (bool) - t.SectorExpiry = abi.ChainEpoch(extraI) + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.ComputeCid = false + case 21: + t.ComputeCid = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } return nil } @@ -2243,7 +2222,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) (err error) { return nil } -var lengthBufSectorDeals = []byte{131} +var lengthBufSectorDeals = []byte{132} func (t *SectorDeals) MarshalCBOR(w io.Writer) error { if t == nil { @@ -2257,6 +2236,12 @@ func (t *SectorDeals) MarshalCBOR(w io.Writer) error { return err } + // t.SectorNumber (abi.SectorNumber) (uint64) + + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { + return err + } + // t.SectorType (abi.RegisteredSealProof) (int64) if t.SectorType >= 0 { if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorType)); err != nil { @@ -2316,10 +2301,24 @@ func (t *SectorDeals) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 3 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } + // t.SectorNumber (abi.SectorNumber) (uint64) + + { + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.SectorNumber = abi.SectorNumber(extra) + + } // t.SectorType (abi.RegisteredSealProof) (int64) { maj, extra, err := cr.ReadHeader() diff --git a/builtin/v17/market/market_types.go b/builtin/v17/market/market_types.go index ede26332..8c49875f 100644 --- a/builtin/v17/market/market_types.go +++ b/builtin/v17/market/market_types.go @@ -35,6 +35,7 @@ type VerifyDealsForActivationParams struct { } type SectorDeals struct { + SectorNumber abi.SectorNumber SectorType abi.RegisteredSealProof SectorExpiry abi.ChainEpoch DealIDs []abi.DealID @@ -45,9 +46,9 @@ type VerifyDealsForActivationReturn struct { UnsealedCIDs []*cid.Cid } -type ActivateDealsParams struct { - DealIDs []abi.DealID - SectorExpiry abi.ChainEpoch +type BatchActivateDealsParams struct { + Sectors []SectorDeals + ComputeCid bool } type ActivateDealsResult struct { diff --git a/builtin/v17/market/methods.go b/builtin/v17/market/methods.go index f8acef31..78a24ca6 100644 --- a/builtin/v17/market/methods.go +++ b/builtin/v17/market/methods.go @@ -16,7 +16,7 @@ var Methods = map[abi.MethodNum]builtin.MethodMeta{ 4: builtin.NewMethodMeta("PublishStorageDeals", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDeals builtin.MustGenerateFRCMethodNum("PublishStorageDeals"): builtin.NewMethodMeta("PublishStorageDealsExported", *new(func(*PublishStorageDealsParams) *PublishStorageDealsReturn)), // PublishStorageDealsExported 5: builtin.NewMethodMeta("VerifyDealsForActivation", *new(func(*VerifyDealsForActivationParams) *VerifyDealsForActivationReturn)), // VerifyDealsForActivation - 6: builtin.NewMethodMeta("ActivateDeals", *new(func(*ActivateDealsParams) *abi.EmptyValue)), // ActivateDeals + 6: builtin.NewMethodMeta("BatchActivateDeals", *new(func(*BatchActivateDealsParams) *abi.EmptyValue)), // BatchActivateDeals 7: builtin.NewMethodMeta("OnMinerSectorsTerminate", *new(func(*OnMinerSectorsTerminateParams) *abi.EmptyValue)), // OnMinerSectorsTerminate 8: builtin.NewMethodMeta("ComputeDataCommitment", nil), // deprecated 9: builtin.NewMethodMeta("CronTick", *new(func(*abi.EmptyValue) *abi.EmptyValue)), // CronTick