chore: cherry-pick precompile cache memory limit fix from paradigmxyz/reth v1.11.4#188
Merged
Merged
Conversation
actioncli
approved these changes
May 14, 2026
joey0612
approved these changes
May 14, 2026
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.
Summary
Cherry-picks upstream commit
2ac58a2(tagged asv1.11.4inparadigmxyz/reth) which bounds the precompile cache by actual byte usage instead of entry count.Motivation
Before this change,
PrecompileCachewas configured withMAX_CACHE_SIZE = 10_000interpreted bymokaas a max entry count (default weigher = 1 per entry). Because the cache stores precompile inputs/outputs whose sizes are attacker-controllable (e.g.IDENTITY,MODEXP), an adversary could fill the cache with large entries and balloon node memory well into the hundreds of MB range with only 10,000 cached results.Change
crates/engine/tree/src/tree/precompile_cache.rs:.weigher(|key, value| (key.len() + value.output.bytes.len()) as u32)so each entry's weight equals the bytes it actually holds.1024 * 1024, which under the new weigher means ≈1 MiB total bytes instead of 10,000 entries.Net effect: precompile cache memory is now hard-bounded at ~1 MiB regardless of per-entry size, eliminating the unbounded-growth surface.
Test plan
cargo check -p reth-engine-treepassescargo test -p reth-engine-tree precompile_cacheUpstream reference
🤖 Generated with Claude Code