Skip to content

Conversation

SolidityNinja
Copy link

@SolidityNinja SolidityNinja commented Mar 12, 2025

PR improves the way of interacting with debug_trace... API endpoints of the Geth node. It provides built-in tracers support (https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers) which configs and responses can be deserialised now into the C#'s language structures and more advanced tracing configs (blockOverrides and stateOverrides). Also, corresponding integration tests were added

More specifically, changes introduced by the PR:

  1. New DTOs for supporting more sophisticated configs for debug and simulation purposes. BlockOverridesDto and StateOverrideDto (represents Block overrides and State overrides (https://geth.ethereum.org/docs/interacting-with-geth/rpc/objects#block-override-set), TraceCallConfigDto and TraceConfigDto (represents TraceCallConfig and TraceConfig objects https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#tracecallconfig) and other DTOs for block responses and struct logs. So for example user can specify the block and state overrides for simulation using language structures
  2. New SendRequestAsync<TOutput>() method overload with generics for DebugTraceBlock, DebugTraceBlockByHash, DebugTraceBlockByNumber, DebugTraceBlockFromFile, DebugTraceTransaction and DebugTraceCall services. Calling this function will return tracer response deserialised into the specified C# class
  3. Adds debug_traceBadBlock endpoint support
  4. Adds support for all currently available built-in tracers: opcodeTracer (default), 4byteTracer, callTracer, prestateTracer, noopTracer, bigram, evmdis, opcount, trigram, unigram. Corresponding DTOs for configs and responses for all of them were added. It's also possible to specify a custom code for tracer

Usage example:

Running debug_traceTransaction with callTracer (only top calls, with logs):

var web3Geth = new Web3Geth("http://node:8545");
var result = await web3Geth.GethDebug.TraceTransaction.SendRequestAsync<CallTracerResponse>(
    txHash,
    new TracingCallOptions()
    {
        Timeout = "1m",
        Reexec = 128,
        TracerInfo = new CallTracerInfo(true, true)
    }
);

This will return tracer response deserialised into CallTracerResponse object

More examples you can find in the integration tests

@SolidityNinja SolidityNinja marked this pull request as ready for review March 12, 2025 14:57
@SolidityNinja SolidityNinja changed the title DTOs for debug and tracer options/responses added, debug api services… debug_trace... endpoints improved Mar 13, 2025
@juanfranblanco
Copy link
Member

Hi,

I am reviewing it, really good.. thanks.

@juanfranblanco juanfranblanco merged commit de10865 into Nethereum:master May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants