Skip to content

fix: include precompile calls in call traces and identify them by address - #1826

Merged
Wodann merged 1 commit into
mainfrom
fix/call-trace-precompiles
Oct 8, 2026
Merged

Wodann merged 1 commit into
mainfrom
fix/call-trace-precompiles

Conversation

@Wodann

@Wodann Wodann commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Since #1278 the provider builds its tracing inspector from TracingInspectorConfig::default_parity(), which excludes precompile calls from the arena, while the Solidity test runner records them.

Stack-trace conversion (edr_solidity::nested_trace::conversion) pairs every call-like step with the next child node, so with precompile calls excluded a CALL to a precompile consumes the next real child: a contract call that follows a precompile call in the same function is attributed to the wrong line, and its failure reports CALL_FAILED_ERROR.

Including precompile calls is not enough on its own. Namely, revm-inspectors only sets maybe_precompile when it excludes precompiles, so an included precompile node reads as a code-less contract and a failing precompile reports UNRECOGNIZED_CONTRACT_ERROR instead of PRECOMPILE_ERROR. Both worked before #1278, when the old TraceCollector recorded every call and nested_tracer identified precompiles by address.

This PR records precompile calls in the provider's call traces, like Solidity test call traces, and marks precompile nodes by address before stack traces are built.

What changes

  • edr_solidity::tracing::mark_precompile_calls sets maybe_precompile on every non-root, value-free call to a known precompile address, the same rule revm-inspectors applies when it excludes them. ContractDecoder::populate_call_trace_arena applies it for the provider; foundry's InspectorStack::collect applies it for the Solidity test runner using the precompiles of the last top-level frame (new precompile_addresses field).
  • Provider inspector config adds .set_exclude_precompile_calls(false) to the default_parity() branch (crates/edr_provider/src/observability.rs). The verbose branch uses all(), which already includes them.
  • Fixtures: stack-trace fixtures special-cases/precompile-call-then-contract-failure and special-cases/precompile-failure-propagated, and the Solidity-test repro PrecompileCall.t.sol with repros::test_trace_marks_precompile_calls.

Behaviour changes

  • JSON-RPC call traces (callTraces(), Hardhat 3's -vvvv output) contain a child node per precompile call. The changeset states this.
  • Stack traces attribute a call that follows a precompile call to the right line, and a failing precompile produces a PRECOMPILE_ERROR entry.

Validation

Notes for review

  • Split out of feat: add backwards compatibility for Response::traces #1301, which needs this for Hardhat 2's raw traces (its PrecompileMessages) and now sits on top of this branch.
  • conversion.rs assumes every recorded call is attached to its parent; re-enabling exclude_precompile_calls would bring the misalignment back.

@changeset-bot

changeset-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6c340d6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/edr Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Wodann
Wodann had a problem deploying to github-action-benchmark October 6, 2026 22:12 — with GitHub Actions Error
@Wodann
Wodann force-pushed the fix/call-trace-precompiles branch from e75b047 to 5b2f2cf Compare October 6, 2026 22:13
@Wodann
Wodann temporarily deployed to github-action-benchmark October 6, 2026 22:14 — with GitHub Actions Inactive
@Wodann
Wodann temporarily deployed to github-action-benchmark October 6, 2026 22:20 — with GitHub Actions Inactive
@Wodann
Wodann temporarily deployed to github-action-benchmark October 6, 2026 22:20 — with GitHub Actions Inactive
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.64%. Comparing base (286e40b) to head (6c340d6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1826      +/-   ##
==========================================
+ Coverage   80.57%   80.64%   +0.07%     
==========================================
  Files         469      469              
  Lines       82327    82392      +65     
  Branches    82327    82392      +65     
==========================================
+ Hits        66334    66445     +111     
+ Misses      13744    13697      -47     
- Partials     2249     2250       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Wodann
Wodann force-pushed the fix/call-trace-precompiles branch from 5b2f2cf to e32c3fd Compare October 7, 2026 15:45
@Wodann
Wodann changed the base branch from fix/hh2-patch-default-gas-limit to main October 7, 2026 15:45
@Wodann
Wodann temporarily deployed to github-action-benchmark October 7, 2026 15:45 — with GitHub Actions Inactive
@Wodann
Wodann temporarily deployed to github-action-benchmark October 7, 2026 15:48 — with GitHub Actions Inactive
@Wodann
Wodann temporarily deployed to github-action-benchmark October 7, 2026 15:48 — with GitHub Actions Inactive
…ress

revm-inspectors only identifies precompile calls when it excludes them
from the call trace. Otherwise `CallTraceNode::is_precompile` is false,
so a stack trace treats a precompile as a code-less contract. A failing
precompile then reports `UNRECOGNIZED_CONTRACT_ERROR` instead of
`PRECOMPILE_ERROR`.

`mark_precompile_calls` marks the calls to known precompiles in an
arena, like revm-inspectors does. The provider applies it while
decoding its arenas. The Solidity test runner applies it when its
inspector stack collects an arena, using the precompiles of the last
top-level frame.

Call traces now include precompile calls, like Solidity test call
traces. The previous `default_parity()` inspector config excluded them.

Two stack-trace fixtures cover a contract call that follows a precompile
call, and a failing precompile call.
@Wodann
Wodann force-pushed the fix/call-trace-precompiles branch from e32c3fd to 6c340d6 Compare October 7, 2026 16:34
@Wodann
Wodann requested a deployment to github-action-benchmark October 7, 2026 16:34 — with GitHub Actions In progress
@Wodann
Wodann requested review from popescuoctavian and a balanced review from Copilot and removed request for Copilot October 7, 2026 16:34
@Wodann Wodann self-assigned this Oct 7, 2026
@Wodann
Wodann requested a balanced review from Copilot October 7, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation is consistent across tracing paths and includes focused regression coverage.

0 open findings

What changed in this PR

Fixes precompile handling in provider and Solidity-test call traces to preserve stack-trace alignment and emit PRECOMPILE_ERROR.

Changes:

  • Includes precompile calls in provider traces and marks them by address.
  • Adds provider and Solidity-test regressions for precompile failures.
File Description
.changeset/​quiet-owls-trace.md Documents corrected tracing behavior.
crates/​edr_provider/​src/​observability.rs Includes precompile calls in provider traces.
crates/​edr_solidity/​src/​contract_decoder.rs Marks precompiles before trace decoding.
crates/​edr_solidity/​src/​tracing.rs Adds precompile marking and unit tests.
crates/​foundry/​evm/​evm/​src/​inspectors/​stack.rs Marks Solidity-test trace nodes.
crates/​edr_solidity_tests/​tests/​it/​repros.rs Verifies precompile flags.
crates/​edr_solidity_tests/​tests/​testdata/​via-ir/​repros/​PrecompileCall.t.sol Adds the Solidity regression fixture.
hardhat-tests/​.../​precompile-failure-propagated/​c.sol Adds failing-precompile fixture code.
hardhat-tests/​.../​precompile-failure-propagated/​test.json Specifies expected precompile error.
hardhat-tests/​.../​precompile-call-then-contract-failure/​c.sol Exercises sequential precompile and contract calls.
hardhat-tests/​.../​precompile-call-then-contract-failure/​d.sol Supplies the reverting contract.
hardhat-tests/​.../​precompile-call-then-contract-failure/​test.json Verifies correct source attribution.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Wodann
Wodann temporarily deployed to github-action-benchmark October 7, 2026 17:26 — with GitHub Actions Inactive
@Wodann
Wodann temporarily deployed to github-action-benchmark October 7, 2026 18:04 — with GitHub Actions Inactive
@Wodann
Wodann temporarily deployed to github-action-benchmark October 7, 2026 18:04 — with GitHub Actions Inactive

@popescuoctavian popescuoctavian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this!

@Wodann
Wodann added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit 994eba4 Oct 8, 2026
44 of 45 checks passed
@Wodann
Wodann deleted the fix/call-trace-precompiles branch October 8, 2026 14:01

This branch was previously deployed

1 inactive deployment
github-action-benchmark — 6c340d6c Deployed Oct 7, 2026 by Wodann via Run JS Solidity test runner benchmark #5603
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