diff --git a/cumulus/Cargo.lock b/cumulus/Cargo.lock index e462792549..249e13a9ce 100644 --- a/cumulus/Cargo.lock +++ b/cumulus/Cargo.lock @@ -923,6 +923,7 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", + "sp-std", "sp-version", "substrate-test-runtime-client", ] @@ -936,6 +937,7 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "sp-inherents", + "sp-runtime", "sp-std", ] @@ -1023,6 +1025,7 @@ dependencies = [ name = "cumulus-test-parachain-runtime" version = "0.1.0" dependencies = [ + "cumulus-parachain-upgrade", "cumulus-runtime", "frame-executive", "frame-support", diff --git a/cumulus/parachain-upgrade/Cargo.toml b/cumulus/parachain-upgrade/Cargo.toml index 5476e30b38..f9b3b639c1 100644 --- a/cumulus/parachain-upgrade/Cargo.toml +++ b/cumulus/parachain-upgrade/Cargo.toml @@ -5,21 +5,6 @@ authors = ["Parity Technologies "] edition = "2018" description = "pallet to manage parachain upgrades" -[features] -default = ['std'] -std = [ - 'serde', - 'codec/std', - 'frame-support/std', - 'pallet-balances/std', - 'cumulus-runtime/std', - 'sp-core/std', - 'sp-runtime/std', - 'sp-io/std', - 'system/std', - 'cumulus-primitives/std', -] - [dependencies] # Cumulus dependencies cumulus-primitives = { path = "../primitives", default-features = false } @@ -32,10 +17,10 @@ parachain = { package = "polkadot-parachain", git = "https://github.com/parityte frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", version = "2.0.0-dev", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", version = "2.0.0-dev", default-features = false } sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } -sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } system = { package = "frame-system", git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } # Other Dependencies @@ -45,3 +30,20 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } [dev-dependencies] sp-externalities = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } +sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "cumulus-branch", default-features = false } + +[features] +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', + 'system/std', + 'cumulus-primitives/std', +] diff --git a/cumulus/parachain-upgrade/src/lib.rs b/cumulus/parachain-upgrade/src/lib.rs index 487f2f3930..b6941b25bd 100644 --- a/cumulus/parachain-upgrade/src/lib.rs +++ b/cumulus/parachain-upgrade/src/lib.rs @@ -35,13 +35,12 @@ use cumulus_primitives::{ well_known_keys::{NEW_VALIDATION_CODE, VALIDATION_FUNCTION_PARAMS}, }; use frame_support::{ - decl_error, decl_event, decl_module, decl_storage, ensure, storage, traits::Get, - weights::DispatchClass, + decl_error, decl_event, decl_module, decl_storage, ensure, storage, weights::DispatchClass, }; use parachain::primitives::RelayChainBlockNumber; use sp_core::storage::well_known_keys; use sp_inherents::{InherentData, InherentIdentifier, ProvideInherent}; -use sp_version::RuntimeVersion; +use sp_std::vec::Vec; use system::ensure_none; /// A ValidationFunction is a compiled WASM blob which, on execution, validates parachain blocks. @@ -53,9 +52,6 @@ pub trait Trait: system::Trait { /// The overarching event type. type Event: From + Into<::Event>; - /// Get the chain's current version. - type Version: Get; - /// Something which can be notified when the validation function params are set. /// /// Set this to `()` if not needed. @@ -67,7 +63,8 @@ decl_storage! { trait Store for Module as ParachainUpgrade { // we need to store the new validation function for the span between // setting it and applying it. - PendingValidationFunction get(fn new_validation_function): Option<(RelayChainBlockNumber, ValidationFunction)>; + PendingValidationFunction get(fn new_validation_function): + Option<(RelayChainBlockNumber, ValidationFunction)>; /// Were the VFPs updated this block? DidUpdateVFPs: bool; @@ -197,7 +194,10 @@ impl ProvideInherent for Module { fn create_inherent(data: &InherentData) -> Option { // If the inherent is not present, this returns None early. This in turn will // cause the on_finalize assertion to fail. - let vfp: ValidationFunctionParams = data.get_data(&INHERENT_IDENTIFIER).ok().flatten() + let vfp: ValidationFunctionParams = data + .get_data(&INHERENT_IDENTIFIER) + .ok() + .flatten() .expect("validation function params are always injected into inherent data; qed"); Some(Call::set_validation_function_parameters(vfp)) @@ -243,6 +243,7 @@ mod tests { traits::{BlakeTwo256, Dispatchable, IdentityLookup}, Perbill, }; + use sp_version::RuntimeVersion; use system::{InitKind, RawOrigin}; impl_outer_origin! { @@ -306,7 +307,6 @@ mod tests { } impl Trait for Test { type Event = TestEvent; - type Version = Version; type OnValidationFunctionParams = (); } @@ -366,7 +366,8 @@ mod tests { tests: Vec, pending_upgrade: Option, ran: bool, - vfp_maker: Option ValidationFunctionParams>>, + vfp_maker: + Option ValidationFunctionParams>>, } impl BlockTests { diff --git a/cumulus/primitives/Cargo.toml b/cumulus/primitives/Cargo.toml index c76046f5ab..7b12137281 100644 --- a/cumulus/primitives/Cargo.toml +++ b/cumulus/primitives/Cargo.toml @@ -8,6 +8,7 @@ edition = "2018" # Substrate dependencies sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false } # Polkadot dependencies polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch", default-features = false } @@ -25,4 +26,5 @@ std = [ "polkadot-primitives/std", "polkadot-parachain/std", "sp-inherents/std", + "sp-runtime/std", ] diff --git a/cumulus/primitives/src/validation_function_params.rs b/cumulus/primitives/src/validation_function_params.rs index a38693a0ba..23cc0f955a 100644 --- a/cumulus/primitives/src/validation_function_params.rs +++ b/cumulus/primitives/src/validation_function_params.rs @@ -24,8 +24,7 @@ use polkadot_primitives::parachain::{GlobalValidationSchedule, LocalValidationDa /// /// This struct is the subset of [`ValidationParams`](polkadot_parachain::ValidationParams) /// which is of interest when upgrading parachain validation functions. -#[derive(PartialEq, Eq, Encode, Decode, Clone, Copy, Default)] -#[cfg_attr(feature = "std", derive(Debug))] +#[derive(PartialEq, Eq, Encode, Decode, Clone, Copy, Default, sp_runtime::RuntimeDebug)] pub struct ValidationFunctionParams { /// The maximum code size permitted, in bytes. pub max_code_size: u32, diff --git a/cumulus/runtime/src/validate_block/implementation.rs b/cumulus/runtime/src/validate_block/implementation.rs index 8fe6b88125..d2337bdd70 100644 --- a/cumulus/runtime/src/validate_block/implementation.rs +++ b/cumulus/runtime/src/validate_block/implementation.rs @@ -25,7 +25,7 @@ use sp_trie::{delta_trie_root, read_trie_value, Layout, MemoryDB}; use hash_db::{HashDB, EMPTY_PREFIX}; -use trie_db::{Trie, TrieDB, TrieDBIterator}; +use trie_db::{TrieDB, TrieDBIterator}; use parachain::primitives::{HeadData, ValidationCode, ValidationParams, ValidationResult}; diff --git a/cumulus/test/parachain/runtime/Cargo.toml b/cumulus/test/parachain/runtime/Cargo.toml index a1ac8cb5dd..c23e910e47 100644 --- a/cumulus/test/parachain/runtime/Cargo.toml +++ b/cumulus/test/parachain/runtime/Cargo.toml @@ -33,6 +33,7 @@ pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", # Cumulus dependencies cumulus-runtime = { path = "../../../runtime", default-features = false } +cumulus-parachain-upgrade = { path = "../../../parachain-upgrade", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3" } @@ -63,4 +64,5 @@ std = [ 'pallet-sudo/std', 'pallet-transaction-payment/std', 'cumulus-runtime/std', + 'cumulus-parachain-upgrade/std', ] diff --git a/cumulus/test/parachain/runtime/src/lib.rs b/cumulus/test/parachain/runtime/src/lib.rs index 47daabc172..4c949061dc 100644 --- a/cumulus/test/parachain/runtime/src/lib.rs +++ b/cumulus/test/parachain/runtime/src/lib.rs @@ -230,6 +230,11 @@ impl pallet_sudo::Trait for Runtime { type Event = Event; } +impl cumulus_parachain_upgrade::Trait for Runtime { + type Event = Event; + type OnValidationFunctionParams = (); +} + construct_runtime! { pub enum Runtime where Block = Block, @@ -242,6 +247,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}, + ParachainUpgrade: cumulus_parachain_upgrade::{Module, Call, Storage, Inherent, Event}, } }