Refactoring Checkpoint: (WIP)
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
[package]
|
||||
name = "pezpallet-welati"
|
||||
version = "1.0.0"
|
||||
description = "PezkuwiChain Governance and State Administration Pallet"
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
repository.workspace = true
|
||||
documentation = "https://docs.rs/pezpallet-welati"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { workspace = true, default-features = false, features = [
|
||||
"derive",
|
||||
"max-encoded-len",
|
||||
] }
|
||||
scale-info = { default-features = false, features = [
|
||||
"derive",
|
||||
], workspace = true }
|
||||
serde = { version = "1.0", default-features = false, features = [
|
||||
"derive",
|
||||
], optional = true }
|
||||
|
||||
pezframe-benchmarking = { optional = true, workspace = true }
|
||||
pezframe-support = { default-features = false, workspace = true }
|
||||
pezframe-system = { default-features = false, workspace = true }
|
||||
log = { default-features = false, workspace = true }
|
||||
pezsp-core = { workspace = true, default-features = false, optional = true }
|
||||
pezsp-io = { workspace = true, default-features = false, optional = true }
|
||||
pezsp-runtime = { default-features = false, workspace = true }
|
||||
pezsp-std = { default-features = false, workspace = true }
|
||||
|
||||
# PezkuwiChain özel paletler
|
||||
pezpallet-identity-kyc = { workspace = true, default-features = false }
|
||||
pezpallet-referral = { workspace = true, default-features = false }
|
||||
pezpallet-tiki = { workspace = true, default-features = false }
|
||||
pezpallet-trust = { workspace = true, default-features = false }
|
||||
|
||||
# Bizinikiwi core paletler
|
||||
pezpallet-collective = { default-features = false, workspace = true }
|
||||
pezpallet-democracy = { default-features = false, workspace = true }
|
||||
pezpallet-elections-phragmen = { default-features = false, workspace = true }
|
||||
pezpallet-scheduler = { default-features = false, workspace = true }
|
||||
pezpallet-timestamp = { default-features = false, workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
pezpallet-balances = { workspace = true, default-features = false }
|
||||
pezpallet-identity = { workspace = true, default-features = false }
|
||||
pezpallet-nfts = { workspace = true, default-features = false }
|
||||
pezpallet-staking-score = { workspace = true, default-features = false }
|
||||
pezsp-core = { workspace = true, default-features = false }
|
||||
pezsp-io = { workspace = true, default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezframe-benchmarking?/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"log/std",
|
||||
"pezpallet-balances/std",
|
||||
"pezpallet-collective/std",
|
||||
"pezpallet-democracy/std",
|
||||
"pezpallet-elections-phragmen/std",
|
||||
"pezpallet-identity-kyc/std",
|
||||
"pezpallet-identity/std",
|
||||
"pezpallet-nfts/std",
|
||||
"pezpallet-referral/std",
|
||||
"pezpallet-scheduler/std",
|
||||
"pezpallet-staking-score/std",
|
||||
"pezpallet-tiki/std",
|
||||
"pezpallet-timestamp/std",
|
||||
"pezpallet-trust/std",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
"serde?/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-io/std",
|
||||
"pezsp-runtime/std",
|
||||
"pezsp-std/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-benchmarking/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-collective/runtime-benchmarks",
|
||||
"pezpallet-democracy/runtime-benchmarks",
|
||||
"pezpallet-elections-phragmen/runtime-benchmarks",
|
||||
"pezpallet-identity-kyc/runtime-benchmarks",
|
||||
"pezpallet-identity/runtime-benchmarks",
|
||||
"pezpallet-nfts/runtime-benchmarks",
|
||||
"pezpallet-referral/runtime-benchmarks",
|
||||
"pezpallet-scheduler/runtime-benchmarks",
|
||||
"pezpallet-staking-score/runtime-benchmarks",
|
||||
"pezpallet-tiki/runtime-benchmarks",
|
||||
"pezpallet-timestamp/runtime-benchmarks",
|
||||
"pezpallet-trust/runtime-benchmarks",
|
||||
"pezsp-core",
|
||||
"pezsp-io",
|
||||
"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-democracy/try-runtime",
|
||||
"pezpallet-elections-phragmen/try-runtime",
|
||||
"pezpallet-identity-kyc/try-runtime",
|
||||
"pezpallet-identity/try-runtime",
|
||||
"pezpallet-nfts/try-runtime",
|
||||
"pezpallet-referral/try-runtime",
|
||||
"pezpallet-scheduler/try-runtime",
|
||||
"pezpallet-staking-score/try-runtime",
|
||||
"pezpallet-tiki/try-runtime",
|
||||
"pezpallet-timestamp/try-runtime",
|
||||
"pezpallet-trust/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
]
|
||||
@@ -0,0 +1,305 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use crate::types::*;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
#[benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// ELECTION SYSTEM BENCHMARKS
|
||||
// ----------------------------------------------------------------
|
||||
#[benchmark]
|
||||
fn initiate_election() {
|
||||
// This benchmark doesn't need special preparation, just needs to be called with root
|
||||
|
||||
#[extrinsic_call]
|
||||
initiate_election(RawOrigin::Root, ElectionType::Parliamentary, None, None);
|
||||
|
||||
assert!(ActiveElections::<T>::get(0).is_some());
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn register_candidate() {
|
||||
// --- SETUP ---
|
||||
Pallet::<T>::initiate_election(
|
||||
RawOrigin::Root.into(),
|
||||
ElectionType::Parliamentary,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Simplified endorsers for benchmark - KYC bypass
|
||||
let endorsers: Vec<T::AccountId> = (0..T::ParliamentaryEndorsements::get())
|
||||
.map(|i| account("endorser", i, 0))
|
||||
.collect();
|
||||
|
||||
let new_candidate: T::AccountId = whitelisted_caller();
|
||||
|
||||
// KYC check is already bypassed in test environment
|
||||
|
||||
#[extrinsic_call]
|
||||
register_candidate(RawOrigin::Signed(new_candidate.clone()), 0, None, endorsers);
|
||||
|
||||
assert!(ElectionCandidates::<T>::get(0, &new_candidate).is_some());
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn cast_vote() {
|
||||
// --- SETUP ---
|
||||
// 1. Prepare election and candidates
|
||||
Pallet::<T>::initiate_election(
|
||||
RawOrigin::Root.into(),
|
||||
ElectionType::Parliamentary,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let candidate: T::AccountId = account("candidate", 1, 0);
|
||||
let voter: T::AccountId = whitelisted_caller();
|
||||
|
||||
// Simplified endorsers for benchmark
|
||||
let endorsers: Vec<T::AccountId> = (0..T::ParliamentaryEndorsements::get())
|
||||
.map(|i| account("endorser", i, 0))
|
||||
.collect();
|
||||
|
||||
// KYC check is already bypassed in test environment
|
||||
|
||||
Pallet::<T>::register_candidate(
|
||||
RawOrigin::Signed(candidate.clone()).into(),
|
||||
0,
|
||||
None,
|
||||
endorsers,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// 2. Advance to voting period
|
||||
let election = ActiveElections::<T>::get(0).unwrap();
|
||||
pezframe_system::Pallet::<T>::set_block_number(election.voting_start);
|
||||
|
||||
let candidates_to_vote_for = vec![candidate];
|
||||
|
||||
#[extrinsic_call]
|
||||
cast_vote(RawOrigin::Signed(voter.clone()), 0, candidates_to_vote_for, None);
|
||||
|
||||
assert!(ElectionVotes::<T>::get(0, &voter).is_some());
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn finalize_election() {
|
||||
// --- SETUP ---
|
||||
// 1. Prepare election, candidate and a vote
|
||||
Pallet::<T>::initiate_election(
|
||||
RawOrigin::Root.into(),
|
||||
ElectionType::Parliamentary,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let candidate: T::AccountId = account("candidate", 1, 0);
|
||||
let voter: T::AccountId = account("voter", 2, 0);
|
||||
|
||||
let endorsers: Vec<T::AccountId> = (0..T::ParliamentaryEndorsements::get())
|
||||
.map(|i| account("endorser", i, 0))
|
||||
.collect();
|
||||
|
||||
// KYC check is already bypassed in test environment
|
||||
|
||||
Pallet::<T>::register_candidate(
|
||||
RawOrigin::Signed(candidate.clone()).into(),
|
||||
0,
|
||||
None,
|
||||
endorsers,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let election = ActiveElections::<T>::get(0).unwrap();
|
||||
pezframe_system::Pallet::<T>::set_block_number(election.voting_start);
|
||||
Pallet::<T>::cast_vote(RawOrigin::Signed(voter.clone()).into(), 0, vec![candidate], None)
|
||||
.unwrap();
|
||||
|
||||
// 2. Advance to election end time
|
||||
pezframe_system::Pallet::<T>::set_block_number(election.end_block + 1u32.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
finalize_election(RawOrigin::Root, 0);
|
||||
|
||||
assert!(ElectionResults::<T>::get(0).is_some());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// APPOINTMENT SYSTEM BENCHMARKS
|
||||
// ----------------------------------------------------------------
|
||||
#[benchmark]
|
||||
fn nominate_official() {
|
||||
// --- SETUP ---
|
||||
let nominator: T::AccountId = whitelisted_caller();
|
||||
let nominee: T::AccountId = account("nominee", 2, 0);
|
||||
let justification = b"Test nomination".to_vec().try_into().unwrap();
|
||||
|
||||
// Set nominator as Serok to pass authorization check
|
||||
CurrentOfficials::<T>::insert(GovernmentPosition::Serok, nominator.clone());
|
||||
|
||||
// Ensure the role is not already filled (clean state for benchmark)
|
||||
// AppointedOfficials storage should be empty for Dadger role
|
||||
// This is important because we added RoleAlreadyFilled check in lib.rs
|
||||
|
||||
#[extrinsic_call]
|
||||
nominate_official(
|
||||
RawOrigin::Signed(nominator),
|
||||
nominee,
|
||||
OfficialRole::Dadger,
|
||||
justification,
|
||||
);
|
||||
|
||||
assert_eq!(NextAppointmentId::<T>::get(), 1);
|
||||
// Verify that the role is still not filled (nomination doesn't fill it, approval does)
|
||||
assert!(!AppointedOfficials::<T>::contains_key(&OfficialRole::Dadger));
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn approve_appointment() {
|
||||
// --- SETUP ---
|
||||
let approver: T::AccountId = whitelisted_caller();
|
||||
let nominator: T::AccountId = account("nominator", 2, 0);
|
||||
let nominee: T::AccountId = account("nominee", 3, 0);
|
||||
let justification = b"Test nomination".to_vec().try_into().unwrap();
|
||||
|
||||
// Set nominator as Serok to pass authorization check for nomination
|
||||
CurrentOfficials::<T>::insert(GovernmentPosition::Serok, nominator.clone());
|
||||
|
||||
// Use a different role (Dozger) to avoid conflicts with nominate_official benchmark
|
||||
Pallet::<T>::nominate_official(
|
||||
RawOrigin::Signed(nominator).into(),
|
||||
nominee.clone(),
|
||||
OfficialRole::Dozger,
|
||||
justification,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Set approver as Serok to pass authorization check for approval
|
||||
CurrentOfficials::<T>::insert(GovernmentPosition::Serok, approver.clone());
|
||||
|
||||
#[extrinsic_call]
|
||||
approve_appointment(RawOrigin::Signed(approver), 0);
|
||||
|
||||
// Verify appointment ID incremented
|
||||
assert_eq!(NextAppointmentId::<T>::get(), 1);
|
||||
// CRITICAL: Verify that the role was assigned in AppointedOfficials storage
|
||||
// This tests the new storage write we added in lib.rs approve_appointment()
|
||||
assert_eq!(AppointedOfficials::<T>::get(&OfficialRole::Dozger), Some(nominee));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// COLLECTIVE DECISION BENCHMARKS
|
||||
// ----------------------------------------------------------------
|
||||
#[benchmark]
|
||||
fn submit_proposal() {
|
||||
// --- SETUP ---
|
||||
let proposer: T::AccountId = whitelisted_caller();
|
||||
|
||||
// Simple member creation for benchmark
|
||||
let member: ParliamentMember<T> = ParliamentMember {
|
||||
account: proposer.clone(),
|
||||
elected_at: 0u32.into(),
|
||||
term_ends_at: 1000u32.into(),
|
||||
votes_participated: 0,
|
||||
total_votes_eligible: 0,
|
||||
participation_rate: 100,
|
||||
committees: Default::default(),
|
||||
};
|
||||
let members: BoundedVec<ParliamentMember<T>, T::ParliamentSize> =
|
||||
vec![member].try_into().unwrap();
|
||||
ParliamentMembers::<T>::put(members);
|
||||
|
||||
let title = b"Test Proposal".to_vec().try_into().unwrap();
|
||||
let description = b"Test proposal description".to_vec().try_into().unwrap();
|
||||
|
||||
#[extrinsic_call]
|
||||
submit_proposal(
|
||||
RawOrigin::Signed(proposer),
|
||||
title,
|
||||
description,
|
||||
CollectiveDecisionType::ParliamentSimpleMajority,
|
||||
ProposalPriority::Normal,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(ActiveProposals::<T>::get(0).is_some());
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn vote_on_proposal() {
|
||||
// --- SETUP ---
|
||||
let proposer: T::AccountId = account("proposer", 1, 0);
|
||||
let voter: T::AccountId = whitelisted_caller();
|
||||
|
||||
// Create two members (proposer and voter)
|
||||
let member1: ParliamentMember<T> = ParliamentMember {
|
||||
account: proposer.clone(),
|
||||
elected_at: 0u32.into(),
|
||||
term_ends_at: 1000u32.into(),
|
||||
votes_participated: 0,
|
||||
total_votes_eligible: 0,
|
||||
participation_rate: 100,
|
||||
committees: Default::default(),
|
||||
};
|
||||
let member2: ParliamentMember<T> = ParliamentMember {
|
||||
account: voter.clone(),
|
||||
elected_at: 0u32.into(),
|
||||
term_ends_at: 1000u32.into(),
|
||||
votes_participated: 0,
|
||||
total_votes_eligible: 0,
|
||||
participation_rate: 100,
|
||||
committees: Default::default(),
|
||||
};
|
||||
let members: BoundedVec<ParliamentMember<T>, T::ParliamentSize> =
|
||||
vec![member1, member2].try_into().unwrap();
|
||||
ParliamentMembers::<T>::put(members);
|
||||
|
||||
let title = b"Test Proposal".to_vec().try_into().unwrap();
|
||||
let description = b"Test proposal description".to_vec().try_into().unwrap();
|
||||
Pallet::<T>::submit_proposal(
|
||||
RawOrigin::Signed(proposer).into(),
|
||||
title,
|
||||
description,
|
||||
CollectiveDecisionType::ParliamentSimpleMajority,
|
||||
ProposalPriority::Normal,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let proposal = ActiveProposals::<T>::get(0).unwrap();
|
||||
pezframe_system::Pallet::<T>::set_block_number(proposal.voting_starts_at + 1u32.into());
|
||||
|
||||
let rationale = Some(b"Test vote rationale".to_vec().try_into().unwrap());
|
||||
|
||||
// Ensure voter hasn't voted yet (clean state for benchmark)
|
||||
// This tests our new ProposalAlreadyVoted check
|
||||
assert!(!CollectiveVotes::<T>::contains_key(0, &voter));
|
||||
|
||||
#[extrinsic_call]
|
||||
vote_on_proposal(RawOrigin::Signed(voter.clone()), 0, VoteChoice::Aye, rationale);
|
||||
|
||||
// Verify vote was recorded
|
||||
assert!(CollectiveVotes::<T>::get(0, &voter).is_some());
|
||||
// Verify the vote details are correct
|
||||
let vote = CollectiveVotes::<T>::get(0, &voter).unwrap();
|
||||
assert_eq!(vote.vote, VoteChoice::Aye);
|
||||
// This benchmark successfully tests:
|
||||
// 1. NotAuthorizedToVote check (voter is in ParliamentMembers)
|
||||
// 2. ProposalAlreadyVoted check (voter hasn't voted before)
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
Pallet,
|
||||
crate::mock::ExtBuilder::default().build(),
|
||||
crate::mock::Test
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,385 @@
|
||||
//! Storage migrations for pezpallet-welati (Governance)
|
||||
|
||||
use super::*;
|
||||
use pezframe_support::{
|
||||
traits::{Get, GetStorageVersion, OnRuntimeUpgrade, StorageVersion},
|
||||
weights::Weight,
|
||||
};
|
||||
use pezsp_std::marker::PhantomData;
|
||||
|
||||
/// Current storage version
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
|
||||
/// Migration from v0 to v1
|
||||
/// This migration handles the initial version setup for pezpallet-welati
|
||||
pub mod v1 {
|
||||
use super::*;
|
||||
|
||||
pub struct MigrateToV1<T>(PhantomData<T>);
|
||||
|
||||
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let current = Pallet::<T>::on_chain_storage_version();
|
||||
|
||||
log::info!(
|
||||
"🔄 Running migration for pezpallet-welati from {:?} to {:?}",
|
||||
current,
|
||||
STORAGE_VERSION
|
||||
);
|
||||
|
||||
if current == StorageVersion::new(0) {
|
||||
let migrated;
|
||||
let mut weight = Weight::zero();
|
||||
|
||||
// Example migration logic for governance storage
|
||||
// If storage format changes in the future, implement transformation here
|
||||
|
||||
// Count existing storage items for logging
|
||||
let officials_count = CurrentOfficials::<T>::iter().count() as u64;
|
||||
let ministers_count = CurrentMinisters::<T>::iter().count() as u64;
|
||||
let elections_count = ActiveElections::<T>::iter().count() as u64;
|
||||
let proposals_count = ActiveProposals::<T>::iter().count() as u64;
|
||||
|
||||
migrated = officials_count + ministers_count + elections_count + proposals_count;
|
||||
|
||||
// Update storage version
|
||||
STORAGE_VERSION.put::<Pallet<T>>();
|
||||
|
||||
log::info!("✅ Migrated {} entries in pezpallet-welati", migrated);
|
||||
log::info!(
|
||||
" Officials: {}, Ministers: {}, Elections: {}, Proposals: {}",
|
||||
officials_count,
|
||||
ministers_count,
|
||||
elections_count,
|
||||
proposals_count
|
||||
);
|
||||
|
||||
// Return weight used
|
||||
// Reads: all storage items + version read
|
||||
// Writes: version write
|
||||
weight = weight.saturating_add(T::DbWeight::get().reads_writes(migrated + 1, 1));
|
||||
|
||||
weight
|
||||
} else {
|
||||
log::info!(
|
||||
"👌 pezpallet-welati migration not needed, current version is {:?}",
|
||||
current
|
||||
);
|
||||
T::DbWeight::get().reads(1)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<pezsp_std::vec::Vec<u8>, pezsp_runtime::TryRuntimeError> {
|
||||
let current = Pallet::<T>::on_chain_storage_version();
|
||||
|
||||
log::info!("🔍 Pre-upgrade check for pezpallet-welati");
|
||||
log::info!(" Current version: {:?}", current);
|
||||
|
||||
// Encode current storage counts for verification
|
||||
let officials_count = CurrentOfficials::<T>::iter().count() as u32;
|
||||
let ministers_count = CurrentMinisters::<T>::iter().count() as u32;
|
||||
let parliament_count = ParliamentMembers::<T>::get().len() as u32;
|
||||
let diwan_count = DiwanMembers::<T>::get().len() as u32;
|
||||
let appointed_count = AppointedOfficials::<T>::iter().count() as u32;
|
||||
let elections_count = ActiveElections::<T>::iter().count() as u32;
|
||||
let candidates_count = ElectionCandidates::<T>::iter().count() as u32;
|
||||
let votes_count = ElectionVotes::<T>::iter().count() as u32;
|
||||
let results_count = ElectionResults::<T>::iter().count() as u32;
|
||||
let districts_count = ElectoralDistrictConfig::<T>::iter().count() as u32;
|
||||
let nominations_count = PendingNominations::<T>::iter().count() as u32;
|
||||
let appointments_count = AppointmentProcesses::<T>::iter().count() as u32;
|
||||
let proposals_count = ActiveProposals::<T>::iter().count() as u32;
|
||||
let collective_votes_count = CollectiveVotes::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(" CurrentOfficials entries: {}", officials_count);
|
||||
log::info!(" CurrentMinisters entries: {}", ministers_count);
|
||||
log::info!(" ParliamentMembers entries: {}", parliament_count);
|
||||
log::info!(" DiwanMembers entries: {}", diwan_count);
|
||||
log::info!(" AppointedOfficials entries: {}", appointed_count);
|
||||
log::info!(" ActiveElections entries: {}", elections_count);
|
||||
log::info!(" ElectionCandidates entries: {}", candidates_count);
|
||||
log::info!(" ElectionVotes entries: {}", votes_count);
|
||||
log::info!(" ElectionResults entries: {}", results_count);
|
||||
log::info!(" ElectoralDistrictConfig entries: {}", districts_count);
|
||||
log::info!(" PendingNominations entries: {}", nominations_count);
|
||||
log::info!(" AppointmentProcesses entries: {}", appointments_count);
|
||||
log::info!(" ActiveProposals entries: {}", proposals_count);
|
||||
log::info!(" CollectiveVotes entries: {}", collective_votes_count);
|
||||
|
||||
Ok((
|
||||
officials_count,
|
||||
ministers_count,
|
||||
parliament_count,
|
||||
diwan_count,
|
||||
appointed_count,
|
||||
elections_count,
|
||||
candidates_count,
|
||||
votes_count,
|
||||
results_count,
|
||||
districts_count,
|
||||
nominations_count,
|
||||
appointments_count,
|
||||
proposals_count,
|
||||
collective_votes_count,
|
||||
)
|
||||
.encode())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(state: pezsp_std::vec::Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
|
||||
use codec::Decode;
|
||||
|
||||
let (
|
||||
pre_officials_count,
|
||||
pre_ministers_count,
|
||||
pre_parliament_count,
|
||||
pre_diwan_count,
|
||||
pre_appointed_count,
|
||||
pre_elections_count,
|
||||
pre_candidates_count,
|
||||
pre_votes_count,
|
||||
pre_results_count,
|
||||
pre_districts_count,
|
||||
pre_nominations_count,
|
||||
pre_appointments_count,
|
||||
pre_proposals_count,
|
||||
pre_collective_votes_count,
|
||||
): (u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32) =
|
||||
Decode::decode(&mut &state[..])
|
||||
.map_err(|_| "Failed to decode pre-upgrade state")?;
|
||||
|
||||
log::info!("🔍 Post-upgrade check for pezpallet-welati");
|
||||
|
||||
// Verify storage version was updated
|
||||
let current_version = Pallet::<T>::on_chain_storage_version();
|
||||
assert_eq!(current_version, STORAGE_VERSION, "Storage version not updated correctly");
|
||||
log::info!("✅ Storage version updated to {:?}", current_version);
|
||||
|
||||
// Verify storage counts (should be same or more, never less)
|
||||
let post_officials_count = CurrentOfficials::<T>::iter().count() as u32;
|
||||
let post_ministers_count = CurrentMinisters::<T>::iter().count() as u32;
|
||||
let post_parliament_count = ParliamentMembers::<T>::get().len() as u32;
|
||||
let post_diwan_count = DiwanMembers::<T>::get().len() as u32;
|
||||
let post_appointed_count = AppointedOfficials::<T>::iter().count() as u32;
|
||||
let post_elections_count = ActiveElections::<T>::iter().count() as u32;
|
||||
let post_candidates_count = ElectionCandidates::<T>::iter().count() as u32;
|
||||
let post_votes_count = ElectionVotes::<T>::iter().count() as u32;
|
||||
let post_results_count = ElectionResults::<T>::iter().count() as u32;
|
||||
let post_districts_count = ElectoralDistrictConfig::<T>::iter().count() as u32;
|
||||
let post_nominations_count = PendingNominations::<T>::iter().count() as u32;
|
||||
let post_appointments_count = AppointmentProcesses::<T>::iter().count() as u32;
|
||||
let post_proposals_count = ActiveProposals::<T>::iter().count() as u32;
|
||||
let post_collective_votes_count = CollectiveVotes::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(
|
||||
" CurrentOfficials entries: {} -> {}",
|
||||
pre_officials_count,
|
||||
post_officials_count
|
||||
);
|
||||
log::info!(
|
||||
" CurrentMinisters entries: {} -> {}",
|
||||
pre_ministers_count,
|
||||
post_ministers_count
|
||||
);
|
||||
log::info!(
|
||||
" ParliamentMembers entries: {} -> {}",
|
||||
pre_parliament_count,
|
||||
post_parliament_count
|
||||
);
|
||||
log::info!(" DiwanMembers entries: {} -> {}", pre_diwan_count, post_diwan_count);
|
||||
log::info!(
|
||||
" AppointedOfficials entries: {} -> {}",
|
||||
pre_appointed_count,
|
||||
post_appointed_count
|
||||
);
|
||||
log::info!(
|
||||
" ActiveElections entries: {} -> {}",
|
||||
pre_elections_count,
|
||||
post_elections_count
|
||||
);
|
||||
log::info!(
|
||||
" ElectionCandidates entries: {} -> {}",
|
||||
pre_candidates_count,
|
||||
post_candidates_count
|
||||
);
|
||||
log::info!(" ElectionVotes entries: {} -> {}", pre_votes_count, post_votes_count);
|
||||
log::info!(
|
||||
" ElectionResults entries: {} -> {}",
|
||||
pre_results_count,
|
||||
post_results_count
|
||||
);
|
||||
log::info!(
|
||||
" ElectoralDistrictConfig entries: {} -> {}",
|
||||
pre_districts_count,
|
||||
post_districts_count
|
||||
);
|
||||
log::info!(
|
||||
" PendingNominations entries: {} -> {}",
|
||||
pre_nominations_count,
|
||||
post_nominations_count
|
||||
);
|
||||
log::info!(
|
||||
" AppointmentProcesses entries: {} -> {}",
|
||||
pre_appointments_count,
|
||||
post_appointments_count
|
||||
);
|
||||
log::info!(
|
||||
" ActiveProposals entries: {} -> {}",
|
||||
pre_proposals_count,
|
||||
post_proposals_count
|
||||
);
|
||||
log::info!(
|
||||
" CollectiveVotes entries: {} -> {}",
|
||||
pre_collective_votes_count,
|
||||
post_collective_votes_count
|
||||
);
|
||||
|
||||
// Verify no data was lost
|
||||
assert!(
|
||||
post_officials_count >= pre_officials_count,
|
||||
"CurrentOfficials entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_ministers_count >= pre_ministers_count,
|
||||
"CurrentMinisters entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_parliament_count >= pre_parliament_count,
|
||||
"ParliamentMembers entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_diwan_count >= pre_diwan_count,
|
||||
"DiwanMembers entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_appointed_count >= pre_appointed_count,
|
||||
"AppointedOfficials entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_elections_count >= pre_elections_count,
|
||||
"ActiveElections entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_candidates_count >= pre_candidates_count,
|
||||
"ElectionCandidates entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_votes_count >= pre_votes_count,
|
||||
"ElectionVotes entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_results_count >= pre_results_count,
|
||||
"ElectionResults entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_districts_count >= pre_districts_count,
|
||||
"ElectoralDistrictConfig entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_nominations_count >= pre_nominations_count,
|
||||
"PendingNominations entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_appointments_count >= pre_appointments_count,
|
||||
"AppointmentProcesses entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_proposals_count >= pre_proposals_count,
|
||||
"ActiveProposals entries decreased during migration"
|
||||
);
|
||||
assert!(
|
||||
post_collective_votes_count >= pre_collective_votes_count,
|
||||
"CollectiveVotes entries decreased during migration"
|
||||
);
|
||||
|
||||
log::info!("✅ Post-upgrade checks passed for pezpallet-welati");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Example migration for future version changes
|
||||
/// This demonstrates how to handle storage format changes in governance data
|
||||
pub mod v2 {
|
||||
use super::*;
|
||||
|
||||
/// Example: Migration when election or proposal format changes
|
||||
pub struct MigrateToV2<T>(PhantomData<T>);
|
||||
|
||||
impl<T: Config> OnRuntimeUpgrade for MigrateToV2<T> {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let current = Pallet::<T>::on_chain_storage_version();
|
||||
|
||||
if current < StorageVersion::new(2) {
|
||||
log::info!("🔄 Running migration for pezpallet-welati to v2");
|
||||
|
||||
// Example migration logic
|
||||
// 1. Transform election data if format changed
|
||||
// 2. Migrate proposal structure if needed
|
||||
// 3. Update parliament/diwan member format
|
||||
// 4. Update version
|
||||
|
||||
// For now, this is just a template
|
||||
StorageVersion::new(2).put::<Pallet<T>>();
|
||||
|
||||
log::info!("✅ Completed migration to pezpallet-welati v2");
|
||||
|
||||
T::DbWeight::get().reads_writes(1, 1)
|
||||
} else {
|
||||
log::info!("👌 pezpallet-welati v2 migration not needed");
|
||||
T::DbWeight::get().reads(1)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<pezsp_std::vec::Vec<u8>, pezsp_runtime::TryRuntimeError> {
|
||||
log::info!("🔍 Pre-upgrade check for pezpallet-welati v2");
|
||||
Ok(pezsp_std::vec::Vec::new())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(_state: pezsp_std::vec::Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
|
||||
log::info!("✅ Post-upgrade check passed for pezpallet-welati v2");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{ExtBuilder, Test};
|
||||
use pezframe_support::traits::OnRuntimeUpgrade;
|
||||
|
||||
#[test]
|
||||
fn test_migration_v1() {
|
||||
ExtBuilder::default().build().execute_with(|| {
|
||||
// Set initial storage version to 0
|
||||
StorageVersion::new(0).put::<Pallet<Test>>();
|
||||
|
||||
// Run migration
|
||||
let weight = v1::MigrateToV1::<Test>::on_runtime_upgrade();
|
||||
|
||||
// Verify version was updated
|
||||
assert_eq!(Pallet::<Test>::on_chain_storage_version(), STORAGE_VERSION);
|
||||
|
||||
// Verify weight is non-zero
|
||||
assert!(weight != Weight::zero());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_migration_idempotent() {
|
||||
ExtBuilder::default().build().execute_with(|| {
|
||||
// Set current version
|
||||
STORAGE_VERSION.put::<Pallet<Test>>();
|
||||
|
||||
// Run migration again
|
||||
let weight = v1::MigrateToV1::<Test>::on_runtime_upgrade();
|
||||
|
||||
// Should be a no-op
|
||||
assert_eq!(weight, pezframe_support::weights::constants::RocksDbWeight::get().reads(1));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,483 @@
|
||||
use crate::{self as pezpallet_welati, *};
|
||||
use pezframe_support::{
|
||||
assert_ok, construct_runtime, derive_impl, parameter_types,
|
||||
traits::{AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Everything, Randomness},
|
||||
BoundedVec,
|
||||
};
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
type AccountId = u64;
|
||||
type Balance = u128;
|
||||
|
||||
// Runtime with pezpallet-identity included for pezpallet-tiki dependency
|
||||
construct_runtime!(
|
||||
pub enum Test {
|
||||
System: pezframe_system,
|
||||
Balances: pezpallet_balances,
|
||||
Timestamp: pezpallet_timestamp,
|
||||
Nfts: pezpallet_nfts,
|
||||
Identity: pezpallet_identity,
|
||||
IdentityKyc: pezpallet_identity_kyc,
|
||||
Tiki: pezpallet_tiki,
|
||||
Trust: pezpallet_trust,
|
||||
StakingScore: pezpallet_staking_score,
|
||||
Referral: pezpallet_referral,
|
||||
Welati: pezpallet_welati,
|
||||
}
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub const SS58Prefix: u8 = 42;
|
||||
}
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig as pezframe_system::DefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type BaseCallFilter = Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = pezframe_support::weights::constants::RocksDbWeight;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Nonce = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = pezpallet_balances::AccountData<Balance>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = SS58Prefix;
|
||||
type OnSetCode = ();
|
||||
type MaxConsumers = ConstU32<16>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 1;
|
||||
pub const MaxLocks: u32 = 50;
|
||||
pub const MaxReserves: u32 = 50;
|
||||
}
|
||||
|
||||
impl pezpallet_balances::Config for Test {
|
||||
type MaxLocks = MaxLocks;
|
||||
type MaxReserves = MaxReserves;
|
||||
type ReserveIdentifier = [u8; 8];
|
||||
type Balance = Balance;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type DustRemoval = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = System;
|
||||
type WeightInfo = ();
|
||||
type FreezeIdentifier = ();
|
||||
type MaxFreezes = ConstU32<0>;
|
||||
type RuntimeHoldReason = ();
|
||||
type RuntimeFreezeReason = ();
|
||||
type DoneSlashHandler = ();
|
||||
}
|
||||
|
||||
impl pezpallet_timestamp::Config for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type MinimumPeriod = ConstU64<1>;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
// Mock Randomness - SADECE BİR KEZ TANIMLA
|
||||
pub struct MockRandomness;
|
||||
impl Randomness<H256, u64> for MockRandomness {
|
||||
fn random(_subject: &[u8]) -> (H256, u64) {
|
||||
(H256::default(), 0)
|
||||
}
|
||||
}
|
||||
|
||||
// NFTs Configuration
|
||||
parameter_types! {
|
||||
pub const CollectionDeposit: Balance = 0;
|
||||
pub const ItemDeposit: Balance = 0;
|
||||
pub const StringLimit: u32 = 64;
|
||||
pub const KeyLimit: u32 = 32;
|
||||
pub const ValueLimit: u32 = 64;
|
||||
pub const ApprovalsLimit: u32 = 1;
|
||||
pub const ItemAttributesApprovalsLimit: u32 = 1;
|
||||
pub const MaxTips: u32 = 1;
|
||||
pub const MaxDeadlineDuration: u64 = 1000;
|
||||
pub const MaxAttributesPerCall: u32 = 1;
|
||||
}
|
||||
|
||||
impl pezpallet_nfts::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type CollectionId = u32;
|
||||
type ItemId = u32;
|
||||
type Currency = Balances;
|
||||
type CreateOrigin = AsEnsureOriginWithArg<pezframe_system::EnsureSigned<AccountId>>;
|
||||
type ForceOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type Locker = ();
|
||||
type CollectionDeposit = CollectionDeposit;
|
||||
type ItemDeposit = ItemDeposit;
|
||||
type MetadataDepositBase = ConstU128<0>;
|
||||
type AttributeDepositBase = ConstU128<0>;
|
||||
type DepositPerByte = ConstU128<0>;
|
||||
type StringLimit = StringLimit;
|
||||
type KeyLimit = KeyLimit;
|
||||
type ValueLimit = ValueLimit;
|
||||
type ApprovalsLimit = ApprovalsLimit;
|
||||
type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit;
|
||||
type MaxTips = MaxTips;
|
||||
type MaxDeadlineDuration = MaxDeadlineDuration;
|
||||
type MaxAttributesPerCall = MaxAttributesPerCall;
|
||||
type Features = ();
|
||||
type OffchainSignature = pezsp_runtime::testing::TestSignature;
|
||||
type OffchainPublic = pezsp_runtime::testing::UintAuthorityId;
|
||||
type WeightInfo = ();
|
||||
type BlockNumberProvider = System;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type Helper = ();
|
||||
}
|
||||
|
||||
// Identity Configuration - MINIMAL for pezpallet-tiki dependency
|
||||
parameter_types! {
|
||||
pub const BasicDeposit: Balance = 10;
|
||||
pub const ByteDeposit: Balance = 1;
|
||||
pub const SubAccountDeposit: Balance = 10;
|
||||
pub const MaxSubAccounts: u32 = 2;
|
||||
pub const MaxRegistrars: u32 = 2;
|
||||
pub const MaxAdditionalFields: u32 = 2;
|
||||
pub const UsernameDeposit: Balance = 100;
|
||||
pub const MaxUsernameLength: u32 = 32;
|
||||
pub const MaxSuffixLength: u32 = 7;
|
||||
pub const PendingUsernameExpiration: u64 = 100;
|
||||
pub const UsernameGracePeriod: u64 = 100;
|
||||
}
|
||||
|
||||
impl pezpallet_identity::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type Slashed = ();
|
||||
type ForceOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type RegistrarOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type WeightInfo = ();
|
||||
type BasicDeposit = BasicDeposit;
|
||||
type SubAccountDeposit = SubAccountDeposit;
|
||||
type MaxSubAccounts = MaxSubAccounts;
|
||||
type MaxRegistrars = MaxRegistrars;
|
||||
type IdentityInformation = pezpallet_identity::legacy::IdentityInfo<MaxAdditionalFields>;
|
||||
type ByteDeposit = ByteDeposit;
|
||||
type UsernameDeposit = UsernameDeposit;
|
||||
type MaxUsernameLength = MaxUsernameLength;
|
||||
type MaxSuffixLength = MaxSuffixLength;
|
||||
type PendingUsernameExpiration = PendingUsernameExpiration;
|
||||
type UsernameGracePeriod = UsernameGracePeriod;
|
||||
type UsernameAuthorityOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type OffchainSignature = pezsp_runtime::testing::TestSignature;
|
||||
type SigningPublicKey = pezsp_runtime::testing::UintAuthorityId;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = ();
|
||||
}
|
||||
|
||||
// Identity KYC Configuration
|
||||
parameter_types! {
|
||||
pub const KycApplicationDeposit: Balance = 1_000;
|
||||
pub const MaxStringLength: u32 = 128;
|
||||
pub const MaxCidLength: u32 = 64;
|
||||
}
|
||||
|
||||
pub struct NoOpOnKycApproved;
|
||||
impl pezpallet_identity_kyc::types::OnKycApproved<AccountId> for NoOpOnKycApproved {
|
||||
fn on_kyc_approved(_who: &AccountId, _referrer: &AccountId) {}
|
||||
}
|
||||
|
||||
pub struct NoOpOnCitizenshipRevoked;
|
||||
impl pezpallet_identity_kyc::types::OnCitizenshipRevoked<AccountId> for NoOpOnCitizenshipRevoked {
|
||||
fn on_citizenship_revoked(_who: &AccountId) {}
|
||||
}
|
||||
|
||||
pub struct NoOpCitizenNftProvider;
|
||||
impl pezpallet_identity_kyc::types::CitizenNftProvider<AccountId> for NoOpCitizenNftProvider {
|
||||
fn mint_citizen_nft(_who: &AccountId) -> Result<(), pezsp_runtime::DispatchError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mint_citizen_nft_confirmed(_who: &AccountId) -> Result<(), pezsp_runtime::DispatchError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn burn_citizen_nft(_who: &AccountId) -> Result<(), pezsp_runtime::DispatchError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl pezpallet_identity_kyc::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type GovernanceOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type WeightInfo = ();
|
||||
type OnKycApproved = NoOpOnKycApproved;
|
||||
type OnCitizenshipRevoked = NoOpOnCitizenshipRevoked;
|
||||
type CitizenNftProvider = NoOpCitizenNftProvider;
|
||||
type KycApplicationDeposit = KycApplicationDeposit;
|
||||
type MaxStringLength = MaxStringLength;
|
||||
type MaxCidLength = MaxCidLength;
|
||||
}
|
||||
|
||||
// Mock StakingInfo provider - SADECE BİR KEZ TANIMLA
|
||||
pub struct MockStakingInfo;
|
||||
impl pezpallet_staking_score::StakingInfoProvider<AccountId, Balance> for MockStakingInfo {
|
||||
fn get_staking_details(
|
||||
_account: &AccountId,
|
||||
) -> Option<pezpallet_staking_score::StakingDetails<Balance>> {
|
||||
Some(pezpallet_staking_score::StakingDetails {
|
||||
staked_amount: 1000u128,
|
||||
nominations_count: 0,
|
||||
unlocking_chunks_count: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Staking Score Configuration
|
||||
impl pezpallet_staking_score::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Balance = Balance;
|
||||
type StakingInfo = MockStakingInfo;
|
||||
}
|
||||
|
||||
// Referral Configuration
|
||||
parameter_types! {
|
||||
pub const DefaultReferrerAccount: AccountId = 1;
|
||||
pub const PenaltyPerRevocation: u32 = 10;
|
||||
}
|
||||
|
||||
impl pezpallet_referral::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type DefaultReferrer = DefaultReferrerAccount;
|
||||
type PenaltyPerRevocation = PenaltyPerRevocation;
|
||||
}
|
||||
|
||||
// Tiki Configuration
|
||||
parameter_types! {
|
||||
pub const MaxTikisPerUser: u32 = 50;
|
||||
pub const TikiCollectionId: u32 = 0;
|
||||
}
|
||||
|
||||
impl pezpallet_tiki::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type AdminOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type WeightInfo = ();
|
||||
type MaxTikisPerUser = MaxTikisPerUser;
|
||||
type Tiki = pezpallet_tiki::Tiki;
|
||||
type TikiCollectionId = TikiCollectionId;
|
||||
}
|
||||
|
||||
// Mock implementations for required traits - YÜKSEK SKORLAR VER
|
||||
pub struct MockStakingScoreProvider;
|
||||
impl pezpallet_staking_score::StakingScoreProvider<AccountId, u64> for MockStakingScoreProvider {
|
||||
fn get_staking_score(_account: &AccountId) -> (u32, u64) {
|
||||
(1000, 0) // Yüksek skor
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MockReferralScoreProvider;
|
||||
impl pezpallet_trust::ReferralScoreProvider<AccountId> for MockReferralScoreProvider {
|
||||
fn get_referral_score(_account: &AccountId) -> u32 {
|
||||
500 // Yüksek skor
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MockPerwerdeScoreProvider;
|
||||
impl pezpallet_trust::PerwerdeScoreProvider<AccountId> for MockPerwerdeScoreProvider {
|
||||
fn get_perwerde_score(_account: &AccountId) -> u32 {
|
||||
750 // Yüksek skor
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MockTikiScoreProvider;
|
||||
|
||||
// `pezpallet_trust` için implementasyon
|
||||
impl pezpallet_trust::TikiScoreProvider<AccountId> for MockTikiScoreProvider {
|
||||
fn get_tiki_score(_account: &AccountId) -> u32 {
|
||||
100
|
||||
}
|
||||
}
|
||||
|
||||
// `pezpallet_welati`'nin ihtiyaç duyduğu `pezpallet_tiki` için implementasyon
|
||||
impl pezpallet_tiki::TikiScoreProvider<AccountId> for MockTikiScoreProvider {
|
||||
fn get_tiki_score(_account: &AccountId) -> u32 {
|
||||
1000 // Yüksek Tiki score - tüm kontrolleri geçer
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MockCitizenshipStatusProvider;
|
||||
impl pezpallet_trust::CitizenshipStatusProvider<AccountId> for MockCitizenshipStatusProvider {
|
||||
fn is_citizen(_account: &AccountId) -> bool {
|
||||
true // Herkes vatandaş
|
||||
}
|
||||
}
|
||||
|
||||
// MOCK TRUST PROVIDER - HERKES İÇİN YÜKSEK SKOR
|
||||
pub struct MockTrustProvider;
|
||||
impl pezpallet_trust::TrustScoreProvider<AccountId> for MockTrustProvider {
|
||||
fn trust_score_of(_account: &AccountId) -> u128 {
|
||||
1000u128 // Herkes için yüksek trust score
|
||||
}
|
||||
}
|
||||
|
||||
// CitizenInfo trait implementation for MockTrustProvider
|
||||
impl CitizenInfo for MockTrustProvider {
|
||||
fn citizen_count() -> u32 {
|
||||
110
|
||||
}
|
||||
}
|
||||
|
||||
// Trust Configuration
|
||||
parameter_types! {
|
||||
pub const ScoreMultiplierBase: u128 = 100;
|
||||
pub const UpdateInterval: u64 = 1000;
|
||||
pub const MaxBatchSize: u32 = 100;
|
||||
}
|
||||
|
||||
impl pezpallet_trust::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Score = u128;
|
||||
type ScoreMultiplierBase = ScoreMultiplierBase;
|
||||
type UpdateInterval = UpdateInterval;
|
||||
type MaxBatchSize = MaxBatchSize;
|
||||
type StakingScoreSource = MockStakingScoreProvider;
|
||||
type ReferralScoreSource = MockReferralScoreProvider;
|
||||
type PerwerdeScoreSource = MockPerwerdeScoreProvider;
|
||||
type TikiScoreSource = MockTikiScoreProvider;
|
||||
type CitizenshipSource = MockCitizenshipStatusProvider;
|
||||
}
|
||||
|
||||
// Welati Configuration - SADECE BİR KEZ TANIMLA
|
||||
parameter_types! {
|
||||
pub const ParliamentSize: u32 = 201;
|
||||
pub const DiwanSize: u32 = 11;
|
||||
pub const ElectionPeriod: u64 = 432_000;
|
||||
pub const CandidacyPeriod: u64 = 86_400;
|
||||
pub const CampaignPeriod: u64 = 259_200;
|
||||
pub const ElectoralDistricts: u32 = 10;
|
||||
pub const CandidacyDeposit: u128 = 10_000;
|
||||
pub const PresidentialEndorsements: u32 = 100;
|
||||
pub const ParliamentaryEndorsements: u32 = 50;
|
||||
}
|
||||
|
||||
impl pezpallet_welati::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Randomness = MockRandomness;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type TrustScoreSource = MockTrustProvider; // Mock provider kullan
|
||||
type TikiSource = MockTikiScoreProvider; // Mock Tiki provider kullan
|
||||
type CitizenSource = MockTrustProvider; // Mock provider kullan
|
||||
type KycSource = IdentityKyc;
|
||||
type ParliamentSize = ParliamentSize;
|
||||
type DiwanSize = DiwanSize;
|
||||
type ElectionPeriod = ElectionPeriod;
|
||||
type CandidacyPeriod = CandidacyPeriod;
|
||||
type CampaignPeriod = CampaignPeriod;
|
||||
type ElectoralDistricts = ElectoralDistricts;
|
||||
type CandidacyDeposit = CandidacyDeposit;
|
||||
type PresidentialEndorsements = PresidentialEndorsements;
|
||||
type ParliamentaryEndorsements = ParliamentaryEndorsements;
|
||||
}
|
||||
|
||||
// CRITICAL: CitizenInfo trait implementation - SADECE BİR KEZ TANIMLA
|
||||
impl CitizenInfo for Trust {
|
||||
fn citizen_count() -> u32 {
|
||||
110
|
||||
}
|
||||
}
|
||||
|
||||
// Test externalities builder
|
||||
pub struct ExtBuilder {
|
||||
balances: Vec<(AccountId, Balance)>,
|
||||
}
|
||||
|
||||
impl Default for ExtBuilder {
|
||||
fn default() -> Self {
|
||||
Self { balances: (1..=110).map(|i| (i as AccountId, 100_000_000_000_000)).collect() }
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtBuilder {
|
||||
pub fn build(self) -> pezsp_io::TestExternalities {
|
||||
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
|
||||
pezpallet_balances::GenesisConfig::<Test> { balances: self.balances, dev_accounts: None }
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
let mut ext = pezsp_io::TestExternalities::new(t);
|
||||
ext.execute_with(|| {
|
||||
System::set_block_number(1);
|
||||
|
||||
assert_ok!(Nfts::create(RuntimeOrigin::signed(1), 1, Default::default()));
|
||||
|
||||
setup_test_users();
|
||||
});
|
||||
ext
|
||||
}
|
||||
}
|
||||
|
||||
// SIMPLIFIED TEST USER SETUP - BOŞ BIRAK, MOCK PROVIDERS YETERLI
|
||||
pub fn setup_test_users() {
|
||||
// Mock provider'lar zaten herkesin yüksek trust score'u olmasını sağlıyor
|
||||
// ve TikiScoreProvider da herkesin Tiki'ye sahip olduğunu söylüyor
|
||||
// Bu sayede pezpallet-tiki ile uğraşmak zorunda kalmıyoruz
|
||||
|
||||
// Sadece NFTs collection'ı oluşturuldu, bu yeterli
|
||||
// Testlerde KYC kontrolü zaten bypass ediliyor
|
||||
}
|
||||
|
||||
// CRITICAL HELPER FUNCTION FOR TESTS
|
||||
pub fn add_parliament_member(account: AccountId) {
|
||||
let member = ParliamentMember {
|
||||
account,
|
||||
elected_at: System::block_number(),
|
||||
term_ends_at: System::block_number() + 100_000,
|
||||
votes_participated: 0,
|
||||
total_votes_eligible: 0,
|
||||
participation_rate: 100,
|
||||
committees: BoundedVec::default(),
|
||||
};
|
||||
|
||||
let mut members = ParliamentMembers::<Test>::get();
|
||||
if members.try_push(member).is_ok() {
|
||||
ParliamentMembers::<Test>::put(members);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_to_block(n: u64) {
|
||||
while System::block_number() < n {
|
||||
if System::block_number() > 0 {
|
||||
System::on_finalize(System::block_number());
|
||||
Welati::on_finalize(System::block_number());
|
||||
}
|
||||
System::set_block_number(System::block_number() + 1);
|
||||
Welati::on_initialize(System::block_number());
|
||||
System::on_initialize(System::block_number());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn last_event() -> RuntimeEvent {
|
||||
System::events().pop().expect("Event expected").event
|
||||
}
|
||||
|
||||
pub fn events() -> Vec<RuntimeEvent> {
|
||||
let evt = System::events().into_iter().map(|evt| evt.event).collect::<Vec<_>>();
|
||||
System::reset_events();
|
||||
evt
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,335 @@
|
||||
// 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_welati`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2025-12-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `MamostePC`, CPU: `11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// ./target/release/frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// --runtime
|
||||
// target/release/wbuild/people-pezkuwichain-runtime/people_pezkuwichain_runtime.compact.compressed.wasm
|
||||
// --pallets
|
||||
// pezpallet_welati
|
||||
// -e
|
||||
// all
|
||||
// --steps
|
||||
// 50
|
||||
// --repeat
|
||||
// 20
|
||||
// --output
|
||||
// pezcumulus/teyrchains/pezpallets/welati/src/weights.rs
|
||||
// --template
|
||||
// bizinikiwi/.maintain/frame-weight-template.hbs
|
||||
|
||||
#![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_welati`.
|
||||
pub trait WeightInfo {
|
||||
fn initiate_election() -> Weight;
|
||||
fn register_candidate() -> Weight;
|
||||
fn cast_vote() -> Weight;
|
||||
fn finalize_election() -> Weight;
|
||||
fn nominate_official() -> Weight;
|
||||
fn approve_appointment() -> Weight;
|
||||
fn submit_proposal() -> Weight;
|
||||
fn vote_on_proposal() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pezpallet_welati` using the Bizinikiwi node and recommended hardware.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
/// Storage: `Welati::NextElectionId` (r:1 w:1)
|
||||
/// Proof: `Welati::NextElectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ActiveElections` (r:0 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
fn initiate_election() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `42`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 21_177_000 picoseconds.
|
||||
Weight::from_parts(22_712_000, 1489)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveElections` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionCandidates` (r:1 w:1)
|
||||
/// Proof: `Welati::ElectionCandidates` (`max_values`: None, `max_size`: Some(3833), added: 6308, mode: `MaxEncodedLen`)
|
||||
fn register_candidate() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `145`
|
||||
// Estimated: `32819`
|
||||
// Minimum execution time: 32_272_000 picoseconds.
|
||||
Weight::from_parts(39_628_000, 32819)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveElections` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionVotes` (r:1 w:1)
|
||||
/// Proof: `Welati::ElectionVotes` (`max_values`: None, `max_size`: Some(435), added: 2910, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionCandidates` (r:1 w:1)
|
||||
/// Proof: `Welati::ElectionCandidates` (`max_values`: None, `max_size`: Some(3833), added: 6308, mode: `MaxEncodedLen`)
|
||||
fn cast_vote() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `3532`
|
||||
// Estimated: `32819`
|
||||
// Minimum execution time: 27_874_000 picoseconds.
|
||||
Weight::from_parts(29_000_000, 32819)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveElections` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionCandidates` (r:1 w:0)
|
||||
/// Proof: `Welati::ElectionCandidates` (`max_values`: None, `max_size`: Some(3833), added: 6308, mode: `MaxEncodedLen`)
|
||||
/// Storage: `IdentityKyc::KycStatuses` (r:2 w:0)
|
||||
/// Proof: `IdentityKyc::KycStatuses` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionResults` (r:0 w:1)
|
||||
/// Proof: `Welati::ElectionResults` (`max_values`: None, `max_size`: Some(6467), added: 8942, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ParliamentMembers` (r:0 w:1)
|
||||
/// Proof: `Welati::ParliamentMembers` (`max_values`: Some(1), `max_size`: Some(11057), added: 11552, mode: `MaxEncodedLen`)
|
||||
fn finalize_election() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `3682`
|
||||
// Estimated: `32819`
|
||||
// Minimum execution time: 35_614_000 picoseconds.
|
||||
Weight::from_parts(38_634_000, 32819)
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::CurrentOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::CurrentMinisters` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentMinisters` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointedOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::AppointedOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::PendingNominations` (r:1 w:1)
|
||||
/// Proof: `Welati::PendingNominations` (`max_values`: None, `max_size`: Some(173), added: 2648, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::NextAppointmentId` (r:1 w:1)
|
||||
/// Proof: `Welati::NextAppointmentId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointmentProcesses` (r:0 w:1)
|
||||
/// Proof: `Welati::AppointmentProcesses` (`max_values`: None, `max_size`: Some(10119), added: 12594, mode: `MaxEncodedLen`)
|
||||
fn nominate_official() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `121`
|
||||
// Estimated: `3638`
|
||||
// Minimum execution time: 25_456_000 picoseconds.
|
||||
Weight::from_parts(26_826_000, 3638)
|
||||
.saturating_add(T::DbWeight::get().reads(5_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::CurrentOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointmentProcesses` (r:1 w:1)
|
||||
/// Proof: `Welati::AppointmentProcesses` (`max_values`: None, `max_size`: Some(10119), added: 12594, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::PendingNominations` (r:1 w:1)
|
||||
/// Proof: `Welati::PendingNominations` (`max_values`: None, `max_size`: Some(173), added: 2648, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointedOfficials` (r:0 w:1)
|
||||
/// Proof: `Welati::AppointedOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
fn approve_appointment() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `444`
|
||||
// Estimated: `13584`
|
||||
// Minimum execution time: 28_797_000 picoseconds.
|
||||
Weight::from_parts(30_151_000, 13584)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::ParliamentMembers` (r:1 w:0)
|
||||
/// Proof: `Welati::ParliamentMembers` (`max_values`: Some(1), `max_size`: Some(11057), added: 11552, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::CurrentOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::NextProposalId` (r:1 w:1)
|
||||
/// Proof: `Welati::NextProposalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ActiveProposals` (r:0 w:1)
|
||||
/// Proof: `Welati::ActiveProposals` (`max_values`: None, `max_size`: Some(1195), added: 3670, mode: `MaxEncodedLen`)
|
||||
fn submit_proposal() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `119`
|
||||
// Estimated: `12542`
|
||||
// Minimum execution time: 16_335_000 picoseconds.
|
||||
Weight::from_parts(17_233_000, 12542)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveProposals` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveProposals` (`max_values`: None, `max_size`: Some(1195), added: 3670, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::CollectiveVotes` (r:1 w:1)
|
||||
/// Proof: `Welati::CollectiveVotes` (`max_values`: None, `max_size`: Some(612), added: 3087, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ParliamentMembers` (r:1 w:0)
|
||||
/// Proof: `Welati::ParliamentMembers` (`max_values`: Some(1), `max_size`: Some(11057), added: 11552, mode: `MaxEncodedLen`)
|
||||
fn vote_on_proposal() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `349`
|
||||
// Estimated: `12542`
|
||||
// Minimum execution time: 20_789_000 picoseconds.
|
||||
Weight::from_parts(21_455_000, 12542)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `Welati::NextElectionId` (r:1 w:1)
|
||||
/// Proof: `Welati::NextElectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ActiveElections` (r:0 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
fn initiate_election() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `42`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 21_177_000 picoseconds.
|
||||
Weight::from_parts(22_712_000, 1489)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveElections` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionCandidates` (r:1 w:1)
|
||||
/// Proof: `Welati::ElectionCandidates` (`max_values`: None, `max_size`: Some(3833), added: 6308, mode: `MaxEncodedLen`)
|
||||
fn register_candidate() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `145`
|
||||
// Estimated: `32819`
|
||||
// Minimum execution time: 32_272_000 picoseconds.
|
||||
Weight::from_parts(39_628_000, 32819)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveElections` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionVotes` (r:1 w:1)
|
||||
/// Proof: `Welati::ElectionVotes` (`max_values`: None, `max_size`: Some(435), added: 2910, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionCandidates` (r:1 w:1)
|
||||
/// Proof: `Welati::ElectionCandidates` (`max_values`: None, `max_size`: Some(3833), added: 6308, mode: `MaxEncodedLen`)
|
||||
fn cast_vote() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `3532`
|
||||
// Estimated: `32819`
|
||||
// Minimum execution time: 27_874_000 picoseconds.
|
||||
Weight::from_parts(29_000_000, 32819)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveElections` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveElections` (`max_values`: None, `max_size`: Some(29354), added: 31829, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionCandidates` (r:1 w:0)
|
||||
/// Proof: `Welati::ElectionCandidates` (`max_values`: None, `max_size`: Some(3833), added: 6308, mode: `MaxEncodedLen`)
|
||||
/// Storage: `IdentityKyc::KycStatuses` (r:2 w:0)
|
||||
/// Proof: `IdentityKyc::KycStatuses` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ElectionResults` (r:0 w:1)
|
||||
/// Proof: `Welati::ElectionResults` (`max_values`: None, `max_size`: Some(6467), added: 8942, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ParliamentMembers` (r:0 w:1)
|
||||
/// Proof: `Welati::ParliamentMembers` (`max_values`: Some(1), `max_size`: Some(11057), added: 11552, mode: `MaxEncodedLen`)
|
||||
fn finalize_election() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `3682`
|
||||
// Estimated: `32819`
|
||||
// Minimum execution time: 35_614_000 picoseconds.
|
||||
Weight::from_parts(38_634_000, 32819)
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::CurrentOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::CurrentMinisters` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentMinisters` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointedOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::AppointedOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::PendingNominations` (r:1 w:1)
|
||||
/// Proof: `Welati::PendingNominations` (`max_values`: None, `max_size`: Some(173), added: 2648, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::NextAppointmentId` (r:1 w:1)
|
||||
/// Proof: `Welati::NextAppointmentId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointmentProcesses` (r:0 w:1)
|
||||
/// Proof: `Welati::AppointmentProcesses` (`max_values`: None, `max_size`: Some(10119), added: 12594, mode: `MaxEncodedLen`)
|
||||
fn nominate_official() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `121`
|
||||
// Estimated: `3638`
|
||||
// Minimum execution time: 25_456_000 picoseconds.
|
||||
Weight::from_parts(26_826_000, 3638)
|
||||
.saturating_add(RocksDbWeight::get().reads(5_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::CurrentOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointmentProcesses` (r:1 w:1)
|
||||
/// Proof: `Welati::AppointmentProcesses` (`max_values`: None, `max_size`: Some(10119), added: 12594, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::PendingNominations` (r:1 w:1)
|
||||
/// Proof: `Welati::PendingNominations` (`max_values`: None, `max_size`: Some(173), added: 2648, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::AppointedOfficials` (r:0 w:1)
|
||||
/// Proof: `Welati::AppointedOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
fn approve_appointment() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `444`
|
||||
// Estimated: `13584`
|
||||
// Minimum execution time: 28_797_000 picoseconds.
|
||||
Weight::from_parts(30_151_000, 13584)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
}
|
||||
/// Storage: `Welati::ParliamentMembers` (r:1 w:0)
|
||||
/// Proof: `Welati::ParliamentMembers` (`max_values`: Some(1), `max_size`: Some(11057), added: 11552, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::CurrentOfficials` (r:1 w:0)
|
||||
/// Proof: `Welati::CurrentOfficials` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::NextProposalId` (r:1 w:1)
|
||||
/// Proof: `Welati::NextProposalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ActiveProposals` (r:0 w:1)
|
||||
/// Proof: `Welati::ActiveProposals` (`max_values`: None, `max_size`: Some(1195), added: 3670, mode: `MaxEncodedLen`)
|
||||
fn submit_proposal() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `119`
|
||||
// Estimated: `12542`
|
||||
// Minimum execution time: 16_335_000 picoseconds.
|
||||
Weight::from_parts(17_233_000, 12542)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Welati::ActiveProposals` (r:1 w:1)
|
||||
/// Proof: `Welati::ActiveProposals` (`max_values`: None, `max_size`: Some(1195), added: 3670, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::CollectiveVotes` (r:1 w:1)
|
||||
/// Proof: `Welati::CollectiveVotes` (`max_values`: None, `max_size`: Some(612), added: 3087, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Welati::ParliamentMembers` (r:1 w:0)
|
||||
/// Proof: `Welati::ParliamentMembers` (`max_values`: Some(1), `max_size`: Some(11057), added: 11552, mode: `MaxEncodedLen`)
|
||||
fn vote_on_proposal() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `349`
|
||||
// Estimated: `12542`
|
||||
// Minimum execution time: 20_789_000 picoseconds.
|
||||
Weight::from_parts(21_455_000, 12542)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user