Skip to content

fix(rpcv10): recompute trace if initial_reads requested#3583

Merged
brbrr merged 3 commits intomainfrom
fix/initial-reads-cache
Apr 29, 2026
Merged

fix(rpcv10): recompute trace if initial_reads requested#3583
brbrr merged 3 commits intomainfrom
fix/initial-reads-cache

Conversation

@brbrr
Copy link
Copy Markdown
Contributor

@brbrr brbrr commented Apr 24, 2026

There is an ordering issue with RPC trace cache for block transactions - we cache only by block hash, so we could end up with a situation where the cache was populated with trace without initial reads, and when the caller request same tries but with initial_reads, we'd just return cached response (with missing initial_reads)

@brbrr brbrr requested a review from MaksymMalicki April 24, 2026 21:05
@brbrr brbrr self-assigned this Apr 24, 2026
Copilot AI review requested due to automatic review settings April 24, 2026 21:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an ordering issue in the RPC v10 block trace cache where a cached trace computed without initial reads could be incorrectly reused for a later request with RETURN_INITIAL_READS.

Changes:

  • Adjusts traceBlockTransactions cache-hit logic to re-trace via VM when initial reads are requested but missing in the cached entry.
  • Avoids re-fetching from feeder gateway when cached traces already exist, while still returning an empty InitialReads when requested (since GW can’t supply them).
  • Adds tests to verify cache coherence across different call orderings (TraceTransaction then TraceBlockTransactions, repeat calls, and flag/no-flag sequences).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
rpc/v10/trace.go Updates cache-hit and feeder-gateway logic to prevent returning a cached response missing initial reads when RETURN_INITIAL_READS is requested.
rpc/v10/trace_test.go Adds regression tests that validate the cache is not “poisoned” by earlier calls without initial reads and that cache reuse behaves as intended.

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

Comment thread rpc/v10/trace.go
Comment thread rpc/v10/trace.go
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.85%. Comparing base (4310ba5) to head (ccf42cf).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3583      +/-   ##
==========================================
+ Coverage   75.77%   75.85%   +0.07%     
==========================================
  Files         380      380              
  Lines       34190    34187       -3     
==========================================
+ Hits        25909    25932      +23     
+ Misses       6456     6427      -29     
- Partials     1825     1828       +3     

☔ View full report in Codecov by Sentry.
📢 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.

@brbrr brbrr marked this pull request as draft April 24, 2026 21:40
@brbrr brbrr marked this pull request as ready for review April 28, 2026 11:06
Copy link
Copy Markdown
Contributor

@EgeCaner EgeCaner left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

@brbrr brbrr merged commit d3386e8 into main Apr 29, 2026
47 of 49 checks passed
@brbrr brbrr deleted the fix/initial-reads-cache branch April 29, 2026 12:29
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.

4 participants