Arbos 60: Return back recent WASMs cache#897
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #897 +/- ##
==========================================
+ Coverage 74.90% 75.21% +0.31%
==========================================
Files 243 243
Lines 14940 14947 +7
Branches 2276 2278 +2
==========================================
+ Hits 11191 11243 +52
+ Misses 2892 2844 -48
- Partials 857 860 +3
🚀 New features to boost your workflow:
|
9ed525c to
475c211
Compare
There was a problem hiding this comment.
Pull request overview
This PR reintroduces a per-block "recent WASMs" cache that allows the second and subsequent Stylus calls to the same code hash within a block to be charged the cheaper "cached" init gas, gated behind ArbOS v60 (StylusContractLimit) to preserve historical consensus. The previous (broken) ClockCache-based RecentWasms is replaced with an LruCache<ValueHash256, byte>, matching Nitro's post-v60 fix semantics.
Changes:
- Rewrite
RecentWasmsas a sealed class wrapping a lazily-allocatedLruCache, clamping a 0 capacity to 1 to mirror Nitro'slru.NewBasicLRUbehavior. - Gate the
Insert(...)-based cached-hit determination inStylusPrograms.CallProgramonArbosVersion >= StylusContractLimit. - Add
RecentWasmsTests(insert/miss/hit/eviction/zero-capacity/clear) andStylusProgramsTestscases comparing pre-v60 vs v60 same-block vs v60 across-block gas consumption.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Nethermind.Arbitrum/Stylus/WasmStore.cs | Replaces RecentWasms (ClockCache-based no-op) with an LRU cache that returns hit/miss and supports Clear(). |
| src/Nethermind.Arbitrum/Arbos/Programs/StylusPrograms.cs | Adds the v60 gate around the recent-cache lookup in CallProgram's cached-flag computation. |
| src/Nethermind.Arbitrum.Test/Stylus/RecentWasmsTests.cs | New unit tests for the LRU semantics of RecentWasms. |
| src/Nethermind.Arbitrum.Test/Arbos/Programs/StylusProgramsTests.cs | Adds end-to-end gas-charge tests for repeat calls pre-v60, v60 same-block, and v60 across blocks; refactors helpers to be static and version-parameterized. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
svlachakis
left a comment
There was a problem hiding this comment.
Maybe worth starting consolidating tests into test cases generally
Not sure I understand. Could you explain what do you mean? |
Should be merged after #890
Closes #879 #421