Skip to content

Add call tracer js implementation#5022

Open
Frozen wants to merge 5 commits into
devfrom
fixed-call-tracer
Open

Add call tracer js implementation#5022
Frozen wants to merge 5 commits into
devfrom
fixed-call-tracer

Conversation

@Frozen
Copy link
Copy Markdown
Collaborator

@Frozen Frozen commented Mar 24, 2026

Adds a JavaScript-based callTracer implementation to the Harmony tracer subsystem, embedding the JS asset and registering a dedicated tracer lookup so callers can request callTracer by name.

@Frozen Frozen self-assigned this Mar 24, 2026
@Frozen Frozen changed the title Add call tracer implementation with asset loading Add call tracer js implementation Mar 24, 2026
@Frozen Frozen requested a review from Copilot March 26, 2026 14:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a JavaScript-based callTracer implementation to the Harmony tracer subsystem, embedding the JS asset and registering a dedicated tracer lookup so callers can request callTracer by name.

Changes:

  • Introduces hmy/tracers/js/call_tracer.go registering a non-wildcard lookup for "callTracer".
  • Embeds call_tracer.js as a gzipped byte payload with a small bindata-style loader.
  • Loads tracer assets during package init and routes "callTracer" construction through newJsTracer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hmy/tracers/js/call_tracer.go
Comment thread hmy/tracers/js/call_tracer.go
Comment thread hmy/tracers/js/call_tracer.go Outdated
Comment thread hmy/tracers/js/call_tracer.go
Comment thread hmy/tracers/js/call_tracer.go
@mur-me mur-me requested review from GheisMohammadi and mur-me April 1, 2026 13:11
@harmony-one harmony-one deleted a comment from Copilot AI Apr 1, 2026
@harmony-one harmony-one deleted a comment from Copilot AI Apr 1, 2026
@harmony-one harmony-one deleted a comment from Copilot AI Apr 1, 2026
@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented Apr 2, 2026

@Frozen please rebase it to the latest dev

@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented Apr 2, 2026

Tested on the archival endpoints:

  • debug_traceTransaction with "tracer": "callTracer" is still an issue
curl -q --location 'https://a.api.s0.t.hmny.io' --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "debug_traceTransaction",
    "params": [
        "0x26084ceb7e5b84c8b77cb5391ff2007fcd90b20fc2f6004100b3f8599ad2cc83",
        {
            "tracer": "callTracer"
        }
    ],
    "id": 0
}' | jq
{
  "jsonrpc": "2.0",
  "id": 0,
  "error": {
    "code": -32000,
    "message": "incorrect number of top-level calls"
  }
}
  • trace_transaction is working fine:
curl -q --location 'https://a.api.s0.t.hmny.io' --header 'Content-Type: application/json' --data-raw '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "trace_transaction",
    "params": ["0x11058254015c3c47b9d6f3be152bc637f853f29381b1fe36ef3c41441b9be046"]
}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "blockNumber": 86444511,
      "blockHash": "0x284ff7497588a114f97dee0b66a86991b9394e76da66167a2218e7bdebccc973",
...

@Frozen Frozen force-pushed the fixed-call-tracer branch 3 times, most recently from 77405bc to 98698d1 Compare April 2, 2026 23:15
@Frozen
Copy link
Copy Markdown
Collaborator Author

Frozen commented Apr 2, 2026

@Frozen please rebase it to the latest dev

Updated

@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented Apr 28, 2026

Hey @Frozen, can you please take a look on the failed test - https://app.travis-ci.com/github/harmony-one/harmony/jobs/639081720

>       assert response["gas"] == "0x0"
E       AssertionError: assert '0x5208' == '0x0'
E         - 0x0
E         + 0x5208

In fact, what we have right now is the following

response["gas"] == "0x5208"
response["gasUsed"] == "0x0"

On latest go-ethereum — currently Geth v1.17.2 stable — for your exact debug_traceCall + callTracer case, it should be:

assert response["gas"] == "0x5208"
assert response["gasUsed"] == "0x5208"

Latest Geth’s native callTracer includes the depth-0 frame, and docs define gas as "gas provided for call" and gasUsed as "gas used during call", link - https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers#call-tracer

@Frozen Frozen force-pushed the fixed-call-tracer branch from 735dc9b to e68df47 Compare April 29, 2026 21:49
@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented May 7, 2026

Hooray, it is wokring!

curl --location -s 'https://api-aa.s0.b.hmny.io' --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "debug_traceTransaction",
    "params": [
        "0x6fcd44a78b9d6757cc6c439b24294aecb860c964ccaf73211afaa0da05b0a69c",
        {
            "tracer": "callTracer"
        }
    ],
    "id": 0
}' |jq
{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "type": "CALL",
    "from": "0xf59de020d650e69ef0755bf37f3d16b80ee132f5",
    "to": "0xc22834581ebc8527d974f8a1c97e1bea4ef910bc",
    "value": "0x0",
    "gas": "0x3d2de",
    "gasUsed": "0x3c57e",
    "input": "0x1688f0b9000000000000000000000000fb1bffc9d739b8d520daf37df666da4c687191ea000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000184b63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000017062a1de2fe6b99be3d9d37841fed19f5738040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f59de020d650e69ef0755bf37f3d16b80ee132f500000000000000000000000045b96ed5d5b18f4f865266d8371c662cd241e6d5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "output": "0x000000000000000000000000e6c18776027c2da24a487e352ec93eb3acef62f2",
    "time": "17.859278ms",
    "calls": [
      {
        "type": "CREATE2",
        "from": "0xc22834581ebc8527d974f8a1c97e1bea4ef910bc",
        "to": "0xe6c18776027c2da24a487e352ec93eb3acef62f2",
        "value": "0x0",
        "gas": "0x33d16",
        "gasUsed": "0xd80d",
        "input": "0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000fb1bffc9d739b8d520daf37df666da4c687191ea",
        "output": "0x608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033"
      },
      {
        "type": "CALL",
        "from": "0xc22834581ebc8527d974f8a1c97e1bea4ef910bc",
        "to": "0xe6c18776027c2da24a487e352ec93eb3acef62f2",
        "value": "0x0",
        "gas": "0x26535",
        "gasUsed": "0x25be4",
        "input": "0xb63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000017062a1de2fe6b99be3d9d37841fed19f5738040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f59de020d650e69ef0755bf37f3d16b80ee132f500000000000000000000000045b96ed5d5b18f4f865266d8371c662cd241e6d50000000000000000000000000000000000000000000000000000000000000000",
        "output": "0x",
        "calls": [
          {
            "type": "DELEGATECALL",
            "from": "0xe6c18776027c2da24a487e352ec93eb3acef62f2",
            "to": "0xfb1bffc9d739b8d520daf37df666da4c687191ea",
            "gas": "0x25546",
            "gasUsed": "0x25546",
            "input": "0xb63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000017062a1de2fe6b99be3d9d37841fed19f5738040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f59de020d650e69ef0755bf37f3d16b80ee132f500000000000000000000000045b96ed5d5b18f4f865266d8371c662cd241e6d50000000000000000000000000000000000000000000000000000000000000000",
            "output": "0x"
          }
        ]
      }
    ]
  }
}

@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented May 7, 2026

Same for the trace_transaction

curl -q --location 'https://api-aa.s0.b.hmny.io' --header 'Content-Type: application/json' --data-raw '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "trace_transaction",
    "params": ["0x6fcd44a78b9d6757cc6c439b24294aecb860c964ccaf73211afaa0da05b0a69c"]
}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "blockNumber": 48958229,
      "blockHash": "0xbf7771c798a2e33203d8d16864b2b2507e8d5c559d6467f8b6f61a65e60cc419",
      "transactionHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "transactionPosition": 0,
      "subtraces": 2,
      "traceAddress": [],
      "type": "call",
      "action": {
        "callType": "call",
        "value": "0x0",
        "to": "0xc22834581ebc8527d974f8a1c97e1bea4ef910bc",
        "gas": "0x3d2de",
        "from": "0xf59de020d650e69ef0755bf37f3d16b80ee132f5",
        "input": "0x1688f0b9000000000000000000000000fb1bffc9d739b8d520daf37df666da4c687191ea000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000184b63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000017062a1de2fe6b99be3d9d37841fed19f5738040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f59de020d650e69ef0755bf37f3d16b80ee132f500000000000000000000000045b96ed5d5b18f4f865266d8371c662cd241e6d5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
      },
      "result": {
        "output": "0x000000000000000000000000e6c18776027c2da24a487e352ec93eb3acef62f2",
        "gasUsed": "0x3c57e"
      }
    },
    {
      "blockNumber": 48958229,
      "blockHash": "0xbf7771c798a2e33203d8d16864b2b2507e8d5c559d6467f8b6f61a65e60cc419",
      "transactionHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "transactionPosition": 0,
      "subtraces": 0,
      "traceAddress": [
        0
      ],
      "type": "create",
      "action": {
        "from": "0xc22834581ebc8527d974f8a1c97e1bea4ef910bc",
        "gas": "0x33d16",
        "init": "0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000fb1bffc9d739b8d520daf37df666da4c687191ea",
        "value": "0x0"
      },
      "result": {
        "address": "0xe6c18776027c2da24a487e352ec93eb3acef62f2",
        "code": "0x608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033",
        "gasUsed": "0xd80d"
      }
    },
    {
      "blockNumber": 48958229,
      "blockHash": "0xbf7771c798a2e33203d8d16864b2b2507e8d5c559d6467f8b6f61a65e60cc419",
      "transactionHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "transactionPosition": 0,
      "subtraces": 1,
      "traceAddress": [
        1
      ],
      "type": "call",
      "action": {
        "callType": "call",
        "value": "0x0",
        "to": "0xe6c18776027c2da24a487e352ec93eb3acef62f2",
        "gas": "0x26535",
        "from": "0xc22834581ebc8527d974f8a1c97e1bea4ef910bc",
        "input": "0xb63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000017062a1de2fe6b99be3d9d37841fed19f5738040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f59de020d650e69ef0755bf37f3d16b80ee132f500000000000000000000000045b96ed5d5b18f4f865266d8371c662cd241e6d50000000000000000000000000000000000000000000000000000000000000000"
      },
      "result": {
        "output": "0x",
        "gasUsed": "0x25be4"
      }
    },
    {
      "blockNumber": 48958229,
      "blockHash": "0xbf7771c798a2e33203d8d16864b2b2507e8d5c559d6467f8b6f61a65e60cc419",
      "transactionHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "transactionPosition": 0,
      "subtraces": 0,
      "traceAddress": [
        1,
        0
      ],
      "type": "call",
      "action": {
        "callType": "delegatecall",
        "to": "0xfb1bffc9d739b8d520daf37df666da4c687191ea",
        "gas": "0x25546",
        "from": "0xe6c18776027c2da24a487e352ec93eb3acef62f2",
        "input": "0xb63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000017062a1de2fe6b99be3d9d37841fed19f5738040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f59de020d650e69ef0755bf37f3d16b80ee132f500000000000000000000000045b96ed5d5b18f4f865266d8371c662cd241e6d50000000000000000000000000000000000000000000000000000000000000000"
      },
      "result": {
        "output": "0x",
        "gasUsed": "0x25546"
      }
    }
  ]
}

@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented May 8, 2026

Hey @Frozen, please also remove this debug log that is just landing in our stdout https://github.com/harmony-one/harmony/blob/dev/hmy/tracer.go#L779

@Frozen
Copy link
Copy Markdown
Collaborator Author

Frozen commented May 8, 2026

removed @mur-me

@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented May 11, 2026

Checking this on the testnet rn

@mur-me
Copy link
Copy Markdown
Collaborator

mur-me commented May 11, 2026

Nice, now more such logs, approved, let's merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants