feat: vm: add actor error backtraces to FVM

This commit is contained in:
Steven Allen 2022-04-20 17:15:14 +02:00 committed by vyzo
parent 0b49f34e01
commit 78899be05d
2 changed files with 22 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/network"
@ -332,6 +333,15 @@ func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet
} }
} }
var aerr aerrors.ActorError
if ret.ExitCode != 0 {
amsg := ret.FailureInfo
if amsg == "" {
amsg = "unknown error"
}
aerr = aerrors.New(exitcode.ExitCode(ret.ExitCode), amsg)
}
return &ApplyRet{ return &ApplyRet{
MessageReceipt: types.MessageReceipt{ MessageReceipt: types.MessageReceipt{
Return: ret.Return, Return: ret.Return,
@ -348,7 +358,7 @@ func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet
GasRefund: 0, GasRefund: 0,
GasBurned: 0, GasBurned: 0,
}, },
ActorErr: nil, ActorErr: aerr,
ExecutionTrace: et.ToExecutionTrace(), ExecutionTrace: et.ToExecutionTrace(),
Duration: time.Since(start), Duration: time.Since(start),
}, nil }, nil
@ -372,13 +382,22 @@ func (vm *FVM) ApplyImplicitMessage(ctx context.Context, cmsg *types.Message) (*
} }
} }
var aerr aerrors.ActorError
if ret.ExitCode != 0 {
amsg := ret.FailureInfo
if amsg == "" {
amsg = "unknown error"
}
aerr = aerrors.New(exitcode.ExitCode(ret.ExitCode), amsg)
}
return &ApplyRet{ return &ApplyRet{
MessageReceipt: types.MessageReceipt{ MessageReceipt: types.MessageReceipt{
Return: ret.Return, Return: ret.Return,
ExitCode: exitcode.ExitCode(ret.ExitCode), ExitCode: exitcode.ExitCode(ret.ExitCode),
GasUsed: ret.GasUsed, GasUsed: ret.GasUsed,
}, },
ActorErr: nil, ActorErr: aerr,
ExecutionTrace: et.ToExecutionTrace(), ExecutionTrace: et.ToExecutionTrace(),
Duration: time.Since(start), Duration: time.Since(start),
}, nil }, nil

2
extern/filecoin-ffi vendored

@ -1 +1 @@
Subproject commit 4cb8411aa6c15bc8f38fef9dcd9ae5d83837eb87 Subproject commit 791b68203d33ac494b9904f04b7239674b068df4