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

Implement BoundedVec with bound on both end #779

Open
2 tasks done
sudipghimire533 opened this issue Aug 23, 2023 · 2 comments
Open
2 tasks done

Implement BoundedVec with bound on both end #779

sudipghimire533 opened this issue Aug 23, 2023 · 2 comments

Comments

@sudipghimire533
Copy link

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Motivation

BoundedVec will not only bound its size in maximum limit but there shall also be minimum limit. This is useful in many case where pallet is expecting a vector within certain bounds eg: Some Name shall be greater than 3 element long but less than 500 and so on

Request

Extend BoundedVec implementation in frame_support to include another type Paramater LowerBound and all the operation in BoundedVec gurantee this bound ( and also the current upperbound ).

If required, default LowerBound can be 0 so it does not change the behavior in places where lower bound is not required

Solution

** Explain Above **

( I can also take the responsibility to implement and raise the PR, but first i need confirmation if everyone else thinks this is worth having )

Are you willing to help with this request?

Yes!

@sudipghimire533
Copy link
Author

If changing the implementation of Current BoundedVec is problematic we can also create new struct DoubleBoundedVec to wrap BoundedVec and inner limit

@xlc
Copy link
Contributor

xlc commented Aug 23, 2023

You should implement DoubleBoundedVec (I don't like this name but also can't think of a better one) and then implement BoundedVec on top of it. This way we can minimize the breaking change (no breaking change for existing BondedVec user) and code duplications.

@KiChjang KiChjang changed the title Vision: Implement BoundedVec with bound on both end Implement BoundedVec with bound on both end Aug 24, 2023
@ggwpez ggwpez transferred this issue from paritytech/substrate Aug 24, 2023
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

3 participants