Merge pull request #965 from filecoin-project/feat/no-fatal-serialization

make serialization error non-fatal
This commit is contained in:
Łukasz Magiera 2019-12-19 22:04:27 +01:00 committed by GitHub
commit f7604b84f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 9 deletions

View File

@ -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,

View File

@ -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
}

2
go.mod
View File

@ -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

2
go.sum
View File

@ -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=