Merged
Conversation
afck
approved these changes
Feb 16, 2026
deuszx
reviewed
Feb 16, 2026
c1a015f to
ef75161
Compare
afck
reviewed
Feb 16, 2026
Comment on lines
+76
to
+79
| if self.modules.contains(&bytecode) { | ||
| self.modules.put(bytecode, module); | ||
| return; | ||
| } |
Contributor
There was a problem hiding this comment.
Is this equivalent? No need to put if the module is already in the cache?
Suggested change
| if self.modules.contains(&bytecode) { | |
| self.modules.put(bytecode, module); | |
| return; | |
| } | |
| if self.modules.promote(&bytecode) { | |
| return; | |
| } |
Contributor
Author
There was a problem hiding this comment.
Good point, I need up upgrade the lru crate version for that though. Will do it
ef75161 to
e621bc1
Compare
e621bc1 to
a1a216e
Compare
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 16, 2026
## Motivation
`ModuleCache::insert()` never incremented `total_size` after inserting a
new entry. It only decremented during
eviction in `reduce_size_to()`. This meant:
- `total_size` was permanently 0
- The eviction check `if self.total_size + bytecode_size >
self.max_size` never triggered
- The cache grew unboundedly despite the 512 MiB limit
- `reduce_size_to()` would underflow on the subtraction `self.total_size
-= bytecode_size`
## Proposal
- Add `self.total_size += bytecode_size` after insertion, only when the
key wasn't already present (to avoid
double-counting on re-insertion of the same bytecode)
- Add an early return when a single bytecode exceeds `max_size`, which
prevents an underflow in the `self.max_size -
bytecode_size` computation passed to `reduce_size_to()`
- Add 4 unit tests covering: size tracking, eviction triggering,
oversized rejection, and duplicate key handling
## Test Plan
- CI + new tests pass
## Release Plan
- These changes should be backported to the latest `testnet` branch,
then
- be released in a validator hotfix.
ndr-ds
added a commit
that referenced
this pull request
Feb 17, 2026
## Motivation
`ModuleCache::insert()` never incremented `total_size` after inserting a
new entry. It only decremented during
eviction in `reduce_size_to()`. This meant:
- `total_size` was permanently 0
- The eviction check `if self.total_size + bytecode_size >
self.max_size` never triggered
- The cache grew unboundedly despite the 512 MiB limit
- `reduce_size_to()` would underflow on the subtraction `self.total_size
-= bytecode_size`
## Proposal
- Add `self.total_size += bytecode_size` after insertion, only when the
key wasn't already present (to avoid
double-counting on re-insertion of the same bytecode)
- Add an early return when a single bytecode exceeds `max_size`, which
prevents an underflow in the `self.max_size -
bytecode_size` computation passed to `reduce_size_to()`
- Add 4 unit tests covering: size tracking, eviction triggering,
oversized rejection, and duplicate key handling
## Test Plan
- CI + new tests pass
## Release Plan
- These changes should be backported to the latest `testnet` branch,
then
- be released in a validator hotfix.
ndr-ds
added a commit
that referenced
this pull request
Feb 17, 2026
## Motivation
`ModuleCache::insert()` never incremented `total_size` after inserting a
new entry. It only decremented during
eviction in `reduce_size_to()`. This meant:
- `total_size` was permanently 0
- The eviction check `if self.total_size + bytecode_size >
self.max_size` never triggered
- The cache grew unboundedly despite the 512 MiB limit
- `reduce_size_to()` would underflow on the subtraction `self.total_size
-= bytecode_size`
## Proposal
- Add `self.total_size += bytecode_size` after insertion, only when the
key wasn't already present (to avoid
double-counting on re-insertion of the same bytecode)
- Add an early return when a single bytecode exceeds `max_size`, which
prevents an underflow in the `self.max_size -
bytecode_size` computation passed to `reduce_size_to()`
- Add 4 unit tests covering: size tracking, eviction triggering,
oversized rejection, and duplicate key handling
## Test Plan
- CI + new tests pass
## Release Plan
- These changes should be backported to the latest `testnet` branch,
then
- be released in a validator hotfix.
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.

Motivation
ModuleCache::insert()never incrementedtotal_sizeafter inserting a new entry. It only decremented duringeviction in
reduce_size_to(). This meant:total_sizewas permanently 0if self.total_size + bytecode_size > self.max_sizenever triggeredreduce_size_to()would underflow on the subtractionself.total_size -= bytecode_sizeProposal
self.total_size += bytecode_sizeafter insertion, only when the key wasn't already present (to avoiddouble-counting on re-insertion of the same bytecode)
max_size, which prevents an underflow in theself.max_size - bytecode_sizecomputation passed toreduce_size_to()Test Plan
Release Plan
testnetbranch, then