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,169 @@
|
||||
// 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.
|
||||
|
||||
//! Dummy DIM pallet benchmarking.
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet as DummyDim;
|
||||
|
||||
use pezframe_benchmarking::v2::{benchmarks, *};
|
||||
use pezframe_support::{assert_ok, traits::Get};
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
type SecretOf<T> = <<T as Config>::People as AddOnlyPeopleTrait>::Secret;
|
||||
type MemberOf<T> = <<T as Config>::People as AddOnlyPeopleTrait>::Member;
|
||||
|
||||
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
|
||||
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
|
||||
}
|
||||
|
||||
fn new_member_from<T: Config>(id: PersonalId) -> (MemberOf<T>, SecretOf<T>) {
|
||||
T::People::mock_key(id)
|
||||
}
|
||||
|
||||
fn generate_members<T: Config>(start: u32, end: u32) -> Vec<(MemberOf<T>, SecretOf<T>)> {
|
||||
(start..end).map(|i| new_member_from::<T>(i as PersonalId)).collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn reserve_ids(c: Linear<1, { T::MaxPersonBatchSize::get() }>) -> Result<(), BenchmarkError> {
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, c);
|
||||
|
||||
assert_last_event::<T>(Event::IdsReserved { count: c }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn renew_id_reservation() -> Result<(), BenchmarkError> {
|
||||
assert_ok!(DummyDim::<T>::reserve_ids(RawOrigin::Root.into(), 1));
|
||||
assert_ok!(DummyDim::<T>::cancel_id_reservation(RawOrigin::Root.into(), 0));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, 0);
|
||||
|
||||
assert_last_event::<T>(Event::IdRenewed { id: 0 }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn cancel_id_reservation() -> Result<(), BenchmarkError> {
|
||||
assert_ok!(DummyDim::<T>::reserve_ids(RawOrigin::Root.into(), 1));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, 0);
|
||||
|
||||
assert_last_event::<T>(Event::IdUnreserved { id: 0 }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn recognize_personhood(
|
||||
c: Linear<1, { T::MaxPersonBatchSize::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
assert_ok!(DummyDim::<T>::reserve_ids(RawOrigin::Root.into(), c));
|
||||
let keys = generate_members::<T>(0, c);
|
||||
let keys_and_ids: Vec<_> =
|
||||
(0..c).map(|i| (i as PersonalId, keys[i as usize].0.clone())).collect();
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, keys_and_ids.try_into().unwrap());
|
||||
|
||||
assert_last_event::<T>(Event::PeopleRegistered { count: c }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn suspend_personhood(
|
||||
c: Linear<1, { T::MaxPersonBatchSize::get() }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
assert_ok!(DummyDim::<T>::reserve_ids(RawOrigin::Root.into(), c));
|
||||
let keys = generate_members::<T>(0, c);
|
||||
let keys_and_ids: Vec<_> =
|
||||
(0..c).map(|i| (i as PersonalId, keys[i as usize].0.clone())).collect();
|
||||
assert_ok!(DummyDim::<T>::recognize_personhood(
|
||||
RawOrigin::Root.into(),
|
||||
keys_and_ids.try_into().unwrap()
|
||||
));
|
||||
assert_ok!(T::People::start_people_set_mutation_session());
|
||||
let ids: Vec<_> = (0..c as PersonalId).collect();
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, ids.try_into().unwrap());
|
||||
|
||||
assert_last_event::<T>(Event::PeopleSuspended { count: c }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn resume_personhood() -> Result<(), BenchmarkError> {
|
||||
let people_count = T::MaxPersonBatchSize::get();
|
||||
assert_ok!(DummyDim::<T>::reserve_ids(RawOrigin::Root.into(), people_count));
|
||||
let keys = generate_members::<T>(0, people_count);
|
||||
let keys_and_ids: Vec<_> = (0..people_count)
|
||||
.map(|i| (i as PersonalId, keys[i as usize].0.clone()))
|
||||
.collect();
|
||||
assert_ok!(DummyDim::<T>::recognize_personhood(
|
||||
RawOrigin::Root.into(),
|
||||
keys_and_ids.try_into().unwrap()
|
||||
));
|
||||
assert_ok!(T::People::start_people_set_mutation_session());
|
||||
let ids: Vec<_> = (0..people_count as PersonalId).collect();
|
||||
assert_ok!(DummyDim::<T>::suspend_personhood(
|
||||
RawOrigin::Root.into(),
|
||||
ids.clone().try_into().unwrap()
|
||||
));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, 0);
|
||||
|
||||
assert_last_event::<T>(Event::PersonhoodResumed { id: 0 }.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn start_mutation_session() -> Result<(), BenchmarkError> {
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root);
|
||||
|
||||
assert_last_event::<T>(Event::SuspensionsStarted.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn end_mutation_session() -> Result<(), BenchmarkError> {
|
||||
assert_ok!(T::People::start_people_set_mutation_session());
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root);
|
||||
|
||||
assert_last_event::<T>(Event::SuspensionsEnded.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Implements a test for each benchmark. Execute with:
|
||||
// `cargo test -p pezpallet-dummy-dim --features runtime-benchmarks`.
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
// 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.
|
||||
|
||||
//! A simple interface to interact with a Proof-of-Personhood system.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![recursion_limit = "128"]
|
||||
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use pezframe_support::traits::reality::{AddOnlyPeopleTrait, PeopleTrait, PersonalId};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
pub mod weights;
|
||||
|
||||
pub use pallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
type MemberOf<T> = <<T as Config>::People as AddOnlyPeopleTrait>::Member;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use pezframe_support::{pezpallet_prelude::*, Twox64Concat};
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
/// The configuration of the pallet dummy DIM.
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
/// The runtime event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The origin which may command personhood updates through this pallet. Root can always do
|
||||
/// this.
|
||||
type UpdateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The maximum number of people supported in a single operation.
|
||||
type MaxPersonBatchSize: Get<u32>;
|
||||
|
||||
/// Who to tell when we recognise personhood.
|
||||
type People: PeopleTrait;
|
||||
}
|
||||
|
||||
/// The record of recognized people.
|
||||
#[derive(
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
RuntimeDebug,
|
||||
Encode,
|
||||
Decode,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
DecodeWithMemTracking,
|
||||
)]
|
||||
pub struct Record<Key> {
|
||||
/// The key of the person.
|
||||
pub key: Key,
|
||||
/// Flag describing the suspension status.
|
||||
pub suspended: bool,
|
||||
}
|
||||
|
||||
/// The personal IDs that are reserved by unproven people.
|
||||
#[pallet::storage]
|
||||
pub type ReservedIds<T: Config> = StorageMap<_, Blake2_128Concat, PersonalId, (), OptionQuery>;
|
||||
|
||||
/// The people we track along with their records.
|
||||
#[pallet::storage]
|
||||
pub type People<T: Config> =
|
||||
StorageMap<_, Twox64Concat, PersonalId, Record<MemberOf<T>>, OptionQuery>;
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A number of IDs was reserved.
|
||||
IdsReserved { count: u32 },
|
||||
/// An ID was renewed.
|
||||
IdRenewed { id: PersonalId },
|
||||
/// A reserved ID was removed.
|
||||
IdUnreserved { id: PersonalId },
|
||||
/// Register multiple people.
|
||||
PeopleRegistered { count: u32 },
|
||||
/// Suspend a number of people.
|
||||
PeopleSuspended { count: u32 },
|
||||
/// Someone's personhood was resumed.
|
||||
PersonhoodResumed { id: PersonalId },
|
||||
/// The pallet enabled suspensions.
|
||||
SuspensionsStarted,
|
||||
/// The pallet disabled suspensions.
|
||||
SuspensionsEnded,
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
/// The personal ID does not belong to a recognized person.
|
||||
NotPerson,
|
||||
/// The personal ID does not belong to a suspended person.
|
||||
NotSuspended,
|
||||
/// The personal ID is not reserved and awaiting recognition.
|
||||
NotReserved,
|
||||
/// The operation does not support this many people.
|
||||
TooManyPeople,
|
||||
}
|
||||
|
||||
#[pallet::call(weight = <T as Config>::WeightInfo)]
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Reserve a number of personal IDs.
|
||||
#[pallet::weight(T::WeightInfo::reserve_ids(T::MaxPersonBatchSize::get()))]
|
||||
#[pallet::call_index(0)]
|
||||
pub fn reserve_ids(origin: OriginFor<T>, count: u32) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
ensure!(count <= T::MaxPersonBatchSize::get(), Error::<T>::TooManyPeople);
|
||||
for _ in 0..count {
|
||||
let id = T::People::reserve_new_id();
|
||||
ReservedIds::<T>::insert(id, ());
|
||||
}
|
||||
Self::deposit_event(Event::IdsReserved { count });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// Renew a personal ID. The ID must not be in use.
|
||||
#[pallet::call_index(1)]
|
||||
pub fn renew_id_reservation(
|
||||
origin: OriginFor<T>,
|
||||
id: PersonalId,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
T::People::renew_id_reservation(id)?;
|
||||
ReservedIds::<T>::insert(id, ());
|
||||
|
||||
Self::deposit_event(Event::IdRenewed { id });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// Cancel a personal ID reservation.
|
||||
#[pallet::call_index(2)]
|
||||
pub fn cancel_id_reservation(
|
||||
origin: OriginFor<T>,
|
||||
id: PersonalId,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
T::People::cancel_id_reservation(id)?;
|
||||
ReservedIds::<T>::remove(id);
|
||||
|
||||
Self::deposit_event(Event::IdUnreserved { id });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// Grant personhood for a list of candidates that have reserved personal IDs.
|
||||
#[pallet::weight(T::WeightInfo::recognize_personhood(T::MaxPersonBatchSize::get()))]
|
||||
#[pallet::call_index(3)]
|
||||
pub fn recognize_personhood(
|
||||
origin: OriginFor<T>,
|
||||
ids_and_keys: BoundedVec<(PersonalId, MemberOf<T>), T::MaxPersonBatchSize>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
let count = ids_and_keys.len() as u32;
|
||||
for (id, key) in ids_and_keys.into_iter() {
|
||||
ReservedIds::<T>::take(id).ok_or(Error::<T>::NotReserved)?;
|
||||
People::<T>::insert(id, Record { key: key.clone(), suspended: false });
|
||||
T::People::recognize_personhood(id, Some(key))?;
|
||||
}
|
||||
|
||||
Self::deposit_event(Event::PeopleRegistered { count });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// Suspend the personhood of a list of recognized people. The people must not currently be
|
||||
/// suspended.
|
||||
#[pallet::weight(T::WeightInfo::suspend_personhood(T::MaxPersonBatchSize::get()))]
|
||||
#[pallet::call_index(4)]
|
||||
pub fn suspend_personhood(
|
||||
origin: OriginFor<T>,
|
||||
ids: BoundedVec<PersonalId, T::MaxPersonBatchSize>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
T::People::suspend_personhood(&ids[..])?;
|
||||
let count = ids.len() as u32;
|
||||
for id in ids.into_iter() {
|
||||
let mut record = People::<T>::get(id).ok_or(Error::<T>::NotPerson)?;
|
||||
record.suspended = true;
|
||||
People::<T>::insert(id, record);
|
||||
}
|
||||
|
||||
Self::deposit_event(Event::PeopleSuspended { count });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// Resume someone's personhood. The person must currently be suspended.
|
||||
#[pallet::call_index(5)]
|
||||
pub fn resume_personhood(
|
||||
origin: OriginFor<T>,
|
||||
id: PersonalId,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
let mut record = People::<T>::get(id).ok_or(Error::<T>::NotPerson)?;
|
||||
ensure!(record.suspended, Error::<T>::NotSuspended);
|
||||
T::People::recognize_personhood(id, None)?;
|
||||
record.suspended = false;
|
||||
People::<T>::insert(id, record);
|
||||
|
||||
Self::deposit_event(Event::PersonhoodResumed { id });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// Start a mutation session in the underlying `People` interface. This call does not check
|
||||
/// whether a mutation session is already ongoing and can start new sessions.
|
||||
#[pallet::call_index(6)]
|
||||
pub fn start_mutation_session(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
T::People::start_people_set_mutation_session()?;
|
||||
Self::deposit_event(Event::SuspensionsStarted);
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// End a mutation session in the underlying `People` interface. This call can end multiple
|
||||
/// mutation sessions, even ones not started by this pallet.
|
||||
///
|
||||
/// This call will fail if no mutation session is ongoing.
|
||||
#[pallet::call_index(7)]
|
||||
pub fn end_mutation_session(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
T::People::end_people_set_mutation_session()?;
|
||||
Self::deposit_event(Event::SuspensionsEnded);
|
||||
Ok(().into())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// 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 pezframe_support::derive_impl;
|
||||
use pezframe_system::{offchain::CreateTransactionBase, pezpallet_prelude::ExtrinsicFor, EnsureRoot};
|
||||
use pezsp_core::{ConstU16, ConstU32, ConstU64, H256};
|
||||
use pezsp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system,
|
||||
People: pezpallet_people,
|
||||
DummyDim: crate
|
||||
}
|
||||
);
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type BaseCallFilter = pezframe_support::traits::Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Nonce = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = ();
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ConstU16<42>;
|
||||
type OnSetCode = ();
|
||||
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
|
||||
}
|
||||
|
||||
impl pezpallet_people::Config for Test {
|
||||
type WeightInfo = ();
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Crypto = verifiable::demo_impls::Simple;
|
||||
type AccountContexts = ();
|
||||
type ChunkPageSize = ConstU32<8>;
|
||||
type MaxRingSize = ConstU32<255>;
|
||||
type OnboardingQueuePageSize = ConstU32<512>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = ();
|
||||
}
|
||||
|
||||
impl crate::Config for Test {
|
||||
type WeightInfo = ();
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type UpdateOrigin = EnsureRoot<Self::AccountId>;
|
||||
type MaxPersonBatchSize = ConstU32<1000>;
|
||||
type People = People;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn advance_to(b: u64) {
|
||||
while System::block_number() < b {
|
||||
System::set_block_number(System::block_number() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
impl CreateTransactionBase<pezpallet_people::Call<Self>> for Test {
|
||||
type Extrinsic = ExtrinsicFor<Test>;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
}
|
||||
|
||||
pub struct ConfigRecord;
|
||||
|
||||
pub fn new_config() -> ConfigRecord {
|
||||
ConfigRecord
|
||||
}
|
||||
|
||||
pub struct TestExt(ConfigRecord);
|
||||
#[allow(dead_code)]
|
||||
impl TestExt {
|
||||
pub fn new() -> Self {
|
||||
Self(new_config())
|
||||
}
|
||||
|
||||
pub fn execute_with<R>(self, f: impl Fn() -> R) -> R {
|
||||
new_test_ext().execute_with(f)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let c = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
pezsp_io::TestExternalities::from(c)
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// 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 std::collections::BTreeSet;
|
||||
|
||||
use crate::{mock::*, ReservedIds};
|
||||
use pezframe_support::{
|
||||
assert_ok,
|
||||
traits::reality::{AddOnlyPeopleTrait, PersonalId},
|
||||
};
|
||||
use verifiable::{demo_impls::Simple, GenerateVerifiable};
|
||||
|
||||
#[test]
|
||||
fn id_registration_works() {
|
||||
TestExt::new().execute_with(|| {
|
||||
assert_ok!(DummyDim::reserve_ids(RuntimeOrigin::root(), 100));
|
||||
let dummy_ids: BTreeSet<_> = ReservedIds::<Test>::iter_keys().collect();
|
||||
let people_ids: BTreeSet<_> =
|
||||
pezpallet_people::ReservedPersonalId::<Test>::iter_keys().collect();
|
||||
assert_eq!(dummy_ids, people_ids);
|
||||
let mut independent_ids = vec![];
|
||||
for _ in 0..100 {
|
||||
let id = People::reserve_new_id();
|
||||
independent_ids.push(id);
|
||||
}
|
||||
assert_ok!(DummyDim::reserve_ids(RuntimeOrigin::root(), 100));
|
||||
let dummy_ids: BTreeSet<_> = ReservedIds::<Test>::iter_keys().collect();
|
||||
let expected_ids: BTreeSet<_> = (0..100).chain(200..300).collect();
|
||||
assert_eq!(dummy_ids, expected_ids);
|
||||
|
||||
for id in 0..100 {
|
||||
assert_ok!(DummyDim::cancel_id_reservation(RuntimeOrigin::root(), id));
|
||||
}
|
||||
let dummy_ids: BTreeSet<_> = ReservedIds::<Test>::iter_keys().collect();
|
||||
let expected_ids: BTreeSet<_> = (200..300).collect();
|
||||
assert_eq!(dummy_ids, expected_ids);
|
||||
|
||||
for id in 100..150 {
|
||||
assert_ok!(People::cancel_id_reservation(id));
|
||||
}
|
||||
|
||||
for id in 50..150 {
|
||||
assert_ok!(DummyDim::renew_id_reservation(RuntimeOrigin::root(), id));
|
||||
}
|
||||
let dummy_ids: BTreeSet<_> = ReservedIds::<Test>::iter_keys().collect();
|
||||
let expected_ids: BTreeSet<_> = (50..150).chain(200..300).collect();
|
||||
assert_eq!(dummy_ids, expected_ids);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn personhood_recognition_and_suspension_works() {
|
||||
TestExt::new().execute_with(|| {
|
||||
assert_ok!(DummyDim::reserve_ids(RuntimeOrigin::root(), 200));
|
||||
let ids_and_keys: Vec<_> = (0..100)
|
||||
.map(|i| (i as PersonalId, Simple::member_from_secret(&[i; 32])))
|
||||
.collect();
|
||||
assert_ok!(DummyDim::recognize_personhood(
|
||||
RuntimeOrigin::root(),
|
||||
ids_and_keys.clone().try_into().unwrap()
|
||||
));
|
||||
for (id, key) in ids_and_keys {
|
||||
assert_eq!(key, crate::People::<Test>::get(id).unwrap().key);
|
||||
assert!(pezpallet_people::Keys::<Test>::contains_key(key));
|
||||
}
|
||||
|
||||
let new_ids_and_keys: Vec<_> = (100..150)
|
||||
.map(|i| (i as PersonalId, Simple::member_from_secret(&[i; 32])))
|
||||
.collect();
|
||||
assert_ok!(DummyDim::recognize_personhood(
|
||||
RuntimeOrigin::root(),
|
||||
new_ids_and_keys.clone().try_into().unwrap()
|
||||
));
|
||||
for (id, key) in new_ids_and_keys {
|
||||
assert_eq!(key, crate::People::<Test>::get(id).unwrap().key);
|
||||
assert!(pezpallet_people::Keys::<Test>::contains_key(key));
|
||||
}
|
||||
|
||||
assert_ok!(DummyDim::start_mutation_session(RuntimeOrigin::root()));
|
||||
|
||||
let suspended_ids: Vec<_> = (50..125).collect();
|
||||
assert_ok!(DummyDim::suspend_personhood(
|
||||
RuntimeOrigin::root(),
|
||||
suspended_ids.try_into().unwrap()
|
||||
));
|
||||
for id in (0..50).chain(125..150) {
|
||||
assert!(!crate::People::<Test>::get(id).unwrap().suspended);
|
||||
assert!(!pezpallet_people::People::<Test>::get(id).unwrap().position.suspended());
|
||||
}
|
||||
for id in 50..125 {
|
||||
assert!(crate::People::<Test>::get(id).unwrap().suspended);
|
||||
assert!(pezpallet_people::People::<Test>::get(id).unwrap().position.suspended());
|
||||
}
|
||||
|
||||
assert_ok!(DummyDim::end_mutation_session(RuntimeOrigin::root()));
|
||||
pezpallet_people::RingsState::<Test>::mutate(|s| *s = s.clone().end_key_migration().unwrap());
|
||||
assert_ok!(DummyDim::start_mutation_session(RuntimeOrigin::root()));
|
||||
|
||||
for id in 50..100 {
|
||||
assert_ok!(DummyDim::resume_personhood(RuntimeOrigin::root(), id));
|
||||
}
|
||||
|
||||
for id in (0..100).chain(125..150) {
|
||||
assert!(!crate::People::<Test>::get(id).unwrap().suspended);
|
||||
assert!(!pezpallet_people::People::<Test>::get(id).unwrap().position.suspended());
|
||||
}
|
||||
for id in 100..125 {
|
||||
assert!(crate::People::<Test>::get(id).unwrap().suspended);
|
||||
assert!(pezpallet_people::People::<Test>::get(id).unwrap().position.suspended());
|
||||
}
|
||||
|
||||
assert_ok!(DummyDim::end_mutation_session(RuntimeOrigin::root()));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// 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_ranked_collective
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-05-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// /Users/gav/Core/bizinikiwi/target/release/bizinikiwi
|
||||
// benchmark
|
||||
// pallet
|
||||
// --pallet
|
||||
// pezpallet-dummy-dim
|
||||
// --extrinsic=*
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --output=../../../frame/dummy-dim/src/weights.rs
|
||||
// --template=../../../.maintain/frame-weight-template.hbs
|
||||
// --header=../../../HEADER-APACHE2
|
||||
// --record-proof
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for pezpallet_dummy_dim.
|
||||
pub trait WeightInfo {
|
||||
fn reserve_ids(c: u32) -> Weight;
|
||||
fn renew_id_reservation() -> Weight;
|
||||
fn cancel_id_reservation() -> Weight;
|
||||
fn recognize_personhood(c: u32) -> Weight;
|
||||
fn suspend_personhood(c: u32) -> Weight;
|
||||
fn resume_personhood() -> Weight;
|
||||
fn start_mutation_session() -> Weight;
|
||||
fn end_mutation_session() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for pezpallet_dummy_dim using the Bizinikiwi node and recommended hardware.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
fn reserve_ids(_c: u32) -> Weight { Weight::zero() }
|
||||
fn renew_id_reservation() -> Weight { Weight::zero() }
|
||||
fn cancel_id_reservation() -> Weight { Weight::zero() }
|
||||
fn recognize_personhood(_c: u32) -> Weight { Weight::zero() }
|
||||
fn suspend_personhood(_c: u32) -> Weight { Weight::zero() }
|
||||
fn resume_personhood() -> Weight { Weight::zero() }
|
||||
fn start_mutation_session() -> Weight { Weight::zero() }
|
||||
fn end_mutation_session() -> Weight { Weight::zero() }
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
fn reserve_ids(_c: u32) -> Weight { Weight::zero() }
|
||||
fn renew_id_reservation() -> Weight { Weight::zero() }
|
||||
fn cancel_id_reservation() -> Weight { Weight::zero() }
|
||||
fn recognize_personhood(_c: u32) -> Weight { Weight::zero() }
|
||||
fn suspend_personhood(_c: u32) -> Weight { Weight::zero() }
|
||||
fn resume_personhood() -> Weight { Weight::zero() }
|
||||
fn start_mutation_session() -> Weight { Weight::zero() }
|
||||
fn end_mutation_session() -> Weight { Weight::zero() }
|
||||
}
|
||||
Reference in New Issue
Block a user