feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
[package]
|
||||
name = "pezpallet-alliance"
|
||||
version = "27.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "The Alliance pallet provides a collective for standard-setting industry collaboration."
|
||||
readme = "README.md"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
array-bytes = { optional = true, workspace = true, default-features = true }
|
||||
log = { workspace = true }
|
||||
|
||||
codec = { features = ["derive"], workspace = true }
|
||||
scale-info = { features = ["derive"], workspace = true }
|
||||
|
||||
pezsp-core = { workspace = true }
|
||||
pezsp-crypto-hashing = { optional = true, workspace = true }
|
||||
pezsp-io = { workspace = true }
|
||||
pezsp-runtime = { workspace = true }
|
||||
|
||||
pezframe-benchmarking = { optional = true, workspace = true }
|
||||
pezframe-support = { workspace = true }
|
||||
pezframe-system = { workspace = true }
|
||||
|
||||
pezpallet-collective = { optional = true, workspace = true }
|
||||
pezpallet-identity = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
array-bytes = { workspace = true, default-features = true }
|
||||
pezpallet-balances = { workspace = true, default-features = true }
|
||||
pezpallet-collective = { workspace = true, default-features = true }
|
||||
pezsp-crypto-hashing = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezframe-benchmarking?/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"log/std",
|
||||
"pezpallet-balances/std",
|
||||
"pezpallet-collective?/std",
|
||||
"pezpallet-identity/std",
|
||||
"scale-info/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-crypto-hashing?/std",
|
||||
"pezsp-io/std",
|
||||
"pezsp-runtime/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"array-bytes",
|
||||
"pezframe-benchmarking/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-collective/runtime-benchmarks",
|
||||
"pezpallet-identity/runtime-benchmarks",
|
||||
"pezsp-crypto-hashing",
|
||||
"pezsp-io/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezpallet-balances/try-runtime",
|
||||
"pezpallet-collective?/try-runtime",
|
||||
"pezpallet-identity/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
]
|
||||
@@ -0,0 +1,66 @@
|
||||
# Alliance Pallet
|
||||
|
||||
The Alliance Pallet provides a collective that curates a list of accounts and URLs, deemed by
|
||||
the voting members to be unscrupulous actors. The Alliance
|
||||
|
||||
- provides a set of ethics against bad behavior, and
|
||||
- provides recognition and influence for those teams that contribute something back to the
|
||||
ecosystem.
|
||||
|
||||
## Overview
|
||||
|
||||
The network initializes the Alliance via a Root call. After that, anyone with an approved
|
||||
identity and website can join as an Ally. The `MembershipManager` origin can elevate Allies to
|
||||
Fellows, giving them voting rights within the Alliance.
|
||||
|
||||
Voting members of the Alliance maintain a list of accounts and websites. Members can also vote
|
||||
to update the Alliance's rule and make announcements.
|
||||
|
||||
### Terminology
|
||||
|
||||
- Rule: The IPFS CID (hash) of the Alliance rules for the community to read and the Alliance
|
||||
members to enforce. Similar to a Charter or Code of Conduct.
|
||||
- Announcement: An IPFS CID of some content that the Alliance want to announce.
|
||||
- Member: An account that is already in the group of the Alliance, including three types:
|
||||
Fellow, or Ally. A member can also be kicked by the `MembershipManager` origin
|
||||
or retire by itself.
|
||||
- Fellow: An account who is elevated from Ally by other Fellows.
|
||||
- Ally: An account who would like to join the Alliance. To become a voting member (Fellow), it
|
||||
will need approval from the `MembershipManager` origin. Any account can join as an Ally either
|
||||
by placing a deposit or by nomination from a voting member.
|
||||
- Unscrupulous List: A list of bad websites and addresses; items can be added or removed by
|
||||
voting members.
|
||||
|
||||
## Interface
|
||||
|
||||
### Dispatchable Functions
|
||||
|
||||
#### For General Users
|
||||
|
||||
- `join_alliance` - Join the Alliance as an Ally. This requires a slashable deposit.
|
||||
|
||||
#### For Members (All)
|
||||
|
||||
- `give_retirement_notice` - Give a retirement notice and start a retirement period required to
|
||||
pass in order to retire.
|
||||
- `retire` - Retire from the Alliance and release the caller's deposit.
|
||||
|
||||
#### For Voting Members
|
||||
|
||||
- `propose` - Propose a motion.
|
||||
- `vote` - Vote on a motion.
|
||||
- `close` - Close a motion with enough votes or that has expired.
|
||||
- `set_rule` - Initialize or update the Alliance's rule by IPFS CID.
|
||||
- `announce` - Make announcement by IPFS CID.
|
||||
- `nominate_ally` - Nominate a non-member to become an Ally, without deposit.
|
||||
- `elevate_ally` - Approve an ally to become a Fellow.
|
||||
- `kick_member` - Kick a member and slash its deposit.
|
||||
- `add_unscrupulous_items` - Add some items, either accounts or websites, to the list of
|
||||
unscrupulous items.
|
||||
- `remove_unscrupulous_items` - Remove some items from the list of unscrupulous items.
|
||||
- `abdicate_fellow_status` - Abdicate one's voting rights, demoting themselves to Ally.
|
||||
|
||||
#### Root Calls
|
||||
|
||||
- `init_members` - Initialize the Alliance, onboard fellows and allies.
|
||||
- `disband` - Disband the Alliance, remove all active members and unreserve deposits.
|
||||
@@ -0,0 +1,844 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Alliance pallet benchmarking.
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use core::{cmp, mem::size_of};
|
||||
use pezsp_runtime::traits::{Bounded, Hash, StaticLookup};
|
||||
|
||||
use pezframe_benchmarking::{account, v2::*, BenchmarkError};
|
||||
use pezframe_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};
|
||||
use pezframe_system::{pezpallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin};
|
||||
|
||||
use super::{Call as AllianceCall, Pallet as Alliance, *};
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
const MAX_BYTES: u32 = 1_024;
|
||||
|
||||
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
|
||||
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
|
||||
}
|
||||
|
||||
fn cid(input: impl AsRef<[u8]>) -> Cid {
|
||||
let result = pezsp_crypto_hashing::sha2_256(input.as_ref());
|
||||
Cid::new_v0(result)
|
||||
}
|
||||
|
||||
fn rule(input: impl AsRef<[u8]>) -> Cid {
|
||||
cid(input)
|
||||
}
|
||||
|
||||
fn announcement(input: impl AsRef<[u8]>) -> Cid {
|
||||
cid(input)
|
||||
}
|
||||
|
||||
fn funded_account<T: Config<I>, I: 'static>(name: &'static str, index: u32) -> T::AccountId {
|
||||
let account: T::AccountId = account(name, index, SEED);
|
||||
T::Currency::make_free_balance_be(&account, BalanceOf::<T, I>::max_value() / 100u8.into());
|
||||
account
|
||||
}
|
||||
|
||||
fn fellow<T: Config<I>, I: 'static>(index: u32) -> T::AccountId {
|
||||
funded_account::<T, I>("fellow", index)
|
||||
}
|
||||
|
||||
fn ally<T: Config<I>, I: 'static>(index: u32) -> T::AccountId {
|
||||
funded_account::<T, I>("ally", index)
|
||||
}
|
||||
|
||||
fn outsider<T: Config<I>, I: 'static>(index: u32) -> T::AccountId {
|
||||
funded_account::<T, I>("outsider", index)
|
||||
}
|
||||
|
||||
fn generate_unscrupulous_account<T: Config<I>, I: 'static>(index: u32) -> T::AccountId {
|
||||
funded_account::<T, I>("unscrupulous", index)
|
||||
}
|
||||
|
||||
fn set_members<T: Config<I>, I: 'static>() {
|
||||
let fellows: BoundedVec<_, T::MaxMembersCount> =
|
||||
BoundedVec::try_from(vec![fellow::<T, I>(1), fellow::<T, I>(2)]).unwrap();
|
||||
fellows.iter().for_each(|who| {
|
||||
T::Currency::reserve(&who, T::AllyDeposit::get()).unwrap();
|
||||
<DepositOf<T, I>>::insert(&who, T::AllyDeposit::get());
|
||||
});
|
||||
Members::<T, I>::insert(MemberRole::Fellow, fellows.clone());
|
||||
|
||||
let allies: BoundedVec<_, T::MaxMembersCount> =
|
||||
BoundedVec::try_from(vec![ally::<T, I>(1)]).unwrap();
|
||||
allies.iter().for_each(|who| {
|
||||
T::Currency::reserve(&who, T::AllyDeposit::get()).unwrap();
|
||||
<DepositOf<T, I>>::insert(&who, T::AllyDeposit::get());
|
||||
});
|
||||
Members::<T, I>::insert(MemberRole::Ally, allies);
|
||||
|
||||
T::InitializeMembers::initialize_members(&[fellows.as_slice()].concat());
|
||||
}
|
||||
|
||||
#[instance_benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
// This tests when proposal is created and queued as "proposed"
|
||||
#[benchmark]
|
||||
fn propose_proposed(
|
||||
b: Linear<1, MAX_BYTES>,
|
||||
m: Linear<2, { T::MaxFellows::get() }>,
|
||||
p: Linear<1, { T::MaxProposals::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
|
||||
|
||||
// Construct `members`.
|
||||
let fellows = (0..m).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
let proposer = fellows[0].clone();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), fellows, vec![])?;
|
||||
|
||||
let threshold = m;
|
||||
// Add previous proposals.
|
||||
for i in 0..p - 1 {
|
||||
// Proposals should be different so that different proposal hashes are generated
|
||||
let proposal: T::Proposal =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![i as u8; b as usize]) }.into();
|
||||
Alliance::<T, I>::propose(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
threshold,
|
||||
Box::new(proposal),
|
||||
bytes_in_storage,
|
||||
)?;
|
||||
}
|
||||
|
||||
let proposal: T::Proposal =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![p as u8; b as usize]) }.into();
|
||||
|
||||
#[extrinsic_call]
|
||||
propose(
|
||||
SystemOrigin::Signed(proposer.clone()),
|
||||
threshold,
|
||||
Box::new(proposal.clone()),
|
||||
bytes_in_storage,
|
||||
);
|
||||
|
||||
let proposal_hash = T::Hashing::hash_of(&proposal);
|
||||
assert_eq!(T::ProposalProvider::proposal_of(proposal_hash), Some(proposal));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn vote(m: Linear<5, { T::MaxFellows::get() }>) -> Result<(), BenchmarkError> {
|
||||
let p = T::MaxProposals::get();
|
||||
let b = MAX_BYTES;
|
||||
let _bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
|
||||
|
||||
// Construct `members`.
|
||||
let fellows = (0..m).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
let proposer = fellows[0].clone();
|
||||
|
||||
let members = fellows.clone();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), fellows, vec![])?;
|
||||
|
||||
// Threshold is 1 less than the number of members so that one person can vote nay
|
||||
let threshold = m - 1;
|
||||
|
||||
// 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 =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![i as u8; b as usize]) }.into();
|
||||
Alliance::<T, I>::propose(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
threshold,
|
||||
Box::new(proposal.clone()),
|
||||
b,
|
||||
)?;
|
||||
last_hash = T::Hashing::hash_of(&proposal);
|
||||
}
|
||||
|
||||
let index = p - 1;
|
||||
// Have almost everyone vote aye on last proposal, while keeping it from passing.
|
||||
for j in 0..m - 3 {
|
||||
let voter = &members[j as usize];
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(voter.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
true,
|
||||
)?;
|
||||
}
|
||||
|
||||
let voter = members[m as usize - 3].clone();
|
||||
// Voter votes aye without resolving the vote.
|
||||
Alliance::<T, I>::vote(SystemOrigin::Signed(voter.clone()).into(), last_hash, index, true)?;
|
||||
|
||||
// Voter switches vote to nay, but does not kill the vote, just updates + inserts
|
||||
let approve = false;
|
||||
|
||||
// Whitelist voter account from further DB operations.
|
||||
let voter_key = pezframe_system::Account::<T>::hashed_key_for(&voter);
|
||||
pezframe_benchmarking::benchmarking::add_to_whitelist(voter_key.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Signed(voter), last_hash, index, approve);
|
||||
|
||||
//nothing to verify
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn close_early_disapproved(
|
||||
m: Linear<4, { T::MaxFellows::get() }>,
|
||||
p: Linear<1, { T::MaxProposals::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let bytes = 100;
|
||||
let bytes_in_storage = bytes + size_of::<Cid>() as u32 + 32;
|
||||
|
||||
// Construct `members`.
|
||||
let fellows = (0..m).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
|
||||
let members = fellows.clone();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), fellows, vec![])?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
let voter = members[1].clone();
|
||||
|
||||
// Threshold is total members so that one nay will disapprove the vote
|
||||
let threshold = m;
|
||||
|
||||
// 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 =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![i as u8; bytes as usize]) }.into();
|
||||
Alliance::<T, I>::propose(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
threshold,
|
||||
Box::new(proposal.clone()),
|
||||
bytes_in_storage,
|
||||
)?;
|
||||
last_hash = T::Hashing::hash_of(&proposal);
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal));
|
||||
}
|
||||
|
||||
let index = p - 1;
|
||||
// Have most everyone vote aye on last proposal, while keeping it from passing.
|
||||
for j in 2..m - 1 {
|
||||
let voter = &members[j as usize];
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(voter.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
true,
|
||||
)?;
|
||||
}
|
||||
|
||||
// Voter votes aye without resolving the vote.
|
||||
Alliance::<T, I>::vote(SystemOrigin::Signed(voter.clone()).into(), last_hash, index, true)?;
|
||||
|
||||
// Voter switches vote to nay, which kills the vote
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(voter.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
false,
|
||||
)?;
|
||||
|
||||
// Whitelist voter account from further DB operations.
|
||||
let voter_key = pezframe_system::Account::<T>::hashed_key_for(&voter);
|
||||
pezframe_benchmarking::benchmarking::add_to_whitelist(voter_key.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage);
|
||||
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// We choose 4 as a minimum for param m, so we always trigger a vote in the voting loop (`for j
|
||||
// in ...`)
|
||||
#[benchmark]
|
||||
fn close_early_approved(
|
||||
b: Linear<1, MAX_BYTES>,
|
||||
m: Linear<4, { T::MaxFellows::get() }>,
|
||||
p: Linear<1, { T::MaxProposals::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
|
||||
|
||||
// Construct `members`.
|
||||
let fellows = (0..m).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
|
||||
let members = fellows.clone();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), fellows, vec![])?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
// Threshold is 2 so any two ayes will approve the vote
|
||||
let threshold = 2;
|
||||
|
||||
// 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 =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![i as u8; b as usize]) }.into();
|
||||
Alliance::<T, I>::propose(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
threshold,
|
||||
Box::new(proposal.clone()),
|
||||
bytes_in_storage,
|
||||
)?;
|
||||
last_hash = T::Hashing::hash_of(&proposal);
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal));
|
||||
}
|
||||
|
||||
let index = p - 1;
|
||||
// Caller switches vote to nay on their own proposal, allowing them to be the deciding
|
||||
// approval vote
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
false,
|
||||
)?;
|
||||
|
||||
// Have almost everyone vote nay on last proposal, while keeping it from failing.
|
||||
for j in 2..m - 1 {
|
||||
let voter = &members[j as usize];
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(voter.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
false,
|
||||
)?;
|
||||
}
|
||||
|
||||
// Member zero is the first aye
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(members[0].clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
true,
|
||||
)?;
|
||||
|
||||
let voter = members[1].clone();
|
||||
// Caller switches vote to aye, which passes the vote
|
||||
Alliance::<T, I>::vote(SystemOrigin::Signed(voter.clone()).into(), last_hash, index, true)?;
|
||||
|
||||
#[extrinsic_call]
|
||||
close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage);
|
||||
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn close_disapproved(
|
||||
m: Linear<2, { T::MaxFellows::get() }>,
|
||||
p: Linear<1, { T::MaxProposals::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let bytes = 100;
|
||||
let bytes_in_storage = bytes + size_of::<Cid>() as u32 + 32;
|
||||
|
||||
// Construct `members`.
|
||||
let fellows = (0..m).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
|
||||
let members = fellows.clone();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), fellows, vec![])?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
let voter = members[1].clone();
|
||||
|
||||
// Threshold is one less than total members so that two nays will disapprove the vote
|
||||
let threshold = m - 1;
|
||||
|
||||
// Add 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 =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![i as u8; bytes as usize]) }.into();
|
||||
Alliance::<T, I>::propose(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
threshold,
|
||||
Box::new(proposal.clone()),
|
||||
bytes_in_storage,
|
||||
)?;
|
||||
last_hash = T::Hashing::hash_of(&proposal);
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal));
|
||||
}
|
||||
|
||||
let index = p - 1;
|
||||
// Have almost everyone vote aye on last proposal, while keeping it from passing.
|
||||
// A few abstainers will be the nay votes needed to fail the vote.
|
||||
for j in 2..m - 1 {
|
||||
let voter = &members[j as usize];
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(voter.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
true,
|
||||
)?;
|
||||
}
|
||||
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(voter.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
false,
|
||||
)?;
|
||||
|
||||
System::<T>::set_block_number(BlockNumberFor::<T>::max_value());
|
||||
|
||||
#[extrinsic_call]
|
||||
close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage);
|
||||
|
||||
// The last proposal is removed.
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// We choose 5 fellows as a minimum so we always trigger a vote in the voting loop (`for j in
|
||||
// ...`)
|
||||
#[benchmark]
|
||||
fn close_approved(
|
||||
b: Linear<1, MAX_BYTES>,
|
||||
m: Linear<5, { T::MaxFellows::get() }>,
|
||||
p: Linear<1, { T::MaxProposals::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
|
||||
|
||||
// Construct `members`.
|
||||
let fellows = (0..m).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
|
||||
let members = fellows.clone();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), fellows, vec![])?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
// Threshold is two, so any two ayes will pass the vote
|
||||
let threshold = 2;
|
||||
|
||||
// Add 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 =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![i as u8; b as usize]) }.into();
|
||||
Alliance::<T, I>::propose(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
threshold,
|
||||
Box::new(proposal.clone()),
|
||||
bytes_in_storage,
|
||||
)?;
|
||||
last_hash = T::Hashing::hash_of(&proposal);
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal));
|
||||
}
|
||||
|
||||
// The prime member votes aye, so abstentions default to aye.
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
last_hash,
|
||||
p - 1,
|
||||
true, // Vote aye.
|
||||
)?;
|
||||
|
||||
let index = p - 1;
|
||||
// Have almost everyone vote nay on last proposal, while keeping it from failing.
|
||||
// A few abstainers will be the aye votes needed to pass the vote.
|
||||
for j in 2..m - 1 {
|
||||
let voter = &members[j as usize];
|
||||
Alliance::<T, I>::vote(
|
||||
SystemOrigin::Signed(voter.clone()).into(),
|
||||
last_hash,
|
||||
index,
|
||||
false,
|
||||
)?;
|
||||
}
|
||||
|
||||
// caller is prime, prime already votes aye by creating the proposal
|
||||
System::<T>::set_block_number(BlockNumberFor::<T>::max_value());
|
||||
|
||||
#[extrinsic_call]
|
||||
close(SystemOrigin::Signed(proposer), last_hash, index, Weight::MAX, bytes_in_storage);
|
||||
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn init_members(
|
||||
m: Linear<1, { T::MaxFellows::get() }>,
|
||||
z: Linear<0, { T::MaxAllies::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let mut fellows = (0..m).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
let mut allies = (0..z).map(ally::<T, I>).collect::<Vec<_>>();
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Root, fellows.clone(), allies.clone());
|
||||
|
||||
fellows.sort();
|
||||
allies.sort();
|
||||
assert_last_event::<T, I>(
|
||||
Event::MembersInitialized { fellows: fellows.clone(), allies: allies.clone() }.into(),
|
||||
);
|
||||
assert_eq!(Members::<T, I>::get(MemberRole::Fellow), fellows);
|
||||
assert_eq!(Members::<T, I>::get(MemberRole::Ally), allies);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn disband(
|
||||
x: Linear<1, { T::MaxFellows::get() }>,
|
||||
y: Linear<0, { T::MaxAllies::get() }>,
|
||||
z: Linear<0, { T::MaxMembersCount::get() / 2 }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let fellows = (0..x).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
let allies = (0..y).map(ally::<T, I>).collect::<Vec<_>>();
|
||||
let witness = DisbandWitness { fellow_members: x, ally_members: y };
|
||||
|
||||
// setting the Alliance to disband on the benchmark call
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), fellows.clone(), allies.clone())?;
|
||||
|
||||
// reserve deposits
|
||||
let deposit = T::AllyDeposit::get();
|
||||
for member in fellows.iter().chain(allies.iter()).take(z as usize) {
|
||||
T::Currency::reserve(&member, deposit)?;
|
||||
<DepositOf<T, I>>::insert(&member, deposit);
|
||||
}
|
||||
|
||||
assert_eq!(Alliance::<T, I>::voting_members_count(), x);
|
||||
assert_eq!(Alliance::<T, I>::ally_members_count(), y);
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Root, witness);
|
||||
|
||||
assert_last_event::<T, I>(
|
||||
Event::AllianceDisbanded {
|
||||
fellow_members: x,
|
||||
ally_members: y,
|
||||
unreserved: cmp::min(z, x + y),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
assert!(!Alliance::<T, I>::is_initialized());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn set_rule() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let rule = rule(b"hello world");
|
||||
|
||||
let call = Call::<T, I>::set_rule { rule: rule.clone() };
|
||||
let origin =
|
||||
T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
call.dispatch_bypass_filter(origin)?;
|
||||
}
|
||||
assert_eq!(Rule::<T, I>::get(), Some(rule.clone()));
|
||||
assert_last_event::<T, I>(Event::NewRuleSet { rule }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn announce() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let announcement = announcement(b"hello world");
|
||||
|
||||
let call = Call::<T, I>::announce { announcement: announcement.clone() };
|
||||
let origin = T::AnnouncementOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
call.dispatch_bypass_filter(origin)?;
|
||||
}
|
||||
|
||||
assert!(Announcements::<T, I>::get().contains(&announcement));
|
||||
assert_last_event::<T, I>(Event::Announced { announcement }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn remove_announcement() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let announcement = announcement(b"hello world");
|
||||
let announcements: BoundedVec<_, T::MaxAnnouncementsCount> =
|
||||
BoundedVec::try_from(vec![announcement.clone()]).unwrap();
|
||||
Announcements::<T, I>::put(announcements);
|
||||
|
||||
let call = Call::<T, I>::remove_announcement { announcement: announcement.clone() };
|
||||
let origin = T::AnnouncementOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
call.dispatch_bypass_filter(origin)?;
|
||||
}
|
||||
|
||||
assert!(!Announcements::<T, I>::get().contains(&announcement));
|
||||
assert_last_event::<T, I>(Event::AnnouncementRemoved { announcement }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn join_alliance() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let outsider = outsider::<T, I>(1);
|
||||
assert!(!Alliance::<T, I>::is_member(&outsider));
|
||||
assert_eq!(DepositOf::<T, I>::get(&outsider), None);
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Signed(outsider.clone()));
|
||||
|
||||
assert!(Alliance::<T, I>::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally
|
||||
assert_eq!(DepositOf::<T, I>::get(&outsider), Some(T::AllyDeposit::get())); // with a deposit
|
||||
assert!(!Alliance::<T, I>::has_voting_rights(&outsider)); // allies don't have voting rights
|
||||
assert_last_event::<T, I>(
|
||||
Event::NewAllyJoined {
|
||||
ally: outsider,
|
||||
nominator: None,
|
||||
reserved: Some(T::AllyDeposit::get()),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn nominate_ally() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let fellow1 = fellow::<T, I>(1);
|
||||
assert!(Alliance::<T, I>::is_member_of(&fellow1, MemberRole::Fellow));
|
||||
|
||||
let outsider = outsider::<T, I>(1);
|
||||
assert!(!Alliance::<T, I>::is_member(&outsider));
|
||||
assert_eq!(DepositOf::<T, I>::get(&outsider), None);
|
||||
|
||||
let outsider_lookup = T::Lookup::unlookup(outsider.clone());
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Signed(fellow1.clone()), outsider_lookup);
|
||||
|
||||
assert!(Alliance::<T, I>::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally
|
||||
assert_eq!(DepositOf::<T, I>::get(&outsider), None); // without a deposit
|
||||
assert!(!Alliance::<T, I>::has_voting_rights(&outsider)); // allies don't have voting rights
|
||||
assert_last_event::<T, I>(
|
||||
Event::NewAllyJoined { ally: outsider, nominator: Some(fellow1), reserved: None }
|
||||
.into(),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn elevate_ally() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let ally1 = ally::<T, I>(1);
|
||||
assert!(Alliance::<T, I>::is_ally(&ally1));
|
||||
|
||||
let ally1_lookup = T::Lookup::unlookup(ally1.clone());
|
||||
let call = Call::<T, I>::elevate_ally { ally: ally1_lookup };
|
||||
let origin = T::MembershipManager::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
call.dispatch_bypass_filter(origin)?;
|
||||
}
|
||||
|
||||
assert!(!Alliance::<T, I>::is_ally(&ally1));
|
||||
assert!(Alliance::<T, I>::has_voting_rights(&ally1));
|
||||
assert_last_event::<T, I>(Event::AllyElevated { ally: ally1 }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn give_retirement_notice() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
let fellow2 = fellow::<T, I>(2);
|
||||
|
||||
assert!(Alliance::<T, I>::has_voting_rights(&fellow2));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Signed(fellow2.clone()));
|
||||
|
||||
assert!(Alliance::<T, I>::is_member_of(&fellow2, MemberRole::Retiring));
|
||||
|
||||
assert_eq!(
|
||||
RetiringMembers::<T, I>::get(&fellow2),
|
||||
Some(System::<T>::block_number() + T::RetirementPeriod::get())
|
||||
);
|
||||
assert_last_event::<T, I>(Event::MemberRetirementPeriodStarted { member: fellow2 }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn retire() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let fellow2 = fellow::<T, I>(2);
|
||||
assert!(Alliance::<T, I>::has_voting_rights(&fellow2));
|
||||
|
||||
assert_eq!(
|
||||
Alliance::<T, I>::give_retirement_notice(SystemOrigin::Signed(fellow2.clone()).into()),
|
||||
Ok(())
|
||||
);
|
||||
System::<T>::set_block_number(System::<T>::block_number() + T::RetirementPeriod::get());
|
||||
|
||||
assert_eq!(DepositOf::<T, I>::get(&fellow2), Some(T::AllyDeposit::get()));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Signed(fellow2.clone()));
|
||||
|
||||
assert!(!Alliance::<T, I>::is_member(&fellow2));
|
||||
assert_eq!(DepositOf::<T, I>::get(&fellow2), None);
|
||||
assert_last_event::<T, I>(
|
||||
Event::MemberRetired { member: fellow2, unreserved: Some(T::AllyDeposit::get()) }
|
||||
.into(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn kick_member() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let fellow2 = fellow::<T, I>(2);
|
||||
assert!(Alliance::<T, I>::is_member_of(&fellow2, MemberRole::Fellow));
|
||||
assert_eq!(DepositOf::<T, I>::get(&fellow2), Some(T::AllyDeposit::get()));
|
||||
|
||||
let fellow2_lookup = T::Lookup::unlookup(fellow2.clone());
|
||||
let call = Call::<T, I>::kick_member { who: fellow2_lookup };
|
||||
let origin = T::MembershipManager::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
call.dispatch_bypass_filter(origin)?;
|
||||
}
|
||||
|
||||
assert!(!Alliance::<T, I>::is_member(&fellow2));
|
||||
assert_eq!(DepositOf::<T, I>::get(&fellow2), None);
|
||||
assert_last_event::<T, I>(
|
||||
Event::MemberKicked { member: fellow2, slashed: Some(T::AllyDeposit::get()) }.into(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn add_unscrupulous_items(
|
||||
n: Linear<0, { T::MaxUnscrupulousItems::get() }>,
|
||||
l: Linear<0, { T::MaxWebsiteUrlLength::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let accounts = (0..n).map(|i| generate_unscrupulous_account::<T, I>(i)).collect::<Vec<_>>();
|
||||
let websites = (0..n)
|
||||
.map(|i| -> BoundedVec<u8, T::MaxWebsiteUrlLength> {
|
||||
BoundedVec::try_from(vec![i as u8; l as usize]).unwrap()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut unscrupulous_list = Vec::with_capacity(accounts.len() + websites.len());
|
||||
unscrupulous_list.extend(accounts.into_iter().map(UnscrupulousItem::AccountId));
|
||||
unscrupulous_list.extend(websites.into_iter().map(UnscrupulousItem::Website));
|
||||
|
||||
let call = Call::<T, I>::add_unscrupulous_items { items: unscrupulous_list.clone() };
|
||||
let origin = T::AnnouncementOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
call.dispatch_bypass_filter(origin)?;
|
||||
}
|
||||
|
||||
assert_last_event::<T, I>(Event::UnscrupulousItemAdded { items: unscrupulous_list }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn remove_unscrupulous_items(
|
||||
n: Linear<0, { T::MaxUnscrupulousItems::get() }>,
|
||||
l: Linear<0, { T::MaxWebsiteUrlLength::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
|
||||
let mut accounts =
|
||||
(0..n).map(|i| generate_unscrupulous_account::<T, I>(i)).collect::<Vec<_>>();
|
||||
accounts.sort();
|
||||
let accounts: BoundedVec<_, T::MaxUnscrupulousItems> = accounts.try_into().unwrap();
|
||||
UnscrupulousAccounts::<T, I>::put(accounts.clone());
|
||||
|
||||
let mut websites = (0..n)
|
||||
.map(|i| -> BoundedVec<_, T::MaxWebsiteUrlLength> {
|
||||
BoundedVec::try_from(vec![i as u8; l as usize]).unwrap()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
websites.sort();
|
||||
let websites: BoundedVec<_, T::MaxUnscrupulousItems> = websites.try_into().unwrap();
|
||||
UnscrupulousWebsites::<T, I>::put(websites.clone());
|
||||
|
||||
let mut unscrupulous_list = Vec::with_capacity(accounts.len() + websites.len());
|
||||
unscrupulous_list.extend(accounts.into_iter().map(UnscrupulousItem::AccountId));
|
||||
unscrupulous_list.extend(websites.into_iter().map(UnscrupulousItem::Website));
|
||||
|
||||
let call = Call::<T, I>::remove_unscrupulous_items { items: unscrupulous_list.clone() };
|
||||
let origin = T::AnnouncementOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
call.dispatch_bypass_filter(origin)?;
|
||||
}
|
||||
|
||||
assert_last_event::<T, I>(
|
||||
Event::UnscrupulousItemRemoved { items: unscrupulous_list }.into(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn abdicate_fellow_status() -> Result<(), BenchmarkError> {
|
||||
set_members::<T, I>();
|
||||
let fellow2 = fellow::<T, I>(2);
|
||||
assert!(Alliance::<T, I>::has_voting_rights(&fellow2));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(SystemOrigin::Signed(fellow2.clone()));
|
||||
|
||||
assert_last_event::<T, I>(Event::FellowAbdicated { fellow: fellow2 }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Alliance, crate::mock::new_bench_ext(), crate::mock::Test);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,179 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{Config, Pallet, Weight, LOG_TARGET};
|
||||
use pezframe_support::{pezpallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade};
|
||||
use log;
|
||||
|
||||
/// The in-code storage version.
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
|
||||
|
||||
/// Wrapper for all migrations of this pallet.
|
||||
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
|
||||
let on_chain_version = Pallet::<T, I>::on_chain_storage_version();
|
||||
let mut weight: Weight = Weight::zero();
|
||||
|
||||
if on_chain_version < 1 {
|
||||
weight = weight.saturating_add(v0_to_v1::migrate::<T, I>());
|
||||
}
|
||||
|
||||
if on_chain_version < 2 {
|
||||
weight = weight.saturating_add(v1_to_v2::migrate::<T, I>());
|
||||
}
|
||||
|
||||
STORAGE_VERSION.put::<Pallet<T, I>>();
|
||||
weight = weight.saturating_add(T::DbWeight::get().writes(1));
|
||||
|
||||
weight
|
||||
}
|
||||
|
||||
/// Implements `OnRuntimeUpgrade` trait.
|
||||
pub struct Migration<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Migration<T, I> {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
migrate::<T, I>()
|
||||
}
|
||||
}
|
||||
|
||||
/// v0_to_v1: `UpForKicking` is replaced by a retirement period.
|
||||
mod v0_to_v1 {
|
||||
use super::*;
|
||||
|
||||
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
|
||||
log::info!(target: LOG_TARGET, "Running migration v0_to_v1.");
|
||||
|
||||
let res = migration::clear_storage_prefix(
|
||||
<Pallet<T, I>>::name().as_bytes(),
|
||||
b"UpForKicking",
|
||||
b"",
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"Cleared '{}' entries from 'UpForKicking' storage prefix",
|
||||
res.unique
|
||||
);
|
||||
|
||||
if res.maybe_cursor.is_some() {
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"Storage prefix 'UpForKicking' is not completely cleared."
|
||||
);
|
||||
}
|
||||
|
||||
T::DbWeight::get().writes(res.unique.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// v1_to_v2: `Members` storage map collapses `Founder` and `Fellow` keys into one `Fellow`.
|
||||
/// Total number of `Founder`s and `Fellow`s must not be higher than `T::MaxMembersCount`.
|
||||
pub(crate) mod v1_to_v2 {
|
||||
use super::*;
|
||||
use crate::{MemberRole, Members};
|
||||
|
||||
/// V1 Role set.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, MaxEncodedLen)]
|
||||
pub enum MemberRoleV1 {
|
||||
Founder,
|
||||
Fellow,
|
||||
Ally,
|
||||
Retiring,
|
||||
}
|
||||
|
||||
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
|
||||
log::info!(target: LOG_TARGET, "Running migration v1_to_v2: `Members` storage map collapses `Founder` and `Fellow` keys into one `Fellow`.");
|
||||
// fetch into the scope all members.
|
||||
let founders_vec = take_members::<T, I>(MemberRoleV1::Founder).into_inner();
|
||||
let mut fellows_vec = take_members::<T, I>(MemberRoleV1::Fellow).into_inner();
|
||||
let allies = take_members::<T, I>(MemberRoleV1::Ally);
|
||||
let retiring = take_members::<T, I>(MemberRoleV1::Retiring);
|
||||
if founders_vec
|
||||
.len()
|
||||
.saturating_add(fellows_vec.len())
|
||||
.saturating_add(allies.len())
|
||||
.saturating_add(retiring.len()) ==
|
||||
0
|
||||
{
|
||||
return T::DbWeight::get().reads(4);
|
||||
}
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"Members storage v1 contains, '{}' founders, '{}' fellows, '{}' allies, '{}' retiring members.",
|
||||
founders_vec.len(),
|
||||
fellows_vec.len(),
|
||||
allies.len(),
|
||||
retiring.len(),
|
||||
);
|
||||
// merge founders with fellows and sort.
|
||||
fellows_vec.extend(founders_vec);
|
||||
fellows_vec.sort();
|
||||
if fellows_vec.len() as u32 > T::MaxMembersCount::get() {
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"Merged list of founders and fellows do not fit into `T::MaxMembersCount` bound. Truncating the merged set into max members count."
|
||||
);
|
||||
fellows_vec.truncate(T::MaxMembersCount::get() as usize);
|
||||
}
|
||||
let fellows: BoundedVec<T::AccountId, T::MaxMembersCount> =
|
||||
fellows_vec.try_into().unwrap_or_default();
|
||||
// insert members with new storage map key.
|
||||
Members::<T, I>::insert(&MemberRole::Fellow, fellows.clone());
|
||||
Members::<T, I>::insert(&MemberRole::Ally, allies.clone());
|
||||
Members::<T, I>::insert(&MemberRole::Retiring, retiring.clone());
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"Members storage updated with, '{}' fellows, '{}' allies, '{}' retiring members.",
|
||||
fellows.len(),
|
||||
allies.len(),
|
||||
retiring.len(),
|
||||
);
|
||||
T::DbWeight::get().reads_writes(4, 4)
|
||||
}
|
||||
|
||||
fn take_members<T: Config<I>, I: 'static>(
|
||||
role: MemberRoleV1,
|
||||
) -> BoundedVec<T::AccountId, T::MaxMembersCount> {
|
||||
migration::take_storage_item::<
|
||||
MemberRoleV1,
|
||||
BoundedVec<T::AccountId, T::MaxMembersCount>,
|
||||
Twox64Concat,
|
||||
>(<Pallet<T, I>>::name().as_bytes(), b"Members", role)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::{mock::*, MemberRole, Members};
|
||||
|
||||
#[test]
|
||||
fn migration_v1_to_v2_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Alliance::join_alliance(RuntimeOrigin::signed(4)));
|
||||
assert_eq!(Members::<Test>::get(MemberRole::Ally), vec![4]);
|
||||
assert_eq!(Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3]);
|
||||
v1_to_v2::migrate::<Test, ()>();
|
||||
assert_eq!(Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3, 4]);
|
||||
assert_eq!(Members::<Test>::get(MemberRole::Ally), vec![]);
|
||||
assert_eq!(Members::<Test>::get(MemberRole::Retiring), vec![]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Test utilities
|
||||
|
||||
pub use pezsp_core::H256;
|
||||
use pezsp_runtime::traits::Hash;
|
||||
pub use pezsp_runtime::{
|
||||
traits::{BlakeTwo256, IdentifyAccount, Lazy, Verify},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
pub use pezframe_support::{
|
||||
assert_noop, assert_ok, derive_impl, ord_parameter_types, parameter_types,
|
||||
traits::EitherOfDiverse, BoundedVec,
|
||||
};
|
||||
use pezframe_system::{EnsureRoot, EnsureSignedBy};
|
||||
use pezpallet_identity::{
|
||||
legacy::{IdentityField, IdentityInfo},
|
||||
Data, IdentityOf, Judgement, SuperOf,
|
||||
};
|
||||
|
||||
pub use crate as pezpallet_alliance;
|
||||
|
||||
use super::*;
|
||||
|
||||
type BlockNumber = u64;
|
||||
type AccountId = u64;
|
||||
|
||||
parameter_types! {
|
||||
pub BlockWeights: pezframe_system::limits::BlockWeights =
|
||||
pezframe_system::limits::BlockWeights::simple_max(Weight::MAX);
|
||||
}
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type Block = Block;
|
||||
type AccountData = pezpallet_balances::AccountData<u64>;
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_balances::Config for Test {
|
||||
type AccountStore = System;
|
||||
}
|
||||
|
||||
const MOTION_DURATION_IN_BLOCKS: BlockNumber = 3;
|
||||
|
||||
parameter_types! {
|
||||
pub const MotionDuration: BlockNumber = MOTION_DURATION_IN_BLOCKS;
|
||||
pub const MaxProposals: u32 = 100;
|
||||
pub const MaxMembers: u32 = 100;
|
||||
pub MaxProposalWeight: Weight = pezsp_runtime::Perbill::from_percent(50) * BlockWeights::get().max_block;
|
||||
}
|
||||
type AllianceCollective = pezpallet_collective::Instance1;
|
||||
impl pezpallet_collective::Config<AllianceCollective> for Test {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Proposal = RuntimeCall;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type MotionDuration = MotionDuration;
|
||||
type MaxProposals = MaxProposals;
|
||||
type MaxMembers = MaxMembers;
|
||||
type DefaultVote = pezpallet_collective::PrimeDefaultVote;
|
||||
type WeightInfo = ();
|
||||
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
|
||||
type MaxProposalWeight = MaxProposalWeight;
|
||||
type DisapproveOrigin = EnsureRoot<Self::AccountId>;
|
||||
type KillOrigin = EnsureRoot<Self::AccountId>;
|
||||
type Consideration = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const BasicDeposit: u64 = 100;
|
||||
pub const ByteDeposit: u64 = 10;
|
||||
pub const UsernameDeposit: u64 = 10;
|
||||
pub const SubAccountDeposit: u64 = 100;
|
||||
pub const MaxSubAccounts: u32 = 2;
|
||||
pub const MaxAdditionalFields: u32 = 2;
|
||||
pub const MaxRegistrars: u32 = 20;
|
||||
pub const PendingUsernameExpiration: u64 = 100;
|
||||
pub const UsernameGracePeriod: u64 = 10;
|
||||
}
|
||||
ord_parameter_types! {
|
||||
pub const One: u64 = 1;
|
||||
pub const Two: u64 = 2;
|
||||
pub const Three: u64 = 3;
|
||||
pub const Four: u64 = 4;
|
||||
pub const Five: u64 = 5;
|
||||
}
|
||||
type EnsureOneOrRoot = EitherOfDiverse<EnsureRoot<AccountId>, EnsureSignedBy<One, AccountId>>;
|
||||
type EnsureTwoOrRoot = EitherOfDiverse<EnsureRoot<AccountId>, EnsureSignedBy<Two, AccountId>>;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub struct BenchmarkHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pezpallet_identity::BenchmarkHelper<AccountU64, AccountU64> for BenchmarkHelper {
|
||||
fn sign_message(_message: &[u8]) -> (AccountU64, AccountU64) {
|
||||
(AccountU64(0), AccountU64(0))
|
||||
}
|
||||
}
|
||||
|
||||
impl pezpallet_identity::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type BasicDeposit = BasicDeposit;
|
||||
type ByteDeposit = ByteDeposit;
|
||||
type UsernameDeposit = UsernameDeposit;
|
||||
type SubAccountDeposit = SubAccountDeposit;
|
||||
type MaxSubAccounts = MaxSubAccounts;
|
||||
type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
|
||||
type MaxRegistrars = MaxRegistrars;
|
||||
type Slashed = ();
|
||||
type RegistrarOrigin = EnsureOneOrRoot;
|
||||
type ForceOrigin = EnsureTwoOrRoot;
|
||||
type OffchainSignature = AccountU64;
|
||||
type SigningPublicKey = AccountU64;
|
||||
type UsernameAuthorityOrigin = EnsureOneOrRoot;
|
||||
type PendingUsernameExpiration = PendingUsernameExpiration;
|
||||
type UsernameGracePeriod = UsernameGracePeriod;
|
||||
type MaxSuffixLength = ConstU32<7>;
|
||||
type MaxUsernameLength = ConstU32<32>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = BenchmarkHelper;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Encode, Decode, DecodeWithMemTracking, PartialEq, Eq, TypeInfo)]
|
||||
pub struct AccountU64(u64);
|
||||
impl IdentifyAccount for AccountU64 {
|
||||
type AccountId = u64;
|
||||
fn into_account(self) -> u64 {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
impl Verify for AccountU64 {
|
||||
type Signer = AccountU64;
|
||||
fn verify<L: Lazy<[u8]>>(
|
||||
&self,
|
||||
_msg: L,
|
||||
_signer: &<Self::Signer as IdentifyAccount>::AccountId,
|
||||
) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AllianceIdentityVerifier;
|
||||
impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
|
||||
fn has_required_identities(who: &AccountId) -> bool {
|
||||
Identity::has_identity(who, (IdentityField::Display | IdentityField::Web).bits())
|
||||
}
|
||||
|
||||
fn has_good_judgement(who: &AccountId) -> bool {
|
||||
if let Some(judgements) =
|
||||
IdentityOf::<Test>::get(who).map(|registration| registration.judgements)
|
||||
{
|
||||
judgements
|
||||
.iter()
|
||||
.any(|(_, j)| matches!(j, Judgement::KnownGood | Judgement::Reasonable))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn super_account_id(who: &AccountId) -> Option<AccountId> {
|
||||
SuperOf::<Test>::get(who).map(|parent| parent.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AllianceProposalProvider;
|
||||
impl ProposalProvider<AccountId, H256, RuntimeCall> for AllianceProposalProvider {
|
||||
fn propose_proposal(
|
||||
who: AccountId,
|
||||
threshold: u32,
|
||||
proposal: Box<RuntimeCall>,
|
||||
length_bound: u32,
|
||||
) -> Result<(u32, u32), DispatchError> {
|
||||
AllianceMotion::do_propose_proposed(who, threshold, proposal, length_bound)
|
||||
}
|
||||
|
||||
fn vote_proposal(
|
||||
who: AccountId,
|
||||
proposal: H256,
|
||||
index: ProposalIndex,
|
||||
approve: bool,
|
||||
) -> Result<bool, DispatchError> {
|
||||
AllianceMotion::do_vote(who, proposal, index, approve)
|
||||
}
|
||||
|
||||
fn close_proposal(
|
||||
proposal_hash: H256,
|
||||
proposal_index: ProposalIndex,
|
||||
proposal_weight_bound: Weight,
|
||||
length_bound: u32,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound)
|
||||
}
|
||||
|
||||
fn proposal_of(proposal_hash: H256) -> Option<RuntimeCall> {
|
||||
pezpallet_collective::ProposalOf::<Test, Instance1>::get(proposal_hash)
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxFellows: u32 = MaxMembers::get();
|
||||
pub const MaxAllies: u32 = 100;
|
||||
pub const AllyDeposit: u64 = 25;
|
||||
pub const RetirementPeriod: BlockNumber = MOTION_DURATION_IN_BLOCKS + 1;
|
||||
}
|
||||
impl Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Proposal = RuntimeCall;
|
||||
type AdminOrigin = EnsureSignedBy<One, AccountId>;
|
||||
type MembershipManager = EnsureSignedBy<Two, AccountId>;
|
||||
type AnnouncementOrigin = EnsureSignedBy<Three, AccountId>;
|
||||
type Currency = Balances;
|
||||
type Slashed = ();
|
||||
type InitializeMembers = AllianceMotion;
|
||||
type MembershipChanged = AllianceMotion;
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
type IdentityVerifier = AllianceIdentityVerifier;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type IdentityVerifier = ();
|
||||
type ProposalProvider = AllianceProposalProvider;
|
||||
type MaxProposals = MaxProposals;
|
||||
type MaxFellows = MaxFellows;
|
||||
type MaxAllies = MaxAllies;
|
||||
type MaxUnscrupulousItems = ConstU32<100>;
|
||||
type MaxWebsiteUrlLength = ConstU32<255>;
|
||||
type MaxAnnouncementsCount = ConstU32<100>;
|
||||
type MaxMembersCount = MaxMembers;
|
||||
type AllyDeposit = AllyDeposit;
|
||||
type WeightInfo = ();
|
||||
type RetirementPeriod = RetirementPeriod;
|
||||
}
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system,
|
||||
Balances: pezpallet_balances,
|
||||
Identity: pezpallet_identity,
|
||||
AllianceMotion: pezpallet_collective::<Instance1>,
|
||||
Alliance: pezpallet_alliance,
|
||||
}
|
||||
);
|
||||
|
||||
fn test_identity_info() -> IdentityInfo<MaxAdditionalFields> {
|
||||
IdentityInfo {
|
||||
additional: BoundedVec::default(),
|
||||
display: Data::Raw(b"name".to_vec().try_into().unwrap()),
|
||||
legal: Data::default(),
|
||||
web: Data::Raw(b"website".to_vec().try_into().unwrap()),
|
||||
riot: Data::default(),
|
||||
email: Data::default(),
|
||||
pgp_fingerprint: None,
|
||||
image: Data::default(),
|
||||
twitter: Data::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn test_identity_info_deposit() -> <Test as pezpallet_balances::Config>::Balance {
|
||||
let basic_deposit: u64 = <Test as pezpallet_identity::Config>::BasicDeposit::get();
|
||||
let byte_deposit: u64 = <Test as pezpallet_identity::Config>::ByteDeposit::get();
|
||||
byte_deposit * test_identity_info().encoded_size() as u64 + basic_deposit
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
|
||||
pezpallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![
|
||||
(1, 1000),
|
||||
(2, 1000),
|
||||
(3, 1000),
|
||||
(4, 1000),
|
||||
(5, test_identity_info_deposit() + 10),
|
||||
(6, 1000),
|
||||
(7, 1000),
|
||||
(8, 1000),
|
||||
(9, 1000),
|
||||
],
|
||||
..Default::default()
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
pezpallet_alliance::GenesisConfig::<Test> {
|
||||
fellows: vec![],
|
||||
allies: vec![],
|
||||
phantom: Default::default(),
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
let mut ext = pezsp_io::TestExternalities::new(t);
|
||||
ext.execute_with(|| {
|
||||
assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 1));
|
||||
|
||||
let info = test_identity_info();
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(1), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
1,
|
||||
Judgement::KnownGood,
|
||||
BlakeTwo256::hash_of(&info)
|
||||
));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(2), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
2,
|
||||
Judgement::KnownGood,
|
||||
BlakeTwo256::hash_of(&info)
|
||||
));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(3), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
3,
|
||||
Judgement::KnownGood,
|
||||
BlakeTwo256::hash_of(&info)
|
||||
));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(4), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
4,
|
||||
Judgement::KnownGood,
|
||||
BlakeTwo256::hash_of(&info)
|
||||
));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(5), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
5,
|
||||
Judgement::KnownGood,
|
||||
BlakeTwo256::hash_of(&info)
|
||||
));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(6), Box::new(info.clone())));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(8), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
8,
|
||||
Judgement::KnownGood,
|
||||
BlakeTwo256::hash_of(&info)
|
||||
));
|
||||
assert_ok!(Identity::set_identity(RuntimeOrigin::signed(9), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
9,
|
||||
Judgement::KnownGood,
|
||||
BlakeTwo256::hash_of(&info)
|
||||
));
|
||||
|
||||
// Joining before init should fail.
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(1)),
|
||||
Error::<Test, ()>::AllianceNotYetInitialized
|
||||
);
|
||||
|
||||
assert_ok!(Alliance::init_members(RuntimeOrigin::root(), vec![1, 2, 3], vec![]));
|
||||
|
||||
System::set_block_number(1);
|
||||
});
|
||||
ext
|
||||
}
|
||||
|
||||
pub fn build_and_execute(test: impl FnOnce()) {
|
||||
new_test_ext().execute_with(|| {
|
||||
test();
|
||||
Alliance::do_try_state().expect("All invariants must hold after a test");
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub fn new_bench_ext() -> pezsp_io::TestExternalities {
|
||||
RuntimeGenesisConfig::default().build_storage().unwrap().into()
|
||||
}
|
||||
|
||||
pub fn test_cid() -> Cid {
|
||||
let result = pezsp_crypto_hashing::sha2_256(b"hello world");
|
||||
Cid::new_v0(result)
|
||||
}
|
||||
|
||||
pub fn make_remark_proposal(value: u64) -> (RuntimeCall, u32, H256) {
|
||||
make_proposal(RuntimeCall::System(pezframe_system::Call::remark { remark: value.encode() }))
|
||||
}
|
||||
|
||||
pub fn make_kick_member_proposal(who: AccountId) -> (RuntimeCall, u32, H256) {
|
||||
make_proposal(RuntimeCall::Alliance(pezpallet_alliance::Call::kick_member { who }))
|
||||
}
|
||||
|
||||
pub fn make_proposal(proposal: RuntimeCall) -> (RuntimeCall, u32, H256) {
|
||||
let len: u32 = proposal.using_encoded(|p| p.len() as u32);
|
||||
let hash = BlakeTwo256::hash_of(&proposal);
|
||||
(proposal, len, hash)
|
||||
}
|
||||
|
||||
pub fn is_fellow(who: &AccountId) -> bool {
|
||||
Alliance::is_member_of(who, MemberRole::Fellow)
|
||||
}
|
||||
@@ -0,0 +1,652 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Tests for the alliance pallet.
|
||||
|
||||
use pezframe_support::{assert_noop, assert_ok};
|
||||
use pezframe_system::{EventRecord, Phase};
|
||||
use pezsp_runtime::traits::BadOrigin;
|
||||
|
||||
use super::*;
|
||||
use crate::{self as alliance, mock::*};
|
||||
|
||||
type AllianceMotionEvent = pezpallet_collective::Event<Test, pezpallet_collective::Instance1>;
|
||||
|
||||
fn assert_powerless(user: RuntimeOrigin, user_is_member: bool) {
|
||||
//vote / veto with a valid proposal
|
||||
let cid = test_cid();
|
||||
let (proposal, _, _) = make_kick_member_proposal(42);
|
||||
|
||||
assert_noop!(Alliance::init_members(user.clone(), vec![], vec![],), BadOrigin);
|
||||
|
||||
assert_noop!(
|
||||
Alliance::disband(user.clone(), DisbandWitness { fellow_members: 3, ..Default::default() }),
|
||||
BadOrigin
|
||||
);
|
||||
|
||||
assert_noop!(Alliance::set_rule(user.clone(), cid.clone()), BadOrigin);
|
||||
|
||||
assert_noop!(Alliance::retire(user.clone()), Error::<Test, ()>::RetirementNoticeNotGiven);
|
||||
|
||||
// Allies should be able to give retirement notice.
|
||||
if !user_is_member {
|
||||
assert_noop!(Alliance::give_retirement_notice(user.clone()), Error::<Test, ()>::NotMember);
|
||||
}
|
||||
|
||||
assert_noop!(Alliance::elevate_ally(user.clone(), 4), BadOrigin);
|
||||
|
||||
assert_noop!(Alliance::kick_member(user.clone(), 1), BadOrigin);
|
||||
|
||||
assert_noop!(Alliance::nominate_ally(user.clone(), 4), Error::<Test, ()>::NoVotingRights);
|
||||
|
||||
assert_noop!(
|
||||
Alliance::propose(user.clone(), 5, Box::new(proposal), 1000),
|
||||
Error::<Test, ()>::NoVotingRights
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn init_members_works() {
|
||||
build_and_execute(|| {
|
||||
// alliance must be reset first, no witness data
|
||||
assert_noop!(
|
||||
Alliance::init_members(RuntimeOrigin::root(), vec![8], vec![],),
|
||||
Error::<Test, ()>::AllianceAlreadyInitialized,
|
||||
);
|
||||
|
||||
// give a retirement notice to check later a retiring member not removed
|
||||
assert_ok!(Alliance::give_retirement_notice(RuntimeOrigin::signed(2)));
|
||||
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
|
||||
|
||||
// disband the Alliance to init new
|
||||
assert_ok!(Alliance::disband(RuntimeOrigin::root(), DisbandWitness::new(2, 0)));
|
||||
|
||||
// fails without root
|
||||
assert_noop!(Alliance::init_members(RuntimeOrigin::signed(1), vec![], vec![]), BadOrigin);
|
||||
|
||||
// fellows missing, other members given
|
||||
assert_noop!(
|
||||
Alliance::init_members(RuntimeOrigin::root(), vec![], vec![2],),
|
||||
Error::<Test, ()>::FellowsMissing,
|
||||
);
|
||||
|
||||
// success call
|
||||
assert_ok!(Alliance::init_members(RuntimeOrigin::root(), vec![8, 5], vec![2],));
|
||||
|
||||
// assert new set of voting members
|
||||
assert_eq!(Alliance::voting_members(), vec![5, 8]);
|
||||
// assert new members member
|
||||
assert!(is_fellow(&8));
|
||||
assert!(is_fellow(&5));
|
||||
assert!(Alliance::is_ally(&2));
|
||||
// assert a retiring member from previous Alliance not removed
|
||||
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
|
||||
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MembersInitialized {
|
||||
fellows: vec![5, 8],
|
||||
allies: vec![2],
|
||||
}));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disband_works() {
|
||||
build_and_execute(|| {
|
||||
let id_deposit = test_identity_info_deposit();
|
||||
let expected_join_deposit = <Test as Config>::AllyDeposit::get();
|
||||
assert_eq!(Balances::free_balance(9), 1000 - id_deposit);
|
||||
// ensure alliance is set
|
||||
assert_eq!(Alliance::voting_members(), vec![1, 2, 3]);
|
||||
|
||||
// give a retirement notice to check later a retiring member not removed
|
||||
assert_ok!(Alliance::give_retirement_notice(RuntimeOrigin::signed(2)));
|
||||
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
|
||||
|
||||
// join alliance and reserve funds
|
||||
assert_eq!(Balances::free_balance(9), 1000 - id_deposit);
|
||||
assert_ok!(Alliance::join_alliance(RuntimeOrigin::signed(9)));
|
||||
assert_eq!(alliance::DepositOf::<Test>::get(9), Some(expected_join_deposit));
|
||||
assert_eq!(Balances::free_balance(9), 1000 - id_deposit - expected_join_deposit);
|
||||
assert!(Alliance::is_member_of(&9, MemberRole::Ally));
|
||||
|
||||
// fails without root
|
||||
assert_noop!(Alliance::disband(RuntimeOrigin::signed(1), Default::default()), BadOrigin);
|
||||
|
||||
// bad witness data checks
|
||||
assert_noop!(
|
||||
Alliance::disband(RuntimeOrigin::root(), Default::default(),),
|
||||
Error::<Test, ()>::BadWitness
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Alliance::disband(RuntimeOrigin::root(), DisbandWitness::new(1, 1)),
|
||||
Error::<Test, ()>::BadWitness,
|
||||
);
|
||||
assert_noop!(
|
||||
Alliance::disband(RuntimeOrigin::root(), DisbandWitness::new(2, 0)),
|
||||
Error::<Test, ()>::BadWitness,
|
||||
);
|
||||
|
||||
// success call
|
||||
assert_ok!(Alliance::disband(RuntimeOrigin::root(), DisbandWitness::new(2, 1)));
|
||||
|
||||
// assert members disband
|
||||
assert!(!Alliance::is_member(&1));
|
||||
assert!(!Alliance::is_initialized());
|
||||
// assert a retiring member from the previous Alliance not removed
|
||||
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
|
||||
// deposit unreserved
|
||||
assert_eq!(Balances::free_balance(9), 1000 - id_deposit);
|
||||
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::AllianceDisbanded {
|
||||
fellow_members: 2,
|
||||
ally_members: 1,
|
||||
unreserved: 1,
|
||||
}));
|
||||
|
||||
// the Alliance must be set first
|
||||
assert_noop!(
|
||||
Alliance::disband(RuntimeOrigin::root(), DisbandWitness::new(100, 100)),
|
||||
Error::<Test, ()>::AllianceNotYetInitialized,
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn propose_works() {
|
||||
build_and_execute(|| {
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
|
||||
// only voting member can propose proposal, 4 is ally not have vote rights
|
||||
assert_noop!(
|
||||
Alliance::propose(
|
||||
RuntimeOrigin::signed(4),
|
||||
3,
|
||||
Box::new(proposal.clone()),
|
||||
proposal_len
|
||||
),
|
||||
Error::<Test, ()>::NoVotingRights
|
||||
);
|
||||
|
||||
assert_ok!(Alliance::propose(
|
||||
RuntimeOrigin::signed(1),
|
||||
3,
|
||||
Box::new(proposal.clone()),
|
||||
proposal_len
|
||||
));
|
||||
assert_eq!(*pezpallet_collective::Proposals::<Test, Instance1>::get(), vec![hash]);
|
||||
assert_eq!(pezpallet_collective::ProposalOf::<Test, Instance1>::get(&hash), Some(proposal));
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![EventRecord {
|
||||
phase: Phase::Initialization,
|
||||
event: mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3,
|
||||
}),
|
||||
topics: vec![],
|
||||
}]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vote_works() {
|
||||
build_and_execute(|| {
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
assert_ok!(Alliance::propose(
|
||||
RuntimeOrigin::signed(1),
|
||||
3,
|
||||
Box::new(proposal.clone()),
|
||||
proposal_len
|
||||
));
|
||||
assert_ok!(Alliance::vote(RuntimeOrigin::signed(2), hash, 0, true));
|
||||
|
||||
let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] };
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0,
|
||||
})),
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn close_works() {
|
||||
build_and_execute(|| {
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
let proposal_weight = proposal.get_dispatch_info().call_weight;
|
||||
assert_ok!(Alliance::propose(
|
||||
RuntimeOrigin::signed(1),
|
||||
3,
|
||||
Box::new(proposal.clone()),
|
||||
proposal_len
|
||||
));
|
||||
assert_ok!(Alliance::vote(RuntimeOrigin::signed(1), hash, 0, true));
|
||||
assert_ok!(Alliance::vote(RuntimeOrigin::signed(2), hash, 0, true));
|
||||
assert_ok!(Alliance::vote(RuntimeOrigin::signed(3), hash, 0, true));
|
||||
assert_ok!(Alliance::close(
|
||||
RuntimeOrigin::signed(1),
|
||||
hash,
|
||||
0,
|
||||
proposal_weight,
|
||||
proposal_len
|
||||
));
|
||||
|
||||
let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] };
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0,
|
||||
})),
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0,
|
||||
})),
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
|
||||
account: 3,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 3,
|
||||
no: 0,
|
||||
})),
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 3,
|
||||
no: 0,
|
||||
})),
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Approved {
|
||||
proposal_hash: hash
|
||||
})),
|
||||
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Ok(()),
|
||||
}))
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_rule_works() {
|
||||
build_and_execute(|| {
|
||||
let cid = test_cid();
|
||||
assert_ok!(Alliance::set_rule(RuntimeOrigin::signed(1), cid.clone()));
|
||||
assert_eq!(alliance::Rule::<Test>::get(), Some(cid.clone()));
|
||||
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::NewRuleSet {
|
||||
rule: cid,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn announce_works() {
|
||||
build_and_execute(|| {
|
||||
let cid = test_cid();
|
||||
|
||||
assert_noop!(Alliance::announce(RuntimeOrigin::signed(2), cid.clone()), BadOrigin);
|
||||
|
||||
assert_ok!(Alliance::announce(RuntimeOrigin::signed(3), cid.clone()));
|
||||
assert_eq!(alliance::Announcements::<Test>::get(), vec![cid.clone()]);
|
||||
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced {
|
||||
announcement: cid,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_announcement_works() {
|
||||
build_and_execute(|| {
|
||||
let cid = test_cid();
|
||||
assert_ok!(Alliance::announce(RuntimeOrigin::signed(3), cid.clone()));
|
||||
assert_eq!(alliance::Announcements::<Test>::get(), vec![cid.clone()]);
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced {
|
||||
announcement: cid.clone(),
|
||||
}));
|
||||
|
||||
System::set_block_number(2);
|
||||
|
||||
assert_ok!(Alliance::remove_announcement(RuntimeOrigin::signed(3), cid.clone()));
|
||||
assert_eq!(alliance::Announcements::<Test>::get(), vec![]);
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(
|
||||
crate::Event::AnnouncementRemoved { announcement: cid },
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn join_alliance_works() {
|
||||
build_and_execute(|| {
|
||||
let id_deposit = test_identity_info_deposit();
|
||||
let join_deposit = <Test as Config>::AllyDeposit::get();
|
||||
assert_eq!(Balances::free_balance(9), 1000 - id_deposit);
|
||||
// check already member
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(1)),
|
||||
Error::<Test, ()>::AlreadyMember
|
||||
);
|
||||
|
||||
// check already listed as unscrupulous
|
||||
assert_ok!(Alliance::add_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(4)]
|
||||
));
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(4)),
|
||||
Error::<Test, ()>::AccountNonGrata
|
||||
);
|
||||
assert_ok!(Alliance::remove_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(4)]
|
||||
));
|
||||
|
||||
// check deposit funds
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(5)),
|
||||
Error::<Test, ()>::InsufficientFunds
|
||||
);
|
||||
|
||||
assert_eq!(Balances::free_balance(4), 1000 - id_deposit);
|
||||
// success to submit
|
||||
assert_ok!(Alliance::join_alliance(RuntimeOrigin::signed(4)));
|
||||
assert_eq!(Balances::free_balance(4), 1000 - id_deposit - join_deposit);
|
||||
assert_eq!(alliance::DepositOf::<Test>::get(4), Some(25));
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Ally), vec![4]);
|
||||
|
||||
// check already member
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(4)),
|
||||
Error::<Test, ()>::AlreadyMember
|
||||
);
|
||||
|
||||
// check missing identity judgement
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(6)),
|
||||
Error::<Test, ()>::WithoutGoodIdentityJudgement
|
||||
);
|
||||
// check missing identity info
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(7)),
|
||||
Error::<Test, ()>::WithoutRequiredIdentityFields
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nominate_ally_works() {
|
||||
build_and_execute(|| {
|
||||
// check already member
|
||||
assert_noop!(
|
||||
Alliance::nominate_ally(RuntimeOrigin::signed(1), 2),
|
||||
Error::<Test, ()>::AlreadyMember
|
||||
);
|
||||
|
||||
// only voting members (Fellows) have nominate right
|
||||
assert_noop!(
|
||||
Alliance::nominate_ally(RuntimeOrigin::signed(5), 4),
|
||||
Error::<Test, ()>::NoVotingRights
|
||||
);
|
||||
|
||||
// check already listed as unscrupulous
|
||||
assert_ok!(Alliance::add_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(4)]
|
||||
));
|
||||
assert_noop!(
|
||||
Alliance::nominate_ally(RuntimeOrigin::signed(1), 4),
|
||||
Error::<Test, ()>::AccountNonGrata
|
||||
);
|
||||
assert_ok!(Alliance::remove_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(4)]
|
||||
));
|
||||
|
||||
// success to nominate
|
||||
assert_ok!(Alliance::nominate_ally(RuntimeOrigin::signed(1), 4));
|
||||
assert_eq!(alliance::DepositOf::<Test>::get(4), None);
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Ally), vec![4]);
|
||||
|
||||
// check already member
|
||||
assert_noop!(
|
||||
Alliance::nominate_ally(RuntimeOrigin::signed(1), 4),
|
||||
Error::<Test, ()>::AlreadyMember
|
||||
);
|
||||
|
||||
// check missing identity judgement
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(6)),
|
||||
Error::<Test, ()>::WithoutGoodIdentityJudgement
|
||||
);
|
||||
// check missing identity info
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
assert_noop!(
|
||||
Alliance::join_alliance(RuntimeOrigin::signed(7)),
|
||||
Error::<Test, ()>::WithoutRequiredIdentityFields
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn elevate_ally_works() {
|
||||
build_and_execute(|| {
|
||||
assert_noop!(
|
||||
Alliance::elevate_ally(RuntimeOrigin::signed(2), 4),
|
||||
Error::<Test, ()>::NotAlly
|
||||
);
|
||||
|
||||
assert_ok!(Alliance::join_alliance(RuntimeOrigin::signed(4)));
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Ally), vec![4]);
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3]);
|
||||
|
||||
assert_ok!(Alliance::elevate_ally(RuntimeOrigin::signed(2), 4));
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Ally), Vec::<u64>::new());
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3, 4]);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn give_retirement_notice_work() {
|
||||
build_and_execute(|| {
|
||||
assert_noop!(
|
||||
Alliance::give_retirement_notice(RuntimeOrigin::signed(4)),
|
||||
Error::<Test, ()>::NotMember
|
||||
);
|
||||
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3]);
|
||||
assert_ok!(Alliance::give_retirement_notice(RuntimeOrigin::signed(3)));
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2]);
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Retiring), vec![3]);
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(
|
||||
crate::Event::MemberRetirementPeriodStarted { member: (3) },
|
||||
));
|
||||
|
||||
assert_noop!(
|
||||
Alliance::give_retirement_notice(RuntimeOrigin::signed(3)),
|
||||
Error::<Test, ()>::AlreadyRetiring
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retire_works() {
|
||||
build_and_execute(|| {
|
||||
assert_noop!(
|
||||
Alliance::retire(RuntimeOrigin::signed(2)),
|
||||
Error::<Test, ()>::RetirementNoticeNotGiven
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Alliance::retire(RuntimeOrigin::signed(4)),
|
||||
Error::<Test, ()>::RetirementNoticeNotGiven
|
||||
);
|
||||
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3]);
|
||||
assert_ok!(Alliance::give_retirement_notice(RuntimeOrigin::signed(3)));
|
||||
assert_noop!(
|
||||
Alliance::retire(RuntimeOrigin::signed(3)),
|
||||
Error::<Test, ()>::RetirementPeriodNotPassed
|
||||
);
|
||||
System::set_block_number(System::block_number() + RetirementPeriod::get());
|
||||
assert_ok!(Alliance::retire(RuntimeOrigin::signed(3)));
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2]);
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberRetired {
|
||||
member: (3),
|
||||
unreserved: None,
|
||||
}));
|
||||
|
||||
// Move time on:
|
||||
System::set_block_number(System::block_number() + RetirementPeriod::get());
|
||||
|
||||
assert_powerless(RuntimeOrigin::signed(3), false);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn abdicate_works() {
|
||||
build_and_execute(|| {
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3]);
|
||||
assert_ok!(Alliance::abdicate_fellow_status(RuntimeOrigin::signed(3)));
|
||||
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::FellowAbdicated {
|
||||
fellow: (3),
|
||||
}));
|
||||
|
||||
assert_powerless(RuntimeOrigin::signed(3), true);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kick_member_works() {
|
||||
build_and_execute(|| {
|
||||
assert_noop!(Alliance::kick_member(RuntimeOrigin::signed(4), 4), BadOrigin);
|
||||
|
||||
assert_noop!(
|
||||
Alliance::kick_member(RuntimeOrigin::signed(2), 4),
|
||||
Error::<Test, ()>::NotMember
|
||||
);
|
||||
|
||||
<DepositOf<Test, ()>>::insert(2, 25);
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 2, 3]);
|
||||
assert_ok!(Alliance::kick_member(RuntimeOrigin::signed(2), 2));
|
||||
assert_eq!(alliance::Members::<Test>::get(MemberRole::Fellow), vec![1, 3]);
|
||||
assert_eq!(<DepositOf<Test, ()>>::get(2), None);
|
||||
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberKicked {
|
||||
member: (2),
|
||||
slashed: Some(25),
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_unscrupulous_items_works() {
|
||||
build_and_execute(|| {
|
||||
assert_noop!(Alliance::add_unscrupulous_items(RuntimeOrigin::signed(2), vec![]), BadOrigin);
|
||||
|
||||
assert_ok!(Alliance::add_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![
|
||||
UnscrupulousItem::AccountId(3),
|
||||
UnscrupulousItem::Website("abc".as_bytes().to_vec().try_into().unwrap())
|
||||
]
|
||||
));
|
||||
assert_eq!(alliance::UnscrupulousAccounts::<Test>::get().into_inner(), vec![3]);
|
||||
assert_eq!(
|
||||
alliance::UnscrupulousWebsites::<Test>::get().into_inner(),
|
||||
vec!["abc".as_bytes().to_vec()]
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Alliance::add_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(3)]
|
||||
),
|
||||
Error::<Test, ()>::AlreadyUnscrupulous
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_unscrupulous_items_works() {
|
||||
build_and_execute(|| {
|
||||
assert_noop!(
|
||||
Alliance::remove_unscrupulous_items(RuntimeOrigin::signed(2), vec![]),
|
||||
BadOrigin
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Alliance::remove_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(3)]
|
||||
),
|
||||
Error::<Test, ()>::NotListedAsUnscrupulous
|
||||
);
|
||||
|
||||
assert_ok!(Alliance::add_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(3)]
|
||||
));
|
||||
assert_eq!(alliance::UnscrupulousAccounts::<Test>::get(), vec![3]);
|
||||
assert_ok!(Alliance::remove_unscrupulous_items(
|
||||
RuntimeOrigin::signed(3),
|
||||
vec![UnscrupulousItem::AccountId(3)]
|
||||
));
|
||||
assert_eq!(alliance::UnscrupulousAccounts::<Test>::get(), Vec::<u64>::new());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weights_sane() {
|
||||
let info = crate::Call::<Test>::join_alliance {}.get_dispatch_info();
|
||||
assert_eq!(<() as crate::WeightInfo>::join_alliance(), info.call_weight);
|
||||
|
||||
let info = crate::Call::<Test>::nominate_ally { who: 10 }.get_dispatch_info();
|
||||
assert_eq!(<() as crate::WeightInfo>::nominate_ally(), info.call_weight);
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use pezframe_support::{traits::ConstU32, BoundedVec};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::RuntimeDebug;
|
||||
|
||||
/// A Multihash instance that only supports the basic functionality and no hashing.
|
||||
#[derive(
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
RuntimeDebug,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
TypeInfo,
|
||||
MaxEncodedLen,
|
||||
)]
|
||||
pub struct Multihash {
|
||||
/// The code of the Multihash.
|
||||
pub code: u64,
|
||||
/// The digest.
|
||||
pub digest: BoundedVec<u8, ConstU32<68>>, // 4 byte dig size + 64 bytes hash digest
|
||||
}
|
||||
|
||||
impl Multihash {
|
||||
/// Returns the size of the digest.
|
||||
pub fn size(&self) -> usize {
|
||||
self.digest.len()
|
||||
}
|
||||
}
|
||||
|
||||
/// The version of the CID.
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
RuntimeDebug,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
TypeInfo,
|
||||
MaxEncodedLen,
|
||||
)]
|
||||
pub enum Version {
|
||||
/// CID version 0.
|
||||
V0,
|
||||
/// CID version 1.
|
||||
V1,
|
||||
}
|
||||
|
||||
/// Representation of a CID.
|
||||
///
|
||||
/// The generic is about the allocated size of the multihash.
|
||||
#[derive(
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
RuntimeDebug,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
TypeInfo,
|
||||
MaxEncodedLen,
|
||||
)]
|
||||
pub struct Cid {
|
||||
/// The version of CID.
|
||||
pub version: Version,
|
||||
/// The codec of CID.
|
||||
pub codec: u64,
|
||||
/// The multihash of CID.
|
||||
pub hash: Multihash,
|
||||
}
|
||||
|
||||
impl Cid {
|
||||
/// Creates a new CIDv0.
|
||||
pub fn new_v0(sha2_256_digest: impl Into<Vec<u8>>) -> Self {
|
||||
/// DAG-PB multicodec code
|
||||
const DAG_PB: u64 = 0x70;
|
||||
/// The SHA_256 multicodec code
|
||||
const SHA2_256: u64 = 0x12;
|
||||
|
||||
let digest = sha2_256_digest.into();
|
||||
assert_eq!(digest.len(), 32);
|
||||
|
||||
Self {
|
||||
version: Version::V0,
|
||||
codec: DAG_PB,
|
||||
hash: Multihash { code: SHA2_256, digest: digest.try_into().expect("msg") },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Witness data for the `disband` call.
|
||||
#[derive(
|
||||
Copy,
|
||||
Clone,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
Default,
|
||||
)]
|
||||
pub struct DisbandWitness {
|
||||
/// Total number of fellow members in the current Alliance.
|
||||
#[codec(compact)]
|
||||
pub(super) fellow_members: u32,
|
||||
/// Total number of ally members in the current Alliance.
|
||||
#[codec(compact)]
|
||||
pub(super) ally_members: u32,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl DisbandWitness {
|
||||
// Creates new DisbandWitness.
|
||||
pub(super) fn new(fellow_members: u32, ally_members: u32) -> Self {
|
||||
Self { fellow_members, ally_members }
|
||||
}
|
||||
}
|
||||
|
||||
impl DisbandWitness {
|
||||
pub(super) fn is_zero(self) -> bool {
|
||||
self == Self::default()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,932 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Autogenerated weights for `pezpallet_alliance`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `4563561839a5`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// --extrinsic=*
|
||||
// --runtime=target/production/wbuild/kitchensink-runtime/kitchensink_runtime.wasm
|
||||
// --pallet=pezpallet_alliance
|
||||
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
|
||||
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/alliance/src/weights.rs
|
||||
// --wasm-execution=compiled
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --heap-pages=4096
|
||||
// --template=bizinikiwi/.maintain/frame-weight-template.hbs
|
||||
// --no-storage-info
|
||||
// --no-min-squares
|
||||
// --no-median-slopes
|
||||
// --genesis-builder-policy=none
|
||||
// --exclude-pallets=pezpallet_xcm,pezpallet_xcm_benchmarks::fungible,pezpallet_xcm_benchmarks::generic,pezpallet_nomination_pools,pezpallet_remark,pezpallet_transaction_storage,pezpallet_election_provider_multi_block,pezpallet_election_provider_multi_block::signed,pezpallet_election_provider_multi_block::unsigned,pezpallet_election_provider_multi_block::verifier
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for `pezpallet_alliance`.
|
||||
pub trait WeightInfo {
|
||||
fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight;
|
||||
fn vote(m: u32, ) -> Weight;
|
||||
fn close_early_disapproved(m: u32, p: u32, ) -> Weight;
|
||||
fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight;
|
||||
fn close_disapproved(m: u32, p: u32, ) -> Weight;
|
||||
fn close_approved(b: u32, m: u32, p: u32, ) -> Weight;
|
||||
fn init_members(m: u32, z: u32, ) -> Weight;
|
||||
fn disband(x: u32, y: u32, z: u32, ) -> Weight;
|
||||
fn set_rule() -> Weight;
|
||||
fn announce() -> Weight;
|
||||
fn remove_announcement() -> Weight;
|
||||
fn join_alliance() -> Weight;
|
||||
fn nominate_ally() -> Weight;
|
||||
fn elevate_ally() -> Weight;
|
||||
fn give_retirement_notice() -> Weight;
|
||||
fn retire() -> Weight;
|
||||
fn kick_member() -> Weight;
|
||||
fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight;
|
||||
fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight;
|
||||
fn abdicate_fellow_status() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pezpallet_alliance` using the Bizinikiwi node and recommended hardware.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalCount` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `b` is `[1, 1024]`.
|
||||
/// The range of component `m` is `[2, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `393 + m * (32 ±0) + p * (36 ±0)`
|
||||
// Estimated: `6676 + m * (31 ±0) + p * (34 ±0)`
|
||||
// Minimum execution time: 28_698_000 picoseconds.
|
||||
Weight::from_parts(30_351_668, 6676)
|
||||
// Standard Error: 159
|
||||
.saturating_add(Weight::from_parts(426, 0).saturating_mul(b.into()))
|
||||
// Standard Error: 1_663
|
||||
.saturating_add(Weight::from_parts(58_244, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_642
|
||||
.saturating_add(Weight::from_parts(167_166, 0).saturating_mul(p.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
.saturating_add(Weight::from_parts(0, 31).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 34).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[5, 100]`.
|
||||
fn vote(m: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `826 + m * (64 ±0)`
|
||||
// Estimated: `6676 + m * (64 ±0)`
|
||||
// Minimum execution time: 28_697_000 picoseconds.
|
||||
Weight::from_parts(31_067_187, 6676)
|
||||
// Standard Error: 1_039
|
||||
.saturating_add(Weight::from_parts(59_623, 0).saturating_mul(m.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
.saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[4, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_early_disapproved(m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `353 + m * (96 ±0) + p * (36 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (36 ±0)`
|
||||
// Minimum execution time: 38_262_000 picoseconds.
|
||||
Weight::from_parts(36_996_728, 6676)
|
||||
// Standard Error: 1_395
|
||||
.saturating_add(Weight::from_parts(57_361, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_360
|
||||
.saturating_add(Weight::from_parts(153_310, 0).saturating_mul(p.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `SafeMode::EnteredUntil` (r:1 w:0)
|
||||
/// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `TxPause::PausedCalls` (r:1 w:0)
|
||||
/// Proof: `TxPause::PausedCalls` (`max_values`: None, `max_size`: Some(532), added: 3007, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `b` is `[1, 1024]`.
|
||||
/// The range of component `m` is `[4, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `787 + m * (96 ±0) + p * (39 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (40 ±0)`
|
||||
// Minimum execution time: 53_346_000 picoseconds.
|
||||
Weight::from_parts(54_867_557, 6676)
|
||||
// Standard Error: 193
|
||||
.saturating_add(Weight::from_parts(1_120, 0).saturating_mul(b.into()))
|
||||
// Standard Error: 2_044
|
||||
.saturating_add(Weight::from_parts(45_379, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_992
|
||||
.saturating_add(Weight::from_parts(175_444, 0).saturating_mul(p.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(7_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[2, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_disapproved(m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `354 + m * (96 ±0) + p * (36 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (36 ±0)`
|
||||
// Minimum execution time: 39_385_000 picoseconds.
|
||||
Weight::from_parts(38_853_198, 6676)
|
||||
// Standard Error: 1_720
|
||||
.saturating_add(Weight::from_parts(52_287, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_699
|
||||
.saturating_add(Weight::from_parts(152_517, 0).saturating_mul(p.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(5_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `b` is `[1, 1024]`.
|
||||
/// The range of component `m` is `[5, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_approved(b: u32, m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `407 + m * (96 ±0) + p * (35 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (36 ±0)`
|
||||
// Minimum execution time: 38_956_000 picoseconds.
|
||||
Weight::from_parts(38_958_561, 6676)
|
||||
// Standard Error: 127
|
||||
.saturating_add(Weight::from_parts(469, 0).saturating_mul(b.into()))
|
||||
// Standard Error: 1_360
|
||||
.saturating_add(Weight::from_parts(42_627, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_311
|
||||
.saturating_add(Weight::from_parts(158_641, 0).saturating_mul(p.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(5_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:2 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[1, 100]`.
|
||||
/// The range of component `z` is `[0, 100]`.
|
||||
fn init_members(m: u32, z: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `12362`
|
||||
// Minimum execution time: 24_313_000 picoseconds.
|
||||
Weight::from_parts(13_936_604, 12362)
|
||||
// Standard Error: 1_153
|
||||
.saturating_add(Weight::from_parts(124_789, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_140
|
||||
.saturating_add(Weight::from_parts(113_862, 0).saturating_mul(z.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:2 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Alliance::DepositOf` (r:200 w:50)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:50 w:50)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `x` is `[1, 100]`.
|
||||
/// The range of component `y` is `[0, 100]`.
|
||||
/// The range of component `z` is `[0, 50]`.
|
||||
fn disband(x: u32, y: u32, z: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0 + x * (83 ±0) + y * (52 ±0) + z * (248 ±0)`
|
||||
// Estimated: `12362 + x * (2539 ±0) + y * (2539 ±0) + z * (2603 ±1)`
|
||||
// Minimum execution time: 369_362_000 picoseconds.
|
||||
Weight::from_parts(373_165_000, 12362)
|
||||
// Standard Error: 30_558
|
||||
.saturating_add(Weight::from_parts(813_586, 0).saturating_mul(x.into()))
|
||||
// Standard Error: 30_411
|
||||
.saturating_add(Weight::from_parts(779_925, 0).saturating_mul(y.into()))
|
||||
// Standard Error: 60_767
|
||||
.saturating_add(Weight::from_parts(14_852_466, 0).saturating_mul(z.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
|
||||
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into())))
|
||||
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into())))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(z.into())))
|
||||
.saturating_add(Weight::from_parts(0, 2539).saturating_mul(x.into()))
|
||||
.saturating_add(Weight::from_parts(0, 2539).saturating_mul(y.into()))
|
||||
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(z.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Rule` (r:0 w:1)
|
||||
/// Proof: `Alliance::Rule` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`)
|
||||
fn set_rule() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 5_320_000 picoseconds.
|
||||
Weight::from_parts(5_541_000, 0)
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Announcements` (r:1 w:1)
|
||||
/// Proof: `Alliance::Announcements` (`max_values`: Some(1), `max_size`: Some(8702), added: 9197, mode: `MaxEncodedLen`)
|
||||
fn announce() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `54`
|
||||
// Estimated: `10187`
|
||||
// Minimum execution time: 7_541_000 picoseconds.
|
||||
Weight::from_parts(7_884_000, 10187)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Announcements` (r:1 w:1)
|
||||
/// Proof: `Alliance::Announcements` (`max_values`: Some(1), `max_size`: Some(8702), added: 9197, mode: `MaxEncodedLen`)
|
||||
fn remove_announcement() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `127`
|
||||
// Estimated: `10187`
|
||||
// Minimum execution time: 8_760_000 picoseconds.
|
||||
Weight::from_parts(9_201_000, 10187)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:0)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::DepositOf` (r:0 w:1)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
fn join_alliance() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `221`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 39_045_000 picoseconds.
|
||||
Weight::from_parts(40_425_000, 18048)
|
||||
.saturating_add(T::DbWeight::get().reads(5_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:0)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
fn nominate_ally() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `170`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 23_593_000 picoseconds.
|
||||
Weight::from_parts(24_151_000, 18048)
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:2 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn elevate_ally() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `206`
|
||||
// Estimated: `12362`
|
||||
// Minimum execution time: 21_720_000 picoseconds.
|
||||
Weight::from_parts(22_214_000, 12362)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:4 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Alliance::RetiringMembers` (r:0 w:1)
|
||||
/// Proof: `Alliance::RetiringMembers` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
|
||||
fn give_retirement_notice() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `206`
|
||||
// Estimated: `23734`
|
||||
// Minimum execution time: 26_820_000 picoseconds.
|
||||
Weight::from_parts(27_614_000, 23734)
|
||||
.saturating_add(T::DbWeight::get().reads(5_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(5_u64))
|
||||
}
|
||||
/// Storage: `Alliance::RetiringMembers` (r:1 w:1)
|
||||
/// Proof: `Alliance::RetiringMembers` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::Members` (r:1 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::DepositOf` (r:1 w:1)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
fn retire() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `458`
|
||||
// Estimated: `6676`
|
||||
// Minimum execution time: 36_070_000 picoseconds.
|
||||
Weight::from_parts(36_974_000, 6676)
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Alliance::DepositOf` (r:1 w:1)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn kick_member() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `434`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 58_302_000 picoseconds.
|
||||
Weight::from_parts(59_775_000, 18048)
|
||||
.saturating_add(T::DbWeight::get().reads(6_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(5_u64))
|
||||
}
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousWebsites` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousWebsites` (`max_values`: Some(1), `max_size`: Some(25702), added: 26197, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[0, 100]`.
|
||||
/// The range of component `l` is `[0, 255]`.
|
||||
fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `54`
|
||||
// Estimated: `27187`
|
||||
// Minimum execution time: 4_803_000 picoseconds.
|
||||
Weight::from_parts(4_858_000, 27187)
|
||||
// Standard Error: 3_655
|
||||
.saturating_add(Weight::from_parts(1_136_024, 0).saturating_mul(n.into()))
|
||||
// Standard Error: 1_431
|
||||
.saturating_add(Weight::from_parts(65_747, 0).saturating_mul(l.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousWebsites` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousWebsites` (`max_values`: Some(1), `max_size`: Some(25702), added: 26197, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[0, 100]`.
|
||||
/// The range of component `l` is `[0, 255]`.
|
||||
fn remove_unscrupulous_items(n: u32, _l: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0 + l * (100 ±0) + n * (289 ±0)`
|
||||
// Estimated: `27187`
|
||||
// Minimum execution time: 4_818_000 picoseconds.
|
||||
Weight::from_parts(4_893_000, 27187)
|
||||
// Standard Error: 184_675
|
||||
.saturating_add(Weight::from_parts(19_530_779, 0).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn abdicate_fellow_status() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `206`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 25_908_000 picoseconds.
|
||||
Weight::from_parts(26_640_000, 18048)
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalCount` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `b` is `[1, 1024]`.
|
||||
/// The range of component `m` is `[2, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `393 + m * (32 ±0) + p * (36 ±0)`
|
||||
// Estimated: `6676 + m * (31 ±0) + p * (34 ±0)`
|
||||
// Minimum execution time: 28_698_000 picoseconds.
|
||||
Weight::from_parts(30_351_668, 6676)
|
||||
// Standard Error: 159
|
||||
.saturating_add(Weight::from_parts(426, 0).saturating_mul(b.into()))
|
||||
// Standard Error: 1_663
|
||||
.saturating_add(Weight::from_parts(58_244, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_642
|
||||
.saturating_add(Weight::from_parts(167_166, 0).saturating_mul(p.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
.saturating_add(Weight::from_parts(0, 31).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 34).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[5, 100]`.
|
||||
fn vote(m: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `826 + m * (64 ±0)`
|
||||
// Estimated: `6676 + m * (64 ±0)`
|
||||
// Minimum execution time: 28_697_000 picoseconds.
|
||||
Weight::from_parts(31_067_187, 6676)
|
||||
// Standard Error: 1_039
|
||||
.saturating_add(Weight::from_parts(59_623, 0).saturating_mul(m.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
.saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[4, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_early_disapproved(m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `353 + m * (96 ±0) + p * (36 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (36 ±0)`
|
||||
// Minimum execution time: 38_262_000 picoseconds.
|
||||
Weight::from_parts(36_996_728, 6676)
|
||||
// Standard Error: 1_395
|
||||
.saturating_add(Weight::from_parts(57_361, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_360
|
||||
.saturating_add(Weight::from_parts(153_310, 0).saturating_mul(p.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `SafeMode::EnteredUntil` (r:1 w:0)
|
||||
/// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `TxPause::PausedCalls` (r:1 w:0)
|
||||
/// Proof: `TxPause::PausedCalls` (`max_values`: None, `max_size`: Some(532), added: 3007, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `b` is `[1, 1024]`.
|
||||
/// The range of component `m` is `[4, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `787 + m * (96 ±0) + p * (39 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (40 ±0)`
|
||||
// Minimum execution time: 53_346_000 picoseconds.
|
||||
Weight::from_parts(54_867_557, 6676)
|
||||
// Standard Error: 193
|
||||
.saturating_add(Weight::from_parts(1_120, 0).saturating_mul(b.into()))
|
||||
// Standard Error: 2_044
|
||||
.saturating_add(Weight::from_parts(45_379, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_992
|
||||
.saturating_add(Weight::from_parts(175_444, 0).saturating_mul(p.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(7_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[2, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_disapproved(m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `354 + m * (96 ±0) + p * (36 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (36 ±0)`
|
||||
// Minimum execution time: 39_385_000 picoseconds.
|
||||
Weight::from_parts(38_853_198, 6676)
|
||||
// Standard Error: 1_720
|
||||
.saturating_add(Weight::from_parts(52_287, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_699
|
||||
.saturating_add(Weight::from_parts(152_517, 0).saturating_mul(p.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(5_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:1 w:0)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Voting` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::ProposalOf` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `b` is `[1, 1024]`.
|
||||
/// The range of component `m` is `[5, 100]`.
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn close_approved(b: u32, m: u32, p: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `407 + m * (96 ±0) + p * (35 ±0)`
|
||||
// Estimated: `6676 + m * (97 ±0) + p * (36 ±0)`
|
||||
// Minimum execution time: 38_956_000 picoseconds.
|
||||
Weight::from_parts(38_958_561, 6676)
|
||||
// Standard Error: 127
|
||||
.saturating_add(Weight::from_parts(469, 0).saturating_mul(b.into()))
|
||||
// Standard Error: 1_360
|
||||
.saturating_add(Weight::from_parts(42_627, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_311
|
||||
.saturating_add(Weight::from_parts(158_641, 0).saturating_mul(p.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(5_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into()))
|
||||
.saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:2 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Members` (r:1 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `m` is `[1, 100]`.
|
||||
/// The range of component `z` is `[0, 100]`.
|
||||
fn init_members(m: u32, z: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `12362`
|
||||
// Minimum execution time: 24_313_000 picoseconds.
|
||||
Weight::from_parts(13_936_604, 12362)
|
||||
// Standard Error: 1_153
|
||||
.saturating_add(Weight::from_parts(124_789, 0).saturating_mul(m.into()))
|
||||
// Standard Error: 1_140
|
||||
.saturating_add(Weight::from_parts(113_862, 0).saturating_mul(z.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:2 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Alliance::DepositOf` (r:200 w:50)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:50 w:50)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `x` is `[1, 100]`.
|
||||
/// The range of component `y` is `[0, 100]`.
|
||||
/// The range of component `z` is `[0, 50]`.
|
||||
fn disband(x: u32, y: u32, z: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0 + x * (83 ±0) + y * (52 ±0) + z * (248 ±0)`
|
||||
// Estimated: `12362 + x * (2539 ±0) + y * (2539 ±0) + z * (2603 ±1)`
|
||||
// Minimum execution time: 369_362_000 picoseconds.
|
||||
Weight::from_parts(373_165_000, 12362)
|
||||
// Standard Error: 30_558
|
||||
.saturating_add(Weight::from_parts(813_586, 0).saturating_mul(x.into()))
|
||||
// Standard Error: 30_411
|
||||
.saturating_add(Weight::from_parts(779_925, 0).saturating_mul(y.into()))
|
||||
// Standard Error: 60_767
|
||||
.saturating_add(Weight::from_parts(14_852_466, 0).saturating_mul(z.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into())))
|
||||
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into())))
|
||||
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(z.into())))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(z.into())))
|
||||
.saturating_add(Weight::from_parts(0, 2539).saturating_mul(x.into()))
|
||||
.saturating_add(Weight::from_parts(0, 2539).saturating_mul(y.into()))
|
||||
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(z.into()))
|
||||
}
|
||||
/// Storage: `Alliance::Rule` (r:0 w:1)
|
||||
/// Proof: `Alliance::Rule` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`)
|
||||
fn set_rule() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 5_320_000 picoseconds.
|
||||
Weight::from_parts(5_541_000, 0)
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Announcements` (r:1 w:1)
|
||||
/// Proof: `Alliance::Announcements` (`max_values`: Some(1), `max_size`: Some(8702), added: 9197, mode: `MaxEncodedLen`)
|
||||
fn announce() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `54`
|
||||
// Estimated: `10187`
|
||||
// Minimum execution time: 7_541_000 picoseconds.
|
||||
Weight::from_parts(7_884_000, 10187)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Announcements` (r:1 w:1)
|
||||
/// Proof: `Alliance::Announcements` (`max_values`: Some(1), `max_size`: Some(8702), added: 9197, mode: `MaxEncodedLen`)
|
||||
fn remove_announcement() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `127`
|
||||
// Estimated: `10187`
|
||||
// Minimum execution time: 8_760_000 picoseconds.
|
||||
Weight::from_parts(9_201_000, 10187)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:0)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::DepositOf` (r:0 w:1)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
fn join_alliance() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `221`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 39_045_000 picoseconds.
|
||||
Weight::from_parts(40_425_000, 18048)
|
||||
.saturating_add(RocksDbWeight::get().reads(5_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:0)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
fn nominate_ally() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `170`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 23_593_000 picoseconds.
|
||||
Weight::from_parts(24_151_000, 18048)
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:2 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn elevate_ally() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `206`
|
||||
// Estimated: `12362`
|
||||
// Minimum execution time: 21_720_000 picoseconds.
|
||||
Weight::from_parts(22_214_000, 12362)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:4 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Alliance::RetiringMembers` (r:0 w:1)
|
||||
/// Proof: `Alliance::RetiringMembers` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
|
||||
fn give_retirement_notice() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `206`
|
||||
// Estimated: `23734`
|
||||
// Minimum execution time: 26_820_000 picoseconds.
|
||||
Weight::from_parts(27_614_000, 23734)
|
||||
.saturating_add(RocksDbWeight::get().reads(5_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(5_u64))
|
||||
}
|
||||
/// Storage: `Alliance::RetiringMembers` (r:1 w:1)
|
||||
/// Proof: `Alliance::RetiringMembers` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::Members` (r:1 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::DepositOf` (r:1 w:1)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
fn retire() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `458`
|
||||
// Estimated: `6676`
|
||||
// Minimum execution time: 36_070_000 picoseconds.
|
||||
Weight::from_parts(36_974_000, 6676)
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:1)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `Alliance::DepositOf` (r:1 w:1)
|
||||
/// Proof: `Alliance::DepositOf` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
|
||||
/// Storage: `System::Account` (r:1 w:1)
|
||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn kick_member() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `434`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 58_302_000 picoseconds.
|
||||
Weight::from_parts(59_775_000, 18048)
|
||||
.saturating_add(RocksDbWeight::get().reads(6_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(5_u64))
|
||||
}
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousWebsites` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousWebsites` (`max_values`: Some(1), `max_size`: Some(25702), added: 26197, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[0, 100]`.
|
||||
/// The range of component `l` is `[0, 255]`.
|
||||
fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `54`
|
||||
// Estimated: `27187`
|
||||
// Minimum execution time: 4_803_000 picoseconds.
|
||||
Weight::from_parts(4_858_000, 27187)
|
||||
// Standard Error: 3_655
|
||||
.saturating_add(Weight::from_parts(1_136_024, 0).saturating_mul(n.into()))
|
||||
// Standard Error: 1_431
|
||||
.saturating_add(Weight::from_parts(65_747, 0).saturating_mul(l.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Alliance::UnscrupulousAccounts` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousAccounts` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Alliance::UnscrupulousWebsites` (r:1 w:1)
|
||||
/// Proof: `Alliance::UnscrupulousWebsites` (`max_values`: Some(1), `max_size`: Some(25702), added: 26197, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[0, 100]`.
|
||||
/// The range of component `l` is `[0, 255]`.
|
||||
fn remove_unscrupulous_items(n: u32, _l: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0 + l * (100 ±0) + n * (289 ±0)`
|
||||
// Estimated: `27187`
|
||||
// Minimum execution time: 4_818_000 picoseconds.
|
||||
Weight::from_parts(4_893_000, 27187)
|
||||
// Standard Error: 184_675
|
||||
.saturating_add(Weight::from_parts(19_530_779, 0).saturating_mul(n.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Alliance::Members` (r:3 w:2)
|
||||
/// Proof: `Alliance::Members` (`max_values`: None, `max_size`: Some(3211), added: 5686, mode: `MaxEncodedLen`)
|
||||
/// Storage: `AllianceMotion::Proposals` (r:1 w:0)
|
||||
/// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Members` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `AllianceMotion::Prime` (r:0 w:1)
|
||||
/// Proof: `AllianceMotion::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||
fn abdicate_fellow_status() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `206`
|
||||
// Estimated: `18048`
|
||||
// Minimum execution time: 25_908_000 picoseconds.
|
||||
Weight::from_parts(26_640_000, 18048)
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user