Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
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 Aug 10, 2021
ff55aba
nit
emostov Aug 10, 2021
759e309
Merge branch 'zeke-voter-bags-module' into zeke-bags-list-staking-ben…
emostov Aug 10, 2021
37c8436
Improve utils
emostov Aug 10, 2021
f3b8c8a
fmt
emostov Aug 10, 2021
a96ce8e
Try merge origin master
emostov Aug 10, 2021
7b6686a
nits
emostov Aug 10, 2021
1a91ead
Merge branch 'zeke-voter-bags-module' into zeke-bags-list-staking-ben…
emostov Aug 10, 2021
804151c
Move generate_bags to its own pallet
emostov Aug 10, 2021
34e2194
Get runtime-benchmarks feature setup with prepare_on_update_benchmark
emostov Aug 10, 2021
dec1e8b
Withdraw unbonded kill working
emostov Aug 12, 2021
a354364
Nominate bench working
emostov Aug 13, 2021
02a218f
some cleanup
emostov Aug 13, 2021
77ab8af
WIP
emostov Aug 13, 2021
da38ccc
Try merge zeke-voter-bags-module
emostov Aug 13, 2021
ecdb7e8
update to check head pre & post conditions
emostov Aug 13, 2021
d3bbd18
Add some post condition verification stuff for on_remove
emostov Aug 13, 2021
1b82579
Update nominate
emostov Aug 13, 2021
19ebb8a
fmt
emostov Aug 13, 2021
e79ad98
Improvements
emostov Aug 13, 2021
cd3a63c
Fix build
emostov Aug 14, 2021
7d18281
fix build with polkadot companion
emostov Aug 14, 2021
644e3bf
Update frame/bags-list/src/list/tests.rs
emostov Aug 16, 2021
a2ddcb4
Try merge feature
emostov Aug 20, 2021
ded3b49
move generate-bag from frame to utils
emostov Aug 20, 2021
624cfe9
wip
emostov Aug 24, 2021
d34a1fd
Merge remote-tracking branch 'origin' into zeke-bags-list-staking-ben…
emostov Aug 24, 2021
d1f5d44
refactor WIP
emostov Aug 24, 2021
76688e7
Merge branch 'zeke-voter-bags-module' of github.com:paritytech/substr…
kianenigma Aug 24, 2021
dbb95db
WIP save
emostov Aug 24, 2021
0cd7103
Refactor working
emostov Aug 24, 2021
aea5554
some variable renaming
emostov Aug 24, 2021
033b717
WIP: prepare to remove head checks
emostov Aug 24, 2021
d08d858
Finish MvP refactor
emostov Aug 24, 2021
d5601ad
Merge branch 'zeke-voter-bags-module' into zeke-bags-list-staking-ben…
emostov Aug 24, 2021
8cacd0c
Some cleanup
emostov Aug 24, 2021
5aa980c
Soem more cleanup
emostov Aug 24, 2021
4f56f74
Merge branch 'zeke-bags-list-staking-benchmarks' of https://github.co…
emostov Aug 24, 2021
efbf22d
save
emostov Aug 26, 2021
532ffff
fix a lot of stuff
kianenigma Aug 26, 2021
24c2767
Update client/db/src/bench.rs
emostov Aug 26, 2021
6b91371
Apply suggestions from code review
emostov Aug 26, 2021
0317ea1
Apply suggestions from code review
emostov Aug 26, 2021
4faf565
Fix some issues that came from trying to merge comments on github
emostov Aug 27, 2021
41a50db
some small changes
emostov Aug 27, 2021
6277454
simplify it
kianenigma Aug 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Soem more cleanup
  • Loading branch information
emostov committed Aug 24, 2021
commit 5aa980c1b889269deaa7fff852235c95460ebfac
51 changes: 30 additions & 21 deletions frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ impl<T: Config> ListScenario<T> {
fn new(origin_weight: BalanceOf<T>, is_increase: bool) -> Result<Self, &'static str> {
ensure!(!origin_weight.is_zero(), "origin weight must be greater than 0");

// create_stash_controller takes a factor, so we compute it.
// create_stash_controller takes a factor, so we compute it
let origin_factor: BalanceOf<T> =
origin_weight * 10u32.into() / T::Currency::minimum_balance();

// create validators to nominate.
// create validators to nominate
let validators = create_validators::<T>(
T::MAX_NOMINATIONS,
100,
Expand Down Expand Up @@ -194,7 +194,7 @@ impl<T: Config> ListScenario<T> {
validators.clone(),
)?;

// find a destination weight that will trigger the worst case scenario.
// find a destination weight that will trigger the worst case scenario
let dest_weight_as_vote =
T::SortedListProvider::weight_update_worst_case(&origin_stash1, is_increase);
let total_issuance = T::Currency::total_issuance();
Expand Down Expand Up @@ -222,10 +222,18 @@ impl<T: Config> ListScenario<T> {
}

fn check_preconditions(&self) {
let ListScenario { dest_stash1, origin_stash2, origin_stash1, origin_weight_as_vote, .. }
= self;
// destination stash1 is not in the origin pos.
let ListScenario {
dest_stash1,
origin_stash2,
origin_stash1,
origin_weight_as_vote,
dest_weight_as_vote,
..
} = self;
// destination stash1 is not in the origin pos,
assert!(!T::SortedListProvider::is_in_pos(&dest_stash1, *origin_weight_as_vote, false));
// and is in the destination pos.
assert!(T::SortedListProvider::is_in_pos(&dest_stash1, *dest_weight_as_vote, true));
// origin stash1 is in the origin pos.
assert!(T::SortedListProvider::is_in_pos(&origin_stash1, *origin_weight_as_vote, true));
// origin stash2 is in the origin pos.
Expand All @@ -238,14 +246,17 @@ impl<T: Config> ListScenario<T> {
origin_stash1,
dest_weight_as_vote,
origin_weight_as_vote,
origin_stash2,
..
} = self;
// dest stash1 is not in the origin pos.
// dest stash1 is not in the origin pos,
assert!(!T::SortedListProvider::is_in_pos(&dest_stash1, *origin_weight_as_vote, false));
// and is in the destination pos.
// and is still in the destination pos.
assert!(T::SortedListProvider::is_in_pos(&dest_stash1, *dest_weight_as_vote, true));
// origin stash1 is now in the destination pos.
assert!(T::SortedListProvider::is_in_pos(&origin_stash1, *dest_weight_as_vote, true));
// origin stash2 is still in the origin pos.
assert!(T::SortedListProvider::is_in_pos(&origin_stash2, *origin_weight_as_vote, true));
}
}

Expand Down Expand Up @@ -285,7 +296,7 @@ benchmarks! {
scenario.check_preconditions();

whitelist_account!(stash);
}: _(RawOrigin::Signed(stash.clone()), max_additional)
}: _(RawOrigin::Signed(stash), max_additional)
verify {
let ledger = Ledger::<T>::get(&controller).ok_or("ledger not created after")?;
let new_bonded: BalanceOf<T> = ledger.active;
Expand Down Expand Up @@ -347,7 +358,7 @@ benchmarks! {
clear_validators_and_nominators::<T>();

// setup a worst case list scenario. Note that we don't care about the setup of the
// destination bag.
// destination position because we are doing a removal from the list but no insert.
let scenario = ListScenario::<T>::new(One::one(), true)?;
let controller = scenario.origin_controller1.clone();
let stash = scenario.origin_stash1.clone();
Expand Down Expand Up @@ -482,13 +493,12 @@ benchmarks! {
}

chill {
// Clean up any existing state.
// clean up any existing state.
clear_validators_and_nominators::<T>();

// setup a worst case list scenario. Note that we don't care about the setup of the
// destination bag.
let scenario
= ListScenario::<T>::new(One::one(), true)?;
// destination position because we are doing a removal from the list but no insert.
let scenario = ListScenario::<T>::new(One::one(), true)?;
let controller = scenario.origin_controller1.clone();
let stash = scenario.origin_stash1.clone();
assert!(T::SortedListProvider::contains(&stash));
Expand Down Expand Up @@ -555,9 +565,8 @@ benchmarks! {
clear_validators_and_nominators::<T>();

// setup a worst case list scenario. Note that we don't care about the setup of the
// destination bag.
let scenario
= ListScenario::<T>::new(One::one(), true)?;
// destination position because we are doing a removal from the list but no insert.
let scenario = ListScenario::<T>::new(One::one(), true)?;
let controller = scenario.origin_controller1.clone();
let stash = scenario.origin_stash1.clone();
assert!(T::SortedListProvider::contains(&stash));
Expand Down Expand Up @@ -663,7 +672,7 @@ benchmarks! {

// setup a worst case list scenario.

// the weight the nominator will start at. Note we use 100 to play friendly with the bags
// the weight the nominator will start at. Note we use 100 to play friendly with the bags,
// list threshold values in the mock.
let origin_weight = 100u32.into();
let scenario = ListScenario::<T>::new(origin_weight, true)?;
Expand All @@ -674,7 +683,7 @@ benchmarks! {

// spread that amount to rebond across `l` unlocking chunks,
let value = rebond_amount / l.into();
// so the sum of unlocking chunks puts voter into the dest bag
// so the sum of unlocking chunks puts voter into the dest bag.
assert!(value * l.into() + origin_weight > origin_weight);
assert!(value * l.into() + origin_weight <= dest_weight);
let unlock_chunk = UnlockChunk::<BalanceOf<T>> {
Expand Down Expand Up @@ -728,7 +737,7 @@ benchmarks! {
clear_validators_and_nominators::<T>();

// setup a worst case list scenario. Note that we don't care about the setup of the
// destination bag.
// destination position because we are doing a removal from the list but no insert.
let scenario = ListScenario::<T>::new(One::one(), true)?;
let controller = scenario.origin_controller1.clone();
let stash = scenario.origin_stash1.clone();
Expand Down Expand Up @@ -894,7 +903,7 @@ benchmarks! {
clear_validators_and_nominators::<T>();

// setup a worst case list scenario. Note that we don't care about the setup of the
// destination bag.
// destination position because we are doing a removal from the list but no insert.
let scenario = ListScenario::<T>::new(One::one(), true)?;
let controller = scenario.origin_controller1.clone();
let stash = scenario.origin_stash1.clone();
Expand Down