Commit graph

13507 commits

Author SHA1 Message Date
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
wit765
a943fcee3c
internal/ethapi: fix time type (#1455)
Co-authored-by: wit <wit765765346@gmail>
2025-09-08 23:30:09 +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
Daniel Liu
900b333241
eth/tracers: add support for block overrides in debug_traceCall #24871 (#1288) 2025-09-08 21:22:09 +08:00
Daniel Liu
1b561493fb
eth/tracers: fix typo and linter #25020 #24783 #25551 (#1286) 2025-09-08 21:15:42 +08:00
Daniel Liu
88d703180c
eth/tracers/js: drop duktape engine #24934 (#1283) 2025-09-08 21:11:27 +08:00
Daniel Liu
b27c8d23b2
eth/tracers/js: add memory.length method #24887 (#1284) 2025-09-08 21:08:16 +08:00
Daniel Liu
5226fa2cbf
eth/tracers/js: goja tracer #23773 (#1282) 2025-09-08 20:59:29 +08:00
Daniel Liu
ba2d72e8d8
eth/tracers: migrate go-bindata to embed #24744 (#1279) 2025-09-08 20:57:23 +08:00
Daniel Liu
44bd05a732
eth/tracers: refactor traceTx to separate out struct logging #24326 (#1278)
* eth/tracers: refactor traceTx to separate out struct logging

review fix

Update eth/tracers/api.go

Co-authored-by: Martin Holst Swende <martin@swende.se>

Mv ExecutionResult type to logger package

review fix

impl GetResult for StructLogger

make formatLogs private

confused exit and end..

account for intrinsicGas in structlogger, fix TraceCall test

Add Stop method to logger

Simplify traceTx

Fix test

rm logger from blockchain test

account for refund in structLogger

* use tx hooks in struct logger

* minor

* avoid executionResult in struct logger

* revert blockchain test changes

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
2025-09-08 20:55:06 +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
001bc5a4d8
eth/tracers/logger: use omitempty to reduce log bloat #24547 (#1276) 2025-09-08 17:50:58 +08:00