eth/tracers: implement trace live filter
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:
- Dependency Injection: We need to pass an
eth.Backendor 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. - 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
OnBlockStarthook, whereas in debug tracing, it is provided during the initialization of tracing. - 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.
@s1na maybe we can support this tracer after https://github.com/ethereum/go-ethereum/pull/30611
This PR is quite stale, going to close for now. If you rebase and want to continue pursing it please go ahead and reopen.