Add information about internal message executions to SimulationResult

- The VM now tracks a list of ExecutionResults to keep track of internal messages
This commit is contained in:
Aayush Rajasekaran 2020-03-03 17:33:55 -08:00
parent 2d63b007f2
commit 340afc3503
4 changed files with 38 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package api
import (
"context"
"github.com/filecoin-project/lotus/chain/vm"
"time"
"github.com/filecoin-project/go-address"
@ -274,6 +275,7 @@ type RetrievalOrder struct {
type InvocResult struct {
Msg *types.Message
MsgRct *types.MessageReceipt
InternalExecutions []*vm.ExecutionResult
Error string
}

View File

@ -60,10 +60,12 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
errs = ret.ActorErr.Error()
log.Warnf("chain call failed: %s", ret.ActorErr)
}
return &api.InvocResult{
Msg: msg,
Msg: msg,
MsgRct: &ret.MessageReceipt,
Error: errs,
InternalExecutions: ret.InternalExecutions,
Error: errs,
}, nil
}

View File

@ -43,6 +43,12 @@ const (
outOfGasErrCode = 200
)
type ExecutionResult struct {
Msg *types.Message
MsgRct *types.MessageReceipt
Error string
}
type VMContext struct {
ctx context.Context
@ -62,6 +68,8 @@ type VMContext struct {
// address that started invoke chain
origin address.Address
internalExecutions []*ExecutionResult
}
// Message is the message that kicked off the current invocation
@ -153,6 +161,24 @@ func (vmc *VMContext) Send(to address.Address, method uint64, value types.BigInt
}
ret, err, _ := vmc.vm.send(ctx, msg, vmc, 0)
mr := types.MessageReceipt{
ExitCode: aerrors.RetCode(err),
Return: ret,
GasUsed: types.EmptyInt,
}
var es = ""
if err != nil {
es = err.Error()
}
er := ExecutionResult{
Msg: msg,
MsgRct: &mr,
Error: es,
}
vmc.internalExecutions = append(vmc.internalExecutions, &er)
return ret, err
}
@ -341,6 +367,7 @@ type Rand interface {
type ApplyRet struct {
types.MessageReceipt
ActorErr aerrors.ActorError
InternalExecutions []*ExecutionResult
}
func (vm *VM) send(ctx context.Context, msg *types.Message, parent *VMContext,
@ -512,6 +539,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet,
GasUsed: gasUsed,
},
ActorErr: actorErr,
InternalExecutions: vmctx.internalExecutions,
}, nil
}

View File

@ -174,9 +174,10 @@ func (a *StateAPI) StateReplay(ctx context.Context, tsk types.TipSetKey, mc cid.
}
return &api.InvocResult{
Msg: m,
MsgRct: &r.MessageReceipt,
Error: errstr,
Msg: m,
MsgRct: &r.MessageReceipt,
InternalExecutions: r.InternalExecutions,
Error: errstr,
}, nil
}