mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 23:28:00 +00:00
8ba7a6aba8
This PR prepares chains specs for _native-runtime-free_ world. This PR has following changes: - `substrate`: - adds support for: - JSON based `GenesisConfig` to `ChainSpec` allowing interaction with runtime `GenesisBuilder` API. - interacting with arbitrary runtime wasm blob to[ `chain-spec-builder`](https://github.com/paritytech/substrate/blob/3ef576eaeb3f42610e85daecc464961cf1295570/bin/utils/chain-spec-builder/src/lib.rs#L46) command line util, - removes [`code`](https://github.com/paritytech/substrate/blob/3ef576eaeb3f42610e85daecc464961cf1295570/frame/system/src/lib.rs#L660) from `system_pallet` - adds `code` to the `ChainSpec` - deprecates [`ChainSpec::from_genesis`](https://github.com/paritytech/substrate/blob/3ef576eaeb3f42610e85daecc464961cf1295570/client/chain-spec/src/chain_spec.rs#L263), but also changes the signature of this method extending it with `code` argument. [`ChainSpec::builder()`](https://github.com/paritytech/substrate/blob/20bee680ed098be7239cf7a6b804cd4de267983e/client/chain-spec/src/chain_spec.rs#L507) should be used instead. - `polkadot`: - all references to `RuntimeGenesisConfig` in `node/service` are removed, - all `(kusama|polkadot|versi|rococo|wococo)_(staging|dev)_genesis_config` functions now return the JSON patch for default runtime `GenesisConfig`, - `ChainSpecBuilder` is used, `ChainSpec::from_genesis` is removed, - `cumulus`: - `ChainSpecBuilder` is used, `ChainSpec::from_genesis` is removed, - _JSON_ patch configuration used instead of `RuntimeGenesisConfig struct` in all chain specs. --------- Co-authored-by: command-bot <> Co-authored-by: Javier Viola <javier@parity.io> Co-authored-by: Davide Galassi <davxy@datawok.net> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Kevin Krone <kevin@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
79 lines
2.3 KiB
Rust
79 lines
2.3 KiB
Rust
// This file is part of Substrate.
|
|
|
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
//! Utilities to build a `TestClient` for `kitchensink-runtime`.
|
|
|
|
use sp_runtime::BuildStorage;
|
|
/// Re-export test-client utilities.
|
|
pub use substrate_test_client::*;
|
|
|
|
/// Call executor for `kitchensink-runtime` `TestClient`.
|
|
pub type ExecutorDispatch = sc_executor::NativeElseWasmExecutor<node_executor::ExecutorDispatch>;
|
|
|
|
/// Default backend type.
|
|
pub type Backend = sc_client_db::Backend<node_primitives::Block>;
|
|
|
|
/// Test client type.
|
|
pub type Client = client::Client<
|
|
Backend,
|
|
client::LocalCallExecutor<node_primitives::Block, Backend, ExecutorDispatch>,
|
|
node_primitives::Block,
|
|
kitchensink_runtime::RuntimeApi,
|
|
>;
|
|
|
|
/// Genesis configuration parameters for `TestClient`.
|
|
#[derive(Default)]
|
|
pub struct GenesisParameters;
|
|
|
|
impl substrate_test_client::GenesisInit for GenesisParameters {
|
|
fn genesis_storage(&self) -> Storage {
|
|
let mut storage = crate::genesis::config().build_storage().unwrap();
|
|
storage.top.insert(
|
|
sp_core::storage::well_known_keys::CODE.to_vec(),
|
|
kitchensink_runtime::wasm_binary_unwrap().into(),
|
|
);
|
|
storage
|
|
}
|
|
}
|
|
|
|
/// A `test-runtime` extensions to `TestClientBuilder`.
|
|
pub trait TestClientBuilderExt: Sized {
|
|
/// Create test client builder.
|
|
fn new() -> Self;
|
|
|
|
/// Build the test client.
|
|
fn build(self) -> Client;
|
|
}
|
|
|
|
impl TestClientBuilderExt
|
|
for substrate_test_client::TestClientBuilder<
|
|
node_primitives::Block,
|
|
client::LocalCallExecutor<node_primitives::Block, Backend, ExecutorDispatch>,
|
|
Backend,
|
|
GenesisParameters,
|
|
>
|
|
{
|
|
fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
|
|
fn build(self) -> Client {
|
|
self.build_with_native_executor(None).0
|
|
}
|
|
}
|