use proper exitcodes for caller validation

This commit is contained in:
Jeromy 2020-03-23 13:44:06 -07:00
parent 066b755b6a
commit 6fe245a278
4 changed files with 8 additions and 6 deletions

View File

@ -4,9 +4,11 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
"reflect"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
@ -64,10 +66,10 @@ func (inv *invoker) Invoke(act *types.Actor, rt runtime.Runtime, method abi.Meth
code, ok := inv.builtInCode[act.Code]
if !ok {
log.Errorf("no code for actor %s (Addr: %s)", act.Code, rt.Message().Receiver())
return nil, aerrors.Newf(255, "no code for actor %s(%d)(%s)", act.Code, method, hex.EncodeToString(params))
return nil, aerrors.Newf(byte(exitcode.SysErrorIllegalActor), "no code for actor %s(%d)(%s)", act.Code, method, hex.EncodeToString(params))
}
if method >= abi.MethodNum(len(code)) || code[method] == nil {
return nil, aerrors.Newf(255, "no method %d on actor", method)
return nil, aerrors.Newf(byte(exitcode.SysErrInvalidMethod), "no method %d on actor", method)
}
return code[method](act, rt, params)

View File

@ -229,7 +229,7 @@ func (rt *Runtime) ValidateImmediateCallerIs(as ...address.Address) {
return
}
}
rt.Abortf(exitcode.ErrForbidden, "caller %s is not one of %s", rt.Message().Caller(), as)
rt.Abortf(exitcode.SysErrForbidden, "caller %s is not one of %s", rt.Message().Caller(), as)
}
func (rt *Runtime) Context() context.Context {
@ -255,7 +255,7 @@ func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid) {
return
}
}
rt.Abortf(exitcode.ErrForbidden, "caller cid type %q was not one of %v", callerCid, ts)
rt.Abortf(exitcode.SysErrForbidden, "caller cid type %q was not one of %v", callerCid, ts)
}
func (rs *Runtime) CurrEpoch() abi.ChainEpoch {

View File

@ -36,7 +36,6 @@ func init() {
// initialize the test skipper with tests being skipped
TestSuiteSkipper = TestSkipper{testSkips: []suites.TestCase{
/* tests to skip go here */
//tipset.TestInternalMessageApplicationFailure,
tipset.TestInvalidSenderAddress,
tipset.TestBlockMessageDeduplication,
tipset.TestMinerSubmitFallbackPoSt,

View File

@ -209,6 +209,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
return nil, aerr, nil
}
}
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)
if parent != nil {
defer func() {