Commit graph

1580 commits

Author SHA1 Message Date
Daniel Liu
693b248d0d
eth/tracers: fix typos in comments #28881 (#1346) 2025-09-09 16:16:26 +08:00
Daniel Liu
f6eb1aacc2
eth/tracers: use proper base fee in tests #28775 (#1345) 2025-09-09 16:08:15 +08:00
Daniel Liu
26001d237b
eth/tracers: tx-level state in debug_traceCall #28460 (#1344)
Co-authored-by: Delweng <delweng@gmail.com>
2025-09-09 15:59:38 +08:00
Daniel Liu
fe337141c1
eth/tracers/js: fix type inconsistencies #28488 (#1343)
This change fixes two type-inconsistencies in the JS tracer:

- In most places we return byte arrays as a `Uint8Array` to the tracer. However it seems we missed doing the conversion for `ctx` fields which are passed to the tracer during `result`. They are passed as simple arrays. I think Uint8Arrays are more suitable and we should change this inconsistency. Note: this will be a breaking-change. But I believe the effect is small. If we look at our tracers we see that these fields (`ctx.from`, `ctx.to`, etc.) are used in 2 ways. Passed to `toHex` which takes both array or buffer. Or the length was measured which is the same for both types.
- The `slice` taking in `int, int` params versus `memory.slice` taking `int64, int64` params. I suggest changing `slice` types to `int64`. This should have no effect almost in any case.

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-09 15:52:57 +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
242ea9e0e9
eth/tracers/js: use t.toBig on ctx.GasPrice for js tracing #27903 (#1341)
This change fixes a bug in js tracer, where `ctx.GasPrice.toString(16)` returns a number string in base `10`.

Co-authored-by: Joe Netti <joe@netti.dev>
2025-09-09 15:40:17 +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
ef3be2cdac
eth/tracers: add ReturnData in the tracer's response #27704 (#1338)
The struct logger (or opcode tracer) was missing the return data field even
if this was explicitly enabled by user via `"enableReturnData": true` in the config.
This PR fixes this issue.

Co-authored-by: Delweng <delweng@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 15:19:36 +08:00
Daniel Liu
31dcbc7645
eth/tracers: use slices package for sorting #27490 (#1337) 2025-09-09 15:12:22 +08:00
Daniel Liu
525a84eae4
eth/tracers: refactor exporting js buffer #27472 (#1336) 2025-09-09 15:05:47 +08:00
Daniel Liu
a5eab7eddb
eth/tracers: replace noarg fmt.Errorf with errors.New #27330 (#1335) 2025-09-09 14:59:01 +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
c5f747a7d3
eth/tracers: add txHash field on txTraceResult #27183 (#1333)
This PR modifies the interface for the results of `debug_traceBlock` and `debug_traceCall` by adding the `txHash`, allowing users to identify which transaction's trace result corresponds to.

---------

Co-authored-by: sjlee1125 <47561537+sjlee1125@users.noreply.github.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-09-09 14:45:46 +08:00
Daniel Liu
cb80dbe4f6
internal/ethapi: add block overrides to eth_call #26414 (#1332) 2025-09-09 14:39:59 +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
be61f66cb2
core/types: remove message #25977 (#1322) 2025-09-09 11:23:47 +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
96a7ed54c6
core/vm: set tracer-observable value of a delegatecall to match parent value #26632 (#1317)
This is a breaking change in the tracing hooks API as well as semantics of the callTracer:

- CaptureEnter hook provided a nil value argument in case of DELEGATECALL. However to stay consistent with how delegate calls behave in EVM this hook is changed to pass in the value of the parent call.
- callTracer will return parent call's value for DELEGATECALL frames.

---------

Co-authored-by: Chris Ziogas <ziogaschr@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 10:41:48 +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
afc20286fb
eth: add request cancellation checks #26320 (#1314)
This ensures that RPC method handlers will react to a timeout or
cancelled request soon after the event occurs.

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 10:18:10 +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
2834be6131
eth/tracers: return proper error from debug_TraceTransaction when tx not found #26211 (#1312)
Currently calling `debug_TraceTransaction` with a transaction hash that doesn't exist returns a confusing error: `genesis is not traceable`. This PR changes the behaviour to instead return an error message saying `transaction not found`

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-09-09 09:36:14 +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
c51f227944
eth/tracers: improve flaky tests #25918 (#1301) 2025-09-09 07:10:44 +08:00
Daniel Liu
51f4757eed
eth/traces: add state limit #25812 (#1300)
This PR introduces a new mechanism in chain tracer for preventing creating too many trace states.

The workflow of chain tracer can be divided into several parts:

- state creator generates trace state in a thread
- state tracer retrieves the trace state and applies the tracing on top in another thread
- state collector gathers all result from state tracer and stream to users

It's basically a producer-consumer model here, while if we imagine that the state producer generates states too fast, then it will lead to accumulate lots of unused states in memory. Even worse, in path-based state scheme it will only keep the latest 128 states in memory, and the newly generated state will invalidate the oldest one by marking it as stale.

The solution for fixing it is to limit the speed of state generation. If there are over 128 states un-consumed in memory, then the creation will be paused until the states are be consumed properly.

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-09-09 07:03:24 +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
b72c76eb30
eth/tracers: pad memory slice on OOB case #25213 (#1295)
* eth/tracers: pad memory slice on oob case

* eth/tracers/js: fix testfailure due to err msg capitalization

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-09-09 06:38:10 +08:00
Daniel Liu
98be4bb911
eth: rework chain tracer #25143 #25715 #29162 (#1294) 2025-09-09 00:06:07 +08:00
Daniel Liu
3b80bd0347
eth/tracers/js: improve integer types in log object #25668 (#1293)
All fields related to gas must be represented as uint64. Depth is
internally tracked as int, so it makes sense to also store it as int.

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-08 23:42:04 +08:00
Daniel Liu
a935810d4c
eth/tracers/js: fill in refund field #25661 (#1292) 2025-09-08 23:40:07 +08:00
Daniel Liu
67efb14ff3
eth/tracers: add onlyTopCall option to callTracer #25430 (#1291) 2025-09-08 23:38:19 +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
241ad1d635
eth/tracers: optimize goja buffer conversion #25156 (#1287)
This changes the []byte <-> Uint8Array conversion to use an
ArrayBuffer, avoiding inefficient copying of the slice data in Goja.

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-08 21:24:58 +08:00