85 Commits

Author SHA1 Message Date
pezkuwichain fd197ae78f fix: presale benchmark missing args + security audit advisory cleanup
- Fix refund_cancelled_presale benchmark: add missing start_index and
  batch_size arguments (0, 100) to match the 3-param extrinsic signature
- Remove 3 stale RUSTSEC advisories from deny.toml and security-audit.yml
  (RUSTSEC-2023-0071, RUSTSEC-2025-0055, RUSTSEC-2026-0002 no longer in deps)
- Add RUSTSEC-2026-0049 (rustls-webpki) to ignore lists (upstream kube/jsonrpsee
  haven't released compatible versions yet)
2026-03-27 09:34:47 +03:00
pezkuwichain 9f4c9b4d19 style: fix formatting, regenerate umbrella, taplo format 2026-03-22 20:17:58 +03:00
pezkuwichain 288978c088 fix(security): audit fixes across 9 custom pallets
- pez-rewards: checked arithmetic in parliamentary reward distribution
- tiki: saturating_add in get_tiki_score fold, benchmarking cleanup
- ping: saturating_add on PingCount
- staking-score: saturating_mul on 4 duration multipliers
- pez-treasury: proper error on TreasuryStartBlock None, saturating_add on NextReleaseMonth, doc fix 70->75%
- messaging: InboxOverflow event on FIFO eviction
- token-wrapper: reorder wrap/unwrap operations, add pallet balance pre-check
- welati: u64 cast for turnout percentage overflow prevention
- presale: fix refund calculation to use net_in_treasury (98%) instead of impossible 99%, update tests
2026-03-22 18:56:37 +03:00
pezkuwichain ad9204cab1 fix(security): address HIGH audit findings across 5 pallets
identity-kyc (H1):
- Add IdentityHashToAccount reverse mapping to prevent same identity hash
  being used by multiple accounts
- Check uniqueness in apply_for_citizenship, populate on confirm_citizenship,
  clean up on renounce_citizenship

pez-rewards (H2):
- Add EpochTotalClaimed storage to track claimed amounts per epoch
- do_close_epoch now only claws back unclaimed rewards (total_allocated -
  total_claimed), not the entire pot balance

tiki (H3):
- Replace custom "locked" attribute with pezpallet_nfts::disable_transfer()
  which sets the system-level PalletAttributes::TransferDisabled attribute
  that is actually enforced during transfers

tiki (H4):
- Fix EnsureTiki to check UserTikis storage for non-unique roles (Wezir,
  Parlementer) instead of TikiHolder which only stores unique roles

perwerde (H5):
- Add MaxPointsPerCourse config constant (1000 in runtime)
- Validate points in complete_course against the max
- Use saturating_add in get_perwerde_score to prevent u32 overflow

welati (H6):
- Add NativeCurrency: ReservableCurrency to Config
- Actually reserve candidacy deposit from candidate's balance

welati (H7):
- Add MaxEndorsers config constant (1000 in runtime)
- Validate endorsers count at the start of register_candidate before
  any storage reads
2026-03-21 21:58:24 +03:00
pezkuwichain 741a65416a fix(security): address remaining CRITICAL audit findings
presale:
- C2: Convert refund_cancelled_presale to batch pattern (start_index, batch_size)
  to prevent unbounded iteration with many contributors
- C3: Add status validation to cancel_presale — prevent cancelling Finalized/Failed
  presales (prevents double-dipping: tokens distributed + refund issued)
- C4: Enforce CreatePresaleOrigin (was defined in Config but never checked)
  Changed to Success = AccountId for proper owner extraction
- Clarified presale_account_id expect() safety comment (Blake2_256 = 32 bytes,
  always sufficient for AccountId decode)
- Removed unused imports (Defensive, AccountIdConversion)

perwerde:
- C5: Prevent NextCourseId overflow — added ensure!(< u32::MAX) check and
  replaced unchecked += 1 with saturating_add

welati:
- C6: Enforce access control on all CollectiveDecisionType variants:
  ConstitutionalReview/Unanimous → Diwan members only
  ExecutiveDecision → Serok only
  HybridDecision → Parliament OR Serok
  VetoOverride → Parliament members only
2026-03-21 21:23:43 +03:00
pezkuwichain f1a7a7f872 fix(security): address critical audit findings in presale and validator-pool pallets
presale:
- Split unbounded finalize_presale distribution into batched batch_distribute()
  extrinsic (same pattern as batch_refund_failed_presale) to prevent block weight
  exhaustion with many contributors
- Fix u128 overflow in calculate_reward_dynamic() by using
  multiply_by_rational_with_rounding() for safe intermediate multiplication
- Fix pre-existing batch_refund test assertion (platform fee deduction was not
  accounted for in expected refund amount)

validator-pool:
- Bound PoolMembers::iter() with .take(MaxPoolSize) in select_validators_for_era()
  to prevent unbounded iteration in on_initialize
- Fix on_initialize weight accounting to include all DB reads/writes from
  do_new_era() and select_validators_for_era() (was only counting 2 reads)
2026-03-21 15:33:25 +03:00
pezkuwichain 420ed35169 feat: add weights, benchmarking, mock and tests for ping and teyrchain-info pallets
- ping: weights.rs (WeightInfo trait + implementations), benchmarking.rs
  (v2-style benchmarks for start/start_many/stop/stop_all), mock.rs
  (test runtime with MockXcmSender), tests.rs (26 tests covering all extrinsics)
- teyrchain-info: mock.rs (minimal test runtime), tests.rs (7 tests for
  genesis config and ParaId getter)
- Updated ping lib.rs to use WeightInfo instead of zero weights
- Added WeightInfo = () to testing runtime Config
2026-03-21 15:19:47 +03:00
pezkuwichain afa8bba099 fix(ci): change Docker Hub namespace from pezkuwichain/ to pezkuwi/
Docker Hub personal account namespace must match the username.
Updated all docker.io image references across workflows, actions,
docker-compose files, and zombienet configs.
2026-03-14 15:58:50 +03:00
pezkuwichain bea99ee1b4 fix(messaging): fix clippy/rustdoc errors in benchmarking
- Mark shell command doc block as ```text to fix rustdoc parsing
- Remove duplicated #![cfg(feature = "runtime-benchmarks")] (already gated in lib.rs)
- Use let _ = for unused MultiRemovalResults from clear_prefix
2026-03-04 15:01:49 +03:00
pezkuwichain 0d3548a87b feat(people): add pezpallet-messaging to People Chain runtime
End-to-end encrypted messaging pallet with citizenship and trust score
verification. Integrated into People Chain runtime as pallet index 55.
spec_version bumped to 1_020_009.
2026-03-04 03:55:55 +03:00
pezkuwichain 5eb2769add fix: cargo fmt + LocalCheckAccount→CheckAccount rename + AH MintLocation fix
- Fix xcm_config.rs import line exceeding rustfmt max width
- Rename LocalCheckAccount to CheckAccount in RC runtime (import + type alias)
- Set AH TeleportTracking to None for teleport compatibility (RC 1_020_007, AH 1_020_007)
- Regenerate umbrella crate
2026-02-22 18:47:46 +03:00
pezkuwichain 0e7a3856c2 fix(xcm): correct MintLocation for AH migration (RC 1_020_007, AH 1_020_006)
Relay Chain no longer has mint authority — teleport tracking set to None.
Asset Hub is now the canonical minter with MintLocation::Local tracking.

RC: LocalCheckAccount → TeleportTracking = None
AH: () → TeleportTracking = Some((CheckingAccount, MintLocation::Local))
2026-02-21 04:55:14 +03:00
pezkuwichain 90a6917616 chore: bump spec versions for mainnet upgrade (RC 1_020_005, AH 1_020_005, People 1_020_008) 2026-02-20 15:26:17 +03:00
pezkuwichain cc156a1d61 fix(ah-staking): stall detection grace period, MinerPages fix, and simulation tools
- Add 3-session grace period to stall detection to allow RC XCM round-trip
  before triggering era recovery (StallDetectionCount storage added)
- Fix plan_new_era() to always increment CurrentEra regardless of
  ElectionProvider::start() result, preventing infinite retry loops
- Fix MinerPages from 2 to 32 to match Pages config (was causing
  incomplete OCW solutions and election failures)
- Bump AH spec_version to 1_020_007
- Add subxt example scripts for simulation and mainnet operations
- Remove obsolete fix_force_era.rs (replaced by sim_reset_election.rs)
2026-02-19 17:16:43 +03:00
pezkuwichain ce79d33f0d feat(governance): activate OpenGov production periods and add Welati tracks
Upgrade all 15 OpenGov track periods from Westend test values (minutes)
to Polkadot production values (hours/days). Add 3 new Welati governance
tracks (welati_election, welati_admin, citizenship_admin) with origins
and XCM routing for RC → People Chain governance via OpenGov referenda.

Bump spec_version: 1_020_007 → 1_020_008
2026-02-18 23:36:31 +03:00
pezkuwichain d6f180621e fix(ah): set force_era=ForceNone in genesis to prevent premature elections
Prevents automatic election before validators are staked on AH.
After staking setup, trigger manually with force_new_era().
2026-02-18 21:23:51 +03:00
pezkuwichain 1f814ca9b9 feat(ah): treasury integration and production staking parameters
- Route RewardRemainder and Slash to Treasury via ResolveTo (previously burned)
- Route DelegatedStaking OnSlash to Treasury
- MaxExposurePageSize: 64 → 512 (Polkadot production value)
- Use prod_or_fast for session Period and SessionLength
- Bump spec_version to 1_020_006
2026-02-18 21:23:23 +03:00
pezkuwichain 6f4bbe2d86 fix(ah-staking): correct fixed_total_issuance to 200M HEZ baseline
The EraPayout fixed_total_issuance was ~5,216 HEZ (copied from
Polkadot's 10-decimal DOT value). Corrected to 200M HEZ (12 decimals)
to match actual chain total issuance. This fixes staking rewards
being ~40x lower than intended on Asset Hub.
2026-02-18 20:19:40 +03:00
pezkuwichain f5d865ae0a fix: lower MinTrust thresholds for welati elections, fix CI fmt
Welati MinTrust changes (People Chain 1_020_008 prep):
- Presidential: 600→250, Parliamentary: 300→100
- SpeakerElection: 400→200, ConstitutionalCourt: 750→275
- OfficialRole: 250→75, Endorser: 100→40

Also fix grant_noter_tiki.rs formatting for CI quick-checks.
2026-02-17 04:01:26 +03:00
pezkuwichain dd4b9874ae fix: taplo formatting and umbrella version for CI quick-checks 2026-02-16 20:00:52 +03:00
pezkuwichain da3a8f23c0 fix: remove staking-score from relay chain, fix CI quick-checks
- Remove pezpallet_staking_score from relay chain runtime (noter model
  lives on People Chain only)
- Update welati mock to current staking-score Config trait
- Fix staking-score feature propagation (zepter: std, runtime-benchmarks)
- Format vendor subxt example files (rustfmt)
- Regenerate umbrella crate
- Update CRITICAL_STATE.md with noter delegation status
2026-02-16 19:50:13 +03:00
pezkuwichain d23daa8f67 feat: noter delegation for staking score system
- Add NoterCheck trait: accounts with Noter tiki can submit
  receive_staking_details without root origin
- Remove stake requirement from start_score_tracking (opt-in only,
  bot + noter submit data after event detection)
- Add zero-stake cleanup: sending staked_amount=0 removes cached
  entry, cleans up StakingStartBlock when no stake remains
- Add NotAuthorized error for non-noter signed callers
- Configure TikiNoterChecker in people-pezkuwichain runtime
- Update weights with detailed DB operation analysis
- Bump People Chain spec_version to 1_020_007
- 49 unit tests (17 new E2E + edge cases), fmt/clippy clean
2026-02-16 19:01:18 +03:00
pezkuwichain 0e809c3a74 sec: remove hardcoded mnemonics, add mainnet tools and subxt examples
- Replace all hardcoded wallet mnemonics with env variable reads
- Add comprehensive e2e test suite (tools/e2e-test/)
- Add zagros validator management tools
- Add subxt examples for mainnet operations
- Update CRITICAL_STATE with zagros testnet and mainnet status
- Fix people chain spec ID and chainspec build script
2026-02-16 08:18:26 +03:00
pezkuwichain d6444076c3 feat: dual-chain staking score with XCM data pipeline
- Rewrite pezpallet-staking-score: StorageDoubleMap (AccountId x StakingSource),
  remove StakingInfoProvider trait, all data via receive_staking_details()
- Add StakingSource enum (RelayChain / AssetHub) for multi-source aggregation
- Add OnStakingDataUpdate callback trait for trust pallet integration
- Trust pallet: on_initialize hook for periodic batch updates,
  OnStakingDataUpdate impl triggers immediate score recalculation
- People Chain runtime: remove noop StakingInfoProvider, wire OnStakingUpdate = Trust
- Update weights for both pallets (conservative estimates incl. callback cost)
- spec_version 1_020_005 -> 1_020_006
- 57 tests passing (25 staking-score + 32 trust)
2026-02-16 07:49:13 +03:00
pezkuwichain 3fa2fe3ea6 bump: spec_version 1_020_003 → 1_020_004 for fresh mainnet launch 2026-02-14 23:40:18 +03:00
pezkuwichain b67e30942e style: taplo formatting and umbrella regeneration 2026-02-14 11:02:01 +03:00
pezkuwichain 558ab4b771 feat: add NominationPoolsApi and StakingApi to Asset Hub runtime
- Implement NominationPoolsApi (pending_rewards, points_to_balance, etc.)
- Implement StakingApi (nominations_quota, eras_stakers_page_count, pending_rewards)
- Fix ss58-registry doc-test crate name (pezkuwi → pezsp)
- Update CRITICAL_STATE.md with current network status and pending tasks
2026-02-14 10:53:06 +03:00
pezkuwichain fb97e696fd feat: add Tiki GenesisConfig for Collection 0 bootstrap and XCM creation tools
- Add GenesisConfig to pezpallet-tiki that creates NFT Collection 0 and mints
  NFT #0 for the founding citizen at genesis, solving the chicken-egg problem
  where Collection 0 must exist before any citizenship NFTs can be minted
- Wire founding_citizen parameter through all People Chain genesis presets
  (genesis, local_testnet, dev)
- Add create_nft_collection.rs XCM script for creating Collection 0 on live
  chain via sudo XCM Transact from Relay Chain
- Add comprehensive_test.rs for post-upgrade chain testing
- Fix clippy warnings (map().flatten() -> and_then()) and apply taplo formatting
2026-02-14 04:41:21 +03:00
pezkuwichain 3e8ad87e15 chore: bump spec_version to 1_020_003 for runtime upgrade
Bump all three runtime spec_versions from 1_020_002 to 1_020_003
to prepare for on-chain runtime upgrade deploying trust score
system changes to the live chain.
2026-02-13 23:47:48 +03:00
pezkuwichain 098963d62f fix: add TrustScoreUpdater type to welati mock Config implementations 2026-02-13 21:02:56 +03:00
pezkuwichain bd454cf395 feat: wire trust score system with cross-chain staking data and component triggers
- Add CachedStakingDetails storage and receive_staking_details extrinsic
  to staking-score pallet for Asset Hub XCM data reception
- Add TrustScoreUpdater triggers to referral, tiki, and perwerde pallets
  so component score changes propagate to trust pallet
- Wire runtime hooks (OnKycApproved, OnCitizenshipRevoked) to Referral
  and CitizenNftProvider to Tiki in people.rs
- Fix PerwerdeScoreSource and ReferralScoreSource to read actual pallet data
- Fix EnsureOrigin trait feature unification issue by removing cfg gate
  from try_successful_origin and adding default Err(()) implementation
- Fix workspace Cargo.toml default-features for pezkuwi-subxt dependencies
2026-02-13 20:13:50 +03:00
pezkuwichain 7cc2f831b4 style: fix formatting in StakingSessionManager 2026-02-13 00:37:51 +03:00
pezkuwichain 3514625d25 feat: forward session events to staking pallet for era progression on Asset Hub
Asset Hub's pallet_staking_async era never advances because it expects
SessionReport messages from the relay chain's ah_client pallet, which is
not yet active. This adds a StakingSessionManager wrapper that intercepts
local session rotation events and generates SessionReport messages to drive
era transitions directly on Asset Hub.

Changes:
- Add StakingSessionManager in staking.rs that delegates to both
  CollatorSelection and Staking via on_relay_session_report()
- Switch SessionManager from CollatorSelection to StakingSessionManager
- Add FixActiveEraStart migration to correct ActiveEra.start=0 from genesis
- Bump spec_version to 1_020_002
2026-02-12 23:58:58 +03:00
pezkuwichain 75ddf88cf8 fix: remove needless borrows in tiki migration tests (clippy) 2026-02-11 07:56:13 +03:00
pezkuwichain cab8e11f21 style: taplo fmt - normalize Cargo.toml indentation 2026-02-11 04:52:44 +03:00
pezkuwichain 60fec915de fix: chain spec corrections - tokenDecimals 18->12, ss58Format, para_id 2026-02-11 04:52:28 +03:00
pezkuwichain f5ffd42a86 style: fix cargo fmt in tiki migrations 2026-02-11 04:49:00 +03:00
pezkuwichain 54e77cfc61 chore: register tiki v2 migration and bump spec_version to 1_020_002
- Added pezpallet_tiki::migrations::v2::MigrateToV2 to People chain
  Migrations tuple (populates TikiHolder on upgrade)
- Bumped spec_version 1_020_001 -> 1_020_002 for both relay chain
  and People chain runtimes
2026-02-11 04:38:18 +03:00
pezkuwichain 5a2504912c fix: add DefaultReferrer to all pallet test mocks
After DefaultReferrer was added to pezpallet_identity_kyc::Config trait,
all dependent pallets need this type in their mock configs. Updated mocks
for identity-kyc, pez-rewards, trust, and welati. Also updated
identity-kyc tests for Option<referrer> parameter change.
2026-02-11 04:38:11 +03:00
pezkuwichain 2be5c6d11e fix: ScoreMultiplierBase 100 -> 10000 for meaningful trust scores
Without sufficient multiplier, integer division produces 0 for most
component scores. Increasing to 10_000 ensures trust scores reflect
actual staking, referral, tiki, and perwerde contributions.
2026-02-11 04:38:02 +03:00
pezkuwichain f1b671ad65 feat: tiki v2 migration - populate TikiHolder from UserTikis
Storage migration v1->v2 scans all UserTikis entries and populates
TikiHolder for unique roles (Serok, SerokiMeclise, Xezinedar, Balyoz).
Fixes empty TikiHolder on live chain despite roles being assigned.

Includes try-runtime pre/post upgrade checks and unit tests.
2026-02-11 04:37:55 +03:00
pezkuwichain 0be7357f90 fix: tiki pallet - burn cleanup, remove on_initialize, scoring fixes
- burn_citizen_nft now clears UserTikis and TikiHolder entries
- Removed on_initialize O(n) per-block scan (uses CitizenNftProvider hooks)
- Added Peseng role score (80 points)
- Removed catch-all match arm for compile-time safety on new roles
- Removed duplicate cfg benchmark/non-benchmark blocks in mint
2026-02-11 04:37:46 +03:00
pezkuwichain bc8e298ea3 fix: referral pallet - force_confirm stats tracking and penalty_score usage
- force_confirm_referral now updates ReferrerStatsStorage (was missing)
- get_referral_score uses stored penalty_score from PenaltyPerRevocation
  instead of hardcoded (revoked*10)/4 formula
- Updated tests to match new penalty calculation behavior
2026-02-11 04:37:38 +03:00
pezkuwichain 172b04e4d4 fix: workflow failures - cargo fmt, taplo fmt, and StakingConfig
- Update taplo.toml exclude patterns to use glob patterns for zombienet files
- Add StakingConfig to genesis_config_presets for proper era initialization
- Fix cargo fmt issues in identity-kyc pallet and pezkuwichain runtime
- Set num_cores to 2 for system teyrchains (Asset Hub + People Chain)
2026-02-10 08:03:10 +03:00
pezkuwichain 1d64a1317a feat: add staking score pallet to relay chain and fix referral default
Relay Chain:
- Add pezpallet-staking-score to runtime
- Implement RelayStakingInfoProvider to read from pallet_staking
- StakingScore pallet index = 92

People Chain:
- Add DefaultReferrer type to identity-kyc pallet Config
- Change DefaultReferrer from Alice to founder address
- Make referrer parameter optional in apply_for_citizenship
- Fallback to DefaultReferrer when no valid referrer provided
2026-02-07 00:43:28 +03:00
pezkuwichain 6a02481f00 feat: update mainnet genesis configuration
- Update validator and collator addresses in genesis presets
- Update special account addresses (founder, treasury, presale, rewards)
- Reduce Asset Hub collators from 4 to 2
- Remove obsolete zombienet config files
2026-01-29 15:25:53 +03:00
pezkuwichain 267fcec12d fix: quick-checks CI failures - taplo format, zepter, umbrella
1. TOML format (taplo): 123 files reformatted using correct config
   - Command: taplo format --config .config/taplo.toml

2. Zepter feature propagation fix:
   - pezframe-support: added pezsp-timestamp/try-runtime to try-runtime feature

3. generate-umbrella.py bug fix:
   - Script crashed when Cargo.toml/src didn't exist in umbrella dir
   - Added existence checks before deletion
2026-01-26 00:39:59 +03:00
pezkuwichain ff5e45f904 fix: correct feature gates for storage-benchmark and metadata-hash
- StorageCmd: change cfg from runtime-benchmarks to storage-benchmark
- enable_metadata_hash_in_wasm_builder: add cfg(feature = "metadata-hash") gate
- Add storage-benchmark feature to pezkuwi-omni-node-lib Cargo.toml
- Add metadata-hash feature to pezframe-metadata-hash-extension Cargo.toml

These fixes resolve cargo-check-all-benches CI failures.
2026-01-25 23:03:06 +03:00
pezkuwichain 75f86b4ebe feat: add pezkuwichain mainnet configuration
Mainnet Configuration:
- Add pezkuwichain_mainnet_config() in chain_spec.rs with HEZ token properties
- Add "pezkuwichain-mainnet" CLI option in command.rs
- Update relay chain name to "pezkuwichain-mainnet" in asset_hubs.rs

Asset Hub Genesis (asset-hub-pezkuwichain):
- Add wUSDT asset (ID: 1000, 6 decimals) for wrapped USDT
- Update treasury, founder, presale accounts to secure mainnet wallets
- Update collator addresses (Azad, Beritan, Civan, Dildar)

People Chain Genesis (people-pezkuwichain):
- Add PezkuwichainGenesis runtime type for mainnet
- Update founder account to secure mainnet wallet
- Update collator addresses (Erin, Firaz, Goran, Hevi)

Token Configuration:
- HEZ: 18 decimals, SS58 format 42
- PEZ: Asset ID 1, 12 decimals
- wHEZ: Asset ID 2, 12 decimals
- wUSDT: Asset ID 1000, 6 decimals
2026-01-25 19:42:43 +03:00
pezkuwichain 98e0d7937e fix: correct Ed25519/Sr25519 key scheme detection for Asset Hub
- Fix RuntimeResolver prefix matching order: check asset-hub-pezkuwichain
  BEFORE asset-hub-pezkuwi to avoid false matches
- Fix zombienet SDK is_asset_hub_pezkuwi detection to exclude pezkuwichain
- Add zombienet-local-21.toml and zombienet-mainnet-21.toml configs
- Update .gitignore for sensitive mainnet files
2026-01-24 10:43:10 +03:00