Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty Arbitrum tracing hooks #365

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (st *StateTransition) buyGas() error {
st.state.SubBalance(st.msg.From, mgvalU256, tracing.BalanceDecreaseGasBuy)

// Arbitrum: record fee payment
if tracer := st.evm.Config.Tracer; tracer != nil {
if tracer := st.evm.Config.Tracer; tracer != nil && tracer.CaptureArbitrumTransfer != nil {
tracer.CaptureArbitrumTransfer(&st.msg.From, nil, mgval, true, "feePayment")
}

Expand Down Expand Up @@ -528,14 +528,14 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}

// Arbitrum: record the tip
if tracer := st.evm.Config.Tracer; tracer != nil && !st.evm.ProcessingHook.DropTip() {
if tracer := st.evm.Config.Tracer; tracer != nil && !st.evm.ProcessingHook.DropTip() && tracer.CaptureArbitrumTransfer != nil {
tracer.CaptureArbitrumTransfer(nil, &tipReceipient, tipAmount, false, "tip")
}

st.evm.ProcessingHook.EndTxHook(st.gasRemaining, vmerr == nil)

// Arbitrum: record self destructs
if tracer := st.evm.Config.Tracer; tracer != nil {
if tracer := st.evm.Config.Tracer; tracer != nil && tracer.CaptureArbitrumTransfer != nil {
suicides := st.evm.StateDB.GetSelfDestructs()
for i, address := range suicides {
balance := st.evm.StateDB.GetBalance(address)
Expand Down Expand Up @@ -582,7 +582,7 @@ func (st *StateTransition) refundGas(refundQuotient uint64) uint64 {
}

// Arbitrum: record the gas refund
if tracer := st.evm.Config.Tracer; tracer != nil {
if tracer := st.evm.Config.Tracer; tracer != nil && tracer.CaptureArbitrumTransfer != nil {
tracer.CaptureArbitrumTransfer(nil, &st.msg.From, remaining.ToBig(), false, "gasRefund")
}

Expand Down
18 changes: 8 additions & 10 deletions eth/tracers/js/goja.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,14 @@ func newJsTracer(code string, ctx *tracers.Context, cfg json.RawMessage) (*trace

return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnOpcode: t.OnOpcode,
OnFault: t.OnFault,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet,
CaptureStylusHostio: t.CaptureStylusHostio,
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnOpcode: t.OnOpcode,
OnFault: t.OnFault,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
CaptureStylusHostio: t.CaptureStylusHostio,
},
GetResult: t.GetResult,
Stop: t.Stop,
Expand Down
3 changes: 0 additions & 3 deletions eth/tracers/js/tracer_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ func (jst *jsTracer) CaptureArbitrumTransfer(
}
}

func (*jsTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {}
func (*jsTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {}

func (jst *jsTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {
hostio, ok := goja.AssertFunction(jst.obj.Get("hostio"))
if !ok {
Expand Down
6 changes: 1 addition & 5 deletions eth/tracers/logger/access_list_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ func NewAccessListTracer(acl types.AccessList, from, to common.Address, precompi

func (a *AccessListTracer) Hooks() *tracing.Hooks {
return &tracing.Hooks{
OnOpcode: a.OnOpcode,
CaptureArbitrumTransfer: a.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: a.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: a.CaptureArbitrumStorageSet,
CaptureStylusHostio: a.CaptureStylusHostio,
OnOpcode: a.OnOpcode,
}
}

Expand Down
26 changes: 9 additions & 17 deletions eth/tracers/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,10 @@ func NewStructLogger(cfg *Config) *StructLogger {

func (l *StructLogger) Hooks() *tracing.Hooks {
return &tracing.Hooks{
OnTxStart: l.OnTxStart,
OnTxEnd: l.OnTxEnd,
OnExit: l.OnExit,
OnOpcode: l.OnOpcode,
CaptureArbitrumTransfer: l.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: l.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: l.CaptureArbitrumStorageSet,
CaptureStylusHostio: l.CaptureStylusHostio,
OnTxStart: l.OnTxStart,
OnTxEnd: l.OnTxEnd,
OnExit: l.OnExit,
OnOpcode: l.OnOpcode,
}
}

Expand Down Expand Up @@ -349,15 +345,11 @@ func NewMarkdownLogger(cfg *Config, writer io.Writer) *mdLogger {

func (t *mdLogger) Hooks() *tracing.Hooks {
return &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnOpcode: t.OnOpcode,
OnFault: t.OnFault,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet,
CaptureStylusHostio: t.CaptureStylusHostio,
OnTxStart: t.OnTxStart,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnOpcode: t.OnOpcode,
OnFault: t.OnFault,
}
}

Expand Down
48 changes: 0 additions & 48 deletions eth/tracers/logger/logger_arbitrum.go

This file was deleted.

26 changes: 9 additions & 17 deletions eth/tracers/logger/logger_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,10 @@ func NewJSONLogger(cfg *Config, writer io.Writer) *tracing.Hooks {
l.cfg = &Config{}
}
return &tracing.Hooks{
OnTxStart: l.OnTxStart,
OnExit: l.OnExit,
OnOpcode: l.OnOpcode,
OnFault: l.OnFault,
CaptureArbitrumTransfer: l.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: l.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: l.CaptureArbitrumStorageSet,
CaptureStylusHostio: l.CaptureStylusHostio,
OnTxStart: l.OnTxStart,
OnExit: l.OnExit,
OnOpcode: l.OnOpcode,
OnFault: l.OnFault,
}
}

Expand All @@ -87,15 +83,11 @@ func NewJSONLoggerWithCallFrames(cfg *Config, writer io.Writer) *tracing.Hooks {
l.cfg = &Config{}
}
return &tracing.Hooks{
OnTxStart: l.OnTxStart,
OnEnter: l.OnEnter,
OnExit: l.OnExit,
OnOpcode: l.OnOpcode,
OnFault: l.OnFault,
CaptureArbitrumTransfer: l.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: l.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: l.CaptureArbitrumStorageSet,
CaptureStylusHostio: l.CaptureStylusHostio,
OnTxStart: l.OnTxStart,
OnEnter: l.OnEnter,
OnExit: l.OnExit,
OnOpcode: l.OnOpcode,
OnFault: l.OnFault,
}
}

Expand Down
8 changes: 2 additions & 6 deletions eth/tracers/native/4byte.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ func newFourByteTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer
}
return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnEnter: t.OnEnter,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet,
CaptureStylusHostio: t.CaptureStylusHostio,
OnTxStart: t.OnTxStart,
OnEnter: t.OnEnter,
},
GetResult: t.GetResult,
Stop: t.Stop,
Expand Down
15 changes: 6 additions & 9 deletions eth/tracers/native/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,12 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer,
}
return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnLog: t.OnLog,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet,
CaptureStylusHostio: t.CaptureStylusHostio,
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnLog: t.OnLog,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
},
GetResult: t.GetResult,
Stop: t.Stop,
Expand Down
13 changes: 5 additions & 8 deletions eth/tracers/native/call_flat.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,11 @@ func newFlatCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Trac
ft := &flatCallTracer{tracer: t, ctx: ctx, config: config}
return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: ft.OnTxStart,
OnTxEnd: ft.OnTxEnd,
OnEnter: ft.OnEnter,
OnExit: ft.OnExit,
CaptureArbitrumTransfer: ft.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: ft.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: ft.CaptureArbitrumStorageSet,
CaptureStylusHostio: ft.CaptureStylusHostio,
OnTxStart: ft.OnTxStart,
OnTxEnd: ft.OnTxEnd,
OnEnter: ft.OnEnter,
OnExit: ft.OnExit,
CaptureArbitrumTransfer: ft.CaptureArbitrumTransfer,
},
Stop: ft.Stop,
GetResult: ft.GetResult,
Expand Down
16 changes: 12 additions & 4 deletions eth/tracers/native/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,33 @@ func (t *muxTracer) OnLog(log *types.Log) {

func (t *muxTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {
for _, t := range t.tracers {
t.CaptureArbitrumStorageGet(key, depth, before)
if t.CaptureArbitrumStorageGet != nil {
t.CaptureArbitrumStorageGet(key, depth, before)
}
}
}

func (t *muxTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {
for _, t := range t.tracers {
t.CaptureArbitrumStorageSet(key, value, depth, before)
if t.CaptureArbitrumStorageSet != nil {
t.CaptureArbitrumStorageSet(key, value, depth, before)
}
}
}

func (t *muxTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) {
for _, t := range t.tracers {
t.CaptureArbitrumTransfer(from, to, value, before, purpose)
if t.CaptureArbitrumTransfer != nil {
t.CaptureArbitrumTransfer(from, to, value, before, purpose)
}
}
}

func (t *muxTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {
for _, t := range t.tracers {
t.CaptureStylusHostio(name, args, outs, startInk, endInk)
if t.CaptureStylusHostio != nil {
t.CaptureStylusHostio(name, args, outs, startInk, endInk)
}
}
}

Expand Down
28 changes: 12 additions & 16 deletions eth/tracers/native/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,18 @@ func newNoopTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, er
t := &noopTracer{}
return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnOpcode: t.OnOpcode,
OnFault: t.OnFault,
OnGasChange: t.OnGasChange,
OnBalanceChange: t.OnBalanceChange,
OnNonceChange: t.OnNonceChange,
OnCodeChange: t.OnCodeChange,
OnStorageChange: t.OnStorageChange,
OnLog: t.OnLog,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet,
CaptureStylusHostio: t.CaptureStylusHostio,
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnEnter: t.OnEnter,
OnExit: t.OnExit,
OnOpcode: t.OnOpcode,
OnFault: t.OnFault,
OnGasChange: t.OnGasChange,
OnBalanceChange: t.OnBalanceChange,
OnNonceChange: t.OnNonceChange,
OnCodeChange: t.OnCodeChange,
OnStorageChange: t.OnStorageChange,
OnLog: t.OnLog,
},
GetResult: t.GetResult,
Stop: t.Stop,
Expand Down
10 changes: 3 additions & 7 deletions eth/tracers/native/prestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,9 @@ func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Trac
}
return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnOpcode: t.OnOpcode,
CaptureArbitrumTransfer: t.CaptureArbitrumTransfer,
CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet,
CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet,
CaptureStylusHostio: t.CaptureStylusHostio,
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnOpcode: t.OnOpcode,
},
GetResult: t.GetResult,
Stop: t.Stop,
Expand Down
24 changes: 0 additions & 24 deletions eth/tracers/native/tracer_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ func (t *callTracer) CaptureArbitrumTransfer(
}
}

func (*fourByteTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) {
}
func (*noopTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) {
}
func (*prestateTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) {
}
func (t *flatCallTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) {
if t.interrupt.Load() {
return
Expand All @@ -80,24 +74,6 @@ func (t *flatCallTracer) CaptureArbitrumTransfer(from, to *common.Address, value
}
}

func (*callTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {}
func (*fourByteTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {}
func (*noopTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {}
func (*prestateTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {}
func (*flatCallTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {}

func (*callTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {}
func (*fourByteTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {}
func (*noopTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {}
func (*prestateTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {}
func (*flatCallTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {}

func (*callTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {}
func (*fourByteTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {}
func (*noopTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {}
func (*prestateTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {}
func (*flatCallTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {}

func bigToHex(n *big.Int) string {
if n == nil {
return ""
Expand Down
Loading