lotus/storage/sealer/storiface/cbor_gen.go

477 lines
9.1 KiB
Go
Raw Normal View History

// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package storiface
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"
cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
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
func (t *CallID) 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.ID (uuid.UUID) (array)
if len("ID") > cbg.MaxLength {
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
}
if len(t.ID) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.ID was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.ID))); err != nil {
return err
}
2022-05-23 19:11:46 +00:00
if _, err := cw.Write(t.ID[:]); err != nil {
return err
}
// t.Sector (abi.SectorID) (struct)
if len("Sector") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Sector\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Sector"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Sector")); err != nil {
return err
}
if err := t.Sector.MarshalCBOR(cw); err != nil {
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *CallID) UnmarshalCBOR(r io.Reader) (err error) {
*t = CallID{}
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("CallID: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
2022-05-23 19:11:46 +00:00
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.ID (uuid.UUID) (array)
case "ID":
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.ID: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra != 16 {
return fmt.Errorf("expected array to have 16 elements")
}
t.ID = [16]uint8{}
2022-05-23 19:11:46 +00:00
if _, err := io.ReadFull(cr, t.ID[:]); err != nil {
return err
}
// t.Sector (abi.SectorID) (struct)
case "Sector":
{
if err := t.Sector.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Sector: %w", err)
}
}
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
}
}
return nil
}
2022-09-02 15:12:58 +00:00
func (t *SecDataHttpHeader) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{162}); err != nil {
return err
}
// t.Key (string) (string)
if len("Key") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Key\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Key"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Key")); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
if len(t.Key) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Key was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Key)); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
// t.Value (string) (string)
if len("Value") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Value\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Value"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Value")); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
if len(t.Value) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Value was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Value)); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
return nil
}
func (t *SecDataHttpHeader) UnmarshalCBOR(r io.Reader) (err error) {
*t = SecDataHttpHeader{}
cr := cbg.NewCborReader(r)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
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("SecDataHttpHeader: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.Key (string) (string)
case "Key":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.Key = string(sval)
}
// t.Value (string) (string)
case "Value":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.Value = string(sval)
}
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
}
}
return nil
}
2022-09-16 21:45:23 +00:00
func (t *SectorLocation) MarshalCBOR(w io.Writer) error {
2022-09-02 15:12:58 +00:00
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{163}); err != nil {
return err
}
// t.URL (string) (string)
if len("URL") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"URL\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("URL"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("URL")); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
if len(t.URL) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.URL was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.URL))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.URL)); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
// t.Local (bool) (bool)
if len("Local") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Local\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Local"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Local")); err != nil {
return err
}
if err := cbg.WriteBool(w, t.Local); err != nil {
return err
}
2022-09-02 15:12:58 +00:00
// t.Headers ([]storiface.SecDataHttpHeader) (slice)
if len("Headers") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Headers\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Headers"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Headers")); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
if len(t.Headers) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Headers was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Headers))); err != nil {
return err
}
for _, v := range t.Headers {
if err := v.MarshalCBOR(cw); err != nil {
return err
}
}
return nil
}
2022-09-16 21:45:23 +00:00
func (t *SectorLocation) UnmarshalCBOR(r io.Reader) (err error) {
*t = SectorLocation{}
2022-09-02 15:12:58 +00:00
cr := cbg.NewCborReader(r)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
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 {
2022-09-16 21:45:23 +00:00
return fmt.Errorf("SectorLocation: map struct too large (%d)", extra)
2022-09-02 15:12:58 +00:00
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.URL (string) (string)
case "URL":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.URL = string(sval)
}
// t.Local (bool) (bool)
2022-09-02 15:12:58 +00:00
case "Local":
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.Local = false
case 21:
t.Local = true
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
// t.Headers ([]storiface.SecDataHttpHeader) (slice)
case "Headers":
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Headers: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Headers = make([]SecDataHttpHeader, extra)
}
for i := 0; i < int(extra); i++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
2022-09-02 15:12:58 +00:00
2023-09-23 21:21:22 +00:00
{
2022-09-02 15:12:58 +00:00
2023-09-23 21:21:22 +00:00
if err := t.Headers[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Headers[i]: %w", err)
}
}
}
2022-09-02 15:12:58 +00:00
}
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
}
}
return nil
}