use proper exitcodes for caller validation
This commit is contained in:
parent
066b755b6a
commit
6fe245a278
@ -4,9 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"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]
|
code, ok := inv.builtInCode[act.Code]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Errorf("no code for actor %s (Addr: %s)", act.Code, rt.Message().Receiver())
|
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 {
|
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)
|
return code[method](act, rt, params)
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ func (rt *Runtime) ValidateImmediateCallerIs(as ...address.Address) {
|
|||||||
return
|
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 {
|
func (rt *Runtime) Context() context.Context {
|
||||||
@ -255,7 +255,7 @@ func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid) {
|
|||||||
return
|
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 {
|
func (rs *Runtime) CurrEpoch() abi.ChainEpoch {
|
||||||
|
@ -36,7 +36,6 @@ func init() {
|
|||||||
// initialize the test skipper with tests being skipped
|
// initialize the test skipper with tests being skipped
|
||||||
TestSuiteSkipper = TestSkipper{testSkips: []suites.TestCase{
|
TestSuiteSkipper = TestSkipper{testSkips: []suites.TestCase{
|
||||||
/* tests to skip go here */
|
/* tests to skip go here */
|
||||||
//tipset.TestInternalMessageApplicationFailure,
|
|
||||||
tipset.TestInvalidSenderAddress,
|
tipset.TestInvalidSenderAddress,
|
||||||
tipset.TestBlockMessageDeduplication,
|
tipset.TestBlockMessageDeduplication,
|
||||||
tipset.TestMinerSubmitFallbackPoSt,
|
tipset.TestMinerSubmitFallbackPoSt,
|
||||||
|
@ -209,6 +209,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
|||||||
return nil, aerr, nil
|
return nil, aerr, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)
|
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user