Update Cumulus for Parachains V1 (#224)

* Start with something

* Whatever

* Update

* MOARE

* Make cumulus-network compile and tests work

* Update more and fixes

* More stuff

* More fixes

* Make collator build

* Make test almost work

* Remove contracts runtime

* More test work

* Make service compile

* Fix test-service

* Fix test client

* More fixes

* Fix collator test

* Fix network tests (again)

* Make everything compile, finally

* Fix tests

* Update to latest masters

* Remove ignore

* Switch to different branch in polkadot for now

* Update reference

* Make it compile with latest changes

* Update collator/src/lib.rs

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>

* Update to latest upstream

* Update to latest master

* Fix test

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
Bastian Köcher
2020-11-08 22:18:09 +01:00
committed by GitHub
parent 9512520b95
commit 76f9ecae47
87 changed files with 3815 additions and 17343 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use codec::Encode;
use sc_service::ChainSpec;
use sc_chain_spec::ChainSpec;
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero};
/// Generate the genesis state for a given ChainSpec.
+13 -25
View File
@@ -25,18 +25,15 @@ pub use polkadot_core_primitives::DownwardMessage;
/// It is "generic" in such a way, that the actual message is encoded in the `data` field.
/// Besides the `data` it also holds the `origin` of the message.
pub use polkadot_parachain::primitives::UpwardMessage as GenericUpwardMessage;
pub use polkadot_parachain::primitives::{
Id as ParaId, ParachainDispatchOrigin as UpwardMessageOrigin,
pub use polkadot_parachain::primitives::{Id as ParaId, ValidationParams};
pub use polkadot_primitives::v1::{
PersistedValidationData, TransientValidationData, ValidationData,
};
#[cfg(feature = "std")]
pub mod genesis;
pub mod validation_function_params;
pub mod xcmp;
use codec::{Decode, Encode};
use sp_runtime::traits::Block as BlockT;
/// Identifiers and types related to Cumulus Inherents
pub mod inherents {
use sp_inherents::InherentIdentifier;
@@ -47,11 +44,10 @@ pub mod inherents {
/// The type of the inherent downward messages.
pub type DownwardMessagesType = sp_std::vec::Vec<crate::DownwardMessage>;
/// The identifier for the `validation_function_params` inherent.
pub const VALIDATION_FUNCTION_PARAMS_IDENTIFIER: InherentIdentifier = *b"valfunp0";
/// The identifier for the `set_validation_data` inherent.
pub const VALIDATION_DATA_IDENTIFIER: InherentIdentifier = *b"valfunp0";
/// The type of the inherent.
pub type ValidationFunctionParamsType =
crate::validation_function_params::ValidationFunctionParams;
pub type ValidationDataType = crate::ValidationData;
}
/// Well known keys for values in the storage.
@@ -61,11 +57,11 @@ pub mod well_known_keys {
/// The upward messages are stored as SCALE encoded `Vec<GenericUpwardMessage>`.
pub const UPWARD_MESSAGES: &'static [u8] = b":cumulus_upward_messages:";
/// Current validation function parameters.
pub const VALIDATION_FUNCTION_PARAMS: &'static [u8] = b":cumulus_validation_function_params";
/// Current validation data.
pub const VALIDATION_DATA: &'static [u8] = b":cumulus_validation_data:";
/// Code upgarde (set as appropriate by a pallet).
pub const NEW_VALIDATION_CODE: &'static [u8] = b":cumulus_new_validation_code";
pub const NEW_VALIDATION_CODE: &'static [u8] = b":cumulus_new_validation_code:";
/// The storage key for the processed downward messages.
///
@@ -80,16 +76,8 @@ pub trait DownwardMessageHandler {
fn handle_downward_message(msg: &DownwardMessage);
}
/// Something that can send upward messages.
pub trait UpwardMessageSender<UpwardMessage> {
/// Send an upward message to the relay chain.
///
/// Returns an error if sending failed.
fn send_upward_message(msg: &UpwardMessage, origin: UpwardMessageOrigin) -> Result<(), ()>;
}
/// The head data of the parachain, stored in the relay chain.
#[derive(Decode, Encode, Debug)]
pub struct HeadData<Block: BlockT> {
pub header: Block::Header,
/// A trait which is called when the validation data is set.
#[impl_trait_for_tuples::impl_for_tuples(30)]
pub trait OnValidationData {
fn on_validation_data(data: ValidationData);
}
@@ -1,66 +0,0 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Validation Function Parameters govern the ability of parachains to upgrade their validation functions.
use codec::{Decode, Encode};
use polkadot_parachain::primitives::{RelayChainBlockNumber, ValidationParams};
use polkadot_primitives::v0::{GlobalValidationData, LocalValidationData};
/// Validation Function Parameters
///
/// 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, sp_runtime::RuntimeDebug)]
pub struct ValidationFunctionParams {
/// The maximum code size permitted, in bytes.
pub max_code_size: u32,
/// The current relay-chain block number.
pub relay_chain_height: RelayChainBlockNumber,
/// Whether a code upgrade is allowed or not, and at which height the upgrade
/// would be applied after, if so. The parachain logic should apply any upgrade
/// issued in this block after the first block
/// with `relay_chain_height` at least this value, if `Some`. if `None`, issue
/// no upgrade.
pub code_upgrade_allowed: Option<RelayChainBlockNumber>,
}
impl From<&ValidationParams> for ValidationFunctionParams {
fn from(vp: &ValidationParams) -> Self {
ValidationFunctionParams {
max_code_size: vp.max_code_size,
relay_chain_height: vp.relay_chain_height,
code_upgrade_allowed: vp.code_upgrade_allowed,
}
}
}
impl From<(GlobalValidationData, LocalValidationData)> for ValidationFunctionParams {
fn from(t: (GlobalValidationData, LocalValidationData)) -> Self {
let (global_validation, local_validation) = t;
ValidationFunctionParams {
max_code_size: global_validation.max_code_size,
relay_chain_height: global_validation.block_number,
code_upgrade_allowed: local_validation.code_upgrade_allowed,
}
}
}
/// A trait which is called when the validation function parameters are set
#[impl_trait_for_tuples::impl_for_tuples(30)]
pub trait OnValidationFunctionParams {
fn on_validation_function_params(vfp: ValidationFunctionParams);
}