feat: implement bal cache as a part of BlockChainProvider#22952
Closed
Soubhik-10 wants to merge 43 commits into
Closed
feat: implement bal cache as a part of BlockChainProvider#22952Soubhik-10 wants to merge 43 commits into
Soubhik-10 wants to merge 43 commits into
Conversation
Introduces an in-memory LRU cache for Block Access Lists (BALs) in the Engine API. BALs are cached when payloads are validated as VALID via newPayload. - Add BalCache with internal Arc for cheap cloning - Store BALs keyed by block hash with block number index for range queries - Implement engine_getBALsByHashV1 and engine_getBALsByRangeV1 - Add metrics for cache inserts/hits/misses Per EIP-7928, the EL should retain BALs for the weak subjectivity period (~3533 epochs). This initial implementation uses a configurable LRU cache (default 1024 entries) as a starting point.
- Collapse nested if statements using let-chains - Add backticks around BTreeMap in doc comment
Ensures caller knows returned BALs correspond to contiguous blocks [start, start + len)
Extract num_hash and BAL before calling new_payload to avoid cloning the entire ExecutionData payload.
Replace LRU-based cache with simpler design: - Use HashMap<BlockHash, Bytes> for O(1) hash lookups - Use BTreeMap<BlockNumber, BlockHash> as source of truth for eviction - Evict oldest (lowest) block numbers when at capacity - Handle reorgs by removing old hash when block number is replaced This is simpler, more predictable, and removes schnellru dependency.
# Conflicts: # crates/rpc/rpc-engine-api/src/engine_api.rs
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.
No description provided.