Skip to content
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

Migrate pallet-democracy benchmarks to benchmark v2 syntax #6509

Open
wants to merge 140 commits into
base: master
Choose a base branch
from
Open
Changes from 137 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
51f9a34
Removed libp2p dependancy from sc_network_sync
ndkazu Jul 8, 2024
b4e3f5a
Preparing an alternative to libp2p dependant OutBoundFailure
ndkazu Jul 9, 2024
fa242e5
Merge branch 'master' into libp2p
ndkazu Jul 9, 2024
6a1fcf1
Agnostic sc-network-sync
ndkazu Jul 10, 2024
b20e332
Merge branch 'paritytech:master' into libp2p
ndkazu Jul 10, 2024
fdac723
Merge branch 'master' into libp2p
ndkazu Jul 15, 2024
b33728b
Update substrate/client/network/src/request_responses.rs
ndkazu Jul 16, 2024
d8fbc30
Remove crate libp2p from sc-authority-discovery
ndkazu Jul 16, 2024
86d50af
Merge branch 'libp2p' of github.com:ndkazu/polkadot-sdk into libp2p
ndkazu Jul 16, 2024
2f09ebd
Removed event
ndkazu Jul 17, 2024
d0e2084
Add a custom InboundFailure
ndkazu Jul 17, 2024
3f7e5ad
Removed the variant Network
ndkazu Jul 18, 2024
6dd1bd3
Changed the type of
ndkazu Jul 20, 2024
97a5453
Merge branch 'master' into libp2p
ndkazu Jul 20, 2024
12db7fa
Merge branch 'master' into libp2p
ndkazu Jul 22, 2024
02f0085
Merge branch 'paritytech:master' into libp2p
ndkazu Jul 24, 2024
372f9fc
Replaced Network2 by Network, and added comments to enums
ndkazu Jul 24, 2024
28830fe
Replaced Network2 by Network
ndkazu Jul 24, 2024
f02b17c
Removed Event0, Need to remove ToSwarm dependance to libp2p
ndkazu Jul 26, 2024
ccbc94a
Merge branch 'paritytech:master' into libp2p
ndkazu Aug 3, 2024
7229689
Merge branch 'master' into libp2p
ndkazu Sep 2, 2024
8609e59
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 3, 2024
54c54c5
Ready for review
ndkazu Sep 3, 2024
ae006e1
First corrections
ndkazu Sep 5, 2024
a52c9d4
Second round of corrections
ndkazu Sep 5, 2024
73860e6
cargo +nightly fmt
ndkazu Sep 5, 2024
7ed1124
Merge branch 'master' into libp2p
ndkazu Sep 6, 2024
db03bc5
Revert "cargo +nightly fmt"
ndkazu Sep 7, 2024
3dd3834
Merge branch 'master' into libp2p
ndkazu Sep 7, 2024
f194e5f
".git/.scripts/commands/fmt/fmt.sh"
Sep 9, 2024
6ac72b3
Removed all #[error(dial-failure)]
ndkazu Sep 9, 2024
104b1c4
Merge branch 'master' into libp2p
ndkazu Sep 9, 2024
e056e0e
Merge branch 'master' into libp2p
ndkazu Sep 11, 2024
53ea246
Replaced CustomOutboundFailure by OutboundFailure
ndkazu Sep 12, 2024
65c732e
Merge branch 'master' into libp2p
ndkazu Sep 12, 2024
da7adc3
first round of corrections
ndkazu Sep 13, 2024
7c916bc
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
aab8614
Reverted where it was necessary
ndkazu Sep 13, 2024
812734c
corrections
ndkazu Sep 13, 2024
35e884e
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
0062a74
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
dd08c06
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
cc0c400
Merge branch 'master' into libp2p
ndkazu Sep 14, 2024
67fe210
Created a prdoc
ndkazu Sep 16, 2024
c608293
Merge branch 'master' into libp2p
ndkazu Sep 16, 2024
a74ebd0
Merge branch 'master' into libp2p
ndkazu Sep 17, 2024
73d4005
implemented From<...> for OutbounFailure & InboundFailure
ndkazu Sep 17, 2024
2fcf160
Reverted changes unrelated to the purpose of the PR
ndkazu Sep 17, 2024
c2abf70
more revert
ndkazu Sep 17, 2024
9c8248b
Merge branch 'master' into libp2p
ndkazu Sep 17, 2024
34cdc57
".git/.scripts/commands/fmt/fmt.sh"
Sep 17, 2024
1ee40e1
Added newline at EOF
ndkazu Sep 17, 2024
a354c2e
Further corrections
ndkazu Sep 17, 2024
abc6f68
correcting format
ndkazu Sep 17, 2024
dfcc689
more format correction
ndkazu Sep 17, 2024
7bb250f
removed space
ndkazu Sep 17, 2024
ba729b5
".git/.scripts/commands/fmt/fmt.sh"
Sep 17, 2024
c969d26
Latest review corrections
ndkazu Sep 17, 2024
e226706
Manual Formatting
ndkazu Sep 17, 2024
f1e0164
Correct newline at EOF in prdoc
dmitry-markin Sep 18, 2024
27c8e13
Merge branch 'master' into libp2p
lexnv Sep 18, 2024
f578962
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 18, 2024
6a3a045
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 24, 2024
f44b2eb
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 25, 2024
b0e1fd1
Starting
ndkazu Sep 25, 2024
f4c798f
Merge branch 'libp2p' of github.com:ndkazu/polkadot-sdk into libp2p
ndkazu Sep 25, 2024
141fbbc
Preparing new types
ndkazu Sep 26, 2024
887c877
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 26, 2024
086c976
libp2p still used in tests
ndkazu Sep 26, 2024
73b46ed
Merge branch 'master' into libp2p
ndkazu Sep 26, 2024
5c02af7
some corrections
ndkazu Sep 27, 2024
b13248f
License
ndkazu Sep 27, 2024
0ec6f2d
Merge branch 'master' into libp2p
ndkazu Sep 27, 2024
a1ed269
Fix clippy
ndkazu Sep 27, 2024
c0baae5
PRdoc
ndkazu Sep 28, 2024
c944af9
PRdoc
ndkazu Sep 28, 2024
bc2e56e
PRdoc
ndkazu Sep 28, 2024
1efb0b2
Removed libp2p from sc-authority-discovery
ndkazu Sep 28, 2024
f9e5edb
Removed libp2p from sc-authority-discovery
ndkazu Sep 28, 2024
568c1e6
Removed libp2p from sc-authority-discovery
ndkazu Sep 28, 2024
48fe9b4
Merge branch 'master' into libp2p
ndkazu Sep 28, 2024
f48a4e2
Merge branch 'master' into libp2p
ndkazu Sep 29, 2024
03e10b5
Merge branch 'master' into libp2p
ndkazu Sep 30, 2024
e3cc477
Merge branch 'master' into libp2p
ndkazu Sep 30, 2024
6052d78
cargo clippy
ndkazu Sep 30, 2024
f3cf4df
Clippy
ndkazu Sep 30, 2024
ddde1b1
Removed all libp2p dependency from sc-authority-discovery
ndkazu Oct 1, 2024
5b2d95e
Merge branch 'master' into libp2p
ndkazu Oct 1, 2024
128ae48
clippy
ndkazu Oct 1, 2024
75cdda4
Fix tests in sc-network
ndkazu Oct 1, 2024
008674c
".git/.scripts/commands/fmt/fmt.sh"
Oct 1, 2024
5f72326
Fixed prdoc
ndkazu Oct 1, 2024
bce2179
Merge branch 'libp2p' of github.com:ndkazu/polkadot-sdk into libp2p
ndkazu Oct 1, 2024
6ef6230
Merge branch 'master' into libp2p
ndkazu Oct 1, 2024
c2f1686
Merge branch 'master' into libp2p
ndkazu Oct 2, 2024
25e12d1
Merge branch 'master' into libp2p
ndkazu Oct 3, 2024
a22a330
Merge branch 'master' into libp2p
ndkazu Oct 4, 2024
afa7659
Merge branch 'master' into libp2p
ndkazu Oct 5, 2024
61926d7
Merge branch 'master' into libp2p
ndkazu Oct 6, 2024
d764d23
Merge branch 'master' into libp2p
ndkazu Oct 7, 2024
c96ace5
Update substrate/client/network/types/src/rec.rs
ndkazu Oct 7, 2024
a3210f5
Applied review corrections
ndkazu Oct 7, 2024
8b13128
Merge branch 'master' into libp2p
ndkazu Oct 7, 2024
0d5912e
Merge branch 'master' into libp2p
ndkazu Oct 8, 2024
d210aa5
Merge branch 'master' into libp2p
ndkazu Oct 9, 2024
c16b692
Merge branch 'master' into libp2p
ndkazu Oct 10, 2024
d59014a
Merge branch 'master' into libp2p
ndkazu Oct 13, 2024
010bbb8
Merge branch 'master' into libp2p
ndkazu Oct 16, 2024
42f5080
Merge branch 'master' into libp2p
ndkazu Oct 18, 2024
d5adbd7
Merge branch 'master' into libp2p
ndkazu Oct 22, 2024
e18a331
Merge branch 'master' into libp2p
ndkazu Oct 25, 2024
fc34928
Merge branch 'master' into libp2p
ndkazu Oct 29, 2024
0df8b33
changed file name from rec.rs to kad.rs
ndkazu Nov 2, 2024
596fcf9
Removed unnecessary into() and libp2p
ndkazu Nov 2, 2024
3ab3460
Removed unneeded conversions
ndkazu Nov 4, 2024
e7e5ccd
Started work on litep2p/mod.rs
ndkazu Nov 4, 2024
96302b0
Merge branch 'master' into libp2p
dmitry-markin Nov 8, 2024
04e74ff
".git/.scripts/commands/fmt/fmt.sh"
Nov 8, 2024
faf8ce8
Merge branch 'master' into libp2p
ndkazu Nov 9, 2024
d1a7df4
Update substrate/client/network/types/src/kad.rs
ndkazu Nov 9, 2024
35fc773
First round of corrections
ndkazu Nov 9, 2024
37d217a
2nd round of corrections
ndkazu Nov 9, 2024
0e60ca0
Corrected format
ndkazu Nov 9, 2024
349906a
Simplified function
ndkazu Nov 9, 2024
65f0af4
Simplified syntax
ndkazu Nov 11, 2024
7995de5
Merge branch 'master' into libp2p
ndkazu Nov 11, 2024
9043046
Merge branch 'master' into libp2p
ndkazu Nov 12, 2024
8618d00
Merge branch 'master' into libp2p
dmitry-markin Nov 12, 2024
e0bc0b6
minor: use `into()` to convert kad key
dmitry-markin Nov 12, 2024
7c402b2
Merge branch 'master' into libp2p
dmitry-markin Nov 12, 2024
7fafdd0
minor: simplify conversions
dmitry-markin Nov 12, 2024
91d2836
minor: simplify conversions (libp2p backend)
dmitry-markin Nov 12, 2024
c3b039f
empty, kick GitHub
dmitry-markin Nov 13, 2024
391047d
minor: more direct conversions in `NetworkWorker`
dmitry-markin Nov 13, 2024
c2f9463
Merge branch 'paritytech:master' into libp2p
ndkazu Nov 16, 2024
86cccce
Start migration to benchmarking V2
ndkazu Nov 16, 2024
6a8f452
Changing to V2
ndkazu Nov 17, 2024
0e907c4
Migrated benchmarking
ndkazu Nov 17, 2024
ab0b870
prdoc and some formating
ndkazu Nov 17, 2024
dae7a6e
prdoc
ndkazu Nov 17, 2024
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
55 changes: 39 additions & 16 deletions substrate/frame/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

//! Democracy pallet benchmarking.

#![cfg(feature = "runtime-benchmarks")]

use super::*;

use frame_benchmarking::v1::{account, benchmarks, whitelist_account, BenchmarkError};
use frame_benchmarking::v2::*;
use frame_support::{
assert_noop, assert_ok,
traits::{Currency, EnsureOrigin, Get, OnInitialize, UnfilteredDispatchable},
Expand Down Expand Up @@ -94,8 +96,12 @@ fn note_preimage<T: Config>() -> T::Hash {
hash
}

benchmarks! {
propose {
#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn propose() -> Result<(), BenchmarkError> {
let p = T::MaxProposals::get();

for i in 0 .. (p - 1) {
Expand All @@ -106,12 +112,16 @@ benchmarks! {
let proposal = make_proposal::<T>(0);
let value = T::MinimumDeposit::get();
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller), proposal, value)
verify {

#[extrinsic_call]
_(RawOrigin::Signed(caller), proposal, value);

assert_eq!(PublicProps::<T>::get().len(), p as usize, "Proposals not created.");
Ok(())
}

second {
#[benchmark]
fn second() -> Result<(), BenchmarkError> {
let caller = funded_account::<T>("caller", 0);
add_proposal::<T>(0)?;

Expand All @@ -125,13 +135,18 @@ benchmarks! {
let deposits = DepositOf::<T>::get(0).ok_or("Proposal not created")?;
assert_eq!(deposits.0.len(), (T::MaxDeposits::get() - 1) as usize, "Seconds not recorded");
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller), 0)
verify {

#[extrinsic_call]
_(RawOrigin::Signed(caller), 0);


let deposits = DepositOf::<T>::get(0).ok_or("Proposal not created")?;
assert_eq!(deposits.0.len(), (T::MaxDeposits::get()) as usize, "`second` benchmark did not work");
Ok(())
}

vote_new {
#[benchmark]
fn vote_new() -> Result<(), BenchmarkError> {
let caller = funded_account::<T>("caller", 0);
let account_vote = account_vote::<T>(100u32.into());

Expand All @@ -148,16 +163,21 @@ benchmarks! {

let ref_index = add_referendum::<T>(T::MaxVotes::get() - 1).0;
whitelist_account!(caller);
}: vote(RawOrigin::Signed(caller.clone()), ref_index, account_vote)
verify {

#[extrinsic_call]
vote(RawOrigin::Signed(caller.clone()), ref_index, account_vote);

let votes = match VotingOf::<T>::get(&caller) {
Voting::Direct { votes, .. } => votes,
_ => return Err("Votes are not direct".into()),
};

assert_eq!(votes.len(), T::MaxVotes::get() as usize, "Vote was not recorded.");
Ok(())
}

vote_existing {
#[benchmark]
fn vote_existing() -> Result<(), BenchmarkError> {
let caller = funded_account::<T>("caller", 0);
let account_vote = account_vote::<T>(100u32.into());

Expand All @@ -179,8 +199,10 @@ benchmarks! {

// This tests when a user changes a vote
whitelist_account!(caller);
}: vote(RawOrigin::Signed(caller.clone()), ref_index, new_vote)
verify {

#[extrinsic_call]
vote(RawOrigin::Signed(caller.clone()), ref_index, new_vote);

let votes = match VotingOf::<T>::get(&caller) {
Voting::Direct { votes, .. } => votes,
_ => return Err("Votes are not direct".into()),
Expand All @@ -193,8 +215,9 @@ benchmarks! {
_ => return Err("referendum not ongoing".into()),
};
assert_eq!(tally.nays, 1000u32.into(), "changed vote was not recorded");
Ok(())
}

/*
Copy link
Member

Choose a reason for hiding this comment

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

can you mark the PR as draft until you are ready for review

emergency_cancel {
let origin =
T::CancellationOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
Expand Down Expand Up @@ -845,7 +868,7 @@ benchmarks! {
hash,
}.into());
}

*/
impl_benchmark_test_suite!(
Democracy,
crate::tests::new_test_ext(),
Expand Down
Loading