@@ -45,10 +45,12 @@ type callLog struct {
4545 // Position of the log relative to subcalls within the same trace
4646 // See https://github.com/ethereum/go-ethereum/pull/28389 for details
4747 Position hexutil.Uint `json:"position"`
48+ Pc uint64 `json:"pc"`
4849}
4950
5051type callFrame struct {
5152 Type vm.OpCode `json:"-"`
53+ Pc uint64 `json:"pc"`
5254 From common.Address `json:"from"`
5355 Gas uint64 `json:"gas"`
5456 GasUsed uint64 `json:"gasUsed"`
@@ -117,6 +119,7 @@ type callTracer struct {
117119 depth int
118120 interrupt atomic.Bool // Atomic flag to signal execution interruption
119121 reason error // Textual reason for the interruption
122+ lastPc uint64
120123}
121124
122125type callTracerConfig struct {
@@ -138,6 +141,7 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *param
138141 OnEnter : t .OnEnter ,
139142 OnExit : t .OnExit ,
140143 OnLog : t .OnLog ,
144+ OnOpcode : t .OnOpcode ,
141145 },
142146 GetResult : t .GetResult ,
143147 Stop : t .Stop ,
@@ -173,6 +177,7 @@ func (t *callTracer) OnEnter(depth int, typ byte, from common.Address, to common
173177 Input : common .CopyBytes (input ),
174178 Gas : gas ,
175179 Value : value ,
180+ Pc : t .lastPc ,
176181 }
177182 if depth == 0 {
178183 call .Gas = t .gasLimit
@@ -219,6 +224,10 @@ func (t *callTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, fr
219224 t .gasLimit = tx .Gas ()
220225}
221226
227+ func (t * callTracer ) OnOpcode (pc uint64 , op byte , gas , cost uint64 , scope tracing.OpContext , rData []byte , depth int , err error ) {
228+ t .lastPc = pc
229+ }
230+
222231func (t * callTracer ) OnTxEnd (receipt * types.Receipt , err error ) {
223232 // Error happened during tx validation.
224233 if err != nil {
@@ -251,6 +260,7 @@ func (t *callTracer) OnLog(log *types.Log) {
251260 Topics : log .Topics ,
252261 Data : log .Data ,
253262 Position : hexutil .Uint (len (t .callstack [len (t .callstack )- 1 ].Calls )),
263+ Pc : t .lastPc ,
254264 }
255265 t .callstack [len (t .callstack )- 1 ].Logs = append (t .callstack [len (t .callstack )- 1 ].Logs , l )
256266}
0 commit comments