The great refactor (#325)

* Move pallets to pallets folder and rename them

* Move genesis file to service

* Rename primitives to primitives-core

* Delete cumulus-runtime

* Move stuff to client folder and rename
This commit is contained in:
Bastian Köcher
2021-02-10 13:07:21 +01:00
committed by GitHub
parent a4998998a9
commit 119e0859b9
48 changed files with 436 additions and 547 deletions
+108 -130
View File
@@ -1070,12 +1070,11 @@ dependencies = [
] ]
[[package]] [[package]]
name = "cumulus-collator" name = "cumulus-client-collator"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-network", "cumulus-client-network",
"cumulus-primitives", "cumulus-primitives-core",
"cumulus-runtime",
"cumulus-test-client", "cumulus-test-client",
"cumulus-test-runtime", "cumulus-test-runtime",
"env_logger", "env_logger",
@@ -1106,7 +1105,7 @@ dependencies = [
] ]
[[package]] [[package]]
name = "cumulus-consensus" name = "cumulus-client-consensus"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-test-client", "cumulus-test-client",
@@ -1131,10 +1130,9 @@ dependencies = [
] ]
[[package]] [[package]]
name = "cumulus-network" name = "cumulus-client-network"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-primitives",
"cumulus-test-service", "cumulus-test-service",
"derive_more 0.99.11", "derive_more 0.99.11",
"futures 0.3.12", "futures 0.3.12",
@@ -1161,89 +1159,18 @@ dependencies = [
] ]
[[package]] [[package]]
name = "cumulus-parachain-system" name = "cumulus-client-service"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-primitives", "cumulus-client-collator",
"cumulus-runtime", "cumulus-client-consensus",
"cumulus-test-relay-sproof-builder", "cumulus-primitives-core",
"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",
"parity-scale-codec",
"polkadot-core-primitives",
"polkadot-parachain",
"polkadot-primitives",
"sc-chain-spec",
"sp-core",
"sp-inherents",
"sp-runtime",
"sp-std",
"sp-trie",
]
[[package]]
name = "cumulus-runtime"
version = "0.1.0"
dependencies = [
"cumulus-primitives",
"cumulus-test-client",
"cumulus-test-relay-sproof-builder",
"env_logger",
"frame-executive",
"hash-db",
"memory-db",
"parity-scale-codec",
"polkadot-parachain",
"sc-client-api",
"sc-executor",
"sp-blockchain",
"sp-consensus",
"sp-core",
"sp-externalities",
"sp-io",
"sp-keyring",
"sp-runtime",
"sp-state-machine",
"sp-std",
"sp-trie",
"trie-db",
]
[[package]]
name = "cumulus-service"
version = "0.1.0"
dependencies = [
"cumulus-collator",
"cumulus-consensus",
"cumulus-primitives",
"futures 0.3.12", "futures 0.3.12",
"parity-scale-codec",
"polkadot-overseer", "polkadot-overseer",
"polkadot-primitives", "polkadot-primitives",
"polkadot-service", "polkadot-service",
"sc-chain-spec",
"sc-client-api", "sc-client-api",
"sc-service", "sc-service",
"sc-tracing", "sc-tracing",
@@ -1256,11 +1183,76 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "cumulus-pallet-parachain-system"
version = "0.1.0"
dependencies = [
"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-pallet-xcm-handler"
version = "0.1.0"
dependencies = [
"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",
"sp-core",
"sp-inherents",
"sp-runtime",
"sp-std",
"sp-trie",
]
[[package]] [[package]]
name = "cumulus-test-client" name = "cumulus-test-client"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-primitives", "cumulus-primitives-core",
"cumulus-test-relay-sproof-builder", "cumulus-test-relay-sproof-builder",
"cumulus-test-runtime", "cumulus-test-runtime",
"cumulus-test-service", "cumulus-test-service",
@@ -1288,9 +1280,9 @@ dependencies = [
name = "cumulus-test-parachain-runtime" name = "cumulus-test-parachain-runtime"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-parachain-system", "cumulus-pallet-parachain-system",
"cumulus-primitives", "cumulus-pallet-xcm-handler",
"cumulus-runtime", "cumulus-primitives-core",
"frame-executive", "frame-executive",
"frame-support", "frame-support",
"frame-system", "frame-system",
@@ -1319,14 +1311,13 @@ dependencies = [
"xcm", "xcm",
"xcm-builder", "xcm-builder",
"xcm-executor", "xcm-executor",
"xcm-handler",
] ]
[[package]] [[package]]
name = "cumulus-test-relay-sproof-builder" name = "cumulus-test-relay-sproof-builder"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-primitives", "cumulus-primitives-core",
"parity-scale-codec", "parity-scale-codec",
"polkadot-primitives", "polkadot-primitives",
"sp-runtime", "sp-runtime",
@@ -1338,9 +1329,8 @@ dependencies = [
name = "cumulus-test-runtime" name = "cumulus-test-runtime"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-parachain-system", "cumulus-pallet-parachain-system",
"cumulus-primitives", "cumulus-primitives-core",
"cumulus-runtime",
"frame-executive", "frame-executive",
"frame-support", "frame-support",
"frame-system", "frame-system",
@@ -1370,10 +1360,10 @@ dependencies = [
name = "cumulus-test-service" name = "cumulus-test-service"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-consensus", "cumulus-client-consensus",
"cumulus-network", "cumulus-client-network",
"cumulus-primitives", "cumulus-client-service",
"cumulus-service", "cumulus-primitives-core",
"cumulus-test-runtime", "cumulus-test-runtime",
"futures 0.3.12", "futures 0.3.12",
"jsonrpc-core", "jsonrpc-core",
@@ -1970,7 +1960,7 @@ dependencies = [
"bitflags", "bitflags",
"frame-metadata", "frame-metadata",
"frame-support-procedural", "frame-support-procedural",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"log", "log",
"once_cell", "once_cell",
"parity-scale-codec", "parity-scale-codec",
@@ -2028,7 +2018,7 @@ version = "2.0.1"
source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"serde", "serde",
"sp-core", "sp-core",
@@ -2780,9 +2770,9 @@ dependencies = [
[[package]] [[package]]
name = "impl-trait-for-tuples" name = "impl-trait-for-tuples"
version = "0.2.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f65a8ecf74feeacdab8d38cb129e550ca871cccaa7d1921d8636ecd75534903" checksum = "d5dacb10c5b3bb92d46ba347505a9041e676bb20ad220101326bffb0c93031ee"
dependencies = [ dependencies = [
"proc-macro2 1.0.24", "proc-macro2 1.0.24",
"quote 1.0.8", "quote 1.0.8",
@@ -4296,7 +4286,7 @@ source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b
dependencies = [ dependencies = [
"frame-support", "frame-support",
"frame-system", "frame-system",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"sp-authorship", "sp-authorship",
"sp-inherents", "sp-inherents",
@@ -4675,7 +4665,7 @@ dependencies = [
"frame-benchmarking", "frame-benchmarking",
"frame-support", "frame-support",
"frame-system", "frame-system",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"serde", "serde",
"sp-inherents", "sp-inherents",
@@ -4749,7 +4739,7 @@ source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b
dependencies = [ dependencies = [
"frame-support", "frame-support",
"frame-system", "frame-system",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"pallet-balances", "pallet-balances",
"parity-scale-codec", "parity-scale-codec",
"serde", "serde",
@@ -4790,7 +4780,7 @@ dependencies = [
name = "parachain-info" name = "parachain-info"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cumulus-primitives", "cumulus-primitives-core",
"frame-support", "frame-support",
"frame-system", "frame-system",
"parity-scale-codec", "parity-scale-codec",
@@ -4890,7 +4880,7 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"ethereum-types", "ethereum-types",
"hashbrown", "hashbrown",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"lru", "lru",
"parity-util-mem-derive", "parity-util-mem-derive",
"parking_lot 0.11.1", "parking_lot 0.11.1",
@@ -6888,11 +6878,11 @@ name = "rococo-collator"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"assert_cmd", "assert_cmd",
"cumulus-collator", "cumulus-client-collator",
"cumulus-consensus", "cumulus-client-consensus",
"cumulus-network", "cumulus-client-network",
"cumulus-primitives", "cumulus-client-service",
"cumulus-service", "cumulus-primitives-core",
"cumulus-test-parachain-runtime", "cumulus-test-parachain-runtime",
"derive_more 0.15.0", "derive_more 0.15.0",
"exit-future 0.1.4", "exit-future 0.1.4",
@@ -7219,7 +7209,7 @@ name = "sc-chain-spec"
version = "2.0.1" version = "2.0.1"
source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916"
dependencies = [ dependencies = [
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"sc-chain-spec-derive", "sc-chain-spec-derive",
"sc-consensus-babe", "sc-consensus-babe",
@@ -8918,7 +8908,7 @@ source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b
dependencies = [ dependencies = [
"either", "either",
"hash256-std-hasher", "hash256-std-hasher",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"log", "log",
"parity-scale-codec", "parity-scale-codec",
"parity-util-mem", "parity-util-mem",
@@ -8937,7 +8927,7 @@ name = "sp-runtime-interface"
version = "2.0.1" version = "2.0.1"
source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916"
dependencies = [ dependencies = [
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"primitive-types", "primitive-types",
"sp-externalities", "sp-externalities",
@@ -9064,7 +9054,7 @@ name = "sp-timestamp"
version = "2.0.1" version = "2.0.1"
source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916"
dependencies = [ dependencies = [
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"sp-api", "sp-api",
"sp-inherents", "sp-inherents",
@@ -9145,7 +9135,7 @@ name = "sp-wasm-interface"
version = "2.0.1" version = "2.0.1"
source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916" source = "git+https://github.com/paritytech/substrate#cc71cca1d3087bf62381a9d60b14ca6235b4b916"
dependencies = [ dependencies = [
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"sp-std", "sp-std",
"wasmi", "wasmi",
@@ -10096,7 +10086,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 0.1.10",
"rand 0.3.23", "rand 0.7.3",
"static_assertions", "static_assertions",
] ]
@@ -10845,7 +10835,7 @@ version = "0.8.22"
source = "git+https://github.com/paritytech/polkadot#e526a15b1fa9bb7ac5378541d9f32667618e18c4" source = "git+https://github.com/paritytech/polkadot#e526a15b1fa9bb7ac5378541d9f32667618e18c4"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"impl-trait-for-tuples 0.2.0", "impl-trait-for-tuples 0.2.1",
"parity-scale-codec", "parity-scale-codec",
"sp-arithmetic", "sp-arithmetic",
"sp-core", "sp-core",
@@ -10855,18 +10845,6 @@ dependencies = [
"xcm", "xcm",
] ]
[[package]]
name = "xcm-handler"
version = "0.1.0"
dependencies = [
"cumulus-primitives",
"frame-support",
"frame-system",
"parity-scale-codec",
"sp-std",
"xcm",
]
[[package]] [[package]]
name = "yamux" name = "yamux"
version = "0.8.0" version = "0.8.0"
+7 -8
View File
@@ -1,21 +1,20 @@
[workspace] [workspace]
members = [ members = [
"consensus", "client/consensus",
"network", "client/network",
"parachain-system", "client/service",
"primitives", "pallets/parachain-system",
"pallets/xcm-handler",
"primitives/core",
"rococo-parachains/", "rococo-parachains/",
"rococo-parachains/pallets/parachain-info", "rococo-parachains/pallets/parachain-info",
"rococo-parachains/primitives", "rococo-parachains/primitives",
"rococo-parachains/runtime", "rococo-parachains/runtime",
"runtime",
"service",
"test/runtime", "test/runtime",
"test/client", "test/client",
"test/service", "test/service",
"test/relay-sproof-builder", "test/relay-sproof-builder",
"xcm-handler",
] ]
[profile.release] [profile.release]
panic = 'unwind' panic = "unwind"
-5
View File
@@ -25,11 +25,6 @@ follow,
[finalize](https://wiki.polkadot.network/docs/en/learn-consensus#probabilistic-vs-provable-finality), [finalize](https://wiki.polkadot.network/docs/en/learn-consensus#probabilistic-vs-provable-finality),
and treat as best. and treat as best.
## Runtime
The [`cumulus-runtime`](runtime) is wrapper around Substrate runtimes that provides parachain
validation capabilities and proof-generation routines.
## Collator ## Collator
A Polkadot [collator](https://wiki.polkadot.network/docs/en/learn-collator) for the parachain is A Polkadot [collator](https://wiki.polkadot.network/docs/en/learn-collator) for the parachain is
@@ -1,5 +1,5 @@
[package] [package]
name = "cumulus-collator" name = "cumulus-client-collator"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" 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" } polkadot-node-subsystem = { git = "https://github.com/paritytech/polkadot", branch = "master" }
# Cumulus dependencies # Cumulus dependencies
cumulus-network = { path = "../network" } cumulus-client-network = { path = "../network" }
cumulus-primitives = { path = "../primitives" } cumulus-primitives-core = { path = "../../primitives/core" }
cumulus-runtime = { path = "../runtime" }
# Other dependencies # Other dependencies
log = "0.4.8" log = "0.4.8"
@@ -37,8 +36,8 @@ parking_lot = "0.9"
[dev-dependencies] [dev-dependencies]
# Cumulus dependencies # Cumulus dependencies
cumulus-test-runtime = { path = "../test/runtime" } cumulus-test-runtime = { path = "../../test/runtime" }
cumulus-test-client = { path = "../test/client" } cumulus-test-client = { path = "../../test/client" }
# Substrate dependencies # Substrate dependencies
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -16,13 +16,12 @@
//! Cumulus Collator implementation for Substrate. //! Cumulus Collator implementation for Substrate.
use cumulus_network::WaitToAnnounce; use cumulus_client_network::WaitToAnnounce;
use cumulus_primitives::{ use cumulus_primitives_core::{
inherents, inherents, ParachainBlockData,
well_known_keys, InboundDownwardMessage, InboundHrmpMessage, OutboundHrmpMessage, well_known_keys, InboundDownwardMessage, InboundHrmpMessage, OutboundHrmpMessage,
PersistedValidationData, relay_chain, PersistedValidationData, relay_chain,
}; };
use cumulus_runtime::ParachainBlockData;
use sc_client_api::{BlockBackend, StateBackend}; use sc_client_api::{BlockBackend, StateBackend};
use sp_consensus::{ use sp_consensus::{
@@ -1,5 +1,5 @@
[package] [package]
name = "cumulus-consensus" name = "cumulus-client-consensus"
description = "Proxy Polkadot's consensus as a consensus engine for Substrate" description = "Proxy Polkadot's consensus as a consensus engine for Substrate"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
@@ -32,8 +32,8 @@ tracing = "0.1.22"
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Cumulus dependencies # Cumulus dependencies
cumulus-test-runtime = { path = "../test/runtime" } cumulus-test-runtime = { path = "../../test/runtime" }
cumulus-test-client = { path = "../test/client" } cumulus-test-client = { path = "../../test/client" }
# Other deps # Other deps
futures-timer = "3.0.2" futures-timer = "3.0.2"
@@ -1,5 +1,5 @@
[package] [package]
name = "cumulus-network" name = "cumulus-client-network"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Cumulus-specific networking protocol" 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-service = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-parachain = { 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 # other deps
codec = { package = "parity-scale-codec", version = "2.0.0", features = [ "derive" ] } codec = { package = "parity-scale-codec", version = "2.0.0", features = [ "derive" ] }
futures = { version = "0.3.1", features = ["compat"] } futures = { version = "0.3.1", features = ["compat"] }
@@ -36,7 +33,7 @@ derive_more = "0.99.2"
[dev-dependencies] [dev-dependencies]
# Cumulus deps # Cumulus deps
cumulus-test-service = { path = "../test/service" } cumulus-test-service = { path = "../../test/service" }
# Polkadot deps # Polkadot deps
polkadot-test-client = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-test-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }
@@ -1,18 +1,19 @@
[package] [package]
name = "cumulus-service" name = "cumulus-client-service"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
# Cumulus dependencies # Cumulus dependencies
cumulus-consensus = { path = "../consensus" } cumulus-client-consensus = { path = "../consensus" }
cumulus-collator = { path = "../collator" } cumulus-client-collator = { path = "../collator" }
cumulus-primitives = { path = "../primitives" } cumulus-primitives-core = { path = "../../primitives/core" }
# Substrate dependencies # 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-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" } sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { 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" } 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 # Other deps
futures = "0.3.6" futures = "0.3.6"
tracing = "0.1.22" tracing = "0.1.22"
codec = { package = "parity-scale-codec", version = "2.0.0" }
@@ -18,7 +18,7 @@ use codec::Encode;
use sc_chain_spec::ChainSpec; use sc_chain_spec::ChainSpec;
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero}; 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<Block: BlockT>( pub fn generate_genesis_block<Block: BlockT>(
chain_spec: &Box<dyn ChainSpec>, chain_spec: &Box<dyn ChainSpec>,
) -> Result<Block, String> { ) -> Result<Block, String> {
@@ -18,7 +18,7 @@
//! //!
//! Provides functions for starting a collator node or a normal full node. //! 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 futures::{Future, FutureExt};
use polkadot_overseer::OverseerHandler; use polkadot_overseer::OverseerHandler;
use polkadot_primitives::v1::{Block as PBlock, CollatorId, CollatorPair}; 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 sp_runtime::traits::{BlakeTwo256, Block as BlockT};
use std::{marker::PhantomData, sync::Arc}; use std::{marker::PhantomData, sync::Arc};
pub mod genesis;
/// Polkadot full node handles. /// Polkadot full node handles.
type PFullNode<C> = polkadot_service::NewFull<C>; type PFullNode<C> = polkadot_service::NewFull<C>;
@@ -188,7 +190,7 @@ where
PClient: AbstractClient<PBlock, PBackend, Api = Api> + 'static, PClient: AbstractClient<PBlock, PBackend, Api = Api> + 'static,
{ {
async move { async move {
cumulus_collator::start_collator(cumulus_collator::StartCollatorParams { cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams {
proposer_factory: self.proposer_factory, proposer_factory: self.proposer_factory,
inherent_data_providers: self.inherent_data_providers, inherent_data_providers: self.inherent_data_providers,
backend: self.backend, backend: self.backend,
@@ -289,7 +291,7 @@ where
Api: RuntimeApiCollection<StateBackend = PBackend::State>, Api: RuntimeApiCollection<StateBackend = PBackend::State>,
PClient: AbstractClient<PBlock, PBackend, Api = Api> + 'static, PClient: AbstractClient<PBlock, PBackend, Api = Api> + 'static,
{ {
let consensus = cumulus_consensus::run_parachain_consensus( let consensus = cumulus_client_consensus::run_parachain_consensus(
self.para_id, self.para_id,
self.client, self.client,
client, client,
+1 -1
View File
@@ -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 To convert a Substrate runtime into a Parachain runtime, the following code needs to be added to the
runtime: runtime:
```rust ```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 This macro call expects the `Block` and `Executive` type. It generates the `validate_block` function
@@ -1,17 +1,16 @@
[package] [package]
name = "cumulus-parachain-system" name = "cumulus-pallet-parachain-system"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
description = "pallet to manage parachain upgrades" description = "Base pallet for cumulus-based parachains"
[dependencies] [dependencies]
# Cumulus dependencies # Cumulus dependencies
cumulus-primitives = { path = "../primitives", default-features = false } cumulus-primitives-core = { path = "../../primitives/core", default-features = false }
cumulus-runtime = { path = "../runtime", default-features = false }
# Polkadot dependencies # 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 # Substrate dependencies
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } 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-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" } 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-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-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-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 # Other Dependencies
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"]} codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"]}
serde = { version = "1.0.101", optional = true, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] }
hash-db = { version = "0.15.2", default-features = false } 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] [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" } 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" } 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" hex-literal = "0.2.1"
lazy_static = "1.4" 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] [features]
default = ['std'] default = [ "std" ]
std = [ std = [
'serde', "serde",
'codec/std', "codec/std",
'frame-support/std', "frame-support/std",
'pallet-balances/std', "pallet-balances/std",
'cumulus-runtime/std', "sp-core/std",
'sp-core/std', "sp-runtime/std",
'sp-runtime/std', "sp-io/std",
'sp-io/std', "sp-std/std",
'sp-std/std', "hash-db/std",
'hash-db/std', "memory-db/std",
'sp-state-machine/std', "trie-db/std",
'sp-trie/std', "sp-state-machine/std",
'frame-system/std', "sp-trie/std",
'cumulus-primitives/std', "sp-externalities/std",
"frame-system/std",
"frame-executive/std",
"cumulus-primitives-core/std",
] ]
@@ -16,7 +16,7 @@
#![cfg_attr(not(feature = "std"), no_std)] #![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: //! 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. //! Users must ensure that they register this pallet as an inherent provider.
use cumulus_primitives::{ use cumulus_primitives_core::{
inherents::{SystemInherentData, SYSTEM_INHERENT_IDENTIFIER}, inherents::{SystemInherentData, SYSTEM_INHERENT_IDENTIFIER},
relay_chain, relay_chain,
well_known_keys::{self, NEW_VALIDATION_CODE, VALIDATION_DATA}, well_known_keys::{self, NEW_VALIDATION_CODE, VALIDATION_DATA},
@@ -43,13 +43,15 @@ use frame_support::{
weights::{DispatchClass, Weight}, weights::{DispatchClass, Weight},
}; };
use frame_system::{ensure_none, ensure_root}; 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_inherents::{InherentData, InherentIdentifier, ProvideInherent};
use sp_runtime::traits::{BlakeTwo256, Hash}; use sp_runtime::traits::{BlakeTwo256, Hash};
use sp_std::{cmp, collections::btree_map::BTreeMap, vec::Vec}; use sp_std::{cmp, collections::btree_map::BTreeMap, vec::Vec};
mod relay_state_snapshot; mod relay_state_snapshot;
use relay_state_snapshot::MessagingStateSnapshot; #[macro_use]
pub mod validate_block;
/// The pallet's configuration trait. /// The pallet's configuration trait.
pub trait Config: frame_system::Config { pub trait Config: frame_system::Config {
@@ -475,7 +477,7 @@ impl<T: Config> Module<T> {
/// This is similar to [`process_inbound_downward_messages`], but works on multiple inbound /// This is similar to [`process_inbound_downward_messages`], but works on multiple inbound
/// channels. /// channels.
fn process_inbound_horizontal_messages( fn process_inbound_horizontal_messages(
ingress_channels: &[(ParaId, cumulus_primitives::AbridgedHrmpChannel)], ingress_channels: &[(ParaId, cumulus_primitives_core::AbridgedHrmpChannel)],
horizontal_messages: BTreeMap<ParaId, Vec<InboundHrmpMessage>>, horizontal_messages: BTreeMap<ParaId, Vec<InboundHrmpMessage>>,
) -> DispatchResult { ) -> DispatchResult {
// First, check that all submitted messages are sent from channels that exist. The channel // First, check that all submitted messages are sent from channels that exist. The channel
@@ -598,9 +600,8 @@ impl<T: Config> Module<T> {
return None; return None;
} }
let relay_blocks_since_last_upgrade = vfp let relay_blocks_since_last_upgrade =
.relay_parent_number vfp.relay_parent_number.saturating_sub(LastUpgrade::get());
.saturating_sub(LastUpgrade::get());
if relay_blocks_since_last_upgrade <= cfg.validation_upgrade_frequency { if relay_blocks_since_last_upgrade <= cfg.validation_upgrade_frequency {
// The cooldown after the last upgrade hasn't elapsed yet. Upgrade is not allowed. // The cooldown after the last upgrade hasn't elapsed yet. Upgrade is not allowed.
@@ -611,9 +612,7 @@ impl<T: Config> Module<T> {
} }
/// The implementation of the runtime upgrade scheduling. /// The implementation of the runtime upgrade scheduling.
fn schedule_upgrade_impl( fn schedule_upgrade_impl(validation_function: Vec<u8>) -> DispatchResult {
validation_function: Vec<u8>,
) -> DispatchResult {
ensure!( ensure!(
!PendingValidationFunction::exists(), !PendingValidationFunction::exists(),
Error::<T>::OverlappingUpgrades Error::<T>::OverlappingUpgrades
@@ -712,9 +711,9 @@ impl<T: Config> Module<T> {
match Self::host_configuration() { match Self::host_configuration() {
Some(cfg) => { Some(cfg) => {
if message.len() > cfg.max_upward_message_size as usize { if message.len() > cfg.max_upward_message_size as usize {
return Err(SendUpErr::TooBig) return Err(SendUpErr::TooBig);
} }
}, }
None => { None => {
// This storage field should carry over from the previous block. So if it's 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 // then it must be that this is an edge-case where a message is attempted to be
@@ -758,7 +757,7 @@ impl<T: Config> Module<T> {
// opened at all so early. At least, relying on this assumption seems to be a better // 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 // tradeoff, compared to introducing an error variant that the clients should be
// prepared to handle. // prepared to handle.
return Err(SendHorizontalErr::NoChannel) return Err(SendHorizontalErr::NoChannel);
} }
}; };
let channel_meta = match relevant_messaging_state let channel_meta = match relevant_messaging_state
@@ -769,7 +768,7 @@ impl<T: Config> Module<T> {
Err(_) => return Err(SendHorizontalErr::NoChannel), Err(_) => return Err(SendHorizontalErr::NoChannel),
}; };
if data.len() as u32 > channel_meta.max_message_size { 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. // And then at last update the storage.
@@ -859,7 +858,7 @@ mod tests {
use super::*; use super::*;
use codec::Encode; use codec::Encode;
use cumulus_primitives::{ use cumulus_primitives_core::{
AbridgedHrmpChannel, InboundDownwardMessage, InboundHrmpMessage, PersistedValidationData, AbridgedHrmpChannel, InboundDownwardMessage, InboundHrmpMessage, PersistedValidationData,
}; };
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
@@ -1325,27 +1324,27 @@ mod tests {
sproof.host_config.max_upward_message_num_per_candidate = 1; sproof.host_config.max_upward_message_num_per_candidate = 1;
sproof.relay_dispatch_queue_size = None; 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"Mr F was here".to_vec()).unwrap();
ParachainSystem::send_upward_message(b"message 2".to_vec()).unwrap(); ParachainSystem::send_upward_message(b"message 2".to_vec()).unwrap();
}, },
|| { || {
let v: Option<Vec<Vec<u8>>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); let v: Option<Vec<Vec<u8>>> =
assert_eq!( storage::unhashed::get(well_known_keys::UPWARD_MESSAGES);
v, assert_eq!(v, Some(vec![b"Mr F was here".to_vec()]),);
Some(vec![b"Mr F was here".to_vec()]), },
); )
}) .add_with_post_test(
.add_with_post_test(2, 2,
|| { /* do nothing within block */ }, || { /* do nothing within block */ },
|| { || {
let v: Option<Vec<Vec<u8>>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); let v: Option<Vec<Vec<u8>>> =
assert_eq!( storage::unhashed::get(well_known_keys::UPWARD_MESSAGES);
v, assert_eq!(v, Some(vec![b"message 2".to_vec()]),);
Some(vec![b"message 2".to_vec()]), },
); );
});
} }
#[test] #[test]
@@ -1360,29 +1359,28 @@ mod tests {
2 => sproof.relay_dispatch_queue_size = Some((4, 0)), 2 => sproof.relay_dispatch_queue_size = Some((4, 0)),
_ => unreachable!(), _ => unreachable!(),
} }
}) })
.add_with_post_test(1, .add_with_post_test(
1,
|| { || {
ParachainSystem::send_upward_message(vec![0u8; 8]).unwrap(); ParachainSystem::send_upward_message(vec![0u8; 8]).unwrap();
}, },
|| { || {
// The message won't be sent because there is already one message in queue. // The message won't be sent because there is already one message in queue.
let v: Option<Vec<Vec<u8>>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); let v: Option<Vec<Vec<u8>>> =
assert_eq!( storage::unhashed::get(well_known_keys::UPWARD_MESSAGES);
v, assert_eq!(v, Some(vec![]),);
Some(vec![]), },
); )
}) .add_with_post_test(
.add_with_post_test(2, 2,
|| { /* do nothing within block */ }, || { /* do nothing within block */ },
|| { || {
let v: Option<Vec<Vec<u8>>> = storage::unhashed::get(well_known_keys::UPWARD_MESSAGES); let v: Option<Vec<Vec<u8>>> =
assert_eq!( storage::unhashed::get(well_known_keys::UPWARD_MESSAGES);
v, assert_eq!(v, Some(vec![vec![0u8; 8]]),);
Some(vec![vec![0u8; 8]]), },
); );
});
} }
#[test] #[test]
@@ -1396,13 +1394,11 @@ mod tests {
}) })
.add(1, || {}) .add(1, || {})
.add(2, || { .add(2, || {
assert!( assert!(ParachainSystem::send_hrmp_message(OutboundHrmpMessage {
ParachainSystem::send_hrmp_message(OutboundHrmpMessage { recipient: ParaId::from(300),
recipient: ParaId::from(300), data: b"derp".to_vec(),
data: b"derp".to_vec(), })
}) .is_err());
.is_err()
);
}); });
} }
@@ -1620,15 +1616,13 @@ mod tests {
} }
BlockTests::new() BlockTests::new()
.with_relay_sproof_builder( .with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num {
|_, relay_block_num, sproof| match relay_block_num { 1 => {
1 => { sproof.dmq_mqc_head =
sproof.dmq_mqc_head = Some(MessageQueueChain::default().extend_downward(&MSG).head());
Some(MessageQueueChain::default().extend_downward(&MSG).head()); }
} _ => unreachable!(),
_ => unreachable!(), })
},
)
.with_inherent_data(|_, relay_block_num, data| match relay_block_num { .with_inherent_data(|_, relay_block_num, data| match relay_block_num {
1 => { 1 => {
data.downward_messages.push(MSG.clone()); data.downward_messages.push(MSG.clone());
@@ -1669,35 +1663,34 @@ mod tests {
} }
BlockTests::new() BlockTests::new()
.with_relay_sproof_builder( .with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num {
|_, relay_block_num, sproof| match relay_block_num { 1 => {
1 => { // 200 - doesn't exist yet
// 200 - doesn't exist yet // 300 - one new message
// 300 - one new message sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head =
sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head());
Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); }
} 2 => {
2 => { // 200 - two new messages
// 200 - two new messages // 300 - now present with one message.
// 300 - now present with one message. sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head =
sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head = Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head());
Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head()); sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = Some(
sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = MessageQueueChain::default()
Some(MessageQueueChain::default() .extend_hrmp(&MSG_1)
.extend_hrmp(&MSG_1) .extend_hrmp(&MSG_2)
.extend_hrmp(&MSG_2) .extend_hrmp(&MSG_3)
.extend_hrmp(&MSG_3) .head(),
.head()); );
} }
3 => { 3 => {
// 200 - no new messages // 200 - no new messages
// 300 - is gone // 300 - is gone
sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head = sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head =
Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head()); Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head());
} }
_ => unreachable!(), _ => unreachable!(),
}, })
)
.with_inherent_data(|_, relay_block_num, data| match relay_block_num { .with_inherent_data(|_, relay_block_num, data| match relay_block_num {
1 => { 1 => {
data.horizontal_messages data.horizontal_messages
@@ -1779,28 +1772,27 @@ mod tests {
const ALICE: ParaId = ParaId::new(300); const ALICE: ParaId = ParaId::new(300);
BlockTests::new() BlockTests::new()
.with_relay_sproof_builder( .with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num {
|_, relay_block_num, sproof| match relay_block_num { 1 => {
1 => { sproof.upsert_inbound_channel(ALICE).mqc_head =
sproof.upsert_inbound_channel(ALICE).mqc_head Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head());
= Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); }
} 2 => {
2 => { // 300 - no new messages, mqc stayed the same.
// 300 - no new messages, mqc stayed the same. sproof.upsert_inbound_channel(ALICE).mqc_head =
sproof.upsert_inbound_channel(ALICE).mqc_head Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head());
= Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); }
} 3 => {
3 => { // 300 - new message.
// 300 - new message. sproof.upsert_inbound_channel(ALICE).mqc_head = Some(
sproof.upsert_inbound_channel(ALICE).mqc_head MessageQueueChain::default()
= Some(MessageQueueChain::default()
.extend_hrmp(&MSG_1) .extend_hrmp(&MSG_1)
.extend_hrmp(&MSG_2) .extend_hrmp(&MSG_2)
.head()); .head(),
} );
_ => unreachable!(), }
}, _ => unreachable!(),
) })
.with_inherent_data(|_, relay_block_num, data| match relay_block_num { .with_inherent_data(|_, relay_block_num, data| match relay_block_num {
1 => { 1 => {
data.horizontal_messages.insert(ALICE, vec![MSG_1.clone()]); data.horizontal_messages.insert(ALICE, vec![MSG_1.clone()]);
@@ -15,7 +15,7 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use codec::{Encode, Decode}; 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 hash_db::{HashDB, EMPTY_PREFIX};
use sp_runtime::traits::HashFor; use sp_runtime::traits::HashFor;
use sp_state_machine::{Backend, TrieBackend}; use sp_state_machine::{Backend, TrieBackend};
@@ -23,16 +23,16 @@ use sp_std::{boxed::Box, vec::Vec};
use hash_db::{HashDB, EMPTY_PREFIX}; 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 codec::{Decode, Encode};
use cumulus_primitives::{ use cumulus_primitives_core::{
well_known_keys::{ well_known_keys::{
HRMP_OUTBOUND_MESSAGES, HRMP_WATERMARK, NEW_VALIDATION_CODE, PROCESSED_DOWNWARD_MESSAGES, HRMP_OUTBOUND_MESSAGES, HRMP_WATERMARK, NEW_VALIDATION_CODE, PROCESSED_DOWNWARD_MESSAGES,
UPWARD_MESSAGES, VALIDATION_DATA, UPWARD_MESSAGES, VALIDATION_DATA,
}, },
OutboundHrmpMessage, UpwardMessage, PersistedValidationData, OutboundHrmpMessage, PersistedValidationData, UpwardMessage,
}; };
use sp_core::storage::{ChildInfo, TrackedStorageKey}; use sp_core::storage::{ChildInfo, TrackedStorageKey};
use sp_externalities::{ use sp_externalities::{
@@ -67,21 +67,24 @@ impl Encode for EncodeOpaqueValue {
/// Validate a given parachain block on a validator. /// Validate a given parachain block on a validator.
#[doc(hidden)] #[doc(hidden)]
pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -> ValidationResult { pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -> ValidationResult {
let block_data = crate::ParachainBlockData::<B>::decode(&mut &params.block_data.0[..]) let block_data =
.expect("Invalid parachain block data"); cumulus_primitives_core::ParachainBlockData::<B>::decode(&mut &params.block_data.0[..])
.expect("Invalid parachain block data");
let parent_head = let parent_head =
B::Header::decode(&mut &params.parent_head.0[..]).expect("Invalid parent head"); B::Header::decode(&mut &params.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!( assert!(
parent_head.hash() == *block.header().parent_hash(), parent_head.hash() == *block.header().parent_hash(),
"Invalid 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(); let root = parent_head.state_root().clone();
if !HashDB::<HashFor<B>, _>::contains(&db, &root, EMPTY_PREFIX) { if !HashDB::<HashFor<B>, _>::contains(&db, &root, EMPTY_PREFIX) {
panic!("Witness data does not contain given storage root."); panic!("Witness data does not contain given storage root.");
@@ -130,10 +133,8 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
.replace_implementation(host_default_child_storage_root), .replace_implementation(host_default_child_storage_root),
sp_io::default_child_storage::host_next_key sp_io::default_child_storage::host_next_key
.replace_implementation(host_default_child_storage_next_key), .replace_implementation(host_default_child_storage_next_key),
sp_io::offchain_index::host_set sp_io::offchain_index::host_set.replace_implementation(host_offchain_index_set),
.replace_implementation(host_offchain_index_set), sp_io::offchain_index::host_clear.replace_implementation(host_offchain_index_clear),
sp_io::offchain_index::host_clear
.replace_implementation(host_offchain_index_clear),
); );
set_and_run_with_externalities(&mut ext, || { 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 /// Should be removed with: https://github.com/paritytech/cumulus/issues/217
/// When removed `WitnessExt` could also be removed. /// When removed `WitnessExt` could also be removed.
fn check_validation_data(&self, mut data: &[u8]) { fn check_validation_data(&self, mut data: &[u8]) {
let validation_data = PersistedValidationData::decode(&mut data) let validation_data =
.expect("Invalid `PersistedValidationData`"); PersistedValidationData::decode(&mut data).expect("Invalid `PersistedValidationData`");
assert_eq!( assert_eq!(self.params.parent_head, validation_data.parent_head,);
self.params.parent_head,
validation_data.parent_head,
);
assert_eq!( assert_eq!(
self.params.relay_parent_number, self.params.relay_parent_number,
validation_data.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)) 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]) {}
@@ -24,7 +24,7 @@ mod tests;
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
#[doc(hidden)] #[doc(hidden)]
pub use parachain; pub use polkadot_parachain;
/// Register the `validate_block` function that is used by parachains to validate blocks on a /// Register the `validate_block` function that is used by parachains to validate blocks on a
/// validator. /// validator.
@@ -39,7 +39,7 @@ pub use parachain;
/// struct Block; /// struct Block;
/// struct BlockExecutor; /// struct BlockExecutor;
/// ///
/// cumulus_runtime::register_validate_block!(Block, BlockExecutor); /// cumulus_pallet_parachain_system::register_validate_block!(Block, BlockExecutor);
/// ///
/// # fn main() {} /// # fn main() {}
/// ``` /// ```
@@ -63,14 +63,14 @@ macro_rules! register_validate_block_impl {
#[no_mangle] #[no_mangle]
unsafe fn validate_block(arguments: *const u8, arguments_len: usize) -> u64 { unsafe fn validate_block(arguments: *const u8, arguments_len: usize) -> u64 {
let params = 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::< let res = $crate::validate_block::implementation::validate_block::<
$block, $block,
$block_executor, $block_executor,
>(params); >(params);
$crate::validate_block::parachain::write_result(&res) $crate::validate_block::polkadot_parachain::write_result(&res)
} }
} }
}; };
@@ -14,16 +14,14 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::ParachainBlockData; use cumulus_primitives_core::{PersistedValidationData, ParachainBlockData};
use cumulus_primitives::PersistedValidationData;
use cumulus_test_client::{ use cumulus_test_client::{
runtime::{Block, Hash, Header, UncheckedExtrinsic, WASM_BINARY}, runtime::{Block, Hash, Header, UncheckedExtrinsic, WASM_BINARY},
transfer, Client, DefaultTestClientBuilderExt, InitBlockBuilder, LongestChain, transfer, Client, DefaultTestClientBuilderExt, InitBlockBuilder, LongestChain,
TestClientBuilder, TestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
}; };
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; 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::{ use sc_executor::{
error::Result, sp_wasm_interface::HostFunctions, WasmExecutionMethod, WasmExecutor, error::Result, sp_wasm_interface::HostFunctions, WasmExecutionMethod, WasmExecutor,
}; };
@@ -1,5 +1,5 @@
[package] [package]
name = "xcm-handler" name = "cumulus-pallet-xcm-handler"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" 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" } xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
# Cumulus Dependencies # Cumulus Dependencies
cumulus-primitives = { path = "../primitives", default-features = false } cumulus-primitives-core = { path = "../../primitives/core", default-features = false }
[features] [features]
default = [ "std" ] default = [ "std" ]
@@ -26,6 +26,6 @@ std = [
"sp-std/std", "sp-std/std",
"frame-support/std", "frame-support/std",
"frame-system/std", "frame-system/std",
"cumulus-primitives/std", "cumulus-primitives-core/std",
"xcm/std" "xcm/std"
] ]
@@ -23,7 +23,7 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use cumulus_primitives::{ use cumulus_primitives_core::{
DownwardMessageHandler, HrmpMessageHandler, HrmpMessageSender, InboundDownwardMessage, DownwardMessageHandler, HrmpMessageHandler, HrmpMessageSender, InboundDownwardMessage,
InboundHrmpMessage, OutboundHrmpMessage, ParaId, UpwardMessageSender, InboundHrmpMessage, OutboundHrmpMessage, ParaId, UpwardMessageSender,
}; };
@@ -1,5 +1,5 @@
[package] [package]
name = "cumulus-primitives" name = "cumulus-primitives-core"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
@@ -9,7 +9,6 @@ edition = "2018"
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } 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-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-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-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" } 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 # Other dependencies
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = [ "derive" ] } 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 dependencies
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } 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] [features]
default = [ "std" ] default = [ "std" ]
std = [ std = [
"sc-chain-spec",
"sp-std/std", "sp-std/std",
"codec/std", "codec/std",
"polkadot-primitives/std", "polkadot-primitives/std",
@@ -14,19 +14,18 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Cumulus related primitive types and traits. //! Cumulus related core primitive types and traits.
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use sp_runtime::traits::Block as BlockT;
pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_core_primitives::InboundDownwardMessage;
pub use polkadot_parachain::primitives::{Id as ParaId, UpwardMessage, ValidationParams}; pub use polkadot_parachain::primitives::{Id as ParaId, UpwardMessage, ValidationParams};
pub use polkadot_primitives::v1::{ pub use polkadot_primitives::v1::{
PersistedValidationData, AbridgedHostConfiguration, AbridgedHrmpChannel, PersistedValidationData, AbridgedHostConfiguration, AbridgedHrmpChannel,
}; };
#[cfg(feature = "std")]
pub mod genesis;
/// A module that re-exports relevant relay chain definitions. /// A module that re-exports relevant relay chain definitions.
pub mod relay_chain { pub mod relay_chain {
pub use polkadot_core_primitives::*; pub use polkadot_core_primitives::*;
@@ -133,3 +132,57 @@ pub trait HrmpMessageSender {
pub trait OnValidationData { pub trait OnValidationData {
fn on_validation_data(data: &PersistedValidationData); 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<B: BlockT> {
/// The header of the parachain block.
header: B::Header,
/// The extrinsics of the parachain block.
extrinsics: sp_std::vec::Vec<B::Extrinsic>,
/// The data that is required to emulate the storage accesses executed by all extrinsics.
storage_proof: sp_trie::StorageProof,
}
impl<B: BlockT> ParachainBlockData<B> {
/// Creates a new instance of `Self`.
pub fn new(
header: <B as BlockT>::Header,
extrinsics: sp_std::vec::Vec<<B as BlockT>::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<B::Extrinsic>, sp_trie::StorageProof) {
(self.header, self.extrinsics, self.storage_proof)
}
}
+5 -5
View File
@@ -56,11 +56,11 @@ sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "maste
jsonrpc-core = "15.1.0" jsonrpc-core = "15.1.0"
# Cumulus dependencies # Cumulus dependencies
cumulus-consensus = { path = "../consensus" } cumulus-client-consensus = { path = "../client/consensus" }
cumulus-collator = { path = "../collator" } cumulus-client-collator = { path = "../client/collator" }
cumulus-network = { path = "../network" } cumulus-client-service = { path = "../client/service" }
cumulus-primitives = { path = "../primitives" } cumulus-client-network = { path = "../client/network" }
cumulus-service = { path = "../service" } cumulus-primitives-core = { path = "../primitives/core" }
# Polkadot dependencies # Polkadot dependencies
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
@@ -409,4 +409,4 @@ impl_runtime_apis! {
} }
} }
cumulus_runtime::register_validate_block!(Block, Executive); cumulus_pallet_parachain_system::register_validate_block!(Block, Executive);
@@ -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-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" } 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] [features]
default = ["std"] default = ["std"]
std = [ std = [
"codec/std", "codec/std",
"serde", "serde",
"cumulus-primitives/std", "cumulus-primitives-core/std",
"frame-support/std", "frame-support/std",
"frame-system/std", "frame-system/std",
] ]
@@ -20,7 +20,7 @@
use frame_support::{decl_module, decl_storage, traits::Get}; use frame_support::{decl_module, decl_storage, traits::Get};
use cumulus_primitives::ParaId; use cumulus_primitives_core::ParaId;
/// Configuration trait of this pallet. /// Configuration trait of this pallet.
pub trait Config: frame_system::Config {} pub trait Config: frame_system::Config {}
+6 -8
View File
@@ -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" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
# Cumulus dependencies # Cumulus dependencies
cumulus-runtime = { path = "../../runtime", default-features = false } cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system", default-features = false }
cumulus-parachain-system = { path = "../../parachain-system", default-features = false } cumulus-primitives-core = { path = "../../primitives/core", default-features = false }
cumulus-primitives = { path = "../../primitives", default-features = false } cumulus-pallet-xcm-handler = { path = "../../pallets/xcm-handler", default-features = false }
xcm-handler = { path = "../../xcm-handler", default-features = false }
# Polkadot dependencies # Polkadot dependencies
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
@@ -74,11 +73,10 @@ std = [
"pallet-transaction-payment/std", "pallet-transaction-payment/std",
"parachain-info/std", "parachain-info/std",
"rococo-parachain-primitives/std", "rococo-parachain-primitives/std",
"cumulus-runtime/std", "cumulus-pallet-parachain-system/std",
"cumulus-parachain-system/std", "cumulus-pallet-xcm-handler/std",
"cumulus-primitives/std", "cumulus-primitives-core/std",
"xcm/std", "xcm/std",
"xcm-builder/std", "xcm-builder/std",
"xcm-executor/std", "xcm-executor/std",
"xcm-handler/std",
] ]
+7 -7
View File
@@ -229,7 +229,7 @@ impl pallet_sudo::Config for Runtime {
type Event = Event; type Event = Event;
} }
impl cumulus_parachain_system::Config for Runtime { impl cumulus_pallet_parachain_system::Config for Runtime {
type Event = Event; type Event = Event;
type OnValidationData = (); type OnValidationData = ();
type SelfParaId = parachain_info::Module<Runtime>; type SelfParaId = parachain_info::Module<Runtime>;
@@ -242,7 +242,7 @@ impl parachain_info::Config for Runtime {}
parameter_types! { parameter_types! {
pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent); pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
pub const RococoNetwork: NetworkId = NetworkId::Polkadot; 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 { pub Ancestry: MultiLocation = Junction::Parachain {
id: ParachainInfo::parachain_id().into() id: ParachainInfo::parachain_id().into()
}.into(); }.into();
@@ -268,7 +268,7 @@ type LocalAssetTransactor = CurrencyAdapter<
type LocalOriginConverter = ( type LocalOriginConverter = (
SovereignSignedViaLocation<LocationConverter, Origin>, SovereignSignedViaLocation<LocationConverter, Origin>,
RelayChainAsNative<RelayChainOrigin, Origin>, RelayChainAsNative<RelayChainOrigin, Origin>,
SiblingParachainAsNative<xcm_handler::Origin, Origin>, SiblingParachainAsNative<cumulus_pallet_xcm_handler::Origin, Origin>,
SignedAccountId32AsNative<RococoNetwork, Origin>, SignedAccountId32AsNative<RococoNetwork, Origin>,
); );
@@ -284,7 +284,7 @@ impl Config for XcmConfig {
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
} }
impl xcm_handler::Config for Runtime { impl cumulus_pallet_xcm_handler::Config for Runtime {
type Event = Event; type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type UpwardMessageSender = ParachainSystem; type UpwardMessageSender = ParachainSystem;
@@ -302,10 +302,10 @@ construct_runtime! {
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>}, Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, 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}, TransactionPayment: pallet_transaction_payment::{Module, Storage},
ParachainInfo: parachain_info::{Module, Storage, Config}, ParachainInfo: parachain_info::{Module, Storage, Config},
XcmHandler: xcm_handler::{Module, Call, Event<T>, Origin}, XcmHandler: cumulus_pallet_xcm_handler::{Module, Call, Event<T>, Origin},
} }
} }
@@ -414,4 +414,4 @@ impl_runtime_apis! {
} }
} }
cumulus_runtime::register_validate_block!(Block, Executive); cumulus_pallet_parachain_system::register_validate_block!(Block, Executive);
+1 -1
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use cumulus_primitives::ParaId; use cumulus_primitives_core::ParaId;
use hex_literal::hex; use hex_literal::hex;
use rococo_parachain_primitives::{AccountId, Signature}; use rococo_parachain_primitives::{AccountId, Signature};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
+10 -8
View File
@@ -19,13 +19,14 @@ use crate::{
cli::{Cli, RelayChainCli, Subcommand}, cli::{Cli, RelayChainCli, Subcommand},
}; };
use codec::Encode; 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 log::info;
use parachain_runtime::Block; use parachain_runtime::Block;
use polkadot_parachain::primitives::AccountIdConversion; use polkadot_parachain::primitives::AccountIdConversion;
use sc_cli::{ use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
KeystoreParams, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
}; };
use sc_service::{ use sc_service::{
config::{BasePath, PrometheusConfig}, config::{BasePath, PrometheusConfig},
@@ -291,11 +292,12 @@ pub fn run() -> Result<()> {
let task_executor = config.task_executor.clone(); let task_executor = config.task_executor.clone();
let polkadot_config = SubstrateCli::create_configuration( let polkadot_config = SubstrateCli::create_configuration(
&polkadot_cli, &polkadot_cli,
&polkadot_cli, &polkadot_cli,
task_executor, task_executor,
config.telemetry_handle.clone(), config.telemetry_handle.clone(),
).map_err(|err| format!("Relay chain argument error: {}", err))?; )
.map_err(|err| format!("Relay chain argument error: {}", err))?;
let collator = cli.run.base.validator || cli.collator; let collator = cli.run.base.validator || cli.collator;
info!("Parachain id: {:?}", id); info!("Parachain id: {:?}", id);
+7 -6
View File
@@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use cumulus_network::build_block_announce_validator; use cumulus_client_network::build_block_announce_validator;
use cumulus_service::{ use cumulus_primitives_core::ParaId;
use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
}; };
use parachain_runtime::RuntimeApi; use parachain_runtime::RuntimeApi;
@@ -69,7 +70,7 @@ pub fn new_partial(
client.clone(), 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(),
client.clone(), client.clone(),
inherent_data_providers.clone(), inherent_data_providers.clone(),
@@ -100,7 +101,7 @@ async fn start_node_impl<RB>(
parachain_config: Configuration, parachain_config: Configuration,
collator_key: CollatorPair, collator_key: CollatorPair,
polkadot_config: Configuration, polkadot_config: Configuration,
id: polkadot_primitives::v0::Id, id: ParaId,
validator: bool, validator: bool,
rpc_ext_builder: RB, rpc_ext_builder: RB,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)> ) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
@@ -118,7 +119,7 @@ where
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let polkadot_full_node = 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 { |e| match e {
polkadot_service::Error::Sub(x) => x, polkadot_service::Error::Sub(x) => x,
s => format!("{}", s).into(), s => format!("{}", s).into(),
@@ -228,7 +229,7 @@ pub async fn start_node(
parachain_config: Configuration, parachain_config: Configuration,
collator_key: CollatorPair, collator_key: CollatorPair,
polkadot_config: Configuration, polkadot_config: Configuration,
id: polkadot_primitives::v0::Id, id: ParaId,
validator: bool, validator: bool,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)> { ) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)> {
start_node_impl( start_node_impl(
-57
View File
@@ -1,57 +0,0 @@
[package]
name = "cumulus-runtime"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
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",
]
-76
View File
@@ -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 <http://www.gnu.org/licenses/>.
#![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<B: BlockT> {
/// The header of the parachain block.
header: <B as BlockT>::Header,
/// The extrinsics of the parachain block without the `PolkadotInherent`.
extrinsics: Vec<<B as BlockT>::Extrinsic>,
/// The data that is required to emulate the storage accesses executed by all extrinsics.
storage_proof: StorageProof,
}
impl<B: BlockT> ParachainBlockData<B> {
/// Creates a new instance of `Self`.
pub fn new(
header: <B as BlockT>::Header,
extrinsics: Vec<<B as BlockT>::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
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "m
cumulus-test-runtime = { path = "../runtime" } cumulus-test-runtime = { path = "../runtime" }
cumulus-test-service = { path = "../service" } cumulus-test-service = { path = "../service" }
cumulus-test-relay-sproof-builder = { path = "../relay-sproof-builder" } cumulus-test-relay-sproof-builder = { path = "../relay-sproof-builder" }
cumulus-primitives = { path = "../../primitives" } cumulus-primitives-core = { path = "../../primitives/core" }
# Polkadot deps # Polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
+1 -1
View File
@@ -15,7 +15,7 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::{Backend, Client}; use crate::{Backend, Client};
use cumulus_primitives::{ use cumulus_primitives_core::{
inherents::{SystemInherentData, SYSTEM_INHERENT_IDENTIFIER}, PersistedValidationData, inherents::{SystemInherentData, SYSTEM_INHERENT_IDENTIFIER}, PersistedValidationData,
}; };
use cumulus_test_runtime::{Block, GetLastTimestamp}; use cumulus_test_runtime::{Block, GetLastTimestamp};
+2 -2
View File
@@ -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" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
# Cumulus dependencies # Cumulus dependencies
cumulus-primitives = { path = "../../primitives", default-features = false } cumulus-primitives-core = { path = "../../primitives/core", default-features = false }
[features] [features]
default = [ "std" ] default = [ "std" ]
@@ -26,5 +26,5 @@ std = [
"sp-state-machine/std", "sp-state-machine/std",
"sp-runtime/std", "sp-runtime/std",
"sp-std/std", "sp-std/std",
"cumulus-primitives/std", "cumulus-primitives-core/std",
] ]
+2 -2
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use cumulus_primitives::{relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId}; use cumulus_primitives_core::{relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId};
use sp_runtime::traits::HashFor; use sp_runtime::traits::HashFor;
use sp_state_machine::MemoryDB; use sp_state_machine::MemoryDB;
use sp_std::collections::btree_map::BTreeMap; use sp_std::collections::btree_map::BTreeMap;
@@ -44,7 +44,7 @@ impl Default for RelayStateSproofBuilder {
fn default() -> Self { fn default() -> Self {
RelayStateSproofBuilder { RelayStateSproofBuilder {
para_id: ParaId::from(200), para_id: ParaId::from(200),
host_config: cumulus_primitives::AbridgedHostConfiguration { host_config: cumulus_primitives_core::AbridgedHostConfiguration {
max_code_size: 2 * 1024 * 1024, max_code_size: 2 * 1024 * 1024,
max_head_data_size: 1024 * 1024, max_head_data_size: 1024 * 1024,
max_upward_queue_count: 8, max_upward_queue_count: 8,
+4 -6
View File
@@ -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" } sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
# Cumulus dependencies # Cumulus dependencies
cumulus-parachain-system = { path = "../../parachain-system", default-features = false } cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system", default-features = false }
cumulus-primitives = { path = "../../primitives", default-features = false } cumulus-primitives-core = { path = "../../primitives/core", default-features = false }
cumulus-runtime = { path = "../../runtime", default-features = false }
# Polkadot dependencies # Polkadot dependencies
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } 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" ] default = [ "std" ]
std = [ std = [
"codec/std", "codec/std",
"cumulus-parachain-system/std", "cumulus-pallet-parachain-system/std",
"cumulus-primitives/std", "cumulus-primitives-core/std",
"cumulus-runtime/std",
"frame-executive/std", "frame-executive/std",
"frame-support/std", "frame-support/std",
"frame-system/std", "frame-system/std",
+4 -4
View File
@@ -207,7 +207,7 @@ impl pallet_sudo::Config for Runtime {
type Event = Event; type Event = Event;
} }
impl cumulus_parachain_system::Config for Runtime { impl cumulus_pallet_parachain_system::Config for Runtime {
type SelfParaId = ParachainId; type SelfParaId = ParachainId;
type Event = Event; type Event = Event;
type OnValidationData = (); type OnValidationData = ();
@@ -216,7 +216,7 @@ impl cumulus_parachain_system::Config for Runtime {
} }
parameter_types! { parameter_types! {
pub storage ParachainId: cumulus_primitives::ParaId = 100.into(); pub storage ParachainId: cumulus_primitives_core::ParaId = 100.into();
} }
construct_runtime! { construct_runtime! {
@@ -230,7 +230,7 @@ construct_runtime! {
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>}, Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, 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}, 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);
+4 -4
View File
@@ -43,10 +43,10 @@ polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch
polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" }
# Cumulus # Cumulus
cumulus-consensus = { path = "../../consensus" } cumulus-client-consensus = { path = "../../client/consensus" }
cumulus-network = { path = "../../network" } cumulus-client-network = { path = "../../client/network" }
cumulus-primitives = { path = "../../primitives" } cumulus-client-service = { path = "../../client/service" }
cumulus-service = { path = "../../service" } cumulus-primitives-core = { path = "../../primitives/core" }
cumulus-test-runtime = { path = "../runtime" } cumulus-test-runtime = { path = "../runtime" }
# RPC related dependencies # RPC related dependencies
+1 -1
View File
@@ -16,7 +16,7 @@
#![allow(missing_docs)] #![allow(missing_docs)]
use cumulus_primitives::ParaId; use cumulus_primitives_core::ParaId;
use cumulus_test_runtime::{AccountId, Signature}; use cumulus_test_runtime::{AccountId, Signature};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType; use sc_service::ChainType;
+2 -1
View File
@@ -15,7 +15,8 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use codec::Encode; 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 cumulus_test_runtime::Block;
use polkadot_primitives::v0::HeadData; use polkadot_primitives::v0::HeadData;
use sp_runtime::traits::Block as BlockT; use sp_runtime::traits::Block as BlockT;
+4 -4
View File
@@ -26,9 +26,9 @@ pub use cumulus_test_runtime as runtime;
pub use genesis::*; pub use genesis::*;
use core::future::Future; use core::future::Future;
use cumulus_network::BlockAnnounceValidator; use cumulus_client_network::BlockAnnounceValidator;
use cumulus_primitives::ParaId; use cumulus_primitives_core::ParaId;
use cumulus_service::{ use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
}; };
use cumulus_test_runtime::{NodeBlock as Block, RuntimeApi}; use cumulus_test_runtime::{NodeBlock as Block, RuntimeApi};
@@ -93,7 +93,7 @@ pub fn new_partial(
client.clone(), 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(),
client.clone(), client.clone(),
inherent_data_providers.clone(), inherent_data_providers.clone(),
+1 -1
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>. // along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use cumulus_primitives::ParaId; use cumulus_primitives_core::ParaId;
use cumulus_test_service::initial_head_data; use cumulus_test_service::initial_head_data;
use futures::join; use futures::join;
use sc_service::TaskExecutor; use sc_service::TaskExecutor;