Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
62dc0d7
New Society
gavofyork Apr 30, 2022
135009c
More logic drafting
gavofyork Apr 30, 2022
01c6834
More work
gavofyork May 3, 2022
a6577e0
Building
gavofyork May 3, 2022
feb7d6b
Some tests
gavofyork May 3, 2022
f7ce7e3
Fixes
gavofyork May 4, 2022
841c732
Improvements to the voting process
gavofyork May 4, 2022
8b997cd
More tests
gavofyork May 4, 2022
3f9fdbd
Test number 20
gavofyork May 4, 2022
98f4060
Tests
gavofyork May 4, 2022
3f6ba74
30 tests
gavofyork May 4, 2022
89c4bf6
Another test]
gavofyork May 5, 2022
db636be
All tests enabled
gavofyork May 5, 2022
d6abcb9
Minor stuff
gavofyork May 5, 2022
f8360a8
generate_storage_alias: Rewrite as proc macro attribute
bkchr May 10, 2022
43cf8c1
Maintenance operations don't pay fee
gavofyork May 10, 2022
0fbf6b5
Merge remote-tracking branch 'origin/master' into gav-society-v2
gavofyork May 10, 2022
287269d
Merge remote-tracking branch 'origin/bkchr-storage-alias-proc-macro' …
gavofyork May 10, 2022
b12cbb2
Fix compilation and FMT
bkchr May 10, 2022
249b664
Moare fixes
bkchr May 10, 2022
0763482
Merge remote-tracking branch 'origin/bkchr-storage-alias-proc-macro' …
gavofyork May 10, 2022
676595c
Migrations
gavofyork May 11, 2022
0fe52d8
Fix tests and add migration testing
gavofyork May 11, 2022
27abee7
Introduce lazy-cleanup and avoid unbounded prefix removal
gavofyork May 11, 2022
adccb66
Fixes
gavofyork May 18, 2022
06700bd
Merge remote-tracking branch 'origin/master' into gav-society-v2
gavofyork May 31, 2022
aefd6db
Fixes
gavofyork Jun 1, 2022
1bbc803
Merge remote-tracking branch 'origin/master' into gav-society-v2
gavofyork Jun 1, 2022
be940c1
[WIP][Society] Adding benchmarking to the v2. (#11776)
arturgontijo Dec 3, 2022
0f4f927
Merge branch 'master' into gav-society-v2
gavofyork Dec 3, 2022
3f20f36
Fix Cargo
gavofyork Dec 5, 2022
db9990f
Fixes
gavofyork Dec 7, 2022
6218e32
Merge remote-tracking branch 'origin/master' into gav-society-v2
gavofyork Dec 7, 2022
d9dce35
Fixes
gavofyork Dec 7, 2022
4c60eef
Spelling
gavofyork Dec 8, 2022
fc1d682
Merge branch 'master' into gav-society-v2
gavofyork Jan 21, 2023
e1214b3
Merge remote-tracking branch 'origin/master' into gav-society-v2
gavofyork Jun 11, 2023
3f119f1
Fix benchmarks
gavofyork Jun 12, 2023
59d1545
Merge remote-tracking branch 'origin/master' into gav-society-v2
gavofyork Jun 12, 2023
2440062
Another fix
gavofyork Jun 12, 2023
7811ac1
Remove println
gavofyork Jun 12, 2023
687d914
Society migration
gavofyork Jun 12, 2023
4841585
Merge remote-tracking branch 'origin/master' into gav-society-v2
Jun 13, 2023
1864679
Merge branch 'gav-society-v2' of github.com:paritytech/substrate into…
gavofyork Jun 13, 2023
ab1eafd
Fixes
gavofyork Jun 13, 2023
c01e8bc
Docs
gavofyork Jun 13, 2023
3d3b43c
Docs
gavofyork Jun 13, 2023
3b73c57
Remove accidental addition.
gavofyork Jun 13, 2023
e51eebf
Fixes
gavofyork Jun 13, 2023
43ea1db
Clippy
gavofyork Jun 14, 2023
bfed684
Fixes
gavofyork Jun 14, 2023
ba534a6
Docs
gavofyork Jun 14, 2023
1528a58
Improve try_runtime test
gavofyork Jun 15, 2023
af65cf7
Use pallet storage version
gavofyork Jun 15, 2023
308e646
Fix up society cargo toml file
gavofyork Jun 15, 2023
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
Fix benchmarks
  • Loading branch information
gavofyork committed Jun 12, 2023
commit 3f119f1b892cf701bf558f3955039fedc426a560
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 47 additions & 14 deletions frame/society/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,33 @@ fn mock_balance_deposit<T: Config<I>, I: 'static>() -> BalanceOf<T, I> {
T::Currency::minimum_balance().saturating_mul(1_000u32.into())
}

fn make_deposit<T: Config<I>, I: 'static>(who: &T::AccountId) -> BalanceOf<T, I> {
let amount = mock_balance_deposit::<T, I>();
let required = amount.saturating_add(T::Currency::minimum_balance());
if T::Currency::free_balance(who) < required {
T::Currency::make_free_balance_be(who, required);
}
T::Currency::reserve(who, amount).expect("Pre-funded account; qed");
amount
}

fn make_bid<T: Config<I>, I: 'static>(
who: &T::AccountId,
) -> BidKind<T::AccountId, BalanceOf<T, I>> {
BidKind::Deposit(make_deposit::<T, I>(who))
}

fn fund_society<T: Config<I>, I: 'static>() {
T::Currency::make_free_balance_be(
&Society::<T, I>::account_id(),
BalanceOf::<T, I>::max_value(),
);
Pot::<T, I>::put(&BalanceOf::<T, I>::max_value());
}

// Set up Society
fn setup_society<T: Config<I>, I: 'static>() -> Result<T::AccountId, &'static str> {
let origin = T::FounderSetOrigin::successful_origin();
let origin = T::FounderSetOrigin::try_successful_origin().map_err(|_| "No origin")?;
let founder: T::AccountId = account("founder", 0, 0);
let founder_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(founder.clone());
let max_members = 5u32;
Expand All @@ -49,6 +73,16 @@ fn setup_society<T: Config<I>, I: 'static>() -> Result<T::AccountId, &'static st
mock_balance_deposit::<T, I>(),
b"benchmarking-society".to_vec(),
)?;
T::Currency::make_free_balance_be(
&Society::<T, I>::account_id(),
T::Currency::minimum_balance(),
);
Ok(founder)
}

fn setup_funded_society<T: Config<I>, I: 'static>() -> Result<T::AccountId, &'static str> {
let founder = setup_society::<T, I>()?;
fund_society::<T, I>();
Ok(founder)
}

Expand All @@ -58,10 +92,9 @@ fn add_candidate<T: Config<I>, I: 'static>(
skeptic_struck: bool,
) -> T::AccountId {
let candidate: T::AccountId = account(name, 0, 0);
T::Currency::make_free_balance_be(&candidate, BalanceOf::<T, I>::max_value());
let candidacy = Candidacy {
round: RoundCount::<T, I>::get(),
kind: BidKind::Deposit(mock_balance_deposit::<T, I>()),
kind: make_bid::<T, I>(&candidate),
bid: 0u32.into(),
tally,
skeptic_struck,
Expand Down Expand Up @@ -92,11 +125,12 @@ benchmarks_instance_pallet! {
}

unbid {
println!("MD: {:?}", mock_balance_deposit::<T, I>());
let founder = setup_society::<T, I>()?;
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T, I>::max_value());
let mut bids = Bids::<T, I>::get();
Society::<T, I>::insert_bid(&mut bids, &caller, 10u32.into(), BidKind::Deposit(mock_balance_deposit::<T, I>()));
Society::<T, I>::insert_bid(&mut bids, &caller, 10u32.into(), make_bid::<T, I>(&caller));
Bids::<T, I>::put(bids);
}: _(RawOrigin::Signed(caller.clone()))
verify {
Expand Down Expand Up @@ -162,14 +196,12 @@ benchmarks_instance_pallet! {
}

payout {
let founder = setup_society::<T, I>()?;
let founder = setup_funded_society::<T, I>()?;
// Payee's account already exists and is a member.
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, mock_balance_deposit::<T, I>());
let _ = Society::<T, I>::insert_member(&caller, 0u32.into());
T::Currency::make_free_balance_be(&Society::<T, I>::payouts(), BalanceOf::<T, I>::max_value());
let mut pot = <Pot<T, I>>::get();
pot = pot.saturating_add(BalanceOf::<T, I>::max_value());
Pot::<T, I>::put(&pot);
// Introduce payout.
Society::<T, I>::bump_payout(&caller, 0u32.into(), 1u32.into());
}: _(RawOrigin::Signed(caller.clone()))
verify {
Expand All @@ -178,11 +210,10 @@ benchmarks_instance_pallet! {
}

waive_repay {
let founder = setup_society::<T, I>()?;
let founder = setup_funded_society::<T, I>()?;
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T, I>::max_value());
let _ = Society::<T, I>::insert_member(&caller, 0u32.into());
T::Currency::make_free_balance_be(&Society::<T, I>::payouts(), BalanceOf::<T, I>::max_value());
Society::<T, I>::bump_payout(&caller, 0u32.into(), 1u32.into());
}: _(RawOrigin::Signed(caller.clone()), 1u32.into())
verify {
Expand All @@ -192,7 +223,7 @@ benchmarks_instance_pallet! {

found_society {
let founder: T::AccountId = whitelisted_caller();
let can_found = T::FounderSetOrigin::successful_origin();
let can_found = T::FounderSetOrigin::try_successful_origin().map_err(|_| "No origin")?;
let founder_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(founder.clone());
}: _<T::RuntimeOrigin>(can_found, founder_lookup, 5, 3, 3, mock_balance_deposit::<T, I>(), b"benchmarking-society".to_vec())
verify {
Expand Down Expand Up @@ -246,8 +277,10 @@ benchmarks_instance_pallet! {
let skeptic: T::AccountId = account("skeptic", 0, 0);
let _ = Society::<T, I>::insert_member(&skeptic, 0u32.into());
Skeptic::<T, I>::put(&skeptic);
frame_system::Pallet::<T>::set_block_number(T::VotingPeriod::get() + 1u32.into());
}: _(RawOrigin::Signed(candidate.clone()))
if let Period::Voting { more, .. } = Society::<T, I>::period() {
frame_system::Pallet::<T>::set_block_number(frame_system::Pallet::<T>::block_number() + more);
}
}: _(RawOrigin::Signed(candidate.clone()))
verify {
let candidacy = Candidates::<T, I>::get(&candidate).unwrap();
assert_eq!(candidacy.skeptic_struck, true);
Expand Down
1 change: 1 addition & 0 deletions frame/society/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ pub mod pallet {
/// Remove up to `max` stale votes for the defender in the given `challenge_round`.
///
/// May be called by any Signed origin, but only after the challenge round is ended.
#[pallet::call_index(19)]
#[pallet::weight(T::WeightInfo::cleanup_challenge())]
pub fn cleanup_challenge(
origin: OriginFor<T>,
Expand Down
2 changes: 1 addition & 1 deletion primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", default-features =
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
log = { version = "0.4.17", default-features = false }
serde = { version = "1.0.163", optional = true, default-features = false, features = ["derive", "alloc"] }
bounded-collections = { version = "0.1.7", default-features = false }
bounded-collections = { version = "0.1.8", default-features = false }
primitive-types = { version = "0.12.0", default-features = false, features = ["codec", "scale-info"] }
impl-serde = { version = "0.4.0", default-features = false, optional = true }
hash-db = { version = "0.16.0", default-features = false }
Expand Down
4 changes: 3 additions & 1 deletion primitives/core/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use scale_info::TypeInfo;

#[cfg(feature = "serde")]
use crate::crypto::Ss58Codec;
use crate::crypto::{CryptoType, CryptoTypeId, Derive, FromEntropy, Public as TraitPublic, UncheckedFrom};
use crate::crypto::{
CryptoType, CryptoTypeId, Derive, FromEntropy, Public as TraitPublic, UncheckedFrom,
};
#[cfg(feature = "full_crypto")]
use crate::crypto::{DeriveError, DeriveJunction, Pair as TraitPair, SecretStringError};
#[cfg(feature = "full_crypto")]
Expand Down
5 changes: 4 additions & 1 deletion primitives/core/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ use schnorrkel::{
use sp_std::vec::Vec;

use crate::{
crypto::{ByteArray, CryptoType, CryptoTypeId, Derive, FromEntropy, Public as TraitPublic, UncheckedFrom},
crypto::{
ByteArray, CryptoType, CryptoTypeId, Derive, FromEntropy, Public as TraitPublic,
UncheckedFrom,
},
hash::{H256, H512},
};
use codec::{Decode, Encode, MaxEncodedLen};
Expand Down