diff --git a/chain/actors/aerrors/wrap.go b/chain/actors/aerrors/wrap.go index 8f2db99c1..da12cb7c6 100644 --- a/chain/actors/aerrors/wrap.go +++ b/chain/actors/aerrors/wrap.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + hamt "github.com/ipfs/go-hamt-ipld" "golang.org/x/xerrors" ) @@ -159,6 +160,16 @@ func HandleExternalError(err error, msg string) ActorError { } } + if xerrors.Is(err, &hamt.SerializationError{}) { + return &actorError{ + fatal: false, + retCode: 253, + msg: msg, + frame: xerrors.Caller(1), + err: err, + } + } + return &actorError{ fatal: true, diff --git a/chain/vm/vm.go b/chain/vm/vm.go index b478c43d4..55516e88b 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -86,10 +86,7 @@ func (vmc *VMContext) Sys() *types.VMSyscalls { 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, fmt.Sprintf("putting object %T", i)) + return cid.Undef, aerrors.HandleExternalError(err, fmt.Sprintf("putting object %T", i)) } return c, nil } @@ -97,10 +94,7 @@ func (vmc *VMContext) Put(i cbg.CBORMarshaler) (cid.Cid, 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 { - return aerrors.Absorb(err, outOfGasErrCode, "Get out of gas") - } - return aerrors.Escalate(err, "getting cid") + return aerrors.HandleExternalError(err, "getting cid") } return nil } diff --git a/go.mod b/go.mod index 8eb3afdfb..55d8abff5 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/ipfs/go-ds-badger v0.0.7 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.14-0.20191216205022-2612fdd40689 + github.com/ipfs/go-hamt-ipld v0.0.14-0.20191218031521-b2c774a54db1 github.com/ipfs/go-ipfs-blockstore v0.1.1 github.com/ipfs/go-ipfs-blocksutil v0.0.1 github.com/ipfs/go-ipfs-chunker v0.0.1 diff --git a/go.sum b/go.sum index cb071c896..f7e70bd83 100644 --- a/go.sum +++ b/go.sum @@ -191,6 +191,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.14-0.20191216205022-2612fdd40689 h1:JxdkwkDD/bZngSyVvAfelThSlJuukrjYC1lUTF6ixUI= github.com/ipfs/go-hamt-ipld v0.0.14-0.20191216205022-2612fdd40689/go.mod h1:8yRx0xLUps1Xq8ZDnIwIVdQRp7JjA55gGvCiRHT91Vk= +github.com/ipfs/go-hamt-ipld v0.0.14-0.20191218031521-b2c774a54db1 h1:0xpCaaXvN8bPyws3ObiCn7G0KIfgbS9E132eL57dHx8= +github.com/ipfs/go-hamt-ipld v0.0.14-0.20191218031521-b2c774a54db1/go.mod h1:8yRx0xLUps1Xq8ZDnIwIVdQRp7JjA55gGvCiRHT91Vk= github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08= github.com/ipfs/go-ipfs-blockstore v0.1.0/go.mod h1:5aD0AvHPi7mZc6Ci1WCAhiBQu2IsfTduLl+422H6Rqw= github.com/ipfs/go-ipfs-blockstore v0.1.1 h1:+PAFREAlSxLs9IEtrRcnJ/DqWkGlDa+l547WFZnohNw=