lotus/conformance/chaos/cbor_gen.go

1096 lines
21 KiB
Go
Raw Normal View History

2020-09-08 20:50:25 +00:00
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package chaos
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-08 20:50:25 +00:00
2020-09-21 09:10:31 +00:00
cid "github.com/ipfs/go-cid"
2020-09-08 20:50:25 +00:00
cbg "github.com/whyrusleeping/cbor-gen"
2020-09-21 09:10:31 +00:00
xerrors "golang.org/x/xerrors"
2022-06-14 15:00:51 +00:00
address "github.com/filecoin-project/go-address"
abi "github.com/filecoin-project/go-state-types/abi"
exitcode "github.com/filecoin-project/go-state-types/exitcode"
2020-09-08 20:50:25 +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-08 20:50:25 +00:00
var lengthBufState = []byte{130}
func (t *State) 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(lengthBufState); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Value (string) (string)
if len(t.Value) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Value was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
if _, err := io.WriteString(w, string(t.Value)); err != nil {
return err
}
// t.Unmarshallable ([]*chaos.UnmarshallableCBOR) (slice)
if len(t.Unmarshallable) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Unmarshallable was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Unmarshallable))); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
for _, v := range t.Unmarshallable {
2022-05-23 19:11:46 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *State) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-08 20:50:25 +00:00
*t = State{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-08 20:50:25 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +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-08 20:50:25 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Value (string) (string)
{
2022-05-23 19:11:46 +00:00
sval, err := cbg.ReadString(cr)
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
t.Value = string(sval)
}
// t.Unmarshallable ([]*chaos.UnmarshallableCBOR) (slice)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Unmarshallable: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Unmarshallable = make([]*UnmarshallableCBOR, extra)
}
for i := 0; i < int(extra); i++ {
var v UnmarshallableCBOR
2022-05-23 19:11:46 +00:00
if err := v.UnmarshalCBOR(cr); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
t.Unmarshallable[i] = &v
}
return nil
}
2020-09-14 11:41:00 +00:00
var lengthBufCallerValidationArgs = []byte{131}
func (t *CallerValidationArgs) 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(lengthBufCallerValidationArgs); err != nil {
2020-09-14 11:41:00 +00:00
return err
}
// t.Branch (chaos.CallerValidationBranch) (int64)
if t.Branch >= 0 {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Branch)); err != nil {
2020-09-14 11:41:00 +00:00
return err
}
} else {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Branch-1)); err != nil {
2020-09-14 11:41:00 +00:00
return err
}
}
// t.Addrs ([]address.Address) (slice)
if len(t.Addrs) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Addrs was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Addrs))); err != nil {
2020-09-14 11:41:00 +00:00
return err
}
for _, v := range t.Addrs {
2022-05-23 19:11:46 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2020-09-14 11:41:00 +00:00
return err
}
}
// t.Types ([]cid.Cid) (slice)
if len(t.Types) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Types was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Types))); err != nil {
2020-09-14 11:41:00 +00:00
return err
}
for _, v := range t.Types {
2022-05-23 19:11:46 +00:00
if err := cbg.WriteCid(w, v); err != nil {
2020-09-14 11:41:00 +00:00
return xerrors.Errorf("failed writing cid field t.Types: %w", err)
}
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *CallerValidationArgs) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-14 11:41:00 +00:00
*t = CallerValidationArgs{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-14 11:41:00 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-14 11:41:00 +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 11:41:00 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 3 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Branch (chaos.CallerValidationBranch) (int64)
{
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-14 11:41:00 +00:00
var extraI int64
if err != nil {
return err
}
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 oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.Branch = CallerValidationBranch(extraI)
}
// t.Addrs ([]address.Address) (slice)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-14 11:41:00 +00:00
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Addrs: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Addrs = make([]address.Address, extra)
}
for i := 0; i < int(extra); i++ {
var v address.Address
2022-05-23 19:11:46 +00:00
if err := v.UnmarshalCBOR(cr); err != nil {
2020-09-14 11:41:00 +00:00
return err
}
t.Addrs[i] = v
}
// t.Types ([]cid.Cid) (slice)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-14 11:41:00 +00:00
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Types: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Types = make([]cid.Cid, extra)
}
for i := 0; i < int(extra); i++ {
2022-05-23 19:11:46 +00:00
c, err := cbg.ReadCid(cr)
2020-09-14 11:41:00 +00:00
if err != nil {
return xerrors.Errorf("reading cid field t.Types failed: %w", err)
}
t.Types[i] = c
}
return nil
}
2020-09-08 20:50:25 +00:00
var lengthBufCreateActorArgs = []byte{132}
func (t *CreateActorArgs) 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(lengthBufCreateActorArgs); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.UndefActorCID (bool) (bool)
if err := cbg.WriteBool(w, t.UndefActorCID); err != nil {
return err
}
// t.ActorCID (cid.Cid) (struct)
2022-05-23 19:11:46 +00:00
if err := cbg.WriteCid(cw, t.ActorCID); err != nil {
2020-09-08 20:50:25 +00:00
return xerrors.Errorf("failed to write cid field t.ActorCID: %w", err)
}
// t.UndefAddress (bool) (bool)
if err := cbg.WriteBool(w, t.UndefAddress); err != nil {
return err
}
// t.Address (address.Address) (struct)
2022-05-23 19:11:46 +00:00
if err := t.Address.MarshalCBOR(cw); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *CreateActorArgs) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-08 20:50:25 +00:00
*t = CreateActorArgs{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-08 20:50:25 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +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-08 20:50:25 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 4 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.UndefActorCID (bool) (bool)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
if maj != cbg.MajOther {
return fmt.Errorf("booleans must be major type 7")
}
switch extra {
case 20:
t.UndefActorCID = false
case 21:
t.UndefActorCID = true
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
// t.ActorCID (cid.Cid) (struct)
{
2022-05-23 19:11:46 +00:00
c, err := cbg.ReadCid(cr)
2020-09-08 20:50:25 +00:00
if err != nil {
return xerrors.Errorf("failed to read cid field t.ActorCID: %w", err)
}
t.ActorCID = c
}
// t.UndefAddress (bool) (bool)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
if maj != cbg.MajOther {
return fmt.Errorf("booleans must be major type 7")
}
switch extra {
case 20:
t.UndefAddress = false
case 21:
t.UndefAddress = true
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
// t.Address (address.Address) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.Address.UnmarshalCBOR(cr); err != nil {
2020-09-08 20:50:25 +00:00
return xerrors.Errorf("unmarshaling t.Address: %w", err)
}
}
return nil
}
var lengthBufResolveAddressResponse = []byte{130}
func (t *ResolveAddressResponse) 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(lengthBufResolveAddressResponse); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Address (address.Address) (struct)
2022-05-23 19:11:46 +00:00
if err := t.Address.MarshalCBOR(cw); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Success (bool) (bool)
if err := cbg.WriteBool(w, t.Success); err != nil {
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *ResolveAddressResponse) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-08 20:50:25 +00:00
*t = ResolveAddressResponse{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-08 20:50:25 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +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-08 20:50:25 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Address (address.Address) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.Address.UnmarshalCBOR(cr); err != nil {
2020-09-08 20:50:25 +00:00
return xerrors.Errorf("unmarshaling t.Address: %w", err)
}
}
// t.Success (bool) (bool)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
if maj != cbg.MajOther {
return fmt.Errorf("booleans must be major type 7")
}
switch extra {
case 20:
t.Success = false
case 21:
t.Success = true
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
return nil
}
var lengthBufSendArgs = []byte{132}
func (t *SendArgs) 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(lengthBufSendArgs); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.To (address.Address) (struct)
2022-05-23 19:11:46 +00:00
if err := t.To.MarshalCBOR(cw); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Value (big.Int) (struct)
2022-05-23 19:11:46 +00:00
if err := t.Value.MarshalCBOR(cw); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Method (abi.MethodNum) (uint64)
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Method)); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Params ([]uint8) (slice)
if len(t.Params) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Params was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Params))); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
2022-05-23 19:11:46 +00:00
if _, err := cw.Write(t.Params[:]); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *SendArgs) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-08 20:50:25 +00:00
*t = SendArgs{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-08 20:50:25 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +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-08 20:50:25 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 4 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.To (address.Address) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.To.UnmarshalCBOR(cr); err != nil {
2020-09-08 20:50:25 +00:00
return xerrors.Errorf("unmarshaling t.To: %w", err)
}
}
// t.Value (big.Int) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.Value.UnmarshalCBOR(cr); err != nil {
2020-09-08 20:50:25 +00:00
return xerrors.Errorf("unmarshaling t.Value: %w", err)
}
}
// t.Method (abi.MethodNum) (uint64)
{
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Method = abi.MethodNum(extra)
}
// t.Params ([]uint8) (slice)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra > 0 {
t.Params = make([]uint8, extra)
}
2022-05-23 19:11:46 +00:00
if _, err := io.ReadFull(cr, t.Params[:]); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
return nil
}
var lengthBufSendReturn = []byte{130}
func (t *SendReturn) 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(lengthBufSendReturn); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
2020-10-08 01:09:33 +00:00
// t.Return (builtin.CBORBytes) (slice)
2020-09-08 20:50:25 +00:00
if len(t.Return) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Return was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Return))); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
2022-05-23 19:11:46 +00:00
if _, err := cw.Write(t.Return[:]); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Code (exitcode.ExitCode) (int64)
if t.Code >= 0 {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Code)); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
} else {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Code-1)); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *SendReturn) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-08 20:50:25 +00:00
*t = SendReturn{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-08 20:50:25 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +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-08 20:50:25 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
2020-10-08 01:09:33 +00:00
// t.Return (builtin.CBORBytes) (slice)
2020-09-08 20:50:25 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Return: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra > 0 {
t.Return = make([]uint8, extra)
}
2022-05-23 19:11:46 +00:00
if _, err := io.ReadFull(cr, t.Return[:]); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Code (exitcode.ExitCode) (int64)
{
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +00:00
var extraI int64
if err != nil {
return err
}
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 oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.Code = exitcode.ExitCode(extraI)
}
return nil
}
var lengthBufMutateStateArgs = []byte{130}
func (t *MutateStateArgs) 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(lengthBufMutateStateArgs); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
// t.Value (string) (string)
if len(t.Value) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Value was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
if _, err := io.WriteString(w, string(t.Value)); err != nil {
return err
}
// t.Branch (chaos.MutateStateBranch) (int64)
if t.Branch >= 0 {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Branch)); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
} else {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Branch-1)); err != nil {
2020-09-08 20:50:25 +00:00
return err
}
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *MutateStateArgs) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-08 20:50:25 +00:00
*t = MutateStateArgs{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-08 20:50:25 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +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-08 20:50:25 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Value (string) (string)
{
2022-05-23 19:11:46 +00:00
sval, err := cbg.ReadString(cr)
2020-09-08 20:50:25 +00:00
if err != nil {
return err
}
t.Value = string(sval)
}
// t.Branch (chaos.MutateStateBranch) (int64)
{
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-08 20:50:25 +00:00
var extraI int64
if err != nil {
return err
}
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 oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.Branch = MutateStateBranch(extraI)
}
return nil
}
2020-09-09 10:40:30 +00:00
2020-09-10 11:03:13 +00:00
var lengthBufAbortWithArgs = []byte{131}
2020-09-09 10:40:30 +00:00
2020-09-10 11:03:13 +00:00
func (t *AbortWithArgs) MarshalCBOR(w io.Writer) error {
2020-09-09 10:40:30 +00:00
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(lengthBufAbortWithArgs); err != nil {
2020-09-09 10:40:30 +00:00
return err
}
// t.Code (exitcode.ExitCode) (int64)
if t.Code >= 0 {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Code)); err != nil {
2020-09-09 10:40:30 +00:00
return err
}
} else {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Code-1)); err != nil {
2020-09-09 10:40:30 +00:00
return err
}
}
// t.Message (string) (string)
if len(t.Message) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Message was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Message))); err != nil {
2020-09-09 10:40:30 +00:00
return err
}
if _, err := io.WriteString(w, string(t.Message)); err != nil {
return err
}
2020-09-10 11:03:13 +00:00
// t.Uncontrolled (bool) (bool)
if err := cbg.WriteBool(w, t.Uncontrolled); err != nil {
return err
}
2020-09-09 10:40:30 +00:00
return nil
}
2022-05-23 19:11:46 +00:00
func (t *AbortWithArgs) UnmarshalCBOR(r io.Reader) (err error) {
2020-09-10 11:03:13 +00:00
*t = AbortWithArgs{}
2020-09-09 10:40:30 +00:00
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-09-09 10:40:30 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-09 10:40:30 +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-09 10:40:30 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 3 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Code (exitcode.ExitCode) (int64)
{
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-09-09 10:40:30 +00:00
var extraI int64
if err != nil {
return err
}
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 oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.Code = exitcode.ExitCode(extraI)
}
2020-09-10 11:03:13 +00:00
// t.Message (string) (string)
{
2022-05-23 19:11:46 +00:00
sval, err := cbg.ReadString(cr)
2020-09-10 11:03:13 +00:00
if err != nil {
return err
}
t.Message = string(sval)
}
// t.Uncontrolled (bool) (bool)
2020-09-09 10:40:30 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-09-09 10:40:30 +00:00
if err != nil {
return err
}
if maj != cbg.MajOther {
return fmt.Errorf("booleans must be major type 7")
}
switch extra {
case 20:
2020-09-10 11:03:13 +00:00
t.Uncontrolled = false
2020-09-09 10:40:30 +00:00
case 21:
2020-09-10 11:03:13 +00:00
t.Uncontrolled = true
2020-09-09 10:40:30 +00:00
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
return nil
}
var lengthBufInspectRuntimeReturn = []byte{134}
func (t *InspectRuntimeReturn) 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(lengthBufInspectRuntimeReturn); err != nil {
return err
}
// t.Caller (address.Address) (struct)
2022-05-23 19:11:46 +00:00
if err := t.Caller.MarshalCBOR(cw); err != nil {
return err
}
// t.Receiver (address.Address) (struct)
2022-05-23 19:11:46 +00:00
if err := t.Receiver.MarshalCBOR(cw); err != nil {
return err
}
// t.ValueReceived (big.Int) (struct)
2022-05-23 19:11:46 +00:00
if err := t.ValueReceived.MarshalCBOR(cw); err != nil {
return err
}
// t.CurrEpoch (abi.ChainEpoch) (int64)
if t.CurrEpoch >= 0 {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.CurrEpoch)); err != nil {
return err
}
} else {
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.CurrEpoch-1)); err != nil {
return err
}
}
// t.CurrentBalance (big.Int) (struct)
2022-05-23 19:11:46 +00:00
if err := t.CurrentBalance.MarshalCBOR(cw); err != nil {
return err
}
// t.State (chaos.State) (struct)
2022-05-23 19:11:46 +00:00
if err := t.State.MarshalCBOR(cw); err != nil {
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *InspectRuntimeReturn) UnmarshalCBOR(r io.Reader) (err error) {
*t = InspectRuntimeReturn{}
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.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 6 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Caller (address.Address) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.Caller.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Caller: %w", err)
}
}
// t.Receiver (address.Address) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.Receiver.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Receiver: %w", err)
}
}
// t.ValueReceived (big.Int) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.ValueReceived.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.ValueReceived: %w", err)
}
}
// t.CurrEpoch (abi.ChainEpoch) (int64)
{
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err
}
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 oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.CurrEpoch = abi.ChainEpoch(extraI)
}
// t.CurrentBalance (big.Int) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.CurrentBalance.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.CurrentBalance: %w", err)
}
}
// t.State (chaos.State) (struct)
{
2022-05-23 19:11:46 +00:00
if err := t.State.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.State: %w", err)
}
}
return nil
}