hedera-mirror-node
hedera-mirror-node copied to clipboard
HIP-801: Opcode tracer endpoint implementation for eth_debug_traceTransaction
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
- As a user, I want to perform
debug_traceTransaction
calls to explore the op code traces for a historical transaction.
Specification
- Implement a new REST POST endpoint:
/api/v1/contracts/results/{transactionIdOrHash}/opcodes
- Handling requests should include the following steps:
- load information about the historical transaction specified with the
{transactionIdOrHash}
- load information about the contract state changes that were externalized by the Consensus node during the original transaction execution
- 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
- we may also need to read precompile results from the contract actions?
- implement the opcode logger tracer (one such does exist in Besu, so try to reuse it)
- re-execute the transaction with enabled tracing by the opcode logger tracer
- load information about the historical transaction specified with the
- Create and implement a test plan
- 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
- HIP-584: Mirror EVM Archive Node
-
EVM Archive Node with Historical block support for
eth_call
-design doc- [shared] -
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
for Q2
Implementation is ready across all products, additional tests are in progress, but will be tracked in separate issue.