lotus/storage/sealer/cbor_gen.go

603 lines
12 KiB
Go
Raw Normal View History

2020-09-14 07:44:55 +00:00
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package sealer
2020-09-14 07:44:55 +00:00
import (
"fmt"
"io"
integrate DAG store and CARv2 in deal-making (#6671) This commit removes badger from the deal-making processes, and moves to a new architecture with the dagstore as the cental component on the miner-side, and CARv2s on the client-side. Every deal that has been handed off to the sealing subsystem becomes a shard in the dagstore. Shards are mounted via the LotusMount, which teaches the dagstore how to load the related piece when serving retrievals. When the miner starts the Lotus for the first time with this patch, we will perform a one-time migration of all active deals into the dagstore. This is a lightweight process, and it consists simply of registering the shards in the dagstore. Shards are backed by the unsealed copy of the piece. This is currently a CARv1. However, the dagstore keeps CARv2 indices for all pieces, so when it's time to acquire a shard to serve a retrieval, the unsealed CARv1 is joined with its index (safeguarded by the dagstore), to form a read-only blockstore, thus taking the place of the monolithic badger. Data transfers have been adjusted to interface directly with CARv2 files. On inbound transfers (client retrievals, miner storage deals), we stream the received data into a CARv2 ReadWrite blockstore. On outbound transfers (client storage deals, miner retrievals), we serve the data off a CARv2 ReadOnly blockstore. Client-side imports are managed by the refactored *imports.Manager component (when not using IPFS integration). Just like it before, we use the go-filestore library to avoid duplicating the data from the original file in the resulting UnixFS DAG (concretely the leaves). However, the target of those imports are what we call "ref-CARv2s": CARv2 files placed under the `$LOTUS_PATH/imports` directory, containing the intermediate nodes in full, and the leaves as positional references to the original file on disk. Client-side retrievals are placed into CARv2 files in the location: `$LOTUS_PATH/retrievals`. A new set of `Dagstore*` JSON-RPC operations and `lotus-miner dagstore` subcommands have been introduced on the miner-side to inspect and manage the dagstore. Despite moving to a CARv2-backed system, the IPFS integration has been respected, and it continues to be possible to make storage deals with data held in an IPFS node, and to perform retrievals directly into an IPFS node. NOTE: because the "staging" and "client" Badger blockstores are no longer used, existing imports on the client will be rendered useless. On startup, Lotus will enumerate all imports and print WARN statements on the log for each import that needs to be reimported. These log lines contain these messages: - import lacks carv2 path; import will not work; please reimport - import has missing/broken carv2; please reimport At the end, we will print a "sanity check completed" message indicating the count of imports found, and how many were deemed broken. Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com> Co-authored-by: Raúl Kripalani <raul@protocol.ai> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com>
2021-08-16 22:34:32 +00:00
"math"
"sort"
2020-09-14 07:44:55 +00:00
cid "github.com/ipfs/go-cid"
2020-09-14 07:44:55 +00:00
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
2022-06-14 15:00:51 +00:00
2022-06-14 18:08:10 +00:00
sealtasks "github.com/filecoin-project/lotus/storage/sealer/sealtasks"
2020-09-14 07:44:55 +00:00
)
var _ = xerrors.Errorf
var _ = cid.Undef
integrate DAG store and CARv2 in deal-making (#6671) This commit removes badger from the deal-making processes, and moves to a new architecture with the dagstore as the cental component on the miner-side, and CARv2s on the client-side. Every deal that has been handed off to the sealing subsystem becomes a shard in the dagstore. Shards are mounted via the LotusMount, which teaches the dagstore how to load the related piece when serving retrievals. When the miner starts the Lotus for the first time with this patch, we will perform a one-time migration of all active deals into the dagstore. This is a lightweight process, and it consists simply of registering the shards in the dagstore. Shards are backed by the unsealed copy of the piece. This is currently a CARv1. However, the dagstore keeps CARv2 indices for all pieces, so when it's time to acquire a shard to serve a retrieval, the unsealed CARv1 is joined with its index (safeguarded by the dagstore), to form a read-only blockstore, thus taking the place of the monolithic badger. Data transfers have been adjusted to interface directly with CARv2 files. On inbound transfers (client retrievals, miner storage deals), we stream the received data into a CARv2 ReadWrite blockstore. On outbound transfers (client storage deals, miner retrievals), we serve the data off a CARv2 ReadOnly blockstore. Client-side imports are managed by the refactored *imports.Manager component (when not using IPFS integration). Just like it before, we use the go-filestore library to avoid duplicating the data from the original file in the resulting UnixFS DAG (concretely the leaves). However, the target of those imports are what we call "ref-CARv2s": CARv2 files placed under the `$LOTUS_PATH/imports` directory, containing the intermediate nodes in full, and the leaves as positional references to the original file on disk. Client-side retrievals are placed into CARv2 files in the location: `$LOTUS_PATH/retrievals`. A new set of `Dagstore*` JSON-RPC operations and `lotus-miner dagstore` subcommands have been introduced on the miner-side to inspect and manage the dagstore. Despite moving to a CARv2-backed system, the IPFS integration has been respected, and it continues to be possible to make storage deals with data held in an IPFS node, and to perform retrievals directly into an IPFS node. NOTE: because the "staging" and "client" Badger blockstores are no longer used, existing imports on the client will be rendered useless. On startup, Lotus will enumerate all imports and print WARN statements on the log for each import that needs to be reimported. These log lines contain these messages: - import lacks carv2 path; import will not work; please reimport - import has missing/broken carv2; please reimport At the end, we will print a "sanity check completed" message indicating the count of imports found, and how many were deemed broken. Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com> Co-authored-by: Raúl Kripalani <raul@protocol.ai> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com>
2021-08-16 22:34:32 +00:00
var _ = math.E
var _ = sort.Sort
2020-09-14 07:44:55 +00:00
func (t *Call) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{164}); err != nil {
2020-09-14 07:44:55 +00:00
return err
}
// t.ID (storiface.CallID) (struct)
if len("ID") > 8192 {
return xerrors.Errorf("Value in field \"ID\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ID"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("ID")); err != nil {
return err
}
2022-05-23 19:11:46 +00:00
if err := t.ID.MarshalCBOR(cw); err != nil {
return err
}
2022-06-14 18:08:10 +00:00
// t.State (sealer.CallState) (uint64)
if len("State") > 8192 {
2020-09-14 07:44:55 +00:00
return xerrors.Errorf("Value in field \"State\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("State"))); err != nil {
2020-09-14 07:44:55 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("State")); err != nil {
2020-09-14 07:44:55 +00:00
return err
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.State)); err != nil {
2020-09-14 07:44:55 +00:00
return err
}
2022-06-14 18:08:10 +00:00
// t.Result (sealer.ManyBytes) (struct)
if len("Result") > 8192 {
2020-09-14 07:44:55 +00:00
return xerrors.Errorf("Value in field \"Result\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Result"))); err != nil {
2020-09-14 07:44:55 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Result")); err != nil {
2020-09-14 07:44:55 +00:00
return err
}
2022-05-23 19:11:46 +00:00
if err := t.Result.MarshalCBOR(cw); err != nil {
2020-09-14 18:28:47 +00:00
return err
}
// t.RetType (sealer.ReturnType) (string)
if len("RetType") > 8192 {
return xerrors.Errorf("Value in field \"RetType\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RetType"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RetType")); err != nil {
return err
}
if len(t.RetType) > 8192 {
return xerrors.Errorf("Value in field t.RetType was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RetType))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.RetType)); err != nil {
return err
}
2020-09-14 07:44:55 +00:00
return nil
}
2022-05-23 19:11:46 +00:00
func (t *Call) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-14 07:44:55 +00:00
*t = Call{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-14 07:44:55 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-14 07:44:55 +00:00
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2020-09-14 07:44:55 +00:00
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
if extra > cbg.MaxLength {
return fmt.Errorf("Call: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
2020-09-14 07:44:55 +00:00
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.ID (storiface.CallID) (struct)
case "ID":
{
2022-05-23 19:11:46 +00:00
if err := t.ID.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.ID: %w", err)
}
}
2022-06-14 18:08:10 +00:00
// t.State (sealer.CallState) (uint64)
2020-09-14 07:44:55 +00:00
case "State":
{
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-14 07:44:55 +00:00
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.State = CallState(extra)
}
2022-06-14 18:08:10 +00:00
// t.Result (sealer.ManyBytes) (struct)
2020-09-14 07:44:55 +00:00
case "Result":
{
2020-09-14 18:28:47 +00:00
2022-05-23 19:11:46 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-05-23 19:11:46 +00:00
if err := cr.UnreadByte(); err != nil {
return err
}
t.Result = new(ManyBytes)
2022-05-23 19:11:46 +00:00
if err := t.Result.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Result pointer: %w", err)
}
}
2020-09-14 07:44:55 +00:00
}
// t.RetType (sealer.ReturnType) (string)
case "RetType":
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
t.RetType = ReturnType(sval)
}
2020-09-14 07:44:55 +00:00
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
2020-09-14 07:44:55 +00:00
}
}
return nil
}
func (t *WorkState) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{166}); err != nil {
return err
}
2022-06-14 18:08:10 +00:00
// t.ID (sealer.WorkID) (struct)
if len("ID") > 8192 {
return xerrors.Errorf("Value in field \"ID\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ID"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("ID")); err != nil {
return err
}
2022-05-23 19:11:46 +00:00
if err := t.ID.MarshalCBOR(cw); err != nil {
return err
}
2022-06-14 18:08:10 +00:00
// t.Status (sealer.WorkStatus) (string)
if len("Status") > 8192 {
return xerrors.Errorf("Value in field \"Status\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Status"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Status")); err != nil {
return err
}
if len(t.Status) > 8192 {
return xerrors.Errorf("Value in field t.Status was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Status)); err != nil {
return err
}
// t.StartTime (int64) (int64)
if len("StartTime") > 8192 {
return xerrors.Errorf("Value in field \"StartTime\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("StartTime"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("StartTime")); err != nil {
return err
}
if t.StartTime >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.StartTime)); err != nil {
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.StartTime-1)); err != nil {
return err
}
}
// t.WorkError (string) (string)
if len("WorkError") > 8192 {
return xerrors.Errorf("Value in field \"WorkError\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("WorkError"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("WorkError")); err != nil {
return err
}
if len(t.WorkError) > 8192 {
return xerrors.Errorf("Value in field t.WorkError was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.WorkError))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.WorkError)); err != nil {
return err
}
// t.WorkerCall (storiface.CallID) (struct)
if len("WorkerCall") > 8192 {
return xerrors.Errorf("Value in field \"WorkerCall\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("WorkerCall"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("WorkerCall")); err != nil {
return err
}
if err := t.WorkerCall.MarshalCBOR(cw); err != nil {
return err
}
// t.WorkerHostname (string) (string)
if len("WorkerHostname") > 8192 {
return xerrors.Errorf("Value in field \"WorkerHostname\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("WorkerHostname"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("WorkerHostname")); err != nil {
return err
}
if len(t.WorkerHostname) > 8192 {
return xerrors.Errorf("Value in field t.WorkerHostname was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.WorkerHostname))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.WorkerHostname)); err != nil {
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *WorkState) UnmarshalCBOR(r io.Reader) (err error) {
*t = WorkState{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
if extra > cbg.MaxLength {
return fmt.Errorf("WorkState: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
name = string(sval)
}
switch name {
2022-06-14 18:08:10 +00:00
// t.ID (sealer.WorkID) (struct)
case "ID":
{
2022-05-23 19:11:46 +00:00
if err := t.ID.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.ID: %w", err)
}
}
2022-06-14 18:08:10 +00:00
// t.Status (sealer.WorkStatus) (string)
case "Status":
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
t.Status = WorkStatus(sval)
}
// t.StartTime (int64) (int64)
case "StartTime":
{
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.StartTime = int64(extraI)
}
// t.WorkError (string) (string)
case "WorkError":
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
t.WorkError = string(sval)
}
// t.WorkerCall (storiface.CallID) (struct)
case "WorkerCall":
{
if err := t.WorkerCall.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.WorkerCall: %w", err)
}
}
// t.WorkerHostname (string) (string)
case "WorkerHostname":
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
t.WorkerHostname = string(sval)
}
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
}
}
return nil
}
func (t *WorkID) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{162}); err != nil {
return err
}
// t.Method (sealtasks.TaskType) (string)
if len("Method") > 8192 {
return xerrors.Errorf("Value in field \"Method\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Method"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Method")); err != nil {
return err
}
if len(t.Method) > 8192 {
return xerrors.Errorf("Value in field t.Method was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Method))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Method)); err != nil {
return err
}
// t.Params (string) (string)
if len("Params") > 8192 {
return xerrors.Errorf("Value in field \"Params\" was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Params"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Params")); err != nil {
return err
}
if len(t.Params) > 8192 {
return xerrors.Errorf("Value in field t.Params was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Params))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Params)); err != nil {
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *WorkID) UnmarshalCBOR(r io.Reader) (err error) {
*t = WorkID{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
if extra > cbg.MaxLength {
return fmt.Errorf("WorkID: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.Method (sealtasks.TaskType) (string)
case "Method":
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
t.Method = sealtasks.TaskType(sval)
}
// t.Params (string) (string)
case "Params":
{
sval, err := cbg.ReadStringWithMax(cr, 8192)
if err != nil {
return err
}
t.Params = string(sval)
}
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
}
}
return nil
}