Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow removing requirement for TypeInfo bounds on type params #95

Closed
ascjones opened this issue May 28, 2021 · 2 comments
Closed

Allow removing requirement for TypeInfo bounds on type params #95

ascjones opened this issue May 28, 2021 · 2 comments

Comments

@ascjones
Copy link
Contributor

ascjones commented May 28, 2021

Polkadot has the type Xcm<Call> which has an Order<Call> and an Order<()> which in turn has an Xcm<Call>. We get a overflow evaluating the requirement Vec<order::Order<()>>: TypeInfo

Since Call is not directly encoded, see double_encoded, this type parameter does not need to implement Encode/Decode/TypeInfo

To get around this for other derives they are just removing the bounds:

#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]

On the surface we should be able to add #[scale_info(bounds()))] from #88 to erase the bounds. Though that is not enough on its own because there is still TypeInfo requirement for adding to type_params.

So what we need to be able to do is control which type params are included in the type_params list, in addition to (or even instead of) the custom bounds.

@ascjones
Copy link
Contributor Author

ascjones commented Jun 14, 2021

Polkadot has the type Xcm which has an Order and an Order<()> which in turn has an Xcm. We get a overflow evaluating the requirement Vec<order::Order<()>>: TypeInfo

As suggested by the error message the issue is in fact caused by the auto added Vec<order::Order<()>>: TypeInfo bound.

The reason we have such an apparently unnecessary bound is because there is not currently a good solution to differentiate between a generic type constructor e.g. Vec<T> and an alias to an associated type e.g. BalanceOf<T>. And we need the bound for the latter, so we just add both.

I have added a test to #88 which fixes this with a custom bound override: 3a98799

So what we need to be able to do is control which type params are included in the type_params list, in addition to (or even instead of) the custom bounds.

We still probably need to be able to do this, but it does not on its own resolve the overflow.

@ascjones ascjones mentioned this issue Jun 14, 2021
9 tasks
@ascjones
Copy link
Contributor Author

Closed by #96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant