Skip to content

[Feature] Can implement the Compact trait for U256? #895

@atenjin

Description

@atenjin

For current version, codec provide the compact for u8 ~ u128, while in substrate, there are also lots of cases need to use U256.

In my case, we use lots of u256 in some structs, which are the types in some extrinsic and storage. I hope I can use Compact to wrap U256 type to save some bytes

I tested for it, while meet error:
e.g.:

#[derive(Encode, Decode)]
struct A {
   a: Compact<U256>
}

When compile, it will print

error[E0275]: overflow evaluating the requirement `for<'b> CompactRef<'b, _>: Encode`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`primitive_zklogin`)
  = note: required for `CompactRef<'b, _>` to implement `for<'b> Encode`
  = note: 253 redundant requirements hidden
  = note: required for `CompactRef<'a, _>` to implement `for<'a> Encode`

it looks like it's in a dead loop, so that what ever value for recursion_limit I set is useless

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions