Skip to content

[pallet-revive] Execution tracer#9722

Merged
pgherveou merged 86 commits intomasterfrom
pg/structlogger
Jan 26, 2026
Merged

[pallet-revive] Execution tracer#9722
pgherveou merged 86 commits intomasterfrom
pg/structlogger

Conversation

@pgherveou
Copy link
Copy Markdown
Contributor

@pgherveou pgherveou commented Sep 12, 2025

This PR introduces a Geth-compatible execution tracer (StructLogger) for pallet-revive

The tracer can be used to capture both EVM opcode and PVM syscall.
It can be used with the same RPC endpoint as Geth StructLogger.

Since it can be quite resource intensive, It can only be queried from the node when the DebugSettings are enabled (This is turned on now by default in the dev-node)

Tested in paritytech/evm-test-suite#138

example:

❯ cast rpc debug_traceTransaction "<TX_HASH>" | jq

# or with options
# See list of options https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers#struct-opcode-logger

  ❯ cast rpc debug_traceTransaction "<TX_HASH>", { "tracer": { "enableMemory": true } } | jq

The response includes additional fields compared to the original Geth debug RPC endpoints:

For the trace:

  • weight_consumed: same as gas but expressed in Weight
  • base_call_weight: the base cost of the transaction

For each step:

  • weight_cost: same as gas_cost but expressed in Weight

For an EVM execution, the output will look like this

{
  "gas": 4208049,
  "weight_consumed": { "ref_time": 126241470000, "proof_size": 4208 },
  "base_call_weight": { "ref_time": 9000000000, "proof_size": 3000 },
  "failed": false,
  "returnValue": "0x",
  "structLogs": [
    {
      "gas": 4109533,
      "gasCost": 3,
      "weight_cost": { "ref_time": 90000, "proof_size": 0 },
      "depth": 1,
      "pc": 0,
      "op": "PUSH1",
      "stack": []
    },
    {
      "gas": 4109530,
      "gasCost": 3,
      "weight_cost": { "ref_time": 90000, "proof_size": 0 },
      "depth": 1,
      "pc": 2,
      "op": "PUSH1",
      "stack": [
        "0x80"
      ]
    },
    {
      "gas": 4109527,
      "gasCost": 3,
      "weight_cost": { "ref_time": 90000, "proof_size": 0 },
      "depth": 1,
      "pc": 4,
      "op": "MSTORE",
      "stack": [
        "0x80",
        "0x40"
      ]
    }]
}

For PVM execution, each step includes additional fields not present in Geth:

  • args: Array of syscall arguments (register values a0-a5) as hex strings
  • returned: The syscall return value as hex string

These fields are enabled by default. To disable them, use disableSyscallDetails: true.

Example output with syscall details:

{
  "gas": 97108,
  "gasCost": 131,
  "weight_cost": { "ref_time": 3930000, "proof_size": 0 },
  "depth": 1,
  "op": "call_data_load",
  "args": ["0x0", "0x4"],
  "returned": "0x2a"
}

@pgherveou pgherveou changed the base branch from master to pg/change-gas-price September 12, 2025 03:57
@pgherveou pgherveou changed the base branch from pg/change-gas-price to master September 12, 2025 03:58
pgherveou and others added 21 commits September 15, 2025 09:28
Currently submitting a transactio to the dev-node or kitchensink will
trigger an error when you try to submit a transaction trhough cast (or
anything using alloy) as the block gas limit on these runtime is greater
than u64::max.

This bump the GAS_PRICE to fix this issue, this will eventually be
superseeded by the new gas model

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: xermicus <[email protected]>
@pgherveou pgherveou changed the base branch from master to pg/fix-tacing-collect September 15, 2025 11:26
Base automatically changed from pg/fix-tacing-collect to master September 16, 2025 15:39
Copy link
Copy Markdown
Member

@xermicus xermicus left a comment

Choose a reason for hiding this comment

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

The EVM trace also reports the stack which should be enough the reconstruct a full execution trace. But PVM missing the syscall arguments and return values makes this of limited use?

@pgherveou
Copy link
Copy Markdown
Contributor Author

pgherveou commented Jan 15, 2026

The EVM trace also reports the stack which should be enough the reconstruct a full execution trace. But PVM missing the syscall arguments and return values makes this of limited use?

true, I can add that in, wasn't planning on supporting pvm at first, but now that I do we better add the args you are right

@pgherveou pgherveou requested review from 0xRVE and xermicus January 16, 2026 15:56
@pgherveou
Copy link
Copy Markdown
Contributor Author

/bot fmt

Copy link
Copy Markdown
Contributor

@marian-radu marian-radu left a comment

Choose a reason for hiding this comment

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

Looks good to me

@pgherveou
Copy link
Copy Markdown
Contributor Author

/bot fmt

@pgherveou pgherveou enabled auto-merge January 23, 2026 12:57
@paritytech-workflow-stopper
Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/21358429077
Failed job name: fmt

@pgherveou pgherveou added this pull request to the merge queue Jan 26, 2026
Merged via the queue into master with commit 51d25de Jan 26, 2026
235 of 239 checks passed
@pgherveou pgherveou deleted the pg/structlogger branch January 26, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants