Skip to content

Arbos 60: Return back recent WASMs cache#897

Merged
wurdum merged 5 commits into
mainfrom
feat/arbos-60-fix-recent-wasms-cache
May 27, 2026
Merged

Arbos 60: Return back recent WASMs cache#897
wurdum merged 5 commits into
mainfrom
feat/arbos-60-fix-recent-wasms-cache

Conversation

@wurdum

@wurdum wurdum commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Should be merged after #890

Closes #879 #421

@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.21%. Comparing base (ca5182f) to head (87ff3c2).

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     
Files with missing lines Coverage Δ
...thermind.Arbitrum/Arbos/Programs/StylusPrograms.cs 73.50% <100.00%> (+0.62%) ⬆️
src/Nethermind.Arbitrum/Stylus/WasmStore.cs 94.00% <100.00%> (+5.11%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from feat/arbos60-increase-stylus-contract-size to main May 25, 2026 14:56
@wurdum wurdum force-pushed the feat/arbos-60-fix-recent-wasms-cache branch from 9ed525c to 475c211 Compare May 25, 2026 19:08
@wurdum wurdum marked this pull request as ready for review May 25, 2026 19:45
Copilot AI review requested due to automatic review settings May 25, 2026 19:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 RecentWasms as a sealed class wrapping a lazily-allocated LruCache, clamping a 0 capacity to 1 to mirror Nitro's lru.NewBasicLRU behavior.
  • Gate the Insert(...)-based cached-hit determination in StylusPrograms.CallProgram on ArbosVersion >= StylusContractLimit.
  • Add RecentWasmsTests (insert/miss/hit/eviction/zero-capacity/clear) and StylusProgramsTests cases 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 svlachakis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth starting consolidating tests into test cases generally

Comment thread src/Nethermind.Arbitrum/Stylus/WasmStore.cs Outdated
@wurdum

wurdum commented May 27, 2026

Copy link
Copy Markdown
Collaborator Author

Maybe worth starting consolidating tests into test cases generally

Not sure I understand. Could you explain what do you mean?

@wurdum wurdum merged commit a951790 into main May 27, 2026
12 checks passed
@wurdum wurdum deleted the feat/arbos-60-fix-recent-wasms-cache branch May 27, 2026 08:57
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.

[ArbOS 60] Stylus Recent-Wasms Cache

5 participants