From fb42d26911a0c6b7f7db41479e5d9cdf31bfc614 Mon Sep 17 00:00:00 2001 From: Sebastian Miasojed Date: Tue, 9 Jan 2024 14:57:08 +0100 Subject: [PATCH 1/4] Fix StorageVec TypeInfo --- crates/storage/src/lazy/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/storage/src/lazy/vec.rs b/crates/storage/src/lazy/vec.rs index d6abb47abfc..f9f0210611c 100644 --- a/crates/storage/src/lazy/vec.rs +++ b/crates/storage/src/lazy/vec.rs @@ -132,10 +132,10 @@ struct CachedLen(Cell>); #[cfg(feature = "std")] impl scale_info::TypeInfo for CachedLen { - type Identity = Option; + type Identity = Self; fn type_info() -> scale_info::Type { - ::type_info() + <() as scale_info::TypeInfo>::type_info() } } From 5a0e6f20f05a3d1c5ae5cfd6f5835e1d4c58f607 Mon Sep 17 00:00:00 2001 From: Sebastian Miasojed Date: Tue, 9 Jan 2024 15:15:55 +0100 Subject: [PATCH 2/4] Changelog updated --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2121cad050e..ad91dde4b69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fix `TypeInfo` for the `len_cached` field of the `StorageVec` type - [#2052](/~https://github.com/paritytech/ink/pull/2052) ## Version 5.0.0-rc From 133b8114d30e05d2a8f8440cb2a057e2bbd7b075 Mon Sep 17 00:00:00 2001 From: Sebastian Miasojed Date: Tue, 9 Jan 2024 16:01:48 +0100 Subject: [PATCH 3/4] Used codec(skip) for len_cached --- crates/storage/src/lazy/vec.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/storage/src/lazy/vec.rs b/crates/storage/src/lazy/vec.rs index f9f0210611c..910bc3e7bca 100644 --- a/crates/storage/src/lazy/vec.rs +++ b/crates/storage/src/lazy/vec.rs @@ -117,6 +117,7 @@ pub struct StorageVec { /// /// Because of caching, never operate on this field directly! /// Always use `fn get_len()` an `fn set_len()` instead. + #[cfg_attr(feature = "std", codec(skip))] len_cached: CachedLen, /// We use a [Mapping] to store all elements of the vector. /// Each element is living in storage under `&(KeyType::KEY, index)`. @@ -130,15 +131,6 @@ pub struct StorageVec { #[derive(Debug)] struct CachedLen(Cell>); -#[cfg(feature = "std")] -impl scale_info::TypeInfo for CachedLen { - type Identity = Self; - - fn type_info() -> scale_info::Type { - <() as scale_info::TypeInfo>::type_info() - } -} - impl Default for StorageVec where V: Packed, From 48675b8712e586dc0c47b3d3039ee893b9a7e978 Mon Sep 17 00:00:00 2001 From: Sebastian Miasojed Date: Tue, 9 Jan 2024 16:36:39 +0100 Subject: [PATCH 4/4] Changelog updated --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad91dde4b69..41e6a2dd2eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- Fix `TypeInfo` for the `len_cached` field of the `StorageVec` type - [#2052](/~https://github.com/paritytech/ink/pull/2052) +- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](/~https://github.com/paritytech/ink/pull/2052) ## Version 5.0.0-rc