Latest Results
Implement dynamic storage for `storage` declaration and `std` (#7598)
## Description
This PR is a part of #7560 implementation and implements:
- `storage` fields access compilation for dynamic storage.
- dynamic storage for all the types and functions in the `std::storage`
module, except the `StorageVec`.
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 `quads` or `slot(s)`, clearly
indicates what kind of storage access the function performs.
Additionally, the existing `clear` API that returned boolean information
about slot occupancy is split into two distinctive APIs: `clear` that
only clears and doesn't return occupancy information, and
`clear_existed` that 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:
- fixes bug in `ir_generation::purity::check_function_purity` where
`StateUpdateSlot` IR instruction and `supd/supi` opcodes were still be
considered as reading and writing operations instead of only writing.
- closes #6829 by properly documenting the semantic of zero-sized types
in relation to storage.
Planned next steps are:
- Adding additional comprehensive test coverage. Some of the existing
tests are adapted to test the new API and dynamic storage in this PR.
Considering the impact of the change, unlike for other experimental
feature, we want dynamic storage test to be included in all the tests
that are currently testing storage.
- Further optimizing writing to storage by supporting
`__state_store_slot` in the `StorageKey`. `__state_store_slot` intrinsic
is used in storage types, e.g. when storing slices or inserting into a
`StorageMap`, but currently not in the `StorageKey` in general. There,
`__state_update_slot` is always used. Supporting `__state_store_slot` in
the `StorageKey` requires introduction of an additional abstraction that
will allow us to express that a `StorageKey` points to a value that is
guaranteed to be the only value in the slot.
- Enabling SDK tests for `StorageVec`s that are temporarily disabled.
This will be done when dynamic storage version of `StorageVec` is
implemented.
- Emitting `<project>-storage_slots.json` for dynamic storage and
properly consuming them in the SDK. Until then, some of the tests are
disabled and marked as `TODO: (INIT-STORAGE)`.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers. Latest Branches
0%
+17%
ironcev/const-generic-array-not-an-indexable-type -20%
ironcev/dynamic-storage-std-and-storage-declaration © 2026 CodSpeed Technology