Storage domains #6701
Labels
compiler: frontend
Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
compiler: ir
IRgen and sway-ir including optimization passes
compiler
General compiler. Should eventually become more specific as the issue is triaged
tracking-issue
Tracking issue for experimental Sway features
This is a tracking issue for
storage_domains
experimental feature.Description
Certain storage types, like, e.g.,
StorageMap
allow storage slots of their contained elements to be defined based on developer's input. E.g., thekey
in aStorageMap
used to calculate the storage slot is a developer input.To ensure that pre-images of such storage slots can never be the same as a pre-image of compiler generated key of a
storage
field, we will prefix the pre-images ofstorage
fields with a single byte that denotes thestorage
field domain. Storage types likeStorageMap
must have a different domain prefix than thisSTORAGE_DOMAIN
which will be set to 0u8.For detailed elaboration see #6317.
Breaking Changes
The
storage_domains
experimental feature changes the way how storage keys are generated forstorage
fields. Instead ofsha256("storage::ns1::ns2.field_name")
we now usesha256((0u8, "storage::ns1::ns2.field_name"))
.This is a breaking change for those who rely on the previous storage key calculation.
Issues
The text was updated successfully, but these errors were encountered: