Skip to content

feat: implement bal cache as a part of BlockChainProvider#22952

Closed
Soubhik-10 wants to merge 43 commits into
paradigmxyz:bal-devnet-3from
Soubhik-10:bal-more-rpc
Closed

feat: implement bal cache as a part of BlockChainProvider#22952
Soubhik-10 wants to merge 43 commits into
paradigmxyz:bal-devnet-3from
Soubhik-10:bal-more-rpc

Conversation

@Soubhik-10
Copy link
Copy Markdown
Contributor

No description provided.

mattsse and others added 30 commits January 21, 2026 11:35
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
@github-actions github-actions Bot added the S-stale This issue/PR is stale and will close with no further activity label Apr 3, 2026
@emmajam emmajam deleted the branch paradigmxyz:bal-devnet-3 April 28, 2026 12:09
@emmajam emmajam closed this Apr 28, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Reth Tracker Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-stale This issue/PR is stale and will close with no further activity

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants