Skip to content

Infinite recursion on BoundedVec #911

@JayPavlina

Description

@JayPavlina

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions