hedera-mirror-node icon indicating copy to clipboard operation
hedera-mirror-node copied to clipboard

HIP-801: Opcode tracer endpoint implementation for eth_debug_traceTransaction

Open stoqnkpL opened this issue 1 year ago • 1 comments

Overview of Package

Definition

Add a new REST POST endpoint in hedera-mirror-web3, that will allow tracing historical transactions and displaying the opcodes that were executed.

Abstract

Add support for debugging historical transactions with the opcodeLogger tracer.

Motivation

Enhancing Mirror Archive Node with debug calls would allow users to replay historical transactions and inspect and analyse them by having detailed information for the execution based on a tracer type that is specified in the request. In addition, this enhancement would improve Hedera interoperability with different ethereum tools and providers, including Remix, Hardhat, Ganache, Geth, Alchemy, etc. This task would cover having an implementation for the opcodeLogger tracer.

Rationale

The JSON-RPC Relay will add a debug_traceTransaction endpoint which in turn will make a request to the Mirror Node REST API.

A new /api/v1/contracts/results/{transactionIdOrHash}/opcodes endpoint needs to be created in order to support handling transaction tracing requests.

User stories

  1. As a user, I want to perform debug_traceTransaction calls to explore the op code traces for a historical transaction.

Specification

  1. Implement a new REST POST endpoint: /api/v1/contracts/results/{transactionIdOrHash}/opcodes
  2. Handling requests should include the following steps:
    1. load information about the historical transaction specified with the {transactionIdOrHash}
    2. load information about the contract state changes that were externalized by the Consensus node during the original transaction execution
    3. instantiate a State that reads from the state changes from the sidecar and the account, contract and token related information that is kept in the different tables
      1. we may also need to read precompile results from the contract actions?
    4. implement the opcode logger tracer (one such does exist in Besu, so try to reuse it)
    5. re-execute the transaction with enabled tracing by the opcode logger tracer
  3. Create and implement a test plan
  4. Disable the endpoint by default (and for production environments)

Backwards compatibility

We’re adding a new endpoint so no impact on backwards compatibility is expected.

Security Implications

Some outputs from tracing transactions (especially with the opcode logger tracer) can be pretty large and could have impact on the performance. This is the reason why this endpoint should not be enabled on production.

References/Dependencies

  1. HIP-584: Mirror EVM Archive Node
  2. EVM Archive Node with Historical block support for eth_call -design doc- [shared]
  3. Draft HIP-XXX for debug_traceTransaction support [shared]
### Tasks
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/8173
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/8174
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/7341

stoqnkpL avatar Aug 30 '23 07:08 stoqnkpL

for Q2

bibitibooo1 avatar Jan 16 '24 14:01 bibitibooo1

Implementation is ready across all products, additional tests are in progress, but will be tracked in separate issue.

georgi-l95 avatar Jul 09 '24 11:07 georgi-l95