Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for Solidity-compatible dynamic arrays via StorageVec<T> in the pvm-storage typed-storage layer, and extends the storage codec to support fixed-size arrays [T; N] (for T != u8) so arrays can be used inside Lazy, Mapping, and StorageVec while preserving solc’s storage layout rules.
Changes:
- Introduces
StorageVec<T>(plus nestedStorageVec<StorageVec<T>>andMapping<K, StorageVec<T>>) with solc-compatible length/body addressing, packing, and clearing semantics. - Adds
[T; N]storage encoding/decoding gated by a newStorageArrayElementmarker trait, and auto-derivesStorageArrayElementfor staticSolTypestructs. - Adds extensive
StorageVeclayout/behavior tests and new template examples/bench variants showcasing typed-storage usage.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/pvm-storage/tests/ui/lazy_of_fixed_array_non_u8_rejected.stderr | Removes compile-fail expectation now that non-u8 fixed arrays are supported. |
| crates/pvm-storage/tests/ui/lazy_of_fixed_array_non_u8_rejected.rs | Removes compile-fail test now that [T; N] storage is implemented for more T. |
| crates/pvm-storage/src/tests.rs | Adds comprehensive runtime tests for StorageVec layouts and behaviors (packed/subword/multislot/dynamic/nested/mapping). |
| crates/pvm-storage/src/lib.rs | Implements StorageVec, Mapping<K, StorageVec<T>>, nested StorageVec<StorageVec<T>>, and supporting helpers (read_len_u64, inc_slot_by, etc.). |
| crates/pvm-contract-types/src/storage_codec.rs | Adds StorageArrayElement and [T; N] StorageEncode/StorageDecode implementations matching solc layout. |
| crates/pvm-contract-types/src/mock_host.rs | Minor comment wording update. |
| crates/pvm-contract-types/src/lib.rs | Re-exports StorageArrayElement. |
| crates/pvm-contract-types/src/host.rs | Minor comment wording update. |
| crates/pvm-contract-sdk/src/lib.rs | Re-exports StorageVec and StorageArrayElement from the SDK surface. |
| crates/pvm-contract-macros/tests/derive_sol_type_storage.rs | Adds tests ensuring derived static structs auto-implement StorageArrayElement and work in [T; N] storage contexts. |
| crates/pvm-contract-macros/src/codegen/sol_type.rs | Auto-emits impl StorageArrayElement for static (non-dynamic-body) SolType structs. |
| crates/pvm-contract-macros/src/codegen/sol_storage.rs | Minor comment wording update. |
| crates/pvm-contract-macros/src/codegen/contract.rs | Minor comment wording update. |
| crates/pvm-contract-benchmarks/src/bin/build-and-measure.rs | Updates benchmark variants/contracts list to include storage-focused example contracts. |
| crates/cargo-pvm-contract/templates/examples/mytoken_storage/MyToken.sol | Adds Solidity interface for typed-storage ERC20-style example. |
| crates/cargo-pvm-contract/templates/examples/mytoken_storage/mytoken_storage_with_alloc.rs | Adds with-alloc Rust example using Lazy/Mapping. |
| crates/cargo-pvm-contract/templates/examples/mytoken_storage/mytoken_storage_no_alloc.rs | Adds no-alloc Rust example using Lazy/Mapping. |
| crates/cargo-pvm-contract/templates/examples/amm_reserves/AmmReserves.sol | Adds Solidity interface for packed-reserves example. |
| crates/cargo-pvm-contract/templates/examples/amm_reserves/amm_reserves_with_alloc.rs | Adds with-alloc Rust example demonstrating packed struct-in-Lazy. |
| crates/cargo-pvm-contract/templates/examples/amm_reserves/amm_reserves_no_alloc.rs | Adds no-alloc Rust example demonstrating packed struct-in-Lazy. |
| crates/cargo-pvm-contract/templates/examples/allowlist/Allowlist.sol | Adds Solidity interface for StorageVec-backed allowlist example. |
| crates/cargo-pvm-contract/templates/examples/allowlist/allowlist_with_alloc.rs | Adds with-alloc Rust example using StorageVec<Address>. |
| crates/cargo-pvm-contract/templates/examples/allowlist/allowlist_no_alloc.rs | Adds no-alloc Rust example using StorageVec<Address>. |
| CLAUDE.md | Updates documentation to reflect StorageVec<T> and removes Stylus references in a few spots. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Benchmark Size Comparison (vs main)
OK: All artifacts within 5% regression thresholdRun 27022454253 | aacee86 | 2026-06-05 15:15 UTC |
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.
This PR adds first-class support for Solidity-compatible dynamic arrays via StorageVec in the pvm-storage typed-storage layer, and extends the storage codec to support fixed-size arrays [T; N] (for T != u8) so arrays can be used inside Lazy, Mapping, and StorageVec while preserving solc’s storage layout rules.
Changes:
Introduces StorageVec (plus nested StorageVec<StorageVec> and Mapping<K, StorageVec>) with solc-compatible length/body addressing, packing, and clearing semantics.
Adds [T; N] storage encoding/decoding gated by a new StorageArrayElement marker trait, and auto-derives StorageArrayElement for static SolType structs.
Adds extensive StorageVec layout/behavior tests and new template examples/bench variants showcasing typed-storage usage.