Skip to content

perf: record only the opcode step data EDR reads - #1917

Merged
anaPerezGhiglia merged 13 commits into
mainfrom
refactor/edr-custom-record-steps
Nov 10, 2026
Merged

anaPerezGhiglia merged 13 commits into
mainfrom
refactor/edr-custom-record-steps

Conversation

@anaPerezGhiglia

@anaPerezGhiglia anaPerezGhiglia commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

revm-inspectors 0.44 grew CallTraceStep from 192 to 232 B (EIP-8037 state-gas fields). The provider records every opcode step of every transaction, so this increased peak memory and, for calls with many steps, wall time. EDR never reads those fields.

This PR turns off TracingInspector's step recording and records steps in EDR instead, keeping only what EDR reads: the PC and opcode, plus stack and memory snapshots when the provider is configured for them.

Changes

  • SolidityTracingInspector, which already wraps TracingInspector, now records each frame's steps in a compact table (8 B per step).
  • Stack traces and the traces() API read steps from that table. Their output is unchanged.
  • SolidityTracingInspector now builds the wrapped TracingInspector itself, with steps disabled, so they cannot be recorded twice.
  • A differential test checks that the recorded steps match TracingInspector's for every call frame and every stack/memory snapshot setting.
  • BytecodeBuilder moved from the provider tests to edr_test_utils so the differential test can use it.

Solidity test runner

The runner keeps recording steps with TracingInspector, so the provider and the runner now read steps from different sources. They remain compatible: both go through the same stack-trace conversion and heuristics, which read only each step's PC and opcode, and the differential test guarantees that both sources record the same steps.

Moving the runner to the same recorder is a possible follow-up, out of scope here, though it may not be worth it.

revm-inspectors fork

Finding the frame a step belongs to requires TracingInspector::active_trace, which is private. This PR pins a fork of revm-inspectors 0.44.2 where it is public (a one-line change). Upstream PR: paradigmxyz/revm-inspectors#584. Once released, the fork can be dropped.

Benchmarks

Hardhat 3 regression benchmark (run 41910123883), compared like the benchmark action does (one run per commit). Rows are the benchmarks the revm 43 upgrade (#1847) made more than 10% worse:

Benchmark Before revm 43
17db6cd3c
main
b660a0842
This PR revm 43 upgrade This PR vs main Net vs before revm 43
lidofinance-core mocha -vvvv, peak RSS 3134 MB 4517 MB 842 MB +44% −81% −73%
lidofinance-core mocha -vvv, peak RSS 1641 MB 1913 MB 847 MB +17% −56% −48%
rocketpool mocha -vvv, peak RSS 3069 MB 3519 MB 1649 MB +15% −53% −46%
rocketpool mocha -vvvv, peak RSS 8061 MB 9063 MB 1776 MB +12% −80% −78%
ens-contracts vitest -vvvv, peak RSS 1214 MB 1381 MB 434 MB +14% −69% −64%
1inch-solidity-utils mocha -vvvv, peak RSS 816 MB 915 MB 433 MB +12% −53% −47%
ens-contracts-v2 vitest, wall time 12.3 s 16.9 s 7.4 s +37% −56% −40%
ens-contracts-v2 vitest, CPU time 36.1 s 40.3 s 30.9 s +12% −23% −14%

In every row, this PR more than undoes the regression, and every mocha and vitest benchmark ends at or below its value before revm 43. Solidity-test benchmarks stay within −5% to +4% of main; they record steps only when re-running a failing test. All benchmarks: comparison tables.

@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 27f6128

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 Patch

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

@anaPerezGhiglia
anaPerezGhiglia force-pushed the refactor/edr-custom-record-steps branch from 211be66 to 8687cb8 Compare November 2, 2026 18:49
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 2, 2026 18:49 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia added the no changeset needed This PR doesn't require a changeset label Nov 2, 2026
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 2, 2026 18:52 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 2, 2026 18:52 — with GitHub Actions Inactive
@anaPerezGhiglia

Copy link
Copy Markdown
Contributor Author

/bench

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.64865% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.65%. Comparing base (159ab74) to head (27f6128).

Files with missing lines Patch % Lines
crates/edr_solidity/src/recorded_trace_arena.rs 95.04% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1917      +/-   ##
==========================================
+ Coverage   81.57%   81.65%   +0.08%     
==========================================
  Files         473      475       +2     
  Lines       84228    84612     +384     
  Branches    84228    84612     +384     
==========================================
+ Hits        68707    69091     +384     
+ Misses      13232    13228       -4     
- Partials     2289     2293       +4     

☔ 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.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for 8687cb83d0ed against Hardhat main (benchmarks matching test solidity*,test mocha*,test vitest*).

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

❌ Regression benchmark failed for 8687cb83d0ed against Hardhat main. This is either a detected performance regression or an infrastructure failure — see the run for details.

View workflow run

@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 3, 2026 14:50 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia changed the title refactor: custom RecordedTraceArena only tracks fields EDR uses perf: record only the opcode step data EDR reads Nov 3, 2026
@anaPerezGhiglia
anaPerezGhiglia requested a balanced review from Copilot November 3, 2026 14:59
@anaPerezGhiglia
anaPerezGhiglia force-pushed the refactor/edr-custom-record-steps branch from 573d8a5 to fb7ea30 Compare November 3, 2026 15:00
@anaPerezGhiglia

Copy link
Copy Markdown
Contributor Author

/bench

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.

🟡 Changes recommended

The differential test never compares creation-frame steps because HALTER exhausts forwarded gas, leaving ROOT below CREATE’s 32,000-gas base cost.

1 open issue
What changed in this PR

This PR reduces provider tracing memory use by recording only the opcode data EDR consumes, while keeping the Solidity test runner on its existing recorder.

Changes:

  • Adds compact per-frame steps and routes provider stack traces and JavaScript trace output through them.
  • Adds differential tests and shares the bytecode builder across test suites.
  • Pins a revm-inspectors fork that exposes the active trace.
File Description
crates/​edr_test_utils/​src/​lib.rs Exports shared bytecode utilities.
crates/​edr_test_utils/​src/​bytecode.rs Shares the builder and adds variable-length pushes.
crates/​edr_solidity/​tests/​recorded_steps.rs Compares compact steps with upstream recording.
crates/​edr_solidity/​src/​tracing.rs Records compact steps and optional snapshots.
crates/​edr_solidity/​src/​solidity_stack_trace.rs Supports stack traces from compact steps.
crates/​edr_solidity/​src/​recorded_steps.rs Defines compact step storage and accessors.
crates/​edr_solidity/​src/​nested_trace/​conversion.rs Converts either step source into nested traces.
crates/​edr_solidity/​src/​nested_trace.rs Exposes conversion with separate step storage.
crates/​edr_solidity/​src/​lib.rs Exports the recorded-steps module.
crates/​edr_solidity/​Cargo.toml Adds differential-test dependencies.
crates/​edr_provider/​tests/​integration/​eip8246.rs Uses shared bytecode utilities.
crates/​edr_provider/​tests/​integration/​eip8037.rs Uses shared bytecode utilities.
crates/​edr_provider/​tests/​integration/​eip8024.rs Uses shared bytecode utilities.
crates/​edr_provider/​tests/​integration/​eip7997.rs Uses the shared bytecode builder.
crates/​edr_provider/​tests/​integration/​eip7954.rs Uses shared opcode exports.
crates/​edr_provider/​tests/​integration/​eip7843.rs Uses shared bytecode utilities.
crates/​edr_provider/​tests/​integration/​eip7778.rs Uses shared bytecode utilities.
crates/​edr_provider/​tests/​integration/​eip2780.rs Uses shared bytecode utilities.
crates/​edr_provider/​tests/​integration/​disable_block_gas_limit.rs Uses shared bytecode utilities.
crates/​edr_provider/​tests/​common/​mod.rs Removes the local bytecode module export.
crates/​edr_provider/​tests/​common/​gas_reporter.rs Uses shared bytecode utilities.
crates/​edr_provider/​src/​requests/​eth/​call.rs Returns recorded trace arenas.
crates/​edr_provider/​src/​observability.rs Disables upstream steps and collects compact traces.
crates/​edr_provider/​src/​lib.rs Updates provider response trace types.
crates/​edr_provider/​src/​error.rs Builds failure stack traces from compact steps.
crates/​edr_provider/​src/​debug_trace.rs Updates accompanying call-trace storage.
crates/​edr_provider/​src/​data/​gas.rs Carries compact traces through gas estimation.
crates/​edr_provider/​src/​data.rs Updates execution result trace types.
crates/​edr_napi/​src/​trace.rs Converts compact steps into JavaScript trace messages.
crates/​edr_napi/​src/​provider/​response.rs Updates response memory-accounting test fixtures.
crates/​edr_napi_core/​src/​spec.rs Carries recorded arenas in binding responses.
Cargo.toml Pins the inspector fork exposing active_trace.
Cargo.lock Locks the fork and added test dependencies.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Starting regression benchmark for fb7ea30687ab against Hardhat main (benchmarks matching test solidity*,test mocha*,test vitest*).

@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 3, 2026 16:53 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 3, 2026 16:55 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 3, 2026 16:55 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

✅ Regression benchmark passed for fb7ea30687ab against Hardhat main.

View workflow run

@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 3, 2026 23:10 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia marked this pull request as ready for review November 3, 2026 23:10
@anaPerezGhiglia
anaPerezGhiglia force-pushed the refactor/edr-custom-record-steps branch from 215de82 to 67997e2 Compare November 6, 2026 15:13
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 6, 2026 15:14 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia force-pushed the refactor/edr-custom-record-steps branch from 67997e2 to 5805944 Compare November 6, 2026 15:59
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 6, 2026 15:59 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 6, 2026 16:06 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 6, 2026 16:06 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia force-pushed the refactor/edr-custom-record-steps branch from a8f74df to 27f6128 Compare November 10, 2026 14:27
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 10, 2026 14:27 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 10, 2026 14:31 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia temporarily deployed to github-action-benchmark November 10, 2026 14:31 — with GitHub Actions Inactive
@anaPerezGhiglia
anaPerezGhiglia added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit fc977dd Nov 10, 2026
64 checks passed
@anaPerezGhiglia
anaPerezGhiglia deleted the refactor/edr-custom-record-steps branch November 10, 2026 15:51

This branch was previously deployed

1 inactive deployment
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