feat(engine): expose engine caches to SDK consumers#23049
Closed
yongkangc wants to merge 10 commits into
Closed
Conversation
…d cache lifecycle Adds a Reth-owned `EngineSharedCaches<Evm>` type that groups execution cache, sparse trie cache, and precompile cache under a single facade created by the node launcher and threaded through the engine validator path — following the same ownership pattern as `ChangesetCache`. This gives a stable public ownership boundary for later downstream consumption without changing internal hot-path behavior.
Contributor
✅ Changelog found on PR. |
- Remove SharedPreservedSparseTrie wrapper; use PayloadSparseTrieCache directly in PayloadProcessor (zero-value delegation layer) - Make EngineSharedCaches fields pub, remove getter methods - Remove Clone derive from EngineSharedCaches (facade is created and moved, not cloned) - Fix trait inversion: make build_tree_validator_with_caches the required method, provide default for build_tree_validator that forwards with EngineSharedCaches::default() (eliminates silent cache-drop footgun and infinite-recursion trap) - Remove redundant build_tree_validator override from BasicEngineValidatorBuilder (trait default handles it) - Clean up doc comments and rustdoc links
Contributor
Author
|
derek bench |
- Revert trait inversion: build_tree_validator stays required, build_tree_validator_with_caches is a default that drops caches and forwards (no semver break for external impls) - Add #[non_exhaustive] to EngineSharedCaches (adding fields later won't break external destructuring/construction) - Add Clone derive (pub fields make no-Clone unenforceable)
Contributor
Author
|
@codex review |
Contributor
Author
|
derek bench |
Member
|
cc @yongkangc ✅ Benchmark complete! View job Benchmark Results
500 blocks Wait Time BreakdownPersistence Wait
Trie Cache Update Wait
Execution Cache Update Wait
ChartsGrafana Dashboard |
Member
|
Superseded by #23242 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes RETH-505
Problem
Engine-tree caches (execution cache, sparse trie, precompile cache) are created inside
BasicEngineValidatorandPayloadProcessor. The launcher has no handle to them, so payload builders can't reuse engine caches like the precompile cache.Solution
New
EngineSharedCaches<Evm>struct with pub fields. The launcher creates it and passes it throughbuild_tree_validator.Before
Payload builders have no access to engine caches. To share them, an SDK consumer would have to:
BasicEngineValidatorentirely and reimplement the validator from scratchEngineValidatorBuilderimplgraph TD L[EngineNodeLauncher] -->|build_tree_validator| BEV[BasicEngineValidator] BEV -->|"new(precompile_cache_map)"| PP[PayloadProcessor] L -->|no cache handle| PB[PayloadBuilder] BEV -.->|creates internally| PCM1["PrecompileCacheMap::default()"] PP -.->|creates internally| EC["PayloadExecutionCache::default()"] PP -.->|creates internally| SST["SharedPreservedSparseTrie::default()"] style PCM1 fill:#f96,stroke:#333 style EC fill:#f96,stroke:#333 style SST fill:#f96,stroke:#333 style PB fill:#eee,stroke:#999,stroke-dasharray: 5 5After
build_tree_validatornow takesEngineSharedCachesas a parameter. SDK consumers can clone whichever cache handle they need before forwarding the bundle:shared_caches.precompile_cache_map.clone())BasicEngineValidatoras normalgraph TD L[EngineNodeLauncher] -->|creates| ESC["EngineSharedCaches::default()"] L -->|"build_tree_validator(shared_caches)"| BEV[BasicEngineValidator] BEV -->|"new(shared_caches)"| PP[PayloadProcessor] ESC -.->|".precompile_cache_map.clone()"| PB[PayloadBuilder] style ESC fill:#6f9,stroke:#333 style PB fill:#69f,stroke:#333Expected Impact
build_tree_validatorsignature now includesEngineSharedCaches#[non_exhaustive]onEngineSharedCachesprotects against future field additions