From 04067054905d6f40260ea88fdd0a1a1e6c7d8eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 13 Sep 2019 20:16:39 +0200 Subject: [PATCH] vm: fix ReadState --- chain/vm/invoker.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chain/vm/invoker.go b/chain/vm/invoker.go index 7d9ff6b80..fb7741abf 100644 --- a/chain/vm/invoker.go +++ b/chain/vm/invoker.go @@ -6,11 +6,10 @@ import ( "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" + "github.com/filecoin-project/go-lotus/chain/actors" "github.com/filecoin-project/go-lotus/chain/actors/aerrors" "github.com/filecoin-project/go-lotus/chain/types" ) @@ -161,7 +160,12 @@ func DumpActorState(code cid.Cid, b []byte) (interface{}, error) { } rv := reflect.New(typ) - if err := cbor.DecodeInto(b, rv.Interface()); err != nil { + um, ok := rv.Interface().(cbg.CBORUnmarshaler) + if !ok { + return nil, xerrors.New("state type does not implement CBORUnmarshaler") + } + + if err := um.UnmarshalCBOR(bytes.NewReader(b)); err != nil { return nil, err }