From 39bf7e9eccf01dd652ed10c9a021a7d972f9bfbb Mon Sep 17 00:00:00 2001 From: tanlang Date: Thu, 13 Apr 2023 05:52:28 +0000 Subject: [PATCH] feat: init Msg and MsgRct for ExecutionTrace when apply msg --- pkg/vm/vmcontext/vmcontext.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/vm/vmcontext/vmcontext.go b/pkg/vm/vmcontext/vmcontext.go index 9fec1d7591..33effd0e5e 100644 --- a/pkg/vm/vmcontext/vmcontext.go +++ b/pkg/vm/vmcontext/vmcontext.go @@ -196,6 +196,10 @@ func (vm *LegacyVM) normalizeAddress(addr address.Address) (address.Address, boo func (vm *LegacyVM) applyImplicitMessage(imsg VmMessage) (*Ret, error) { // implicit messages gas is tracked separatly and not paid by the miner gasTank := gas.NewGasTracker(constants.BlockGasLimit * 10000) + gasTank.ExecutionTrace.Msg.From = imsg.From + gasTank.ExecutionTrace.Msg.To = imsg.To + gasTank.ExecutionTrace.Msg.Method = imsg.Method + gasTank.ExecutionTrace.Msg.Value = imsg.Value if imsg.Params != nil { gasTank.ExecutionTrace.Msg.ParamsCodec = CborCodec } @@ -238,6 +242,8 @@ func (vm *LegacyVM) applyImplicitMessage(imsg VmMessage) (*Ret, error) { if len(ret) > 0 { gasTank.ExecutionTrace.MsgRct.ReturnCodec = CborCodec } + gasTank.ExecutionTrace.MsgRct.Return = ret + gasTank.ExecutionTrace.MsgRct.ExitCode = code return &Ret{ GasTracker: gasTank, OutPuts: gas.GasOutputs{}, @@ -267,6 +273,10 @@ func (vm *LegacyVM) applyMessage(msg *types.Message, onChainMsgSize int) (*Ret, // (see: `invocationContext.invoke()` for the dispatch and execution) // initiate gas tracking gasTank := gas.NewGasTracker(msg.GasLimit) + gasTank.ExecutionTrace.Msg.From = msg.From + gasTank.ExecutionTrace.Msg.To = msg.To + gasTank.ExecutionTrace.Msg.Method = msg.Method + gasTank.ExecutionTrace.Msg.Value = msg.Value if len(msg.Params) > 0 { gasTank.ExecutionTrace.Msg.ParamsCodec = CborCodec } @@ -421,6 +431,8 @@ func (vm *LegacyVM) applyMessage(msg *types.Message, onChainMsgSize int) (*Ret, if len(ret) > 0 { gasTank.ExecutionTrace.MsgRct.ReturnCodec = CborCodec } + gasTank.ExecutionTrace.MsgRct.Return = ret + gasTank.ExecutionTrace.MsgRct.ExitCode = code // Roll back all stateView if the receipt's exit code is not ok. // This is required in addition To revert within the invocation context since top level messages can fail for