sync: pezkuwi-sdk templates/minimal ile senkronize edildi

- node/src/* guncelendi
- runtime/src/lib.rs guncelendi (pezsp_keyring import fix)
- pezpallets/template/src/* guncelendi
This commit is contained in:
2025-12-25 11:24:40 +03:00
parent 57c7bf64e5
commit 2094b221cc
10 changed files with 122 additions and 91 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
# Pezkuwi SDK's Minimal Template
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/raw/master/docs/images/Pezkuwi_Logo_Horizontal_Pink_White.png#gh-dark-mode-only"/>
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/raw/master/docs/images/Pezkuwi_Logo_Horizontal_Pink_Black.png#gh-light-mode-only"/>
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/blob/main/docs/images/Pezkuwi_Logo_Horizontal_Pink_Black.png"/>
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/blob/main/docs/images/Pezkuwi_Logo_Horizontal_Pink_Black.png"/>
> This is a minimal template for creating a blockchain based on Pezkuwi SDK.
>
+5 -5
View File
@@ -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<ChainSpec, String> {
.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())
}
+13 -4
View File
@@ -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),
+20 -9
View File
@@ -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<Box<dyn pezsc_service::ChainSpec>, 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::<pezsc_network::NetworkWorker<_, _>>(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),
}
})
+1 -1
View File
@@ -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");
+2 -2
View File
@@ -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");
+8 -8
View File
@@ -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<OpaqueBlock>
+ pezkuwi_sdk::pezsp_api::ProvideRuntimeApi<OpaqueBlock>
+ HeaderBackend<OpaqueBlock>
+ HeaderMetadata<OpaqueBlock, Error = BlockChainError>
+ 'static,
C::Api: pezsp_block_builder::BlockBuilder<OpaqueBlock>,
C::Api: pezframe_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
C::Api: pezkuwi_sdk::pezsp_block_builder::BlockBuilder<OpaqueBlock>,
C::Api: bizinikiwi_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
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;
+7 -6
View File
@@ -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<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>:
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<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>:
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<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>:
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);
+7 -6
View File
@@ -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
//! <https://github.com/pezkuwichain/pezkuwi-sdk>
//! <https://docs.pezkuwichain.io/sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html>
#![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]
+57 -48
View File
@@ -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<Runtime>,
// Checks that the sender is not the zero address.
frame_system::CheckNonZeroSender<Runtime>,
pezframe_system::CheckNonZeroSender<Runtime>,
// Checks that the runtime version is correct.
frame_system::CheckSpecVersion<Runtime>,
pezframe_system::CheckSpecVersion<Runtime>,
// Checks that the transaction version is correct.
frame_system::CheckTxVersion<Runtime>,
pezframe_system::CheckTxVersion<Runtime>,
// Checks that the genesis hash is correct.
frame_system::CheckGenesis<Runtime>,
pezframe_system::CheckGenesis<Runtime>,
// Checks that the era is valid.
frame_system::CheckEra<Runtime>,
pezframe_system::CheckEra<Runtime>,
// Checks that the nonce is valid.
frame_system::CheckNonce<Runtime>,
pezframe_system::CheckNonce<Runtime>,
// Checks that the weight is valid.
frame_system::CheckWeight<Runtime>,
pezframe_system::CheckWeight<Runtime>,
// 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<Runtime>,
// 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<Runtime>,
pezframe_system::WeightReclaim<Runtime>,
);
// 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<Runtime>;
}
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<<Runtime as pezpallet_balances::Config>::Balance>;
type AccountData =
pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::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<Runtime, TxExtension>;
type Header = HeaderFor<Runtime>;
type RuntimeExecutive =
Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem>;
type RuntimeExecutive = Executive<
Runtime,
Block,
pezframe_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
>;
impl_runtime_apis! {
use pezsp_runtime::traits::BlockT;
impl apis::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
fn execute_block(block: <Block as BlockT>::LazyBlock) {
RuntimeExecutive::execute_block(block.into())
fn execute_block(block: <Block as frame::traits::Block>::LazyBlock) {
RuntimeExecutive::execute_block(block)
}
fn initialize_block(header: &Header) -> ExtrinsicInclusionMode {
@@ -227,7 +238,7 @@ impl_runtime_apis! {
}
impl apis::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata()
OpaqueMetadata::new(Runtime::metadata().into())
}
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
@@ -249,16 +260,14 @@ impl_runtime_apis! {
}
fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> {
// TODO: Implement proper inherent extrinsics creation
Vec::new()
data.create_extrinsics()
}
fn check_inherents(
block: <Block as BlockT>::LazyBlock,
block: <Block as frame::traits::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<Runtime>,
block_hash: <Runtime as frame_system::Config>::Hash,
block_hash: <Runtime as pezframe_system::Config>::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 = <Runtime as frame_system::Config>::AccountId;
pub type Nonce = <Runtime as frame_system::Config>::Nonce;
pub type Hash = <Runtime as frame_system::Config>::Hash;
pub type AccountId = <Runtime as pezframe_system::Config>::AccountId;
pub type Nonce = <Runtime as pezframe_system::Config>::Nonce;
pub type Hash = <Runtime as pezframe_system::Config>::Hash;
pub type Balance = <Runtime as pezpallet_balances::Config>::Balance;
pub type MinimumBalance = <Runtime as pezpallet_balances::Config>::ExistentialDeposit;
}