diff --git a/Cargo.lock b/Cargo.lock index d80a8aac4dd..db493e3ed82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1070,12 +1070,11 @@ dependencies = [ ] [[package]] -name = "cumulus-collator" +name = "cumulus-client-collator" version = "0.1.0" dependencies = [ - "cumulus-network", - "cumulus-primitives", - "cumulus-runtime", + "cumulus-client-network", + "cumulus-primitives-core", "cumulus-test-client", "cumulus-test-runtime", "env_logger", @@ -1106,7 +1105,7 @@ dependencies = [ ] [[package]] -name = "cumulus-consensus" +name = "cumulus-client-consensus" version = "0.1.0" dependencies = [ "cumulus-test-client", @@ -1131,10 +1130,9 @@ dependencies = [ ] [[package]] -name = "cumulus-network" +name = "cumulus-client-network" version = "0.1.0" dependencies = [ - "cumulus-primitives", "cumulus-test-service", "derive_more 0.99.11", "futures 0.3.12", @@ -1161,106 +1159,100 @@ dependencies = [ ] [[package]] -name = "cumulus-parachain-system" +name = "cumulus-client-service" version = "0.1.0" dependencies = [ - "cumulus-primitives", - "cumulus-runtime", - "cumulus-test-relay-sproof-builder", - "frame-support", - "frame-system", - "hash-db", - "hex-literal 0.2.1", - "lazy_static", - "pallet-balances", - "parity-scale-codec", - "polkadot-parachain", - "serde", - "sp-core", - "sp-externalities", - "sp-inherents", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", - "sp-version", - "substrate-test-runtime-client", -] - -[[package]] -name = "cumulus-primitives" -version = "0.1.0" -dependencies = [ - "impl-trait-for-tuples 0.1.3", + "cumulus-client-collator", + "cumulus-client-consensus", + "cumulus-primitives-core", + "futures 0.3.12", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", + "polkadot-overseer", "polkadot-primitives", + "polkadot-service", "sc-chain-spec", + "sc-client-api", + "sc-service", + "sc-tracing", + "sp-api", + "sp-blockchain", + "sp-consensus", "sp-core", "sp-inherents", "sp-runtime", - "sp-std", - "sp-trie", + "tracing", ] [[package]] -name = "cumulus-runtime" +name = "cumulus-pallet-parachain-system" version = "0.1.0" dependencies = [ - "cumulus-primitives", + "cumulus-primitives-core", "cumulus-test-client", "cumulus-test-relay-sproof-builder", "env_logger", "frame-executive", + "frame-support", + "frame-system", "hash-db", + "hex-literal 0.2.1", + "lazy_static", "memory-db", + "pallet-balances", "parity-scale-codec", "polkadot-parachain", "sc-client-api", "sc-executor", + "serde", "sp-blockchain", "sp-consensus", "sp-core", "sp-externalities", + "sp-inherents", "sp-io", "sp-keyring", "sp-runtime", "sp-state-machine", "sp-std", "sp-trie", + "sp-version", + "substrate-test-runtime-client", "trie-db", ] [[package]] -name = "cumulus-service" +name = "cumulus-pallet-xcm-handler" version = "0.1.0" dependencies = [ - "cumulus-collator", - "cumulus-consensus", - "cumulus-primitives", - "futures 0.3.12", - "polkadot-overseer", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-std", + "xcm", +] + +[[package]] +name = "cumulus-primitives-core" +version = "0.1.0" +dependencies = [ + "impl-trait-for-tuples 0.2.1", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", "polkadot-primitives", - "polkadot-service", - "sc-client-api", - "sc-service", - "sc-tracing", - "sp-api", - "sp-blockchain", - "sp-consensus", "sp-core", "sp-inherents", "sp-runtime", - "tracing", + "sp-std", + "sp-trie", ] [[package]] name = "cumulus-test-client" version = "0.1.0" dependencies = [ - "cumulus-primitives", + "cumulus-primitives-core", "cumulus-test-relay-sproof-builder", "cumulus-test-runtime", "cumulus-test-service", @@ -1288,9 +1280,9 @@ dependencies = [ name = "cumulus-test-parachain-runtime" version = "0.1.0" dependencies = [ - "cumulus-parachain-system", - "cumulus-primitives", - "cumulus-runtime", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcm-handler", + "cumulus-primitives-core", "frame-executive", "frame-support", "frame-system", @@ -1319,14 +1311,13 @@ dependencies = [ "xcm", "xcm-builder", "xcm-executor", - "xcm-handler", ] [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" dependencies = [ - "cumulus-primitives", + "cumulus-primitives-core", "parity-scale-codec", "polkadot-primitives", "sp-runtime", @@ -1338,9 +1329,8 @@ dependencies = [ name = "cumulus-test-runtime" version = "0.1.0" dependencies = [ - "cumulus-parachain-system", - "cumulus-primitives", - "cumulus-runtime", + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", "frame-executive", "frame-support", "frame-system", @@ -1370,10 +1360,10 @@ dependencies = [ name = "cumulus-test-service" version = "0.1.0" dependencies = [ - "cumulus-consensus", - "cumulus-network", - "cumulus-primitives", - "cumulus-service", + "cumulus-client-consensus", + "cumulus-client-network", + "cumulus-client-service", + "cumulus-primitives-core", "cumulus-test-runtime", "futures 0.3.12", "jsonrpc-core", @@ -1970,7 +1960,7 @@ dependencies = [ "bitflags", "frame-metadata", "frame-support-procedural", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "log", "once_cell", "parity-scale-codec", @@ -2028,7 +2018,7 @@ version = "2.0.1" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" dependencies = [ "frame-support", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "serde", "sp-core", @@ -2780,9 +2770,9 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f65a8ecf74feeacdab8d38cb129e550ca871cccaa7d1921d8636ecd75534903" +checksum = "d5dacb10c5b3bb92d46ba347505a9041e676bb20ad220101326bffb0c93031ee" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", @@ -4296,7 +4286,7 @@ source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b dependencies = [ "frame-support", "frame-system", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "sp-authorship", "sp-inherents", @@ -4675,7 +4665,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "serde", "sp-inherents", @@ -4749,7 +4739,7 @@ source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b dependencies = [ "frame-support", "frame-system", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "pallet-balances", "parity-scale-codec", "serde", @@ -4790,7 +4780,7 @@ dependencies = [ name = "parachain-info" version = "0.1.0" dependencies = [ - "cumulus-primitives", + "cumulus-primitives-core", "frame-support", "frame-system", "parity-scale-codec", @@ -4890,7 +4880,7 @@ dependencies = [ "cfg-if 1.0.0", "ethereum-types", "hashbrown", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "lru", "parity-util-mem-derive", "parking_lot 0.11.1", @@ -6888,11 +6878,11 @@ name = "rococo-collator" version = "0.1.0" dependencies = [ "assert_cmd", - "cumulus-collator", - "cumulus-consensus", - "cumulus-network", - "cumulus-primitives", - "cumulus-service", + "cumulus-client-collator", + "cumulus-client-consensus", + "cumulus-client-network", + "cumulus-client-service", + "cumulus-primitives-core", "cumulus-test-parachain-runtime", "derive_more 0.15.0", "exit-future 0.1.4", @@ -7219,7 +7209,7 @@ name = "sc-chain-spec" version = "2.0.1" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" dependencies = [ - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "sc-chain-spec-derive", "sc-consensus-babe", @@ -8918,7 +8908,7 @@ source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b dependencies = [ "either", "hash256-std-hasher", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "log", "parity-scale-codec", "parity-util-mem", @@ -8937,7 +8927,7 @@ name = "sp-runtime-interface" version = "2.0.1" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" dependencies = [ - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "primitive-types", "sp-externalities", @@ -9064,7 +9054,7 @@ name = "sp-timestamp" version = "2.0.1" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" dependencies = [ - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "sp-api", "sp-inherents", @@ -9145,7 +9135,7 @@ name = "sp-wasm-interface" version = "2.0.1" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" dependencies = [ - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "sp-std", "wasmi", @@ -10096,7 +10086,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" dependencies = [ "cfg-if 0.1.10", - "rand 0.3.23", + "rand 0.7.3", "static_assertions", ] @@ -10845,7 +10835,7 @@ version = "0.8.22" source = "git+https://github.com/paritytech/polkadot#e526a15b1fa9bb7ac5378541d9f32667618e18c4" dependencies = [ "frame-support", - "impl-trait-for-tuples 0.2.0", + "impl-trait-for-tuples 0.2.1", "parity-scale-codec", "sp-arithmetic", "sp-core", @@ -10855,18 +10845,6 @@ dependencies = [ "xcm", ] -[[package]] -name = "xcm-handler" -version = "0.1.0" -dependencies = [ - "cumulus-primitives", - "frame-support", - "frame-system", - "parity-scale-codec", - "sp-std", - "xcm", -] - [[package]] name = "yamux" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index 843cea096fc..5c0c2b39e20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,20 @@ [workspace] members = [ - "consensus", - "network", - "parachain-system", - "primitives", + "client/consensus", + "client/network", + "client/service", + "pallets/parachain-system", + "pallets/xcm-handler", + "primitives/core", "rococo-parachains/", "rococo-parachains/pallets/parachain-info", "rococo-parachains/primitives", "rococo-parachains/runtime", - "runtime", - "service", "test/runtime", "test/client", "test/service", "test/relay-sproof-builder", - "xcm-handler", ] [profile.release] -panic = 'unwind' +panic = "unwind" diff --git a/README.md b/README.md index 8502a46240f..c494f7e6abc 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,6 @@ follow, [finalize](https://wiki.polkadot.network/docs/en/learn-consensus#probabilistic-vs-provable-finality), and treat as best. -## Runtime - -The [`cumulus-runtime`](runtime) is wrapper around Substrate runtimes that provides parachain -validation capabilities and proof-generation routines. - ## Collator A Polkadot [collator](https://wiki.polkadot.network/docs/en/learn-collator) for the parachain is diff --git a/collator/Cargo.toml b/client/collator/Cargo.toml similarity index 90% rename from collator/Cargo.toml rename to client/collator/Cargo.toml index e26eec1777b..164bbaa6b5d 100644 --- a/collator/Cargo.toml +++ b/client/collator/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cumulus-collator" +name = "cumulus-client-collator" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" @@ -25,9 +25,8 @@ polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = " polkadot-node-subsystem = { git = "https://github.com/paritytech/polkadot", branch = "master" } # Cumulus dependencies -cumulus-network = { path = "../network" } -cumulus-primitives = { path = "../primitives" } -cumulus-runtime = { path = "../runtime" } +cumulus-client-network = { path = "../network" } +cumulus-primitives-core = { path = "../../primitives/core" } # Other dependencies log = "0.4.8" @@ -37,8 +36,8 @@ parking_lot = "0.9" [dev-dependencies] # Cumulus dependencies -cumulus-test-runtime = { path = "../test/runtime" } -cumulus-test-client = { path = "../test/client" } +cumulus-test-runtime = { path = "../../test/runtime" } +cumulus-test-client = { path = "../../test/client" } # Substrate dependencies sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/collator/src/lib.rs b/client/collator/src/lib.rs similarity index 99% rename from collator/src/lib.rs rename to client/collator/src/lib.rs index 821d2d26d06..3a893204921 100644 --- a/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -16,13 +16,12 @@ //! Cumulus Collator implementation for Substrate. -use cumulus_network::WaitToAnnounce; -use cumulus_primitives::{ - inherents, +use cumulus_client_network::WaitToAnnounce; +use cumulus_primitives_core::{ + inherents, ParachainBlockData, well_known_keys, InboundDownwardMessage, InboundHrmpMessage, OutboundHrmpMessage, PersistedValidationData, relay_chain, }; -use cumulus_runtime::ParachainBlockData; use sc_client_api::{BlockBackend, StateBackend}; use sp_consensus::{ diff --git a/consensus/Cargo.toml b/client/consensus/Cargo.toml similarity index 91% rename from consensus/Cargo.toml rename to client/consensus/Cargo.toml index 58c8c9fc4fd..47067d43cdb 100644 --- a/consensus/Cargo.toml +++ b/client/consensus/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cumulus-consensus" +name = "cumulus-client-consensus" description = "Proxy Polkadot's consensus as a consensus engine for Substrate" version = "0.1.0" authors = ["Parity Technologies "] @@ -32,8 +32,8 @@ tracing = "0.1.22" sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } # Cumulus dependencies -cumulus-test-runtime = { path = "../test/runtime" } -cumulus-test-client = { path = "../test/client" } +cumulus-test-runtime = { path = "../../test/runtime" } +cumulus-test-client = { path = "../../test/client" } # Other deps futures-timer = "3.0.2" diff --git a/consensus/src/import_queue.rs b/client/consensus/src/import_queue.rs similarity index 100% rename from consensus/src/import_queue.rs rename to client/consensus/src/import_queue.rs diff --git a/consensus/src/lib.rs b/client/consensus/src/lib.rs similarity index 100% rename from consensus/src/lib.rs rename to client/consensus/src/lib.rs diff --git a/network/Cargo.toml b/client/network/Cargo.toml similarity index 93% rename from network/Cargo.toml rename to client/network/Cargo.toml index 2716efd51b4..a8b8b5cccdd 100644 --- a/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cumulus-network" +name = "cumulus-client-network" version = "0.1.0" authors = ["Parity Technologies "] description = "Cumulus-specific networking protocol" @@ -23,9 +23,6 @@ polkadot-node-subsystem = { git = "https://github.com/paritytech/polkadot", bran polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "master" } -# Cumulus deps -cumulus-primitives = { path = "../primitives" } - # other deps codec = { package = "parity-scale-codec", version = "2.0.0", features = [ "derive" ] } futures = { version = "0.3.1", features = ["compat"] } @@ -36,7 +33,7 @@ derive_more = "0.99.2" [dev-dependencies] # Cumulus deps -cumulus-test-service = { path = "../test/service" } +cumulus-test-service = { path = "../../test/service" } # Polkadot deps polkadot-test-client = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/network/src/lib.rs b/client/network/src/lib.rs similarity index 100% rename from network/src/lib.rs rename to client/network/src/lib.rs diff --git a/network/src/tests.rs b/client/network/src/tests.rs similarity index 100% rename from network/src/tests.rs rename to client/network/src/tests.rs diff --git a/network/src/wait_on_relay_chain_block.rs b/client/network/src/wait_on_relay_chain_block.rs similarity index 100% rename from network/src/wait_on_relay_chain_block.rs rename to client/network/src/wait_on_relay_chain_block.rs diff --git a/service/Cargo.toml b/client/service/Cargo.toml similarity index 78% rename from service/Cargo.toml rename to client/service/Cargo.toml index ddd1abe42b5..4d1e575a1fe 100644 --- a/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -1,18 +1,19 @@ [package] -name = "cumulus-service" +name = "cumulus-client-service" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] # Cumulus dependencies -cumulus-consensus = { path = "../consensus" } -cumulus-collator = { path = "../collator" } -cumulus-primitives = { path = "../primitives" } +cumulus-client-consensus = { path = "../consensus" } +cumulus-client-collator = { path = "../collator" } +cumulus-primitives-core = { path = "../../primitives/core" } # Substrate dependencies -sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -29,3 +30,4 @@ polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = " # Other deps futures = "0.3.6" tracing = "0.1.22" +codec = { package = "parity-scale-codec", version = "2.0.0" } diff --git a/primitives/src/genesis.rs b/client/service/src/genesis.rs similarity index 96% rename from primitives/src/genesis.rs rename to client/service/src/genesis.rs index 76f80f6b275..0efc0c85c10 100644 --- a/primitives/src/genesis.rs +++ b/client/service/src/genesis.rs @@ -18,7 +18,7 @@ use codec::Encode; use sc_chain_spec::ChainSpec; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero}; -/// Generate the genesis state for a given ChainSpec. +/// Generate the genesis block from a given ChainSpec. pub fn generate_genesis_block( chain_spec: &Box, ) -> Result { diff --git a/service/src/lib.rs b/client/service/src/lib.rs similarity index 97% rename from service/src/lib.rs rename to client/service/src/lib.rs index acc9a76be65..9bafb063bac 100644 --- a/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -18,7 +18,7 @@ //! //! Provides functions for starting a collator node or a normal full node. -use cumulus_primitives::ParaId; +use cumulus_primitives_core::ParaId; use futures::{Future, FutureExt}; use polkadot_overseer::OverseerHandler; use polkadot_primitives::v1::{Block as PBlock, CollatorId, CollatorPair}; @@ -34,6 +34,8 @@ use sp_inherents::InherentDataProviders; use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; use std::{marker::PhantomData, sync::Arc}; +pub mod genesis; + /// Polkadot full node handles. type PFullNode = polkadot_service::NewFull; @@ -188,7 +190,7 @@ where PClient: AbstractClient + 'static, { async move { - cumulus_collator::start_collator(cumulus_collator::StartCollatorParams { + cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams { proposer_factory: self.proposer_factory, inherent_data_providers: self.inherent_data_providers, backend: self.backend, @@ -289,7 +291,7 @@ where Api: RuntimeApiCollection, PClient: AbstractClient + 'static, { - let consensus = cumulus_consensus::run_parachain_consensus( + let consensus = cumulus_client_consensus::run_parachain_consensus( self.para_id, self.client, client, diff --git a/docs/overview.md b/docs/overview.md index 3312cec1262..2d6753d0ffa 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -13,7 +13,7 @@ messages of other Parachains. To convert a Substrate runtime into a Parachain runtime, the following code needs to be added to the runtime: ```rust -cumulus_runtime::register_validate_block!(Block, Executive); +cumulus_pallet_parachain_system::register_validate_block!(Block, Executive); ``` This macro call expects the `Block` and `Executive` type. It generates the `validate_block` function diff --git a/parachain-system/Cargo.toml b/pallets/parachain-system/Cargo.toml similarity index 58% rename from parachain-system/Cargo.toml rename to pallets/parachain-system/Cargo.toml index 05ab692d2db..c24299c05fd 100644 --- a/parachain-system/Cargo.toml +++ b/pallets/parachain-system/Cargo.toml @@ -1,17 +1,16 @@ [package] -name = "cumulus-parachain-system" +name = "cumulus-pallet-parachain-system" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" -description = "pallet to manage parachain upgrades" +description = "Base pallet for cumulus-based parachains" [dependencies] # Cumulus dependencies -cumulus-primitives = { path = "../primitives", default-features = false } -cumulus-runtime = { path = "../runtime", default-features = false } +cumulus-primitives-core = { path = "../../primitives/core", default-features = false } # Polkadot dependencies -parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, features = [ "wasm-api" ], branch = "master" } # Substrate dependencies frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -23,37 +22,50 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-state-machine = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-externalities = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } # Other Dependencies codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"]} serde = { version = "1.0.101", optional = true, features = ["derive"] } hash-db = { version = "0.15.2", default-features = false } +memory-db = { version = "0.26.0", default-features = false } +trie-db = { version = "0.22.0", default-features = false } [dev-dependencies] -sp-externalities = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -cumulus-test-relay-sproof-builder = { path = "../test/relay-sproof-builder" } +cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder" } hex-literal = "0.2.1" lazy_static = "1.4" +sc-client-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } +cumulus-test-client = { path = "../../test/client" } +env_logger = "0.7.1" [features] -default = ['std'] +default = [ "std" ] std = [ - 'serde', - 'codec/std', - 'frame-support/std', - 'pallet-balances/std', - 'cumulus-runtime/std', - 'sp-core/std', - 'sp-runtime/std', - 'sp-io/std', - 'sp-std/std', - 'hash-db/std', - 'sp-state-machine/std', - 'sp-trie/std', - 'frame-system/std', - 'cumulus-primitives/std', + "serde", + "codec/std", + "frame-support/std", + "pallet-balances/std", + "sp-core/std", + "sp-runtime/std", + "sp-io/std", + "sp-std/std", + "hash-db/std", + "memory-db/std", + "trie-db/std", + "sp-state-machine/std", + "sp-trie/std", + "sp-externalities/std", + "frame-system/std", + "frame-executive/std", + "cumulus-primitives-core/std", ] diff --git a/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs similarity index 94% rename from parachain-system/src/lib.rs rename to pallets/parachain-system/src/lib.rs index 9935a3f4577..ec712163af7 100644 --- a/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -16,7 +16,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -//! parachain-system is a base module for cumulus-based parachains. +//! cumulus-pallet-parachain-system is a base module for cumulus-based parachains. //! //! This module handles low-level details of being a parachain. It's responsibilities include: //! @@ -27,7 +27,7 @@ //! //! Users must ensure that they register this pallet as an inherent provider. -use cumulus_primitives::{ +use cumulus_primitives_core::{ inherents::{SystemInherentData, SYSTEM_INHERENT_IDENTIFIER}, relay_chain, well_known_keys::{self, NEW_VALIDATION_CODE, VALIDATION_DATA}, @@ -43,13 +43,15 @@ use frame_support::{ weights::{DispatchClass, Weight}, }; use frame_system::{ensure_none, ensure_root}; -use parachain::primitives::RelayChainBlockNumber; +use polkadot_parachain::primitives::RelayChainBlockNumber; +use relay_state_snapshot::MessagingStateSnapshot; use sp_inherents::{InherentData, InherentIdentifier, ProvideInherent}; use sp_runtime::traits::{BlakeTwo256, Hash}; use sp_std::{cmp, collections::btree_map::BTreeMap, vec::Vec}; mod relay_state_snapshot; -use relay_state_snapshot::MessagingStateSnapshot; +#[macro_use] +pub mod validate_block; /// The pallet's configuration trait. pub trait Config: frame_system::Config { @@ -475,7 +477,7 @@ impl Module { /// This is similar to [`process_inbound_downward_messages`], but works on multiple inbound /// channels. fn process_inbound_horizontal_messages( - ingress_channels: &[(ParaId, cumulus_primitives::AbridgedHrmpChannel)], + ingress_channels: &[(ParaId, cumulus_primitives_core::AbridgedHrmpChannel)], horizontal_messages: BTreeMap>, ) -> DispatchResult { // First, check that all submitted messages are sent from channels that exist. The channel @@ -598,9 +600,8 @@ impl Module { return None; } - let relay_blocks_since_last_upgrade = vfp - .relay_parent_number - .saturating_sub(LastUpgrade::get()); + let relay_blocks_since_last_upgrade = + vfp.relay_parent_number.saturating_sub(LastUpgrade::get()); if relay_blocks_since_last_upgrade <= cfg.validation_upgrade_frequency { // The cooldown after the last upgrade hasn't elapsed yet. Upgrade is not allowed. @@ -611,9 +612,7 @@ impl Module { } /// The implementation of the runtime upgrade scheduling. - fn schedule_upgrade_impl( - validation_function: Vec, - ) -> DispatchResult { + fn schedule_upgrade_impl(validation_function: Vec) -> DispatchResult { ensure!( !PendingValidationFunction::exists(), Error::::OverlappingUpgrades @@ -712,9 +711,9 @@ impl Module { match Self::host_configuration() { Some(cfg) => { if message.len() > cfg.max_upward_message_size as usize { - return Err(SendUpErr::TooBig) + return Err(SendUpErr::TooBig); } - }, + } None => { // This storage field should carry over from the previous block. So if it's None // then it must be that this is an edge-case where a message is attempted to be @@ -758,7 +757,7 @@ impl Module { // opened at all so early. At least, relying on this assumption seems to be a better // tradeoff, compared to introducing an error variant that the clients should be // prepared to handle. - return Err(SendHorizontalErr::NoChannel) + return Err(SendHorizontalErr::NoChannel); } }; let channel_meta = match relevant_messaging_state @@ -769,7 +768,7 @@ impl Module { Err(_) => return Err(SendHorizontalErr::NoChannel), }; if data.len() as u32 > channel_meta.max_message_size { - return Err(SendHorizontalErr::TooBig) + return Err(SendHorizontalErr::TooBig); } // And then at last update the storage. @@ -859,7 +858,7 @@ mod tests { use super::*; use codec::Encode; - use cumulus_primitives::{ + use cumulus_primitives_core::{ AbridgedHrmpChannel, InboundDownwardMessage, InboundHrmpMessage, PersistedValidationData, }; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; @@ -1325,27 +1324,27 @@ mod tests { sproof.host_config.max_upward_message_num_per_candidate = 1; sproof.relay_dispatch_queue_size = None; }) - .add_with_post_test(1, + .add_with_post_test( + 1, || { ParachainSystem::send_upward_message(b"Mr F was here".to_vec()).unwrap(); ParachainSystem::send_upward_message(b"message 2".to_vec()).unwrap(); }, || { - let v: Option>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); - assert_eq!( - v, - Some(vec![b"Mr F was here".to_vec()]), - ); - }) - .add_with_post_test(2, + let v: Option>> = + storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); + assert_eq!(v, Some(vec![b"Mr F was here".to_vec()]),); + }, + ) + .add_with_post_test( + 2, || { /* do nothing within block */ }, || { - let v: Option>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); - assert_eq!( - v, - Some(vec![b"message 2".to_vec()]), - ); - }); + let v: Option>> = + storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); + assert_eq!(v, Some(vec![b"message 2".to_vec()]),); + }, + ); } #[test] @@ -1360,29 +1359,28 @@ mod tests { 2 => sproof.relay_dispatch_queue_size = Some((4, 0)), _ => unreachable!(), } - }) - .add_with_post_test(1, + .add_with_post_test( + 1, || { ParachainSystem::send_upward_message(vec![0u8; 8]).unwrap(); }, || { // The message won't be sent because there is already one message in queue. - let v: Option>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); - assert_eq!( - v, - Some(vec![]), - ); - }) - .add_with_post_test(2, + let v: Option>> = + storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); + assert_eq!(v, Some(vec![]),); + }, + ) + .add_with_post_test( + 2, || { /* do nothing within block */ }, || { - let v: Option>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); - assert_eq!( - v, - Some(vec![vec![0u8; 8]]), - ); - }); + let v: Option>> = + storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); + assert_eq!(v, Some(vec![vec![0u8; 8]]),); + }, + ); } #[test] @@ -1396,13 +1394,11 @@ mod tests { }) .add(1, || {}) .add(2, || { - assert!( - ParachainSystem::send_hrmp_message(OutboundHrmpMessage { - recipient: ParaId::from(300), - data: b"derp".to_vec(), - }) - .is_err() - ); + assert!(ParachainSystem::send_hrmp_message(OutboundHrmpMessage { + recipient: ParaId::from(300), + data: b"derp".to_vec(), + }) + .is_err()); }); } @@ -1620,15 +1616,13 @@ mod tests { } BlockTests::new() - .with_relay_sproof_builder( - |_, relay_block_num, sproof| match relay_block_num { - 1 => { - sproof.dmq_mqc_head = - Some(MessageQueueChain::default().extend_downward(&MSG).head()); - } - _ => unreachable!(), - }, - ) + .with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num { + 1 => { + sproof.dmq_mqc_head = + Some(MessageQueueChain::default().extend_downward(&MSG).head()); + } + _ => unreachable!(), + }) .with_inherent_data(|_, relay_block_num, data| match relay_block_num { 1 => { data.downward_messages.push(MSG.clone()); @@ -1669,35 +1663,34 @@ mod tests { } BlockTests::new() - .with_relay_sproof_builder( - |_, relay_block_num, sproof| match relay_block_num { - 1 => { - // 200 - doesn't exist yet - // 300 - one new message - sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = - Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); - } - 2 => { - // 200 - two new messages - // 300 - now present with one message. - sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head = - Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head()); - sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = - Some(MessageQueueChain::default() - .extend_hrmp(&MSG_1) - .extend_hrmp(&MSG_2) - .extend_hrmp(&MSG_3) - .head()); - } - 3 => { - // 200 - no new messages - // 300 - is gone - sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head = - Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head()); - } - _ => unreachable!(), - }, - ) + .with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num { + 1 => { + // 200 - doesn't exist yet + // 300 - one new message + sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = + Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); + } + 2 => { + // 200 - two new messages + // 300 - now present with one message. + sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head = + Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head()); + sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = Some( + MessageQueueChain::default() + .extend_hrmp(&MSG_1) + .extend_hrmp(&MSG_2) + .extend_hrmp(&MSG_3) + .head(), + ); + } + 3 => { + // 200 - no new messages + // 300 - is gone + sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head = + Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head()); + } + _ => unreachable!(), + }) .with_inherent_data(|_, relay_block_num, data| match relay_block_num { 1 => { data.horizontal_messages @@ -1779,28 +1772,27 @@ mod tests { const ALICE: ParaId = ParaId::new(300); BlockTests::new() - .with_relay_sproof_builder( - |_, relay_block_num, sproof| match relay_block_num { - 1 => { - sproof.upsert_inbound_channel(ALICE).mqc_head - = Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); - } - 2 => { - // 300 - no new messages, mqc stayed the same. - sproof.upsert_inbound_channel(ALICE).mqc_head - = Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); - } - 3 => { - // 300 - new message. - sproof.upsert_inbound_channel(ALICE).mqc_head - = Some(MessageQueueChain::default() + .with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num { + 1 => { + sproof.upsert_inbound_channel(ALICE).mqc_head = + Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); + } + 2 => { + // 300 - no new messages, mqc stayed the same. + sproof.upsert_inbound_channel(ALICE).mqc_head = + Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); + } + 3 => { + // 300 - new message. + sproof.upsert_inbound_channel(ALICE).mqc_head = Some( + MessageQueueChain::default() .extend_hrmp(&MSG_1) .extend_hrmp(&MSG_2) - .head()); - } - _ => unreachable!(), - }, - ) + .head(), + ); + } + _ => unreachable!(), + }) .with_inherent_data(|_, relay_block_num, data| match relay_block_num { 1 => { data.horizontal_messages.insert(ALICE, vec![MSG_1.clone()]); diff --git a/parachain-system/src/relay_state_snapshot.rs b/pallets/parachain-system/src/relay_state_snapshot.rs similarity index 98% rename from parachain-system/src/relay_state_snapshot.rs rename to pallets/parachain-system/src/relay_state_snapshot.rs index fb049d9d4be..1bfe478e329 100644 --- a/parachain-system/src/relay_state_snapshot.rs +++ b/pallets/parachain-system/src/relay_state_snapshot.rs @@ -15,7 +15,7 @@ // along with Cumulus. If not, see . use codec::{Encode, Decode}; -use cumulus_primitives::{relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId}; +use cumulus_primitives_core::{relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId}; use hash_db::{HashDB, EMPTY_PREFIX}; use sp_runtime::traits::HashFor; use sp_state_machine::{Backend, TrieBackend}; diff --git a/runtime/src/validate_block/implementation.rs b/pallets/parachain-system/src/validate_block/implementation.rs similarity index 93% rename from runtime/src/validate_block/implementation.rs rename to pallets/parachain-system/src/validate_block/implementation.rs index 084ac1d6bc1..5eb5553da49 100644 --- a/runtime/src/validate_block/implementation.rs +++ b/pallets/parachain-system/src/validate_block/implementation.rs @@ -23,16 +23,16 @@ use sp_std::{boxed::Box, vec::Vec}; use hash_db::{HashDB, EMPTY_PREFIX}; -use parachain::primitives::{HeadData, ValidationCode, ValidationParams, ValidationResult}; +use polkadot_parachain::primitives::{HeadData, ValidationCode, ValidationParams, ValidationResult}; use codec::{Decode, Encode}; -use cumulus_primitives::{ +use cumulus_primitives_core::{ well_known_keys::{ HRMP_OUTBOUND_MESSAGES, HRMP_WATERMARK, NEW_VALIDATION_CODE, PROCESSED_DOWNWARD_MESSAGES, UPWARD_MESSAGES, VALIDATION_DATA, }, - OutboundHrmpMessage, UpwardMessage, PersistedValidationData, + OutboundHrmpMessage, PersistedValidationData, UpwardMessage, }; use sp_core::storage::{ChildInfo, TrackedStorageKey}; use sp_externalities::{ @@ -67,21 +67,24 @@ impl Encode for EncodeOpaqueValue { /// Validate a given parachain block on a validator. #[doc(hidden)] pub fn validate_block>(params: ValidationParams) -> ValidationResult { - let block_data = crate::ParachainBlockData::::decode(&mut ¶ms.block_data.0[..]) - .expect("Invalid parachain block data"); + let block_data = + cumulus_primitives_core::ParachainBlockData::::decode(&mut ¶ms.block_data.0[..]) + .expect("Invalid parachain block data"); let parent_head = B::Header::decode(&mut ¶ms.parent_head.0[..]).expect("Invalid parent head"); - let head_data = HeadData(block_data.header.encode()); + let (header, extrinsics, storage_proof) = block_data.deconstruct(); - let block = B::new(block_data.header, block_data.extrinsics); + let head_data = HeadData(header.encode()); + + let block = B::new(header, extrinsics); assert!( parent_head.hash() == *block.header().parent_hash(), "Invalid parent hash", ); - let db = block_data.storage_proof.into_memory_db(); + let db = storage_proof.into_memory_db(); let root = parent_head.state_root().clone(); if !HashDB::, _>::contains(&db, &root, EMPTY_PREFIX) { panic!("Witness data does not contain given storage root."); @@ -130,10 +133,8 @@ pub fn validate_block>(params: ValidationParams) - .replace_implementation(host_default_child_storage_root), sp_io::default_child_storage::host_next_key .replace_implementation(host_default_child_storage_next_key), - sp_io::offchain_index::host_set - .replace_implementation(host_offchain_index_set), - sp_io::offchain_index::host_clear - .replace_implementation(host_offchain_index_clear), + sp_io::offchain_index::host_set.replace_implementation(host_offchain_index_set), + sp_io::offchain_index::host_clear.replace_implementation(host_offchain_index_clear), ); set_and_run_with_externalities(&mut ext, || { @@ -205,13 +206,10 @@ impl<'a, B: BlockT> WitnessExt<'a, B> { /// Should be removed with: https://github.com/paritytech/cumulus/issues/217 /// When removed `WitnessExt` could also be removed. fn check_validation_data(&self, mut data: &[u8]) { - let validation_data = PersistedValidationData::decode(&mut data) - .expect("Invalid `PersistedValidationData`"); + let validation_data = + PersistedValidationData::decode(&mut data).expect("Invalid `PersistedValidationData`"); - assert_eq!( - self.params.parent_head, - validation_data.parent_head, - ); + assert_eq!(self.params.parent_head, validation_data.parent_head,); assert_eq!( self.params.relay_parent_number, validation_data.relay_parent_number, @@ -487,6 +485,6 @@ fn host_default_child_storage_next_key(storage_key: &[u8], key: &[u8]) -> Option with_externalities(|ext| ext.next_child_storage_key(&child_info, key)) } -fn host_offchain_index_set(_key: &[u8], _value: &[u8]) { } +fn host_offchain_index_set(_key: &[u8], _value: &[u8]) {} -fn host_offchain_index_clear(_key: &[u8]) { } +fn host_offchain_index_clear(_key: &[u8]) {} diff --git a/runtime/src/validate_block/mod.rs b/pallets/parachain-system/src/validate_block/mod.rs similarity index 88% rename from runtime/src/validate_block/mod.rs rename to pallets/parachain-system/src/validate_block/mod.rs index 5aad0e77b41..66550b5469c 100644 --- a/runtime/src/validate_block/mod.rs +++ b/pallets/parachain-system/src/validate_block/mod.rs @@ -24,7 +24,7 @@ mod tests; #[cfg(not(feature = "std"))] #[doc(hidden)] -pub use parachain; +pub use polkadot_parachain; /// Register the `validate_block` function that is used by parachains to validate blocks on a /// validator. @@ -39,7 +39,7 @@ pub use parachain; /// struct Block; /// struct BlockExecutor; /// -/// cumulus_runtime::register_validate_block!(Block, BlockExecutor); +/// cumulus_pallet_parachain_system::register_validate_block!(Block, BlockExecutor); /// /// # fn main() {} /// ``` @@ -63,14 +63,14 @@ macro_rules! register_validate_block_impl { #[no_mangle] unsafe fn validate_block(arguments: *const u8, arguments_len: usize) -> u64 { let params = - $crate::validate_block::parachain::load_params(arguments, arguments_len); + $crate::validate_block::polkadot_parachain::load_params(arguments, arguments_len); let res = $crate::validate_block::implementation::validate_block::< $block, $block_executor, >(params); - $crate::validate_block::parachain::write_result(&res) + $crate::validate_block::polkadot_parachain::write_result(&res) } } }; diff --git a/runtime/src/validate_block/tests.rs b/pallets/parachain-system/src/validate_block/tests.rs similarity index 97% rename from runtime/src/validate_block/tests.rs rename to pallets/parachain-system/src/validate_block/tests.rs index a1d634c7dbf..625d7285456 100644 --- a/runtime/src/validate_block/tests.rs +++ b/pallets/parachain-system/src/validate_block/tests.rs @@ -14,16 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use crate::ParachainBlockData; - -use cumulus_primitives::PersistedValidationData; +use cumulus_primitives_core::{PersistedValidationData, ParachainBlockData}; use cumulus_test_client::{ runtime::{Block, Hash, Header, UncheckedExtrinsic, WASM_BINARY}, transfer, Client, DefaultTestClientBuilderExt, InitBlockBuilder, LongestChain, TestClientBuilder, TestClientBuilderExt, }; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; -use parachain::primitives::{BlockData, HeadData, ValidationParams, ValidationResult}; +use polkadot_parachain::primitives::{BlockData, HeadData, ValidationParams, ValidationResult}; use sc_executor::{ error::Result, sp_wasm_interface::HostFunctions, WasmExecutionMethod, WasmExecutor, }; diff --git a/xcm-handler/Cargo.toml b/pallets/xcm-handler/Cargo.toml similarity index 85% rename from xcm-handler/Cargo.toml rename to pallets/xcm-handler/Cargo.toml index 5c38b3ce086..5ae34c28006 100644 --- a/xcm-handler/Cargo.toml +++ b/pallets/xcm-handler/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "xcm-handler" +name = "cumulus-pallet-xcm-handler" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" @@ -17,7 +17,7 @@ frame-system = { git = "https://github.com/paritytech/substrate", default-featur xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } # Cumulus Dependencies -cumulus-primitives = { path = "../primitives", default-features = false } +cumulus-primitives-core = { path = "../../primitives/core", default-features = false } [features] default = [ "std" ] @@ -26,6 +26,6 @@ std = [ "sp-std/std", "frame-support/std", "frame-system/std", - "cumulus-primitives/std", + "cumulus-primitives-core/std", "xcm/std" ] diff --git a/xcm-handler/src/lib.rs b/pallets/xcm-handler/src/lib.rs similarity index 99% rename from xcm-handler/src/lib.rs rename to pallets/xcm-handler/src/lib.rs index a8c25ec7af0..e64576cedbf 100644 --- a/xcm-handler/src/lib.rs +++ b/pallets/xcm-handler/src/lib.rs @@ -23,7 +23,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; -use cumulus_primitives::{ +use cumulus_primitives_core::{ DownwardMessageHandler, HrmpMessageHandler, HrmpMessageSender, InboundDownwardMessage, InboundHrmpMessage, OutboundHrmpMessage, ParaId, UpwardMessageSender, }; diff --git a/primitives/Cargo.toml b/primitives/core/Cargo.toml similarity index 88% rename from primitives/Cargo.toml rename to primitives/core/Cargo.toml index 22fb0a80558..fecb21bd70e 100644 --- a/primitives/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cumulus-primitives" +name = "cumulus-primitives-core" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" @@ -9,7 +9,6 @@ edition = "2018" sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sc-chain-spec = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -19,7 +18,7 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default- # Other dependencies codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = [ "derive" ] } -impl-trait-for-tuples = "0.1.3" +impl-trait-for-tuples = "0.2.1" # Polkadot dependencies polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -27,7 +26,6 @@ polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", def [features] default = [ "std" ] std = [ - "sc-chain-spec", "sp-std/std", "codec/std", "polkadot-primitives/std", diff --git a/primitives/src/lib.rs b/primitives/core/src/lib.rs similarity index 77% rename from primitives/src/lib.rs rename to primitives/core/src/lib.rs index 533ee3a8f85..bce98490895 100644 --- a/primitives/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -14,19 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -//! Cumulus related primitive types and traits. +//! Cumulus related core primitive types and traits. #![cfg_attr(not(feature = "std"), no_std)] +use sp_runtime::traits::Block as BlockT; + pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain::primitives::{Id as ParaId, UpwardMessage, ValidationParams}; pub use polkadot_primitives::v1::{ PersistedValidationData, AbridgedHostConfiguration, AbridgedHrmpChannel, }; -#[cfg(feature = "std")] -pub mod genesis; - /// A module that re-exports relevant relay chain definitions. pub mod relay_chain { pub use polkadot_core_primitives::*; @@ -133,3 +132,57 @@ pub trait HrmpMessageSender { pub trait OnValidationData { fn on_validation_data(data: &PersistedValidationData); } + +/// The parachain block that is created by a collator. +/// +/// This is send as PoV (proof of validity block) to the relay-chain validators. There it will be +/// passed to the parachain validation Wasm blob to be validated. +#[derive(codec::Encode, codec::Decode)] +pub struct ParachainBlockData { + /// The header of the parachain block. + header: B::Header, + /// The extrinsics of the parachain block. + extrinsics: sp_std::vec::Vec, + /// The data that is required to emulate the storage accesses executed by all extrinsics. + storage_proof: sp_trie::StorageProof, +} + +impl ParachainBlockData { + /// Creates a new instance of `Self`. + pub fn new( + header: ::Header, + extrinsics: sp_std::vec::Vec<::Extrinsic>, + storage_proof: sp_trie::StorageProof, + ) -> Self { + Self { + header, + extrinsics, + storage_proof, + } + } + + /// Convert `self` into the stored header. + pub fn into_header(self) -> B::Header { + self.header + } + + /// Returns the header. + pub fn header(&self) -> &B::Header { + &self.header + } + + /// Returns the extrinsics. + pub fn extrinsics(&self) -> &[B::Extrinsic] { + &self.extrinsics + } + + /// Returns the [`StorageProof`](sp_trie::StorageProof). + pub fn storage_proof(&self) -> &sp_trie::StorageProof { + &self.storage_proof + } + + /// Deconstruct into the inner parts. + pub fn deconstruct(self) -> (B::Header, sp_std::vec::Vec, sp_trie::StorageProof) { + (self.header, self.extrinsics, self.storage_proof) + } +} diff --git a/rococo-parachains/Cargo.toml b/rococo-parachains/Cargo.toml index adbc3d6e23c..253022518bb 100644 --- a/rococo-parachains/Cargo.toml +++ b/rococo-parachains/Cargo.toml @@ -56,11 +56,11 @@ sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "maste jsonrpc-core = "15.1.0" # Cumulus dependencies -cumulus-consensus = { path = "../consensus" } -cumulus-collator = { path = "../collator" } -cumulus-network = { path = "../network" } -cumulus-primitives = { path = "../primitives" } -cumulus-service = { path = "../service" } +cumulus-client-consensus = { path = "../client/consensus" } +cumulus-client-collator = { path = "../client/collator" } +cumulus-client-service = { path = "../client/service" } +cumulus-client-network = { path = "../client/network" } +cumulus-primitives-core = { path = "../primitives/core" } # Polkadot dependencies polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/rococo-parachains/contracts-runtime/src/lib.rs b/rococo-parachains/contracts-runtime/src/lib.rs index 0babce163e9..59a07551e39 100644 --- a/rococo-parachains/contracts-runtime/src/lib.rs +++ b/rococo-parachains/contracts-runtime/src/lib.rs @@ -409,4 +409,4 @@ impl_runtime_apis! { } } -cumulus_runtime::register_validate_block!(Block, Executive); +cumulus_pallet_parachain_system::register_validate_block!(Block, Executive); diff --git a/rococo-parachains/pallets/parachain-info/Cargo.toml b/rococo-parachains/pallets/parachain-info/Cargo.toml index d308dd86a31..42bf4afceab 100644 --- a/rococo-parachains/pallets/parachain-info/Cargo.toml +++ b/rococo-parachains/pallets/parachain-info/Cargo.toml @@ -11,14 +11,14 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -cumulus-primitives = { path = "../../../primitives", default-features = false } +cumulus-primitives-core = { path = "../../../primitives/core", default-features = false } [features] default = ["std"] std = [ - "codec/std", - "serde", - "cumulus-primitives/std", - "frame-support/std", - "frame-system/std", + "codec/std", + "serde", + "cumulus-primitives-core/std", + "frame-support/std", + "frame-system/std", ] diff --git a/rococo-parachains/pallets/parachain-info/src/lib.rs b/rococo-parachains/pallets/parachain-info/src/lib.rs index 548979e80a1..0a1422fdb68 100644 --- a/rococo-parachains/pallets/parachain-info/src/lib.rs +++ b/rococo-parachains/pallets/parachain-info/src/lib.rs @@ -20,7 +20,7 @@ use frame_support::{decl_module, decl_storage, traits::Get}; -use cumulus_primitives::ParaId; +use cumulus_primitives_core::ParaId; /// Configuration trait of this pallet. pub trait Config: frame_system::Config {} diff --git a/rococo-parachains/runtime/Cargo.toml b/rococo-parachains/runtime/Cargo.toml index ab3c1cb370f..e7c114ab6b9 100644 --- a/rococo-parachains/runtime/Cargo.toml +++ b/rococo-parachains/runtime/Cargo.toml @@ -34,10 +34,9 @@ pallet-sudo = { git = "https://github.com/paritytech/substrate", default-feature pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } # Cumulus dependencies -cumulus-runtime = { path = "../../runtime", default-features = false } -cumulus-parachain-system = { path = "../../parachain-system", default-features = false } -cumulus-primitives = { path = "../../primitives", default-features = false } -xcm-handler = { path = "../../xcm-handler", default-features = false } +cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system", default-features = false } +cumulus-primitives-core = { path = "../../primitives/core", default-features = false } +cumulus-pallet-xcm-handler = { path = "../../pallets/xcm-handler", default-features = false } # Polkadot dependencies polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -74,11 +73,10 @@ std = [ "pallet-transaction-payment/std", "parachain-info/std", "rococo-parachain-primitives/std", - "cumulus-runtime/std", - "cumulus-parachain-system/std", - "cumulus-primitives/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm-handler/std", + "cumulus-primitives-core/std", "xcm/std", "xcm-builder/std", "xcm-executor/std", - "xcm-handler/std", ] diff --git a/rococo-parachains/runtime/src/lib.rs b/rococo-parachains/runtime/src/lib.rs index 7f0c759aea6..4789bf6669a 100644 --- a/rococo-parachains/runtime/src/lib.rs +++ b/rococo-parachains/runtime/src/lib.rs @@ -229,7 +229,7 @@ impl pallet_sudo::Config for Runtime { type Event = Event; } -impl cumulus_parachain_system::Config for Runtime { +impl cumulus_pallet_parachain_system::Config for Runtime { type Event = Event; type OnValidationData = (); type SelfParaId = parachain_info::Module; @@ -242,7 +242,7 @@ impl parachain_info::Config for Runtime {} parameter_types! { pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent); pub const RococoNetwork: NetworkId = NetworkId::Polkadot; - pub RelayChainOrigin: Origin = xcm_handler::Origin::Relay.into(); + pub RelayChainOrigin: Origin = cumulus_pallet_xcm_handler::Origin::Relay.into(); pub Ancestry: MultiLocation = Junction::Parachain { id: ParachainInfo::parachain_id().into() }.into(); @@ -268,7 +268,7 @@ type LocalAssetTransactor = CurrencyAdapter< type LocalOriginConverter = ( SovereignSignedViaLocation, RelayChainAsNative, - SiblingParachainAsNative, + SiblingParachainAsNative, SignedAccountId32AsNative, ); @@ -284,7 +284,7 @@ impl Config for XcmConfig { type LocationInverter = LocationInverter; } -impl xcm_handler::Config for Runtime { +impl cumulus_pallet_xcm_handler::Config for Runtime { type Event = Event; type XcmExecutor = XcmExecutor; type UpwardMessageSender = ParachainSystem; @@ -302,10 +302,10 @@ construct_runtime! { Balances: pallet_balances::{Module, Call, Storage, Config, Event}, Sudo: pallet_sudo::{Module, Call, Storage, Config, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - ParachainSystem: cumulus_parachain_system::{Module, Call, Storage, Inherent, Event}, + ParachainSystem: cumulus_pallet_parachain_system::{Module, Call, Storage, Inherent, Event}, TransactionPayment: pallet_transaction_payment::{Module, Storage}, ParachainInfo: parachain_info::{Module, Storage, Config}, - XcmHandler: xcm_handler::{Module, Call, Event, Origin}, + XcmHandler: cumulus_pallet_xcm_handler::{Module, Call, Event, Origin}, } } @@ -414,4 +414,4 @@ impl_runtime_apis! { } } -cumulus_runtime::register_validate_block!(Block, Executive); +cumulus_pallet_parachain_system::register_validate_block!(Block, Executive); diff --git a/rococo-parachains/src/chain_spec.rs b/rococo-parachains/src/chain_spec.rs index 34b71675ea6..3bcb201696b 100644 --- a/rococo-parachains/src/chain_spec.rs +++ b/rococo-parachains/src/chain_spec.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use cumulus_primitives::ParaId; +use cumulus_primitives_core::ParaId; use hex_literal::hex; use rococo_parachain_primitives::{AccountId, Signature}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; diff --git a/rococo-parachains/src/command.rs b/rococo-parachains/src/command.rs index d664a70fa51..1d2578cb9cb 100644 --- a/rococo-parachains/src/command.rs +++ b/rococo-parachains/src/command.rs @@ -19,13 +19,14 @@ use crate::{ cli::{Cli, RelayChainCli, Subcommand}, }; use codec::Encode; -use cumulus_primitives::{genesis::generate_genesis_block, ParaId}; +use cumulus_primitives_core::ParaId; +use cumulus_client_service::genesis::generate_genesis_block; use log::info; use parachain_runtime::Block; use polkadot_parachain::primitives::AccountIdConversion; use sc_cli::{ - ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, - KeystoreParams, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, + ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, + NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, }; use sc_service::{ config::{BasePath, PrometheusConfig}, @@ -291,11 +292,12 @@ pub fn run() -> Result<()> { let task_executor = config.task_executor.clone(); let polkadot_config = SubstrateCli::create_configuration( - &polkadot_cli, - &polkadot_cli, - task_executor, - config.telemetry_handle.clone(), - ).map_err(|err| format!("Relay chain argument error: {}", err))?; + &polkadot_cli, + &polkadot_cli, + task_executor, + config.telemetry_handle.clone(), + ) + .map_err(|err| format!("Relay chain argument error: {}", err))?; let collator = cli.run.base.validator || cli.collator; info!("Parachain id: {:?}", id); diff --git a/rococo-parachains/src/service.rs b/rococo-parachains/src/service.rs index a2d3a247230..16aebc21d5e 100644 --- a/rococo-parachains/src/service.rs +++ b/rococo-parachains/src/service.rs @@ -14,8 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use cumulus_network::build_block_announce_validator; -use cumulus_service::{ +use cumulus_client_network::build_block_announce_validator; +use cumulus_primitives_core::ParaId; +use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, }; use parachain_runtime::RuntimeApi; @@ -69,7 +70,7 @@ pub fn new_partial( client.clone(), ); - let import_queue = cumulus_consensus::import_queue::import_queue( + let import_queue = cumulus_client_consensus::import_queue::import_queue( client.clone(), client.clone(), inherent_data_providers.clone(), @@ -100,7 +101,7 @@ async fn start_node_impl( parachain_config: Configuration, collator_key: CollatorPair, polkadot_config: Configuration, - id: polkadot_primitives::v0::Id, + id: ParaId, validator: bool, rpc_ext_builder: RB, ) -> sc_service::error::Result<(TaskManager, Arc>)> @@ -118,7 +119,7 @@ where let parachain_config = prepare_node_config(parachain_config); let polkadot_full_node = - cumulus_service::build_polkadot_full_node(polkadot_config, collator_key.public()).map_err( + cumulus_client_service::build_polkadot_full_node(polkadot_config, collator_key.public()).map_err( |e| match e { polkadot_service::Error::Sub(x) => x, s => format!("{}", s).into(), @@ -228,7 +229,7 @@ pub async fn start_node( parachain_config: Configuration, collator_key: CollatorPair, polkadot_config: Configuration, - id: polkadot_primitives::v0::Id, + id: ParaId, validator: bool, ) -> sc_service::error::Result<(TaskManager, Arc>)> { start_node_impl( diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml deleted file mode 100644 index 9d1ada4faee..00000000000 --- a/runtime/Cargo.toml +++ /dev/null @@ -1,57 +0,0 @@ -[package] -name = "cumulus-runtime" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -# Other dependencies -codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = [ "derive" ] } -hash-db = { version = "0.15.2", default-features = false } -memory-db = { version = "0.26.0", default-features = false } -trie-db = { version = "0.22.0", default-features = false } - -# Cumulus dependencies -cumulus-primitives = { path = "../primitives", default-features = false } - -# Substrate dependencies -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-state-machine = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-externalities = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } - -# Polkadot dependencies -parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", default-features = false, features = [ "wasm-api" ], branch = "master" } - -[dev-dependencies] -sc-client-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } -cumulus-test-relay-sproof-builder = { path = "../test/relay-sproof-builder" } -cumulus-test-client = { path = "../test/client" } -env_logger = "0.7.1" - -[features] -default = ["std"] -std = [ - "codec/std", - "cumulus-primitives/std", - "sp-std/std", - "sp-io/std", - "sp-runtime/std", - "sp-core/std", - "frame-executive/std", - "memory-db/std", - "hash-db/std", - "trie-db/std", - "sp-state-machine/std", - "sp-externalities/std", - "sp-trie/std", - "parachain/std", -] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs deleted file mode 100644 index 334a3111e8f..00000000000 --- a/runtime/src/lib.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2019 Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus 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. - -// Cumulus 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 Cumulus. If not, see . - -#![cfg_attr(not(feature = "std"), no_std)] - -///! The Cumulus runtime to make a runtime a parachain. -use codec::{Decode, Encode}; -use sp_runtime::traits::Block as BlockT; -use sp_std::vec::Vec; -use sp_trie::StorageProof; - -#[cfg(not(feature = "std"))] -#[doc(hidden)] -pub use sp_std::slice; - -#[macro_use] -pub mod validate_block; - -/// The parachain block that is created on a collator and validated by a validator. -#[derive(Encode, Decode)] -pub struct ParachainBlockData { - /// The header of the parachain block. - header: ::Header, - /// The extrinsics of the parachain block without the `PolkadotInherent`. - extrinsics: Vec<::Extrinsic>, - /// The data that is required to emulate the storage accesses executed by all extrinsics. - storage_proof: StorageProof, -} - -impl ParachainBlockData { - /// Creates a new instance of `Self`. - pub fn new( - header: ::Header, - extrinsics: Vec<::Extrinsic>, - storage_proof: StorageProof, - ) -> Self { - Self { - header, - extrinsics, - storage_proof, - } - } - - /// Convert `self` into the stored header. - pub fn into_header(self) -> B::Header { - self.header - } - - /// Returns the header. - pub fn header(&self) -> &B::Header { - &self.header - } - - /// Returns the extrinsics. - pub fn extrinsics(&self) -> &[B::Extrinsic] { - &self.extrinsics - } - - /// Returns the [`StorageProof`]. - pub fn storage_proof(&self) -> &StorageProof { - &self.storage_proof - } -} diff --git a/test/client/Cargo.toml b/test/client/Cargo.toml index 056050ae99e..b7d586f5865 100644 --- a/test/client/Cargo.toml +++ b/test/client/Cargo.toml @@ -26,7 +26,7 @@ pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "m cumulus-test-runtime = { path = "../runtime" } cumulus-test-service = { path = "../service" } cumulus-test-relay-sproof-builder = { path = "../relay-sproof-builder" } -cumulus-primitives = { path = "../../primitives" } +cumulus-primitives-core = { path = "../../primitives/core" } # Polkadot deps polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/test/client/src/block_builder.rs b/test/client/src/block_builder.rs index cd532cf36d6..fcd5bfe1983 100644 --- a/test/client/src/block_builder.rs +++ b/test/client/src/block_builder.rs @@ -15,7 +15,7 @@ // along with Cumulus. If not, see . use crate::{Backend, Client}; -use cumulus_primitives::{ +use cumulus_primitives_core::{ inherents::{SystemInherentData, SYSTEM_INHERENT_IDENTIFIER}, PersistedValidationData, }; use cumulus_test_runtime::{Block, GetLastTimestamp}; diff --git a/test/relay-sproof-builder/Cargo.toml b/test/relay-sproof-builder/Cargo.toml index d3bf91f8425..9342ff74721 100644 --- a/test/relay-sproof-builder/Cargo.toml +++ b/test/relay-sproof-builder/Cargo.toml @@ -17,7 +17,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } # Cumulus dependencies -cumulus-primitives = { path = "../../primitives", default-features = false } +cumulus-primitives-core = { path = "../../primitives/core", default-features = false } [features] default = [ "std" ] @@ -26,5 +26,5 @@ std = [ "sp-state-machine/std", "sp-runtime/std", "sp-std/std", - "cumulus-primitives/std", + "cumulus-primitives-core/std", ] diff --git a/test/relay-sproof-builder/src/lib.rs b/test/relay-sproof-builder/src/lib.rs index 148540a6822..693106b3943 100644 --- a/test/relay-sproof-builder/src/lib.rs +++ b/test/relay-sproof-builder/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -use cumulus_primitives::{relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId}; +use cumulus_primitives_core::{relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId}; use sp_runtime::traits::HashFor; use sp_state_machine::MemoryDB; use sp_std::collections::btree_map::BTreeMap; @@ -44,7 +44,7 @@ impl Default for RelayStateSproofBuilder { fn default() -> Self { RelayStateSproofBuilder { para_id: ParaId::from(200), - host_config: cumulus_primitives::AbridgedHostConfiguration { + host_config: cumulus_primitives_core::AbridgedHostConfiguration { max_code_size: 2 * 1024 * 1024, max_head_data_size: 1024 * 1024, max_upward_queue_count: 8, diff --git a/test/runtime/Cargo.toml b/test/runtime/Cargo.toml index c05cba49467..b6dad7f162f 100644 --- a/test/runtime/Cargo.toml +++ b/test/runtime/Cargo.toml @@ -30,9 +30,8 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } # Cumulus dependencies -cumulus-parachain-system = { path = "../../parachain-system", default-features = false } -cumulus-primitives = { path = "../../primitives", default-features = false } -cumulus-runtime = { path = "../../runtime", default-features = false } +cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system", default-features = false } +cumulus-primitives-core = { path = "../../primitives/core", default-features = false } # Polkadot dependencies polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -44,9 +43,8 @@ substrate-wasm-builder = "3.0.0" default = [ "std" ] std = [ "codec/std", - "cumulus-parachain-system/std", - "cumulus-primitives/std", - "cumulus-runtime/std", + "cumulus-pallet-parachain-system/std", + "cumulus-primitives-core/std", "frame-executive/std", "frame-support/std", "frame-system/std", diff --git a/test/runtime/src/lib.rs b/test/runtime/src/lib.rs index c96bed0532d..14b8d511aeb 100644 --- a/test/runtime/src/lib.rs +++ b/test/runtime/src/lib.rs @@ -207,7 +207,7 @@ impl pallet_sudo::Config for Runtime { type Event = Event; } -impl cumulus_parachain_system::Config for Runtime { +impl cumulus_pallet_parachain_system::Config for Runtime { type SelfParaId = ParachainId; type Event = Event; type OnValidationData = (); @@ -216,7 +216,7 @@ impl cumulus_parachain_system::Config for Runtime { } parameter_types! { - pub storage ParachainId: cumulus_primitives::ParaId = 100.into(); + pub storage ParachainId: cumulus_primitives_core::ParaId = 100.into(); } construct_runtime! { @@ -230,7 +230,7 @@ construct_runtime! { Balances: pallet_balances::{Module, Call, Storage, Config, Event}, Sudo: pallet_sudo::{Module, Call, Storage, Config, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - ParachainSystem: cumulus_parachain_system::{Module, Call, Storage, Inherent, Event}, + ParachainSystem: cumulus_pallet_parachain_system::{Module, Call, Storage, Inherent, Event}, TransactionPayment: pallet_transaction_payment::{Module, Storage}, } } @@ -371,4 +371,4 @@ impl_runtime_apis! { } } -cumulus_runtime::register_validate_block!(Block, Executive); +cumulus_pallet_parachain_system::register_validate_block!(Block, Executive); diff --git a/test/service/Cargo.toml b/test/service/Cargo.toml index 4421234d8f9..768d9c6eabf 100644 --- a/test/service/Cargo.toml +++ b/test/service/Cargo.toml @@ -43,10 +43,10 @@ polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" } # Cumulus -cumulus-consensus = { path = "../../consensus" } -cumulus-network = { path = "../../network" } -cumulus-primitives = { path = "../../primitives" } -cumulus-service = { path = "../../service" } +cumulus-client-consensus = { path = "../../client/consensus" } +cumulus-client-network = { path = "../../client/network" } +cumulus-client-service = { path = "../../client/service" } +cumulus-primitives-core = { path = "../../primitives/core" } cumulus-test-runtime = { path = "../runtime" } # RPC related dependencies diff --git a/test/service/src/chain_spec.rs b/test/service/src/chain_spec.rs index 7d68d1c6180..6e48821b509 100644 --- a/test/service/src/chain_spec.rs +++ b/test/service/src/chain_spec.rs @@ -16,7 +16,7 @@ #![allow(missing_docs)] -use cumulus_primitives::ParaId; +use cumulus_primitives_core::ParaId; use cumulus_test_runtime::{AccountId, Signature}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; diff --git a/test/service/src/genesis.rs b/test/service/src/genesis.rs index 92e05d0f4ed..34f3457c9f7 100644 --- a/test/service/src/genesis.rs +++ b/test/service/src/genesis.rs @@ -15,7 +15,8 @@ // along with Cumulus. If not, see . use codec::Encode; -use cumulus_primitives::{genesis::generate_genesis_block, ParaId}; +use cumulus_primitives_core::ParaId; +use cumulus_client_service::genesis::generate_genesis_block; use cumulus_test_runtime::Block; use polkadot_primitives::v0::HeadData; use sp_runtime::traits::Block as BlockT; diff --git a/test/service/src/lib.rs b/test/service/src/lib.rs index d21dacfc3ff..6f17a38c8fc 100644 --- a/test/service/src/lib.rs +++ b/test/service/src/lib.rs @@ -26,9 +26,9 @@ pub use cumulus_test_runtime as runtime; pub use genesis::*; use core::future::Future; -use cumulus_network::BlockAnnounceValidator; -use cumulus_primitives::ParaId; -use cumulus_service::{ +use cumulus_client_network::BlockAnnounceValidator; +use cumulus_primitives_core::ParaId; +use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, }; use cumulus_test_runtime::{NodeBlock as Block, RuntimeApi}; @@ -93,7 +93,7 @@ pub fn new_partial( client.clone(), ); - let import_queue = cumulus_consensus::import_queue::import_queue( + let import_queue = cumulus_client_consensus::import_queue::import_queue( client.clone(), client.clone(), inherent_data_providers.clone(), diff --git a/test/service/tests/integration.rs b/test/service/tests/integration.rs index 4cc5d652252..cdbef977652 100644 --- a/test/service/tests/integration.rs +++ b/test/service/tests/integration.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use cumulus_primitives::ParaId; +use cumulus_primitives_core::ParaId; use cumulus_test_service::initial_head_data; use futures::join; use sc_service::TaskExecutor;