Implement dynamic storage for storage declaration and std#7598
Implement dynamic storage for storage declaration and std#7598
storage declaration and std#7598Conversation
PR SummaryHigh Risk Overview Extends Fixes purity analysis to treat Reviewed by Cursor Bugbot for commit 271d72c. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
👍 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 15d3ff5. Configure here.

Description
This PR is a part of #7560 implementation and implements:
storagefields access compilation for dynamic storage.std::storagemodule, except theStorageVec.In the
storage_api, support for dynamic storage is added as the extension to the existing API based on quads. The reason is that we will need to support quad-based storage for backwards compatibility, for contracts that cannot migrate all the data, but still want to use, in parallel, the benefits of dynamic storage.The existing API is marked as deprecated in favor of the new API in which the function suffix, either
quadsorslot(s), clearly indicates what kind of storage access the function performs.Additionally, the existing
clearAPI that returned boolean information about slot occupancy is split into two distinctive APIs:clearthat only clears and doesn't return occupancy information, andclear_existedthat returns boolean information about slot occupancy.Introducing two variants for clearing is done for performance reasons. Returning the occupancy information in dynamic storage case requires more gas, and in many of the cases that information is not needed. Having two distinctive function allows developers to opt-in for the cost.
Additionally, the PR:
ir_generation::purity::check_function_puritywhereStateUpdateSlotIR instruction andsupd/supiopcodes were still be considered as reading and writing operations instead of only writing.Iteratorimplementation forStorageVec#6829 by properly documenting the semantic of zero-sized types in relation to storage.Planned next steps are:
__state_store_slotin theStorageKey.__state_store_slotintrinsic is used in storage types, e.g. when storing slices or inserting into aStorageMap, but currently not in theStorageKeyin general. There,__state_update_slotis always used. Supporting__state_store_slotin theStorageKeyrequires introduction of an additional abstraction that will allow us to express that aStorageKeypoints to a value that is guaranteed to be the only value in the slot.StorageVecs that are temporarily disabled. This will be done when dynamic storage version ofStorageVecis implemented.<project>-storage_slots.jsonfor dynamic storage and properly consuming them in the SDK. Until then, some of the tests are disabled and marked asTODO: (INIT-STORAGE).Checklist
Breaking*orNew Featurelabels where relevant.