perf(rpc): add progressive block trace caching - #4021
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4021 +/- ##
==========================================
+ Coverage 79.19% 79.24% +0.05%
==========================================
Files 464 467 +3
Lines 35741 35947 +206
==========================================
+ Hits 28305 28487 +182
- Misses 7427 7451 +24
Partials 9 9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
58d79fc to
6ab7d60
Compare
|
Claude finished @danielntmd's task in 6m 39s —— View job Review complete
I focused on concurrency correctness in the new Findings: no blockers or bugs. The single-flight-per-block design, panic-safe waiter release ( Two non-blocking nits posted inline:
One thing worth double-checking with the author rather than a code issue: the VM is now always invoked with Note: I wasn't able to run |
|
Claude finished @danielntmd's task in 4m 16s —— View job Review complete
This PR was synchronized with a new commit ( New commit review: correct, no issues.
Severity: none (nit/important/blocker) — no new issues found. The two nits from the earlier review round (feeder-gateway path lacking single-flight coordination, and Note: |
Collect initial reads on demand, replaying the block when cached traces lack requested reads. Shape responses at the RPC boundary and share finalised trace routing. Publish immutable cache records with per-block flight coordination. Trim test fixtures and strengthen checkpoint and prefix preservation coverage.

User description
Summary
TraceTransaction currently executes every transaction in a finalized block on a cache miss, even when the requested transaction appears near the beginning.
This PR caches successful tracing progress from the beginning of each block (a prefix). Later requests reconstruct the state at the cached point and execute only the remaining transactions through the requested target (the missing suffix). Only one request extends a block at a time, while different blocks can be traced concurrently.
Successful execution publishes a new cache record while existing cached traces remain available to readers.
Workflow
Cache Invariants
Tracing Behavior
Benchmarks
Cold
starknet_traceTransactionat 100 VUsBroad corpus sample size: 1,000
Everything else: 200
Interleaved
traceTransaction->traceBlockTransactionsSample size: 200
PR Type
Enhancement, Tests
Description
Add progressive caching for block transaction traces
Optimize trace requests with prefix-based reconstruction
Coordinate in-flight block trace extensions concurrently
Replay blocks to fetch missing initial reads
File Walkthrough
2 files
Remove nil check from adaptVMInitialReadsReplace generic trace cache with custom blockTraceCache4 files
Add emptyInitialReads helper functionIntegrate progressive caching and trace targets in block tracingImplement concurrent block trace cache with flight coordinationAdd logic for progressive trace execution and state checkpoints3 files
Add unit tests for the block trace cacheAdd unit tests for progressive trace execution logicUpdate and expand trace handler tests for cache coherence