diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go index c2247d1ce491..979c2e1d7fc6 100644 --- a/eth/tracers/native/call.go +++ b/eth/tracers/native/call.go @@ -45,10 +45,12 @@ type callLog struct { // Position of the log relative to subcalls within the same trace // See https://github.com/ethereum/go-ethereum/pull/28389 for details Position hexutil.Uint `json:"position"` + Pc uint64 `json:"pc"` } type callFrame struct { Type vm.OpCode `json:"-"` + Pc uint64 `json:"pc"` From common.Address `json:"from"` Gas uint64 `json:"gas"` GasUsed uint64 `json:"gasUsed"` @@ -117,6 +119,7 @@ type callTracer struct { depth int interrupt atomic.Bool // Atomic flag to signal execution interruption reason error // Textual reason for the interruption + lastPc uint64 } type callTracerConfig struct { @@ -138,6 +141,7 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *param OnEnter: t.OnEnter, OnExit: t.OnExit, OnLog: t.OnLog, + OnOpcode: t.OnOpcode, }, GetResult: t.GetResult, Stop: t.Stop, @@ -173,6 +177,7 @@ func (t *callTracer) OnEnter(depth int, typ byte, from common.Address, to common Input: common.CopyBytes(input), Gas: gas, Value: value, + Pc: t.lastPc, } if depth == 0 { call.Gas = t.gasLimit @@ -219,6 +224,10 @@ func (t *callTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, fr t.gasLimit = tx.Gas() } +func (t *callTracer) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) { + t.lastPc = pc +} + func (t *callTracer) OnTxEnd(receipt *types.Receipt, err error) { // Error happened during tx validation. if err != nil { @@ -251,6 +260,7 @@ func (t *callTracer) OnLog(log *types.Log) { Topics: log.Topics, Data: log.Data, Position: hexutil.Uint(len(t.callstack[len(t.callstack)-1].Calls)), + Pc: t.lastPc, } t.callstack[len(t.callstack)-1].Logs = append(t.callstack[len(t.callstack)-1].Logs, l) } diff --git a/eth/tracers/native/gen_callframe_json.go b/eth/tracers/native/gen_callframe_json.go index c44f38390df7..5211982d8a42 100644 --- a/eth/tracers/native/gen_callframe_json.go +++ b/eth/tracers/native/gen_callframe_json.go @@ -17,6 +17,7 @@ var _ = (*callFrameMarshaling)(nil) func (c callFrame) MarshalJSON() ([]byte, error) { type callFrame0 struct { Type vm.OpCode `json:"-"` + Pc uint64 `json:"pc"` From common.Address `json:"from"` Gas hexutil.Uint64 `json:"gas"` GasUsed hexutil.Uint64 `json:"gasUsed"` @@ -44,6 +45,7 @@ func (c callFrame) MarshalJSON() ([]byte, error) { enc.Logs = c.Logs enc.Value = (*hexutil.Big)(c.Value) enc.TypeString = c.TypeString() + enc.Pc = c.Pc return json.Marshal(&enc) } @@ -51,6 +53,7 @@ func (c callFrame) MarshalJSON() ([]byte, error) { func (c *callFrame) UnmarshalJSON(input []byte) error { type callFrame0 struct { Type *vm.OpCode `json:"-"` + Pc uint64 `json:"pc"` From *common.Address `json:"from"` Gas *hexutil.Uint64 `json:"gas"` GasUsed *hexutil.Uint64 `json:"gasUsed"` @@ -70,6 +73,9 @@ func (c *callFrame) UnmarshalJSON(input []byte) error { if dec.Type != nil { c.Type = *dec.Type } + + c.Pc = dec.Pc + if dec.From != nil { c.From = *dec.From }