Trace API vs. Debug API

The differences between the Trace API by Openethereum and the Debug API by Geth

Prerequisites

Before reading this article you should know about Ethereum Clients and EVM Traces.

Introduction

Geth and Openethereum are two popular Ethereum clients. In this article, we'll compare and contrast the debug API offered by Geth with the trace API offered by Openethereum and Erigon.

Debug API

The Debug API is a set of RPC methods developed by the Go-Ethereum team that provide deeper insights into transaction processing. Some common debug API methods are:

  1. debug_traceTransaction
  2. debug_traceCall
  3. debug_traceBlockByNumber
  4. debug_traceBlockByHash

Trace API

Trace API Quickstart is Openethereum's equivalent to Geth's Debug API. It is also a set of RPC methods that provide deeper insights into transaction processing. Some common Trace API methods are:

  1. trace_transaction
  2. trace_call
  3. trace_block
  4. trace_filter
  5. trace_get
  6. trace_rawTransaction
  7. trace_replayBlockTransactions
  8. trace_replayTransaction

Difference between Trace API and Debug API

  1. Geth offers debug API while Trace API is offered by Openethereum and Erigon.
  2. Debug API has more methods than Trace API. Here you can find a list of all the methods that Debug API supports.
  3. Debug API is more accessible than Trace API as the majority of the Ethereum nodes run the Geth client.
  4. Trace API does not include calls to the 9 precompiled contracts specified in the Ethereum chain specification, while debug API does.

📘

Precompiled Contracts

Precompiled contracts are a feature of the Ethereum Virtual Machine (EVM) that allow for efficient execution of certain computationally expensive operations. These contracts are built into the EVM and can be called by other contracts to perform specific tasks. They are specified as a part of the Ethereum chain specification, and their addresses are hardcoded into the EVM.

Currently, there are nine precompiled contracts in the Ethereum network. These precompiled contracts can be called by other smart contracts, and the gas cost of executing them is determined by the size of the input data, which is fixed and known in advance. It means that the execution cost of these contracts is constant, regardless of the specific input provided. This is useful for operations that are known to be computationally expensive, such as elliptic curve operations, modular exponentiation, and hash calculations.

  1. Trace API includes REWARDS for miners in the trace, but debug API does not.
  2. The representation of the callstack is different between Trace and Debug API, trace API includes a field called traceAddress which gives the exact location of the call trace, while the call stack is nested in the response in debug API.
  3. The way error handling is done is different in Trace and Debug API, trace API uses custom error handling while debug API uses predefined constants to represent errors that can occur during EVM execution.
6144
ReadMe