-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add support for feature pallet_balances/insecure_zero_ed in benchmarks and testing
#7379
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
Merged
bkchr
merged 7 commits into
paritytech:master
from
moonbeam-foundation:manuel/add-support-for-feature-pallet-balances-insecure-zero-ed-in-benchmarks-and-testing
Jan 29, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
260d204
feat: :sparkles: support feature insecure_zero_ed in benchmarks and t…
manuelmauro ca8b63c
test: :sparkles: add balance assertion for insecure_zero_ed case
manuelmauro 438661a
docs: :memo: add prdoc
manuelmauro e5e5615
refactor: :recycle: use cfg! macro to check for insecure_zero_ed feature
manuelmauro b1cf78f
test: :white_check_mark: rely on minimum_balance() instead of Existen…
manuelmauro eacbcf6
fix benchmark when insecure_zero_ed is enabled
RomarQ cc26620
fix clippy error
RomarQ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
| # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
|
||
| title: "Add support for feature pallet_balances/insecure_zero_ed in benchmarks and testing" | ||
|
|
||
| doc: | ||
| - audience: Runtime Dev | ||
| description: | | ||
| Currently benchmarks and tests on pallet_balances would fail when the feature insecure_zero_ed is enabled. This PR allows to run such benchmark and tests keeping into account the fact that accounts would not be deleted when their balance goes below a threshold. | ||
|
|
||
| crates: | ||
| - name: pallet-balances | ||
| bump: patch |
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ use frame_support::{ | |
| BalanceStatus::{Free, Reserved}, | ||
| Currency, | ||
| ExistenceRequirement::{self, AllowDeath, KeepAlive}, | ||
| Hooks, InspectLockableCurrency, LockIdentifier, LockableCurrency, NamedReservableCurrency, | ||
| InspectLockableCurrency, LockIdentifier, LockableCurrency, NamedReservableCurrency, | ||
| ReservableCurrency, WithdrawReasons, | ||
| }, | ||
| StorageNoopGuard, | ||
|
|
@@ -1136,7 +1136,9 @@ fn operations_on_dead_account_should_not_change_state() { | |
|
|
||
| #[test] | ||
| #[should_panic = "The existential deposit must be greater than zero!"] | ||
| #[cfg(not(feature = "insecure_zero_ed"))] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only this is required. |
||
| fn zero_ed_is_prohibited() { | ||
| use frame_support::traits::Hooks; | ||
| // These functions all use `mutate_account` which may introduce a storage change when | ||
| // the account never existed to begin with, and shouldn't exist in the end. | ||
| ExtBuilder::default().existential_deposit(0).build_and_execute_with(|| { | ||
|
|
||
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 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.
These changes are not required, since this change: 1c4141a
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.
Unfortunately, the linked change was not enough as some benchmarks/tests rely on the side-effect of an account being removed as its balance goes below the
ExistentialBalancethreshold.E.g., https://github.com/paritytech/polkadot-sdk/pull/7379/files/e5e561501393e4384bac52b2c8febae49591b1c9#diff-bbca4fed8efbc441432d5d1772f445f49b1f4a25e0920dbcd41ccba2dfbc6520L209-L213
To reproduce the issue:
cargo test -p pallet-balances --features runtime-benchmarks,insecure_zero_edThere 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 double-checked it on
masterand it's right, those tests fail with theinsecure_zero_edfeature flagThere 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.
Yeah I forgot the
runtime-benchmarksflag earlier :D