Skip to content

refactor(provider): introduce ObservedExecution to encapsulate EVM observer lifecycle#1461

Merged
anaPerezGhiglia merged 6 commits into
mainfrom
chore/refactor-execution-observability
Jun 9, 2026
Merged

refactor(provider): introduce ObservedExecution to encapsulate EVM observer lifecycle#1461
anaPerezGhiglia merged 6 commits into
mainfrom
chore/refactor-execution-observability

Conversation

@anaPerezGhiglia

Copy link
Copy Markdown
Contributor

Context

While implementing gas estimation improvements (#1455), several structural issues in the existing code became apparent: the EVM observer lifecycle was repeated manually at every call site, and estimate_gas logic was spread across data.rs rather than living in gas.rs alongside its helpers. This PR addresses those improvements independently to avoid mixing concerns and enable focused review

Changes

Introduces ObservedExecution<T> and observe_execution in observability.rs to encapsulate the observer lifecycle (create → run → collect_and_report), replacing the manual pattern repeated at every EVM call site.

Key changes:

  • observe_execution wraps observer creation and collection into a single call
  • ObservedExecution::into_result_and_traces provides a consuming accessor for the execution result and filtered call traces
  • EvmObservedData::into_call_traces / CallResultWithMetadata::into_call_traces are consuming filter methods that replace inline if/else blocks
  • estimate_gas is moved from data.rs into gas.rs, with check_gas_limit and binary_search_estimation refactored to take a shared Context struct; this also eliminates the one call_trace_arena.clone() that existed in the previous implementation

@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 5, 2026 20:10 — with GitHub Actions Inactive
@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cd28569

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@anaPerezGhiglia anaPerezGhiglia added the no changeset needed This PR doesn't require a changeset label Jun 5, 2026
@anaPerezGhiglia anaPerezGhiglia had a problem deploying to github-action-benchmark June 5, 2026 20:12 — with GitHub Actions Error
@anaPerezGhiglia anaPerezGhiglia had a problem deploying to github-action-benchmark June 5, 2026 20:12 — with GitHub Actions Error
@anaPerezGhiglia anaPerezGhiglia requested a review from Copilot June 5, 2026 20:17
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 5, 2026 20:17 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia had a problem deploying to github-action-benchmark June 5, 2026 20:19 — with GitHub Actions Error
@anaPerezGhiglia anaPerezGhiglia had a problem deploying to github-action-benchmark June 5, 2026 20:19 — with GitHub Actions Error

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.

Pull request overview

This PR refactors EDR provider EVM observability and gas estimation flow by introducing an ObservedExecution<T> wrapper and observe_execution helper to centralize the EVM observer lifecycle (create → execute → collect/report), while also relocating estimate_gas into data/gas.rs alongside its helpers.

Changes:

  • Added observe_execution + ObservedExecution<T> to standardize EVM observer lifecycle handling and trace extraction.
  • Introduced consuming “filter-to-traces” helpers (EvmObservedData::into_call_traces, CallResultWithMetadata::into_call_traces) to replace repeated inline if include_call_traces { ... } blocks.
  • Moved/refactored estimate_gas into data/gas.rs and introduced a shared Context to reduce duplication and avoid unnecessary cloning.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/edr_provider/src/requests/hardhat/miner.rs Refactors call trace extraction to use EvmObservedData::into_call_traces.
crates/edr_provider/src/requests/eth/evm.rs Refactors call trace extraction to use EvmObservedData::into_call_traces.
crates/edr_provider/src/observability.rs Introduces ObservedExecution<T> and observe_execution to encapsulate observer lifecycle and filtered trace retrieval.
crates/edr_provider/src/debug_trace.rs Switches debug tracing flow to use observe_execution and into_result_and_traces.
crates/edr_provider/src/data/gas.rs Moves/refactors gas estimation into gas.rs with shared Context and observer lifecycle consolidation.
crates/edr_provider/src/data.rs Adopts observe_execution at call sites, adds conversion from ObservedExecution to CallResultWithMetadata, and delegates gas estimation into gas.rs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/edr_provider/src/data/gas.rs Outdated
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.37%. Comparing base (bccd377) to head (cd28569).

Files with missing lines Patch % Lines
crates/edr_provider/src/data/gas.rs 87.71% 9 Missing and 5 partials ⚠️
crates/edr_provider/src/data.rs 97.01% 0 Missing and 2 partials ⚠️
crates/edr_provider/src/observability.rs 95.91% 0 Missing and 2 partials ⚠️
crates/edr_provider/src/debug_trace.rs 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1461      +/-   ##
==========================================
+ Coverage   79.34%   79.37%   +0.02%     
==========================================
  Files         445      445              
  Lines       76465    76480      +15     
  Branches    76465    76480      +15     
==========================================
+ Hits        60673    60707      +34     
+ Misses      13660    13651       -9     
+ Partials     2132     2122      -10     

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

@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 5, 2026 20:34 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia requested a review from a team June 5, 2026 20:34
@anaPerezGhiglia anaPerezGhiglia marked this pull request as ready for review June 5, 2026 20:35
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 5, 2026 20:36 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 5, 2026 20:36 — with GitHub Actions Inactive
@Wodann Wodann requested review from Wodann and removed request for a team June 6, 2026 15:13
Unify gas structs into gas::Context

Unify observe_execution logic, simplify check_gas function

Organize and cleanup code

Fix refactor: avoid cloning traces
@anaPerezGhiglia anaPerezGhiglia force-pushed the chore/refactor-execution-observability branch from cfe3428 to 2be6236 Compare June 8, 2026 13:45
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 8, 2026 13:45 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 8, 2026 14:06 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 8, 2026 14:06 — with GitHub Actions Inactive

@Wodann Wodann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for simplifying the code. I have one major concern, re. performance impact of the change.

Comment thread crates/edr_provider/src/data/gas.rs Outdated
Comment thread crates/edr_provider/src/data/gas.rs
Comment thread crates/edr_provider/src/observability.rs
Comment thread crates/edr_provider/src/data/gas.rs
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 8, 2026 21:39 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 8, 2026 21:41 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia temporarily deployed to github-action-benchmark June 8, 2026 21:41 — with GitHub Actions Inactive
@anaPerezGhiglia anaPerezGhiglia added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit 88beb95 Jun 9, 2026
56 of 57 checks passed
@anaPerezGhiglia anaPerezGhiglia deleted the chore/refactor-execution-observability branch June 9, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changeset needed This PR doesn't require a changeset

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants