diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go index 68194cf0f5..0d9e6b8242 100644 --- a/eth/tracers/native/call.go +++ b/eth/tracers/native/call.go @@ -32,17 +32,13 @@ import ( "github.com/ethereum/go-ethereum/params" ) -//go:generate go run github.com/fjl/gencodec -type callFrame -field-override callFrameMarshaling -out gen_callframe_json.go +//go:generate go run github.com/fjl/gencodec -type CallFrame -field-override CallFrameMarshaling -out gen_CallFrame_json.go func init() { tracers.DefaultDirectory.Register("callTracer", newCallTracer, false) } -type CallFrame struct { - callFrame -} - -type callLog struct { +type CallLog struct { Address common.Address `json:"address"` Topics []common.Hash `json:"topics"` Data hexutil.Bytes `json:"data"` @@ -51,7 +47,7 @@ type callLog struct { Position hexutil.Uint `json:"position"` } -type callFrame struct { +type CallFrame struct { Type vm.OpCode `json:"type"` From common.Address `json:"from"` Gas uint64 `json:"gas"` @@ -61,23 +57,23 @@ type callFrame struct { Output []byte `json:"output,omitempty" rlp:"optional"` Error string `json:"error,omitempty" rlp:"optional"` RevertReason string `json:"revertReason,omitempty"` - Calls []callFrame `json:"calls,omitempty" rlp:"optional"` - Logs []callLog `json:"logs,omitempty" rlp:"optional"` + Calls []CallFrame `json:"calls,omitempty" rlp:"optional"` + Logs []CallLog `json:"logs,omitempty" rlp:"optional"` // Placed at end on purpose. The RLP will be decoded to 0 instead of // nil if there are non-empty elements after in the struct. Value *big.Int `json:"value,omitempty" rlp:"optional"` revertedSnapshot bool } -func (f callFrame) TypeString() string { +func (f CallFrame) TypeString() string { return f.Type.String() } -func (f callFrame) failed() bool { +func (f CallFrame) failed() bool { return len(f.Error) > 0 && f.revertedSnapshot } -func (f *callFrame) processOutput(output []byte, err error, reverted bool) { +func (f *CallFrame) processOutput(output []byte, err error, reverted bool) { output = common.CopyBytes(output) // Clear error if tx wasn't reverted. This happened // for pre-homestead contract storage OOG. @@ -105,7 +101,7 @@ func (f *callFrame) processOutput(output []byte, err error, reverted bool) { } } -type callFrameMarshaling struct { +type CallFrameMarshaling struct { TypeString string `json:"type"` Gas hexutil.Uint64 GasUsed hexutil.Uint64 @@ -115,7 +111,7 @@ type callFrameMarshaling struct { } type callTracer struct { - callstack []callFrame + callstack []CallFrame config callTracerConfig gasLimit uint64 depth int @@ -153,9 +149,9 @@ func newCallTracerObject(ctx *tracers.Context, cfg json.RawMessage) (*callTracer if err := json.Unmarshal(cfg, &config); err != nil { return nil, err } - // First callframe contains tx context info + // First CallFrame contains tx context info // and is populated on start and end. - return &callTracer{callstack: make([]callFrame, 0, 1), config: config}, nil + return &callTracer{callstack: make([]CallFrame, 0, 1), config: config}, nil } // OnEnter is called when EVM enters a new scope (via call, create or selfdestruct). @@ -170,7 +166,7 @@ func (t *callTracer) OnEnter(depth int, typ byte, from common.Address, to common } toCopy := to - call := callFrame{ + call := CallFrame{ Type: vm.OpCode(typ), From: from, To: &toCopy, @@ -250,7 +246,7 @@ func (t *callTracer) OnLog(log *types.Log) { if t.interrupt.Load() { return } - l := callLog{ + l := CallLog{ Address: log.Address, Topics: log.Topics, Data: log.Data, @@ -279,9 +275,9 @@ func (t *callTracer) Stop(err error) { t.interrupt.Store(true) } -// clearFailedLogs clears the logs of a callframe and all its children +// clearFailedLogs clears the logs of a CallFrame and all its children // in case of execution failure. -func clearFailedLogs(cf *callFrame, parentFailed bool) { +func clearFailedLogs(cf *CallFrame, parentFailed bool) { failed := cf.failed() || parentFailed // Clear own logs if failed { diff --git a/eth/tracers/native/call_flat.go b/eth/tracers/native/call_flat.go index 4e7fc31a9c..e472566439 100644 --- a/eth/tracers/native/call_flat.go +++ b/eth/tracers/native/call_flat.go @@ -247,7 +247,7 @@ func (t *flatCallTracer) isPrecompiled(addr common.Address) bool { return slices.Contains(t.activePrecompiles, addr) } -func flatFromNested(input *callFrame, traceAddress []int, convertErrs bool, ctx *tracers.Context) (output []flatCallFrame, err error) { +func flatFromNested(input *CallFrame, traceAddress []int, convertErrs bool, ctx *tracers.Context) (output []flatCallFrame, err error) { var frame *flatCallFrame switch input.Type { case vm.CREATE, vm.CREATE2: @@ -288,7 +288,7 @@ func flatFromNested(input *callFrame, traceAddress []int, convertErrs bool, ctx return output, nil } -func newFlatCreate(input *callFrame) *flatCallFrame { +func newFlatCreate(input *CallFrame) *flatCallFrame { var ( actionInit = input.Input[:] resultCode = input.Output[:] @@ -311,7 +311,7 @@ func newFlatCreate(input *callFrame) *flatCallFrame { } } -func newFlatCall(input *callFrame) *flatCallFrame { +func newFlatCall(input *CallFrame) *flatCallFrame { var ( actionInput = input.Input[:] resultOutput = input.Output[:] @@ -334,7 +334,7 @@ func newFlatCall(input *callFrame) *flatCallFrame { } } -func newFlatSelfdestruct(input *callFrame) *flatCallFrame { +func newFlatSelfdestruct(input *CallFrame) *flatCallFrame { return &flatCallFrame{ Type: "suicide", Action: flatCallAction{ @@ -345,20 +345,20 @@ func newFlatSelfdestruct(input *callFrame) *flatCallFrame { } } -func fillCallFrameFromContext(callFrame *flatCallFrame, ctx *tracers.Context) { +func fillCallFrameFromContext(CallFrame *flatCallFrame, ctx *tracers.Context) { if ctx == nil { return } if ctx.BlockHash != (common.Hash{}) { - callFrame.BlockHash = &ctx.BlockHash + CallFrame.BlockHash = &ctx.BlockHash } if ctx.BlockNumber != nil { - callFrame.BlockNumber = ctx.BlockNumber.Uint64() + CallFrame.BlockNumber = ctx.BlockNumber.Uint64() } if ctx.TxHash != (common.Hash{}) { - callFrame.TransactionHash = &ctx.TxHash + CallFrame.TransactionHash = &ctx.TxHash } - callFrame.TransactionPosition = uint64(ctx.TxIndex) + CallFrame.TransactionPosition = uint64(ctx.TxIndex) } func convertErrorToParity(call *flatCallFrame) { diff --git a/eth/tracers/native/gen_callframe_json.go b/eth/tracers/native/gen_callframe_json.go index 40e35f1674..ba85cf767d 100644 --- a/eth/tracers/native/gen_callframe_json.go +++ b/eth/tracers/native/gen_callframe_json.go @@ -11,11 +11,11 @@ import ( "github.com/ethereum/go-ethereum/core/vm" ) -var _ = (*callFrameMarshaling)(nil) +var _ = (*CallFrameMarshaling)(nil) // MarshalJSON marshals as JSON. -func (c callFrame) MarshalJSON() ([]byte, error) { - type callFrame0 struct { +func (c CallFrame) MarshalJSON() ([]byte, error) { + type CallFrame0 struct { Type vm.OpCode `json:"type"` From common.Address `json:"from"` Gas hexutil.Uint64 `json:"gas"` @@ -25,12 +25,12 @@ func (c callFrame) MarshalJSON() ([]byte, error) { Output hexutil.Bytes `json:"output,omitempty" rlp:"optional"` Error string `json:"error,omitempty" rlp:"optional"` RevertReason string `json:"revertReason,omitempty"` - Calls []callFrame `json:"calls,omitempty" rlp:"optional"` - Logs []callLog `json:"logs,omitempty" rlp:"optional"` + Calls []CallFrame `json:"calls,omitempty" rlp:"optional"` + Logs []CallLog `json:"logs,omitempty" rlp:"optional"` Value *hexutil.Big `json:"value,omitempty" rlp:"optional"` TypeString string `json:"type"` } - var enc callFrame0 + var enc CallFrame0 enc.Type = c.Type enc.From = c.From enc.Gas = hexutil.Uint64(c.Gas) @@ -48,8 +48,8 @@ func (c callFrame) MarshalJSON() ([]byte, error) { } // UnmarshalJSON unmarshals from JSON. -func (c *callFrame) UnmarshalJSON(input []byte) error { - type callFrame0 struct { +func (c *CallFrame) UnmarshalJSON(input []byte) error { + type CallFrame0 struct { Type *vm.OpCode `json:"type"` From *common.Address `json:"from"` Gas *hexutil.Uint64 `json:"gas"` @@ -59,11 +59,11 @@ func (c *callFrame) UnmarshalJSON(input []byte) error { Output *hexutil.Bytes `json:"output,omitempty" rlp:"optional"` Error *string `json:"error,omitempty" rlp:"optional"` RevertReason *string `json:"revertReason,omitempty"` - Calls []callFrame `json:"calls,omitempty" rlp:"optional"` - Logs []callLog `json:"logs,omitempty" rlp:"optional"` + Calls []CallFrame `json:"calls,omitempty" rlp:"optional"` + Logs []CallLog `json:"logs,omitempty" rlp:"optional"` Value *hexutil.Big `json:"value,omitempty" rlp:"optional"` } - var dec callFrame0 + var dec CallFrame0 if err := json.Unmarshal(input, &dec); err != nil { return err }