Commit graph

53 commits

Author SHA1 Message Date
Daniel Liu
3fd03e0814
core, core/types: rename AuthList to SetCodeAuthorizations #30935 (#1884) 2025-12-23 15:40:53 +05:30
Daniel Liu
510be504ef
eth/tracers: prestate lookup EIP7702 delegation account #32080 (#1828)
Implement https://github.com/ethereum/go-ethereum/issues/32078
Parse and lookup the delegation account if EIP7702 is enabled.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
2025-12-20 11:12:33 +05:30
Daniel Liu
142b1155d8
all: implement eip-7702 set code tx #30078 (#1759) 2025-12-19 14:09:45 +04:00
Daniel Liu
7f89733a09
eth/tracers, core: handle non-EVM tx tracing, fix #1863 (#1865)
* Detect non-EVM special transactions and construct a synthetic top level callFrame in OnTxStart.
* GetResult returns the virtual frame for non-EVM txs to preserve debug API compatibility.
* Add bounds checks in OnTxEnd and OnLog to avoid panics when callstack is empty.
* Add unit tests to verify the fix
2025-12-15 12:33:32 +04:00
Daniel Liu
ff779bae72
eth/tracers: fill the creationMethod in flatCall #30539 (#1501)
`flatCallTracer` will now specify the type of a create in the action
via the `creationMethod` field.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-21 18:52:27 +08:00
Daniel Liu
af69d382ff
eth/tracers: various fixes #30540 (#1491)
Breaking changes:

- The ChainConfig was exposed to tracers via VMContext passed in
`OnTxStart`. This is unnecessary specially looking through the lens of
live tracers as chain config remains the same throughout the lifetime of
the program. It was there so that native API-invoked tracers could
access it. So instead we moved it to the constructor of API tracers.

Non-breaking:

- Change the default config of the tracers to be `{}` instead of nil.
This way an extra nil check can be avoided.

Refactoring:

- Rename `supply` struct to `supplyTracer`.
- Un-export some hook definitions.

Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
2025-09-17 09:04:38 +08:00
wit liu
99e2885b03
all: fix misspell (#1510)
Co-authored-by: wit <wit765765346@gmail>
2025-09-17 08:27:52 +08:00
Daniel Liu
20e3de2c4b
eth/tracers: add disableCode/Storage options for prestateTracer #30648 (#1498)
When using the prestateTracer, in some cases users are only concerned
with balances or nonce information, and are not interested in the lengthy
contract code or storage data.

Therefore, this PR introduces two new configuration options in the
`prestateTracerConfig` structure:
- `disableCode`
- `disableStorage`

These options allow users to control whether the tracer returns contract
code and storage data during execution tracing. By setting these
options, users can more flexibly customize their needs and focus on
obtaining information that is more critical and relevant to their
specific use cases.

These options work with the default mode as well as `diffMode: true`.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
2025-09-17 08:22:13 +08:00
Daniel Liu
ea187b53bd
eth/tracers: flatCallTracer error compatible with parity #30497 (#1499)
Compatible error message in the flat call tracer with parity-style endpoints.

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
2025-09-17 08:18:09 +08:00
Daniel Liu
f5e76ea6df
eth/tracers: avoid panic in state test runner #30332 (#1485)
Make tracers more robust by handling `nil` receipt as input.
Also pass in a receipt with gas used in the state test runner.
Closes https://github.com/ethereum/go-ethereum/issues/30117.

---------

Co-authored-by: Martin HS <martin@swende.se>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-13 10:50:10 +08:00
Daniel Liu
a00d95bf1a
eth/tracers/native: remove unnecessary check #30071 (#1477) 2025-09-13 10:40:18 +08:00
Daniel Liu
db1082355d
eth/tracers: clear error for non-reverting pre-homestead fail #29824 (#1471)
Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
2025-09-13 10:29:34 +08:00
Daniel Liu
23e2e20da9
eth/tracers/native: fix flatCallTracer Stop() bug #29623 (#1465)
Co-authored-by: Dragan Milic <dragan@netice9.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-13 10:26:00 +08:00
Daniel Liu
b896f4dce1
eth/tracers: use slices.Contains #29461 (#1463)
Co-authored-by: Aaron Chen <aaronchen.lisp@gmail.com>
2025-09-13 10:18:06 +08:00
Daniel Liu
ad9003c41e
eth/tracers: live chain tracing with hooks #29189 (#1352)
Here we add a Go API for running tracing plugins within the main block import process.

As an advanced user of geth, you can now create a Go file in eth/tracers/live/, and within
that file register your custom tracer implementation. Then recompile geth and select your tracer
on the command line. Hooks defined in the tracer will run whenever a block is processed.

The hook system is defined in package core/tracing. It uses a struct with callbacks, instead of
requiring an interface, for several reasons:

- We plan to keep this API stable long-term. The core/tracing hook API does not depend on
  on deep geth internals.
- There are a lot of hooks, and tracers will only need some of them. Using a struct allows you
   to implement only the hooks you want to actually use.

All existing tracers in eth/tracers/native have been rewritten to use the new hook system.

This change breaks compatibility with the vm.EVMLogger interface that we used to have.
If you are a user of vm.EVMLogger, please migrate to core/tracing, and sorry for breaking
your stuff. But we just couldn't have both the old and new tracing APIs coexist in the EVM.

---------

Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
Co-authored-by: Matthieu Vachon <matthieu.o.vachon@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
Co-authored-by: Martin HS <martin@swende.se>
2025-09-09 17:30:56 +08:00
Daniel Liu
bb7da37fb9
eth/tracers: fix prestateTracer pre nonce on contract creation #29099 (#1349)
The prestateTracer was reporting an inaccurate nonce for the contract being created in
post EIP-158 transactions. Correct nonce is 0, due to the issue nonce was being reported as 1.

Co-authored-by: Andrei Silviu Dragnea <andreidragnea.dev@gmail.com>
2025-09-09 16:38:20 +08:00
Daniel Liu
2ba36f3f0d
eth/tracers: fix callTracer logs on onlyTopCall == true #29068 (#1348)
Co-authored-by: Andrei Silviu Dragnea <andreisilviudragnea@gmail.com>
2025-09-09 16:32:17 +08:00
Daniel Liu
ed46409261
eth/tracers: add position field for callTracer logs #28389 (#1342)
Currently, one can use the "withLogs" parameter to include logs in the
callTracer results, which allows the user to see at which trace level
was each log emitted.
This commit adds a position field to the logs which determine
the exact ordering of a call's logs and its subcalls. This would
be useful e.g. for explorers wishing to display the flow of execution.

Co-authored-by: Alvaro Sevilla <alvarosevilla95@gmail.com>
Co-authored-by: jsvisa <delweng@gmail.com>
2025-09-09 15:46:12 +08:00
Daniel Liu
e4d4fb7d9c
eth/tracers/native: replace instances of suicide with selfdestruct #27716 (#1340) 2025-09-09 15:33:16 +08:00
Daniel Liu
b0e3d4118c
eth/tracers/native: panic on memory read in prestateTracer #27691 (#1339)
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 15:26:12 +08:00
Daniel Liu
548adb56e6
eth/tracers: fix flatCallTracer crasher #27304 (#1334)
FlatCallTracer had a crasher when it was passed `onlyTopCall: true` as config.
This PR ignores config fields inherited from the normal call tracer.

Co-authored-by: minh-bq <97180373+minh-bq@users.noreply.github.com>
2025-09-09 14:51:46 +08:00
Daniel Liu
712ca01d65
eth/tracers: use atomic type #27031 (#1326)
Use the new atomic types in package eth/tracers

---------

Co-authored-by: s7v7nislands <s7v7nislands@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 12:26:48 +08:00
Daniel Liu
9fd13e5e4a
eth/tracers: report correct gasLimit in call tracers #27029 (#1325)
This includes a semantic change to the `callTracer` as well as `flatCallTracer`.
The value of field `gas` in the **first** call frame will change as follows:

- It previously contained gas available after initial deductions (i.e. tx costs)
- It will now contain the full tx gasLimit value

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
2025-09-09 11:56:50 +08:00
Daniel Liu
98e9dc6c95
eth/tracers/native: prevent panic for LOG edge-cases #26848 (#1324)
This PR fixes OOM panic in the callTracer as well as panicing on
opcode validation errors (e.g. stack underflow) in callTracer and
prestateTracer.

Co-authored-by: jwasinger <j-wasinger@hotmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-09-09 11:40:55 +08:00
Daniel Liu
19f5417121
eth/tracers/native: set created address to nil in case of failure #26779 (#1321)
Fixes #26073

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 11:17:01 +08:00
Chris Ziogas
1361040a37 eth/tracers: add native flatCallTracer (aka parity style tracer) #26377 (#1320)
Adds support for a native call tracer with the Parity format, which outputs call frames
in a flat array. This tracer accepts the following options:

- `convertParityErrors: true` will convert error messages to match those of Parity
- `includePrecompiles: true` will report all calls to precompiles. The default
  matches Parity's behavior where CALL and STATICCALLs to precompiles are excluded

Incompatibilities with Parity include:

- Parity removes the result object in case of failure. This behavior is maintained
  with the exception of reverts. Revert output usually contains useful information,
  i.e. Solidity revert reason.
- The `gasUsed` field accounts for intrinsic gas (e.g. 21000 for simple transfers)
  and refunds unlike Parity
- Block rewards are not reported

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 11:03:38 +08:00
Daniel Liu
e1baea4d8b
eth/tracer: rename to revertReason #26574 (#1316)
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-09-09 10:34:50 +08:00
Daniel Liu
0061de6b0a
eth/tracers: use non-threaded tracechain #24283 (#1315)
This makes non-JS tracers execute all block txs on a single goroutine.
In the previous implementation, we used to prepare every tx pre-state
on one goroutine, and then run the transactions again with tracing enabled.
Native tracers are usually faster, so it is faster overall to use their output as
the pre-state for tracing the next transaction.

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 10:25:37 +08:00
Daniel Liu
dee4c985b1
eth/tracers/native: fix possible crash in prestate tracer #26351 (#1313) 2025-09-09 09:52:13 +08:00
Daniel Liu
7d4d81f586
eth/tracers, core/vm: remove time from trace output and tracing interface #26291 (#1311)
This removes the 'time' field from logs, as well as from the tracer interface. This change makes the trace output deterministic.  If a tracer needs the time they can measure it themselves. No need for evm to do this.

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 09:26:10 +08:00
Daniel Liu
dd9fac6d41
eth/tracers: small refactor for native tracers #26196 (#1310)
Use noopTracer as a base for other native tracers to avoid extra boilerplate for unimplemented hooks.

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 09:17:54 +08:00
Daniel Liu
5edb41bfd8
eth/tracers: add multiplexing tracer #26086 (#1309)
* eth/tracers: add native multiplexing tracer

* minor improv callTracer

* mv evm cancellation to api

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 08:24:41 +08:00
Daniel Liu
bbb2d8f8de
eth/tracers: prestateTracer - exclude unchanged storage slots in diffMode #25944 (#1308)
Fixes #25943

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 08:18:33 +08:00
Daniel Liu
95adac8c1f
eth/tracers: add withLog to callTracer #25991 (#1307)
In some cases, it is desirable to capture what is triggered by each trace, when using the `callTracer`. For example: call `USDT.transfer` will trigger a `Transfer(from, to, value)` event.

This PR adds the option to capture logs to the call tracer, by specifying `{"withLog": true}` in the tracerconfig.
Any logs belonging to failed/reverted call-scopes are removed from the output, to prevent interpretation mistakes.

Signed-off-by: Delweng <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 08:10:29 +08:00
Daniel Liu
fac00cbcfb
eth/tracers: fix trace call for inner reverts #25971 (#1306)
Inner call reverts will now return the reason similar to the top-level call. Separately, if top-level call is of type CREATE and it fails, its `to` field will now be cleared to `0x00...00` instead of being set to the created address.

Co-authored-by: Nicolas Gotchac <ngotchac@gmail.com>
2025-09-09 08:03:45 +08:00
Daniel Liu
06f50c7226
eth/tracers: fix gasUsed for native and JS tracers #26048 (#1305)
* eth/tracers: fix gasUsed in call tracer

* fix js tracers gasUsed

* fix legacy prestate tracer

* fix restGas in test

* drop intrinsicGas field from js tracers

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 07:57:17 +08:00
Daniel Liu
25caabb77a
eth/tracers: simplify test framework #25973 (#1304)
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 07:46:56 +08:00
Daniel Liu
ebba3c13b4
eth/tracers: fix the issue prestate missing existing contract state #25996 (#1303)
The prestate tracer did not report accounts that existed at a given address prior to a contract being created at that address.

Signed-off-by: Delweng <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 07:27:07 +08:00
Daniel Liu
b0937bc62f
eth/tracers: fix the issue of panic in prestate with diffmode #25957 (#1302)
In some cases, inner contract creation may not be successful, and an inner contract was not created. This PR fixes a crash that could occur when doing tracing in such situations.

Co-authored-by: Delweng <delweng@gmail.com>
2025-09-09 07:19:43 +08:00
Daniel Liu
0988b4b9fd
eth/tracers: add diffMode to prestateTracer #25422 (#1299)
Backwards compatibility warning: The result will from now on omit empty fields instead
of including a zero value (e.g. no more `balance: '0x'`).

The prestateTracer will now take an option `diffMode: bool`. In this mode
the tracer will output the pre state and post data for the modified parts of state.
Read-only accesses will be completely omitted. Creations (be it account or slot)
will be signified by omission in the `pre` list and inclusion in `post`. Whereas
deletion (be it account or slot) will be signified by inclusion in `pre` and omission
in `post` list.

Signed-off-by: Delweng <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
2025-09-09 06:56:34 +08:00
Daniel Liu
9d8bec712d
eth/tracers: remove revertReasonTracer, add revert reason to callTracer #25508 (#1298)
* eth/tracers: add revertReason to callTracer

* update callframe gen json

* add revertal to calltrace test

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 06:43:32 +08:00
Daniel Liu
d962a06975
eth/tracers: fix a bug in prestateTracer #25884 (#1297)
Co-authored-by: Delweng <delweng@gmail.com>
2025-09-09 06:41:52 +08:00
Daniel Liu
de4fa1d674
eth/tracers: use gencodec for native tracers #25637 (#1296)
The call tracer and prestate tracer store data JSON-encoded in memory. In order to support alternative encodings (specifically RLP), it's better to keep data a native format during tracing. This PR does marshalling at the end, using gencodec.

OBS!
This PR changes the call tracer result slightly:

-  Order of type and value fields are changed (should not matter).
-  Output fields are completely omitted when they're empty (no more output: "0x"). Previously, this was only _sometimes_ omitted (e.g. when call ended in a non-revert error) and otherwise 0x when the output was actually empty.

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 06:40:01 +08:00
Daniel Liu
bfc00e775b
eth/tracers: add initial revertReasonTracer tracer #25265 (#1289)
Adds a native tracer that returns that in case of failure returns the error message or the revert reason of a transaction.

Co-authored-by: Philip Fan <fanwengang@hotmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-09-08 23:36:28 +08:00
Daniel Liu
0bc25c35b4
core,eth: implement tx-level hooks for tracers #24510 (#1277)
* core,eth: add empty tx logger hooks

* core,eth: add initial and remaining gas to tx hooks

* store tx gasLimit in js tracer

* use gasLimit to compute intrinsic cost for js tracer

* re-use rules in transitiondb

* rm logs

* rm logs

* Mv some fields from Start to TxStart

* simplify sender lookup in prestate tracer

* mv env to TxStart

* Revert "mv env to TxStart"

This reverts commit 656939634b9aff19f55a1cd167345faf8b1ec310.

* Revert "simplify sender lookup in prestate tracer"

This reverts commit ab65bce48007cab99e68232e7aac2fe008338d50.

* Revert "Mv some fields from Start to TxStart"

This reverts commit aa50d3d9b2559addc80df966111ef5fb5d0c1b6b.

* fix intrinsic gas for prestate tracer

* add comments

* refactor

* fix test case

* simplify consumedGas calc in prestate tracer

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-08 17:53:21 +08:00
Daniel Liu
4f738d2191
eth/tracers: clean-up tracer collection #24320 (#1274) 2025-09-08 17:47:33 +08:00
Daniel Liu
0c293e5c34
eth/tracers: native prestate tracer #24268 (#1273) 2025-09-08 17:45:28 +08:00
Daniel Liu
7d433a454a
eth/tracers: make native 4byte default, remove js version #23916 (#1268)
Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-08-31 16:33:25 +08:00
Daniel Liu
1d1a88db5f
eth/tracers: add golang 4byte tracer #23882 (#1267)
* native 4byte tracer

* Update eth/tracers/native/4byte.go



* Update eth/tracers/native/4byte.go



* goimports

* eth/tracers: make 4byte tracer not care about create

Co-authored-by: Ward Bradt <wardbradt5@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-08-31 16:05:54 +08:00
Daniel Liu
031ea75eca
eth/tracers: package restructuring #23857 (#1266) 2025-08-29 05:26:36 +08:00