paritytech / paritytech/parity-common
Infinite recursion on BoundedVec
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 311
- Forks
- 245
- PR merge metrics
- No merged PRs in 30d
Description
When using bounded-collections v0.2.4, I get this error when compiling the runtime:
error: reached the recursion limit while instantiating `decode_vec_with_len::<(sp_runtime::Vec<u8>, sp_runtime::Vec<u8>), ...>`
--> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parity-scale-codec-3.7.4/src/codec.rs:1228:34
|
1228 | .and_then(move |Compact(len)| decode_vec_with_len(input, len as usize))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `decode_vec_with_len` defined here
--> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parity-scale-codec-3.7.4/src/codec.rs:1196:1
|
1196 | / pub fn decode_vec_with_len<T: Decode, I: Input>(
1197 | | input: &mut I,
1198 | | len: usize,
1199 | | ) -> Result<Vec<T>, Error> {
| |__________________________^
= note: the full type name has been written to '/path/long-type.txt'
error: reached the recursion limit while instantiating `decode_vec_with_len::<MultiAsset, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, ...>>>>>`
--> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bounded-collections-0.2.4/src/bounded_vec.rs:279:15
|
279 | let inner = decode_vec_with_len(input, len as usize)?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `decode_vec_with_len` defined here
--> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parity-scale-codec-3.7.4/src/codec.rs:1196:1
|
1196 | / pub fn decode_vec_with_len<T: Decode, I: Input>(
1197 | | input: &mut I,
1198 | | len: usize,
1199 | | ) -> Result<Vec<T>, Error> {
| |__________________________^
= note: the full type name has been written to 'path.long-type.txt'
error: could not compile `enjin-matrix-runtime` (lib) due to 2 previous errors
Process finished with exit code 101
The contents of the mentioned long-type file are this:
decode_vec_with_len::<(sp_runtime::Vec<u8>, sp_runtime::Vec<u8>), sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_, sp_core::bounded_collections::bounded_btree_map::PrependCompactInput<'_,
// the above repeats maybe a hundred times
codec::codec::BytesCursor>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The runtime compiles correctly when I patch bounded-collections to v0.2.3. I have the recursion limit set to 256. It seems to be an issue with BoundedVec, but it mentions sp_core::bounded_collections::bounded_btree_map::PrependCompactInput, so not sure.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing bounded-collections 0.2.3 and 0.2.4 at bounded_vec.rs:279, then inspect parity-scale-codec's codec.rs around lines 1196 and 1228. Reproduce the runtime compilation with recursion_limit set to 256 and use the generated long-type file to trace the nested PrependCompactInput types. Done means the reported runtime compiles with bounded-collections 0.2.4 without reaching the recursion limit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100