fix: preserve shielded ops for bytes(sbytes) aliases (#248)#249
Merged
fix: preserve shielded ops for bytes(sbytes) aliases (#248)#249
Conversation
ce39504 to
407ce00
Compare
407ce00 to
8db99ce
Compare
81fcc4b to
f74d0d6
Compare
f74d0d6 to
6a75ff4
Compare
6a75ff4 to
4575d03
Compare
4575d03 to
27c079b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #248.
bytes(sbytes_storage_ref)could lose the fact that the alias still points at shielded storage. That made the compiler emit ordinary storage ops for paths that still touch private slots, which then failed at runtime withInvalidPrivateStorageAccess.Affected cases included:
return bytes(m[0]);bytes storage ref = bytes(data);return ref,ref[i],ref[i] = ...,ref.push(...), andref.pop()bytes storagealiases derived from shielded storageFix
The compiler now preserves an internal shielded-storage marker on
bytes/stringstorage references produced from shielded storage.Both codegen pipelines use that marker to keep using shielded storage ops while the alias still points at shielded storage:
cloadcstoreThe marker is only for storage-op selection. It does not change the surface type of
bytes: user-visible typing like.lengthstays ordinary, and deep copies into genuinely public storage stay on ordinary storage ops.Tests
Added and expanded coverage for:
bytes(sbytes_storage)bugbytes(sbytes_storage_ref).length