go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

eth/tracers: implement trace live filter

Open jsvisa opened this issue 1 year ago • 1 comments

Hi @s1na,

This is a poc version of the trace_xxx RPC. I primarily use the freezer database to store the block traces and register the RPC in stack with a callback (which may be refactored later). In this branch, I attempt to implement a simple version of the trace_filter, trace_block, and trace_transaction RPC methods. I then run these changes locally to verify the correctness of the data produced.

Here are some areas that need further refactoring:

  1. Dependency Injection: We need to pass an eth.Backend or a similar object to the filter_tracer to fetch the chain’s inner services. For example, trace_transaction requires the transaction-to-block number mapping.
  2. Tracer Compatibility: We need to adjust some aspects of the prestate and call tracers to be compatible with both live and debug traces. For instance, in live tracing, the block context is passed via the OnBlockStart hook, whereas in debug tracing, it is provided during the initialization of tracing.
  3. RPC Design: I'm intending to maintain compatibility with Parity’s RPC. For example:
{
  "jsonrpc": "2.0",
  "method": "trace_block",
  "id": 67,
  "params": [
    "0x5990",
    {"tracer": "callTracer"}  // Added in our implementation
  ]
}

Should the default tracer be parity? In Parity’s case, the response should also be the same as Parity’s(need more redesign). For other tracers (e.g., callTracer, prestateTracer), the response format should be consistent with the debug_traceXXX methods.

Starting geth with filter live tracer:

geth
... # other arguments
--http.api=engine,web3,eth,debug,trace # append trace namespace
--vmtrace=filter # enable the filter live tracer
--vmtrace.jsonconfig="{\"path\": \"/data/trace-filter\", \"config\": {\"callTracer\": {}, \"flatCallTracer\": {\"includePrecompiles\": true, \"convertParityErrors\": true}}}"

Looking forward to your feedback and suggestions.

jsvisa avatar Aug 01 '24 16:08 jsvisa

@s1na maybe we can support this tracer after https://github.com/ethereum/go-ethereum/pull/30611

jsvisa avatar Oct 17 '24 07:10 jsvisa

This PR is quite stale, going to close for now. If you rebase and want to continue pursing it please go ahead and reopen.

lightclient avatar May 02 '25 15:05 lightclient