Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CallTracer implementation for debug endpoints #2001

Merged
merged 4 commits into from
Oct 26, 2023
Merged

Conversation

goran-ethernal
Copy link
Contributor

@goran-ethernal goran-ethernal commented Oct 20, 2023

Description

This PR implements the callTracer for debug rpc endpoints. debug_ rpc endpoints config is now expanded with tracer field to specify which tracer you want to be used. Currently, Edge has two tracers: structTracer and callTracer. If no tracer is specified when calling some debug endpoint, structTracer will be used by default.

This implementation is provided by the Gateway.fm friends, who implemented this on their own Edge fork.

How to use callTracer

  1. Start Edge nodes.
  2. Run this curl to get some epoch ending block:
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber", "params": ["10", false]}' http://localhost:10002`
  1. After eth_getBlockByNumber returns a result, take some transaction hash from transactions item in json result.
  2. Run this curl to get call debug_traceTransaction:
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"debug_traceTransaction", "params": ["transactionHash", {"tracer": "callTracer"}]}' http://localhost:10002
  1. Notice that result looks something like this:
{
  "jsonrpc": "2.0",
  "id": null,
  "result": {
    "type": "CALL",
    "from": "0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE",
    "to": "0x0000000000000000000000000000000000000101",
    "value": "0x0",
    "gas": "0xeedd4",
    "gasUsed": "0x13966",
    "input": "0x0f50287c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000",
    "output": "0x",
    "calls": [
      {
        "type": "DELEGATECALL",
        "from": "0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE",
        "to": "0x0000000000000000000000000000000000000101",
        "value": "0x0",
        "gas": "0xea7be",
        "gasUsed": "0x12eb7",
        "input": "0x0f50287c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000",
        "output": "0x"
      }
    ]
  }
}

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

@goran-ethernal goran-ethernal self-assigned this Oct 20, 2023
@goran-ethernal goran-ethernal added the feature New update to Polygon Edge label Oct 20, 2023
@goran-ethernal goran-ethernal marked this pull request as ready for review October 20, 2023 12:11
@goran-ethernal goran-ethernal requested a review from a team October 20, 2023 12:52
Copy link
Contributor

@Stefan-Ethernal Stefan-Ethernal left a comment

Choose a reason for hiding this comment

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

Generally LGTM

state/runtime/tracer/calltracer/call_tracer.go Outdated Show resolved Hide resolved
state/runtime/tracer/calltracer/call_tracer.go Outdated Show resolved Hide resolved
state/runtime/tracer/calltracer/call_tracer.go Outdated Show resolved Hide resolved
@goran-ethernal goran-ethernal merged commit 7001f4e into develop Oct 26, 2023
10 checks passed
@goran-ethernal goran-ethernal deleted the call-tracer branch October 26, 2023 13:20
@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New update to Polygon Edge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants