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.6k
Force bag changes in relevant benchmarks (targets #9507) #9529
Merged
emostov
merged 46 commits into
zeke-voter-bags-module
from
zeke-bags-list-staking-benchmarks
Aug 28, 2021
Merged
Changes from 3 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
55cf648
force rebag for unbond, rebond, and bond_extra
emostov ff55aba
nit
emostov 759e309
Merge branch 'zeke-voter-bags-module' into zeke-bags-list-staking-ben…
emostov 37c8436
Improve utils
emostov f3b8c8a
fmt
emostov a96ce8e
Try merge origin master
emostov 7b6686a
nits
emostov 1a91ead
Merge branch 'zeke-voter-bags-module' into zeke-bags-list-staking-ben…
emostov 804151c
Move generate_bags to its own pallet
emostov 34e2194
Get runtime-benchmarks feature setup with prepare_on_update_benchmark
emostov dec1e8b
Withdraw unbonded kill working
emostov a354364
Nominate bench working
emostov 02a218f
some cleanup
emostov 77ab8af
WIP
emostov da38ccc
Try merge zeke-voter-bags-module
emostov ecdb7e8
update to check head pre & post conditions
emostov d3bbd18
Add some post condition verification stuff for on_remove
emostov 1b82579
Update nominate
emostov 19ebb8a
fmt
emostov e79ad98
Improvements
emostov cd3a63c
Fix build
emostov 7d18281
fix build with polkadot companion
emostov 644e3bf
Update frame/bags-list/src/list/tests.rs
emostov a2ddcb4
Try merge feature
emostov ded3b49
move generate-bag from frame to utils
emostov 624cfe9
wip
emostov d34a1fd
Merge remote-tracking branch 'origin' into zeke-bags-list-staking-ben…
emostov d1f5d44
refactor WIP
emostov 76688e7
Merge branch 'zeke-voter-bags-module' of github.com:paritytech/substr…
kianenigma dbb95db
WIP save
emostov 0cd7103
Refactor working
emostov aea5554
some variable renaming
emostov 033b717
WIP: prepare to remove head checks
emostov d08d858
Finish MvP refactor
emostov d5601ad
Merge branch 'zeke-voter-bags-module' into zeke-bags-list-staking-ben…
emostov 8cacd0c
Some cleanup
emostov 5aa980c
Soem more cleanup
emostov 4f56f74
Merge branch 'zeke-bags-list-staking-benchmarks' of https://github.co…
emostov efbf22d
save
emostov 532ffff
fix a lot of stuff
kianenigma 24c2767
Update client/db/src/bench.rs
emostov 6b91371
Apply suggestions from code review
emostov 0317ea1
Apply suggestions from code review
emostov 4faf565
Fix some issues that came from trying to merge comments on github
emostov 41a50db
some small changes
emostov 6277454
simplify it
kianenigma 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 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 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 |
---|---|---|
|
@@ -59,6 +59,22 @@ pub fn create_funded_user<T: Config>( | |
user | ||
} | ||
|
||
/// Grab a funded user. | ||
pub fn create_funded_user_b<T: Config>( | ||
string: &'static str, | ||
n: u32, | ||
balance_factor: crate::BalanceOf<T>, | ||
) -> T::AccountId { | ||
use sp_runtime::traits::Bounded; | ||
let user = account(string, n, SEED); | ||
let balance = | ||
(T::Currency::minimum_balance() * balance_factor).max(BalanceOf::<T>::max_value()); | ||
T::Currency::make_free_balance_be(&user, balance); | ||
// ensure T::CurrencyToVote will work correctly. | ||
T::Currency::issue(balance); // TODO I don't get this .. will drop NegativeImbalance which cancels itself out | ||
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. note 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. does everything work as expected without it? |
||
user | ||
} | ||
|
||
/// Create a stash and controller pair. | ||
pub fn create_stash_controller<T: Config>( | ||
n: u32, | ||
|
@@ -79,6 +95,26 @@ pub fn create_stash_controller<T: Config>( | |
return Ok((stash, controller)) | ||
} | ||
|
||
/// Create a stash and controller pair. | ||
pub fn create_stash_controller_b<T: Config>( | ||
n: u32, | ||
balance_factor: crate::BalanceOf<T>, | ||
destination: RewardDestination<T::AccountId>, | ||
) -> Result<(T::AccountId, T::AccountId), &'static str> { | ||
let stash = create_funded_user_b::<T>("stash", n, balance_factor); | ||
let controller = create_funded_user_b::<T>("controller", n, balance_factor); | ||
let controller_lookup: <T::Lookup as StaticLookup>::Source = | ||
T::Lookup::unlookup(controller.clone()); | ||
let amount = T::Currency::minimum_balance() * (balance_factor / 10u32.into()).max(1u32.into()); | ||
Staking::<T>::bond( | ||
RawOrigin::Signed(stash.clone()).into(), | ||
controller_lookup, | ||
amount, | ||
destination, | ||
)?; | ||
Ok((stash, controller)) | ||
} | ||
|
||
/// Create a stash and controller pair, where the controller is dead, and payouts go to controller. | ||
/// This is used to test worst case payout scenarios. | ||
pub fn create_stash_and_dead_controller<T: Config>( | ||
|
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.
My fundamental issue with this start the moment I see the word
bag
inpallet-staking
. Further down I also see notions ofthreshold
which is again OT in staking.In an ideal world and in my head, staking should only work and talk to
SortedListProvider
. I might be oversimplifying it, but I think the majority of the staking benchmark for something likebond_extra
should stay the same, and it should only callT::SortedListProvider::prepare_worse_case(who, amount)
, which means "I need you to make sure a rebag (worse case) happens if I change backing ofwho
byamount
".Then, in the receiving side, we make sure that this rebag happens.
Thinking a bit more, it might be easier to do this:
T::SortedListProvider::weight_update_worse_case(who)
, in which bags-list will tell staking by how much it should increasewho
's stake to cause a worse case (aka. rebag).And a similar analogy should exist in the rest of them as well.
That being said, the benchmarks seem to be correct and solid in terms of delivering worse-case code execution, so I think doing this refactor in a follow-up is also acceptable.