From 2f019158d0efce18ffa67af217c37435020ddb36 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 10 Sep 2019 12:58:45 -0700 Subject: [PATCH] more switching over to correct cbor marshaling --- chain/actors/actor_init.go | 29 +++++++++++++++-------------- chain/actors/actor_miner.go | 15 ++------------- chain/actors/actor_multisig.go | 19 +++++-------------- chain/actors/actor_paych.go | 19 +++++-------------- chain/actors/actor_storagemarket.go | 24 ++++++------------------ chain/actors/actors.go | 6 ------ chain/actors/cbor_gen.go | 6 +++--- chain/actors/params.go | 12 +++++++----- chain/gen/utils.go | 11 ++++++----- chain/state/statetree.go | 6 +++--- chain/stmgr/call.go | 6 ------ chain/stmgr/stmgr.go | 6 +++--- chain/sync_test.go | 2 +- chain/types/vmcontext.go | 9 +++++---- chain/vm/invoker.go | 14 ++++++++++++-- chain/vm/vm.go | 8 +++++--- go.mod | 4 ++-- go.sum | 6 ++++++ 18 files changed, 86 insertions(+), 116 deletions(-) diff --git a/chain/actors/actor_init.go b/chain/actors/actor_init.go index acb5cfd00..dddcb63cd 100644 --- a/chain/actors/actor_init.go +++ b/chain/actors/actor_init.go @@ -5,9 +5,11 @@ import ( "context" "encoding/binary" "fmt" + "github.com/filecoin-project/go-lotus/chain/actors/aerrors" "github.com/filecoin-project/go-lotus/chain/address" "github.com/filecoin-project/go-lotus/chain/types" + cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "github.com/ipfs/go-cid" @@ -26,8 +28,6 @@ const ( ) func init() { - cbor.RegisterCborType(ExecParams{}) - cbor.RegisterCborType(struct{}{}) n, err := cbor.WrapObject(map[string]string{}, mh.SHA2_256, -1) if err != nil { @@ -64,17 +64,16 @@ type ExecParams struct { Params []byte } -func CreateExecParams(act cid.Cid, obj interface{}) ([]byte, aerrors.ActorError) { +func CreateExecParams(act cid.Cid, obj cbg.CBORMarshaler) ([]byte, aerrors.ActorError) { encparams, err := SerializeParams(obj) if err != nil { return nil, aerrors.Wrap(err, "creating ExecParams") } - var ep ExecParams - ep.Code = act - ep.Params = encparams - - return SerializeParams(ep) + return SerializeParams(&ExecParams{ + Code: act, + Params: encparams, + }) } func (ia InitActor) Exec(act *types.Actor, vmctx types.VMContext, p *ExecParams) ([]byte, aerrors.ActorError) { @@ -117,10 +116,12 @@ func (ia InitActor) Exec(act *types.Actor, vmctx types.VMContext, p *ExecParams) Head: EmptyCBOR, Nonce: 0, } - _, err = vmctx.Storage().Put(struct{}{}) - if err != nil { - return nil, err - } + /* + _, err = vmctx.Storage().Put(struct{}{}) + if err != nil { + return nil, err + } + */ // The call to the actors constructor will set up the initial state // from the given parameters, setting `actor.Head` to a new value when successful. @@ -153,7 +154,7 @@ func (ia InitActor) Exec(act *types.Actor, vmctx types.VMContext, p *ExecParams) return nil, err } - c, err := vmctx.Storage().Put(self) + c, err := vmctx.Storage().Put(&self) if err != nil { return nil, err } @@ -213,7 +214,7 @@ func (ias *InitActorState) Lookup(cst *hamt.CborIpldStore, addr address.Address) var val interface{} err = amap.Find(context.TODO(), string(addr.Bytes()), &val) if err != nil { - return address.Undef, xerrors.Errorf("ias lookup failed to do lookup: %w", err) + return address.Undef, xerrors.Errorf("ias lookup failed to do find: %w", err) } ival, ok := val.(uint64) diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index 0692c169b..bde5b815d 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -2,6 +2,7 @@ package actors import ( "context" + "github.com/filecoin-project/go-lotus/chain/actors/aerrors" "github.com/filecoin-project/go-lotus/chain/address" "github.com/filecoin-project/go-lotus/chain/types" @@ -14,18 +15,6 @@ import ( "golang.org/x/xerrors" ) -func init() { - cbor.RegisterCborType(StorageMinerActorState{}) - cbor.RegisterCborType(StorageMinerConstructorParams{}) - cbor.RegisterCborType(CommitSectorParams{}) - cbor.RegisterCborType(MinerInfo{}) - cbor.RegisterCborType(SubmitPoStParams{}) - cbor.RegisterCborType(PieceInclVoucherData{}) - cbor.RegisterCborType(InclusionProof{}) - cbor.RegisterCborType(PaymentVerifyParams{}) - cbor.RegisterCborType(UpdatePeerIDParams{}) -} - var ProvingPeriodDuration = uint64(2 * 60) // an hour, for now const POST_SECTORS_COUNT = 8192 @@ -190,7 +179,7 @@ func (sma StorageMinerActor) StorageMinerConstructor(act *types.Actor, vmctx typ self.Info = minfocid storage := vmctx.Storage() - c, err := storage.Put(self) + c, err := storage.Put(&self) if err != nil { return nil, err } diff --git a/chain/actors/actor_multisig.go b/chain/actors/actor_multisig.go index 68a35ae2b..f06da0e51 100644 --- a/chain/actors/actor_multisig.go +++ b/chain/actors/actor_multisig.go @@ -2,24 +2,13 @@ package actors import ( "github.com/ipfs/go-cid" - cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/go-lotus/chain/actors/aerrors" "github.com/filecoin-project/go-lotus/chain/address" "github.com/filecoin-project/go-lotus/chain/types" -) -func init() { - cbor.RegisterCborType(MultiSigActorState{}) - cbor.RegisterCborType(MultiSigConstructorParams{}) - cbor.RegisterCborType(MultiSigProposeParams{}) - cbor.RegisterCborType(MultiSigTxID{}) - cbor.RegisterCborType(MultiSigSwapSignerParams{}) - cbor.RegisterCborType(MultiSigChangeReqParams{}) - cbor.RegisterCborType(MTransaction{}) - cbor.RegisterCborType(MultiSigRemoveSignerParam{}) - cbor.RegisterCborType(MultiSigAddSignerParam{}) -} + cbg "github.com/whyrusleeping/cbor-gen" +) type MultiSigActor struct{} type MultiSigActorState struct { @@ -203,7 +192,9 @@ func (msa MultiSigActor) Propose(act *types.Actor, vmctx types.VMContext, return nil, aerrors.Wrap(err, "saving state") } - return SerializeParams(tx.TxID) + // REVIEW: On one hand, I like being very explicit about how we're doing the serialization + // on the other, maybe we shouldnt do direct calls to underlying serialization libs? + return cbg.CborEncodeMajorType(cbg.MajUnsignedInt, tx.TxID), nil } type MultiSigTxID struct { diff --git a/chain/actors/actor_paych.go b/chain/actors/actor_paych.go index 752c69ff4..107cf9efc 100644 --- a/chain/actors/actor_paych.go +++ b/chain/actors/actor_paych.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/ipfs/go-cid" - cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/go-lotus/build" "github.com/filecoin-project/go-lotus/chain/actors/aerrors" @@ -13,14 +12,6 @@ import ( "github.com/filecoin-project/go-lotus/chain/types" ) -func init() { - cbor.RegisterCborType(PaymentChannelActorState{}) - cbor.RegisterCborType(PCAConstructorParams{}) - cbor.RegisterCborType(LaneState{}) - cbor.RegisterCborType(PCAUpdateChannelStateParams{}) - cbor.RegisterCborType(PaymentInfo{}) -} - type PaymentChannelActor struct{} type PaymentInfo struct { @@ -84,7 +75,7 @@ func (pca PaymentChannelActor) Constructor(act *types.Actor, vmctx types.VMConte self.LaneStates = make(map[string]*LaneState) storage := vmctx.Storage() - c, err := storage.Put(self) + c, err := storage.Put(&self) if err != nil { return nil, err } @@ -136,7 +127,7 @@ func (pca PaymentChannelActor) UpdateChannelState(act *types.Actor, vmctx types. } if sv.Extra != nil { - encoded, err := SerializeParams(PaymentVerifyParams{sv.Extra.Data, params.Proof}) + encoded, err := SerializeParams(&PaymentVerifyParams{sv.Extra.Data, params.Proof}) if err != nil { return nil, err } @@ -203,7 +194,7 @@ func (pca PaymentChannelActor) UpdateChannelState(act *types.Actor, vmctx types. } } - ncid, err := storage.Put(self) + ncid, err := storage.Put(&self) if err != nil { return nil, err } @@ -235,7 +226,7 @@ func (pca PaymentChannelActor) Close(act *types.Actor, vmctx types.VMContext, pa self.ClosingAt = self.MinCloseHeight } - ncid, err := storage.Put(self) + ncid, err := storage.Put(&self) if err != nil { return nil, err } @@ -272,7 +263,7 @@ func (pca PaymentChannelActor) Collect(act *types.Actor, vmctx types.VMContext, self.ToSend = types.NewInt(0) - ncid, err := storage.Put(self) + ncid, err := storage.Put(&self) if err != nil { return nil, err } diff --git a/chain/actors/actor_storagemarket.go b/chain/actors/actor_storagemarket.go index 29bfeecce..47fa48223 100644 --- a/chain/actors/actor_storagemarket.go +++ b/chain/actors/actor_storagemarket.go @@ -10,18 +10,10 @@ import ( cid "github.com/ipfs/go-cid" hamt "github.com/ipfs/go-hamt-ipld" - cbor "github.com/ipfs/go-ipld-cbor" "github.com/libp2p/go-libp2p-core/peer" + cbg "github.com/whyrusleeping/cbor-gen" ) -func init() { - cbor.RegisterCborType(StorageMarketState{}) - cbor.RegisterCborType(CreateStorageMinerParams{}) - cbor.RegisterCborType(IsMinerParam{}) - cbor.RegisterCborType(PowerLookupParams{}) - cbor.RegisterCborType(UpdateStorageParams{}) -} - type StorageMarketActor struct{} type smaMethods struct { @@ -98,7 +90,7 @@ func (sma StorageMarketActor) CreateStorageMiner(act *types.Actor, vmctx types.V } self.Miners = ncid - nroot, err := vmctx.Storage().Put(self) + nroot, err := vmctx.Storage().Put(&self) if err != nil { return nil, err } @@ -139,7 +131,7 @@ func (sma StorageMarketActor) UpdateStorage(act *types.Actor, vmctx types.VMCont self.TotalStorage = types.BigAdd(self.TotalStorage, params.Delta) - nroot, err := vmctx.Storage().Put(self) + nroot, err := vmctx.Storage().Put(&self) if err != nil { return nil, err } @@ -179,7 +171,7 @@ func (sma StorageMarketActor) PowerLookup(act *types.Actor, vmctx types.VMContex return nil, aerrors.New(1, "miner not registered with storage market") } - ret, err := vmctx.Send(params.Miner, MAMethods.GetPower, types.NewInt(0), EmptyStructCBOR) + ret, err := vmctx.Send(params.Miner, MAMethods.GetPower, types.NewInt(0), nil) if err != nil { return nil, aerrors.Wrap(err, "invoke Miner.GetPower") } @@ -202,11 +194,7 @@ func (sma StorageMarketActor) IsMiner(act *types.Actor, vmctx types.VMContext, p return nil, err } - out, err := SerializeParams(has) - if err != nil { - return nil, err - } - return out, nil + return cbg.EncodeBool(has), nil } func MinerSetHas(ctx context.Context, vmctx types.VMContext, rcid cid.Cid, maddr address.Address) (bool, aerrors.ActorError) { @@ -215,7 +203,7 @@ func MinerSetHas(ctx context.Context, vmctx types.VMContext, rcid cid.Cid, maddr return false, aerrors.Escalate(err, "failed to load miner set") } - _, err = nd.Find(context.TODO(), string(maddr.Bytes())) + err = nd.Find(context.TODO(), string(maddr.Bytes()), nil) switch err { case hamt.ErrNotFound: return false, nil diff --git a/chain/actors/actors.go b/chain/actors/actors.go index 9efa5c873..1fc9c15ce 100644 --- a/chain/actors/actors.go +++ b/chain/actors/actors.go @@ -4,15 +4,9 @@ import ( "github.com/filecoin-project/go-lotus/chain/address" "github.com/ipfs/go-cid" - cbor "github.com/ipfs/go-ipld-cbor" mh "github.com/multiformats/go-multihash" ) -func init() { - cbor.RegisterCborType(InitActorState{}) - cbor.RegisterCborType(AccountActorState{}) -} - var AccountActorCodeCid cid.Cid var StorageMarketActorCodeCid cid.Cid var StorageMinerCodeCid cid.Cid diff --git a/chain/actors/cbor_gen.go b/chain/actors/cbor_gen.go index ad934a395..52217948f 100644 --- a/chain/actors/cbor_gen.go +++ b/chain/actors/cbor_gen.go @@ -39,7 +39,7 @@ func (t *InitActorState) UnmarshalCBOR(br io.Reader) error { return err } if maj != cbg.MajArray { - return fmt.Errorf("cbor input should be of type array") + return fmt.Errorf("cbor input should be of type array (got %d, %d)", maj, extra) } if extra != 2 { @@ -2007,7 +2007,7 @@ func (t *PaymentInfo) UnmarshalCBOR(br io.Reader) error { return fmt.Errorf("expected cbor array") } if extra > 0 { - t.Vouchers = make([]types.SignedVoucher, extra) + t.Vouchers = make([]*types.SignedVoucher, extra) } for i := 0; i < int(extra); i++ { var v types.SignedVoucher @@ -2015,7 +2015,7 @@ func (t *PaymentInfo) UnmarshalCBOR(br io.Reader) error { return err } - t.Vouchers[i] = v + t.Vouchers[i] = &v } return nil diff --git a/chain/actors/params.go b/chain/actors/params.go index b899e10c0..94624502c 100644 --- a/chain/actors/params.go +++ b/chain/actors/params.go @@ -1,19 +1,21 @@ package actors import ( + "bytes" + "github.com/filecoin-project/go-lotus/chain/actors/aerrors" - cbor "github.com/ipfs/go-ipld-cbor" + cbg "github.com/whyrusleeping/cbor-gen" ) var ( EmptyStructCBOR = []byte{0xa0} ) -func SerializeParams(i interface{}) ([]byte, aerrors.ActorError) { - dump, err := cbor.DumpObject(i) - if err != nil { +func SerializeParams(i cbg.CBORMarshaler) ([]byte, aerrors.ActorError) { + buf := new(bytes.Buffer) + if err := i.MarshalCBOR(buf); err != nil { // TODO: shouldnt this be a fatal error? return nil, aerrors.Absorb(err, 1, "failed to encode parameter") } - return dump, nil + return buf.Bytes(), nil } diff --git a/chain/gen/utils.go b/chain/gen/utils.go index 4b2faf7c9..dfe8f2d27 100644 --- a/chain/gen/utils.go +++ b/chain/gen/utils.go @@ -18,6 +18,7 @@ import ( hamt "github.com/ipfs/go-hamt-ipld" bstore "github.com/ipfs/go-ipfs-blockstore" peer "github.com/libp2p/go-libp2p-peer" + cbg "github.com/whyrusleeping/cbor-gen" sharray "github.com/whyrusleeping/sharray" ) @@ -161,7 +162,7 @@ type GenMinerCfg struct { PeerIDs []peer.ID } -func mustEnc(i interface{}) []byte { +func mustEnc(i cbg.CBORMarshaler) []byte { enc, err := actors.SerializeParams(i) if err != nil { panic(err) @@ -180,7 +181,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid worker := gmcfg.Workers[i] pid := gmcfg.PeerIDs[i] - params := mustEnc(actors.CreateStorageMinerParams{ + params := mustEnc(&actors.CreateStorageMinerParams{ Owner: owner, Worker: worker, SectorSize: types.NewInt(build.SectorSize), @@ -199,7 +200,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid gmcfg.MinerAddrs = append(gmcfg.MinerAddrs, maddr) - params = mustEnc(actors.UpdateStorageParams{Delta: types.NewInt(5000)}) + params = mustEnc(&actors.UpdateStorageParams{Delta: types.NewInt(5000)}) _, err = doExec(ctx, vm, actors.StorageMarketAddress, maddr, actors.SMAMethods.UpdateStorage, params) if err != nil { @@ -226,7 +227,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid } mstate.Power = types.NewInt(5000) - nstate, err := cst.Put(ctx, mstate) + nstate, err := cst.Put(ctx, &mstate) if err != nil { return cid.Undef, err } @@ -258,7 +259,7 @@ func doExec(ctx context.Context, vm *vm.VM, to, from address.Address, method uin Nonce: act.Nonce, }) if err != nil { - return nil, err + return nil, xerrors.Errorf("doExec apply message failed: %w", err) } if ret.ExitCode != 0 { diff --git a/chain/state/statetree.go b/chain/state/statetree.go index ac5e15819..8b3df8e74 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -90,10 +90,10 @@ func (st *StateTree) GetActor(addr address.Address) (*types.Actor, error) { if addr.Protocol() != address.ID { iaddr, err := st.lookupID(addr) if err != nil { - if err == hamt.ErrNotFound { - return nil, types.ErrActorNotFound + if xerrors.Is(err, hamt.ErrNotFound) { + return nil, xerrors.Errorf("lookup failed: %w", types.ErrActorNotFound) } - return nil, err + return nil, xerrors.Errorf("address resolution: %w", err) } addr = iaddr } diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 9b04a094a..607273724 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -26,12 +26,6 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate if msg.Value == types.EmptyInt { msg.Value = types.NewInt(0) } - if msg.Params == nil { - msg.Params, err = actors.SerializeParams(struct{}{}) - if err != nil { - return nil, err - } - } fromActor, err := vmi.StateTree().GetActor(msg.From) if err != nil { diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 76f94fa8a..447c1bd63 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -124,13 +124,13 @@ func (sm *StateManager) GetActor(addr address.Address) (*types.Actor, error) { ts := sm.cs.GetHeaviestTipSet() stcid, err := sm.TipSetState(ts.Cids()) if err != nil { - return nil, err + return nil, xerrors.Errorf("tipset state: %w", err) } cst := hamt.CSTFromBstore(sm.cs.Blockstore()) state, err := state.LoadStateTree(cst, stcid) if err != nil { - return nil, err + return nil, xerrors.Errorf("load state tree: %w", err) } return state.GetActor(addr) @@ -139,7 +139,7 @@ func (sm *StateManager) GetActor(addr address.Address) (*types.Actor, error) { func (sm *StateManager) GetBalance(addr address.Address) (types.BigInt, error) { act, err := sm.GetActor(addr) if err != nil { - return types.BigInt{}, err + return types.BigInt{}, xerrors.Errorf("get actor: %w", err) } return act.Balance, nil diff --git a/chain/sync_test.go b/chain/sync_test.go index 861c02237..4f35a7fd7 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -256,7 +256,7 @@ func (tu *syncTestUtil) submitSourceBlocks(to int, h int, n int) { */ func TestSyncSimple(t *testing.T) { - H := 100 + H := 15 tu := prepSyncTest(t, H) client := tu.addClientNode() diff --git a/chain/types/vmcontext.go b/chain/types/vmcontext.go index b43492512..64507f69d 100644 --- a/chain/types/vmcontext.go +++ b/chain/types/vmcontext.go @@ -6,11 +6,12 @@ import ( "github.com/filecoin-project/go-lotus/chain/address" "github.com/ipfs/go-cid" "github.com/ipfs/go-hamt-ipld" + cbg "github.com/whyrusleeping/cbor-gen" ) type Storage interface { - Put(interface{}) (cid.Cid, aerrors.ActorError) - Get(cid.Cid, interface{}) aerrors.ActorError + Put(cbg.CBORMarshaler) (cid.Cid, aerrors.ActorError) + Get(cid.Cid, cbg.CBORUnmarshaler) aerrors.ActorError GetHead() cid.Cid @@ -42,7 +43,7 @@ type storageWrapper struct { } func (sw *storageWrapper) Put(i interface{}) (cid.Cid, error) { - c, err := sw.s.Put(i) + c, err := sw.s.Put(i.(cbg.CBORMarshaler)) if err != nil { return cid.Undef, err } @@ -51,7 +52,7 @@ func (sw *storageWrapper) Put(i interface{}) (cid.Cid, error) { } func (sw *storageWrapper) Get(c cid.Cid, out interface{}) error { - if err := sw.s.Get(c, out); err != nil { + if err := sw.s.Get(c, out.(cbg.CBORUnmarshaler)); err != nil { return err } diff --git a/chain/vm/invoker.go b/chain/vm/invoker.go index 4e7a035e3..7d9ff6b80 100644 --- a/chain/vm/invoker.go +++ b/chain/vm/invoker.go @@ -1,11 +1,13 @@ package vm import ( + "bytes" "fmt" "reflect" "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" + cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" actors "github.com/filecoin-project/go-lotus/chain/actors" @@ -121,8 +123,7 @@ func (*invoker) transform(instance Invokee) (nativeCode, error) { inBytes := in[2].Interface().([]byte) if len(inBytes) > 0 { - err := cbor.DecodeInto(inBytes, param.Interface()) - if err != nil { + if err := DecodeParams(inBytes, param.Interface()); err != nil { aerr := aerrors.Absorb(err, 1, "failed to decode parameters") return []reflect.Value{ reflect.ValueOf([]byte{}), @@ -142,6 +143,15 @@ func (*invoker) transform(instance Invokee) (nativeCode, error) { return code, nil } +func DecodeParams(b []byte, out interface{}) error { + um, ok := out.(cbg.CBORUnmarshaler) + if !ok { + return fmt.Errorf("type %T does not implement UnmarshalCBOR", out) + } + + return um.UnmarshalCBOR(bytes.NewReader(b)) +} + func DumpActorState(code cid.Cid, b []byte) (interface{}, error) { i := newInvoker() // TODO: register builtins in init block diff --git a/chain/vm/vm.go b/chain/vm/vm.go index c0ffbb4e2..82fc94094 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/go-lotus/chain/store" "github.com/filecoin-project/go-lotus/chain/types" "github.com/filecoin-project/go-lotus/lib/bufbstore" + cbg "github.com/whyrusleeping/cbor-gen" "go.opencensus.io/trace" block "github.com/ipfs/go-block-format" @@ -67,18 +68,19 @@ func (vmc *VMContext) Message() *types.Message { // Storage interface -func (vmc *VMContext) Put(i interface{}) (cid.Cid, aerrors.ActorError) { +func (vmc *VMContext) Put(i cbg.CBORMarshaler) (cid.Cid, aerrors.ActorError) { c, err := vmc.cst.Put(context.TODO(), i) if err != nil { if aerr := vmc.ChargeGas(0); aerr != nil { return cid.Undef, aerrors.Absorb(err, outOfGasErrCode, "Put out of gas") } - return cid.Undef, aerrors.Escalate(err, "putting cid") + panic("no u") + return cid.Undef, aerrors.Escalate(err, fmt.Sprintf("putting object %T", i)) } return c, nil } -func (vmc *VMContext) Get(c cid.Cid, out interface{}) aerrors.ActorError { +func (vmc *VMContext) Get(c cid.Cid, out cbg.CBORUnmarshaler) aerrors.ActorError { err := vmc.cst.Get(context.TODO(), c, out) if err != nil { if aerr := vmc.ChargeGas(0); aerr != nil { diff --git a/go.mod b/go.mod index c9d39cca9..c4aa1f5af 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/ipfs/go-ds-badger v0.0.5 github.com/ipfs/go-filestore v0.0.2 github.com/ipfs/go-fs-lock v0.0.1 - github.com/ipfs/go-hamt-ipld v0.0.12-0.20190830015840-8aabc0c74ac6 + github.com/ipfs/go-hamt-ipld v0.0.12-0.20190910032255-ee6e898f0456 github.com/ipfs/go-ipfs-blockstore v0.1.0 github.com/ipfs/go-ipfs-chunker v0.0.1 github.com/ipfs/go-ipfs-ds-help v0.0.1 @@ -67,7 +67,7 @@ require ( github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a github.com/stretchr/testify v1.4.0 github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba - github.com/whyrusleeping/cbor-gen v0.0.0-20190909233408-ae6265959798 + github.com/whyrusleeping/cbor-gen v0.0.0-20190910040623-f29470053db6 github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 github.com/whyrusleeping/pubsub v0.0.0-20131020042734-02de8aa2db3d github.com/whyrusleeping/sharray v0.0.0-20190718051354-e41931821e33 diff --git a/go.sum b/go.sum index 2d6d80ce3..f12c36d1a 100644 --- a/go.sum +++ b/go.sum @@ -170,6 +170,8 @@ github.com/ipfs/go-fs-lock v0.0.1 h1:XHX8uW4jQBYWHj59XXcjg7BHlHxV9ZOYs6Y43yb7/l0 github.com/ipfs/go-fs-lock v0.0.1/go.mod h1:DNBekbboPKcxs1aukPSaOtFA3QfSdi5C855v0i9XJ8Y= github.com/ipfs/go-hamt-ipld v0.0.12-0.20190830015840-8aabc0c74ac6 h1:qVk+425ErvzJEz/9f38lhjPfmmu0GAj/BSNt56SW4xQ= github.com/ipfs/go-hamt-ipld v0.0.12-0.20190830015840-8aabc0c74ac6/go.mod h1:UPmViPxLn1GGxxnllIww8yWUVO60qEYLFFfF9e3ojgo= +github.com/ipfs/go-hamt-ipld v0.0.12-0.20190910032255-ee6e898f0456 h1:I0DHyyygfm9fxWK3dZ6XAXBHVY2u93ske4kprAmm4og= +github.com/ipfs/go-hamt-ipld v0.0.12-0.20190910032255-ee6e898f0456/go.mod h1:oVAOWGetjaaAPloFDCudyhxofsSG/WijXMJLTA0kRhM= github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08= github.com/ipfs/go-ipfs-blockstore v0.0.2/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08= github.com/ipfs/go-ipfs-blockstore v0.1.0 h1:V1GZorHFUIB6YgTJQdq7mcaIpUfCM3fCyVi+MTo9O88= @@ -530,6 +532,10 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20190909232404-de20c470a082 h1:Wh1Hyuaz github.com/whyrusleeping/cbor-gen v0.0.0-20190909232404-de20c470a082/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/cbor-gen v0.0.0-20190909233408-ae6265959798 h1:4j/w+x60KmMsRwRavx3cxDgdV0iCRVoNCizhiAo2vF8= github.com/whyrusleeping/cbor-gen v0.0.0-20190909233408-ae6265959798/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= +github.com/whyrusleeping/cbor-gen v0.0.0-20190910031516-c1cbffdb01bb h1:8yBVx6dgk1GfkiWOQ+RbeDDBLCOZxOtmZ949O2uj5H4= +github.com/whyrusleeping/cbor-gen v0.0.0-20190910031516-c1cbffdb01bb/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= +github.com/whyrusleeping/cbor-gen v0.0.0-20190910040623-f29470053db6 h1:e46mGjWNMelsw+YLq/5TyMfwGz8p0cBY2cf91y6tSBA= +github.com/whyrusleeping/cbor-gen v0.0.0-20190910040623-f29470053db6/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k=