Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

RPC: debug_traceTransaction endpoint #506

Merged
merged 32 commits into from
Sep 4, 2021
Merged

Conversation

crypto-facs
Copy link
Contributor

Closes: #71

Description

First PR for debug_traceTansaction endpoint implementation. Second PR will add custom config param for custom javascript tracing that GETH supports. The goal is not to make this PR huge.

NOTE: The trace result is return as a slice of bytes due to uncertainty in the type of the response. By passing a custom param the response format is completely up to the user.


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@orijbot
Copy link

orijbot commented Aug 27, 2021

@codecov
Copy link

codecov bot commented Aug 27, 2021

Codecov Report

Merging #506 (80424e7) into main (6794daf) will decrease coverage by 0.33%.
The diff coverage is 31.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #506      +/-   ##
==========================================
- Coverage   50.45%   50.11%   -0.34%     
==========================================
  Files          59       60       +1     
  Lines        5522     5705     +183     
==========================================
+ Hits         2786     2859      +73     
- Misses       2614     2718     +104     
- Partials      122      128       +6     
Impacted Files Coverage Δ
x/evm/types/query.go 0.00% <0.00%> (ø)
x/evm/types/query.pb.gw.go 0.00% <0.00%> (ø)
x/evm/types/tracer.go 0.00% <0.00%> (ø)
x/evm/keeper/grpc_query.go 68.55% <59.13%> (-2.66%) ⬇️
x/evm/keeper/keeper.go 67.25% <100.00%> (+0.29%) ⬆️
x/evm/keeper/state_transition.go 74.50% <0.00%> (+2.74%) ⬆️
x/evm/keeper/msg_server.go 83.58% <0.00%> (+13.43%) ⬆️

@crypto-facs crypto-facs changed the title Debug trace RPC: debug_traceTransaction endpoint Aug 27, 2021
proto/ethermint/evm/v1/query.proto Outdated Show resolved Hide resolved
x/evm/keeper/grpc_query.go Show resolved Hide resolved
x/evm/keeper/grpc_query.go Outdated Show resolved Hide resolved
ethereum/rpc/apis.go Outdated Show resolved Hide resolved
ethereum/rpc/namespaces/debug/api.go Show resolved Hide resolved
x/evm/types/msg.go Outdated Show resolved Hide resolved
x/evm/types/tracer.go Outdated Show resolved Hide resolved
x/evm/types/tracer.go Show resolved Hide resolved
x/evm/types/tracer.go Show resolved Hide resolved
x/evm/keeper/grpc_query.go Show resolved Hide resolved
Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK! Minor comments. Can you also add the docs for the JSON-RPC endpoint? Thanks @crypto-facs! 💯


//check if block number is 0
if transaction.Height == 0 {
return nil, errors.New("genesis is not traceable")
Copy link
Contributor

@fedekunze fedekunze Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: you can use a.clientCtx.Client.Genesis(a.ctx) to get the genesis

proto/ethermint/evm/v1/evm.proto Outdated Show resolved Hide resolved
x/evm/keeper/grpc_query_test.go Show resolved Hide resolved
if trace.Stack != nil {
stack := make([]string, len(trace.Stack))
for i, stackValue := range trace.Stack {
stack[i] = fmt.Sprintf("%x", stackValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use hex.EncodeToString, it's faster

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crypto-facs can you create an issue for this? Ideally, we should also add a test and a benchmark

x/evm/types/tracer.go Show resolved Hide resolved
x/evm/types/tracer.go Show resolved Hide resolved
docs/api/json-rpc/endpoints.md Outdated Show resolved Hide resolved
docs/api/json-rpc/endpoints.md Outdated Show resolved Hide resolved
docs/api/json-rpc/endpoints.md Show resolved Hide resolved
docs/api/json-rpc/endpoints.md Outdated Show resolved Hide resolved
x/evm/keeper/grpc_query.go Outdated Show resolved Hide resolved
x/evm/keeper/grpc_query.go Outdated Show resolved Hide resolved
if trace.Stack != nil {
stack := make([]string, len(trace.Stack))
for i, stackValue := range trace.Stack {
stack[i] = fmt.Sprintf("%x", stackValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crypto-facs can you create an issue for this? Ideally, we should also add a test and a benchmark

@fedekunze fedekunze enabled auto-merge (squash) September 4, 2021 20:17
@fedekunze
Copy link
Contributor

@crypto-facs can you also add a Changelog entry under Features?

@fedekunze fedekunze merged commit c7554e9 into evmos:main Sep 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement debug_ namespace
3 participants