fix(cache): reduce tx cache retention#3299
Conversation
📝 WalkthroughWalkthroughThis PR reduces transaction cache retention from 24 hours to 30 minutes to prevent out-of-memory conditions during heavy transaction load, and adjusts the cleanup frequency to run at one-tenth the retention interval with a 15-second minimum. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @julienrbrt's task in 1m 22s —— View job Code Review
This is a small, focused fix to reduce memory pressure from the transaction seen-hash cache. The changes are clean. A few observations:
|
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3299 +/- ##
==========================================
+ Coverage 62.48% 62.50% +0.02%
==========================================
Files 122 122
Lines 13047 13047
==========================================
+ Hits 8152 8155 +3
+ Misses 4009 4008 -1
+ Partials 886 884 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
block/internal/cache/manager.go (1)
29-30: Consider making tx retention configurable instead of fixed.
At Line 30, a single hardcoded retention may be too aggressive or too lenient across different networks/workloads. Keeping30mas default but exposing config would give operators safer tuning control.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@block/internal/cache/manager.go` around lines 29 - 30, Replace the hardcoded DefaultTxCacheRetention with a configurable retention by keeping DefaultTxCacheRetention as the default value but adding a configurable field/parameter (e.g., TxCacheRetention) to the cache manager config or constructor; update the cache manager initialization (where New/Init for the manager is called) to accept an optional retention value (read from a config struct or env flag) and fall back to DefaultTxCacheRetention when unset, and ensure any uses of DefaultTxCacheRetention (symbol DefaultTxCacheRetention) are switched to reference the configured retention field so operators can tune retention per deployment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@block/internal/cache/manager.go`:
- Around line 29-30: Replace the hardcoded DefaultTxCacheRetention with a
configurable retention by keeping DefaultTxCacheRetention as the default value
but adding a configurable field/parameter (e.g., TxCacheRetention) to the cache
manager config or constructor; update the cache manager initialization (where
New/Init for the manager is called) to accept an optional retention value (read
from a config struct or env flag) and fall back to DefaultTxCacheRetention when
unset, and ensure any uses of DefaultTxCacheRetention (symbol
DefaultTxCacheRetention) are switched to reference the configured retention
field so operators can tune retention per deployment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e5c5a916-8385-4d53-aecb-fa45a37152db
📒 Files selected for processing (3)
CHANGELOG.mdblock/internal/cache/manager.goblock/internal/reaping/reaper.go
Overview
Extract and tweak some useful improvements from #3290
Summary by CodeRabbit