Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

make MAX_VOTERS and MAX_CANDIDATES in elections-phragmen configurable. Fix: #11092 #11908

Merged
merged 17 commits into from
Aug 14, 2022

Conversation

sudipghimire533
Copy link
Contributor

@sudipghimire533 sudipghimire533 commented Jul 25, 2022

Closes: #11902
Polkadot companion: paritytech/polkadot#5815

Update

  • Allow max_voters & max_candidates to be configurable from Config trait of pallet_elections_phragmen
  • Put value 1000 (for max_candidates) & 10_000 (for max_voters) while creating runtime from /bin/node/runtime. Value taken as was in PR prep council election pallet for being dissolved #11790

Polkadot address: 126X27SbhrV19mBFawys3ovkyBS87SGfYwtwa8J2FjHrtbmA

@cla-bot-2021
Copy link

cla-bot-2021 bot commented Jul 25, 2022

User @sudipghimire533, please sign the CLA here.

@sudipghimire533 sudipghimire533 marked this pull request as ready for review July 25, 2022 15:38
@@ -395,9 +392,10 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;

let max_candidate = <T as Config>::MaxCandidates::get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let max_candidate = <T as Config>::MaxCandidates::get();

let actual_count = <Candidates<T>>::decode_len().unwrap_or(0) as u32;
ensure!(actual_count <= candidate_count, Error::<T>::InvalidWitnessData);
ensure!(actual_count <= MAX_CANDIDATES, Error::<T>::TooManyCandidates);
ensure!(actual_count <= max_candidate, Error::<T>::TooManyCandidates);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ensure!(actual_count <= max_candidate, Error::<T>::TooManyCandidates);
ensure!(actual_count <= <T as Config>::MaxCandidates::get(), Error::<T>::TooManyCandidates);

@kianenigma kianenigma added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Jul 25, 2022
@kianenigma
Copy link
Contributor

Looks mostly good, need to make companions.

@sudipghimire533
Copy link
Contributor Author

Polkadot companion: paritytech/polkadot#5815

@Szegoo
Copy link
Contributor

Szegoo commented Jul 26, 2022

@sudipghimire533 Note that you have to update the benchmarking.rs file also.

@sudipghimire533
Copy link
Contributor Author

sudipghimire533 commented Jul 26, 2022

@Szegoo maybe you can help me here:

error: expected one of `:`, `;`, `=`, `@`, or `|`, found keyword `in`
   --> frame/elections-phragmen/src/benchmarking.rs:394:9
    |
394 |         let e in T::MaxVoters::get() .. T::MaxVoters * MAXIMUM_VOTE as u32;
    |               ^^ expected one of `:`, `;`, `=`, `@`, or `|`

error: expected one of `:`, `;`, `=`, `@`, or `|`, found keyword `in`
   --> frame/elections-phragmen/src/benchmarking.rs:429:9
    |
429 |         let e in T::MaxVoters::get() .. T::MaxVoters::get() * MAXIMUM_VOTE as u32;
    |               ^^ expected one of `:`, `;`, `=`, `@`, or `|`

@kianenigma
Copy link
Contributor

@Szegoo maybe you can help me here:

error: expected one of `:`, `;`, `=`, `@`, or `|`, found keyword `in`
   --> frame/elections-phragmen/src/benchmarking.rs:394:9
    |
394 |         let e in T::MaxVoters::get() .. T::MaxVoters * MAXIMUM_VOTE as u32;
    |               ^^ expected one of `:`, `;`, `=`, `@`, or `|`

error: expected one of `:`, `;`, `=`, `@`, or `|`, found keyword `in`
   --> frame/elections-phragmen/src/benchmarking.rs:429:9
    |
429 |         let e in T::MaxVoters::get() .. T::MaxVoters::get() * MAXIMUM_VOTE as u32;
    |               ^^ expected one of `:`, `;`, `=`, `@`, or `|`

I think you need to wrap it in a parenthesis:

let v in (MaxValidators::<T>::get() / 2) .. MaxValidators::<T>::get();

@sudipghimire533
Copy link
Contributor Author

Not working same error and neither can I assign it as variable and re-use. @kianenigma do you think you can help me with benchmarking.rs ?

@Szegoo
Copy link
Contributor

Szegoo commented Jul 26, 2022

Not working same error and neither can I assign it as variable and re-use. @kianenigma do you think you can help me with benchmarking.rs ?

I have run into the same issue when working on this, the suggested solution from @kianenigma should work. Could you give me access to your branch, so maybe I manage to get it working?

@sudipghimire533
Copy link
Contributor Author

Not working same error and neither can I assign it as variable and re-use. @kianenigma do you think you can help me with benchmarking.rs ?

I have run into the same issue when working on this, the suggested solution from @kianenigma should work. Could you give me access to your branch, so maybe I manage to get it working?

@Szegoo I have invited you to my fork. Also I tried adding () as well. Not good from my side. Let's see

@sudipghimire533
Copy link
Contributor Author

Not working same error and neither can I assign it as variable and re-use. @kianenigma do you think you can help me with benchmarking.rs ?

I have run into the same issue when working on this, the suggested solution from @kianenigma should work. Could you give me access to your branch, so maybe I manage to get it working?

@Szegoo I have invited you to my fork. Also I tried adding () as well. Not good from my side. Let's see

Ahh you guys meant to only wrap the get. Gotcha but looks like benchmark verification failing no?

Jul 26 20:05:52.022 ERROR runtime::elections-phragmen: Failed to run election. Number of voters exceeded    

frame/elections-phragmen/src/lib.rs Outdated Show resolved Hide resolved
frame/elections-phragmen/src/lib.rs Outdated Show resolved Hide resolved
@@ -397,7 +394,7 @@ pub mod pallet {

let actual_count = <Candidates<T>>::decode_len().unwrap_or(0) as u32;
ensure!(actual_count <= candidate_count, Error::<T>::InvalidWitnessData);
ensure!(actual_count <= MAX_CANDIDATES, Error::<T>::TooManyCandidates);
ensure!(actual_count <= <T as Config>::MaxCandidates::get(), Error::<T>::TooManyCandidates);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ensure!(actual_count <= <T as Config>::MaxCandidates::get(), Error::<T>::TooManyCandidates);
ensure!(actual_count <= T::MaxCandidates::get(), Error::<T>::TooManyCandidates);

@ggwpez
Copy link
Member

ggwpez commented Aug 8, 2022

/cmd queue -c bench-bot $ pallet dev pallet_elections_phragmen

@command-bot
Copy link

command-bot bot commented Aug 8, 2022

@ggwpez https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1726285 was started for your command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_elections_phragmen. Check out https://gitlab.parity.io/parity/mirrors/substrate/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment /cmd cancel 10-705eccf4-9bf2-4e1f-aed1-46615cdc9dbf to cancel this command or /cmd cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Aug 8, 2022

@ggwpez Command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_elections_phragmen has finished. Result: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1726285 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1726285/artifacts/download.

@kianenigma
Copy link
Contributor

bot rebase

@paritytech-processbot
Copy link

Rebased

@kianenigma
Copy link
Contributor

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 34a0621 into paritytech:master Aug 14, 2022
@kianenigma
Copy link
Contributor

https://github.com/sudipghimire533 @Szegoo can you both paste your Polkadot address for a tip here?

@Szegoo
Copy link
Contributor

Szegoo commented Aug 14, 2022

https://github.com/sudipghimire533 @Szegoo can you both paste your Polkadot address for a tip here?

I can't edit the PR description, should I provide it somehow else?

@sudipghimire533
Copy link
Contributor Author

https://github.com/sudipghimire533 @Szegoo can you both paste your Polkadot address for a tip here?

I can't edit the PR description, should I provide it somehow else?

If it need to be in PR description you can put it here and I will put in the Description

@sudipghimire533
Copy link
Contributor Author

Mine is: 1FNfKQFHFLp2Fin8Xqz1KhtZ5nVr4RqCM4Z5SGtv6QctCA9

@Szegoo
Copy link
Contributor

Szegoo commented Aug 15, 2022

Polkadot address: 126X27SbhrV19mBFawys3ovkyBS87SGfYwtwa8J2FjHrtbmA

@kianenigma
Copy link
Contributor

/tip small

@substrate-tip-bot
Copy link

@kianenigma A small tip was successfully submitted for sudipghimire533 (1FNfKQFHFLp2Fin8Xqz1KhtZ5nVr4RqCM4Z5SGtv6QctCA9 on polkadot).

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/treasury/tips

@kianenigma
Copy link
Contributor

/tip small

@substrate-tip-bot
Copy link

@kianenigma A small tip was successfully submitted for sudipghimire533 (126X27SbhrV19mBFawys3ovkyBS87SGfYwtwa8J2FjHrtbmA on polkadot).

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/treasury/tips

@Szegoo
Copy link
Contributor

Szegoo commented Aug 17, 2022

/tip small

It doesn't seem like this worked, only the first tip was submitted if I am not mistaken.

@sudipghimire533
Copy link
Contributor Author

On my address as well there we no balance whatsoever. Maybe because mine was freshly created address and it didn't even had existential deposit

@Szegoo
Copy link
Contributor

Szegoo commented Aug 17, 2022

On my address as well there we no balance whatsoever. Maybe because mine was freshly created address and it didn't even had existential deposit

Yours was submitted successfully, you can check it on https://www.dotreasury.com/dot/tips

@sudipghimire533
Copy link
Contributor Author

@Szegoo
Copy link
Contributor

Szegoo commented Aug 17, 2022

That is because no one has yet declared a tip value, you can check how this works in the tips pallet(https://github.com/paritytech/substrate/tree/master/frame/tips/)

@sudipghimire533
Copy link
Contributor Author

That is because no one has yet declared a tip value, you can check how this works in the tips pallet(https://github.com/paritytech/substrate/tree/master/frame/tips/)

Is that something I need to do or parity team?

@Szegoo
Copy link
Contributor

Szegoo commented Aug 17, 2022

That is because no one has yet declared a tip value, you can check how this works in the tips pallet(https://github.com/paritytech/substrate/tree/master/frame/tips/)

Is that something I need to do or parity team?

You don't have to do anything, you need to wait for the tippers to declare the tip value.

ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…Fix: paritytech#11092 (paritytech#11908)

* make MAX_VOTERS and MAX_CANDIDATES in elections-phragmen configurable

* Configure election-phragmen in node bin configuring max candidates & voters

* Add document comment for added Config parameter

* Incorporate suggestion

* fix benchmarks

* Update frame/elections-phragmen/src/lib.rs

* Update frame/elections-phragmen/src/lib.rs

* fix wrong values

* fix typo

* docs

* more detailed docs

* fmt

* ".git/.scripts/bench-bot.sh" pallet dev pallet_elections_phragmen

Co-authored-by: Szegoo <sakacszergej@gmail.com>
Co-authored-by: Sergej Sakac <73715684+Szegoo@users.noreply.github.com>
Co-authored-by: command-bot <>
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. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make MAX_VOTERS and MAX_CANDIDATES in elections-phragmen configurable
7 participants