From 4b7dfc4c2552f1e46599d1afb5903b4f94884c98 Mon Sep 17 00:00:00 2001
From: Gavin Wood <gavin@parity.io>
Date: Mon, 3 Jun 2019 16:48:33 +0200
Subject: [PATCH] Allow parachains to send messages (#274)

* Slots module

* Integrate slots

* More drafting

* Minor updates

* Update parachains to use trati

* More build fixes

* Full code now compiles

* Add renew bid function

* Implement calculate_winner

* Warning remove

* Update gitignore

* Test framework

* Tests

* Further testing

* More tests, new parameterisation.

* Fix and new test

* Thread-safe tests

* Test off-boarding and a fix.

* Test onboarding

* Allow late onboarding.

* Another test and fix

* Avoid println in nostd

* Compact representation of paraids

* Introduce documentation.

* Introduce events.

* Additional test and fix

* Additional test

* Tidy up line lengths.

* Remove printlns

* Use later substrate utils.

* Allow parachains to send messages.

* Fix build/test

* Make slots work with latest substrate

* Update runtime/src/slot_range.rs

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

* Update runtime/src/slots.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update runtime/src/slots.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Polish logic

* Rewind to earlier substrate master

* Remove dead code.

* Fix build

* Update substrate ref to master

* Update to new inherent digests API

* address grumbles

* fix

* Fix a warning.

* Reworded a comment.

* Check that receipt matches expectations

* Add test for final checks

* Split out queuing logic.

* Test final piece of queuing logic

* Fix up docs.

* More docs fixes
---
 polkadot/Cargo.lock                         | 171 +++---
 polkadot/collator/src/lib.rs                |   2 +-
 polkadot/network/src/collator_pool.rs       |   4 +-
 polkadot/network/src/gossip.rs              |   2 +-
 polkadot/network/src/lib.rs                 |   2 +-
 polkadot/network/src/tests/mod.rs           |   4 +-
 polkadot/parachain/src/lib.rs               |  34 ++
 polkadot/parachain/src/wasm_api.rs          |  13 +-
 polkadot/parachain/src/wasm_executor.rs     |  66 ++-
 polkadot/parachain/tests/adder.rs           |   5 +-
 polkadot/primitives/src/parachain.rs        |  20 +-
 polkadot/runtime/src/claims.rs              |   2 +
 polkadot/runtime/src/lib.rs                 |   7 +-
 polkadot/runtime/src/parachains.rs          | 585 ++++++++++++++++++--
 polkadot/runtime/wasm/Cargo.lock            | 110 ++--
 polkadot/validation/src/collation.rs        | 103 +++-
 polkadot/validation/src/lib.rs              |  10 +-
 polkadot/validation/src/shared_table/mod.rs |  12 +-
 18 files changed, 928 insertions(+), 224 deletions(-)

diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock
index 8382ac0633b..d9ec7ad46df 100644
--- a/polkadot/Cargo.lock
+++ b/polkadot/Cargo.lock
@@ -89,7 +89,7 @@ dependencies = [
  "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -812,7 +812,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 [[package]]
 name = "fork-tree"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -1112,7 +1112,7 @@ dependencies = [
  "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1143,6 +1143,14 @@ dependencies = [
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "impl-serde"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "indexmap"
 version = "1.0.2"
@@ -1297,6 +1305,15 @@ dependencies = [
  "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "kvdb-memorydb"
+version = "0.1.0"
+source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d"
+dependencies = [
+ "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
+ "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "kvdb-rocksdb"
 version = "0.1.4"
@@ -2502,13 +2519,13 @@ dependencies = [
 
 [[package]]
 name = "primitive-types"
-version = "0.2.1"
+version = "0.2.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -3104,7 +3121,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 [[package]]
 name = "sr-api-macros"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3116,7 +3133,7 @@ dependencies = [
 [[package]]
 name = "sr-io"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3133,7 +3150,7 @@ dependencies = [
 [[package]]
 name = "sr-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3148,7 +3165,7 @@ dependencies = [
 [[package]]
 name = "sr-std"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -3156,7 +3173,7 @@ dependencies = [
 [[package]]
 name = "sr-version"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3168,7 +3185,7 @@ dependencies = [
 [[package]]
 name = "srml-aura"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3185,7 +3202,7 @@ dependencies = [
 [[package]]
 name = "srml-balances"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3200,7 +3217,7 @@ dependencies = [
 [[package]]
 name = "srml-consensus"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3215,7 +3232,7 @@ dependencies = [
 [[package]]
 name = "srml-council"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3232,7 +3249,7 @@ dependencies = [
 [[package]]
 name = "srml-democracy"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3247,7 +3264,7 @@ dependencies = [
 [[package]]
 name = "srml-executive"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3261,7 +3278,7 @@ dependencies = [
 [[package]]
 name = "srml-finality-tracker"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3275,7 +3292,7 @@ dependencies = [
 [[package]]
 name = "srml-grandpa"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3293,7 +3310,7 @@ dependencies = [
 [[package]]
 name = "srml-indices"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3310,7 +3327,7 @@ dependencies = [
 [[package]]
 name = "srml-metadata"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3321,7 +3338,7 @@ dependencies = [
 [[package]]
 name = "srml-session"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3337,7 +3354,7 @@ dependencies = [
 [[package]]
 name = "srml-staking"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3355,7 +3372,7 @@ dependencies = [
 [[package]]
 name = "srml-sudo"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3370,7 +3387,7 @@ dependencies = [
 [[package]]
 name = "srml-support"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3388,7 +3405,7 @@ dependencies = [
 [[package]]
 name = "srml-support-procedural"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3400,7 +3417,7 @@ dependencies = [
 [[package]]
 name = "srml-support-procedural-tools"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3412,7 +3429,7 @@ dependencies = [
 [[package]]
 name = "srml-support-procedural-tools-derive"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3422,7 +3439,7 @@ dependencies = [
 [[package]]
 name = "srml-system"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3437,7 +3454,7 @@ dependencies = [
 [[package]]
 name = "srml-timestamp"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3451,7 +3468,7 @@ dependencies = [
 [[package]]
 name = "srml-treasury"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3589,7 +3606,7 @@ dependencies = [
 [[package]]
 name = "substrate-cli"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3624,7 +3641,7 @@ dependencies = [
 [[package]]
 name = "substrate-client"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3652,10 +3669,11 @@ dependencies = [
 [[package]]
 name = "substrate-client-db"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
+ "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
  "kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3674,7 +3692,7 @@ dependencies = [
 [[package]]
 name = "substrate-consensus-aura"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3700,7 +3718,7 @@ dependencies = [
 [[package]]
 name = "substrate-consensus-aura-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -3709,7 +3727,7 @@ dependencies = [
 [[package]]
 name = "substrate-consensus-authorities"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-io 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -3724,7 +3742,7 @@ dependencies = [
 [[package]]
 name = "substrate-consensus-common"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3732,18 +3750,19 @@ dependencies = [
  "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "sr-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "sr-version 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-inherents 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
- "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "substrate-consensus-slots"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3760,7 +3779,7 @@ dependencies = [
 [[package]]
 name = "substrate-executor"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3783,7 +3802,7 @@ dependencies = [
 [[package]]
 name = "substrate-finality-grandpa"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "finality-grandpa 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "fork-tree 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -3809,7 +3828,7 @@ dependencies = [
 [[package]]
 name = "substrate-finality-grandpa-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -3821,7 +3840,7 @@ dependencies = [
 [[package]]
 name = "substrate-inherents"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3832,7 +3851,7 @@ dependencies = [
 [[package]]
 name = "substrate-keyring"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -3844,7 +3863,7 @@ dependencies = [
 [[package]]
 name = "substrate-keystore"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3857,7 +3876,7 @@ dependencies = [
 [[package]]
 name = "substrate-network"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3877,14 +3896,14 @@ dependencies = [
  "substrate-network-libp2p 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-peerset 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
- "tokio 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "substrate-network-libp2p"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3903,7 +3922,7 @@ dependencies = [
  "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "substrate-peerset 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "zeroize 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3912,7 +3931,7 @@ dependencies = [
 [[package]]
 name = "substrate-offchain"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3920,7 +3939,6 @@ dependencies = [
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-consensus-common 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
- "substrate-inherents 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-offchain-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-transaction-pool 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -3930,7 +3948,7 @@ dependencies = [
 [[package]]
 name = "substrate-offchain-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -3939,7 +3957,7 @@ dependencies = [
 [[package]]
 name = "substrate-panic-handler"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3948,7 +3966,7 @@ dependencies = [
 [[package]]
 name = "substrate-peerset"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
  "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3961,7 +3979,7 @@ dependencies = [
 [[package]]
 name = "substrate-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3971,8 +3989,9 @@ dependencies = [
  "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3989,7 +4008,7 @@ dependencies = [
 [[package]]
 name = "substrate-rpc"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4014,7 +4033,7 @@ dependencies = [
 [[package]]
 name = "substrate-rpc-servers"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "jsonrpc-http-server 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "jsonrpc-pubsub 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4028,7 +4047,7 @@ dependencies = [
 [[package]]
 name = "substrate-serializer"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4037,7 +4056,7 @@ dependencies = [
 [[package]]
 name = "substrate-service"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4055,7 +4074,6 @@ dependencies = [
  "substrate-client-db 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-consensus-common 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-executor 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
- "substrate-inherents 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-keystore 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-network 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-offchain 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -4070,7 +4088,7 @@ dependencies = [
 [[package]]
 name = "substrate-state-db"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4081,10 +4099,11 @@ dependencies = [
 [[package]]
 name = "substrate-state-machine"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "substrate-panic-handler 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -4097,7 +4116,7 @@ dependencies = [
 [[package]]
 name = "substrate-telemetry"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4115,7 +4134,7 @@ dependencies = [
 [[package]]
 name = "substrate-transaction-graph"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4129,7 +4148,7 @@ dependencies = [
 [[package]]
 name = "substrate-transaction-pool"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4145,7 +4164,7 @@ dependencies = [
 [[package]]
 name = "substrate-trie"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#3c2cec6e01e71450debc4149d93cca4e825d948f"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4316,7 +4335,7 @@ dependencies = [
  "tokio-sync 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4439,7 +4458,7 @@ dependencies = [
 
 [[package]]
 name = "tokio-timer"
-version = "0.2.10"
+version = "0.2.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4570,7 +4589,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "uint"
-version = "0.6.1"
+version = "0.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4775,7 +4794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
  "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "wasm-bindgen 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "web-sys 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -5097,6 +5116,7 @@ dependencies = [
 "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
 "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b"
 "checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56"
+"checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1"
 "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
 "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903"
 "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77"
@@ -5114,6 +5134,7 @@ dependencies = [
 "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=616b40150ded71f57f650067fcbc5c99d7c343e6)" = "<none>"
 "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "<none>"
 "checksum kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=616b40150ded71f57f650067fcbc5c99d7c343e6)" = "<none>"
+"checksum kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "<none>"
 "checksum kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=616b40150ded71f57f650067fcbc5c99d7c343e6)" = "<none>"
 "checksum kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "<none>"
 "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
@@ -5200,7 +5221,7 @@ dependencies = [
 "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
 "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
 "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
-"checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e"
+"checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f"
 "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c"
 "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8"
 "checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66"
@@ -5367,7 +5388,7 @@ dependencies = [
 "checksum tokio-sync 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fda385df506bf7546e70872767f71e81640f1f251bdf2fd8eb81a0eaec5fe022"
 "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119"
 "checksum tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ec5759cf26cf9659555f36c431b515e3d05f66831741c85b4b5d5dfb9cf1323c"
-"checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6"
+"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e"
 "checksum tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c"
 "checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3"
 "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92"
@@ -5382,7 +5403,7 @@ dependencies = [
 "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
 "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
 "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
-"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708"
+"checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4"
 "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
 "checksum unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41d17211f887da8e4a70a45b9536f26fc5de166b81e2d5d80de4a17fd22553bd"
 "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
diff --git a/polkadot/collator/src/lib.rs b/polkadot/collator/src/lib.rs
index fd5294c6162..a95709148ac 100644
--- a/polkadot/collator/src/lib.rs
+++ b/polkadot/collator/src/lib.rs
@@ -152,10 +152,10 @@ pub fn collate<'a, R, P>(
 			collator: key.public(),
 			signature,
 			head_data,
-			balance_uploads: Vec::new(),
 			egress_queue_roots,
 			fees: 0,
 			block_data_hash,
+			upward_messages: Vec::new(),
 		};
 
 		Ok(parachain::Collation {
diff --git a/polkadot/network/src/collator_pool.rs b/polkadot/network/src/collator_pool.rs
index 281f6c0ab49..1b396742ae7 100644
--- a/polkadot/network/src/collator_pool.rs
+++ b/polkadot/network/src/collator_pool.rs
@@ -277,10 +277,10 @@ mod tests {
 				collator: primary.into(),
 				signature: Default::default(),
 				head_data: HeadData(vec![1, 2, 3]),
-				balance_uploads: vec![],
 				egress_queue_roots: vec![],
 				fees: 0,
 				block_data_hash: [3; 32].into(),
+				upward_messages: Vec::new(),
 			},
 			pov: make_pov(vec![4, 5, 6]),
 		});
@@ -304,10 +304,10 @@ mod tests {
 				collator: primary,
 				signature: Default::default(),
 				head_data: HeadData(vec![1, 2, 3]),
-				balance_uploads: vec![],
 				egress_queue_roots: vec![],
 				fees: 0,
 				block_data_hash: [3; 32].into(),
+				upward_messages: Vec::new(),
 			},
 			pov: make_pov(vec![4, 5, 6]),
 		});
diff --git a/polkadot/network/src/gossip.rs b/polkadot/network/src/gossip.rs
index 7822c65fdeb..58d8160cab1 100644
--- a/polkadot/network/src/gossip.rs
+++ b/polkadot/network/src/gossip.rs
@@ -643,10 +643,10 @@ mod tests {
 			collator: [255; 32].unchecked_into(),
 			head_data: HeadData(vec![9, 9, 9]),
 			signature: Default::default(),
-			balance_uploads: Vec::new(),
 			egress_queue_roots: Vec::new(),
 			fees: 1_000_000,
 			block_data_hash: [20u8; 32].into(),
+			upward_messages: Vec::new(),
 		};
 
 		let statement = GossipMessage::Statement(GossipStatement {
diff --git a/polkadot/network/src/lib.rs b/polkadot/network/src/lib.rs
index 82dd879740e..a0b64eb5436 100644
--- a/polkadot/network/src/lib.rs
+++ b/polkadot/network/src/lib.rs
@@ -69,7 +69,7 @@ mod benefit {
 type FullStatus = GenericFullStatus<Block>;
 
 /// Specialization of the network service for the polkadot protocol.
-pub type NetworkService = ::substrate_network::Service<Block, PolkadotProtocol>;
+pub type NetworkService = ::substrate_network::NetworkService<Block, PolkadotProtocol>;
 
 /// Status of a Polkadot node.
 #[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
diff --git a/polkadot/network/src/tests/mod.rs b/polkadot/network/src/tests/mod.rs
index 9a88e69a9ec..799fa87c2e7 100644
--- a/polkadot/network/src/tests/mod.rs
+++ b/polkadot/network/src/tests/mod.rs
@@ -158,10 +158,10 @@ fn fetches_from_those_with_knowledge() {
 		collator: [255; 32].unchecked_into(),
 		head_data: HeadData(vec![9, 9, 9]),
 		signature: Default::default(),
-		balance_uploads: Vec::new(),
 		egress_queue_roots: Vec::new(),
 		fees: 1_000_000,
 		block_data_hash,
+		upward_messages: Vec::new(),
 	};
 
 	let candidate_hash = candidate_receipt.hash();
@@ -242,10 +242,10 @@ fn fetches_available_block_data() {
 		collator: [255; 32].unchecked_into(),
 		head_data: HeadData(vec![9, 9, 9]),
 		signature: Default::default(),
-		balance_uploads: Vec::new(),
 		egress_queue_roots: Vec::new(),
 		fees: 1_000_000,
 		block_data_hash,
+		upward_messages: Vec::new(),
 	};
 
 	let candidate_hash = candidate_receipt.hash();
diff --git a/polkadot/parachain/src/lib.rs b/polkadot/parachain/src/lib.rs
index bd0b4182119..69c2155344c 100644
--- a/polkadot/parachain/src/lib.rs
+++ b/polkadot/parachain/src/lib.rs
@@ -197,3 +197,37 @@ pub struct MessageRef<'a> {
 	/// Underlying data of the message.
 	pub data: &'a [u8],
 }
+
+/// Which origin a parachain's message to the relay chain should be dispatched from.
+#[derive(Clone, PartialEq, Eq, Encode, Decode)]
+#[cfg_attr(feature = "std", derive(Debug))]
+#[repr(u8)]
+pub enum ParachainDispatchOrigin {
+	/// As a simple `Origin::Signed`, using `ParaId::account_id` as its value. This is good when
+	/// interacting with standard modules such as `balances`.
+	Signed,
+	/// As the special `Origin::Parachain(ParaId)`. This is good when interacting with parachain-
+	/// aware modules which need to succinctly verify that the origin is a parachain.
+	Parachain,
+}
+
+impl core::convert::TryFrom<u8> for ParachainDispatchOrigin {
+	type Error = ();
+	fn try_from(x: u8) -> core::result::Result<ParachainDispatchOrigin, ()> {
+		const SIGNED: u8 = ParachainDispatchOrigin::Signed as u8;
+		const PARACHAIN: u8 = ParachainDispatchOrigin::Parachain as u8;
+		Ok(match x {
+			SIGNED => ParachainDispatchOrigin::Signed,
+			PARACHAIN => ParachainDispatchOrigin::Parachain,
+			_ => return Err(()),
+		})
+	}
+}
+
+/// A reference to an upward message.
+pub struct UpwardMessageRef<'a> {
+	/// The origin type.
+	pub origin: ParachainDispatchOrigin,
+	/// Underlying data of the message.
+	pub data: &'a [u8],
+}
diff --git a/polkadot/parachain/src/wasm_api.rs b/polkadot/parachain/src/wasm_api.rs
index 0f11259b7bc..ad7c14ececd 100644
--- a/polkadot/parachain/src/wasm_api.rs
+++ b/polkadot/parachain/src/wasm_api.rs
@@ -17,11 +17,14 @@
 //! Utilities for writing parachain WASM.
 
 use codec::{Encode, Decode};
-use super::{ValidationParams, ValidationResult, MessageRef};
+use super::{
+	ValidationParams, ValidationResult, MessageRef, UpwardMessageRef, ParachainDispatchOrigin
+};
 
 mod ll {
 	extern "C" {
 		pub(super) fn ext_post_message(target: u32, data_ptr: *const u8, data_len: u32);
+		pub(super) fn ext_post_upward_message(origin: u32, data_ptr: *const u8, data_len: u32);
 	}
 }
 
@@ -61,3 +64,11 @@ pub fn post_message(message: MessageRef) {
 
 	unsafe { ll::ext_post_message(message.target.into_inner(), data_ptr, data_len as u32) }
 }
+
+/// Post a message to this parachain's relay chain.
+pub fn post_upward_message(message: UpwardMessageRef) {
+	let data_ptr = message.as_ptr();
+	let data_len = message.len();
+
+	unsafe { ll::ext_post_upward_message(message.origin as u8 as u32, data_ptr, data_len as u32) }
+}
diff --git a/polkadot/parachain/src/wasm_executor.rs b/polkadot/parachain/src/wasm_executor.rs
index cde5df04d5f..f3903351903 100644
--- a/polkadot/parachain/src/wasm_executor.rs
+++ b/polkadot/parachain/src/wasm_executor.rs
@@ -20,20 +20,21 @@
 //! Assuming the parameters are correct, this module provides a wrapper around
 //! a WASM VM for re-execution of a parachain candidate.
 
+use std::{cell::RefCell, fmt, convert::TryInto};
 use codec::{Decode, Encode};
-
-use wasmi::{self, Module, ModuleInstance, Trap, MemoryInstance, MemoryDescriptor, MemoryRef, ModuleImportResolver};
-use wasmi::{memory_units, RuntimeValue, Externals, Error as WasmError, ValueType};
-use wasmi::memory_units::{Bytes, Pages, RoundUpTo};
-
-use super::{ValidationParams, ValidationResult, MessageRef};
-
-use std::cell::RefCell;
-use std::fmt;
+use wasmi::{
+	self, Module, ModuleInstance, Trap, MemoryInstance, MemoryDescriptor, MemoryRef,
+	ModuleImportResolver, RuntimeValue, Externals, Error as WasmError, ValueType,
+	memory_units::{self, Bytes, Pages, RoundUpTo}
+};
+use super::{ValidationParams, ValidationResult, MessageRef, UpwardMessageRef};
 
 mod ids {
 	/// Post a message to another parachain.
 	pub const POST_MESSAGE: usize = 1;
+
+	/// Post a message to this parachain's relay chain.
+	pub const POST_UPWARDS_MESSAGE: usize = 2;
 }
 
 error_chain! {
@@ -67,6 +68,9 @@ pub enum ExternalitiesError {
 pub trait Externalities {
 	/// Called when a message is to be posted to another parachain.
 	fn post_message(&mut self, message: MessageRef) -> Result<(), ExternalitiesError>;
+
+	/// Called when a message is to be posted to the parachain's relay chain.
+	fn post_upward_message(&mut self, message: UpwardMessageRef) -> Result<(), ExternalitiesError>;
 }
 
 impl fmt::Display for ExternalitiesError {
@@ -96,7 +100,23 @@ impl ModuleImportResolver for Resolver {
 			"ext_post_message" => {
 				let index = ids::POST_MESSAGE;
 				let (params, ret_ty): (&[ValueType], Option<ValueType>) =
-				(&[ValueType::I32, ValueType::I32, ValueType::I32], None);
+					(&[ValueType::I32, ValueType::I32, ValueType::I32], None);
+
+				if signature.params() != params && signature.return_type() != ret_ty {
+					Err(WasmError::Instantiation(
+						format!("Export {} has a bad signature", field_name)
+					))
+				} else {
+					Ok(wasmi::FuncInstance::alloc_host(
+						wasmi::Signature::new(&params[..], ret_ty),
+						index,
+					))
+				}
+			}
+			"ext_upwards_post_message" => {
+				let index = ids::POST_UPWARDS_MESSAGE;
+				let (params, ret_ty): (&[ValueType], Option<ValueType>) =
+					(&[ValueType::I32, ValueType::I32], None);
 
 				if signature.params() != params && signature.return_type() != ret_ty {
 					Err(WasmError::Instantiation(
@@ -172,6 +192,31 @@ impl<'a, E: 'a + Externalities> ValidationExternals<'a, E> {
 			}
 		})
 	}
+	/// Signature: post_upward_message(u32, *const u8, u32) -> None
+	/// usage: post_upward_message(origin, data ptr, data len).
+	/// Origin is the integer representation of the dispatch origin.
+	/// Data is the raw data of the message.
+	fn ext_post_upward_message(&mut self, args: ::wasmi::RuntimeArgs) -> Result<(), Trap> {
+		let origin: u32 = args.nth_checked(0)?;
+		let data_ptr: u32 = args.nth_checked(1)?;
+		let data_len: u32 = args.nth_checked(2)?;
+
+		let (data_ptr, data_len) = (data_ptr as usize, data_len as usize);
+
+		self.memory.with_direct_access(|mem| {
+			if mem.len() < (data_ptr + data_len) {
+				Err(Trap::new(wasmi::TrapKind::MemoryAccessOutOfBounds))
+			} else {
+				let origin = (origin as u8).try_into()
+					.map_err(|_| Trap::new(wasmi::TrapKind::UnexpectedSignature))?;
+				let message = UpwardMessageRef { origin, data: &mem[data_ptr..][..data_len] };
+				let res = self.externalities.post_upward_message(message);
+				res.map_err(|e| Trap::new(wasmi::TrapKind::Host(
+					Box::new(e) as Box<_>
+				)))
+			}
+		})
+	}
 }
 
 impl<'a, E: 'a + Externalities> Externals for ValidationExternals<'a, E> {
@@ -182,6 +227,7 @@ impl<'a, E: 'a + Externalities> Externals for ValidationExternals<'a, E> {
 	) -> Result<Option<RuntimeValue>, Trap> {
 		match index {
 			ids::POST_MESSAGE => self.ext_post_message(args).map(|_| None),
+			ids::POST_UPWARDS_MESSAGE => self.ext_post_upward_message(args).map(|_| None),
 			_ => panic!("no externality at given index"),
 		}
 	}
diff --git a/polkadot/parachain/tests/adder.rs b/polkadot/parachain/tests/adder.rs
index ac36f5c96d4..ac6005ffb3c 100644
--- a/polkadot/parachain/tests/adder.rs
+++ b/polkadot/parachain/tests/adder.rs
@@ -22,7 +22,7 @@ extern crate parity_codec as codec;
 extern crate polkadot_parachain as parachain;
 extern crate tiny_keccak;
 
-use parachain::{MessageRef, IncomingMessage, ValidationParams};
+use parachain::{MessageRef, UpwardMessageRef, IncomingMessage, ValidationParams};
 use parachain::wasm_executor::{Externalities, ExternalitiesError};
 use codec::{Decode, Encode};
 
@@ -57,6 +57,9 @@ impl Externalities for DummyExt {
 	fn post_message(&mut self, _message: MessageRef) -> Result<(), ExternalitiesError> {
 		Ok(())
 	}
+	fn post_upward_message(&mut self, _message: UpwardMessageRef) -> Result<(), ExternalitiesError> {
+		Ok(())
+	}
 }
 
 const TEST_CODE: &[u8] = include_bytes!("res/adder.wasm");
diff --git a/polkadot/primitives/src/parachain.rs b/polkadot/primitives/src/parachain.rs
index 8bc6093502f..9281809b0b6 100644
--- a/polkadot/primitives/src/parachain.rs
+++ b/polkadot/primitives/src/parachain.rs
@@ -19,7 +19,7 @@
 use rstd::prelude::*;
 use rstd::cmp::Ordering;
 use parity_codec::{Encode, Decode};
-use super::Hash;
+use super::{Hash, Balance};
 
 #[cfg(feature = "std")]
 use serde::{Serialize, Deserialize};
@@ -28,7 +28,7 @@ use serde::{Serialize, Deserialize};
 use primitives::bytes;
 use primitives::ed25519;
 
-pub use polkadot_parachain::{Id, AccountIdConversion};
+pub use polkadot_parachain::{Id, AccountIdConversion, ParachainDispatchOrigin};
 
 /// Identity that collators use.
 pub type CollatorId = ed25519::Public;
@@ -108,6 +108,16 @@ pub struct Extrinsic {
 	pub outgoing_messages: Vec<OutgoingMessage>
 }
 
+/// A message from a parachain to its Relay Chain.
+#[derive(Clone, PartialEq, Eq, Encode, Decode)]
+#[cfg_attr(feature = "std", derive(Debug))]
+pub struct UpwardMessage {
+	/// The origin for the message to be sent from.
+	pub origin: ParachainDispatchOrigin,
+	/// The message data.
+	pub data: Vec<u8>,
+}
+
 /// Candidate receipt type.
 #[derive(PartialEq, Eq, Clone, Encode, Decode)]
 #[cfg_attr(feature = "std", derive(Debug))]
@@ -120,15 +130,15 @@ pub struct CandidateReceipt {
 	pub signature: CollatorSignature,
 	/// The head-data
 	pub head_data: HeadData,
-	/// Balance uploads to the relay chain.
-	pub balance_uploads: Vec<(super::AccountId, u64)>,
 	/// Egress queue roots. Must be sorted lexicographically (ascending)
 	/// by parachain ID.
 	pub egress_queue_roots: Vec<(Id, Hash)>,
 	/// Fees paid from the chain to the relay chain validators
-	pub fees: u64,
+	pub fees: Balance,
 	/// blake2-256 Hash of block data.
 	pub block_data_hash: Hash,
+	/// Messages destined to be interpreted by the Relay chain itself.
+	pub upward_messages: Vec<UpwardMessage>,
 }
 
 impl CandidateReceipt {
diff --git a/polkadot/runtime/src/claims.rs b/polkadot/runtime/src/claims.rs
index 2e1adb8584e..7b6837da28a 100644
--- a/polkadot/runtime/src/claims.rs
+++ b/polkadot/runtime/src/claims.rs
@@ -172,6 +172,7 @@ impl<T: Trait> ValidateUnsigned for Module<T> {
 					requires: vec![],
 					provides: vec![],
 					longevity: TransactionLongevity::max_value(),
+					propagate: true,
 				}
 			}
 			_ => TransactionValidity::Invalid(INVALID_CALL)
@@ -345,6 +346,7 @@ mod tests {
 					requires: vec![],
 					provides: vec![],
 					longevity: TransactionLongevity::max_value(),
+					propagate: true,
 				}
 			);
 			assert_eq!(
diff --git a/polkadot/runtime/src/lib.rs b/polkadot/runtime/src/lib.rs
index b61cc81bad3..31574cc99d0 100644
--- a/polkadot/runtime/src/lib.rs
+++ b/polkadot/runtime/src/lib.rs
@@ -200,7 +200,10 @@ impl grandpa::Trait for Runtime {
 	type Event = Event;
 }
 
-impl parachains::Trait for Runtime {}
+impl parachains::Trait for Runtime {
+	type Origin = Origin;
+	type Call = Call;
+}
 
 parameter_types!{
 	pub const LeasePeriod: BlockNumber = 100000;
@@ -245,7 +248,7 @@ construct_runtime!(
 		CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin},
 		CouncilSeats: council_seats::{Config<T>},
 		Treasury: treasury,
-		Parachains: parachains::{Module, Call, Storage, Config<T>, Inherent},
+		Parachains: parachains::{Module, Call, Storage, Config<T>, Inherent, Origin},
 		Slots: slots::{Module, Call, Storage, Event<T>},
 		Sudo: sudo,
 	}
diff --git a/polkadot/runtime/src/parachains.rs b/polkadot/runtime/src/parachains.rs
index d82f41f3b0b..aebdb6a8777 100644
--- a/polkadot/runtime/src/parachains.rs
+++ b/polkadot/runtime/src/parachains.rs
@@ -21,11 +21,16 @@ use parity_codec::{Decode, HasCompact};
 use srml_support::{decl_storage, decl_module, fail, ensure};
 
 use bitvec::{bitvec, BigEndian};
-use sr_primitives::traits::{Hash as HashT, BlakeTwo256, Member};
-use primitives::{Hash, parachain::{Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement, AccountIdConversion}};
+use sr_primitives::traits::{Hash as HashT, BlakeTwo256, Member, CheckedConversion};
+use primitives::{Hash, parachain::{
+	Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement, AccountIdConversion,
+	ParachainDispatchOrigin, UpwardMessage
+}};
 use {system, session};
+use srml_support::{
+	StorageValue, StorageMap, storage::AppendableStorageMap, Parameter, Dispatchable, dispatch::Result
+};
 
-use srml_support::{StorageValue, StorageMap, Parameter, dispatch::Result};
 #[cfg(feature = "std")]
 use srml_support::storage::hashed::generator;
 
@@ -96,6 +101,19 @@ impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
 }
 
 pub trait Trait: session::Trait {
+	/// The outer origin type.
+	type Origin: From<Origin> + From<system::RawOrigin<Self::AccountId>>;
+
+	/// The outer call dispatch type.
+	type Call: Parameter + Dispatchable<Origin=<Self as Trait>::Origin>;
+}
+
+/// Origin for the parachains module.
+#[derive(PartialEq, Eq, Clone)]
+#[cfg_attr(feature = "std", derive(Debug))]
+pub enum Origin {
+	/// It comes from a parachain.
+	Parachain(ParaId),
 }
 
 // result of <NodeCodec<Blake2Hasher> as trie_db::NodeCodec<Blake2Hasher>>::hashed_null_node()
@@ -104,6 +122,13 @@ const EMPTY_TRIE_ROOT: [u8; 32] = [
 	98, 177, 87, 231, 135, 134, 216, 192, 130, 242, 157, 207, 76, 17, 19, 20
 ];
 
+/// Total number of individual messages allowed in the parachain -> relay-chain message queue.
+const MAX_QUEUE_COUNT: usize = 100;
+/// Total size of messages allowed in the parachain -> relay-chain message queue before which no
+/// further messages may be added to it. If it exceeds this then the queue may contain only a
+/// single message.
+const WATERMARK_QUEUE_SIZE: usize = 20000;
+
 decl_storage! {
 	trait Store for Module<T: Trait> as Parachains {
 		// Vector of all parachain IDs.
@@ -115,6 +140,14 @@ decl_storage! {
 		// message routing roots (from, to).
 		pub Routing: map (ParaId, ParaId) => Option<Hash>;
 
+		/// Messages ready to be dispatched onto the relay chain. It is subject to
+		/// `MAX_MESSAGE_COUNT` and `WATERMARK_MESSAGE_SIZE`.
+		pub RelayDispatchQueue: map ParaId => Vec<UpwardMessage>;
+		/// Size of the dispatch queues. Separated from actual data in order to avoid costly
+		/// decoding when checking receipt validity. First item in tuple is the count of messages
+		//	second if the total length (in bytes) of the message payloads.
+		pub RelayDispatchQueueSize: map ParaId => (u32, u32);
+
 		// Did the parachain heads get updated in this block?
 		DidUpdate: bool;
 
@@ -144,50 +177,69 @@ decl_storage! {
 
 decl_module! {
 	/// Parachains module.
-	pub struct Module<T: Trait> for enum Call where origin: T::Origin {
+	pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin {
 		/// Provide candidate receipts for parachains, in ascending order by id.
 		fn set_heads(origin, heads: Vec<AttestedCandidate>) -> Result {
 			ensure_none(origin)?;
 			ensure!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
 
 			let active_parachains = Self::active_parachains();
-
-			// perform integrity checks before writing to storage.
-			{
-				let n_parachains = active_parachains.len();
-				ensure!(heads.len() <= n_parachains, "Too many parachain candidates");
-
-				let mut last_id = None;
-				let mut iter = active_parachains.iter();
-				for head in &heads {
-					// proposed heads must be ascending order by parachain ID without duplicate.
-					ensure!(
-						last_id.as_ref().map_or(true, |x| x < &head.parachain_index()),
-						"Parachain candidates out of order by ID"
-					);
-
-					// must be unknown since active parachains are always sorted.
-					ensure!(
-						iter.find(|x| x == &&head.parachain_index()).is_some(),
-						"Submitted candidate for unregistered or out-of-order parachain {}"
-					);
-
-					Self::check_egress_queue_roots(&head, &active_parachains)?;
-
-					last_id = Some(head.parachain_index());
+			let parachain_count = active_parachains.len();
+			ensure!(heads.len() <= parachain_count, "Too many parachain candidates");
+
+			if !active_parachains.is_empty() {
+				// perform integrity checks before writing to storage.
+				{
+					let mut last_id = None;
+					let mut iter = active_parachains.iter();
+					for head in &heads {
+						let id = head.parachain_index();
+						// proposed heads must be ascending order by parachain ID without duplicate.
+						ensure!(
+							last_id.as_ref().map_or(true, |x| x < &id),
+							"Parachain candidates out of order by ID"
+						);
+
+						// must be unknown since active parachains are always sorted.
+						ensure!(
+							iter.find(|x| x == &&id).is_some(),
+							"Submitted candidate for unregistered or out-of-order parachain {}"
+						);
+
+						Self::check_upward_messages(
+							id,
+							&head.candidate.upward_messages,
+							MAX_QUEUE_COUNT,
+							WATERMARK_QUEUE_SIZE,
+						)?;
+						Self::check_egress_queue_roots(&head, &active_parachains)?;
+
+						last_id = Some(head.parachain_index());
+					}
 				}
-			}
 
-			Self::check_attestations(&heads)?;
+				Self::check_attestations(&heads)?;
 
-			for head in heads {
-				let id = head.parachain_index();
-				<Heads<T>>::insert(id, head.candidate.head_data.0);
+				for head in heads.iter() {
+					let id = head.parachain_index();
+					<Heads<T>>::insert(id, &head.candidate.head_data.0);
 
-				// update egress.
-				for &(to, root) in &head.candidate.egress_queue_roots {
-					<Routing<T>>::insert((id, to), root);
+					// update egress.
+					for &(to, root) in &head.candidate.egress_queue_roots {
+						<Routing<T>>::insert((id, to), root);
+					}
+
+					// Queue up upwards messages (from parachains to relay chain).
+					Self::queue_upward_messages(id, &head.candidate.upward_messages);
 				}
+
+				Self::dispatch_upward_messages(
+					<system::Module<T>>::block_number(),
+					&active_parachains,
+					MAX_QUEUE_COUNT,
+					WATERMARK_QUEUE_SIZE,
+					Self::dispatch_message,
+				);
 			}
 
 			<DidUpdate<T>>::put(true);
@@ -225,6 +277,113 @@ fn localized_payload(statement: Statement, parent_hash: ::primitives::Hash) -> V
 }
 
 impl<T: Trait> Module<T> {
+	/// Dispatch some messages from a parachain.
+	fn dispatch_message(
+		id: ParaId,
+		origin: ParachainDispatchOrigin,
+		data: &[u8],
+	) {
+		if let Some(message_call) = T::Call::decode(&mut &data[..]) {
+			let origin: <T as Trait>::Origin = match origin {
+				ParachainDispatchOrigin::Signed =>
+					system::RawOrigin::Signed(id.into_account()).into(),
+				ParachainDispatchOrigin::Parachain =>
+					Origin::Parachain(id).into(),
+			};
+			let _ok = message_call.dispatch(origin).is_ok();
+			// Not much to do with the result as it is. It's up to the parachain to ensure that the
+			// message makes sense.
+		}
+	}
+
+	/// Ensure all is well with the upward messages.
+	fn check_upward_messages(
+		id: ParaId,
+		upward_messages: &[UpwardMessage],
+		max_queue_count: usize,
+		watermark_queue_size: usize,
+	) -> Result {
+		// Either there are no more messages to add...
+		if !upward_messages.is_empty() {
+			let (count, size) = <RelayDispatchQueueSize<T>>::get(id);
+			ensure!(
+				// ...or we are appending one message onto an empty queue...
+				upward_messages.len() + count as usize == 1
+				// ...or...
+				|| (
+					// ...the total messages in the queue ends up being no greater than the
+					// limit...
+					upward_messages.len() + count as usize <= max_queue_count
+				&&
+					// ...and the total size of the payloads in the queue ends up being no
+					// greater than the limit.
+					upward_messages.iter()
+						.fold(size as usize, |a, x| a + x.data.len())
+					<= watermark_queue_size
+				),
+				"Messages added when queue full"
+			);
+		}
+		Ok(())
+	}
+
+	/// Place any new upward messages into our queue for later dispatch.
+	fn queue_upward_messages(id: ParaId, upward_messages: &[UpwardMessage]) {
+		if !upward_messages.is_empty() {
+			<RelayDispatchQueueSize<T>>::mutate(id, |&mut(ref mut count, ref mut len)| {
+				*count += upward_messages.len() as u32;
+				*len += upward_messages.iter()
+					.fold(0, |a, x| a + x.data.len()) as u32;
+			});
+			// Should never be able to fail assuming our state is uncorrupted, but best not
+			// to panic, even if it does.
+			let _ = <RelayDispatchQueue<T>>::append(id, upward_messages);
+		}
+	}
+
+	/// Simple round-robin dispatcher, using block number modulo parachain count
+	/// to decide which takes precedence and proceeding from there.
+	fn dispatch_upward_messages(
+		now: T::BlockNumber,
+		active_parachains: &[ParaId],
+		max_queue_count: usize,
+		watermark_queue_size: usize,
+		mut dispatch_message: impl FnMut(ParaId, ParachainDispatchOrigin, &[u8]),
+	) {
+		let para_count = active_parachains.len();
+		let offset = (now % T::BlockNumber::from(para_count as u32))
+			.checked_into::<usize>()
+			.expect("value is modulo a usize value; qed");
+
+		let mut dispatched_count = 0usize;
+		let mut dispatched_size = 0usize;
+		for id in active_parachains.iter().cycle().skip(offset).take(para_count) {
+			let (count, size) = <RelayDispatchQueueSize<T>>::get(id);
+			let count = count as usize;
+			let size = size as usize;
+			if dispatched_count == 0 || (
+				dispatched_count + count <= max_queue_count
+					&& dispatched_size + size <= watermark_queue_size
+			) {
+				if count > 0 {
+					// still dispatching messages...
+					<RelayDispatchQueueSize<T>>::remove(id);
+					let messages = <RelayDispatchQueue<T>>::take(id);
+					for UpwardMessage { origin, data } in messages.into_iter() {
+						dispatch_message(*id, origin, &data);
+					}
+					dispatched_count += count;
+					dispatched_size += size;
+					if dispatched_count >= max_queue_count
+						|| dispatched_size >= watermark_queue_size
+					{
+						break
+					}
+				}
+			}
+		}
+	}
+
 	/// Calculate the current block's duty roster using system's random seed.
 	pub fn calculate_duty_roster() -> DutyRoster {
 		let parachains = Self::active_parachains();
@@ -268,7 +427,8 @@ impl<T: Trait> Module<T> {
 			let remaining = (validator_count - i) as usize;
 
 			// 8 32-bit ints per 256-bit seed.
-			let val_index = u32::decode(&mut &seed[offset..offset + 4]).expect("using 4 bytes for a 32-bit quantity") as usize % remaining;
+			let val_index = u32::decode(&mut &seed[offset..offset + 4])
+				.expect("using 4 bytes for a 32-bit quantity") as usize % remaining;
 
 			if offset == 28 {
 				// into the last 4 bytes - rehash to gather new entropy
@@ -507,18 +667,30 @@ impl<T: Trait> ProvideInherent for Module<T> {
 #[cfg(test)]
 mod tests {
 	use super::*;
+	use super::Call as ParachainsCall;
 	use sr_io::{TestExternalities, with_externalities};
 	use substrate_primitives::{H256, Blake2Hasher};
 	use substrate_trie::NodeCodec;
 	use sr_primitives::{generic, BuildStorage};
 	use sr_primitives::traits::{BlakeTwo256, IdentityLookup};
-	use primitives::{parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorIndex}, SessionKey};
+	use primitives::{
+		parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorIndex}, SessionKey
+	};
 	use keyring::{AuthorityKeyring, AccountKeyring};
-	use srml_support::{impl_outer_origin, assert_ok};
+	use srml_support::{impl_outer_origin, impl_outer_dispatch, assert_ok, assert_err};
 	use {consensus, timestamp};
+	use crate::parachains;
 
 	impl_outer_origin! {
-		pub enum Origin for Test {}
+		pub enum Origin for Test {
+			parachains
+		}
+	}
+
+	impl_outer_dispatch! {
+		pub enum Call for Test where origin: Origin {
+			parachains::Parachains,
+		}
 	}
 
 	#[derive(Clone, Eq, PartialEq)]
@@ -550,7 +722,10 @@ mod tests {
 		type Moment = u64;
 		type OnTimestampSet = ();
 	}
-	impl Trait for Test {}
+	impl Trait for Test {
+		type Origin = Origin;
+		type Call = Call;
+	}
 
 	type Parachains = Module<Test>;
 	type System = system::Module<Test>;
@@ -588,12 +763,16 @@ mod tests {
 			keys: vec![],
 		}.build_storage().unwrap().0);
 		t.extend(GenesisConfig::<Test>{
-			parachains: parachains,
+			parachains,
 			_phdata: Default::default(),
 		}.build_storage().unwrap().0);
 		t.into()
 	}
 
+	fn set_heads(v: Vec<AttestedCandidate>) -> ParachainsCall<Test> {
+		ParachainsCall::set_heads(v)
+	}
+
 	fn make_attestations(candidate: &mut AttestedCandidate) {
 		let mut vote_implicit = false;
 		let parent_hash = crate::System::parent_hash();
@@ -640,14 +819,300 @@ mod tests {
 				collator: Default::default(),
 				signature: Default::default(),
 				head_data: HeadData(vec![1, 2, 3]),
-				balance_uploads: vec![],
 				egress_queue_roots,
 				fees: 0,
 				block_data_hash: Default::default(),
+				upward_messages: vec![],
 			}
 		}
 	}
 
+	fn new_candidate_with_upward_messages(
+		id: u32,
+		upward_messages: Vec<(ParachainDispatchOrigin, Vec<u8>)>
+	) -> AttestedCandidate {
+		AttestedCandidate {
+			validity_votes: vec![],
+			candidate: CandidateReceipt {
+				parachain_index: id.into(),
+				collator: Default::default(),
+				signature: Default::default(),
+				head_data: HeadData(vec![1, 2, 3]),
+				egress_queue_roots: vec![],
+				fees: 0,
+				block_data_hash: Default::default(),
+				upward_messages: upward_messages.into_iter()
+					.map(|x| UpwardMessage { origin: x.0, data: x.1 })
+					.collect(),
+			}
+		}
+	}
+
+	#[test]
+	fn check_dispatch_upward_works() {
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+			(1u32.into(), vec![], vec![]),
+			(2u32.into(), vec![], vec![]),
+		];
+		with_externalities(&mut new_test_ext(parachains.clone()), || {
+			let parachains = vec![0.into(), 1.into(), 2.into()];
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 4] }
+			]);
+			Parachains::queue_upward_messages(1.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1; 4] }
+			]);
+			let mut dispatched: Vec<(ParaId, ParachainDispatchOrigin, Vec<u8>)> = vec![];
+			let dummy = |id, origin, data: &[u8]| dispatched.push((id, origin, data.to_vec()));
+			Parachains::dispatch_upward_messages(0, &parachains, 2, 3, dummy);
+			assert_eq!(dispatched, vec![
+				(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 4])
+			]);
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
+			assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
+		});
+		with_externalities(&mut new_test_ext(parachains.clone()), || {
+			let parachains = vec![0.into(), 1.into(), 2.into()];
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
+			]);
+			Parachains::queue_upward_messages(1.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1; 2] }
+			]);
+			Parachains::queue_upward_messages(2.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![2] }
+			]);
+			let mut dispatched: Vec<(ParaId, ParachainDispatchOrigin, Vec<u8>)> = vec![];
+			let dummy = |id, origin, data: &[u8]| dispatched.push((id, origin, data.to_vec()));
+			Parachains::dispatch_upward_messages(0, &parachains, 2, 3, dummy);
+			assert_eq!(dispatched, vec![
+				(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 2]),
+				(2.into(), ParachainDispatchOrigin::Parachain, vec![2])
+			]);
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
+			assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
+		});
+		with_externalities(&mut new_test_ext(parachains.clone()), || {
+			let parachains = vec![0.into(), 1.into(), 2.into()];
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
+			]);
+			Parachains::queue_upward_messages(1.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1; 2] }
+			]);
+			Parachains::queue_upward_messages(2.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![2] }
+			]);
+			let mut dispatched: Vec<(ParaId, ParachainDispatchOrigin, Vec<u8>)> = vec![];
+			let dummy = |id, origin, data: &[u8]| dispatched.push((id, origin, data.to_vec()));
+			Parachains::dispatch_upward_messages(1, &parachains, 2, 3, dummy);
+			assert_eq!(dispatched, vec![
+				(1.into(), ParachainDispatchOrigin::Parachain, vec![1; 2]),
+				(2.into(), ParachainDispatchOrigin::Parachain, vec![2])
+			]);
+			assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).len(), 1);
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).is_empty());
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
+		});
+		with_externalities(&mut new_test_ext(parachains.clone()), || {
+			let parachains = vec![0.into(), 1.into(), 2.into()];
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![0; 2] }
+			]);
+			Parachains::queue_upward_messages(1.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1; 2] }
+			]);
+			Parachains::queue_upward_messages(2.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![2] }
+			]);
+			let mut dispatched: Vec<(ParaId, ParachainDispatchOrigin, Vec<u8>)> = vec![];
+			let dummy = |id, origin, data: &[u8]| dispatched.push((id, origin, data.to_vec()));
+			Parachains::dispatch_upward_messages(2, &parachains, 2, 3, dummy);
+			assert_eq!(dispatched, vec![
+				(2.into(), ParachainDispatchOrigin::Parachain, vec![2]),
+				(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 2])
+			]);
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
+			assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
+		});
+	}
+
+	#[test]
+	fn check_queue_upward_messages_works() {
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+		];
+		with_externalities(&mut new_test_ext(parachains), || {
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] }
+			];
+			assert_ok!(Parachains::check_upward_messages(0.into(), &messages, 2, 3));
+
+			// all good.
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
+			]);
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1, 2] }
+			];
+			assert_ok!(Parachains::check_upward_messages(0.into(), &messages, 2, 3));
+			Parachains::queue_upward_messages(0.into(), &messages);
+			assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)), vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
+				UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1, 2] },
+			]);
+		});
+	}
+
+	#[test]
+	fn check_queue_full_upward_messages_fails() {
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+		];
+		with_externalities(&mut new_test_ext(parachains), || {
+			// oversize, but ok since it's just one and the queue is empty.
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0; 4] },
+			];
+			assert_ok!(Parachains::check_upward_messages(0.into(), &messages, 2, 3));
+
+			// oversize and bad since it's not just one.
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0; 4] },
+			];
+			assert_err!(
+				Parachains::check_upward_messages(0.into(), &messages, 2, 3),
+				"Messages added when queue full"
+			);
+
+			// too many messages.
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![1] },
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![2] },
+			];
+			assert_err!(
+				Parachains::check_upward_messages(0.into(), &messages, 2, 3),
+				"Messages added when queue full"
+			);
+		});
+	}
+
+	#[test]
+	fn check_queued_too_many_upward_messages_fails() {
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+		];
+		with_externalities(&mut new_test_ext(parachains), || {
+			// too many messages.
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
+			]);
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![1] },
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![2] },
+			];
+			assert_err!(
+				Parachains::check_upward_messages(0.into(), &messages, 2, 3),
+				"Messages added when queue full"
+			);
+		});
+	}
+
+	#[test]
+	fn check_queued_total_oversize_upward_messages_fails() {
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+		];
+		with_externalities(&mut new_test_ext(parachains), || {
+			// too much data.
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0, 1] },
+			]);
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![2, 3] },
+			];
+			assert_err!(
+				Parachains::check_upward_messages(0.into(), &messages, 2, 3),
+				"Messages added when queue full"
+			);
+		});
+	}
+
+	#[test]
+	fn check_queued_pre_jumbo_upward_messages_fails() {
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+		];
+		with_externalities(&mut new_test_ext(parachains), || {
+			// bad - already an oversize messages queued.
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0; 4] },
+			]);
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] }
+			];
+			assert_err!(
+				Parachains::check_upward_messages(0.into(), &messages, 2, 3),
+				"Messages added when queue full"
+			);
+		});
+	}
+
+	#[test]
+	fn check_queued_post_jumbo_upward_messages_fails() {
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+		];
+		with_externalities(&mut new_test_ext(parachains), || {
+			// bad - oversized and already a message queued.
+			Parachains::queue_upward_messages(0.into(), &vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
+			]);
+			let messages = vec![
+				UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0; 4] }
+			];
+			assert_err!(
+				Parachains::check_upward_messages(0.into(), &messages, 2, 3),
+				"Messages added when queue full"
+			);
+		});
+	}
+
+	#[test]
+	fn upward_queuing_works() {
+		// That the list of egress queue roots is in ascending order by `ParaId`.
+		let parachains = vec![
+			(0u32.into(), vec![], vec![]),
+			(1u32.into(), vec![], vec![]),
+		];
+
+		with_externalities(&mut new_test_ext(parachains), || {
+			// parachain 0 is self
+			let mut candidates = vec![
+				new_candidate_with_upward_messages(0, vec![
+					(ParachainDispatchOrigin::Signed, vec![1]),
+				]),
+				new_candidate_with_upward_messages(1, vec![
+					(ParachainDispatchOrigin::Parachain, vec![2]),
+				])
+			];
+			candidates.iter_mut().for_each(make_attestations);
+
+			assert_ok!(Parachains::dispatch(
+				set_heads(candidates),
+				Origin::NONE,
+			));
+
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
+			assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).is_empty());
+		});
+	}
+
 	#[test]
 	fn active_parachains_should_work() {
 		let parachains = vec![
@@ -706,13 +1171,13 @@ mod tests {
 			let duty_roster_0 = Parachains::calculate_duty_roster();
 			check_roster(&duty_roster_0);
 
-			System::initialize(&1, &H256::from([1; 32]), &Default::default());
+			System::initialize(&1, &H256::from([1; 32]), &Default::default(), &Default::default());
 			let duty_roster_1 = Parachains::calculate_duty_roster();
 			check_roster(&duty_roster_1);
 			assert!(duty_roster_0 != duty_roster_1);
 
 
-			System::initialize(&2, &H256::from([2; 32]), &Default::default());
+			System::initialize(&2, &H256::from([2; 32]), &Default::default(), &Default::default());
 			let duty_roster_2 = Parachains::calculate_duty_roster();
 			check_roster(&duty_roster_2);
 			assert!(duty_roster_0 != duty_roster_2);
@@ -735,15 +1200,15 @@ mod tests {
 					collator: Default::default(),
 					signature: Default::default(),
 					head_data: HeadData(vec![1, 2, 3]),
-					balance_uploads: vec![],
 					egress_queue_roots: vec![],
 					fees: 0,
 					block_data_hash: Default::default(),
+					upward_messages: vec![],
 				},
 
 			};
 
-			assert!(Parachains::dispatch(Call::set_heads(vec![candidate]), Origin::NONE).is_err());
+			assert!(Parachains::dispatch(set_heads(vec![candidate]), Origin::NONE).is_err());
 		})
 	}
 
@@ -762,10 +1227,10 @@ mod tests {
 					collator: Default::default(),
 					signature: Default::default(),
 					head_data: HeadData(vec![1, 2, 3]),
-					balance_uploads: vec![],
 					egress_queue_roots: vec![],
 					fees: 0,
 					block_data_hash: Default::default(),
+					upward_messages: vec![],
 				}
 			};
 
@@ -776,10 +1241,10 @@ mod tests {
 					collator: Default::default(),
 					signature: Default::default(),
 					head_data: HeadData(vec![2, 3, 4]),
-					balance_uploads: vec![],
 					egress_queue_roots: vec![],
 					fees: 0,
 					block_data_hash: Default::default(),
+					upward_messages: vec![],
 				}
 			};
 
@@ -787,12 +1252,12 @@ mod tests {
 			make_attestations(&mut candidate_b);
 
 			assert!(Parachains::dispatch(
-				Call::set_heads(vec![candidate_b.clone(), candidate_a.clone()]),
+				set_heads(vec![candidate_b.clone(), candidate_a.clone()]),
 				Origin::NONE,
 			).is_err());
 
 			assert!(Parachains::dispatch(
-				Call::set_heads(vec![candidate_a.clone(), candidate_b.clone()]),
+				set_heads(vec![candidate_a.clone(), candidate_b.clone()]),
 				Origin::NONE,
 			).is_ok());
 		});
@@ -813,10 +1278,10 @@ mod tests {
 					collator: Default::default(),
 					signature: Default::default(),
 					head_data: HeadData(vec![1, 2, 3]),
-					balance_uploads: vec![],
 					egress_queue_roots: vec![],
 					fees: 0,
 					block_data_hash: Default::default(),
+					upward_messages: vec![],
 				}
 			};
 
@@ -826,7 +1291,7 @@ mod tests {
 			double_validity.validity_votes.push(candidate.validity_votes[0].clone());
 
 			assert!(Parachains::dispatch(
-				Call::set_heads(vec![double_validity]),
+				set_heads(vec![double_validity]),
 				Origin::NONE,
 			).is_err());
 		});
@@ -849,10 +1314,10 @@ mod tests {
 					collator: Default::default(),
 					signature: Default::default(),
 					head_data: HeadData(vec![1, 2, 3]),
-					balance_uploads: vec![],
 					egress_queue_roots: from_a.clone(),
 					fees: 0,
 					block_data_hash: Default::default(),
+					upward_messages: vec![],
 				}
 			};
 
@@ -864,10 +1329,10 @@ mod tests {
 					collator: Default::default(),
 					signature: Default::default(),
 					head_data: HeadData(vec![1, 2, 3]),
-					balance_uploads: vec![],
 					egress_queue_roots: from_b.clone(),
 					fees: 0,
 					block_data_hash: Default::default(),
+					upward_messages: vec![],
 				}
 			};
 
@@ -878,7 +1343,7 @@ mod tests {
 			assert_eq!(Parachains::ingress(ParaId::from(99)), Some(Vec::new()));
 
 			assert!(Parachains::dispatch(
-				Call::set_heads(vec![candidate_a, candidate_b]),
+				set_heads(vec![candidate_a, candidate_b]),
 				Origin::NONE,
 			).is_ok());
 
@@ -917,7 +1382,7 @@ mod tests {
 			make_attestations(&mut candidate);
 
 			let result = Parachains::dispatch(
-				Call::set_heads(vec![candidate.clone()]),
+				set_heads(vec![candidate.clone()]),
 				Origin::NONE,
 			);
 
@@ -941,7 +1406,7 @@ mod tests {
 			make_attestations(&mut candidate);
 
 			let result = Parachains::dispatch(
-				Call::set_heads(vec![candidate.clone()]),
+				set_heads(vec![candidate.clone()]),
 				Origin::NONE,
 			);
 
@@ -965,7 +1430,7 @@ mod tests {
 			make_attestations(&mut candidate);
 
 			let result = Parachains::dispatch(
-				Call::set_heads(vec![candidate.clone()]),
+				set_heads(vec![candidate.clone()]),
 				Origin::NONE,
 			);
 
@@ -989,7 +1454,7 @@ mod tests {
 			make_attestations(&mut candidate);
 
 			let result = Parachains::dispatch(
-				Call::set_heads(vec![candidate.clone()]),
+				set_heads(vec![candidate.clone()]),
 				Origin::NONE,
 			);
 
diff --git a/polkadot/runtime/wasm/Cargo.lock b/polkadot/runtime/wasm/Cargo.lock
index 251c02b15f9..ac8e513a79a 100644
--- a/polkadot/runtime/wasm/Cargo.lock
+++ b/polkadot/runtime/wasm/Cargo.lock
@@ -814,6 +814,14 @@ dependencies = [
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "impl-serde"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "integer-sqrt"
 version = "0.1.2"
@@ -1717,13 +1725,13 @@ dependencies = [
 
 [[package]]
 name = "primitive-types"
-version = "0.2.1"
+version = "0.2.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2221,7 +2229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 [[package]]
 name = "sr-api-macros"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2233,7 +2241,7 @@ dependencies = [
 [[package]]
 name = "sr-io"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2250,7 +2258,7 @@ dependencies = [
 [[package]]
 name = "sr-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2265,7 +2273,7 @@ dependencies = [
 [[package]]
 name = "sr-std"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -2273,7 +2281,7 @@ dependencies = [
 [[package]]
 name = "sr-version"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2285,7 +2293,7 @@ dependencies = [
 [[package]]
 name = "srml-aura"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2301,7 +2309,7 @@ dependencies = [
 [[package]]
 name = "srml-balances"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2316,7 +2324,7 @@ dependencies = [
 [[package]]
 name = "srml-consensus"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2331,7 +2339,7 @@ dependencies = [
 [[package]]
 name = "srml-council"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2348,7 +2356,7 @@ dependencies = [
 [[package]]
 name = "srml-democracy"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2363,7 +2371,7 @@ dependencies = [
 [[package]]
 name = "srml-executive"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2377,7 +2385,7 @@ dependencies = [
 [[package]]
 name = "srml-finality-tracker"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2391,7 +2399,7 @@ dependencies = [
 [[package]]
 name = "srml-grandpa"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2409,7 +2417,7 @@ dependencies = [
 [[package]]
 name = "srml-indices"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2426,7 +2434,7 @@ dependencies = [
 [[package]]
 name = "srml-metadata"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2437,7 +2445,7 @@ dependencies = [
 [[package]]
 name = "srml-session"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2453,7 +2461,7 @@ dependencies = [
 [[package]]
 name = "srml-staking"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2471,7 +2479,7 @@ dependencies = [
 [[package]]
 name = "srml-sudo"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2486,7 +2494,7 @@ dependencies = [
 [[package]]
 name = "srml-support"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2504,7 +2512,7 @@ dependencies = [
 [[package]]
 name = "srml-support-procedural"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2516,7 +2524,7 @@ dependencies = [
 [[package]]
 name = "srml-support-procedural-tools"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2528,7 +2536,7 @@ dependencies = [
 [[package]]
 name = "srml-support-procedural-tools-derive"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
  "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2538,7 +2546,7 @@ dependencies = [
 [[package]]
 name = "srml-system"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2553,7 +2561,7 @@ dependencies = [
 [[package]]
 name = "srml-timestamp"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2567,7 +2575,7 @@ dependencies = [
 [[package]]
 name = "srml-treasury"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2631,7 +2639,7 @@ dependencies = [
 [[package]]
 name = "substrate-client"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2659,7 +2667,7 @@ dependencies = [
 [[package]]
 name = "substrate-consensus-aura-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2668,7 +2676,7 @@ dependencies = [
 [[package]]
 name = "substrate-consensus-authorities"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-io 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2683,14 +2691,15 @@ dependencies = [
 [[package]]
 name = "substrate-consensus-common"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
  "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "sr-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "sr-version 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2702,10 +2711,10 @@ dependencies = [
 [[package]]
 name = "substrate-executor"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2725,7 +2734,7 @@ dependencies = [
 [[package]]
 name = "substrate-finality-grandpa-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2737,7 +2746,7 @@ dependencies = [
 [[package]]
 name = "substrate-inherents"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2748,7 +2757,7 @@ dependencies = [
 [[package]]
 name = "substrate-keyring"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2760,7 +2769,7 @@ dependencies = [
 [[package]]
 name = "substrate-offchain-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "sr-primitives 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
  "substrate-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2769,7 +2778,7 @@ dependencies = [
 [[package]]
 name = "substrate-panic-handler"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2778,7 +2787,7 @@ dependencies = [
 [[package]]
 name = "substrate-primitives"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2788,8 +2797,9 @@ dependencies = [
  "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2806,7 +2816,7 @@ dependencies = [
 [[package]]
 name = "substrate-serializer"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2815,10 +2825,11 @@ dependencies = [
 [[package]]
 name = "substrate-state-machine"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "substrate-panic-handler 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
@@ -2831,7 +2842,7 @@ dependencies = [
 [[package]]
 name = "substrate-telemetry"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2849,7 +2860,7 @@ dependencies = [
 [[package]]
 name = "substrate-trie"
 version = "2.0.0"
-source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#6d38263434aba843585c7dc8744fc89703be90b5"
+source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#31fe3c7fd56ef03cf6c97cbffc768bc7094c844e"
 dependencies = [
  "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3213,7 +3224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "uint"
-version = "0.6.1"
+version = "0.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3613,6 +3624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
 "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b"
 "checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56"
+"checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1"
 "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903"
 "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
 "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
@@ -3688,7 +3700,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9"
 "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
 "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
-"checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e"
+"checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f"
 "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c"
 "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8"
 "checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66"
@@ -3827,7 +3839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c"
 "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
 "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
-"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708"
+"checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4"
 "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
 "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426"
 "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
diff --git a/polkadot/validation/src/collation.rs b/polkadot/validation/src/collation.rs
index 5e09de0ef54..cf244abe842 100644
--- a/polkadot/validation/src/collation.rs
+++ b/polkadot/validation/src/collation.rs
@@ -21,13 +21,12 @@
 
 use std::sync::Arc;
 
-use polkadot_primitives::{Block, Hash, BlockId, parachain::CollatorId};
-use polkadot_primitives::parachain::{Id as ParaId, Collation, Extrinsic, OutgoingMessage};
-use polkadot_primitives::parachain::{
+use polkadot_primitives::{Block, Hash, BlockId, parachain::CollatorId, parachain::{
 	ConsolidatedIngress, ConsolidatedIngressRoots, CandidateReceipt, ParachainHost,
-};
+	Id as ParaId, Collation, Extrinsic, OutgoingMessage, UpwardMessage
+}};
 use runtime_primitives::traits::ProvideRuntimeApi;
-use parachain::{wasm_executor::{self, ExternalitiesError}, MessageRef};
+use parachain::{wasm_executor::{self, ExternalitiesError}, MessageRef, UpwardMessageRef};
 use error_chain::bail;
 
 use futures::prelude::*;
@@ -190,6 +189,10 @@ error_chain! {
 			description("Block data is too big."),
 			display("Block data is too big (maximum allowed size: {}, actual size: {})", max_size, size),
 		}
+		UpwardMessagesInvalid(expected: Vec<UpwardMessage>, got: Vec<UpwardMessage>) {
+			description("Parachain validation produced wrong relay-chain messages."),
+			display("Parachain validation produced wrong relay-chain messages (expected: {:?}, got {:?})", expected, got),
+		}
 	}
 }
 
@@ -275,6 +278,7 @@ fn check_extrinsic(
 struct Externalities {
 	parachain_index: ParaId,
 	outgoing: Vec<OutgoingMessage>,
+	upward: Vec<UpwardMessage>,
 }
 
 impl wasm_executor::Externalities for Externalities {
@@ -293,14 +297,35 @@ impl wasm_executor::Externalities for Externalities {
 
 		Ok(())
 	}
+
+	fn post_upward_message(&mut self, message: UpwardMessageRef)
+		-> Result<(), ExternalitiesError>
+	{
+		// TODO: https://github.com/paritytech/polkadot/issues/92
+		// check per-message and per-byte fees for the parachain.
+		self.upward.push(UpwardMessage {
+			origin: message.origin,
+			data: message.data.to_vec(),
+		});
+		Ok(())
+	}
 }
 
+
+
 impl Externalities {
 	// Performs final checks of validity, producing the extrinsic data.
 	fn final_checks(
 		self,
 		candidate: &CandidateReceipt,
 	) -> Result<Extrinsic, Error> {
+		if &self.upward != &candidate.upward_messages {
+			bail!(ErrorKind::UpwardMessagesInvalid(
+				candidate.upward_messages.clone(),
+				self.upward.clone(),
+			));
+		}
+
 		check_extrinsic(
 			self.outgoing,
 			&candidate.egress_queue_roots[..],
@@ -382,6 +407,7 @@ pub fn validate_collation<P>(
 	let mut ext = Externalities {
 		parachain_index: collation.receipt.parachain_index.clone(),
 		outgoing: Vec::new(),
+		upward: Vec::new(),
 	};
 
 	match wasm_executor::validate_candidate(&validation_code, params, &mut ext) {
@@ -403,6 +429,8 @@ pub fn validate_collation<P>(
 mod tests {
 	use super::*;
 	use parachain::wasm_executor::Externalities as ExternalitiesTrait;
+	use parachain::ParachainDispatchOrigin;
+	use polkadot_primitives::parachain::{Statement::Candidate, CandidateReceipt, HeadData};
 
 	#[test]
 	fn compute_and_check_egress() {
@@ -453,9 +481,74 @@ mod tests {
 		let mut ext = Externalities {
 			parachain_index: 5.into(),
 			outgoing: Vec::new(),
+			upward: Vec::new(),
 		};
 
 		assert!(ext.post_message(MessageRef { target: 1.into(), data: &[] }).is_ok());
 		assert!(ext.post_message(MessageRef { target: 5.into(), data: &[] }).is_err());
 	}
+
+	#[test]
+	fn ext_checks_upward_messages() {
+		let ext = || Externalities {
+			parachain_index: 5.into(),
+			outgoing: Vec::new(),
+			upward: vec![
+				UpwardMessage{ data: vec![42], origin: ParachainDispatchOrigin::Parachain },
+			],
+		};
+		let receipt = CandidateReceipt {
+			parachain_index: 5.into(),
+			collator: Default::default(),
+			signature: Default::default(),
+			head_data: HeadData(Vec::new()),
+			egress_queue_roots: Vec::new(),
+			fees: 0,
+			block_data_hash: Default::default(),
+			upward_messages: vec![
+				UpwardMessage{ data: vec![42], origin: ParachainDispatchOrigin::Signed },
+				UpwardMessage{ data: vec![69], origin: ParachainDispatchOrigin::Parachain },
+			],
+		};
+		assert!(ext().final_checks(&receipt).is_err());
+		let receipt = CandidateReceipt {
+			parachain_index: 5.into(),
+			collator: Default::default(),
+			signature: Default::default(),
+			head_data: HeadData(Vec::new()),
+			egress_queue_roots: Vec::new(),
+			fees: 0,
+			block_data_hash: Default::default(),
+			upward_messages: vec![
+				UpwardMessage{ data: vec![42], origin: ParachainDispatchOrigin::Signed },
+			],
+		};
+		assert!(ext().final_checks(&receipt).is_err());
+		let receipt = CandidateReceipt {
+			parachain_index: 5.into(),
+			collator: Default::default(),
+			signature: Default::default(),
+			head_data: HeadData(Vec::new()),
+			egress_queue_roots: Vec::new(),
+			fees: 0,
+			block_data_hash: Default::default(),
+			upward_messages: vec![
+				UpwardMessage{ data: vec![69], origin: ParachainDispatchOrigin::Parachain },
+			],
+		};
+		assert!(ext().final_checks(&receipt).is_err());
+		let receipt = CandidateReceipt {
+			parachain_index: 5.into(),
+			collator: Default::default(),
+			signature: Default::default(),
+			head_data: HeadData(Vec::new()),
+			egress_queue_roots: Vec::new(),
+			fees: 0,
+			block_data_hash: Default::default(),
+			upward_messages: vec![
+				UpwardMessage{ data: vec![42], origin: ParachainDispatchOrigin::Parachain },
+			],
+		};
+		assert!(ext().final_checks(&receipt).is_ok());
+	}
 }
diff --git a/polkadot/validation/src/lib.rs b/polkadot/validation/src/lib.rs
index 46ef184ad59..414e07c1cc3 100644
--- a/polkadot/validation/src/lib.rs
+++ b/polkadot/validation/src/lib.rs
@@ -48,7 +48,7 @@ use polkadot_primitives::parachain::{
 	Collation, PoVBlock,
 };
 use primitives::{Pair, ed25519};
-use runtime_primitives::{traits::{ProvideRuntimeApi, Header as HeaderT}, ApplyError};
+use runtime_primitives::{traits::{ProvideRuntimeApi, Header as HeaderT, Block as BlockT}, ApplyError};
 use tokio::runtime::TaskExecutor;
 use tokio::timer::{Delay, Interval};
 use transaction_pool::txpool::{Pool, ChainApi as PoolChainApi};
@@ -570,7 +570,11 @@ impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
 	type Error = Error;
 	type Create = Either<CreateProposal<C, TxApi>, future::FutureResult<Block, Error>>;
 
-	fn propose(&self, inherent_data: InherentData, max_duration: Duration) -> Self::Create {
+	fn propose(&self,
+		inherent_data: InherentData,
+		_digest: <<Block as BlockT>::Header as HeaderT>::Digest,
+		max_duration: Duration,
+	) -> Self::Create {
 		const ATTEMPT_PROPOSE_EVERY: Duration = Duration::from_millis(100);
 		const SLOT_DURATION_DENOMINATOR: u64 = 3; // wait up to 1/3 of the slot for candidates.
 
@@ -712,7 +716,7 @@ impl<C, TxApi> CreateProposal<C, TxApi> where
 
 		let runtime_api = self.client.runtime_api();
 
-		let mut block_builder = BlockBuilder::at_block(&self.parent_id, &*self.client, false)?;
+		let mut block_builder = BlockBuilder::at_block(&self.parent_id, &*self.client, false, Default::default())?;
 
 		{
 			let inherents = runtime_api.inherent_extrinsics(&self.parent_id, inherent_data)?;
diff --git a/polkadot/validation/src/shared_table/mod.rs b/polkadot/validation/src/shared_table/mod.rs
index fdba93dc2c8..42284e552d1 100644
--- a/polkadot/validation/src/shared_table/mod.rs
+++ b/polkadot/validation/src/shared_table/mod.rs
@@ -630,10 +630,10 @@ mod tests {
 			collator: [1; 32].unchecked_into(),
 			signature: Default::default(),
 			head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
-			balance_uploads: Vec::new(),
 			egress_queue_roots: Vec::new(),
 			fees: 1_000_000,
 			block_data_hash: [2; 32].into(),
+			upward_messages: Vec::new(),
 		};
 
 		let candidate_statement = GenericStatement::Candidate(candidate);
@@ -684,10 +684,10 @@ mod tests {
 			collator: [1; 32].unchecked_into(),
 			signature: Default::default(),
 			head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
-			balance_uploads: Vec::new(),
 			egress_queue_roots: Vec::new(),
 			fees: 1_000_000,
 			block_data_hash: [2; 32].into(),
+			upward_messages: Vec::new(),
 		};
 
 		let candidate_statement = GenericStatement::Candidate(candidate);
@@ -717,10 +717,10 @@ mod tests {
 			collator: [1; 32].unchecked_into(),
 			signature: Default::default(),
 			head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
-			balance_uploads: Vec::new(),
 			egress_queue_roots: Vec::new(),
 			fees: 1_000_000,
 			block_data_hash: [2; 32].into(),
+			upward_messages: Vec::new(),
 		};
 
 		let hash = candidate.hash();
@@ -758,10 +758,10 @@ mod tests {
 			collator: [1; 32].unchecked_into(),
 			signature: Default::default(),
 			head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
-			balance_uploads: Vec::new(),
 			egress_queue_roots: Vec::new(),
 			fees: 1_000_000,
 			block_data_hash: [2; 32].into(),
+			upward_messages: Vec::new(),
 		};
 
 		let hash = candidate.hash();
@@ -819,10 +819,10 @@ mod tests {
 			collator: [1; 32].unchecked_into(),
 			signature: Default::default(),
 			head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
-			balance_uploads: Vec::new(),
 			egress_queue_roots: Vec::new(),
 			fees: 1_000_000,
 			block_data_hash: [2; 32].into(),
+			upward_messages: Vec::new(),
 		};
 
 		let hash = candidate.hash();
@@ -884,10 +884,10 @@ mod tests {
 			collator: [1; 32].unchecked_into(),
 			signature: Default::default(),
 			head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
-			balance_uploads: Vec::new(),
 			egress_queue_roots: Vec::new(),
 			fees: 1_000_000,
 			block_data_hash: [2; 32].into(),
+			upward_messages: Vec::new(),
 		};
 
 		let hash = candidate.hash();
-- 
GitLab