mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
eth/tracers: add pc field to callTracer
This commit is contained in:
parent
395425902d
commit
22475726d7
2 changed files with 16 additions and 0 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue