This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Introduce WeakBoundedVec, StorageTryAppend, and improve BoundedVec API #8842
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bkchr
reviewed
May 17, 2021
kianenigma
approved these changes
May 18, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think BoundedBTreeMap etc. also have similar confusion + use of unsafe.
ah yes, I changed it too now. |
after discussion I will implement WeakBoundedVec and make BoundedVec API complete by changing Decode/Encode |
3e02cf4
to
a5c03ea
Compare
gui1117
commented
May 20, 2021
/// Marker trait that will be implemented for types that support the `storage::try_append` api. | ||
/// | ||
/// This trait is sealed. | ||
pub trait StorageTryAppend<Item>: StorageDecodeLength + private::Sealed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a new trait in order to be able to implement try_append for both WeakBoudedVec and BoundedVec without too much code duplication.
shawntabrizi
approved these changes
May 20, 2021
thank you! |
coriolinus
reviewed
May 21, 2021
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
coriolinus
approved these changes
May 21, 2021
bot merge |
Trying merge. |
nazar-pc
pushed a commit
to autonomys/substrate
that referenced
this pull request
Aug 8, 2021
paritytech#8842) * fix bounded vec doc and unsafe * fix btree map and set and tests * introduce weak_bounded_vec and StorageTryAppend * fix tests and reorganize tests * improve doc * add doc * Update frame/support/src/storage/weak_bounded_vec.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * fix inner doc Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
This pull request was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
A0-please_review
Pull request needs code review.
C1-low
PR touches the given topic and has a low impact on builders.
D5-nicetohaveaudit ⚠️
PR contains trivial changes to logic that should be properly reviewed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #8839
This PR does:
WeakBoundedVec
: it is exactly same as BoundedVec previous to this PR, i.e. the lenght is not enforced byforce_from
nordecode
, but it warns when exceeded.BoundedVec
API:force_from
is removed anddecode
only accept vec with correct size.StorageTryAppend
: allow to specify that a storage value have a maximum bound. It is used to implement try_append on storage value, storage map and storage double map now.Previous to this PR, try_append was only implemented for
BoundedVec
explicitly. TheStorageTryAppend
allow to implementtry_append
on various types, such asBoundedVec
andWeakBoundedVec
.