fix(l2): correctly accumulate operations counts in in-memory rollup store #5742
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
The in-memory rollup store is used in L2 components that expose metrics about transactions, privileged transactions and messages. These metrics depend on the global counters exposed by get_operations_count. However, the in-memory implementation of update_operations_count was not updating the underlying state at all, so the counters always stayed at zero. This silently broke L2 metrics when the in-memory backend is used and also made its behavior diverge from the SQL backend.
Description
This change fixes the in-memory implementation of StoreEngineRollup::update_operations_count so that it mutates the operations_counts array inside StoreInner instead of working on a local copy. As a result, subsequent calls to get_operations_count now return the accumulated values, matching the semantics of the SQL backend. A small async unit test was added to in_memory.rs to verify that multiple updates correctly accumulate and are reflected in the result of get_operations_count.