Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

add a test relay chain runtime #1347

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ members = [
"runtime/polkadot",
"runtime/kusama",
"runtime/westend",
"runtime/origami",
"runtime/test-runtime",
"runtime/test-runtime/client",
"service",
Expand All @@ -59,6 +60,7 @@ exclude = [
"runtime/polkadot/wasm",
"runtime/kusama/wasm",
"runtime/westend/wasm",
"runtime/origami/wasm",
"parachain/test-parachains/adder/wasm",
]

Expand Down
1 change: 1 addition & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ polkadot-overseer = { path = "../overseer" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../subsystem" }
kusama-runtime = { path = "../../runtime/kusama" }
westend-runtime = { path = "../../runtime/westend" }
origami-runtime = { path = "../../runtime/origami" }
polkadot-network = { path = "../../network", optional = true }
polkadot-rpc = { path = "../../rpc" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
41 changes: 41 additions & 0 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec};
#[cfg(feature = "full-node")]
pub use codec::Codec;
pub use polkadot_runtime;
pub use origami_runtime;
pub use kusama_runtime;
pub use westend_runtime;
use prometheus_endpoint::Registry;
Expand All @@ -79,6 +80,14 @@ native_executor_instance!(
frame_benchmarking::benchmarking::HostFunctions,
);


native_executor_instance!(
pub OrigamiExecutor,
origami_runtime::api::dispatch,
origami_runtime::native_version,
frame_benchmarking::benchmarking::HostFunctions,
);

/// A set of APIs that polkadot-like runtimes must implement.
pub trait RuntimeApiCollection<Extrinsic: codec::Codec + Send + Sync + 'static>:
sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
Expand Down Expand Up @@ -686,6 +695,38 @@ pub fn westend_new_full(
Ok((components, client, FullNodeHandles))
}

/// Create a new Polkadot service for a full node.
#[cfg(feature = "full-node")]
pub fn origami_new_full(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be in service-new, because that is the service that uses the overseer.

mut config: Configuration,
collating_for: Option<(CollatorId, parachain::Id)>,
_max_block_data_size: Option<u64>,
_authority_discovery_enabled: bool,
_slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
)
-> Result<(
TaskManager,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
polkadot_runtime::RuntimeApi
>>,
FullNodeHandles,
), ServiceError>
{
let (components, client) = new_full!(
config,
collating_for,
authority_discovery_enabled,
grandpa_pause,
origami_runtime::RuntimeApi,
OrigamiExecutor,
);

Ok((components, client, FullNodeHandles))
}

/// Create a new Polkadot service for a light client.
pub fn polkadot_new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
{
Expand Down
159 changes: 159 additions & 0 deletions runtime/origami/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
[package]
name = "origami-runtime"
version = "0.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"

[dependencies]
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] }
log = { version = "0.3.9", optional = true }
rustc-hex = { version = "2.0.1", default-features = false }
serde = { version = "1.0.102", default-features = false }
serde_derive = { version = "1.0.102", optional = true }
static_assertions = "1.1.0"
smallvec = "1.4.0"

authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
version = { package = "sp-version", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

authority-discovery = { package = "pallet-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
transaction-payment = { package = "pallet-transaction-payment", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
collective = { package = "pallet-collective", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
democracy = { package = "pallet-democracy", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
elections-phragmen = { package = "pallet-elections-phragmen", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
executive = { package = "frame-executive", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
finality-tracker = { package = "pallet-finality-tracker", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
grandpa = { package = "pallet-grandpa", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
identity = { package = "pallet-identity", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
indices = { package = "pallet-indices", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
proxy = { package = "pallet-proxy", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
scheduler = { package = "pallet-scheduler", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
staking = { package = "pallet-staking", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
system = { package = "frame-system", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
system_rpc_runtime_api = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sudo = { package = "pallet-sudo", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
utility = { package = "pallet-utility", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
hex-literal = { version = "0.2.1", optional = true }

runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }

[dev-dependencies]
hex-literal = "0.2.1"
libsecp256k1 = "0.3.2"
tiny-keccak = "1.5.0"
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
trie-db = "0.20.0"
serde_json = "1.0.41"

[build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.6" }

[features]
default = ["std"]
no_std = []
only-staking = []
std = [
"authority-discovery-primitives/std",
"authority-discovery/std",
"bitvec/std",
"primitives/std",
"rustc-hex/std",
"codec/std",
"inherents/std",
"sp-core/std",
"sp-api/std",
"tx-pool-api/std",
"block-builder-api/std",
"offchain-primitives/std",
"sp-std/std",
"frame-support/std",
"authorship/std",
"balances/std",
"transaction-payment/std",
"transaction-payment-rpc-runtime-api/std",
"collective/std",
"elections-phragmen/std",
"democracy/std",
"executive/std",
"finality-tracker/std",
"grandpa/std",
"identity/std",
"im-online/std",
"indices/std",
"offences/std",
"proxy/std",
"sp-runtime/std",
"sp-staking/std",
"scheduler/std",
"session/std",
"staking/std",
"system/std",
"system_rpc_runtime_api/std",
"timestamp/std",
"version/std",
"serde_derive",
"serde/std",
"log",
"babe/std",
"babe-primitives/std",
"sp-session/std",
"randomness-collective-flip/std",
"runtime-common/std",
"sudo/std",
"utility/std",
]
runtime-benchmarks = [
"runtime-common/runtime-benchmarks",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking",
"system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"balances/runtime-benchmarks",
"collective/runtime-benchmarks",
"democracy/runtime-benchmarks",
"elections-phragmen/runtime-benchmarks",
"im-online/runtime-benchmarks",
"scheduler/runtime-benchmarks",
"staking/runtime-benchmarks",
"timestamp/runtime-benchmarks",
"pallet-offences-benchmarking",
"pallet-session-benchmarking",
"hex-literal",
]
# When enabled, the runtime api will not be build.
#
# This is required by Cumulus to access certain types of the
# runtime without clashing with the runtime api exported functions
# in WASM.
disable-runtime-api = []
5 changes: 5 additions & 0 deletions runtime/origami/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

= Origami Runtime

A simple test runtime pulling in all parachain relevant blocks, to create a test
runtime for a relay-chain.
26 changes: 26 additions & 0 deletions runtime/origami/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot 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.

// Substrate 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 Substrate. If not, see <http://www.gnu.org/licenses/>.

use wasm_builder_runner::WasmBuilder;

fn main() {
WasmBuilder::new()
.with_current_project()
.with_wasm_builder_from_crates("1.0.11")
.import_memory()
.export_heap_base()
.build()
}
Loading