Latest Results
Implement dynamic storage opcodes in the compiler (#7595)
## Description
This PR is a step in implementing #7560. It adds compiler support for
[dynamic storage
opcodes](https://github.com/FuelLabs/fuel-specs/pull/640) by:
- supporting all opcodes in `asm` blocks.
- adding IR instructions for all opcodes.
Note that the `FuelVmInstruction::StatePreload` IR instruction returns
zero if the slot is not used, but also if it is used and contains
zero-sized content. The reason is that zero-sized storage types, like,
e.g. `StorageVec`, have special semantics in the storage API and the
`storage_api` does not write zero-sized types into storage, nor reads
them. Modeling the IR instruction this way preserves this semantics and
allows for more efficient implementation that is actually needed in the
API. (Returning both the length and the existence information would
require a stack allocation and more gas expensive compilation for
something that is actually not used.)
This API semantics might be changed to support zero-sized types like any
other types. This would be a separate breaking change and a part of
[Configurable and composable storage
RFC](https://github.com/FuelLabs/sway-rfcs/pull/40).
Meanwhile, if a distinction between unused and zero-sized used slot is
needed while preloading, it can be achieved by using the `SPLD` opcode
in `asm` block.
## 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%
ironcev/dynamic-storage-add-intrinsics 0%
ironcev/dynamic-storage-add-opcodes 0%
© 2026 CodSpeed Technology