-
Notifications
You must be signed in to change notification settings - Fork 732
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
pallet-referenda: Detect incorrect pre-image length #3850
Merged
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
There has been a case that a referenda failed because the length given to `submit` was incorrect. The pallet can actually check the length if the pre-image already exists to ensure that these kind of issues are not happening again.
liamaharon
approved these changes
Mar 27, 2024
joepetrowski
approved these changes
Mar 27, 2024
substrate/frame/referenda/src/lib.rs
Outdated
// If the pre-image is already stored, ensure that it has the same length as given in | ||
// `proposal`. | ||
if let Some(hash) = proposal.lookup_hash() { | ||
if let Some((l, r)) = |
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.
Suggested change
if let Some((l, r)) = | |
if let Some((preimage_length, proposal_length)) = |
😅
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.
ensure!(
proposal.lookup_hash()
.and_then(|hash| T::Preimages::len(&hash))
.map(|hash_len| hash_len != proposal.lookup_len().unwrap_or(u32::MAX))
.unwrap_or(true),
Error::<T, I>::PreimageStoredWithDifferentLength
)
just playing some Option
API games :D
Ank4n
approved these changes
Mar 27, 2024
ggwpez
approved these changes
Mar 27, 2024
dharjeezy
pushed a commit
to dharjeezy/polkadot-sdk
that referenced
this pull request
Apr 9, 2024
There has been a case that a referenda failed because the length given to `submit` was incorrect. The pallet can actually check the length if the pre-image already exists to ensure that these kind of issues are not happening again.
This was referenced Jun 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There has been a case that a referenda failed because the length given to
submit
was incorrect. The pallet can actually check the length if the pre-image already exists to ensure that these kind of issues are not happening again.