Parse input/output for delegate call + other smaller things
This commit is contained in:
parent
029a4a72b8
commit
ed407689e6
@ -939,6 +939,9 @@ type EthTrace struct {
|
||||
Type string `json:"Type"`
|
||||
|
||||
Parent *EthTrace `json:"-"`
|
||||
|
||||
// if a subtrace makes a call to GetBytecode, we store a pointer to that subtrace here
|
||||
// which we then lookup when checking for delegatecall (InvokeContractDelegate)
|
||||
LastByteCode *EthTrace `json:"-"`
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/builtin/v10/evm"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
|
||||
builtinactors "github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
@ -192,6 +193,7 @@ func buildTraces(ctx context.Context, traces *[]*ethtypes.EthTrace, parent *etht
|
||||
}
|
||||
}
|
||||
|
||||
if builtinactors.IsEvmActor(parent.Action.FilecoinCodeCid) {
|
||||
// Handle delegate calls
|
||||
//
|
||||
// 1) Look for trace from an EVM actor to itself on InvokeContractDelegate, method 6.
|
||||
@ -204,16 +206,27 @@ func buildTraces(ctx context.Context, traces *[]*ethtypes.EthTrace, parent *etht
|
||||
if prev.Action.From == trace.Action.From && prev.Action.FilecoinMethod == builtin.MethodsEVM.GetBytecode && prev.Parent == trace.Parent {
|
||||
trace.SetCallType("delegatecall")
|
||||
trace.Action.To = prev.Action.To
|
||||
|
||||
var dp evm.DelegateCallParams
|
||||
err := dp.UnmarshalCBOR(bytes.NewReader(et.Msg.Params))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed UnmarshalCBOR: %w", err)
|
||||
}
|
||||
trace.Action.Input = dp.Input
|
||||
|
||||
trace.Result.Output, err = decodePayload(et.MsgRct.Return, et.MsgRct.ReturnCodec)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed decodePayload: %w", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Handle EVM call special casing
|
||||
//
|
||||
// Any outbound call from an EVM actor on methods 1-1023 are side-effects from EVM instructions
|
||||
// and should be dropped from the trace.
|
||||
if builtinactors.IsEvmActor(parent.Action.FilecoinCodeCid) &&
|
||||
et.Msg.Method > 0 &&
|
||||
if et.Msg.Method > 0 &&
|
||||
et.Msg.Method <= 1023 {
|
||||
log.Debugf("COND5 found outbound call from an EVM actor on method 1-1023 method:%d, code:%s, height:%d", et.Msg.Method, parent.Action.FilecoinCodeCid.String(), height)
|
||||
log.Debugf("Infof found outbound call from an EVM actor on method 1-1023 method:%d, code:%s, height:%d", et.Msg.Method, parent.Action.FilecoinCodeCid.String(), height)
|
||||
|
||||
if et.Msg.Method == builtin.MethodsEVM.GetBytecode {
|
||||
// save the last bytecode trace to handle delegate calls
|
||||
@ -225,6 +238,8 @@ func buildTraces(ctx context.Context, traces *[]*ethtypes.EthTrace, parent *etht
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// we are adding trace to the traces so update the parent subtraces count as it was originally set to zero
|
||||
if parent != nil {
|
||||
parent.Subtraces += 1
|
||||
|
Loading…
Reference in New Issue
Block a user