Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,450 changes: 1,826 additions & 1,624 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[workspace]
members = [ "consensus" ]
members = [
"consensus",
"runtime",
"test/runtime",
"test/client",
]
20 changes: 10 additions & 10 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
name = "cumulus-consensus"
description = "Proxy Polkadot's consensus as a consensus engine for Substrate"
version = "0.1.0"
authors = ["Parity Technologies"]
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
# substrate deps
substrate-client = { git = "https://github.com/paritytech/substrate" }
substrate-consensus-common = { git = "https://github.com/paritytech/substrate" }
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
sr-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
substrate-consensus-common = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }

# polkadot deps
polkadot-service = { git = "https://github.com/paritytech/polkadot" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }

# other deps
futures = "0.1.21"
tokio = "0.1.8"
parity-codec = "3.0"
log = "0.4"
parity-codec = "3.1"
log = "0.4"
16 changes: 8 additions & 8 deletions consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub enum Error<P> {
/// A parachain head update.
pub struct HeadUpdate {
/// The relay-chain's block hash where the parachain head updated.
pub relay_hash: PHash,
pub relay_hash: PHash,
/// The parachain head-data.
pub head_data: Vec<u8>,
}
Expand All @@ -80,9 +80,9 @@ pub trait PolkadotClient: Clone {
}

/// Spawns a future that follows the Polkadot relay chain for the given parachain.
pub fn follow_polkadot<'a, L: 'a, P: 'a>(para_id: ParaId, local: Arc<L>, polkadot: P)
pub fn follow_polkadot<'a, L: 'a, P: 'a>(para_id: ParaId, local: Arc<L>, polkadot: P)
-> impl Future<Item=(),Error=()> + Send + 'a
where
where
L: LocalClient + Send + Sync,
P: PolkadotClient + Send + Sync,
{
Expand Down Expand Up @@ -169,23 +169,23 @@ impl<B, E, RA> PolkadotClient for Arc<Client<B, E, PBlock, RA>> where
{
type Error = ClientError;

type HeadUpdates = Box<Stream<Item=HeadUpdate,Error=Self::Error> + Send>;
type Finalized = Box<Stream<Item=Vec<u8>,Error=Self::Error> + Send>;
type HeadUpdates = Box<Stream<Item=HeadUpdate, Error=Self::Error> + Send>;
type Finalized = Box<Stream<Item=Vec<u8>, Error=Self::Error> + Send>;

fn head_updates(&self, para_id: ParaId) -> Self::HeadUpdates {
let parachain_key = parachain_key(para_id);
let stream = stream::once(self.storage_changes_notification_stream(Some(&[parachain_key.clone()])))
.map(|s| s.map_err(|()| panic!("unbounded receivers never yield errors; qed")))
.flatten();

let s = stream.filter_map(move |(hash, changes)| {
let head_data = changes.iter()
.filter_map(|(k, v)| if k == &parachain_key { Some(v) } else { None })
.next();

match head_data {
Some(Some(head_data)) => Some(HeadUpdate {
relay_hash: hash,
Some(Some(head_data)) => Some(HeadUpdate {
relay_hash: hash,
head_data: head_data.0.clone(),
}),
Some(None) | None => None,
Expand Down
44 changes: 44 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "cumulus-runtime"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
codec = { package = "parity-codec", version = "3.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 }
hashbrown = "0.1"

[dev-dependencies]
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
executor = { package = "substrate-executor", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
test-client = { package = "cumulus-test-client", path = "../test/client" }

[features]
default = ["std"]
std = [
"codec/std",
"rstd/std",
"rio/std",
"runtime-primitives/std",
"primitives/std",
"executive/std",
"memory-db/std",
"hash-db/std",
"trie-db/std",
"test-client/std",
"substrate-trie/std",
]
wasm = [
"hashbrown/nightly",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this wasm feature something native or something that require some feature declaration?
(I remember that I wanted to use hashbrown but use hasmap_core in trie because it felt easier to manage with 'std' substrate feature, just thinking let's wait for hashbrown to be std and see if at some point it makes it to alloc).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires a feature declaration.

"rio/wasm-nice-panic-message",
]
61 changes: 61 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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 rstd::vec::Vec;
use codec::{Encode, Decode};
use runtime_primitives::traits::Block as BlockT;

#[cfg(not(feature = "std"))]
#[doc(hidden)]
pub use rstd::slice;

#[macro_use]
pub mod validate_block;

/// The witness data type.
type WitnessData = Vec<Vec<u8>>;

/// 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.
witness_data: WitnessData,
witness_data_storage_root: <B as BlockT>::Hash,
}

impl<B: BlockT> ParachainBlockData<B> {
pub fn new(
header: <B as BlockT>::Header,
extrinsics: Vec<<B as BlockT>::Extrinsic>,
witness_data: WitnessData,
witness_data_storage_root: <B as BlockT>::Hash,
) -> Self {
Self {
header,
extrinsics,
witness_data,
witness_data_storage_root,
}
}
}
Loading