Some updates

This commit is contained in:
Bastian Köcher
2019-09-26 09:44:21 +02:00
parent 9bef7a9dc0
commit ce064775fc
8 changed files with 775 additions and 717 deletions
Generated
+704 -696
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -9,6 +9,7 @@ edition = "2018"
runtime-primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
consensus-common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
cli = { package = "substrate-cli", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
# Polkadot dependencies
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
@@ -16,5 +17,5 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch =
# other deps
log = "0.4.6"
codec = { package = "parity-codec", version = "3.5.1", features = [ "derive" ] }
codec = { package = "parity-codec", version = "4.1.1", features = [ "derive" ] }
futures = "0.1.27"
+61 -6
View File
@@ -16,10 +16,13 @@
//! Cumulus Collator implementation for Substrate.
use runtime_primitives::traits::Block as BlockT;
use runtime_primitives::{traits::Block as BlockT, ed25519};
use consensus_common::{Environment, Proposer};
use inherents::InherentDataProviders;
use polkadot_collator::{InvalidHead, ParachainContext};
use polkadot_collator::{
InvalidHead, ParachainContext, BuildParachainContext, Network as CollatorNetwork, VersionInfo,
};
use polkadot_primitives::{
Hash, parachain::{self, BlockData, Message, Id as ParaId, Extrinsic, Status as ParachainStatus}
};
@@ -40,19 +43,22 @@ struct HeadData<Block: BlockT> {
pub struct Collator<Block, PF> {
proposer_factory: Arc<PF>,
_phantom: PhantomData<Block>,
inherent_data_providers: inherents::InherentDataProviders,
inherent_data_providers: InherentDataProviders,
collator_network: Arc<dyn CollatorNetwork>,
}
impl<Block: BlockT, PF: Environment<Block>> Collator<Block, PF> {
/// Create a new instance.
fn new(
proposer_factory: Arc<PF>,
inherent_data_providers: inherents::InherentDataProviders
inherent_data_providers: InherentDataProviders,
collator_network: Arc<dyn CollatorNetwork>,
) -> Self {
Self {
proposer_factory,
inherent_data_providers,
_phantom: PhantomData,
collator_network,
}
}
}
@@ -63,12 +69,12 @@ impl<Block, PF> Clone for Collator<Block, PF> {
proposer_factory: self.proposer_factory.clone(),
inherent_data_providers: self.inherent_data_providers.clone(),
_phantom: PhantomData,
collator_network: self.collator_network.clone(),
}
}
}
impl<Block, PF> ParachainContext for Collator<Block, PF>
where
impl<Block, PF> ParachainContext for Collator<Block, PF> where
Block: BlockT,
PF: Environment<Block> + 'static,
PF::Error: std::fmt::Debug,
@@ -126,4 +132,53 @@ where
Box::new(res)
}
}
/// Implements `BuildParachainContext` to build a collator instance.
struct CollatorBuilder<Block, PF> {
inherent_data_providers: InherentDataProviders,
proposer_factory: Arc<PF>,
_phantom: PhantomData<Block>,
}
impl<Block, PF> CollatorBuilder<Block, PF> {
/// Create a new instance of self.
fn new(proposer_factory: Arc<PF>, inherent_data_providers: InherentDataProviders) -> Self {
Self {
inherent_data_providers,
proposer_factory,
_phantom: Default::default(),
}
}
}
impl<Block, PF> BuildParachainContext for CollatorBuilder<Block, PF> where
Block: BlockT,
PF: Environment<Block> + 'static,
PF::Error: std::fmt::Debug,
{
type ParachainContext = Collator<Block, PF>;
fn build(self, network: Arc<dyn CollatorNetwork>) -> Result<Self::ParachainContext, ()> {
Ok(Collator::new(self.proposer_factory, self.inherent_data_providers, network))
}
}
/// Run a collator with the given proposer factory.
pub fn run_collator<Block, PF, E, I>(
proposer_factory: Arc<PF>,
inherent_data_providers: InherentDataProviders,
para_id: ParaId,
exit: E,
key: Arc<ed25519::Pair>,
args: I,
version: VersionInfo,
) -> Result<(), cli::error::Error>
where
Block: BlockT,
PF: Environment<Block> + 'static + Send,
PF::Error: std::fmt::Debug
{
let builder = CollatorBuilder::new(proposer_factory, inherent_data_providers);
polkadot_collator::run_collator(builder, para_id, exit, key, args, version)
}
+1 -1
View File
@@ -19,5 +19,5 @@ polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "b
# other deps
futures = "0.1.21"
tokio = "0.1.8"
parity-codec = "3.5"
parity-codec = "4.1.1"
log = "0.4"
+4 -4
View File
@@ -5,16 +5,16 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
codec = { package = "parity-codec", version = "3.5.1", default-features = false, features = [ "derive" ] }
codec = { package = "parity-codec", version = "4.1.1", default-features = false, features = [ "derive" ] }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
runtime-primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
rio = { package = "sr-io", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
executive = { package = "srml-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
substrate-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
memory-db = { version = "0.12.2", default-features = false }
hash-db = { version = "0.12.2", default-features = false }
trie-db = { version = "0.12.2", default-features = false }
memory-db = { version = "0.14.0", default-features = false }
hash-db = { version = "0.14.0", default-features = false }
trie-db = { version = "0.14.0", default-features = false }
hashbrown = "0.5.0"
[dev-dependencies]
+1 -1
View File
@@ -28,7 +28,7 @@ use rstd::{slice, ptr, cmp, vec::Vec, boxed::Box, mem};
use hash_db::HashDB;
static mut STORAGE: Option<Box<Storage>> = None;
static mut STORAGE: Option<Box<dyn Storage>> = None;
/// The message to use as expect message while accessing the `STORAGE`.
const STORAGE_SET_EXPECT: &str =
"`STORAGE` needs to be set before calling this function.";
+1 -1
View File
@@ -10,7 +10,7 @@ runtime = { package = "cumulus-runtime", path = "../../runtime", default-feature
substrate-test-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
[build-dependencies]
wasm-builder-runner = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = " 1.0.2" }
[features]
default = ["std"]
+1 -7
View File
@@ -17,11 +17,5 @@
use wasm_builder_runner::{build_current_project, WasmBuilderSource};
fn main() {
build_current_project(
"wasm_binary.rs",
WasmBuilderSource::Git {
repo: "https://github.com/paritytech/substrate",
rev: "c7fa536d85df5d6a0fc5cdc3f82b6e5a1a2db640",
}
);
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.4"));
}