diff --git a/cmd/evm/blockrunner.go b/cmd/evm/blockrunner.go
index d5cd8d8e3de2..44477296cc6a 100644
--- a/cmd/evm/blockrunner.go
+++ b/cmd/evm/blockrunner.go
@@ -26,7 +26,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
"github.com/ethereum/go-ethereum/tests"
"github.com/urfave/cli/v2"
diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go
index d8665d22d34b..fa477dec1127 100644
--- a/cmd/evm/internal/t8ntool/transition.go
+++ b/cmd/evm/internal/t8ntool/transition.go
@@ -29,7 +29,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/tracers"
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
index 235fed66302a..af12b7a0fe81 100644
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -33,7 +33,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm/runtime"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index e98d5cc8e3e0..1ab126ed51b6 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -42,6 +42,7 @@ import (
"github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/txpool/blobpool"
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
"github.com/ethereum/go-ethereum/core/vm"
@@ -2180,7 +2181,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
if ctx.IsSet(VMTraceFlag.Name) {
if name := ctx.String(VMTraceFlag.Name); name != "" {
config := json.RawMessage(ctx.String(VMTraceJsonConfigFlag.Name))
- t, err := tracers.LiveDirectory.New(name, config)
+ t, err := tracing.LiveDirectory.New(name, config)
if err != nil {
Fatalf("Failed to create tracer %q: %v", name, err)
}
diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go
index 4ee19c7d4d6e..ebe9f89547a2 100644
--- a/consensus/beacon/consensus.go
+++ b/consensus/beacon/consensus.go
@@ -26,7 +26,7 @@ import (
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go
index 4f92f1282b9e..4890286381d8 100644
--- a/consensus/ethash/consensus.go
+++ b/consensus/ethash/consensus.go
@@ -28,7 +28,7 @@ import (
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
diff --git a/consensus/misc/dao.go b/consensus/misc/dao.go
index b80c1b833a47..83857ec68b48 100644
--- a/consensus/misc/dao.go
+++ b/consensus/misc/dao.go
@@ -21,7 +21,7 @@ import (
"errors"
"math/big"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
diff --git a/core/blockchain.go b/core/blockchain.go
index c3da61b28108..ae1e6451401e 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -39,7 +39,7 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/stateless"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/core/evm.go b/core/evm.go
index 5d3c454d7c47..b5ac9c88cdff 100644
--- a/core/evm.go
+++ b/core/evm.go
@@ -22,7 +22,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/holiman/uint256"
diff --git a/core/genesis.go b/core/genesis.go
index eff92084ebad..50a2cba60647 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -29,7 +29,7 @@ import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 0183c14480df..593b0d0f6487 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -30,7 +30,7 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/stateless"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
diff --git a/core/state/statedb_hooked.go b/core/state/statedb_hooked.go
index e7ec0228f0f7..f880fa1e2387 100644
--- a/core/state/statedb_hooked.go
+++ b/core/state/statedb_hooked.go
@@ -21,7 +21,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/stateless"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
diff --git a/core/state_processor.go b/core/state_processor.go
index bd0ffb86403a..3065dcc642d8 100644
--- a/core/state_processor.go
+++ b/core/state_processor.go
@@ -226,10 +226,8 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
// contract. This method is exported to be used in tests.
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb vm.StateDB) {
if tracer := vmenv.Config.Tracer; tracer != nil {
- if tracer.OnSystemCallStartV2 != nil {
- tracer.OnSystemCallStartV2(vmenv.GetVMContext())
- } else if tracer.OnSystemCallStart != nil {
- tracer.OnSystemCallStart()
+ if tracer.OnSystemCallStart != nil {
+ tracer.OnSystemCallStart(vmenv.GetVMContext())
}
if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd()
@@ -254,10 +252,8 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb vm.St
// as per EIP-2935.
func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb vm.StateDB) {
if tracer := vmenv.Config.Tracer; tracer != nil {
- if tracer.OnSystemCallStartV2 != nil {
- tracer.OnSystemCallStartV2(vmenv.GetVMContext())
- } else if tracer.OnSystemCallStart != nil {
- tracer.OnSystemCallStart()
+ if tracer.OnSystemCallStart != nil {
+ tracer.OnSystemCallStart(vmenv.GetVMContext())
}
if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd()
@@ -292,10 +288,8 @@ func ProcessConsolidationQueue(vmenv *vm.EVM, statedb vm.StateDB) []byte {
func processRequestsSystemCall(vmenv *vm.EVM, statedb vm.StateDB, requestType byte, addr common.Address) []byte {
if tracer := vmenv.Config.Tracer; tracer != nil {
- if tracer.OnSystemCallStartV2 != nil {
- tracer.OnSystemCallStartV2(vmenv.GetVMContext())
- } else if tracer.OnSystemCallStart != nil {
- tracer.OnSystemCallStart()
+ if tracer.OnSystemCallStart != nil {
+ tracer.OnSystemCallStart(vmenv.GetVMContext())
}
if tracer.OnSystemCallEnd != nil {
defer tracer.OnSystemCallEnd()
diff --git a/core/state_transition.go b/core/state_transition.go
index 4bd3c00167fc..ef86ab442aa7 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -22,7 +22,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go
index 404f340eb730..f3a250f614f0 100644
--- a/core/tracing/hooks.go
+++ b/core/tracing/hooks.go
@@ -17,6 +17,7 @@
package tracing
import (
+ "encoding/json"
"math/big"
"reflect"
@@ -71,6 +72,9 @@ type BlockEvent struct {
}
type (
+ // LiveConstructor is the constructor for a live tracer.
+ LiveConstructor = func(config json.RawMessage) (*Hooks, error)
+
/*
- VM events -
*/
@@ -150,10 +154,6 @@ type (
// will not be invoked.
OnSystemCallStartHook = func()
- // OnSystemCallStartHookV2 is called when a system call is about to be executed. Refer
- // to `OnSystemCallStartHook` for more information.
- OnSystemCallStartHookV2 = func(vm *VMContext)
-
// OnSystemCallEndHook is called when a system call has finished executing. Today,
// this hook is invoked when the EIP-4788 system call is about to be executed to set the
// beacon block root.
@@ -177,29 +177,11 @@ type (
// LogHook is called when a log is emitted.
LogHook = func(log *types.Log)
-
- // BalanceReadHook is called when EVM reads the balance of an account.
- BalanceReadHook = func(addr common.Address, bal *big.Int)
-
- // NonceReadHook is called when EVM reads the nonce of an account.
- NonceReadHook = func(addr common.Address, nonce uint64)
-
- // CodeReadHook is called when EVM reads the code of an account.
- CodeReadHook = func(addr common.Address, code []byte)
-
- // CodeSizeReadHook is called when EVM reads the code size of an account.
- CodeSizeReadHook = func(addr common.Address, size int)
-
- // CodeHashReadHook is called when EVM reads the code hash of an account.
- CodeHashReadHook = func(addr common.Address, hash common.Hash)
-
- // StorageReadHook is called when EVM reads a storage slot of an account.
- StorageReadHook = func(addr common.Address, slot, value common.Hash)
-
- // BlockHashReadHook is called when EVM reads the blockhash of a block.
- BlockHashReadHook = func(blockNumber uint64, hash common.Hash)
)
+// Hooks is a collection of hooks in EVM execution, blockchain, and state logic.
+// It is used by live tracers which run parallel to the node's execution, as well
+// as the debug tracing API.
type Hooks struct {
// VM events
OnTxStart TxStartHook
@@ -210,47 +192,56 @@ type Hooks struct {
OnFault FaultHook
OnGasChange GasChangeHook
// Chain events
- OnBlockchainInit BlockchainInitHook
- OnClose CloseHook
- OnBlockStart BlockStartHook
- OnBlockEnd BlockEndHook
- OnSkippedBlock SkippedBlockHook
- OnGenesisBlock GenesisBlockHook
- OnSystemCallStart OnSystemCallStartHook
- OnSystemCallStartV2 OnSystemCallStartHookV2
- OnSystemCallEnd OnSystemCallEndHook
+ OnBlockchainInit BlockchainInitHook
+ OnClose CloseHook
+ OnBlockStart BlockStartHook
+ OnBlockEnd BlockEndHook
+ OnSkippedBlock SkippedBlockHook
+ OnGenesisBlock GenesisBlockHook
+ OnSystemCallStart OnSystemCallStartHook
+ OnSystemCallEnd OnSystemCallEndHook
// State events
OnBalanceChange BalanceChangeHook
OnNonceChange NonceChangeHook
OnCodeChange CodeChangeHook
OnStorageChange StorageChangeHook
OnLog LogHook
- // State reads
- OnBalanceRead BalanceReadHook
- OnNonceRead NonceReadHook
- OnCodeRead CodeReadHook
- OnCodeSizeRead CodeSizeReadHook
- OnCodeHashRead CodeHashReadHook
- OnStorageRead StorageReadHook
- // Block hash read
- OnBlockHashRead BlockHashReadHook
}
-// Copy creates a new Hooks instance with all implemented hooks copied from the original.
-func (h *Hooks) Copy() *Hooks {
- copied := &Hooks{}
+// CopyHooks creates a new instance of U with all implemented hooks copied from the original T,
+// except for those specified in the exclude parameter.
+func CopyHooks[T, U any](h *T, exclude ...string) *U {
+ copied := new(U)
srcValue := reflect.ValueOf(h).Elem()
dstValue := reflect.ValueOf(copied).Elem()
+ excludeMap := make(map[string]bool)
+ for _, field := range exclude {
+ excludeMap[field] = true
+ }
+
for i := 0; i < srcValue.NumField(); i++ {
- field := srcValue.Field(i)
- if !field.IsNil() {
- dstValue.Field(i).Set(field)
+ srcField := srcValue.Type().Field(i)
+ srcFieldValue := srcValue.Field(i)
+
+ if srcFieldValue.IsNil() || excludeMap[srcField.Name] {
+ continue
+ }
+
+ dstField := dstValue.FieldByName(srcField.Name)
+ if dstField.IsValid() && dstField.CanSet() {
+ dstField.Set(srcFieldValue)
}
}
+
return copied
}
+// Copy creates a new Hooks instance with all implemented hooks copied from the original.
+func (h *Hooks) Copy() *Hooks {
+ return CopyHooks[Hooks, Hooks](h)
+}
+
// BalanceChangeReason is used to indicate the reason for a balance change, useful
// for tracing and reporting.
type BalanceChangeReason byte
diff --git a/core/tracing/v2/hooks.go b/core/tracing/v2/hooks.go
new file mode 100644
index 000000000000..4f2a7db03e4e
--- /dev/null
+++ b/core/tracing/v2/hooks.go
@@ -0,0 +1,262 @@
+package v2
+
+import (
+ "encoding/json"
+ "errors"
+ "math/big"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/tracing"
+)
+
+// Type aliases so tracers don't have to import both versions.
+type (
+ // VMContext provides the context for the EVM execution.
+ VMContext = tracing.VMContext
+
+ // OpContext provides the context at which the opcode is being
+ // executed in, including the memory, stack and various contract-level information.
+ OpContext = tracing.OpContext
+
+ // BlockEvent is emitted upon tracing an incoming block.
+ // It contains the block as well as consensus related information.
+ BlockEvent = tracing.BlockEvent
+
+ // StateDB gives tracers access to the whole state.
+ StateDB = tracing.StateDB
+)
+
+type (
+ // NewLiveTracer is the v2 constructor for a live tracer.
+ NewLiveTracer = func(config json.RawMessage) (*Hooks, error)
+
+ // BalanceChangeHook is called when the balance of an account changes.
+ BalanceChangeHook = func(addr common.Address, prev, new *big.Int, reason BalanceChangeReason)
+
+ // GasChangeHook is invoked when the gas changes.
+ GasChangeHook = func(old, new uint64, reason GasChangeReason)
+
+ // OnSystemCallStartHook is called when a system call is about to be executed. Refer
+ // to docs for OnSystemCallStartHook.
+ OnSystemCallStartHook = func(vm *tracing.VMContext)
+
+ // BalanceReadHook is called when EVM reads the balance of an account.
+ BalanceReadHook = func(addr common.Address, bal *big.Int)
+
+ // NonceReadHook is called when EVM reads the nonce of an account.
+ NonceReadHook = func(addr common.Address, nonce uint64)
+
+ // CodeReadHook is called when EVM reads the code of an account.
+ CodeReadHook = func(addr common.Address, code []byte)
+
+ // CodeSizeReadHook is called when EVM reads the code size of an account.
+ CodeSizeReadHook = func(addr common.Address, size int)
+
+ // CodeHashReadHook is called when EVM reads the code hash of an account.
+ CodeHashReadHook = func(addr common.Address, hash common.Hash)
+
+ // StorageReadHook is called when EVM reads a storage slot of an account.
+ StorageReadHook = func(addr common.Address, slot, value common.Hash)
+
+ // BlockHashReadHook is called when EVM reads the blockhash of a block.
+ BlockHashReadHook = func(blockNumber uint64, hash common.Hash)
+)
+
+// Hooks is a collection of hooks in EVM execution, blockchain, and state logic.
+// It is used by live tracers which run parallel to the node's execution, as well
+// as the debug tracing API.
+type Hooks struct {
+ // V1 hooks minus OnBlockchainInit which is removed.
+ // VM events
+ OnTxStart tracing.TxStartHook
+ OnTxEnd tracing.TxEndHook
+ OnEnter tracing.EnterHook
+ OnExit tracing.ExitHook
+ OnOpcode tracing.OpcodeHook
+ OnFault tracing.FaultHook
+ // Chain events
+ OnBlockchainInit tracing.BlockchainInitHook
+ OnClose tracing.CloseHook
+ OnBlockStart tracing.BlockStartHook
+ OnBlockEnd tracing.BlockEndHook
+ OnSkippedBlock tracing.SkippedBlockHook
+ OnGenesisBlock tracing.GenesisBlockHook
+ OnSystemCallEnd tracing.OnSystemCallEndHook
+ // State events
+ OnNonceChange tracing.NonceChangeHook
+ OnCodeChange tracing.CodeChangeHook
+ OnStorageChange tracing.StorageChangeHook
+ OnLog tracing.LogHook
+
+ OnBalanceChange BalanceChangeHook
+ OnGasChange GasChangeHook
+
+ // V2 changes
+ OnSystemCallStart OnSystemCallStartHook
+ // State reads
+ OnBalanceRead BalanceReadHook
+ OnNonceRead NonceReadHook
+ OnCodeRead CodeReadHook
+ OnCodeSizeRead CodeSizeReadHook
+ OnCodeHashRead CodeHashReadHook
+ OnStorageRead StorageReadHook
+ // Block hash read
+ OnBlockHashRead BlockHashReadHook
+}
+
+// Copy creates a new Hooks instance with all implemented hooks copied from the original.
+func (h *Hooks) Copy() *Hooks {
+ return tracing.CopyHooks[Hooks, Hooks](h)
+}
+
+// ToV2 converts a Hooks instance to a Hooks instance.
+//
+// Note that OnSystemCallStart hook is excluded from the copy as it is
+// changed in a backwards-incompatible way.
+func ToV2(h *tracing.Hooks) *Hooks {
+ return tracing.CopyHooks[tracing.Hooks, Hooks](h, "OnSystemCallStart", "OnBalanceChange", "OnGasChange")
+}
+
+// LiveDirectory is the collection of tracers which can be used
+// during normal block import operations.
+var LiveDirectory = liveDirectory{elems: make(map[string]NewLiveTracer)}
+
+type liveDirectory struct {
+ elems map[string]NewLiveTracer
+}
+
+// RegisterV2 registers a tracer constructor by name.
+func (d *liveDirectory) Register(name string, f NewLiveTracer) {
+ d.elems[name] = f
+}
+
+// New instantiates a tracer by name.
+func (d *liveDirectory) New(name string, config json.RawMessage) (*Hooks, error) {
+ if f, ok := d.elems[name]; ok {
+ return f(config)
+ }
+ return nil, errors.New("not found")
+}
+
+// BalanceChangeReason is used to indicate the reason for a balance change, useful
+// for tracing and reporting.
+type BalanceChangeReason byte
+
+//go:generate go run golang.org/x/tools/cmd/stringer -type=BalanceChangeReason -output gen_balance_change_reason_stringer.go
+
+const (
+ BalanceChangeUnspecified BalanceChangeReason = 0
+
+ // Issuance
+ // BalanceIncreaseRewardMineUncle is a reward for mining an uncle block.
+ BalanceIncreaseRewardMineUncle BalanceChangeReason = 1
+ // BalanceIncreaseRewardMineBlock is a reward for mining a block.
+ BalanceIncreaseRewardMineBlock BalanceChangeReason = 2
+ // BalanceIncreaseWithdrawal is ether withdrawn from the beacon chain.
+ BalanceIncreaseWithdrawal BalanceChangeReason = 3
+ // BalanceIncreaseGenesisBalance is ether allocated at the genesis block.
+ BalanceIncreaseGenesisBalance BalanceChangeReason = 4
+
+ // Transaction fees
+ // BalanceIncreaseRewardTransactionFee is the transaction tip increasing block builder's balance.
+ BalanceIncreaseRewardTransactionFee BalanceChangeReason = 5
+ // BalanceDecreaseGasBuy is spent to purchase gas for execution a transaction.
+ // Part of this gas will be burnt as per EIP-1559 rules.
+ BalanceDecreaseGasBuy BalanceChangeReason = 6
+ // BalanceIncreaseGasReturn is ether returned for unused gas at the end of execution.
+ BalanceIncreaseGasReturn BalanceChangeReason = 7
+
+ // DAO fork
+ // BalanceIncreaseDaoContract is ether sent to the DAO refund contract.
+ BalanceIncreaseDaoContract BalanceChangeReason = 8
+ // BalanceDecreaseDaoAccount is ether taken from a DAO account to be moved to the refund contract.
+ BalanceDecreaseDaoAccount BalanceChangeReason = 9
+
+ // BalanceChangeTransfer is ether transferred via a call.
+ // it is a decrease for the sender and an increase for the recipient.
+ BalanceChangeTransfer BalanceChangeReason = 10
+ // BalanceChangeTouchAccount is a transfer of zero value. It is only there to
+ // touch-create an account.
+ BalanceChangeTouchAccount BalanceChangeReason = 11
+
+ // BalanceIncreaseSelfdestruct is added to the recipient as indicated by a selfdestructing account.
+ BalanceIncreaseSelfdestruct BalanceChangeReason = 12
+ // BalanceDecreaseSelfdestruct is deducted from a contract due to self-destruct.
+ BalanceDecreaseSelfdestruct BalanceChangeReason = 13
+ // BalanceDecreaseSelfdestructBurn is ether that is sent to an already self-destructed
+ // account within the same tx (captured at end of tx).
+ // Note it doesn't account for a self-destruct which appoints itself as recipient.
+ BalanceDecreaseSelfdestructBurn BalanceChangeReason = 14
+
+ // BalanceChangeRevert is emitted when the balance is reverted back to a previous value due to call failure.
+ // It is only emitted when the tracer has opted in to use the journaling wrapper.
+ BalanceChangeRevert BalanceChangeReason = 15
+)
+
+// GasChangeReason is used to indicate the reason for a gas change, useful
+// for tracing and reporting.
+//
+// There is essentially two types of gas changes, those that can be emitted once per transaction
+// and those that can be emitted on a call basis, so possibly multiple times per transaction.
+//
+// They can be recognized easily by their name, those that start with `GasChangeTx` are emitted
+// once per transaction, while those that start with `GasChangeCall` are emitted on a call basis.
+type GasChangeReason byte
+
+const (
+ GasChangeUnspecified GasChangeReason = 0
+
+ // GasChangeTxInitialBalance is the initial balance for the call which will be equal to the gasLimit of the call. There is only
+ // one such gas change per transaction.
+ GasChangeTxInitialBalance GasChangeReason = 1
+ // GasChangeTxIntrinsicGas is the amount of gas that will be charged for the intrinsic cost of the transaction, there is
+ // always exactly one of those per transaction.
+ GasChangeTxIntrinsicGas GasChangeReason = 2
+ // GasChangeTxRefunds is the sum of all refunds which happened during the tx execution (e.g. storage slot being cleared)
+ // this generates an increase in gas. There is at most one of such gas change per transaction.
+ GasChangeTxRefunds GasChangeReason = 3
+ // GasChangeTxLeftOverReturned is the amount of gas left over at the end of transaction's execution that will be returned
+ // to the chain. This change will always be a negative change as we "drain" left over gas towards 0. If there was no gas
+ // left at the end of execution, no such even will be emitted. The returned gas's value in Wei is returned to caller.
+ // There is at most one of such gas change per transaction.
+ GasChangeTxLeftOverReturned GasChangeReason = 4
+
+ // GasChangeCallInitialBalance is the initial balance for the call which will be equal to the gasLimit of the call. There is only
+ // one such gas change per call.
+ GasChangeCallInitialBalance GasChangeReason = 5
+ // GasChangeCallLeftOverReturned is the amount of gas left over that will be returned to the caller, this change will always
+ // be a negative change as we "drain" left over gas towards 0. If there was no gas left at the end of execution, no such even
+ // will be emitted.
+ GasChangeCallLeftOverReturned GasChangeReason = 6
+ // GasChangeCallLeftOverRefunded is the amount of gas that will be refunded to the call after the child call execution it
+ // executed completed. This value is always positive as we are giving gas back to the you, the left over gas of the child.
+ // If there was no gas left to be refunded, no such even will be emitted.
+ GasChangeCallLeftOverRefunded GasChangeReason = 7
+ // GasChangeCallContractCreation is the amount of gas that will be burned for a CREATE.
+ GasChangeCallContractCreation GasChangeReason = 8
+ // GasChangeContractCreation is the amount of gas that will be burned for a CREATE2.
+ GasChangeCallContractCreation2 GasChangeReason = 9
+ // GasChangeCallCodeStorage is the amount of gas that will be charged for code storage.
+ GasChangeCallCodeStorage GasChangeReason = 10
+ // GasChangeCallOpCode is the amount of gas that will be charged for an opcode executed by the EVM, exact opcode that was
+ // performed can be check by `OnOpcode` handling.
+ GasChangeCallOpCode GasChangeReason = 11
+ // GasChangeCallPrecompiledContract is the amount of gas that will be charged for a precompiled contract execution.
+ GasChangeCallPrecompiledContract GasChangeReason = 12
+ // GasChangeCallStorageColdAccess is the amount of gas that will be charged for a cold storage access as controlled by EIP2929 rules.
+ GasChangeCallStorageColdAccess GasChangeReason = 13
+ // GasChangeCallFailedExecution is the burning of the remaining gas when the execution failed without a revert.
+ GasChangeCallFailedExecution GasChangeReason = 14
+ // GasChangeWitnessContractInit flags the event of adding to the witness during the contract creation initialization step.
+ GasChangeWitnessContractInit GasChangeReason = 15
+ // GasChangeWitnessContractCreation flags the event of adding to the witness during the contract creation finalization step.
+ GasChangeWitnessContractCreation GasChangeReason = 16
+ // GasChangeWitnessCodeChunk flags the event of adding one or more contract code chunks to the witness.
+ GasChangeWitnessCodeChunk GasChangeReason = 17
+ // GasChangeWitnessContractCollisionCheck flags the event of adding to the witness when checking for contract address collision.
+ GasChangeWitnessContractCollisionCheck GasChangeReason = 18
+
+ // GasChangeIgnored is a special value that can be used to indicate that the gas change should be ignored as
+ // it will be "manually" tracked by a direct emit of the gas change event.
+ GasChangeIgnored GasChangeReason = 0xFF
+)
diff --git a/core/tracing/journal.go b/core/tracing/v2/journal.go
similarity index 99%
rename from core/tracing/journal.go
rename to core/tracing/v2/journal.go
index 88d70362977f..10584c1ba2d6 100644
--- a/core/tracing/journal.go
+++ b/core/tracing/v2/journal.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tracing
+package v2
import (
"fmt"
diff --git a/core/tracing/journal_test.go b/core/tracing/v2/journal_test.go
similarity index 99%
rename from core/tracing/journal_test.go
rename to core/tracing/v2/journal_test.go
index 129209b2a3ae..01d8e6d3dd7b 100644
--- a/core/tracing/journal_test.go
+++ b/core/tracing/v2/journal_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tracing
+package v2
import (
"errors"
diff --git a/core/vm/contract.go b/core/vm/contract.go
index cfda75b27e11..f6ef95f1d3eb 100644
--- a/core/vm/contract.go
+++ b/core/vm/contract.go
@@ -18,7 +18,7 @@ package vm
import (
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/holiman/uint256"
)
diff --git a/core/vm/contracts.go b/core/vm/contracts.go
index f54d5ab86e66..623700c3a5d7 100644
--- a/core/vm/contracts.go
+++ b/core/vm/contracts.go
@@ -30,7 +30,7 @@ import (
"github.com/consensys/gnark-crypto/ecc/bls12-381/fp"
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/blake2b"
"github.com/ethereum/go-ethereum/crypto/bn256"
diff --git a/core/vm/eips.go b/core/vm/eips.go
index 71d51f81efe0..e28cca7b0890 100644
--- a/core/vm/eips.go
+++ b/core/vm/eips.go
@@ -22,7 +22,7 @@ import (
"sort"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"
)
diff --git a/core/vm/evm.go b/core/vm/evm.go
index 26ff495579f1..4eebd67a1b89 100644
--- a/core/vm/evm.go
+++ b/core/vm/evm.go
@@ -23,7 +23,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index 540f0e508dae..b11f5228f065 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -20,7 +20,7 @@ import (
"math"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
diff --git a/core/vm/interface.go b/core/vm/interface.go
index 9229f4d2cd95..fd3919b0c079 100644
--- a/core/vm/interface.go
+++ b/core/vm/interface.go
@@ -21,7 +21,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/stateless"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie/utils"
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index 793f398367a7..7f62e1f3d745 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -21,7 +21,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/holiman/uint256"
diff --git a/core/vm/operations_acl.go b/core/vm/operations_acl.go
index b993b651ffbb..12885e88f448 100644
--- a/core/vm/operations_acl.go
+++ b/core/vm/operations_acl.go
@@ -21,7 +21,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/params"
)
diff --git a/eth/backend.go b/eth/backend.go
index ccfe650f41c6..9e4f132225b5 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -32,6 +32,7 @@ import (
"github.com/ethereum/go-ethereum/core/bloombits"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state/pruner"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/txpool/blobpool"
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
@@ -42,7 +43,6 @@ import (
"github.com/ethereum/go-ethereum/eth/gasprice"
"github.com/ethereum/go-ethereum/eth/protocols/eth"
"github.com/ethereum/go-ethereum/eth/protocols/snap"
- "github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/ethapi"
@@ -203,7 +203,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.VMTraceJsonConfig != "" {
traceConfig = json.RawMessage(config.VMTraceJsonConfig)
}
- t, err := tracers.LiveDirectory.New(config.VMTrace, traceConfig)
+ t, err := tracing.LiveDirectory.New(config.VMTrace, traceConfig)
if err != nil {
return nil, fmt.Errorf("failed to create tracer %s: %v", config.VMTrace, err)
}
diff --git a/eth/tracers/dir.go b/eth/tracers/dir.go
index 55bcb44d23ad..342d449e73fc 100644
--- a/eth/tracers/dir.go
+++ b/eth/tracers/dir.go
@@ -21,7 +21,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/params"
)
diff --git a/eth/tracers/js/goja.go b/eth/tracers/js/goja.go
index 35abd00017b7..e74b0c71b50a 100644
--- a/eth/tracers/js/goja.go
+++ b/eth/tracers/js/goja.go
@@ -25,7 +25,7 @@ import (
"sync"
"github.com/dop251/goja"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/eth/tracers/internal"
diff --git a/eth/tracers/live.go b/eth/tracers/live.go
index 8b222d2e6cdf..b796c2927a70 100644
--- a/eth/tracers/live.go
+++ b/eth/tracers/live.go
@@ -18,33 +18,42 @@ package tracers
import (
"encoding/json"
- "errors"
+ "math/big"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/tracing"
+ tracingV2 "github.com/ethereum/go-ethereum/core/tracing/v2"
)
-type ctorFunc func(config json.RawMessage) (*tracing.Hooks, error)
-
// LiveDirectory is the collection of tracers which can be used
// during normal block import operations.
-var LiveDirectory = liveDirectory{elems: make(map[string]ctorFunc)}
+//
+// Deprecated: It is left for backwards-compatibility with v1 tracers.
+var LiveDirectory = liveDirectory{}
-type liveDirectory struct {
- elems map[string]ctorFunc
-}
+type liveDirectory struct{}
// Register registers a tracer constructor by name.
-func (d *liveDirectory) Register(name string, f ctorFunc) {
- d.elems[name] = f
+func (d *liveDirectory) Register(name string, f tracing.LiveConstructor) {
+ tracingV2.LiveDirectory.Register(name, wrapV1(f))
}
-// New instantiates a tracer by name.
-func (d *liveDirectory) New(name string, config json.RawMessage) (*tracing.Hooks, error) {
- if len(config) == 0 {
- config = json.RawMessage("{}")
- }
- if f, ok := d.elems[name]; ok {
- return f(config)
+func wrapV1(ctor tracing.LiveConstructor) tracingV2.NewLiveTracer {
+ return func(config json.RawMessage) (*tracingV2.Hooks, error) {
+ hooks, err := ctor(config)
+ if err != nil {
+ return nil, err
+ }
+ v2 := tracingV2.ToV2(hooks)
+ v2.OnSystemCallStart = func(ctx *tracingV2.VMContext) {
+ hooks.OnSystemCallStart()
+ }
+ v2.OnBalanceChange = func(addr common.Address, prev, new *big.Int, reason tracingV2.BalanceChangeReason) {
+ hooks.OnBalanceChange(addr, prev, new, tracing.BalanceChangeReason(reason))
+ }
+ v2.OnGasChange = func(prev, new uint64, reason tracingV2.GasChangeReason) {
+ hooks.OnGasChange(prev, new, tracing.GasChangeReason(reason))
+ }
+ return v2, nil
}
- return nil, errors.New("not found")
}
diff --git a/eth/tracers/live/noop.go b/eth/tracers/live/noop.go
index a430b8629617..c08f3758201d 100644
--- a/eth/tracers/live/noop.go
+++ b/eth/tracers/live/noop.go
@@ -57,13 +57,6 @@ func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) {
OnCodeChange: t.OnCodeChange,
OnStorageChange: t.OnStorageChange,
OnLog: t.OnLog,
- OnBalanceRead: t.OnBalanceRead,
- OnNonceRead: t.OnNonceRead,
- OnCodeRead: t.OnCodeRead,
- OnCodeSizeRead: t.OnCodeSizeRead,
- OnCodeHashRead: t.OnCodeHashRead,
- OnStorageRead: t.OnStorageRead,
- OnBlockHashRead: t.OnBlockHashRead,
}, nil
}
@@ -99,6 +92,10 @@ func (t *noop) OnBlockchainInit(chainConfig *params.ChainConfig) {
func (t *noop) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) {
}
+func (t *noop) OnSystemCallStart() {}
+
+func (t *noop) OnSystemCallEnd() {}
+
func (t *noop) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
}
@@ -115,19 +112,5 @@ func (t *noop) OnLog(l *types.Log) {
}
-func (t *noop) OnBalanceRead(addr common.Address, bal *big.Int) {}
-
-func (t *noop) OnNonceRead(addr common.Address, nonce uint64) {}
-
-func (t *noop) OnCodeRead(addr common.Address, code []byte) {}
-
-func (t *noop) OnCodeSizeRead(addr common.Address, size int) {}
-
-func (t *noop) OnCodeHashRead(addr common.Address, hash common.Hash) {}
-
-func (t *noop) OnStorageRead(addr common.Address, slot, val common.Hash) {}
-
-func (t *noop) OnBlockHashRead(number uint64, hash common.Hash) {}
-
func (t *noop) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {
}
diff --git a/eth/tracers/live/noopv2.go b/eth/tracers/live/noopv2.go
new file mode 100644
index 000000000000..37300cc9c8a8
--- /dev/null
+++ b/eth/tracers/live/noopv2.go
@@ -0,0 +1,139 @@
+// Copyright 2024 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 live
+
+import (
+ "encoding/json"
+ "math/big"
+
+ "github.com/ethereum/go-ethereum/common"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/params"
+)
+
+func init() {
+ tracing.LiveDirectory.Register("noopv2", newNoopV2Tracer)
+}
+
+// noopV2 is a no-op live tracer. It's there to
+// catch changes in the tracing interface, as well as
+// for testing live tracing performance. Can be removed
+// as soon as we have a real live tracer.
+type noopV2 struct{}
+
+func newNoopV2Tracer(_ json.RawMessage) (*tracing.Hooks, error) {
+ t := &noopV2{}
+ return &tracing.Hooks{
+ OnTxStart: t.OnTxStart,
+ OnTxEnd: t.OnTxEnd,
+ OnEnter: t.OnEnter,
+ OnExit: t.OnExit,
+ OnOpcode: t.OnOpcode,
+ OnFault: t.OnFault,
+ OnGasChange: t.OnGasChange,
+ OnBlockchainInit: t.OnBlockchainInit,
+ OnBlockStart: t.OnBlockStart,
+ OnBlockEnd: t.OnBlockEnd,
+ OnSkippedBlock: t.OnSkippedBlock,
+ OnGenesisBlock: t.OnGenesisBlock,
+ OnSystemCallStart: t.OnSystemCallStart,
+ OnSystemCallEnd: t.OnSystemCallEnd,
+ OnBalanceChange: t.OnBalanceChange,
+ OnNonceChange: t.OnNonceChange,
+ OnCodeChange: t.OnCodeChange,
+ OnStorageChange: t.OnStorageChange,
+ OnLog: t.OnLog,
+ OnBalanceRead: t.OnBalanceRead,
+ OnNonceRead: t.OnNonceRead,
+ OnCodeRead: t.OnCodeRead,
+ OnCodeSizeRead: t.OnCodeSizeRead,
+ OnCodeHashRead: t.OnCodeHashRead,
+ OnStorageRead: t.OnStorageRead,
+ OnBlockHashRead: t.OnBlockHashRead,
+ }, nil
+}
+
+func (t *noopV2) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
+}
+
+func (t *noopV2) OnFault(pc uint64, op byte, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
+}
+
+func (t *noopV2) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
+}
+
+func (t *noopV2) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
+}
+
+func (t *noopV2) OnTxStart(vm *tracing.VMContext, tx *types.Transaction, from common.Address) {
+}
+
+func (t *noopV2) OnTxEnd(receipt *types.Receipt, err error) {
+}
+
+func (t *noopV2) OnBlockStart(ev tracing.BlockEvent) {
+}
+
+func (t *noopV2) OnBlockEnd(err error) {
+}
+
+func (t *noopV2) OnSkippedBlock(ev tracing.BlockEvent) {}
+
+func (t *noopV2) OnBlockchainInit(chainConfig *params.ChainConfig) {
+}
+
+func (t *noopV2) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) {
+}
+
+func (t *noopV2) OnSystemCallStart(ctx *tracing.VMContext) {}
+
+func (t *noopV2) OnSystemCallEnd() {}
+
+func (t *noopV2) OnReorg(reverted []*types.Block) {}
+
+func (t *noopV2) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
+}
+
+func (t *noopV2) OnNonceChange(a common.Address, prev, new uint64) {
+}
+
+func (t *noopV2) OnCodeChange(a common.Address, prevCodeHash common.Hash, prev []byte, codeHash common.Hash, code []byte) {
+}
+
+func (t *noopV2) OnStorageChange(a common.Address, k, prev, new common.Hash) {
+}
+
+func (t *noopV2) OnLog(l *types.Log) {
+
+}
+
+func (t *noopV2) OnBalanceRead(addr common.Address, bal *big.Int) {}
+
+func (t *noopV2) OnNonceRead(addr common.Address, nonce uint64) {}
+
+func (t *noopV2) OnCodeRead(addr common.Address, code []byte) {}
+
+func (t *noopV2) OnCodeSizeRead(addr common.Address, size int) {}
+
+func (t *noopV2) OnCodeHashRead(addr common.Address, hash common.Hash) {}
+
+func (t *noopV2) OnStorageRead(addr common.Address, slot, val common.Hash) {}
+
+func (t *noopV2) OnBlockHashRead(number uint64, hash common.Hash) {}
+
+func (t *noopV2) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {}
diff --git a/eth/tracers/live/supply.go b/eth/tracers/live/supply.go
index fa4e5b190431..5f7853f5c6d9 100644
--- a/eth/tracers/live/supply.go
+++ b/eth/tracers/live/supply.go
@@ -26,16 +26,15 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/natefinch/lumberjack.v2"
)
func init() {
- tracers.LiveDirectory.Register("supply", newSupplyTracer)
+ tracing.LiveDirectory.Register("supply", newSupplyTracer)
}
type supplyInfoIssuance struct {
diff --git a/eth/tracers/logger/access_list_tracer.go b/eth/tracers/logger/access_list_tracer.go
index e8231461b0cf..55cdc5ee9ced 100644
--- a/eth/tracers/logger/access_list_tracer.go
+++ b/eth/tracers/logger/access_list_tracer.go
@@ -20,7 +20,7 @@ import (
"maps"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
)
diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go
index f918ce154b50..0c4e025b9110 100644
--- a/eth/tracers/logger/logger.go
+++ b/eth/tracers/logger/logger.go
@@ -28,7 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
diff --git a/eth/tracers/logger/logger_json.go b/eth/tracers/logger/logger_json.go
index 797f7ac65821..4a1f3b37bdf4 100644
--- a/eth/tracers/logger/logger_json.go
+++ b/eth/tracers/logger/logger_json.go
@@ -24,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
)
@@ -127,7 +127,7 @@ func (l *jsonLogger) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracin
l.encoder.Encode(log)
}
-func (l *jsonLogger) onSystemCallStart() {
+func (l *jsonLogger) onSystemCallStart(ctx *tracing.VMContext) {
// Process no events while in system call.
hooks := *l.hooks
*l.hooks = tracing.Hooks{
diff --git a/eth/tracers/native/4byte.go b/eth/tracers/native/4byte.go
index cec45a1e7a58..3e65c82ffc19 100644
--- a/eth/tracers/native/4byte.go
+++ b/eth/tracers/native/4byte.go
@@ -23,7 +23,7 @@ import (
"sync/atomic"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/tracers"
diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go
index c2247d1ce491..cc93e79904d3 100644
--- a/eth/tracers/native/call.go
+++ b/eth/tracers/native/call.go
@@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/tracers"
diff --git a/eth/tracers/native/call_flat.go b/eth/tracers/native/call_flat.go
index b7cc60b096bd..4be4ba49df05 100644
--- a/eth/tracers/native/call_flat.go
+++ b/eth/tracers/native/call_flat.go
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/tracers"
diff --git a/eth/tracers/native/mux.go b/eth/tracers/native/mux.go
index 77ab254568e6..dd76c274f863 100644
--- a/eth/tracers/native/mux.go
+++ b/eth/tracers/native/mux.go
@@ -21,7 +21,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/params"
diff --git a/eth/tracers/native/noop.go b/eth/tracers/native/noop.go
index ac174cc25e7f..5770f19fba53 100644
--- a/eth/tracers/native/noop.go
+++ b/eth/tracers/native/noop.go
@@ -21,7 +21,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/params"
diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go
index 978ba0670c92..899d5cda8552 100644
--- a/eth/tracers/native/prestate.go
+++ b/eth/tracers/native/prestate.go
@@ -24,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 10d79c85ae06..8be8b110a3ef 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -38,7 +38,7 @@ import (
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/internal/ethapi/logtracer.go b/internal/ethapi/logtracer.go
index 456aa937367f..565b6b0b59bf 100644
--- a/internal/ethapi/logtracer.go
+++ b/internal/ethapi/logtracer.go
@@ -20,7 +20,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
)
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index 77bf945e40e7..4c53bb84b9ec 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -35,7 +35,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/tracing"
+ tracing "github.com/ethereum/go-ethereum/core/tracing/v2"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"