feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
[package]
|
||||
name = "revive-dev-node"
|
||||
description = "A development Bizinikiwi-based Bizinikiwi node, equipped with pezpallet-revive."
|
||||
version = "0.0.0"
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
edition.workspace = true
|
||||
publish = false
|
||||
build = "build.rs"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
clap = { features = ["derive"], workspace = true }
|
||||
docify = { workspace = true }
|
||||
futures = { features = ["thread-pool"], workspace = true }
|
||||
futures-timer = { workspace = true }
|
||||
jsonrpsee = { features = ["server"], workspace = true }
|
||||
|
||||
pezkuwi-sdk = { workspace = true, features = ["experimental", "node"] }
|
||||
revive-dev-runtime = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
pezkuwi-sdk = { workspace = true, features = ["bizinikiwi-build-script-utils"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["pezkuwi-sdk/std", "revive-dev-runtime/std"]
|
||||
runtime-benchmarks = [
|
||||
"pezkuwi-sdk/runtime-benchmarks",
|
||||
"revive-dev-runtime/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use pezkuwi_sdk::bizinikiwi_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
|
||||
|
||||
fn main() {
|
||||
generate_cargo_keys();
|
||||
rerun_if_git_head_changed();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use pezkuwi_sdk::{
|
||||
pezsc_service::{ChainType, Properties},
|
||||
*,
|
||||
};
|
||||
use revive_dev_runtime::WASM_BINARY;
|
||||
|
||||
/// 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(), 12.into());
|
||||
properties.insert("tokenSymbol".to_string(), "MINI".into());
|
||||
properties
|
||||
}
|
||||
|
||||
pub fn development_chain_spec() -> Result<ChainSpec, String> {
|
||||
Ok(ChainSpec::builder(WASM_BINARY.expect("Development wasm not available"), Default::default())
|
||||
.with_name("Development")
|
||||
.with_id("dev")
|
||||
.with_chain_type(ChainType::Development)
|
||||
.with_genesis_config_preset_name(pezsp_genesis_builder::DEV_RUNTIME_PRESET)
|
||||
.with_properties(props())
|
||||
.build())
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use pezkuwi_sdk::{pezsc_cli::RunCmd, *};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Consensus {
|
||||
ManualSeal(u64),
|
||||
InstantSeal,
|
||||
None,
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Consensus {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(if s == "instant-seal" {
|
||||
Consensus::InstantSeal
|
||||
} else if let Some(block_time) = s.strip_prefix("manual-seal-") {
|
||||
Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?)
|
||||
} else if s.to_lowercase() == "none" {
|
||||
Consensus::None
|
||||
} else {
|
||||
return Err("incorrect consensus identifier".into());
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, clap::Parser)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub subcommand: Option<Subcommand>,
|
||||
|
||||
#[clap(long, default_value = "instant-seal")]
|
||||
pub consensus: Consensus,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub run: RunCmd,
|
||||
}
|
||||
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
pub enum Subcommand {
|
||||
/// Key management cli utilities
|
||||
#[command(subcommand)]
|
||||
Key(pezsc_cli::KeySubcommand),
|
||||
|
||||
/// Build a chain specification.
|
||||
BuildSpec(pezsc_cli::BuildSpecCmd),
|
||||
|
||||
/// Validate blocks.
|
||||
CheckBlock(pezsc_cli::CheckBlockCmd),
|
||||
|
||||
/// Export blocks.
|
||||
ExportBlocks(pezsc_cli::ExportBlocksCmd),
|
||||
|
||||
/// Export the chain specification.
|
||||
ExportChainSpec(pezsc_cli::ExportChainSpecCmd),
|
||||
|
||||
/// Export the state of a given block into a chain spec.
|
||||
ExportState(pezsc_cli::ExportStateCmd),
|
||||
|
||||
/// Import blocks.
|
||||
ImportBlocks(pezsc_cli::ImportBlocksCmd),
|
||||
|
||||
/// Remove the whole chain.
|
||||
PurgeChain(pezsc_cli::PurgeChainCmd),
|
||||
|
||||
/// Revert the chain to a previous state.
|
||||
Revert(pezsc_cli::RevertCmd),
|
||||
|
||||
/// Db meta columns information.
|
||||
ChainInfo(pezsc_cli::ChainInfoCmd),
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{
|
||||
chain_spec,
|
||||
cli::{Cli, Subcommand},
|
||||
service,
|
||||
};
|
||||
use pezkuwi_sdk::{pezsc_cli::BizinikiwiCli, pezsc_service::PartialComponents, *};
|
||||
|
||||
impl BizinikiwiCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
"Bizinikiwi Node".into()
|
||||
}
|
||||
|
||||
fn impl_version() -> String {
|
||||
env!("BIZINIKIWI_CLI_IMPL_VERSION").into()
|
||||
}
|
||||
|
||||
fn description() -> String {
|
||||
env!("CARGO_PKG_DESCRIPTION").into()
|
||||
}
|
||||
|
||||
fn author() -> String {
|
||||
env!("CARGO_PKG_AUTHORS").into()
|
||||
}
|
||||
|
||||
fn support_url() -> String {
|
||||
"support.anonymous.an".into()
|
||||
}
|
||||
|
||||
fn copyright_start_year() -> i32 {
|
||||
2017
|
||||
}
|
||||
|
||||
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))?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run() -> pezsc_cli::Result<()> {
|
||||
let args = std::env::args_os().map(|s| s.to_string_lossy().to_string()).collect::<Vec<_>>();
|
||||
return run_with_args(args);
|
||||
}
|
||||
|
||||
/// Parse and run command line arguments
|
||||
pub fn run_with_args(args: Vec<String>) -> pezsc_cli::Result<()> {
|
||||
let mut cli = Cli::from_iter(args);
|
||||
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
},
|
||||
Some(Subcommand::CheckBlock(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents { client, task_manager, import_queue, .. } =
|
||||
service::new_partial(&config)?;
|
||||
Ok((cmd.run(client, import_queue), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?;
|
||||
Ok((cmd.run(client, config.database), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::ExportChainSpec(cmd)) => {
|
||||
let chain_spec = cli.load_spec(&cmd.chain)?;
|
||||
cmd.run(chain_spec)
|
||||
},
|
||||
Some(Subcommand::ExportState(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?;
|
||||
Ok((cmd.run(client, config.chain_spec), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::ImportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents { client, task_manager, import_queue, .. } =
|
||||
service::new_partial(&config)?;
|
||||
Ok((cmd.run(client, import_queue), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::PurgeChain(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.database))
|
||||
},
|
||||
Some(Subcommand::Revert(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
let PartialComponents { client, task_manager, backend, .. } =
|
||||
service::new_partial(&config)?;
|
||||
Ok((cmd.run(client, backend, None), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::ChainInfo(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run::<revive_dev_runtime::OpaqueBlock>(&config))
|
||||
},
|
||||
None => {
|
||||
// Enforce dev
|
||||
cli.run.shared_params.dev = true;
|
||||
|
||||
// Pass Default logging settings if none are specified
|
||||
if std::env::var("RUST_LOG").is_err() && cli.run.shared_params.log.is_empty() {
|
||||
cli.run.shared_params.log = "error,pezsc_rpc_server=info,runtime::revive=debug"
|
||||
.split(',')
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
}
|
||||
|
||||
// Enforce single-state pool-type if instant-seal is selected
|
||||
if matches!(cli.consensus, crate::cli::Consensus::InstantSeal) {
|
||||
cli.run.pool_config.pool_type = pezsc_cli::TransactionPoolType::SingleState
|
||||
}
|
||||
let runner = cli.create_runner(&cli.run)?;
|
||||
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
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)
|
||||
.map_err(pezsc_cli::Error::Service),
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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.
|
||||
|
||||
pub mod chain_spec;
|
||||
pub(crate) mod cli;
|
||||
pub mod command;
|
||||
pub mod rpc;
|
||||
pub mod service;
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
//! Bizinikiwi Node Template CLI library.
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod chain_spec;
|
||||
mod cli;
|
||||
mod command;
|
||||
mod rpc;
|
||||
mod service;
|
||||
|
||||
fn main() -> pezkuwi_sdk::pezsc_cli::Result<()> {
|
||||
command::run()
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// 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 collection of node-specific RPC methods.
|
||||
//! 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)]
|
||||
|
||||
use crate::cli::Consensus;
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc, RpcModule};
|
||||
use pezkuwi_sdk::{
|
||||
pezsc_transaction_pool_api::TransactionPool,
|
||||
pezsp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata},
|
||||
*,
|
||||
};
|
||||
use revive_dev_runtime::{AccountId, Nonce, OpaqueBlock};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Full client dependencies.
|
||||
pub struct FullDeps<C, P> {
|
||||
/// The client instance to use.
|
||||
pub client: Arc<C>,
|
||||
/// Transaction pool instance.
|
||||
pub pool: Arc<P>,
|
||||
/// The consensus type of the node.
|
||||
pub consensus: Consensus,
|
||||
}
|
||||
|
||||
/// AutoMine JSON-RPC api.
|
||||
/// Automine is a feature of the Hardhat Network where a new block is automatically mined after each
|
||||
/// transaction.
|
||||
#[rpc(server, client)]
|
||||
pub trait AutoMineRpc {
|
||||
/// API to get the automine status.
|
||||
#[method(name = "getAutomine")]
|
||||
fn get_automine(&self) -> RpcResult<bool>;
|
||||
}
|
||||
|
||||
/// Implementation of the AutoMine RPC api.
|
||||
pub struct AutoMineRpcImpl {
|
||||
/// Whether the node is running in auto-mine mode.
|
||||
is_auto_mine: bool,
|
||||
}
|
||||
|
||||
impl AutoMineRpcImpl {
|
||||
/// Create new `AutoMineRpcImpl` instance.
|
||||
pub fn new(consensus: Consensus) -> Self {
|
||||
Self { is_auto_mine: matches!(consensus, Consensus::InstantSeal) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AutoMineRpcServer for AutoMineRpcImpl {
|
||||
/// Returns `true` if block production is set to `instant`.
|
||||
fn get_automine(&self) -> RpcResult<bool> {
|
||||
Ok(self.is_auto_mine)
|
||||
}
|
||||
}
|
||||
|
||||
#[docify::export]
|
||||
/// Instantiate all full RPC extensions.
|
||||
pub fn create_full<C, P>(
|
||||
deps: FullDeps<C, P>,
|
||||
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
|
||||
where
|
||||
C: Send
|
||||
+ Sync
|
||||
+ 'static
|
||||
+ pezsp_api::ProvideRuntimeApi<OpaqueBlock>
|
||||
+ HeaderBackend<OpaqueBlock>
|
||||
+ HeaderMetadata<OpaqueBlock, Error = BlockChainError>
|
||||
+ 'static,
|
||||
C::Api: pezsp_block_builder::BlockBuilder<OpaqueBlock>,
|
||||
C::Api: bizinikiwi_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
|
||||
P: TransactionPool + 'static,
|
||||
{
|
||||
use pezkuwi_sdk::bizinikiwi_frame_rpc_system::{System, SystemApiServer};
|
||||
let mut module = RpcModule::new(());
|
||||
let FullDeps { client, pool, consensus } = deps;
|
||||
|
||||
module.merge(AutoMineRpcImpl::new(consensus).into_rpc())?;
|
||||
module.merge(System::new(client.clone(), pool.clone()).into_rpc())?;
|
||||
|
||||
Ok(module)
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::cli::Consensus;
|
||||
use pezkuwi_sdk::{
|
||||
pezsc_client_api::StorageProvider,
|
||||
pezsc_executor::WasmExecutor,
|
||||
pezsc_service::{error::Error as ServiceError, Configuration, TaskManager},
|
||||
pezsc_telemetry::{Telemetry, TelemetryWorker},
|
||||
pezsp_runtime::traits::Block as BlockT,
|
||||
*,
|
||||
};
|
||||
use revive_dev_runtime::{OpaqueBlock as Block, Runtime, RuntimeApi};
|
||||
use std::sync::Arc;
|
||||
|
||||
type HostFunctions = pezsp_io::BizinikiwiHostFunctions;
|
||||
|
||||
#[docify::export]
|
||||
pub(crate) type FullClient =
|
||||
pezsc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
|
||||
|
||||
type FullBackend = pezsc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = pezsc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
/// Assembly of PartialComponents (enough to run chain ops subcommands)
|
||||
pub type Service = pezsc_service::PartialComponents<
|
||||
FullClient,
|
||||
FullBackend,
|
||||
FullSelectChain,
|
||||
pezsc_consensus::DefaultImportQueue<Block>,
|
||||
pezsc_transaction_pool::TransactionPoolHandle<Block, FullClient>,
|
||||
Option<Telemetry>,
|
||||
>;
|
||||
|
||||
pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||
let telemetry = config
|
||||
.telemetry_endpoints
|
||||
.clone()
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|endpoints| -> Result<_, pezsc_telemetry::Error> {
|
||||
let worker = TelemetryWorker::new(16)?;
|
||||
let telemetry = worker.handle().new_telemetry(endpoints);
|
||||
Ok((worker, telemetry))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
let executor = pezsc_service::new_wasm_executor(&config.executor);
|
||||
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
pezsc_service::new_full_parts::<Block, RuntimeApi, _>(
|
||||
config,
|
||||
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
||||
executor,
|
||||
)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
let telemetry = telemetry.map(|(worker, telemetry)| {
|
||||
task_manager.spawn_handle().spawn("telemetry", None, worker.run());
|
||||
telemetry
|
||||
});
|
||||
|
||||
let select_chain = pezsc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let transaction_pool = Arc::from(
|
||||
pezsc_transaction_pool::Builder::new(
|
||||
task_manager.spawn_essential_handle(),
|
||||
client.clone(),
|
||||
config.role.is_authority().into(),
|
||||
)
|
||||
.with_options(config.transaction_pool.clone())
|
||||
.build(),
|
||||
);
|
||||
|
||||
let import_queue = pezsc_consensus_manual_seal::import_queue(
|
||||
Box::new(client.clone()),
|
||||
&task_manager.spawn_essential_handle(),
|
||||
None,
|
||||
);
|
||||
|
||||
Ok(pezsc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
task_manager,
|
||||
import_queue,
|
||||
keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
other: (telemetry),
|
||||
})
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>::Hash>>(
|
||||
config: Configuration,
|
||||
consensus: Consensus,
|
||||
) -> Result<TaskManager, ServiceError> {
|
||||
let pezsc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
mut task_manager,
|
||||
import_queue,
|
||||
keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
other: mut telemetry,
|
||||
} = new_partial(&config)?;
|
||||
|
||||
let net_config = pezsc_network::config::FullNetworkConfiguration::<
|
||||
Block,
|
||||
<Block as BlockT>::Hash,
|
||||
Network,
|
||||
>::new(&config.network, None);
|
||||
let metrics = Network::register_notification_metrics(None);
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, sync_service) =
|
||||
pezsc_service::build_network(pezsc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
net_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
block_announce_validator_builder: None,
|
||||
warp_sync_config: None,
|
||||
block_relay: None,
|
||||
metrics,
|
||||
})?;
|
||||
|
||||
let rpc_extensions_builder = {
|
||||
let client = client.clone();
|
||||
let pool = transaction_pool.clone();
|
||||
|
||||
Box::new(move |_| {
|
||||
let deps =
|
||||
crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), consensus };
|
||||
crate::rpc::create_full(deps).map_err(Into::into)
|
||||
})
|
||||
};
|
||||
|
||||
let _rpc_handlers = pezsc_service::spawn_tasks(pezsc_service::SpawnTasksParams {
|
||||
network,
|
||||
client: client.clone(),
|
||||
keystore: keystore_container.keystore(),
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
rpc_builder: rpc_extensions_builder,
|
||||
backend,
|
||||
system_rpc_tx,
|
||||
tx_handler_controller,
|
||||
sync_service,
|
||||
config,
|
||||
telemetry: telemetry.as_mut(),
|
||||
tracing_execute_block: None,
|
||||
})?;
|
||||
|
||||
let proposer = pezsc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool.clone(),
|
||||
None,
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
);
|
||||
|
||||
// Due to instant seal or low block time multiple blocks can have the same timestamp.
|
||||
// This is because Etereum only uses second granularity (as opposed to ms).
|
||||
// Here we make sure that we increment by at least a second from the last block.
|
||||
//
|
||||
// # Warning
|
||||
//
|
||||
// This will lead to blocks with timestamps in the future. This might cause other issues
|
||||
// when dealing with off chain data. But for a development node it is more important to not
|
||||
// have duplicate timestamps. The only way to not have timestamps in the future and no
|
||||
// duplicates is to set the block time to at least one second (`--consensus manual-seal-1000`).
|
||||
let timestamp_provider = {
|
||||
let client = client.clone();
|
||||
move |parent, ()| {
|
||||
let client = client.clone();
|
||||
async move {
|
||||
let key = pezsp_core::storage::StorageKey(
|
||||
pezkuwi_sdk::pezpallet_timestamp::Now::<Runtime>::hashed_key().to_vec(),
|
||||
);
|
||||
let current = pezsp_timestamp::Timestamp::current();
|
||||
let next = client
|
||||
.storage(parent, &key)
|
||||
.ok()
|
||||
.flatten()
|
||||
.and_then(|data| data.0.try_into().ok())
|
||||
.map(|data| {
|
||||
let last = u64::from_le_bytes(data) / 1000;
|
||||
pezsp_timestamp::Timestamp::new((last + 1) * 1000)
|
||||
})
|
||||
.unwrap_or(current);
|
||||
Ok(pezsp_timestamp::InherentDataProvider::new(current.max(next)))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
match consensus {
|
||||
Consensus::InstantSeal => {
|
||||
let params = pezsc_consensus_manual_seal::InstantSealParams {
|
||||
block_import: client.clone(),
|
||||
env: proposer,
|
||||
client,
|
||||
pool: transaction_pool,
|
||||
select_chain,
|
||||
consensus_data_provider: None,
|
||||
create_inherent_data_providers: timestamp_provider,
|
||||
};
|
||||
|
||||
let authorship_future = pezsc_consensus_manual_seal::run_instant_seal_and_finalize(params);
|
||||
|
||||
task_manager.spawn_essential_handle().spawn_blocking(
|
||||
"instant-seal",
|
||||
None,
|
||||
authorship_future,
|
||||
);
|
||||
},
|
||||
Consensus::ManualSeal(block_time) => {
|
||||
let (mut sink, commands_stream) = futures::channel::mpsc::channel(1024);
|
||||
task_manager.spawn_handle().spawn("block_authoring", None, async move {
|
||||
loop {
|
||||
futures_timer::Delay::new(std::time::Duration::from_millis(block_time)).await;
|
||||
sink.try_send(pezsc_consensus_manual_seal::EngineCommand::SealNewBlock {
|
||||
create_empty: true,
|
||||
finalize: true,
|
||||
parent_hash: None,
|
||||
sender: None,
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
});
|
||||
|
||||
let params = pezsc_consensus_manual_seal::ManualSealParams {
|
||||
block_import: client.clone(),
|
||||
env: proposer,
|
||||
client,
|
||||
pool: transaction_pool,
|
||||
select_chain,
|
||||
commands_stream: Box::pin(commands_stream),
|
||||
consensus_data_provider: None,
|
||||
create_inherent_data_providers: timestamp_provider,
|
||||
};
|
||||
let authorship_future = pezsc_consensus_manual_seal::run_manual_seal(params);
|
||||
|
||||
task_manager.spawn_essential_handle().spawn_blocking(
|
||||
"manual-seal",
|
||||
None,
|
||||
authorship_future,
|
||||
);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
Ok(task_manager)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
[package]
|
||||
name = "revive-dev-runtime"
|
||||
description = "A solochain dev runtime for revive."
|
||||
version = "0.1.0"
|
||||
license = "Apache-2.0"
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
array-bytes = { workspace = true }
|
||||
codec = { workspace = true }
|
||||
pezkuwi-sdk = { workspace = true, features = [
|
||||
"pezpallet-balances",
|
||||
"pezpallet-revive",
|
||||
"pezpallet-sudo",
|
||||
"pezpallet-timestamp",
|
||||
"pezpallet-transaction-payment",
|
||||
"pezpallet-transaction-payment-rpc-runtime-api",
|
||||
"pezkuwi-runtime-common",
|
||||
"runtime",
|
||||
"teyrchains-common",
|
||||
"with-tracing",
|
||||
] }
|
||||
scale-info = { workspace = true }
|
||||
serde_json = { workspace = true, default-features = false, features = [
|
||||
"alloc",
|
||||
] }
|
||||
pezsp-debug-derive = { workspace = true, features = ["force-debug"] }
|
||||
|
||||
[build-dependencies]
|
||||
pezkuwi-sdk = { optional = true, workspace = true, features = [
|
||||
"bizinikiwi-wasm-builder",
|
||||
] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezkuwi-sdk/std",
|
||||
"scale-info/std",
|
||||
"serde_json/std",
|
||||
"pezsp-debug-derive/std",
|
||||
]
|
||||
runtime-benchmarks = ["pezkuwi-sdk/runtime-benchmarks"]
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
fn main() {
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
pezkuwi_sdk::bizinikiwi_wasm_builder::WasmBuilder::build_using_defaults();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
// 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.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
use currency::*;
|
||||
use pezframe_support::weights::{
|
||||
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND},
|
||||
Weight,
|
||||
};
|
||||
use pezframe_system::limits::BlockWeights;
|
||||
use pezpallet_revive::{
|
||||
evm::{
|
||||
fees::{BlockRatioFee, Info as FeeInfo},
|
||||
runtime::EthExtra,
|
||||
},
|
||||
AccountId32Mapper,
|
||||
};
|
||||
use pezpallet_transaction_payment::{ConstFeeMultiplier, FeeDetails, Multiplier, RuntimeDispatchInfo};
|
||||
use pezkuwi_sdk::{
|
||||
pezkuwi_sdk_frame::{
|
||||
deps::pezsp_genesis_builder,
|
||||
runtime::{apis, prelude::*},
|
||||
traits::Block as BlockT,
|
||||
},
|
||||
*,
|
||||
};
|
||||
use pezsp_weights::ConstantMultiplier;
|
||||
|
||||
pub use pezkuwi_sdk::{
|
||||
pezkuwi_sdk_frame::runtime::types_common::OpaqueBlock,
|
||||
teyrchains_common::{AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature},
|
||||
};
|
||||
|
||||
pub mod currency {
|
||||
use super::Balance;
|
||||
pub const DOLLARS: Balance = 1_000_000_000_000;
|
||||
pub const CENTS: Balance = DOLLARS / 100;
|
||||
pub const MILLICENTS: Balance = CENTS / 1_000;
|
||||
}
|
||||
|
||||
/// Provides getters for genesis configuration presets.
|
||||
pub mod genesis_config_presets {
|
||||
use super::*;
|
||||
use crate::{
|
||||
currency::DOLLARS, pezsp_keyring::Sr25519Keyring, Balance, BalancesConfig,
|
||||
RuntimeGenesisConfig, SudoConfig,
|
||||
};
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
use serde_json::Value;
|
||||
|
||||
pub const ENDOWMENT: Balance = 1_000_000_001 * DOLLARS;
|
||||
|
||||
fn well_known_accounts() -> Vec<AccountId> {
|
||||
Sr25519Keyring::well_known()
|
||||
.map(|k| k.to_account_id())
|
||||
.chain([
|
||||
// subxt_signer::eth::dev::alith()
|
||||
array_bytes::hex_n_into_unchecked(
|
||||
"f24ff3a9cf04c71dbc94d0b566f7a27b94566caceeeeeeeeeeeeeeeeeeeeeeee",
|
||||
),
|
||||
// subxt_signer::eth::dev::baltathar()
|
||||
array_bytes::hex_n_into_unchecked(
|
||||
"3cd0a705a2dc65e5b1e1205896baa2be8a07c6e0eeeeeeeeeeeeeeeeeeeeeeee",
|
||||
),
|
||||
// subxt_signer::eth::dev::charleth()
|
||||
array_bytes::hex_n_into_unchecked(
|
||||
"798d4ba9baf0064ec19eb4f0a1a45785ae9d6dfceeeeeeeeeeeeeeeeeeeeeeee",
|
||||
),
|
||||
// subxt_signer::eth::dev::dorothy()
|
||||
array_bytes::hex_n_into_unchecked(
|
||||
"773539d4ac0e786233d90a233654ccee26a613d9eeeeeeeeeeeeeeeeeeeeeeee",
|
||||
),
|
||||
// subxt_signer::eth::dev::ethan()
|
||||
array_bytes::hex_n_into_unchecked(
|
||||
"ff64d3f6efe2317ee2807d223a0bdc4c0c49dfdbeeeeeeeeeeeeeeeeeeeeeeee",
|
||||
),
|
||||
])
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
/// Returns a development genesis config preset.
|
||||
pub fn development_config_genesis() -> Value {
|
||||
pezframe_support::build_struct_json_patch!(RuntimeGenesisConfig {
|
||||
balances: BalancesConfig {
|
||||
balances: well_known_accounts()
|
||||
.into_iter()
|
||||
.map(|id| (id, ENDOWMENT))
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
sudo: SudoConfig { key: Some(Sr25519Keyring::Alice.to_account_id()) },
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the set of the available genesis config presets.
|
||||
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
|
||||
let patch = match id.as_ref() {
|
||||
pezsp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(),
|
||||
_ => return None,
|
||||
};
|
||||
Some(
|
||||
serde_json::to_string(&patch)
|
||||
.expect("serialization to json is expected to work. qed.")
|
||||
.into_bytes(),
|
||||
)
|
||||
}
|
||||
|
||||
/// List of supported presets.
|
||||
pub fn preset_names() -> Vec<PresetId> {
|
||||
vec![PresetId::from(pezsp_genesis_builder::DEV_RUNTIME_PRESET)]
|
||||
}
|
||||
}
|
||||
|
||||
/// The runtime version.
|
||||
#[runtime_version]
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: alloc::borrow::Cow::Borrowed("revive-dev-runtime"),
|
||||
impl_name: alloc::borrow::Cow::Borrowed("revive-dev-runtime"),
|
||||
authoring_version: 1,
|
||||
spec_version: 0,
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 1,
|
||||
system_version: 1,
|
||||
};
|
||||
|
||||
/// The version information used to identify this runtime when compiled natively.
|
||||
#[cfg(feature = "std")]
|
||||
pub fn native_version() -> NativeVersion {
|
||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||
}
|
||||
|
||||
/// The address format for describing accounts.
|
||||
pub type Address = pezsp_runtime::MultiAddress<AccountId, ()>;
|
||||
/// Block type as expected by this runtime.
|
||||
pub type Block = pezsp_runtime::generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// The transaction extensions that are added to the runtime.
|
||||
type TxExtension = (
|
||||
// Checks that the sender is not the zero address.
|
||||
pezframe_system::CheckNonZeroSender<Runtime>,
|
||||
// Checks that the runtime version is correct.
|
||||
pezframe_system::CheckSpecVersion<Runtime>,
|
||||
// Checks that the transaction version is correct.
|
||||
pezframe_system::CheckTxVersion<Runtime>,
|
||||
// Checks that the genesis hash is correct.
|
||||
pezframe_system::CheckGenesis<Runtime>,
|
||||
// Checks that the era is valid.
|
||||
pezframe_system::CheckEra<Runtime>,
|
||||
// Checks that the nonce is valid.
|
||||
pezframe_system::CheckNonce<Runtime>,
|
||||
// Checks that the weight is valid.
|
||||
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>,
|
||||
// Needs to be done after all extensions that rely on a signed origin.
|
||||
pezpallet_revive::evm::tx_extension::SetOrigin<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
|
||||
pezframe_system::WeightReclaim<Runtime>,
|
||||
);
|
||||
|
||||
/// Default extensions applied to Ethereum transactions.
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct EthExtraImpl;
|
||||
|
||||
impl EthExtra for EthExtraImpl {
|
||||
type Config = Runtime;
|
||||
type Extension = TxExtension;
|
||||
|
||||
fn get_eth_extension(nonce: u32, tip: Balance) -> Self::Extension {
|
||||
(
|
||||
pezframe_system::CheckNonZeroSender::<Runtime>::new(),
|
||||
pezframe_system::CheckSpecVersion::<Runtime>::new(),
|
||||
pezframe_system::CheckTxVersion::<Runtime>::new(),
|
||||
pezframe_system::CheckGenesis::<Runtime>::new(),
|
||||
pezframe_system::CheckMortality::from(pezsp_runtime::generic::Era::Immortal),
|
||||
pezframe_system::CheckNonce::<Runtime>::from(nonce),
|
||||
pezframe_system::CheckWeight::<Runtime>::new(),
|
||||
pezpallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
pezpallet_revive::evm::tx_extension::SetOrigin::<Runtime>::new_from_eth_transaction(),
|
||||
pezframe_system::WeightReclaim::<Runtime>::new(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub type UncheckedExtrinsic =
|
||||
pezpallet_revive::evm::runtime::UncheckedExtrinsic<Address, Signature, EthExtraImpl>;
|
||||
|
||||
type Executive = pezframe_executive::Executive<
|
||||
Runtime,
|
||||
Block,
|
||||
pezframe_system::ChainContext<Runtime>,
|
||||
Runtime,
|
||||
AllPalletsWithSystem,
|
||||
>;
|
||||
|
||||
// Composes the runtime by adding all the used pallets and deriving necessary types.
|
||||
#[frame_construct_runtime]
|
||||
mod runtime {
|
||||
/// The main runtime type.
|
||||
#[runtime::runtime]
|
||||
#[runtime::derive(
|
||||
RuntimeCall,
|
||||
RuntimeEvent,
|
||||
RuntimeError,
|
||||
RuntimeOrigin,
|
||||
RuntimeFreezeReason,
|
||||
RuntimeHoldReason,
|
||||
RuntimeSlashReason,
|
||||
RuntimeLockId,
|
||||
RuntimeTask,
|
||||
RuntimeViewFunction
|
||||
)]
|
||||
pub struct Runtime;
|
||||
|
||||
/// Mandatory system pallet that should always be included in a FRAME runtime.
|
||||
#[runtime::pezpallet_index(0)]
|
||||
pub type System = pezframe_system::Pallet<Runtime>;
|
||||
|
||||
/// Provides a way for consensus systems to set and check the onchain time.
|
||||
#[runtime::pezpallet_index(1)]
|
||||
pub type Timestamp = pezpallet_timestamp::Pallet<Runtime>;
|
||||
|
||||
/// Provides the ability to keep track of balances.
|
||||
#[runtime::pezpallet_index(2)]
|
||||
pub type Balances = pezpallet_balances::Pallet<Runtime>;
|
||||
|
||||
/// Provides a way to execute privileged functions.
|
||||
#[runtime::pezpallet_index(3)]
|
||||
pub type Sudo = pezpallet_sudo::Pallet<Runtime>;
|
||||
|
||||
/// Provides the ability to charge for extrinsic execution.
|
||||
#[runtime::pezpallet_index(4)]
|
||||
pub type TransactionPayment = pezpallet_transaction_payment::Pallet<Runtime>;
|
||||
|
||||
/// Provides the ability to execute Smart Contracts.
|
||||
#[runtime::pezpallet_index(5)]
|
||||
pub type Revive = pezpallet_revive::Pallet<Runtime>;
|
||||
}
|
||||
|
||||
/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
|
||||
/// This is used to limit the maximal weight of a single extrinsic.
|
||||
const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
||||
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
|
||||
/// by Operational extrinsics.
|
||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||
/// We allow for 2 seconds of compute with a 6 second average block time, with maximum proof size.
|
||||
const MAXIMUM_BLOCK_WEIGHT: Weight =
|
||||
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX);
|
||||
|
||||
parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
|
||||
.base_block(BlockExecutionWeight::get())
|
||||
.for_class(DispatchClass::all(), |weights| {
|
||||
weights.base_extrinsic = ExtrinsicBaseWeight::get();
|
||||
})
|
||||
.for_class(DispatchClass::Normal, |weights| {
|
||||
weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
|
||||
})
|
||||
.for_class(DispatchClass::Operational, |weights| {
|
||||
weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
|
||||
// Operational transactions have some extra reserved space, so that they
|
||||
// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
|
||||
weights.reserved = Some(
|
||||
MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
|
||||
);
|
||||
})
|
||||
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
|
||||
.build_or_panic();
|
||||
}
|
||||
|
||||
/// Implements the types required for the system pallet.
|
||||
#[derive_impl(pezframe_system::config_preludes::SolochainDefaultConfig)]
|
||||
impl pezframe_system::Config for Runtime {
|
||||
type Block = Block;
|
||||
type Version = Version;
|
||||
type AccountId = AccountId;
|
||||
type Hash = Hash;
|
||||
type Nonce = Nonce;
|
||||
type AccountData = pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::Balance>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = CENTS;
|
||||
}
|
||||
|
||||
// Implements the types required for the balances pallet.
|
||||
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_balances::Config for Runtime {
|
||||
type AccountStore = System;
|
||||
type Balance = Balance;
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
}
|
||||
|
||||
// Implements the types required for the sudo pallet.
|
||||
#[derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_sudo::Config for Runtime {}
|
||||
|
||||
// Implements the types required for the sudo pallet.
|
||||
#[derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_timestamp::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
|
||||
pub FeeMultiplier: Multiplier = Multiplier::one();
|
||||
}
|
||||
|
||||
// Implements the types required for the transaction payment pallet.
|
||||
#[derive_impl(pezpallet_transaction_payment::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = pezpallet_transaction_payment::FungibleAdapter<Balances, ()>;
|
||||
type WeightToFee = BlockRatioFee<1, 1, Self>;
|
||||
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
|
||||
type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_revive::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_revive::Config for Runtime {
|
||||
type AddressMapper = AccountId32Mapper<Self>;
|
||||
type ChainId = ConstU64<420_420_420>;
|
||||
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
|
||||
type Balance = Balance;
|
||||
type Currency = Balances;
|
||||
type NativeToEthRatio = ConstU32<1_000_000>;
|
||||
type UploadOrigin = EnsureSigned<Self::AccountId>;
|
||||
type InstantiateOrigin = EnsureSigned<Self::AccountId>;
|
||||
type Time = Timestamp;
|
||||
type FeeInfo = FeeInfo<Address, Signature, EthExtraImpl>;
|
||||
type DebugEnabled = ConstBool<false>;
|
||||
}
|
||||
|
||||
pezpallet_revive::impl_runtime_apis_plus_revive_traits!(
|
||||
Runtime,
|
||||
Revive,
|
||||
Executive,
|
||||
EthExtraImpl,
|
||||
|
||||
impl apis::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
}
|
||||
|
||||
fn execute_block(block: <Block as BlockT>::LazyBlock) {
|
||||
Executive::execute_block(block)
|
||||
}
|
||||
|
||||
fn initialize_block(header: &Header) -> ExtrinsicInclusionMode {
|
||||
Executive::initialize_block(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::Metadata<Block> for Runtime {
|
||||
fn metadata() -> OpaqueMetadata {
|
||||
OpaqueMetadata::new(Runtime::metadata().into())
|
||||
}
|
||||
|
||||
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
|
||||
Runtime::metadata_at_version(version)
|
||||
}
|
||||
|
||||
fn metadata_versions() -> Vec<u32> {
|
||||
Runtime::metadata_versions()
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: ExtrinsicFor<Runtime>) -> ApplyExtrinsicResult {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
|
||||
fn finalize_block() -> HeaderFor<Runtime> {
|
||||
Executive::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
fn check_inherents(
|
||||
block: <Block as BlockT>::LazyBlock,
|
||||
data: InherentData,
|
||||
) -> CheckInherentsResult {
|
||||
data.check_extrinsics(&block)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: TransactionSource,
|
||||
tx: ExtrinsicFor<Runtime>,
|
||||
block_hash: <Runtime as pezframe_system::Config>::Hash,
|
||||
) -> TransactionValidity {
|
||||
Executive::validate_transaction(source, tx, block_hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(header: &HeaderFor<Runtime>) {
|
||||
Executive::offchain_worker(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::SessionKeys<Block> for Runtime {
|
||||
fn generate_session_keys(_seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn decode_session_keys(
|
||||
_encoded: Vec<u8>,
|
||||
) -> Option<Vec<(Vec<u8>, apis::KeyTypeId)>> {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
|
||||
fn account_nonce(account: AccountId) -> Nonce {
|
||||
System::account_nonce(account)
|
||||
}
|
||||
}
|
||||
|
||||
impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
|
||||
Block,
|
||||
Balance,
|
||||
> for Runtime {
|
||||
fn query_info(uxt: ExtrinsicFor<Runtime>, len: u32) -> RuntimeDispatchInfo<Balance> {
|
||||
TransactionPayment::query_info(uxt, len)
|
||||
}
|
||||
fn query_fee_details(uxt: ExtrinsicFor<Runtime>, len: u32) -> FeeDetails<Balance> {
|
||||
TransactionPayment::query_fee_details(uxt, len)
|
||||
}
|
||||
fn query_weight_to_fee(weight: Weight) -> Balance {
|
||||
TransactionPayment::weight_to_fee(weight)
|
||||
}
|
||||
fn query_length_to_fee(length: u32) -> Balance {
|
||||
TransactionPayment::length_to_fee(length)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::GenesisBuilder<Block> for Runtime {
|
||||
fn build_state(config: Vec<u8>) -> pezsp_genesis_builder::Result {
|
||||
build_state::<RuntimeGenesisConfig>(config)
|
||||
}
|
||||
|
||||
fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
|
||||
get_preset::<RuntimeGenesisConfig>(id, self::genesis_config_presets::get_preset)
|
||||
}
|
||||
|
||||
fn preset_names() -> Vec<PresetId> {
|
||||
self::genesis_config_presets::preset_names()
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user