Skip to content

refactor(lru): switch LRU implementation to golang-lru#3674

Open
brbrr wants to merge 3 commits into
mainfrom
update/switch-lru-implementation
Open

refactor(lru): switch LRU implementation to golang-lru#3674
brbrr wants to merge 3 commits into
mainfrom
update/switch-lru-implementation

Conversation

@brbrr
Copy link
Copy Markdown
Contributor

@brbrr brbrr commented May 22, 2026

No description provided.

brbrr added 2 commits May 22, 2026 16:56
Rationale is that LRU returns a error if the size is <= 0, and in our
case, all the size parameters are comptime known constants, so
discarding a error is fine at the moment, but panics (hopefully) protect
us in the future in case of mis-use
@brbrr brbrr self-assigned this May 22, 2026
Copilot AI review requested due to automatic review settings May 22, 2026 15:14
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

This PR refactors the codebase’s LRU cache usage to rely on github.com/hashicorp/golang-lru/v2 (and simplelru) instead of the previous go-ethereum LRU helpers, centralizing construction logic in utils.

Changes:

  • Added utils.NewLRU and utils.NewSimpleLRU helpers to standardize LRU construction.
  • Migrated RPC trace caches and pending pre-latest caching to HashiCorp LRU implementations.
  • Updated aggregated bloom filter cache to use the new LRU and adjusted its constructor/tests accordingly.

Reviewed changes

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

Show a summary per file
File Description
utils/lru.go Introduces shared constructors for thread-safe and non-thread-safe LRU caches.
sync/pending_polling.go Switches the pre-latest “seen-by-parent” cache to simplelru via utils.NewSimpleLRU.
rpc/v8/handlers.go Updates RPC v8 handler trace cache construction to use utils.NewLRU.
rpc/v9/handlers.go Updates RPC v9 handler trace cache construction to use utils.NewLRU.
rpc/v10/handlers.go Updates RPC v10 handler trace cache construction to use utils.NewLRU.
blockchain/aggregated_bloom_filter_cache.go Replaces the previous LRU cache with HashiCorp’s cache and uses utils.NewLRU; changes constructor signature.
blockchain/blockchain.go Adjusts blockchain initialization to match the aggregated bloom cache constructor change.
blockchain/aggregated_bloom_filter_cache_test.go Updates tests to use the new aggregated bloom cache constructor and constant size.
go.mod Adds github.com/hashicorp/golang-lru/v2 as a direct dependency.

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

Comment thread blockchain/aggregated_bloom_filter_cache.go
Comment thread utils/lru.go
@brbrr brbrr temporarily deployed to Development May 22, 2026 15:19 — with GitHub Actions Inactive
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.30%. Comparing base (6fc5100) to head (bfeda6c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3674      +/-   ##
==========================================
+ Coverage   76.16%   76.30%   +0.14%     
==========================================
  Files         396      397       +1     
  Lines       36585    36540      -45     
==========================================
+ Hits        27865    27882      +17     
+ Misses       6743     6681      -62     
  Partials     1977     1977              

☔ 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 temporarily deployed to Development May 22, 2026 15:58 — with GitHub Actions Inactive
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.

2 participants