Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 16 additions & 32 deletions pallets/dao-collective/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ benchmarks_instance_pallet! {
// Add previous proposals.
for i in 0 .. p - 1 {
// Proposals should be different so that different proposal hashes are generated
let proposal: T::Proposal = SystemCall::<T>::remark { remark: vec![i as u8; b as usize] }.into();
let proposal: T::Proposal =
SystemCall::<T>::remark { remark: vec![i as u8; b as usize] }.into();
Collective::<T, I>::propose(
SystemOrigin::Signed(caller.clone()).into(),
0,
Expand All @@ -114,19 +115,11 @@ benchmarks_instance_pallet! {

assert_eq!(Collective::<T, I>::proposals(0).len(), (p - 1) as usize);

let proposal: T::Proposal = SystemCall::<T>::remark { remark: vec![p as u8; b as usize] }.into();
let proposal: T::Proposal =
SystemCall::<T>::remark { remark: vec![p as u8; b as usize] }.into();
let bounded = T::Preimages::bound(proposal.clone())?.transmute();
let proposal_hash = T::Hashing::hash_of(&bounded);

let meta: Option<Vec<u8>> = Some("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor \
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, \
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim \
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo \
consequat. Duis aute irure dolor in reprehenderit".into());
let meta = Some(vec![97_u8; T::ProposalMetadataLimit::get() as usize]);
}: _(
SystemOrigin::Signed(caller.clone()),
0,
Expand All @@ -152,11 +145,10 @@ benchmarks_instance_pallet! {
}

vote {
let b in 1 .. MAX_BYTES;
// We choose 5 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 5 .. T::MaxMembers::get();

let p = T::MaxProposals::get();
let b = MAX_BYTES;
let bytes_in_storage = b + size_of::<u32>() as u32;

create_dao::<T, I>()?;
Expand Down Expand Up @@ -230,35 +222,32 @@ benchmarks_instance_pallet! {
}

close_early_disapproved {
let b in 1 .. MAX_BYTES;
// We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 4 .. T::MaxMembers::get();
let p in 1 .. T::MaxProposals::get();

let bytes = 100;
let bytes_in_storage = bytes + size_of::<u32>() as u32;
let bytes_in_storage = b + size_of::<u32>() as u32;

create_dao::<T, I>()?;

// Construct `members`.
let mut members = vec![];
let proposer = account::<T::AccountId>("proposer", 0, SEED);
let proposer: T::AccountId = account::<T::AccountId>("proposer", 0, SEED);
members.push(proposer.clone());
for i in 1 .. m - 1 {
let member = account::<T::AccountId>("member", i, SEED);
members.push(member);
}
let voter = account::<T::AccountId>("voter", 0, SEED);
let voter: T::AccountId = account::<T::AccountId>("voter", 0, SEED);
members.push(voter.clone());
Collective::<T, I>::initialize_members(0, members.clone())?;

// Add previous proposals
let mut last_hash = T::Hash::default();
for i in 0 .. p {
// Proposals should be different so that different proposal hashes are generated
let proposal: T::Proposal = SystemCall::<T>::remark {

remark: vec![i as u8; bytes as usize]
}.into();
let proposal: T::Proposal =
SystemCall::<T>::remark { remark: vec![i as u8; b as usize] }.into();
Collective::<T, I>::propose(
SystemOrigin::Signed(proposer.clone()).into(),
0,
Expand Down Expand Up @@ -315,7 +304,6 @@ benchmarks_instance_pallet! {
// We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 4 .. T::MaxMembers::get();
let p in 1 .. T::MaxProposals::get();

let bytes_in_storage = b + size_of::<u32>() as u32;

create_dao::<T, I>()?;
Expand Down Expand Up @@ -412,12 +400,11 @@ benchmarks_instance_pallet! {

// TODO: get back to it in case if prime member returned back
close_disapproved {
let b in 1 .. MAX_BYTES;
// We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 4 .. T::MaxMembers::get();
let p in 1 .. T::MaxProposals::get();

let bytes = 100;
let bytes_in_storage = bytes + size_of::<u32>() as u32;
let bytes_in_storage = b + size_of::<u32>() as u32;

create_dao::<T, I>()?;

Expand All @@ -438,10 +425,8 @@ benchmarks_instance_pallet! {
let mut last_hash = T::Hash::default();
for i in 0 .. p {
// Proposals should be different so that different proposal hashes are generated
let proposal: T::Proposal = SystemCall::<T>::remark {

remark: vec![i as u8; bytes as usize]
}.into();
let proposal: T::Proposal =
SystemCall::<T>::remark { remark: vec![i as u8; b as usize] }.into();
Collective::<T, I>::propose(
SystemOrigin::Signed(caller.clone()).into(),
0,
Expand Down Expand Up @@ -500,7 +485,6 @@ benchmarks_instance_pallet! {
// We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 4 .. T::MaxMembers::get();
let p in 1 .. T::MaxProposals::get();

let bytes_in_storage = b + size_of::<u32>() as u32;

create_dao::<T, I>()?;
Expand Down
12 changes: 1 addition & 11 deletions pallets/dao-democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,7 @@ benchmarks! {
let value = 10_u32.into();
whitelist_account!(caller);

let meta: Option<Vec<u8>> = Some(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor \
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, \
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim \
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo \
consequat. Duis aute irure dolor in reprehenderit".into()
);
let meta = Some(vec![97_u8; T::ProposalMetadataLimit::get() as usize]);
}: _(RawOrigin::Signed(caller), 0, proposal, value, meta)
verify {
assert_eq!(Democracy::<T>::public_props(0).len(), p as usize, "Proposals not created.");
Expand Down
17 changes: 2 additions & 15 deletions pallets/dao-eth-governance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ fn setup_dao_payload<T: Config>() -> Vec<u8> {
serde_json::to_vec(&dao_json).ok().unwrap()
}

fn get_proposal_metadata() -> Vec<u8> {
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor \
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, \
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim \
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo \
consequat. Duis aute irure dolor in reprehenderit"
.into()
}

fn create_dao<T: Config>() -> Result<T::AccountId, DispatchError> {
let caller: T::AccountId = account("caller", 0, SEED);

Expand Down Expand Up @@ -93,7 +80,7 @@ fn add_proposal<T: Config>(
Box::new(proposal.clone()),
proposal_len,
other_eth.into(),
Some(get_proposal_metadata()),
Some(vec![97_u8; T::ProposalMetadataLimit::get() as usize]),
)?;
Ok((
proposal.clone(),
Expand Down Expand Up @@ -136,7 +123,7 @@ benchmarks! {

let proposal = make_proposal::<T>(0);
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
let meta: Option<Vec<u8>> = Some(get_proposal_metadata());
let meta = Some(vec![97_u8; T::ProposalMetadataLimit::get() as usize]);
}: _(RawOrigin::Signed(caller), 0, Box::new(proposal), proposal_len, caller_eth.into(), meta)
verify {
assert_eq!(PendingProposals::<T>::get(0).len(), usize::try_from(T::MaxProposals::get()).unwrap());
Expand Down
48 changes: 24 additions & 24 deletions pallets/dao-eth-governance/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//! Autogenerated weights for pallet_dao_eth_governance
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-06-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-09-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `MacBook-Pro.local`, CPU: `<UNKNOWN>`
//! HOSTNAME: `macbook-pro.lan`, CPU: `<UNKNOWN>`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -58,10 +58,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: DaoEthGovernance PendingProposalOf (max_values: None, max_size: Some(967), added: 3442, mode: MaxEncodedLen)
fn propose_with_meta() -> Weight {
// Proof Size summary in bytes:
// Measured: `1968`
// Measured: `2021`
// Estimated: `9606`
// Minimum execution time: 34_000_000 picoseconds.
Weight::from_parts(37_000_000, 9606)
// Minimum execution time: 31_000_000 picoseconds.
Weight::from_parts(32_000_000, 9606)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -85,10 +85,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: DaoEthGovernance Voting (max_values: None, max_size: Some(4974), added: 7449, mode: MaxEncodedLen)
fn approve_propose() -> Weight {
// Proof Size summary in bytes:
// Measured: `4127`
// Measured: `4214`
// Estimated: `71275`
// Minimum execution time: 63_000_000 picoseconds.
Weight::from_parts(72_000_000, 71275)
// Minimum execution time: 62_000_000 picoseconds.
Weight::from_parts(64_000_000, 71275)
.saturating_add(T::DbWeight::get().reads(8_u64))
.saturating_add(T::DbWeight::get().writes(8_u64))
}
Expand All @@ -102,7 +102,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: DaoEthGovernance PendingVoting (max_values: None, max_size: Some(133), added: 2608, mode: MaxEncodedLen)
fn vote() -> Weight {
// Proof Size summary in bytes:
// Measured: `591`
// Measured: `644`
// Estimated: `18049`
// Minimum execution time: 26_000_000 picoseconds.
Weight::from_parts(27_000_000, 18049)
Expand All @@ -119,8 +119,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `501`
// Estimated: `17119`
// Minimum execution time: 22_000_000 picoseconds.
Weight::from_parts(23_000_000, 17119)
// Minimum execution time: 21_000_000 picoseconds.
Weight::from_parts(21_000_000, 17119)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand All @@ -138,8 +138,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `701`
// Estimated: `63098`
// Minimum execution time: 49_000_000 picoseconds.
Weight::from_parts(52_000_000, 63098)
// Minimum execution time: 48_000_000 picoseconds.
Weight::from_parts(49_000_000, 63098)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
Expand All @@ -155,10 +155,10 @@ impl WeightInfo for () {
/// Proof: DaoEthGovernance PendingProposalOf (max_values: None, max_size: Some(967), added: 3442, mode: MaxEncodedLen)
fn propose_with_meta() -> Weight {
// Proof Size summary in bytes:
// Measured: `1968`
// Measured: `2021`
// Estimated: `9606`
// Minimum execution time: 34_000_000 picoseconds.
Weight::from_parts(37_000_000, 9606)
// Minimum execution time: 31_000_000 picoseconds.
Weight::from_parts(32_000_000, 9606)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -182,10 +182,10 @@ impl WeightInfo for () {
/// Proof: DaoEthGovernance Voting (max_values: None, max_size: Some(4974), added: 7449, mode: MaxEncodedLen)
fn approve_propose() -> Weight {
// Proof Size summary in bytes:
// Measured: `4127`
// Measured: `4214`
// Estimated: `71275`
// Minimum execution time: 63_000_000 picoseconds.
Weight::from_parts(72_000_000, 71275)
// Minimum execution time: 62_000_000 picoseconds.
Weight::from_parts(64_000_000, 71275)
.saturating_add(RocksDbWeight::get().reads(8_u64))
.saturating_add(RocksDbWeight::get().writes(8_u64))
}
Expand All @@ -199,7 +199,7 @@ impl WeightInfo for () {
/// Proof: DaoEthGovernance PendingVoting (max_values: None, max_size: Some(133), added: 2608, mode: MaxEncodedLen)
fn vote() -> Weight {
// Proof Size summary in bytes:
// Measured: `591`
// Measured: `644`
// Estimated: `18049`
// Minimum execution time: 26_000_000 picoseconds.
Weight::from_parts(27_000_000, 18049)
Expand All @@ -216,8 +216,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `501`
// Estimated: `17119`
// Minimum execution time: 22_000_000 picoseconds.
Weight::from_parts(23_000_000, 17119)
// Minimum execution time: 21_000_000 picoseconds.
Weight::from_parts(21_000_000, 17119)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand All @@ -235,8 +235,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `701`
// Estimated: `63098`
// Minimum execution time: 49_000_000 picoseconds.
Weight::from_parts(52_000_000, 63098)
// Minimum execution time: 48_000_000 picoseconds.
Weight::from_parts(49_000_000, 63098)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
Expand Down
17 changes: 2 additions & 15 deletions pallets/dao-nft-governance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ fn setup_dao_payload<T: Config>() -> Vec<u8> {
serde_json::to_vec(&dao_json).ok().unwrap()
}

fn get_proposal_metadata() -> Vec<u8> {
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor \
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt \
mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, \
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim \
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo \
consequat. Duis aute irure dolor in reprehenderit"
.into()
}

fn create_dao<T: Config>() -> Result<T::AccountId, DispatchError> {
let caller: T::AccountId = account("caller", 0, SEED);

Expand Down Expand Up @@ -79,7 +66,7 @@ fn add_proposal<T: Config>(
RawOrigin::Signed(other).into(),
0,
Box::new(proposal.clone()),
Some(get_proposal_metadata()),
Some(vec![97_u8; T::ProposalMetadataLimit::get() as usize]),
)?;
Ok((
proposal.clone(),
Expand All @@ -103,7 +90,7 @@ benchmarks! {

let proposal = make_proposal::<T>(0);
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
let meta: Option<Vec<u8>> = Some(get_proposal_metadata());
let meta = Some(vec![97_u8; T::ProposalMetadataLimit::get() as usize]);
}: _(RawOrigin::Signed(caller), 0, Box::new(proposal), meta)
verify { }

Expand Down
12 changes: 0 additions & 12 deletions pallets/dao-nft-governance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@ impl DaoProvider<AccountId, H256> for TestDaoProvider {
type ApproveOrigin = AsEnsureOriginWithArg<frame_system::EnsureRoot<AccountId>>;
type NFTCollectionId = u32;

fn exists(_id: Self::Id) -> Result<(), DispatchError> {
Ok(())
}

fn dao_account_id(id: Self::Id) -> AccountId {
PalletId(*b"py/sctld").into_sub_account_truncating(id)
}
Expand All @@ -278,14 +274,6 @@ impl DaoProvider<AccountId, H256> for TestDaoProvider {
Ok(Some(0))
}

fn count() -> u32 {
1
}

fn ensure_member(_id: Self::Id, _who: &AccountId) -> Result<bool, DispatchError> {
Ok(true)
}

fn ensure_approved(
origin: Self::Origin,
dao_id: Self::Id,
Expand Down
1 change: 1 addition & 0 deletions pallets/dao-subscription/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn setup_subscription<T: Config>() -> Result<(), DispatchError> {

benchmarks! {

// TODO: use max length for the tier
set_subscription_tier {
let (tier, details) = Subscription::<T>::get_default_tier_details();
}: _(RawOrigin::Root, tier.clone(), details.clone())
Expand Down
Loading