diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock
index 0f3e68a844e30479c628de3b3c024ef6383a6c10..0da8f25b22426b98cb4596083cff78e3ea0123b7 100644
--- a/substrate/Cargo.lock
+++ b/substrate/Cargo.lock
@@ -2620,9 +2620,9 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-client-transports"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6f7b1cdf66312002e15682a24430728bd13036c641163c016bc53fb686a7c2d"
+checksum = "489b9c612e60c766f751ab40fcb43cbb55a1e10bb44a9b4307ed510ca598cbd7"
 dependencies = [
  "failure",
  "futures 0.1.29",
@@ -2637,9 +2637,9 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-core"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f30b12567a31d48588a65b6cf870081e6ba1d7b2ae353977cb9820d512e69c70"
+checksum = "0745a6379e3edc893c84ec203589790774e4247420033e71a76d3ab4687991fa"
 dependencies = [
  "futures 0.1.29",
  "log",
@@ -2650,18 +2650,18 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-core-client"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d175ca0cf77439b5495612bf216c650807d252d665b4b70ab2eebd895a88fac1"
+checksum = "6f764902d7b891344a0acb65625f32f6f7c6db006952143bd650209fbe7d94db"
 dependencies = [
  "jsonrpc-client-transports",
 ]
 
 [[package]]
 name = "jsonrpc-derive"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c2cc6ea7f785232d9ca8786a44e9fa698f92149dcdc1acc4aa1fc69c4993d79e"
+checksum = "99a847f9ec7bb52149b2786a17c9cb260d6effc6b8eeb8c16b343a487a7563a3"
 dependencies = [
  "proc-macro-crate",
  "proc-macro2",
@@ -2671,9 +2671,9 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-http-server"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9996b26c0c7a59626d0ed6c5ec8bf06218e62ce1474bd2849f9b9fd38a0158c0"
+checksum = "4fb5c4513b7b542f42da107942b7b759f27120b5cc894729f88254b28dff44b7"
 dependencies = [
  "hyper 0.12.35",
  "jsonrpc-core",
@@ -2686,9 +2686,9 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-ipc-server"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b8e8f2278fb2b277175b6e21b23e7ecf30e78daff5ee301d0a2a411d9a821a0a"
+checksum = "cf50e53e4eea8f421a7316c5f63e395f7bc7c4e786a6dc54d76fab6ff7aa7ce7"
 dependencies = [
  "jsonrpc-core",
  "jsonrpc-server-utils",
@@ -2700,9 +2700,9 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-pubsub"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f389c5cd1f3db258a99296892c21047e21ae73ff4c0e2d39650ea86fe994b4c7"
+checksum = "639558e0604013be9787ae52f798506ae42bf4220fe587bdc5625871cc8b9c77"
 dependencies = [
  "jsonrpc-core",
  "log",
@@ -2713,9 +2713,9 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-server-utils"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c623e1895d0d9110cb0ea7736cfff13191ff52335ad33b21bd5c775ea98b27af"
+checksum = "72f1f3990650c033bd8f6bd46deac76d990f9bbfb5f8dc8c4767bf0a00392176"
 dependencies = [
  "bytes 0.4.12",
  "globset",
@@ -2729,9 +2729,9 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-ws-server"
-version = "15.0.0"
+version = "15.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "436a92034d0137ab3e3c64a7a6350b428f31cb4d7d1a89f284bcdbcd98a7bc56"
+checksum = "6596fe75209b73a2a75ebe1dce4e60e03b88a2b25e8807b667597f6315150d22"
 dependencies = [
  "jsonrpc-core",
  "jsonrpc-server-utils",
@@ -3981,7 +3981,6 @@ dependencies = [
  "frame-system-benchmarking",
  "frame-system-rpc-runtime-api",
  "hex-literal",
- "integer-sqrt",
  "node-primitives",
  "pallet-authority-discovery",
  "pallet-authorship",
@@ -6797,6 +6796,7 @@ dependencies = [
  "jsonrpc-core-client",
  "jsonrpc-derive",
  "log",
+ "parity-scale-codec",
  "parking_lot 0.10.2",
  "sc-basic-authorship",
  "sc-client-api",
@@ -6810,6 +6810,7 @@ dependencies = [
  "sp-consensus-babe",
  "sp-core",
  "sp-inherents",
+ "sp-keyring",
  "sp-keystore",
  "sp-runtime",
  "sp-timestamp",
@@ -9798,7 +9799,7 @@ version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56"
 dependencies = [
- "rand 0.3.23",
+ "rand 0.7.3",
 ]
 
 [[package]]
diff --git a/substrate/bin/node-template/node/Cargo.toml b/substrate/bin/node-template/node/Cargo.toml
index 8b1a47fd2bf15740e36a28692510985b4d7a28e1..d2b5a35b352b25d3b89788cd31727cdae94b5cfc 100644
--- a/substrate/bin/node-template/node/Cargo.toml
+++ b/substrate/bin/node-template/node/Cargo.toml
@@ -35,7 +35,7 @@ sc-client-api = { version = "2.0.0", path = "../../../client/api" }
 sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" }
 
 # These dependencies are used for the node template's RPCs
-jsonrpc-core = "15.0.0"
+jsonrpc-core = "15.1.0"
 sc-rpc = { version = "2.0.0", path = "../../../client/rpc" }
 sp-api = { version = "2.0.0", path = "../../../primitives/api" }
 sc-rpc-api = { version = "0.8.0", path = "../../../client/rpc-api" }
diff --git a/substrate/bin/node/rpc-client/Cargo.toml b/substrate/bin/node/rpc-client/Cargo.toml
index 9f358e901dafa1917c142b4533bbe49436d6537a..26d9de133c6883c8e2404fd6d996985f336e09df 100644
--- a/substrate/bin/node/rpc-client/Cargo.toml
+++ b/substrate/bin/node/rpc-client/Cargo.toml
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
 [dependencies]
 futures = "0.1.29"
 hyper = "0.12.35"
-jsonrpc-core-client = { version = "15.0.0", default-features = false, features = ["http"] }
+jsonrpc-core-client = { version = "15.1.0", default-features = false, features = ["http"] }
 log = "0.4.8"
 node-primitives = { version = "2.0.0", path = "../primitives" }
 sp-tracing = { version = "2.0.0", path = "../../../primitives/tracing" }
diff --git a/substrate/bin/node/rpc/Cargo.toml b/substrate/bin/node/rpc/Cargo.toml
index aef4a82db776a0c8ea9def1bed0f98e2ea52bc0e..10d7fe80d7ce9c5723737f38cc931e0fc55c028f 100644
--- a/substrate/bin/node/rpc/Cargo.toml
+++ b/substrate/bin/node/rpc/Cargo.toml
@@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/substrate/"
 targets = ["x86_64-unknown-linux-gnu"]
 
 [dependencies]
-jsonrpc-core = "15.0.0"
+jsonrpc-core = "15.1.0"
 node-primitives = { version = "2.0.0", path = "../primitives" }
 node-runtime = { version = "2.0.0", path = "../runtime" }
 pallet-contracts-rpc = { version = "0.8.0", path = "../../../frame/contracts/rpc/" }
diff --git a/substrate/bin/node/runtime/Cargo.toml b/substrate/bin/node/runtime/Cargo.toml
index 80c914ff575806c4c11abad01690a58cc7bb7985..2bad2db510be4fae67b1c3bcaff5eb4803a9258b 100644
--- a/substrate/bin/node/runtime/Cargo.toml
+++ b/substrate/bin/node/runtime/Cargo.toml
@@ -15,7 +15,6 @@ targets = ["x86_64-unknown-linux-gnu"]
 
 # third-party dependencies
 codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
-integer-sqrt = { version = "0.1.2" }
 serde = { version = "1.0.102", optional = true }
 static_assertions = "1.1.0"
 hex-literal = { version = "0.3.1", optional = true }
diff --git a/substrate/client/api/src/execution_extensions.rs b/substrate/client/api/src/execution_extensions.rs
index 4fdd897b215797c2eae07ca503c0df6e063e7942..c187e7580023570d91e57fa64472ac2514a4e665 100644
--- a/substrate/client/api/src/execution_extensions.rs
+++ b/substrate/client/api/src/execution_extensions.rs
@@ -136,31 +136,9 @@ impl<Block: traits::Block> ExecutionExtensions<Block> {
 		*self.transaction_pool.write() = Some(Arc::downgrade(&pool) as _);
 	}
 
-	/// Create `ExecutionManager` and `Extensions` for given offchain call.
-	///
 	/// Based on the execution context and capabilities it produces
-	/// the right manager and extensions object to support desired set of APIs.
-	pub fn manager_and_extensions<E: std::fmt::Debug, R: codec::Codec>(
-		&self,
-		at: &BlockId<Block>,
-		context: ExecutionContext,
-	) -> (
-		ExecutionManager<DefaultHandler<R, E>>,
-		Extensions,
-	) {
-		let manager = match context {
-			ExecutionContext::BlockConstruction =>
-				self.strategies.block_construction.get_manager(),
-			ExecutionContext::Syncing =>
-				self.strategies.syncing.get_manager(),
-			ExecutionContext::Importing =>
-				self.strategies.importing.get_manager(),
-			ExecutionContext::OffchainCall(Some((_, capabilities))) if capabilities.has_all() =>
-				self.strategies.offchain_worker.get_manager(),
-			ExecutionContext::OffchainCall(_) =>
-				self.strategies.other.get_manager(),
-		};
-
+	/// the extensions object to support desired set of APIs.
+	pub fn extensions(&self, at: &BlockId<Block>, context: ExecutionContext) -> Extensions {
 		let capabilities = context.capabilities();
 
 		let mut extensions = self.extensions_factory.read().extensions_for(capabilities);
@@ -190,7 +168,35 @@ impl<Block: traits::Block> ExecutionExtensions<Block> {
 			);
 		}
 
-		(manager, extensions)
+		extensions
+	}
+
+	/// Create `ExecutionManager` and `Extensions` for given offchain call.
+	///
+	/// Based on the execution context and capabilities it produces
+	/// the right manager and extensions object to support desired set of APIs.
+	pub fn manager_and_extensions<E: std::fmt::Debug, R: codec::Codec>(
+		&self,
+		at: &BlockId<Block>,
+		context: ExecutionContext,
+	) -> (
+		ExecutionManager<DefaultHandler<R, E>>,
+		Extensions,
+	) {
+		let manager = match context {
+			ExecutionContext::BlockConstruction =>
+				self.strategies.block_construction.get_manager(),
+			ExecutionContext::Syncing =>
+				self.strategies.syncing.get_manager(),
+			ExecutionContext::Importing =>
+				self.strategies.importing.get_manager(),
+			ExecutionContext::OffchainCall(Some((_, capabilities))) if capabilities.has_all() =>
+				self.strategies.offchain_worker.get_manager(),
+			ExecutionContext::OffchainCall(_) =>
+				self.strategies.other.get_manager(),
+		};
+
+		(manager, self.extensions(at, context))
 	}
 }
 
diff --git a/substrate/client/consensus/babe/rpc/Cargo.toml b/substrate/client/consensus/babe/rpc/Cargo.toml
index 5b3169e600a98e0730fca62b782fdcac59225da7..8a376e6c95b9a043c6d8884ff959709e3c66ee53 100644
--- a/substrate/client/consensus/babe/rpc/Cargo.toml
+++ b/substrate/client/consensus/babe/rpc/Cargo.toml
@@ -15,9 +15,9 @@ targets = ["x86_64-unknown-linux-gnu"]
 [dependencies]
 sc-consensus-babe = { version = "0.8.0", path = "../" }
 sc-rpc-api = { version = "0.8.0", path = "../../../rpc-api" }
-jsonrpc-core = "15.0.0"
-jsonrpc-core-client = "15.0.0"
-jsonrpc-derive = "15.0.0"
+jsonrpc-core = "15.1.0"
+jsonrpc-core-client = "15.1.0"
+jsonrpc-derive = "15.1.0"
 sp-consensus-babe = { version = "0.8.0", path = "../../../../primitives/consensus/babe" }
 serde = { version = "1.0.104", features=["derive"] }
 sp-blockchain = { version = "2.0.0", path = "../../../../primitives/blockchain" }
diff --git a/substrate/client/consensus/babe/src/lib.rs b/substrate/client/consensus/babe/src/lib.rs
index 4705381c2b918ba12c090a8a3bfbdd4e8c8f0b90..e980e358b848d4b37932b715055752799229f365 100644
--- a/substrate/client/consensus/babe/src/lib.rs
+++ b/substrate/client/consensus/babe/src/lib.rs
@@ -199,58 +199,86 @@ impl Epoch {
 	}
 }
 
+/// Errors encountered by the babe authorship task.
 #[derive(derive_more::Display, Debug)]
-enum Error<B: BlockT> {
+pub enum Error<B: BlockT> {
+	/// Multiple BABE pre-runtime digests
 	#[display(fmt = "Multiple BABE pre-runtime digests, rejecting!")]
 	MultiplePreRuntimeDigests,
+	/// No BABE pre-runtime digest found
 	#[display(fmt = "No BABE pre-runtime digest found")]
 	NoPreRuntimeDigest,
+	/// Multiple BABE epoch change digests
 	#[display(fmt = "Multiple BABE epoch change digests, rejecting!")]
 	MultipleEpochChangeDigests,
+	/// Multiple BABE config change digests
 	#[display(fmt = "Multiple BABE config change digests, rejecting!")]
 	MultipleConfigChangeDigests,
+	/// Could not extract timestamp and slot
 	#[display(fmt = "Could not extract timestamp and slot: {:?}", _0)]
 	Extraction(sp_consensus::Error),
+	/// Could not fetch epoch
 	#[display(fmt = "Could not fetch epoch at {:?}", _0)]
 	FetchEpoch(B::Hash),
+	/// Header rejected: too far in the future
 	#[display(fmt = "Header {:?} rejected: too far in the future", _0)]
 	TooFarInFuture(B::Hash),
+	/// Parent unavailable. Cannot import
 	#[display(fmt = "Parent ({}) of {} unavailable. Cannot import", _0, _1)]
 	ParentUnavailable(B::Hash, B::Hash),
+	/// Slot number must increase
 	#[display(fmt = "Slot number must increase: parent slot: {}, this slot: {}", _0, _1)]
 	SlotNumberMustIncrease(u64, u64),
+	/// Header has a bad seal
 	#[display(fmt = "Header {:?} has a bad seal", _0)]
 	HeaderBadSeal(B::Hash),
+	/// Header is unsealed
 	#[display(fmt = "Header {:?} is unsealed", _0)]
 	HeaderUnsealed(B::Hash),
+	/// Slot author not found
 	#[display(fmt = "Slot author not found")]
 	SlotAuthorNotFound,
+	/// Secondary slot assignments are disabled for the current epoch.
 	#[display(fmt = "Secondary slot assignments are disabled for the current epoch.")]
 	SecondarySlotAssignmentsDisabled,
+	/// Bad signature
 	#[display(fmt = "Bad signature on {:?}", _0)]
 	BadSignature(B::Hash),
+	/// Invalid author: Expected secondary author
 	#[display(fmt = "Invalid author: Expected secondary author: {:?}, got: {:?}.", _0, _1)]
 	InvalidAuthor(AuthorityId, AuthorityId),
+	/// No secondary author expected.
 	#[display(fmt = "No secondary author expected.")]
 	NoSecondaryAuthorExpected,
+	/// VRF verification of block by author failed
 	#[display(fmt = "VRF verification of block by author {:?} failed: threshold {} exceeded", _0, _1)]
 	VRFVerificationOfBlockFailed(AuthorityId, u128),
+	/// VRF verification failed
 	#[display(fmt = "VRF verification failed: {:?}", _0)]
 	VRFVerificationFailed(SignatureError),
+	/// Could not fetch parent header
 	#[display(fmt = "Could not fetch parent header: {:?}", _0)]
 	FetchParentHeader(sp_blockchain::Error),
+	/// Expected epoch change to happen.
 	#[display(fmt = "Expected epoch change to happen at {:?}, s{}", _0, _1)]
 	ExpectedEpochChange(B::Hash, u64),
+	/// Unexpected config change.
 	#[display(fmt = "Unexpected config change")]
 	UnexpectedConfigChange,
+	/// Unexpected epoch change
 	#[display(fmt = "Unexpected epoch change")]
 	UnexpectedEpochChange,
+	/// Parent block has no associated weight
 	#[display(fmt = "Parent block of {} has no associated weight", _0)]
 	ParentBlockNoAssociatedWeight(B::Hash),
 	#[display(fmt = "Checking inherents failed: {}", _0)]
+	/// Check Inherents error
 	CheckInherents(String),
+	/// Client error
 	Client(sp_blockchain::Error),
+	/// Runtime error
 	Runtime(sp_inherents::Error),
+	/// Fork tree error
 	ForkTree(Box<fork_tree::Error<sp_blockchain::Error>>),
 }
 
@@ -669,7 +697,7 @@ impl<B, C, E, I, Error, SO> sc_consensus_slots::SimpleSlotWorker<B> for BabeSlot
 
 /// Extract the BABE pre digest from the given header. Pre-runtime digests are
 /// mandatory, the function will return `Err` if none is found.
-fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<PreDigest, Error<B>>
+pub fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<PreDigest, Error<B>>
 {
 	// genesis block doesn't contain a pre digest so let's generate a
 	// dummy one to not break any invariants in the rest of the code
diff --git a/substrate/client/consensus/manual-seal/Cargo.toml b/substrate/client/consensus/manual-seal/Cargo.toml
index dba8121264f40a04770cd5b7f37f05d2aac75791..d50cb593652691ab378fcd055d8b7cdc423c32c1 100644
--- a/substrate/client/consensus/manual-seal/Cargo.toml
+++ b/substrate/client/consensus/manual-seal/Cargo.toml
@@ -15,11 +15,12 @@ targets = ["x86_64-unknown-linux-gnu"]
 [dependencies]
 derive_more = "0.99.2"
 futures = "0.3.4"
-jsonrpc-core = "15.0.0"
-jsonrpc-core-client = "15.0.0"
-jsonrpc-derive = "15.0.0"
+jsonrpc-core = "15.1.0"
+jsonrpc-core-client = "15.1.0"
+jsonrpc-derive = "15.1.0"
 log = "0.4.8"
 parking_lot = "0.10.0"
+codec = { package = "parity-scale-codec", version = "1.3.1" }
 serde = { version = "1.0", features=["derive"] }
 assert_matches = "1.3.0"
 
@@ -35,6 +36,7 @@ sp-inherents = { path = "../../../primitives/inherents", version = "2.0.0" }
 sp-runtime = {  path = "../../../primitives/runtime", version = "2.0.0" }
 sp-core = {  path = "../../../primitives/core", version = "2.0.0" }
 sp-keystore = {  path = "../../../primitives/keystore", version = "0.8.0" }
+sp-keyring = {  path = "../../../primitives/keyring", version = "2.0.0" }
 sp-api = {  path = "../../../primitives/api", version = "2.0.0" }
 sp-transaction-pool = { path = "../../../primitives/transaction-pool", version = "2.0.0" }
 sp-timestamp = { path = "../../../primitives/timestamp", version = "2.0.0" }
diff --git a/substrate/client/consensus/manual-seal/src/consensus/babe.rs b/substrate/client/consensus/manual-seal/src/consensus/babe.rs
index e51eb42e49e13489a97e23c03cee1ea17c73d726..c2fdf6243c30407504a74b0aba4fd370b9595e3d 100644
--- a/substrate/client/consensus/manual-seal/src/consensus/babe.rs
+++ b/substrate/client/consensus/manual-seal/src/consensus/babe.rs
@@ -20,7 +20,7 @@
 
 use super::ConsensusDataProvider;
 use crate::Error;
-
+use codec::Encode;
 use std::{
 	any::Any,
 	borrow::Cow,
@@ -30,21 +30,24 @@ use std::{
 use sc_client_api::AuxStore;
 use sc_consensus_babe::{
 	Config, Epoch, authorship, CompatibleDigestItem, BabeIntermediate,
-	register_babe_inherent_data_provider, INTERMEDIATE_KEY,
+	register_babe_inherent_data_provider, INTERMEDIATE_KEY, find_pre_digest,
 };
-use sc_consensus_epochs::{SharedEpochChanges, descendent_query};
+use sc_consensus_epochs::{SharedEpochChanges, descendent_query, ViableEpochDescriptor, EpochHeader};
+use sp_keystore::SyncCryptoStorePtr;
 
 use sp_api::{ProvideRuntimeApi, TransactionFor};
 use sp_blockchain::{HeaderBackend, HeaderMetadata};
 use sp_consensus::BlockImportParams;
-use sp_consensus_babe::{BabeApi, inherents::BabeInherentData};
-use sp_keystore::SyncCryptoStorePtr;
+use sp_consensus_babe::{
+	BabeApi, inherents::BabeInherentData, ConsensusLog, BABE_ENGINE_ID, AuthorityId,
+	digests::{PreDigest, SecondaryPlainPreDigest, NextEpochDescriptor}, BabeAuthorityWeight,
+};
 use sp_inherents::{InherentDataProviders, InherentData, ProvideInherentData, InherentIdentifier};
 use sp_runtime::{
-	traits::{DigestItemFor, DigestFor, Block as BlockT, Header as _},
-	generic::Digest,
+	traits::{DigestItemFor, DigestFor, Block as BlockT, Zero, Header},
+	generic::{Digest, BlockId},
 };
-use sp_timestamp::{InherentType, InherentError, INHERENT_IDENTIFIER};
+use sp_timestamp::{InherentType, InherentError, INHERENT_IDENTIFIER, TimestampInherentData};
 
 /// Provides BABE-compatible predigests and BlockImportParams.
 /// Intended for use with BABE runtimes.
@@ -60,12 +63,15 @@ pub struct BabeConsensusDataProvider<B: BlockT, C> {
 
 	/// BABE config, gotten from the runtime.
 	config: Config,
+
+	/// Authorities to be used for this babe chain.
+	authorities: Vec<(AuthorityId, BabeAuthorityWeight)>,
 }
 
 impl<B, C> BabeConsensusDataProvider<B, C>
 	where
 		B: BlockT,
-		C: AuxStore + ProvideRuntimeApi<B>,
+		C: AuxStore + HeaderBackend<B> + ProvideRuntimeApi<B> + HeaderMetadata<B, Error = sp_blockchain::Error>,
 		C::Api: BabeApi<B, Error = sp_blockchain::Error>,
 {
 	pub fn new(
@@ -73,9 +79,14 @@ impl<B, C> BabeConsensusDataProvider<B, C>
 		keystore: SyncCryptoStorePtr,
 		provider: &InherentDataProviders,
 		epoch_changes: SharedEpochChanges<B, Epoch>,
+		authorities: Vec<(AuthorityId, BabeAuthorityWeight)>,
 	) -> Result<Self, Error> {
+		if authorities.is_empty() {
+			return Err(Error::StringError("Cannot supply empty authority set!".into()))
+		}
+
 		let config = Config::get_or_compute(&*client)?;
-		let timestamp_provider = SlotTimestampProvider::new(config.slot_duration)?;
+		let timestamp_provider = SlotTimestampProvider::new(client.clone())?;
 
 		provider.register_provider(timestamp_provider)?;
 		register_babe_inherent_data_provider(provider, config.slot_duration)?;
@@ -85,21 +96,11 @@ impl<B, C> BabeConsensusDataProvider<B, C>
 			client,
 			keystore,
 			epoch_changes,
+			authorities,
 		})
 	}
-}
-
-impl<B, C> ConsensusDataProvider<B> for BabeConsensusDataProvider<B, C>
-	where
-		B: BlockT,
-		C: AuxStore + HeaderBackend<B> + HeaderMetadata<B, Error = sp_blockchain::Error> + ProvideRuntimeApi<B>,
-		C::Api: BabeApi<B, Error = sp_blockchain::Error>,
-{
-	type Transaction = TransactionFor<C, B>;
-
-	fn create_digest(&self, parent: &B::Header, inherents: &InherentData) -> Result<DigestFor<B>, Error> {
-		let slot_number = inherents.babe_inherent_data()?;
 
+	fn epoch(&self, parent: &B::Header, slot_number: u64) -> Result<Epoch, Error> {
 		let epoch_changes = self.epoch_changes.lock();
 		let epoch_descriptor = epoch_changes
 			.epoch_descriptor_for_child_of(
@@ -121,15 +122,70 @@ impl<B, C> ConsensusDataProvider<B> for BabeConsensusDataProvider<B, C>
 				sp_consensus::Error::InvalidAuthoritiesSet
 			})?;
 
-		// this is a dev node environment, we should always be able to claim a slot.
-		let (predigest, _) = authorship::claim_slot(slot_number, epoch.as_ref(), &self.keystore)
-			.ok_or_else(|| Error::StringError("failed to claim slot for authorship".into()))?;
+		Ok(epoch.as_ref().clone())
+	}
+}
 
-		Ok(Digest {
-			logs: vec![
+impl<B, C> ConsensusDataProvider<B> for BabeConsensusDataProvider<B, C>
+	where
+		B: BlockT,
+		C: AuxStore + HeaderBackend<B> + HeaderMetadata<B, Error = sp_blockchain::Error> + ProvideRuntimeApi<B>,
+		C::Api: BabeApi<B, Error = sp_blockchain::Error>,
+{
+	type Transaction = TransactionFor<C, B>;
+
+	fn create_digest(&self, parent: &B::Header, inherents: &InherentData) -> Result<DigestFor<B>, Error> {
+		let slot_number = inherents.babe_inherent_data()?;
+		let epoch = self.epoch(parent, slot_number)?;
+
+		// this is a dev node environment, we should always be able to claim a slot.
+		let logs =  if let Some((predigest, _)) = authorship::claim_slot(slot_number, &epoch, &self.keystore) {
+			vec![
 				<DigestItemFor<B> as CompatibleDigestItem>::babe_pre_digest(predigest),
-			],
-		})
+			]
+		} else {
+			// well we couldn't claim a slot because this is an existing chain and we're not in the authorities.
+			// we need to tell BabeBlockImport that the epoch has changed, and we put ourselves in the authorities.
+			let predigest = PreDigest::SecondaryPlain(SecondaryPlainPreDigest {
+				slot_number,
+				authority_index: 0_u32,
+			});
+
+			let mut epoch_changes = self.epoch_changes.lock();
+			let epoch_descriptor = epoch_changes
+				.epoch_descriptor_for_child_of(
+					descendent_query(&*self.client),
+					&parent.hash(),
+					parent.number().clone(),
+					slot_number,
+				)
+				.map_err(|e| Error::StringError(format!("failed to fetch epoch_descriptor: {}", e)))?
+				.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet)?;
+
+			let epoch_mut = match epoch_descriptor {
+				ViableEpochDescriptor::Signaled(identifier, _epoch_header) => {
+					epoch_changes.epoch_mut(&identifier)
+						.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet)?
+				},
+				_ => unreachable!("we couldn't claim a slot, so this isn't the genesis epoch; qed")
+			};
+
+			// mutate the current epoch
+			epoch_mut.authorities = self.authorities.clone();
+
+			let next_epoch = ConsensusLog::NextEpochData(NextEpochDescriptor {
+				authorities: self.authorities.clone(),
+				// copy the old randomness
+				randomness: epoch_mut.randomness.clone(),
+			});
+
+			vec![
+				DigestItemFor::<B>::PreRuntime(BABE_ENGINE_ID, predigest.encode()),
+				DigestItemFor::<B>::Consensus(BABE_ENGINE_ID, next_epoch.encode())
+			]
+		};
+
+		Ok(Digest { logs })
 	}
 
 	fn append_block_import(
@@ -139,16 +195,42 @@ impl<B, C> ConsensusDataProvider<B> for BabeConsensusDataProvider<B, C>
 		inherents: &InherentData
 	) -> Result<(), Error> {
 		let slot_number = inherents.babe_inherent_data()?;
-
-		let epoch_descriptor = self.epoch_changes.lock()
+		let epoch_changes = self.epoch_changes.lock();
+		let mut epoch_descriptor = epoch_changes
 			.epoch_descriptor_for_child_of(
 				descendent_query(&*self.client),
 				&parent.hash(),
 				parent.number().clone(),
 				slot_number,
 			)
-			.map_err(|e| Error::StringError(format!("failed to fetch epoch data: {}", e)))?
+			.map_err(|e| Error::StringError(format!("failed to fetch epoch_descriptor: {}", e)))?
 			.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet)?;
+		// drop the lock
+		drop(epoch_changes);
+		// a quick check to see if we're in the authorities
+		let epoch = self.epoch(parent, slot_number)?;
+		let (authority, _) = self.authorities.first().expect("authorities is non-emptyp; qed");
+		let has_authority = epoch.authorities.iter()
+			.find(|(id, _)| *id == *authority)
+			.is_some();
+
+		if !has_authority {
+			log::info!(target: "manual-seal", "authority not found");
+			let slot_number = inherents.timestamp_inherent_data()? / self.config.slot_duration;
+			// manually hard code epoch descriptor
+			epoch_descriptor = match epoch_descriptor {
+				ViableEpochDescriptor::Signaled(identifier, _header) => {
+					ViableEpochDescriptor::Signaled(
+						identifier,
+						EpochHeader {
+							start_slot: slot_number,
+							end_slot: slot_number * self.config.epoch_length,
+						},
+					)
+				},
+				_ => unreachable!("we're not in the authorities, so this isn't the genesis epoch; qed")
+			};
+		}
 
 		params.intermediates.insert(
 			Cow::from(INTERMEDIATE_KEY),
@@ -168,12 +250,32 @@ struct SlotTimestampProvider {
 
 impl SlotTimestampProvider {
 	/// create a new mocked time stamp provider.
-	fn new(slot_duration: u64) -> Result<Self, Error> {
-		let now = SystemTime::now();
-		let duration = now.duration_since(SystemTime::UNIX_EPOCH)
-			.map_err(|err| Error::StringError(format!("{}", err)))?;
+	fn new<B, C>(client: Arc<C>) -> Result<Self, Error>
+		where
+			B: BlockT,
+			C: AuxStore + HeaderBackend<B> + ProvideRuntimeApi<B>,
+			C::Api: BabeApi<B, Error = sp_blockchain::Error>,
+	{
+		let slot_duration = Config::get_or_compute(&*client)?.slot_duration;
+		let info = client.info();
+
+		// looks like this isn't the first block, rehydrate the fake time.
+		// otherwise we'd be producing blocks for older slots.
+		let duration = if info.best_number != Zero::zero() {
+			let header = client.header(BlockId::Hash(info.best_hash))?.unwrap();
+			let slot_number = find_pre_digest::<B>(&header).unwrap().slot_number();
+			// add the slot duration so there's no collision of slots
+			(slot_number * slot_duration) + slot_duration
+		} else {
+			// this is the first block, use the correct time.
+			let now = SystemTime::now();
+			now.duration_since(SystemTime::UNIX_EPOCH)
+				.map_err(|err| Error::StringError(format!("{}", err)))?
+				.as_millis() as u64
+		};
+
 		Ok(Self {
-			time: atomic::AtomicU64::new(duration.as_millis() as u64),
+			time: atomic::AtomicU64::new(duration),
 			slot_duration,
 		})
 	}
diff --git a/substrate/client/executor/src/native_executor.rs b/substrate/client/executor/src/native_executor.rs
index 1da82313a2df90ba39832c4f0df605a0de05e6b2..b5d67b9e73f4226a1c20d637c3ad7cb0dc41ea87 100644
--- a/substrate/client/executor/src/native_executor.rs
+++ b/substrate/client/executor/src/native_executor.rs
@@ -258,10 +258,10 @@ impl<D: NativeExecutionDispatch> NativeExecutor<D> {
 		default_heap_pages: Option<u64>,
 		max_runtime_instances: usize,
 	) -> Self {
-		let mut host_functions = sp_io::SubstrateHostFunctions::host_functions();
+		let mut host_functions = D::ExtendHostFunctions::host_functions();
 
 		// Add the custom host functions provided by the user.
-		host_functions.extend(D::ExtendHostFunctions::host_functions());
+		host_functions.extend(sp_io::SubstrateHostFunctions::host_functions());
 		let wasm_executor = WasmExecutor::new(
 			fallback_method,
 			default_heap_pages,
diff --git a/substrate/client/finality-grandpa/rpc/Cargo.toml b/substrate/client/finality-grandpa/rpc/Cargo.toml
index c0c2ea8b27d88a88599b83cd67f1d98b80f68890..d1be93a19a72b496ea40d17a1d9c9ad8ac94b818 100644
--- a/substrate/client/finality-grandpa/rpc/Cargo.toml
+++ b/substrate/client/finality-grandpa/rpc/Cargo.toml
@@ -15,10 +15,10 @@ sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" }
 sp-core = { version = "2.0.0", path = "../../../primitives/core" }
 sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" }
 finality-grandpa = { version = "0.12.3", features = ["derive-codec"] }
-jsonrpc-core = "15.0.0"
-jsonrpc-core-client = "15.0.0"
-jsonrpc-derive = "15.0.0"
-jsonrpc-pubsub = "15.0.0"
+jsonrpc-core = "15.1.0"
+jsonrpc-core-client = "15.1.0"
+jsonrpc-derive = "15.1.0"
+jsonrpc-pubsub = "15.1.0"
 futures = { version = "0.3.4", features = ["compat"] }
 serde = { version = "1.0.105", features = ["derive"] }
 serde_json = "1.0.50"
diff --git a/substrate/client/rpc-api/Cargo.toml b/substrate/client/rpc-api/Cargo.toml
index 55eb51d261cdbdb008da2924a235e60c52bde876..0947dc47819cd374da23fdf81e43b058df110633 100644
--- a/substrate/client/rpc-api/Cargo.toml
+++ b/substrate/client/rpc-api/Cargo.toml
@@ -16,10 +16,10 @@ targets = ["x86_64-unknown-linux-gnu"]
 codec = { package = "parity-scale-codec", version = "1.3.4" }
 derive_more = "0.99.2"
 futures = { version = "0.3.1", features = ["compat"] }
-jsonrpc-core = "15.0.0"
-jsonrpc-core-client = "15.0.0"
-jsonrpc-derive = "15.0.0"
-jsonrpc-pubsub = "15.0.0"
+jsonrpc-core = "15.1.0"
+jsonrpc-core-client = "15.1.0"
+jsonrpc-derive = "15.1.0"
+jsonrpc-pubsub = "15.1.0"
 log = "0.4.8"
 parking_lot = "0.10.0"
 sp-core = { version = "2.0.0", path = "../../primitives/core" }
diff --git a/substrate/client/rpc-servers/Cargo.toml b/substrate/client/rpc-servers/Cargo.toml
index 4fdf0298a530b7a996ce980ca9466b78c45f7c8c..d414fbf259d3d9a22239d29367b33ee8916c0b62 100644
--- a/substrate/client/rpc-servers/Cargo.toml
+++ b/substrate/client/rpc-servers/Cargo.toml
@@ -14,8 +14,8 @@ targets = ["x86_64-unknown-linux-gnu"]
 
 [dependencies]
 futures = "0.1.6"
-jsonrpc-core = "15.0.0"
-pubsub = { package = "jsonrpc-pubsub", version = "15.0.0" }
+jsonrpc-core = "15.1.0"
+pubsub = { package = "jsonrpc-pubsub", version = "15.1.0" }
 log = "0.4.8"
 prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.8.0"}
 serde = "1.0.101"
@@ -23,6 +23,6 @@ serde_json = "1.0.41"
 sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" }
 
 [target.'cfg(not(target_os = "unknown"))'.dependencies]
-http = { package = "jsonrpc-http-server", version = "15.0.0" }
-ipc = { package = "jsonrpc-ipc-server", version = "15.0.0" }
-ws = { package = "jsonrpc-ws-server", version = "15.0.0" }
+http = { package = "jsonrpc-http-server", version = "15.1.0" }
+ipc = { package = "jsonrpc-ipc-server", version = "15.1.0" }
+ws = { package = "jsonrpc-ws-server", version = "15.1.0" }
diff --git a/substrate/client/rpc/Cargo.toml b/substrate/client/rpc/Cargo.toml
index 021c795fe5b948f8b182f26108ee4ea9069320d5..0af880f4330bf6ad6e82aa6565da7d6e07d40c8b 100644
--- a/substrate/client/rpc/Cargo.toml
+++ b/substrate/client/rpc/Cargo.toml
@@ -18,11 +18,10 @@ sc-client-api = { version = "2.0.0", path = "../api" }
 sp-api = { version = "2.0.0", path = "../../primitives/api" }
 codec = { package = "parity-scale-codec", version = "1.3.4" }
 futures = { version = "0.3.1", features = ["compat"] }
-jsonrpc-pubsub = "15.0.0"
+jsonrpc-pubsub = "15.1.0"
 log = "0.4.8"
 sp-core = { version = "2.0.0", path = "../../primitives/core" }
-sp-keystore = { version = "0.8.0", path = "../../primitives/keystore" }
-rpc = { package = "jsonrpc-core", version = "15.0.0" }
+rpc = { package = "jsonrpc-core", version = "15.1.0" }
 sp-version = { version = "2.0.0", path = "../../primitives/version" }
 serde_json = "1.0.41"
 sp-session = { version = "2.0.0", path = "../../primitives/session" }
@@ -30,6 +29,7 @@ sp-offchain = { version = "2.0.0", path = "../../primitives/offchain" }
 sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" }
 sp-utils = { version = "2.0.0", path = "../../primitives/utils" }
 sp-rpc = { version = "2.0.0", path = "../../primitives/rpc" }
+sp-keystore = { version = "0.8.0", path = "../../primitives/keystore" }
 sp-state-machine = { version = "0.8.0", path = "../../primitives/state-machine" }
 sp-chain-spec = { version = "2.0.0", path = "../../primitives/chain-spec" }
 sc-executor = { version = "0.8.0", path = "../executor" }
diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml
index 3569b2e7e58534ec76ca0b3dc3637d3ed1af9683..b85ebde3c1d28f95dde46575137be46cad0b0967 100644
--- a/substrate/client/service/Cargo.toml
+++ b/substrate/client/service/Cargo.toml
@@ -27,8 +27,8 @@ test-helpers = []
 derive_more = "0.99.2"
 futures01 = { package = "futures", version = "0.1.29" }
 futures = { version = "0.3.4", features = ["compat"] }
-jsonrpc-pubsub = "15.0"
-jsonrpc-core = "15.0"
+jsonrpc-pubsub = "15.1"
+jsonrpc-core = "15.1"
 rand = "0.7.3"
 parking_lot = "0.10.0"
 lazy_static = "1.4.0"
diff --git a/substrate/frame/contracts/rpc/Cargo.toml b/substrate/frame/contracts/rpc/Cargo.toml
index 587abcbcddaec7b9c2833f856b106521fd089965..362e298102a0ef405170ee8021e28044f5158668 100644
--- a/substrate/frame/contracts/rpc/Cargo.toml
+++ b/substrate/frame/contracts/rpc/Cargo.toml
@@ -14,9 +14,9 @@ targets = ["x86_64-unknown-linux-gnu"]
 
 [dependencies]
 codec = { package = "parity-scale-codec", version = "1.3.4" }
-jsonrpc-core = "15.0.0"
-jsonrpc-core-client = "15.0.0"
-jsonrpc-derive = "15.0.0"
+jsonrpc-core = "15.1.0"
+jsonrpc-core-client = "15.1.0"
+jsonrpc-derive = "15.1.0"
 sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" }
 sp-core = { version = "2.0.0", path = "../../../primitives/core" }
 sp-rpc = { version = "2.0.0", path = "../../../primitives/rpc" }
diff --git a/substrate/frame/transaction-payment/rpc/Cargo.toml b/substrate/frame/transaction-payment/rpc/Cargo.toml
index 26f073e60237f7f42df5a6d3a5cd5deb1c4b0371..77ebc0fb80e9a87b06df98ef2101accaece81b9f 100644
--- a/substrate/frame/transaction-payment/rpc/Cargo.toml
+++ b/substrate/frame/transaction-payment/rpc/Cargo.toml
@@ -14,9 +14,9 @@ targets = ["x86_64-unknown-linux-gnu"]
 
 [dependencies]
 codec = { package = "parity-scale-codec", version = "1.3.1" }
-jsonrpc-core = "15.0.0"
-jsonrpc-core-client = "15.0.0"
-jsonrpc-derive = "15.0.0"
+jsonrpc-core = "15.1.0"
+jsonrpc-core-client = "15.1.0"
+jsonrpc-derive = "15.1.0"
 sp-core = { version = "2.0.0", path = "../../../primitives/core" }
 sp-rpc = { version = "2.0.0", path = "../../../primitives/rpc" }
 serde = { version = "1.0.101", features = ["derive"] }
diff --git a/substrate/utils/frame/rpc/support/Cargo.toml b/substrate/utils/frame/rpc/support/Cargo.toml
index 2541ed0cf655f5ff574832fa77a8a53f540ef289..3b310b3a91c4805861244f183ef57d43401d6e11 100644
--- a/substrate/utils/frame/rpc/support/Cargo.toml
+++ b/substrate/utils/frame/rpc/support/Cargo.toml
@@ -13,8 +13,8 @@ targets = ["x86_64-unknown-linux-gnu"]
 
 [dependencies]
 futures = { version = "0.3.0", features = ["compat"] }
-jsonrpc-client-transports = { version = "15.0.0", default-features = false, features = ["http"] }
-jsonrpc-core = "15.0.0"
+jsonrpc-client-transports = { version = "15.1.0", default-features = false, features = ["http"] }
+jsonrpc-core = "15.1.0"
 codec = { package = "parity-scale-codec", version = "1.3.1" }
 serde = "1"
 frame-support = { version = "2.0.0", path = "../../../../frame/support" }
diff --git a/substrate/utils/frame/rpc/system/Cargo.toml b/substrate/utils/frame/rpc/system/Cargo.toml
index 515ff93251522025fbb7c695663337b33d81f302..19b6a6e8302bbd23da6abdd12e331219db9b13ed 100644
--- a/substrate/utils/frame/rpc/system/Cargo.toml
+++ b/substrate/utils/frame/rpc/system/Cargo.toml
@@ -16,9 +16,9 @@ targets = ["x86_64-unknown-linux-gnu"]
 sc-client-api = { version = "2.0.0", path = "../../../../client/api" }
 codec = { package = "parity-scale-codec", version = "1.3.1" }
 futures = { version = "0.3.4", features = ["compat"] }
-jsonrpc-core = "15.0.0"
-jsonrpc-core-client = "15.0.0"
-jsonrpc-derive = "15.0.0"
+jsonrpc-core = "15.1.0"
+jsonrpc-core-client = "15.1.0"
+jsonrpc-derive = "15.1.0"
 log = "0.4.8"
 serde = { version = "1.0.101", features = ["derive"] }
 sp-runtime = { version = "2.0.0", path = "../../../../primitives/runtime" }