From 2094b221cc0c9624b294e71fe4f47137c4e8993d Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Thu, 25 Dec 2025 11:24:40 +0300 Subject: [PATCH] sync: pezkuwi-sdk templates/minimal ile senkronize edildi - node/src/* guncelendi - runtime/src/lib.rs guncelendi (pezsp_keyring import fix) - pezpallets/template/src/* guncelendi --- README.md | 4 +- node/src/chain_spec.rs | 10 ++-- node/src/cli.rs | 17 ++++-- node/src/command.rs | 29 ++++++--- node/src/lib.rs | 2 +- node/src/main.rs | 4 +- node/src/rpc.rs | 16 ++--- node/src/service.rs | 13 ++-- pezpallets/template/src/lib.rs | 13 ++-- runtime/src/lib.rs | 105 ++++++++++++++++++--------------- 10 files changed, 122 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index 6426e0b..99d9576 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ # Pezkuwi SDK's Minimal Template -Pezkuwi SDK Logo -Pezkuwi SDK Logo +Pezkuwi SDK Logo +Pezkuwi SDK Logo > This is a minimal template for creating a blockchain based on Pezkuwi SDK. > diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index c49e29f..a2ced7b 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,6 +1,6 @@ -// This file is part of pezkuwi-sdk. +// This file is part of Bizinikiwi. -// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,13 +21,13 @@ use pezkuwi_sdk::{ *, }; -/// This is a specialization of the general bizinikiwi ChainSpec type. +/// This is a specialization of the general Bizinikiwi ChainSpec type. pub type ChainSpec = pezsc_service::GenericChainSpec; fn props() -> Properties { let mut properties = Properties::new(); properties.insert("tokenDecimals".to_string(), 0.into()); - properties.insert("tokenSymbol".to_string(), "PEZ".into()); + properties.insert("tokenSymbol".to_string(), "MINI".into()); properties } @@ -36,7 +36,7 @@ pub fn development_chain_spec() -> Result { .with_name("Development") .with_id("dev") .with_chain_type(ChainType::Development) - .with_genesis_config_preset_name(pezsp_genesis_builder::DEV_RUNTIME_PRESET) + .with_genesis_config_preset_name(pezkuwi_sdk::pezsp_genesis_builder::DEV_RUNTIME_PRESET) .with_properties(props()) .build()) } diff --git a/node/src/cli.rs b/node/src/cli.rs index 16908e4..16a5780 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -1,7 +1,8 @@ -// This file is part of pezkuwi-sdk. +// This file is part of Bizinikiwi. -// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024. +// 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 @@ -14,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use pezkuwi_sdk::{pezsc_cli::RunCmd, *}; +use pezkuwi_sdk::*; #[derive(Debug, Clone)] pub enum Consensus { @@ -48,7 +49,7 @@ pub struct Cli { pub consensus: Consensus, #[clap(flatten)] - pub run: RunCmd, + pub run: pezsc_cli::RunCmd, } #[derive(Debug, clap::Subcommand)] @@ -58,8 +59,16 @@ pub enum Subcommand { Key(pezsc_cli::KeySubcommand), /// Build a chain specification. + /// DEPRECATED: `build-spec` command will be removed after 1/04/2026. Use `export-chain-spec` + /// command instead. + #[deprecated( + note = "build-spec command will be removed after 1/04/2026. Use export-chain-spec command instead" + )] BuildSpec(pezsc_cli::BuildSpecCmd), + /// Export the chain specification. + ExportChainSpec(pezsc_cli::ExportChainSpecCmd), + /// Validate blocks. CheckBlock(pezsc_cli::CheckBlockCmd), diff --git a/node/src/command.rs b/node/src/command.rs index 1cd6f6b..bfa9aab 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -1,6 +1,6 @@ -// This file is part of pezkuwi-sdk. +// This file is part of Bizinikiwi. -// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -50,8 +50,9 @@ impl BizinikiwiCli for Cli { fn load_spec(&self, id: &str) -> Result, String> { Ok(match id { "dev" => Box::new(chain_spec::development_chain_spec()?), - path => - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), + path => { + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?) + }, }) } } @@ -62,6 +63,7 @@ pub fn run() -> pezsc_cli::Result<()> { match &cli.subcommand { Some(Subcommand::Key(cmd)) => cmd.run(&cli), + #[allow(deprecated)] Some(Subcommand::BuildSpec(cmd)) => { let runner = cli.create_runner(cmd)?; runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) @@ -74,6 +76,10 @@ pub fn run() -> pezsc_cli::Result<()> { Ok((cmd.run(client, import_queue), task_manager)) }) }, + Some(Subcommand::ExportChainSpec(cmd)) => { + let chain_spec = cli.load_spec(&cmd.chain)?; + cmd.run(chain_spec) + }, Some(Subcommand::ExportBlocks(cmd)) => { let runner = cli.create_runner(cmd)?; runner.async_run(|config| { @@ -117,13 +123,18 @@ pub fn run() -> pezsc_cli::Result<()> { None => { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| async move { - match config.network.network_backend.unwrap_or_default() { - pezsc_network::config::NetworkBackendType::Libp2p => - service::new_full::>(config, cli.consensus) - .map_err(pezsc_cli::Error::Service), + match config.network.network_backend { + pezsc_network::config::NetworkBackendType::Libp2p => service::new_full::< + pezsc_network::NetworkWorker<_, _>, + >( + config, cli.consensus + ) + .map_err(pezsc_cli::Error::Service), pezsc_network::config::NetworkBackendType::Litep2p => service::new_full::< pezsc_network::Litep2pNetworkBackend, - >(config, cli.consensus) + >( + config, cli.consensus + ) .map_err(pezsc_cli::Error::Service), } }) diff --git a/node/src/lib.rs b/node/src/lib.rs index ba613ac..3819d83 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Pezkuwi Sdk. -// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/node/src/main.rs b/node/src/main.rs index 62207df..c1643b7 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -1,6 +1,6 @@ -// This file is part of pezkuwi-sdk. +// This file is part of Bizinikiwi. -// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 7db7110..759d8cf 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -1,6 +1,6 @@ -// This file is part of pezkuwi-sdk. +// This file is part of Bizinikiwi. -// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,8 +16,8 @@ // limitations under the License. //! A collection of node-specific RPC methods. -//! bizinikiwi provides the `pezsc-rpc` crate, which defines the core RPC layer -//! used by bizinikiwi nodes. This file extends those RPC definitions with +//! Bizinikiwi provides the `sc-rpc` crate, which defines the core RPC layer +//! used by Bizinikiwi nodes. This file extends those RPC definitions with //! capabilities that are specific to this project's runtime configuration. #![warn(missing_docs)] @@ -48,15 +48,15 @@ where C: Send + Sync + 'static - + pezsp_api::ProvideRuntimeApi + + pezkuwi_sdk::pezsp_api::ProvideRuntimeApi + HeaderBackend + HeaderMetadata + 'static, - C::Api: pezsp_block_builder::BlockBuilder, - C::Api: pezframe_rpc_system::AccountNonceApi, + C::Api: pezkuwi_sdk::pezsp_block_builder::BlockBuilder, + C::Api: bizinikiwi_frame_rpc_system::AccountNonceApi, P: TransactionPool + 'static, { - use pezkuwi_sdk::pezframe_rpc_system::{System, SystemApiServer}; + use pezkuwi_sdk::bizinikiwi_frame_rpc_system::{System, SystemApiServer}; let mut module = RpcModule::new(()); let FullDeps { client, pool } = deps; diff --git a/node/src/service.rs b/node/src/service.rs index 3a573c0..07c19f1 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,6 +1,6 @@ -// This file is part of pezkuwi-sdk. +// This file is part of Bizinikiwi. -// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,12 +24,12 @@ use pezkuwi_sdk::{ pezsc_service::{error::Error as ServiceError, Configuration, TaskManager}, pezsc_telemetry::{Telemetry, TelemetryWorker}, pezsc_transaction_pool_api::OffchainTransactionPoolFactory, - pezsp_runtime::traits::Block as BlockT, *, }; +use pezsp_runtime::traits::Block as BlockT; use std::sync::Arc; -type HostFunctions = pezsp_io::BizinikiwiHostFunctions; +type HostFunctions = pezkuwi_sdk::pezsp_io::BizinikiwiHostFunctions; #[docify::export] pub(crate) type FullClient = @@ -194,6 +194,7 @@ pub fn new_full: sync_service, config, telemetry: telemetry.as_mut(), + tracing_execute_block: None, })?; let proposer = pezsc_basic_authorship::ProposerFactory::new( @@ -214,7 +215,7 @@ pub fn new_full: select_chain, consensus_data_provider: None, create_inherent_data_providers: move |_, ()| async move { - Ok(pezsp_timestamp::InherentDataProvider::from_system_time()) + Ok(pezkuwi_sdk::pezsp_timestamp::InherentDataProvider::from_system_time()) }, }; @@ -250,7 +251,7 @@ pub fn new_full: commands_stream: Box::pin(commands_stream), consensus_data_provider: None, create_inherent_data_providers: move |_, ()| async move { - Ok(pezsp_timestamp::InherentDataProvider::from_system_time()) + Ok(pezkuwi_sdk::pezsp_timestamp::InherentDataProvider::from_system_time()) }, }; let authorship_future = pezsc_consensus_manual_seal::run_manual_seal(params); diff --git a/pezpallets/template/src/lib.rs b/pezpallets/template/src/lib.rs index b69aa94..9e1904a 100644 --- a/pezpallets/template/src/lib.rs +++ b/pezpallets/template/src/lib.rs @@ -1,17 +1,18 @@ -//! A shell pezpallet built with [`pezframe`]. +//! A shell pezpallet built with [`frame`]. //! //! To get started with this pezpallet, try implementing the guide in -//! +//! #![cfg_attr(not(feature = "std"), no_std)] -use pezkuwi_sdk::pezkuwi_sdk_frame::deps::pezframe_support::pezpallet_prelude::*; +use frame::prelude::*; +use pezkuwi_sdk::pezkuwi_sdk_frame as frame; // Re-export all pezpallet parts, this is needed to properly import the pezpallet into the runtime. -pub use pallet::*; +pub use pezpallet::*; -#[pezkuwi_sdk::pezframe_support::pezpallet] -pub mod pallet { +#[frame::pezpallet] +pub mod pezpallet { use super::*; #[pezpallet::config] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9eff910..123a023 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1,3 +1,20 @@ +// 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 minimal runtime that includes the template [`pezpallet`](`pezpallet_minimal_template`). #![cfg_attr(not(feature = "std"), no_std)] @@ -9,26 +26,24 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); extern crate alloc; use alloc::vec::Vec; -use pezpallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use pezkuwi_sdk::{ pezkuwi_sdk_frame::{ self as frame, deps::pezsp_genesis_builder, runtime::{apis, prelude::*}, }, - pezframe_system as frame_system, *, }; +use pezpallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; /// Provides getters for genesis configuration presets. pub mod genesis_config_presets { use super::*; use crate::{ interface::{Balance, MinimumBalance}, - runtime::{BalancesConfig, RuntimeGenesisConfig, SudoConfig}, + BalancesConfig, RuntimeGenesisConfig, SudoConfig, }; - #[cfg(feature = "std")] - use pezkuwi_sdk::pezsp_keyring::Sr25519Keyring; + use frame::deps::pezsp_keyring::Sr25519Keyring; use alloc::{vec, vec::Vec}; use serde_json::Value; @@ -86,34 +101,34 @@ pub fn native_version() -> NativeVersion { /// The transaction extensions that are added to the runtime. type TxExtension = ( + // Authorize calls that validate themselves. + pezframe_system::AuthorizeCall, // Checks that the sender is not the zero address. - frame_system::CheckNonZeroSender, + pezframe_system::CheckNonZeroSender, // Checks that the runtime version is correct. - frame_system::CheckSpecVersion, + pezframe_system::CheckSpecVersion, // Checks that the transaction version is correct. - frame_system::CheckTxVersion, + pezframe_system::CheckTxVersion, // Checks that the genesis hash is correct. - frame_system::CheckGenesis, + pezframe_system::CheckGenesis, // Checks that the era is valid. - frame_system::CheckEra, + pezframe_system::CheckEra, // Checks that the nonce is valid. - frame_system::CheckNonce, + pezframe_system::CheckNonce, // Checks that the weight is valid. - frame_system::CheckWeight, + pezframe_system::CheckWeight, // Ensures that the sender has enough funds to pay for the transaction // and deducts the fee from the sender's account. pezpallet_transaction_payment::ChargeTransactionPayment, // Reclaim the unused weight from the block using post dispatch information. // It must be last in the pipeline in order to catch the refund in previous transaction // extensions - frame_system::WeightReclaim, + pezframe_system::WeightReclaim, ); -// Composes the runtime by adding all the used pezpallets and deriving necessary types. +// Composes the runtime by adding all the used pallets and deriving necessary types. #[frame_construct_runtime] -pub mod runtime { - use super::*; - +mod runtime { /// The main runtime type. #[runtime::runtime] #[runtime::derive( @@ -128,7 +143,6 @@ pub mod runtime { RuntimeTask, RuntimeViewFunction )] - #[derive(Clone, PartialEq, Eq)] pub struct Runtime; /// Mandatory system pezpallet that should always be included in a FRAME runtime. @@ -156,24 +170,18 @@ pub mod runtime { pub type Template = pezpallet_minimal_template::Pezpallet; } -pub use runtime::{ - Runtime, System, Timestamp, Balances, Sudo, TransactionPayment, Template, - RuntimeCall, RuntimeEvent, RuntimeError, RuntimeOrigin, RuntimeFreezeReason, - RuntimeHoldReason, RuntimeSlashReason, RuntimeLockId, RuntimeTask, RuntimeViewFunction, - AllPalletsWithSystem, RuntimeGenesisConfig, BalancesConfig, SudoConfig, -}; - parameter_types! { pub const Version: RuntimeVersion = VERSION; } /// Implements the types required for the system pezpallet. -#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)] -impl frame_system::Config for Runtime { +#[derive_impl(pezframe_system::config_preludes::SolochainDefaultConfig)] +impl pezframe_system::Config for Runtime { type Block = Block; type Version = Version; // Use the account data from the balances pezpallet - type AccountData = pezpallet_balances::AccountData<::Balance>; + type AccountData = + pezpallet_balances::AccountData<::Balance>; } // Implements the types required for the balances pezpallet. @@ -186,7 +194,7 @@ impl pezpallet_balances::Config for Runtime { #[derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)] impl pezpallet_sudo::Config for Runtime {} -// Implements the types required for the timestamp pezpallet. +// Implements the types required for the sudo pezpallet. #[derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)] impl pezpallet_timestamp::Config for Runtime {} @@ -206,19 +214,22 @@ impl pezpallet_minimal_template::Config for Runtime {} type Block = frame::runtime::types_common::BlockOf; type Header = HeaderFor; -type RuntimeExecutive = - Executive, Runtime, AllPalletsWithSystem>; +type RuntimeExecutive = Executive< + Runtime, + Block, + pezframe_system::ChainContext, + Runtime, + AllPalletsWithSystem, +>; impl_runtime_apis! { - use pezsp_runtime::traits::BlockT; - impl apis::Core for Runtime { fn version() -> RuntimeVersion { VERSION } - fn execute_block(block: ::LazyBlock) { - RuntimeExecutive::execute_block(block.into()) + fn execute_block(block: ::LazyBlock) { + RuntimeExecutive::execute_block(block) } fn initialize_block(header: &Header) -> ExtrinsicInclusionMode { @@ -227,7 +238,7 @@ impl_runtime_apis! { } impl apis::Metadata for Runtime { fn metadata() -> OpaqueMetadata { - Runtime::metadata() + OpaqueMetadata::new(Runtime::metadata().into()) } fn metadata_at_version(version: u32) -> Option { @@ -249,16 +260,14 @@ impl_runtime_apis! { } fn inherent_extrinsics(data: InherentData) -> Vec> { - // TODO: Implement proper inherent extrinsics creation - Vec::new() + data.create_extrinsics() } fn check_inherents( - block: ::LazyBlock, + block: ::LazyBlock, data: InherentData, ) -> CheckInherentsResult { - // TODO: Implement proper inherents checking - CheckInherentsResult::new() + data.check_extrinsics(&block) } } @@ -266,7 +275,7 @@ impl_runtime_apis! { fn validate_transaction( source: TransactionSource, tx: ExtrinsicFor, - block_hash: ::Hash, + block_hash: ::Hash, ) -> TransactionValidity { RuntimeExecutive::validate_transaction(source, tx, block_hash) } @@ -333,16 +342,16 @@ impl_runtime_apis! { /// /// Other types should preferably be private. // TODO: this should be standardized in some way, see: -// https://github.com/paritytech/substrate/issues/10579#issuecomment-1600537558 +// https://github.com/pezkuwichain/pezkuwi-sdk/issues/3 pub mod interface { - use super::{Runtime, frame_system}; - use pezkuwi_sdk::{pezkuwi_sdk_frame as frame, *, pezpallet_balances}; + use super::Runtime; + use pezkuwi_sdk::{pezkuwi_sdk_frame as frame, *}; pub type Block = super::Block; pub use frame::runtime::types_common::OpaqueBlock; - pub type AccountId = ::AccountId; - pub type Nonce = ::Nonce; - pub type Hash = ::Hash; + pub type AccountId = ::AccountId; + pub type Nonce = ::Nonce; + pub type Hash = ::Hash; pub type Balance = ::Balance; pub type MinimumBalance = ::ExistentialDeposit; }