Repository navigation
fix: include precompile calls in call traces and identify them by address - #1826
Conversation
🦋 Changeset detectedLatest commit: 6c340d6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
e75b047 to
5b2f2cf
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
5b2f2cf to
e32c3fd
Compare
…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.
e32c3fd to
6c340d6
Compare
There was a problem hiding this comment.
🟢 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.
popescuoctavian
left a comment
There was a problem hiding this comment.
LGTM, thanks for fixing this!
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 aCALLto 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 reportsCALL_FAILED_ERROR.Including precompile calls is not enough on its own. Namely, revm-inspectors only sets
maybe_precompilewhen it excludes precompiles, so an included precompile node reads as a code-less contract and a failing precompile reportsUNRECOGNIZED_CONTRACT_ERRORinstead ofPRECOMPILE_ERROR. Both worked before #1278, when the oldTraceCollectorrecorded every call andnested_traceridentified 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_callssetsmaybe_precompileon 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_arenaapplies it for the provider; foundry'sInspectorStack::collectapplies it for the Solidity test runner using the precompiles of the last top-level frame (newprecompile_addressesfield)..set_exclude_precompile_calls(false)to thedefault_parity()branch (crates/edr_provider/src/observability.rs). The verbose branch usesall(), which already includes them.special-cases/precompile-call-then-contract-failureandspecial-cases/precompile-failure-propagated, and the Solidity-test reproPrecompileCall.t.solwithrepros::test_trace_marks_precompile_calls.Behaviour changes
callTraces(), Hardhat 3's-vvvvoutput) contain a child node per precompile call. The changeset states this.PRECOMPILE_ERRORentry.Validation
main(the first reports line 12 instead of 10, the second reports the wrong error) and pass here; both pass on the pre-refactor: unify provider & soldity test tracing architecture #1278TraceCollectorbuild.Response::traces#1301 head that first carried this change (run 37409980640): 99 entries, no time or cpu alert; the-vvvventries that carry arenas are unchanged.Notes for review
Response::traces#1301, which needs this for Hardhat 2's raw traces (itsPrecompileMessages) and now sits on top of this branch.conversion.rsassumes every recorded call is attached to its parent; re-enablingexclude_precompile_callswould bring the misalignment back.