- 
                Notifications
    You must be signed in to change notification settings 
- Fork 978
Description
Description
As a dev, I want to troubleshoot specific opcodes in insanely big blocks or transactions so that I can check and fix consensus bugs. Specifically I'm interested in having an optional parameter called opcodes that is passed to tracing RPC methods in order to filter traces based on the specified opcodes. This makes tracing consume less resources in the case of big blocks or transactions - I can get a simpler and faster reply from the node.
In some cases it's not even possible to get a trace due to the size of the trace produced. I found an example transaction on Hoodi of such case: https://hoodi.etherscan.io/tx/0xdfd5028da0f2f306ae71dc558c26bb1935b13ec3a0e909223eaa77bf761189a8 - even with everything disabled but stack, it's not possible to trace this transaction either with debug_traceBlockByHash or debug_standardTraceBlockToFile since the RPC handler chokes on the request, i.e.:
$ curl --location --globoff 'http://localhost:8545' --data '{
    "jsonrpc": "2.0",
    "method": "debug_traceBlockByHash",
    "params": [
        "0x2476b23a03dd87f272724a12213dc4a1ca8f13a1aa9d128a690e1b7d7d312e5e",
        {
            "disableStack": false,
            "disableMemory": true,
            "disableStorage": true
        }
    ],
    "id": 1
}'
Gateway Timeout
$ curl --location --globoff 'http://localhost:8545' --data '{
    "jsonrpc": "2.0",
    "method": "debug_standardTraceBlockToFile",
    "params": [
        "0x2476b23a03dd87f272724a12213dc4a1ca8f13a1aa9d128a690e1b7d7d312e5e",
        {
            "disableStack": false,
            "disableMemory": true,
            "disableStorage": true
        }
    ],
    "id": 1
}'
Gateway Timeout
Checking the traces on disk, a sizeable amount of traces are produced:
$ du -h /data/besu/traces/block_0x2476b23a-*
2.4G	/data/besu/traces/block_0x2476b23a-0-0xdfd5028d-1760719531046
135M	/data/besu/traces/block_0x2476b23a-1-0x82a815d7-1760719561042
135M	/data/besu/traces/block_0x2476b23a-2-0xf9c008f1-1760719564562
135M	/data/besu/traces/block_0x2476b23a-3-0x8444b07f-1760719568059
64M	/data/besu/traces/block_0x2476b23a-4-0x8dfe68a1-1760719571545
Acceptance Criteria
I can restrict the number of trace frames returned by debug_* RPC methods by specifying which opcodes I want to trace for. I also need the frame just after the specified opcode to view stack, memory, storage, etc..., outputs. Specifically I'm interested in the following set of RPC methods:
- debug_standardTraceBlockToFile
- debug_standardTraceBadBlockToFile
- debug_traceBlockByNumber
- debug_traceBlockByHash
- debug_traceTransaction
- debug_traceBlock
- debug_traceCall
I also want this parameter to be optional, so backwards compatibility is not broken.