From 72e4db5d667da17ccb8b10e38e2e99e5b6b4c3d5 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 14:33:47 -0300 Subject: [PATCH] Remove empty Arbitrum tracing hooks --- core/state_transition.go | 8 ++-- eth/tracers/js/goja.go | 18 ++++----- eth/tracers/js/tracer_arbitrum.go | 3 -- eth/tracers/logger/access_list_tracer.go | 6 +-- eth/tracers/logger/logger.go | 26 +++++-------- eth/tracers/logger/logger_arbitrum.go | 48 ------------------------ eth/tracers/logger/logger_json.go | 26 +++++-------- eth/tracers/native/4byte.go | 8 +--- eth/tracers/native/call.go | 15 +++----- eth/tracers/native/call_flat.go | 13 +++---- eth/tracers/native/mux.go | 16 ++++++-- eth/tracers/native/noop.go | 28 ++++++-------- eth/tracers/native/prestate.go | 10 ++--- eth/tracers/native/tracer_arbitrum.go | 24 ------------ 14 files changed, 71 insertions(+), 178 deletions(-) delete mode 100644 eth/tracers/logger/logger_arbitrum.go diff --git a/core/state_transition.go b/core/state_transition.go index 20602a825a..8c01b2c285 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -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") } @@ -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) @@ -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") } diff --git a/eth/tracers/js/goja.go b/eth/tracers/js/goja.go index c63fac360e..8a0765c27e 100644 --- a/eth/tracers/js/goja.go +++ b/eth/tracers/js/goja.go @@ -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, diff --git a/eth/tracers/js/tracer_arbitrum.go b/eth/tracers/js/tracer_arbitrum.go index 01c421e0aa..db59809ac6 100644 --- a/eth/tracers/js/tracer_arbitrum.go +++ b/eth/tracers/js/tracer_arbitrum.go @@ -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 { diff --git a/eth/tracers/logger/access_list_tracer.go b/eth/tracers/logger/access_list_tracer.go index 46752861bb..e8231461b0 100644 --- a/eth/tracers/logger/access_list_tracer.go +++ b/eth/tracers/logger/access_list_tracer.go @@ -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, } } diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index 924257bc2f..ef1d471466 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -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, } } @@ -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, } } diff --git a/eth/tracers/logger/logger_arbitrum.go b/eth/tracers/logger/logger_arbitrum.go deleted file mode 100644 index 35f56e83eb..0000000000 --- a/eth/tracers/logger/logger_arbitrum.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package logger - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/common" -) - -func (*AccessListTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) { -} -func (*jsonLogger) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) { -} -func (*StructLogger) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) { -} -func (*mdLogger) CaptureArbitrumTransfer(from, to *common.Address, amount *big.Int, before bool, purpose string) { -} - -func (*AccessListTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} -func (*jsonLogger) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} -func (*StructLogger) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} -func (*mdLogger) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} - -func (*AccessListTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} -func (*jsonLogger) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} -func (*StructLogger) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} -func (*mdLogger) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} - -func (*AccessListTracer) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) { -} -func (*jsonLogger) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {} -func (*StructLogger) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {} -func (*mdLogger) CaptureStylusHostio(name string, args, outs []byte, startInk, endInk uint64) {} diff --git a/eth/tracers/logger/logger_json.go b/eth/tracers/logger/logger_json.go index a03bedd889..d66b8c4b8a 100644 --- a/eth/tracers/logger/logger_json.go +++ b/eth/tracers/logger/logger_json.go @@ -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, } } @@ -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, } } diff --git a/eth/tracers/native/4byte.go b/eth/tracers/native/4byte.go index 9819a1f12f..9ef4c5cd56 100644 --- a/eth/tracers/native/4byte.go +++ b/eth/tracers/native/4byte.go @@ -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, diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go index 8a10e5c2a2..05690c3aa4 100644 --- a/eth/tracers/native/call.go +++ b/eth/tracers/native/call.go @@ -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, diff --git a/eth/tracers/native/call_flat.go b/eth/tracers/native/call_flat.go index 36fbdf23a9..45f81cf1c1 100644 --- a/eth/tracers/native/call_flat.go +++ b/eth/tracers/native/call_flat.go @@ -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, diff --git a/eth/tracers/native/mux.go b/eth/tracers/native/mux.go index bfb3795731..2a3a7dcdd0 100644 --- a/eth/tracers/native/mux.go +++ b/eth/tracers/native/mux.go @@ -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) + } } } diff --git a/eth/tracers/native/noop.go b/eth/tracers/native/noop.go index 8f8d259956..f147134610 100644 --- a/eth/tracers/native/noop.go +++ b/eth/tracers/native/noop.go @@ -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, diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go index f32990b284..b353c06960 100644 --- a/eth/tracers/native/prestate.go +++ b/eth/tracers/native/prestate.go @@ -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, diff --git a/eth/tracers/native/tracer_arbitrum.go b/eth/tracers/native/tracer_arbitrum.go index 1616dab323..5134b5f099 100644 --- a/eth/tracers/native/tracer_arbitrum.go +++ b/eth/tracers/native/tracer_arbitrum.go @@ -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 @@ -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 ""