Repository navigation
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/tracing-back-compat #1536 +/- ##
============================================================
+ Coverage 80.10% 80.13% +0.03%
============================================================
Files 445 445
Lines 76436 76572 +136
Branches 76436 76572 +136
============================================================
+ Hits 61228 61363 +135
- Misses 13086 13087 +1
Partials 2122 2122 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Reduces non-verbose raw-tracing overhead by capturing only the top-of-stack value per EVM step (instead of cloning full stack snapshots), while preserving the JS-facing TracingStep.stack.last() semantics and keeping verbose tracing behavior unchanged.
Changes:
- Added optional per-step “top-of-stack” capture to
SolidityTracingInspectorand post-processing to write those values into arena steps in execution order. - Removed
StackSnapshotType::Fullusage in non-verbose tracing configuration and introduced a lightweight top-of-stack capture gate. - Added unit tests for execution-order assignment across nested frames and a NAPI integration test covering nested calls.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/edr_solidity/src/tracing.rs | Captures per-step stack tops and writes them into trace steps in execution order; adds unit tests. |
| crates/edr_provider/src/observability.rs | Stops recording full stack snapshots in non-verbose mode; enables lightweight top-of-stack capture when traces are included. |
| crates/edr_napi/test/provider.ts | Adds an integration test asserting correct per-step top-of-stack across nested call frames. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
79caff6 to
16dcddd
Compare
9acaaac to
a8ef4d2
Compare
16dcddd to
f25666b
Compare
Recording `StackSnapshotType::Full` clones the entire EVM stack on every step of every transaction, causing up to a 2.45x slowdown in the provider benchmarks - paid even when the arena is discarded (`include_call_traces` defaults to `None`). The non-verbose `traces()` output only ever reads the top of the stack at step start, so record exactly that, the way the pre-unification `TraceCollector` did. `SolidityTracingInspector` now captures `interp.stack.last()` in its `step` hook (one `U256` copy, no per-step allocation) into a flat, execution-ordered vector, and writes the values into the collected arena's steps by following each node's `ordering` depth-first. The napi conversion is unchanged: it still reads `step.stack.last()`. Capture is skipped when raw traces cannot reach a response (`include_call_traces == None`) or when verbose tracing records full snapshots anyway, so Hardhat 3's default path has zero overhead.
f25666b to
b5184e1
Compare
|
Superseded by #1544 |
On top of #1301 (
feat/tracing-back-compat) to resolve the benchmark regression of up to 2.45x reported there.PR filed on paradigmxyz/revm-inspectors#468 to add a
StackSnapshotType::Top. We will need to upgrade to revm 41 when it does merge.Claude summary
Problem
To expose the top of the stack through the non-verbose
Response::traces()output, #1301 setsStackSnapshotType::Full, which clones the entire EVM stack on every step of every transaction. The cost is paid unconditionally — even when the arena is discarded (includeCallTracesdefaults toIncludeTraces::None, the Hardhat 3 default). The consumer only ever readsstep.stack.last()in non-verbose mode, and no releasedrevm-inspectors(0.33–0.41) offers a top-of-stack-only snapshot type.Approach
Record exactly what the output needs, the way the pre-unification
TraceCollectordid (Stack::Top):SolidityTracingInspector::stepcapturesinterp.stack.last().copied()— oneU256copy per step into a flat vector, no per-step allocation.collect()/take()time, the captured values are written into the arena's steps as single-elementstacksnapshots, following each node'sorderingdepth-first (i.e. execution order, which matches capture order one-to-one).Responsemarshalling, and the JS-visibleTracingStep.stacksemantics are unchanged: non-verbose still readsstep.stack.last().Resulting cost per configuration:
includeCallTraces: None(Hardhat 3 default)mainincludeCallTraces: All, non-verbose (Hardhat 2)U256copy per step (the historical baseline)all())Anticipated questions
StackSnapshotType? Now filed as feat: add top-of-stack snapshot type paradigmxyz/revm-inspectors#468 (StackSnapshotType::Top, drop-in for the mechanism here: samestep.stackfield, same pre-op timing,.last()consumers unchanged). If accepted, it lands on the revm-41 line, so we can only adopt it after our next revm major bump — at which point the capture,write_stack_tops, and the ordering DFS in this PR get deleted in favor ofset_stack_snapshots(StackSnapshotType::Top), with the tests kept as the contract. Until then, this PR is the fix that works on revm 38 today, and it stands alone if the upstream PR stalls.includeCallTraces != None? Arenas are still recorded in that mode (for stack-trace generation and internal-OOG detection), but nothing on those paths readsstep.stack, so capturing tops would be pure waste on the default path..expects in the ordering DFS: the indices come from the arena's ownordering/childreninvariants; a violation means a corrupt arena, where a loud failure beats silently emitting misaligned traces. The twodebug_asserts guard the capture/step count alignment in both directions; in release builds a mismatch degrades to steps without a stack (rendered as an empty stack), never wrong values.Testing
edr_napitest with a nestedCALLacross two contracts, asserting per-step tops in both frames — including the callee frame starting empty and the caller's post-CALLstep seeing the success flag. This fails loudly on any cross-frame misalignment or off-by-one.Response::traces#1301 contract tests ("top of the stack by default", verbose full stacks, memory,debug_traceTransaction/debug_traceCall) pass unchanged;debug_traceTransactionstructLogs are unaffected as they come from the separateDebugInspector.edr-benchmarkjob fails on this PR, and that is expected. The base branch's hardhat 2.28.6 patch enablesincludeCallTraces: Allat provider creation, and the JS scenario benchmark instantiates its provider through that patched hardhat — so benchmarks on this stack now measure the traces-on configuration against a stored traces-off baseline. The +14–28% alert is the cost ofAllwith top-of-stack capture (oneU256copy per step plus single-element stack snapshots at collect time), i.e. the historical HH2 baseline — down from up to 2.45x with full-stack snapshots, which is the regression this PR fixes. The alert is accepted deliberately. perf: make raw trace collection demand-driven #1541 (stacked on this PR) makes the remaining cost lazy and lets Hardhat 2 only enable trace collection while the vm trace bridge has listeners, which returns the benchmark to theNonepath. (The fluctuating single-suite alerts in the Solidity test runner job are unrelated noise: that path doesn't go through the hardhat provider.)