diff --git a/substrate/.gitignore b/substrate/.gitignore index 21dee82d81463..d9ba8ac2b411f 100644 --- a/substrate/.gitignore +++ b/substrate/.gitignore @@ -18,3 +18,5 @@ polkadot.* .idea/ nohup.out rls*.log +*.orig +*.rej diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 6549381f6027e..6ff9929eb7837 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -3757,6 +3757,7 @@ dependencies = [ name = "substrate-consensus-aura-primitives" version = "0.1.0" dependencies = [ + "sr-primitives 0.1.0", "substrate-client 0.1.0", ] diff --git a/substrate/core/consensus/aura/primitives/Cargo.toml b/substrate/core/consensus/aura/primitives/Cargo.toml index d55db6b1eeb30..cc7fbeb3dd31d 100644 --- a/substrate/core/consensus/aura/primitives/Cargo.toml +++ b/substrate/core/consensus/aura/primitives/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [dependencies] substrate-client = { path = "../../../client", default-features = false } +runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives", default-features = false } [features] default = ["std"] diff --git a/substrate/core/consensus/aura/primitives/src/lib.rs b/substrate/core/consensus/aura/primitives/src/lib.rs index 9401b164ced94..47b6ec7c14170 100644 --- a/substrate/core/consensus/aura/primitives/src/lib.rs +++ b/substrate/core/consensus/aura/primitives/src/lib.rs @@ -19,6 +19,10 @@ #![cfg_attr(not(feature = "std"), no_std)] use substrate_client::decl_runtime_apis; +use runtime_primitives::ConsensusEngineId; + +/// The `ConsensusEngineId` of AuRa. +pub const AURA_ENGINE_ID: ConsensusEngineId = [b'a', b'u', b'r', b'a']; decl_runtime_apis! { /// API necessary for block authorship with aura. diff --git a/substrate/core/consensus/aura/src/lib.rs b/substrate/core/consensus/aura/src/lib.rs index 3a9bfd971abde..cf83d3fa6eb8f 100644 --- a/substrate/core/consensus/aura/src/lib.rs +++ b/substrate/core/consensus/aura/src/lib.rs @@ -25,7 +25,7 @@ //! //! Blocks from future steps will be either deferred or rejected depending on how //! far in the future they are. - +#![deny(deprecated)] use std::{sync::Arc, time::Duration, thread, marker::PhantomData, hash::Hash, fmt::Debug}; use parity_codec::{Encode, Decode}; @@ -37,6 +37,7 @@ use client::ChainHead; use client::block_builder::api::BlockBuilder as BlockBuilderApi; use client::runtime_api::ApiExt; use consensus_common::{ImportBlock, BlockOrigin}; +use aura_primitives::AURA_ENGINE_ID; use runtime_primitives::{generic, generic::BlockId, Justification}; use runtime_primitives::traits::{ Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi @@ -113,27 +114,42 @@ fn inherent_to_common_error(err: RuntimeString) -> consensus_common::Error { /// A digest item which is usable with aura consensus. pub trait CompatibleDigestItem: Sized { - /// Construct a digest item which is a slot number and a signature on the + /// Construct a digest item which contains a slot number and a signature on the /// hash. - fn aura_seal(slot_number: u64, signature: Signature) -> Self; + fn aura_seal(slot_num: u64, signature: Signature) -> Self; /// If this item is an Aura seal, return the slot number and signature. fn as_aura_seal(&self) -> Option<(u64, Signature)>; + + /// Return `true` if this seal type is deprecated. Otherwise, return + /// `false`. + fn is_deprecated(&self) -> bool; } -impl CompatibleDigestItem for generic::DigestItem> - where T::Signature: Clone +impl CompatibleDigestItem

for generic::DigestItem + where P: Pair, P::Signature: Clone + Encode + Decode, { /// Construct a digest item which is a slot number and a signature on the /// hash. - fn aura_seal(slot_number: u64, signature: Signature) -> Self { - generic::DigestItem::Seal(slot_number, signature) + fn aura_seal(slot_number: u64, signature: Signature

) -> Self { + generic::DigestItem::Consensus(AURA_ENGINE_ID, (slot_number, signature).encode()) } + /// If this item is an Aura seal, return the slot number and signature. - fn as_aura_seal(&self) -> Option<(u64, Signature)> { + #[allow(deprecated)] + fn as_aura_seal(&self) -> Option<(u64, Signature

)> { match self { generic::DigestItem::Seal(slot, ref sig) => Some((*slot, (*sig).clone())), - _ => None + generic::DigestItem::Consensus(AURA_ENGINE_ID, seal) => Decode::decode(&mut &seal[..]), + _ => None, + } + } + + #[allow(deprecated)] + fn is_deprecated(&self) -> bool { + match self { + generic::DigestItem::Seal(_, _) => true, + _ => false, } } } @@ -171,6 +187,7 @@ pub fn start_aura_thread( Error: From + From + 'static, P: Pair + Send + Sync + 'static, P::Public: Encode + Decode + Eq + Clone + Debug + Hash + Send + Sync + 'static, + P::Signature: Encode, SO: SyncOracle + Send + Sync + Clone + 'static, OnExit: Future + Send + 'static, DigestItemFor: CompatibleDigestItem

+ DigestItem> + 'static, @@ -217,6 +234,7 @@ pub fn start_aura( Error: From + From, P: Pair + Send + Sync + 'static, P::Public: Hash + Eq + Send + Sync + Clone + Debug + Encode + Decode + 'static, + P::Signature: Encode, SO: SyncOracle + Send + Sync + Clone, DigestItemFor: CompatibleDigestItem

+ DigestItem>, Error: ::std::error::Error + Send + 'static + From<::consensus_common::Error>, @@ -259,6 +277,7 @@ impl SlotWorker for AuraWorker + Send + Sync + 'static, P: Pair + Send + Sync + 'static, P::Public: Hash + Eq + Send + Sync + Clone + Debug + Encode + Decode + 'static, + P::Signature: Encode, Error: From + From, SO: SyncOracle + Send + Clone, DigestItemFor: CompatibleDigestItem

+ DigestItem>, @@ -416,19 +435,32 @@ impl SlotWorker for AuraWorker(slot_now: u64, mut header: B::Header, hash: B::Hash, authorities: &[AuthorityId

]) - -> Result, String> +#[forbid(deprecated)] +fn check_header( + slot_now: u64, + mut header: B::Header, + hash: B::Hash, + authorities: &[AuthorityId

], + allow_old_seals: bool, +) -> Result, String> where DigestItemFor: CompatibleDigestItem

, P::Public: Clone + AsRef, + P::Signature: Decode, { let digest_item = match header.digest_mut().pop() { Some(x) => x, None => return Err(format!("Header {:?} is unsealed", hash)), }; - let (slot_num, sig) = match digest_item.as_aura_seal() { - Some(x) => x, - None => return Err(format!("Header {:?} is unsealed", hash)), - }; + + if !allow_old_seals && digest_item.is_deprecated() { + debug!(target: "aura", "Header {:?} uses old seal format, rejecting", hash); + return Err(format!("Header {:?} uses old seal format, rejecting", hash)) + } + + let (slot_num, sig) = digest_item.as_aura_seal().ok_or_else(|| { + debug!(target: "aura", "Header {:?} is unsealed", hash); + format!("Header {:?} is unsealed", hash) + })?; if slot_num > slot_now { header.digest_mut().push(digest_item); @@ -436,7 +468,6 @@ fn check_header(slot_now: u64, mut header: B::Header, hash: B } else { // check the signature is valid under the expected authority and // chain state. - let expected_author = match slot_author::

(slot_num, &authorities) { None => return Err("Slot Author not found".to_string()), Some(author) => author @@ -473,6 +504,7 @@ pub struct AuraVerifier { extra: E, phantom: PhantomData

, inherent_data_providers: inherents::InherentDataProviders, + allow_old_seals: bool, } impl AuraVerifier @@ -539,6 +571,7 @@ impl ExtraVerification for NothingExtra { } } +#[forbid(deprecated)] impl Verifier for AuraVerifier where C: Authorities + ProvideRuntimeApi + Send + Sync, C::Api: BlockBuilderApi, @@ -546,6 +579,7 @@ impl Verifier for AuraVerifier where E: ExtraVerification, P: Pair + Send + Sync + 'static, P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + AsRef + 'static, + P::Signature: Encode + Decode, { fn verify( &self, @@ -569,7 +603,13 @@ impl Verifier for AuraVerifier where // we add one to allow for some small drift. // FIXME #1019 in the future, alter this queue to allow deferring of headers - let checked_header = check_header::(slot_now + 1, header, hash, &authorities[..])?; + let checked_header = check_header::( + slot_now + 1, + header, + hash, + &authorities[..], + self.allow_old_seals, + )?; match checked_header { CheckedHeader::Checked(pre_header, slot_num, sig) => { let item = >::aura_seal(slot_num, sig); @@ -654,6 +694,7 @@ pub fn import_queue( client: Arc, extra: E, inherent_data_providers: InherentDataProviders, + allow_old_seals: bool, ) -> Result, consensus_common::Error> where B: Block, C: 'static + Authorities + ProvideRuntimeApi + Send + Sync, @@ -662,6 +703,7 @@ pub fn import_queue( E: 'static + ExtraVerification, P: Pair + Send + Sync + 'static, P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode + AsRef, + P::Signature: Encode + Decode, { register_aura_inherent_data_provider(&inherent_data_providers, slot_duration.get())?; @@ -671,6 +713,7 @@ pub fn import_queue( extra, inherent_data_providers, phantom: PhantomData, + allow_old_seals, } ); Ok(BasicQueue::new(verifier, block_import, justification_import)) @@ -756,6 +799,7 @@ mod tests { extra: NothingExtra, inherent_data_providers, phantom: Default::default(), + allow_old_seals: false, }) } diff --git a/substrate/core/finality-grandpa/src/lib.rs b/substrate/core/finality-grandpa/src/lib.rs index d6eda5a0916b8..daf37357a0868 100644 --- a/substrate/core/finality-grandpa/src/lib.rs +++ b/substrate/core/finality-grandpa/src/lib.rs @@ -111,7 +111,7 @@ use ed25519::{Public as AuthorityId, Signature as AuthoritySignature}; #[cfg(test)] mod tests; -const GRANDPA_ENGINE_ID: network::ConsensusEngineId = [b'a', b'f', b'g', b'1']; +const GRANDPA_ENGINE_ID: runtime_primitives::ConsensusEngineId = [b'a', b'f', b'g', b'1']; const MESSAGE_ROUND_TOLERANCE: u64 = 2; /// A GRANDPA message for a substrate chain. diff --git a/substrate/core/network/src/consensus_gossip.rs b/substrate/core/network/src/consensus_gossip.rs index 3f6073f1d4e2a..433dd5b795fd7 100644 --- a/substrate/core/network/src/consensus_gossip.rs +++ b/substrate/core/network/src/consensus_gossip.rs @@ -25,10 +25,10 @@ use rand::{self, seq::SliceRandom}; use lru_cache::LruCache; use network_libp2p::{Severity, PeerId}; use runtime_primitives::traits::{Block as BlockT, Hash, HashFor}; +use runtime_primitives::ConsensusEngineId; pub use crate::message::generic::{Message, ConsensusMessage}; use crate::protocol::Context; use crate::config::Roles; -use crate::ConsensusEngineId; // FIXME: Add additional spam/DoS attack protection: https://github.com/paritytech/substrate/issues/1115 const KNOWN_MESSAGES_CACHE_SIZE: usize = 4096; diff --git a/substrate/core/network/src/lib.rs b/substrate/core/network/src/lib.rs index 0f184af77302e..0200494517879 100644 --- a/substrate/core/network/src/lib.rs +++ b/substrate/core/network/src/lib.rs @@ -48,7 +48,7 @@ pub use network_libp2p::{ NodeKeyConfig, Secret, Secp256k1Secret, Ed25519Secret, build_multiaddr, PeerId, PublicKey }; -pub use message::{generic as generic_message, RequestId, Status as StatusMessage, ConsensusEngineId}; +pub use message::{generic as generic_message, RequestId, Status as StatusMessage}; pub use error::Error; pub use on_demand::{OnDemand, OnDemandService, RemoteResponse}; #[doc(hidden)] diff --git a/substrate/core/network/src/message.rs b/substrate/core/network/src/message.rs index 355935b10ece6..221a867c6750f 100644 --- a/substrate/core/network/src/message.rs +++ b/substrate/core/network/src/message.rs @@ -17,7 +17,7 @@ //! Network packet message types. These get serialized and put into the lower level protocol payload. use bitflags::bitflags; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT}; +use runtime_primitives::{ConsensusEngineId, traits::{Block as BlockT, Header as HeaderT}}; use parity_codec::{Encode, Decode, Input, Output}; pub use self::generic::{ BlockAnnounce, RemoteCallRequest, RemoteReadRequest, @@ -29,9 +29,6 @@ pub use self::generic::{ /// A unique ID of a request. pub type RequestId = u64; -/// Consensus engine unique ID. -pub type ConsensusEngineId = [u8; 4]; - /// Type alias for using the message type using block type parameters. pub type Message = generic::Message< ::Header, diff --git a/substrate/core/network/src/protocol.rs b/substrate/core/network/src/protocol.rs index 27e615e56ff38..185f595cc0912 100644 --- a/substrate/core/network/src/protocol.rs +++ b/substrate/core/network/src/protocol.rs @@ -19,10 +19,10 @@ use futures::sync::mpsc; use parking_lot::Mutex; use network_libp2p::{PeerId, Severity}; use primitives::storage::StorageKey; -use runtime_primitives::generic::BlockId; +use runtime_primitives::{generic::BlockId, ConsensusEngineId}; use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, NumberFor, Zero}; use consensus::import_queue::ImportQueue; -use crate::message::{self, Message, ConsensusEngineId}; +use crate::message::{self, Message}; use crate::message::generic::{Message as GenericMessage, ConsensusMessage}; use crate::consensus_gossip::ConsensusGossip; use crate::on_demand::OnDemandService; diff --git a/substrate/core/network/src/service.rs b/substrate/core/network/src/service.rs index d0cd0540d2f02..8e8658739884e 100644 --- a/substrate/core/network/src/service.rs +++ b/substrate/core/network/src/service.rs @@ -27,12 +27,12 @@ use network_libp2p::{multiaddr, RegisteredProtocol, NetworkState}; use peerset::Peerset; use consensus::import_queue::{ImportQueue, Link}; use crate::consensus_gossip::ConsensusGossip; -use crate::message::{Message, ConsensusEngineId}; +use crate::message::Message; use crate::protocol::{self, Context, FromNetworkMsg, Protocol, ConnectedPeer, ProtocolMsg, ProtocolStatus, PeerInfo}; use crate::config::Params; use crossbeam_channel::{self as channel, Receiver, Sender, TryRecvError}; use crate::error::Error; -use runtime_primitives::traits::{Block as BlockT, NumberFor}; +use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; use crate::specialization::NetworkSpecialization; use tokio::prelude::task::AtomicTask; @@ -295,6 +295,7 @@ impl> ::consensus::SyncOracle f fn is_major_syncing(&self) -> bool { self.is_major_syncing() } + fn is_offline(&self) -> bool { self.is_offline.load(Ordering::Relaxed) } @@ -315,6 +316,7 @@ impl> SyncProvider for Servi fn is_major_syncing(&self) -> bool { self.is_major_syncing() } + /// Get sync status fn status(&self) -> mpsc::UnboundedReceiver> { let (sink, stream) = mpsc::unbounded(); diff --git a/substrate/core/network/src/test/mod.rs b/substrate/core/network/src/test/mod.rs index b6e7c3b10f1c9..b4b1c4f4e249c 100644 --- a/substrate/core/network/src/test/mod.rs +++ b/substrate/core/network/src/test/mod.rs @@ -39,7 +39,7 @@ use crate::consensus_gossip::ConsensusGossip; use crossbeam_channel::{self as channel, Sender, select}; use futures::Future; use futures::sync::{mpsc, oneshot}; -use crate::message::{Message, ConsensusEngineId}; +use crate::message::Message; use network_libp2p::PeerId; use parity_codec::Encode; use parking_lot::{Mutex, RwLock}; @@ -47,7 +47,7 @@ use primitives::{H256, ed25519::Public as AuthorityId}; use crate::protocol::{ConnectedPeer, Context, FromNetworkMsg, Protocol, ProtocolMsg}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{AuthorityIdFor, Block as BlockT, Digest, DigestItem, Header, NumberFor}; -use runtime_primitives::Justification; +use runtime_primitives::{Justification, ConsensusEngineId}; use crate::service::{network_channel, NetworkChan, NetworkLink, NetworkMsg, NetworkPort, TransactionPool}; use crate::specialization::NetworkSpecialization; use test_client::{self, AccountKeyring}; @@ -260,11 +260,13 @@ impl + Clone> Peer { } // SyncOracle: are we connected to any peer? + #[cfg(test)] fn is_offline(&self) -> bool { self.is_offline.load(Ordering::Relaxed) } // SyncOracle: are we in the process of catching-up with the chain? + #[cfg(test)] fn is_major_syncing(&self) -> bool { self.is_major_syncing.load(Ordering::Relaxed) } @@ -644,7 +646,6 @@ pub trait TestNetFactory: Sized { Some(NetworkMsg::ReportPeer(who, _)) => { to_disconnect.insert(who); } - Some(_msg) => continue, } } for d in to_disconnect { diff --git a/substrate/core/primitives/src/crypto.rs b/substrate/core/primitives/src/crypto.rs index fe7c1fabb8ecc..82b36d8a97e97 100644 --- a/substrate/core/primitives/src/crypto.rs +++ b/substrate/core/primitives/src/crypto.rs @@ -414,7 +414,7 @@ mod tests { fn derive>(&self, _path: Iter) -> Result { Err(()) } - fn from_seed(_seed: Self::Seed) -> Self { TestPair::Seed(vec![]) } + fn from_seed(_seed: ::Seed) -> Self { TestPair::Seed(vec![]) } fn sign(&self, _message: &[u8]) -> Self::Signature { () } fn verify, M: AsRef<[u8]>>(_sig: &Self::Signature, _message: M, _pubkey: P) -> bool { true } fn verify_weak, M: AsRef<[u8]>>(_sig: &[u8], _message: M, _pubkey: P) -> bool { true } diff --git a/substrate/core/primitives/src/ed25519.rs b/substrate/core/primitives/src/ed25519.rs index 8b55300df45f6..295c23b3787a8 100644 --- a/substrate/core/primitives/src/ed25519.rs +++ b/substrate/core/primitives/src/ed25519.rs @@ -523,7 +523,7 @@ impl Pair { mod test { use super::*; use hex_literal::{hex, hex_impl}; - use crate::{Pair as PairT, crypto::DEV_PHRASE}; + use crate::crypto::DEV_PHRASE; #[test] fn default_phrase_should_be_used() { diff --git a/substrate/core/service/src/lib.rs b/substrate/core/service/src/lib.rs index 3b39607a974ae..105bab8ca03cf 100644 --- a/substrate/core/service/src/lib.rs +++ b/substrate/core/service/src/lib.rs @@ -48,6 +48,7 @@ pub use chain_spec::{ChainSpec, Properties}; pub use transaction_pool::txpool::{ self, Pool as TransactionPool, Options as TransactionPoolOptions, ChainApi, IntoPoolError }; +use client::runtime_api::BlockT; pub use client::FinalityNotifications; pub use components::{ServiceFactory, FullBackend, FullExecutor, LightBackend, @@ -227,9 +228,9 @@ impl Service { // A utility stream that drops all ready items and only returns the last one. // This is used to only keep the last finality notification and avoid // overloading the sync module with notifications. - struct MostRecentNotification(futures::stream::Fuse>); + struct MostRecentNotification(futures::stream::Fuse>); - impl Stream for MostRecentNotification { + impl Stream for MostRecentNotification { type Item = as Stream>::Item; type Error = as Stream>::Error; diff --git a/substrate/core/sr-primitives/src/generic/digest.rs b/substrate/core/sr-primitives/src/generic/digest.rs index 710bcc77457ce..8eed63900ffe8 100644 --- a/substrate/core/sr-primitives/src/generic/digest.rs +++ b/substrate/core/sr-primitives/src/generic/digest.rs @@ -21,6 +21,7 @@ use serde_derive::Serialize; use rstd::prelude::*; +use crate::ConsensusEngineId; use crate::codec::{Decode, Encode, Codec, Input}; use crate::traits::{self, Member, DigestItem as DigestItemT, MaybeHash}; @@ -61,6 +62,7 @@ impl traits::Digest for Digest where /// provide opaque access to other items. #[derive(PartialEq, Eq, Clone)] #[cfg_attr(feature = "std", derive(Debug))] +#[allow(deprecated)] pub enum DigestItem { /// System digest item announcing that authorities set has been changed /// in the block. Contains the new set of authorities. @@ -69,8 +71,11 @@ pub enum DigestItem { /// block. It is created for every block iff runtime supports changes /// trie creation. ChangesTrieRoot(Hash), - /// Put a Seal on it + /// The old way to put a Seal on it. Deprecated. + #[deprecated] Seal(u64, SealSignature), + /// Put a Seal on it + Consensus(ConsensusEngineId, Vec), /// Any 'non-system' digest item, opaque to the native code. Other(Vec), } @@ -89,16 +94,20 @@ impl ::serde::Serializ /// final runtime implementations for encoding/decoding its log items. #[derive(PartialEq, Eq, Clone)] #[cfg_attr(feature = "std", derive(Debug))] +#[allow(deprecated)] pub enum DigestItemRef<'a, Hash: 'a, AuthorityId: 'a, SealSignature: 'a> { /// Reference to `DigestItem::AuthoritiesChange`. AuthoritiesChange(&'a [AuthorityId]), /// Reference to `DigestItem::ChangesTrieRoot`. ChangesTrieRoot(&'a Hash), - /// A sealed signature for testing + /// A deprecated sealed signature for testing + #[deprecated] Seal(&'a u64, &'a SealSignature), + /// A sealed signature for testing + Consensus(&'a ConsensusEngineId, &'a [u8]), /// Any 'non-system' digest item, opaque to the native code. /// Reference to `DigestItem::Other`. - Other(&'a Vec), + Other(&'a [u8]), } /// Type of the digest item. Used to gain explicit control over `DigestItem` encoding @@ -109,9 +118,10 @@ pub enum DigestItemRef<'a, Hash: 'a, AuthorityId: 'a, SealSignature: 'a> { #[derive(Encode, Decode)] enum DigestItemType { Other = 0, - AuthoritiesChange, - ChangesTrieRoot, - Seal, + AuthoritiesChange = 1, + ChangesTrieRoot = 2, + Seal = 3, + Consensus = 4, } impl DigestItem { @@ -124,11 +134,13 @@ impl DigestItem(&'a self) -> DigestItemRef<'a, Hash, AuthorityId, SealSignature> { match *self { DigestItem::AuthoritiesChange(ref v) => DigestItemRef::AuthoritiesChange(v), DigestItem::ChangesTrieRoot(ref v) => DigestItemRef::ChangesTrieRoot(v), DigestItem::Seal(ref v, ref s) => DigestItemRef::Seal(v, s), + DigestItem::Consensus(ref v, ref s) => DigestItemRef::Consensus(v, s), DigestItem::Other(ref v) => DigestItemRef::Other(v), } } @@ -158,6 +170,7 @@ impl Encode for Digest } impl Decode for DigestItem { + #[allow(deprecated)] fn decode(input: &mut I) -> Option { let item_type: DigestItemType = Decode::decode(input)?; match item_type { @@ -171,6 +184,10 @@ impl Decode for Digest let vals: (u64, SealSignature) = Decode::decode(input)?; Some(DigestItem::Seal(vals.0, vals.1)) }, + DigestItemType::Consensus => { + let vals: (ConsensusEngineId, Vec) = Decode::decode(input)?; + Some(DigestItem::Consensus(vals.0, vals.1)) + } DigestItemType::Other => Some(DigestItem::Other( Decode::decode(input)?, )), @@ -196,6 +213,7 @@ impl<'a, Hash: Codec + Member, AuthorityId: Codec + Member, SealSignature: Codec } } +#[allow(deprecated)] impl<'a, Hash: Encode, AuthorityId: Encode, SealSignature: Encode> Encode for DigestItemRef<'a, Hash, AuthorityId, SealSignature> { fn encode(&self) -> Vec { let mut v = Vec::new(); @@ -213,6 +231,10 @@ impl<'a, Hash: Encode, AuthorityId: Encode, SealSignature: Encode> Encode for Di DigestItemType::Seal.encode_to(&mut v); (val, sig).encode_to(&mut v); }, + DigestItemRef::Consensus(val, sig) => { + DigestItemType::Consensus.encode_to(&mut v); + (val, sig).encode_to(&mut v); + }, DigestItemRef::Other(val) => { DigestItemType::Other.encode_to(&mut v); val.encode_to(&mut v); @@ -229,6 +251,7 @@ mod tests { use substrate_primitives::hash::H512 as Signature; #[test] + #[allow(deprecated)] fn should_serialize_digest() { let digest = Digest { logs: vec![ diff --git a/substrate/core/sr-primitives/src/lib.rs b/substrate/core/sr-primitives/src/lib.rs index 41d1564127c4f..cd83573cfce62 100644 --- a/substrate/core/sr-primitives/src/lib.rs +++ b/substrate/core/sr-primitives/src/lib.rs @@ -120,6 +120,9 @@ impl BuildStorage for StorageOverlay { } } +/// Consensus engine unique ID. +pub type ConsensusEngineId = [u8; 4]; + /// Permill is parts-per-million (i.e. after multiplying by this, divide by 1000000). #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] #[derive(Encode, Decode, Default, Copy, Clone, PartialEq, Eq)] diff --git a/substrate/core/test-runtime/wasm/Cargo.lock b/substrate/core/test-runtime/wasm/Cargo.lock index 771ffe97e3deb..ced5304a73bd5 100644 --- a/substrate/core/test-runtime/wasm/Cargo.lock +++ b/substrate/core/test-runtime/wasm/Cargo.lock @@ -2280,6 +2280,7 @@ dependencies = [ name = "substrate-consensus-aura-primitives" version = "0.1.0" dependencies = [ + "sr-primitives 0.1.0", "substrate-client 0.1.0", ] diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 3eae0c992eb83..afdd492c6aafc 100644 Binary files a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/substrate/node-template/runtime/wasm/Cargo.lock b/substrate/node-template/runtime/wasm/Cargo.lock index 6db886a520434..b54048856d655 100644 --- a/substrate/node-template/runtime/wasm/Cargo.lock +++ b/substrate/node-template/runtime/wasm/Cargo.lock @@ -2445,6 +2445,7 @@ dependencies = [ name = "substrate-consensus-aura-primitives" version = "0.1.0" dependencies = [ + "sr-primitives 0.1.0", "substrate-client 0.1.0", ] diff --git a/substrate/node-template/src/service.rs b/substrate/node-template/src/service.rs index 2ff5041f76e76..95283c03f2540 100644 --- a/substrate/node-template/src/service.rs +++ b/substrate/node-template/src/service.rs @@ -94,6 +94,7 @@ construct_service_factory! { client, NothingExtra, config.custom.inherent_data_providers.clone(), + true, ).map_err(Into::into) }, LightImportQueue = AuraImportQueue< @@ -107,6 +108,7 @@ construct_service_factory! { client, NothingExtra, config.custom.inherent_data_providers.clone(), + true, ).map_err(Into::into) }, } diff --git a/substrate/node/cli/src/service.rs b/substrate/node/cli/src/service.rs index c4dd70fc51728..a1fb61f175b4b 100644 --- a/substrate/node/cli/src/service.rs +++ b/substrate/node/cli/src/service.rs @@ -148,6 +148,7 @@ construct_service_factory! { client, NothingExtra, config.custom.inherent_data_providers.clone(), + true, ).map_err(Into::into) }}, LightImportQueue = AuraImportQueue @@ -159,6 +160,7 @@ construct_service_factory! { client, NothingExtra, config.custom.inherent_data_providers.clone(), + true, ).map_err(Into::into) } }, diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index dc1683c38e2b5..ad31c082969cc 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 48, - impl_version: 49, + spec_version: 49, + impl_version: 50, apis: RUNTIME_API_VERSIONS, }; diff --git a/substrate/node/runtime/wasm/Cargo.lock b/substrate/node/runtime/wasm/Cargo.lock index 4ad70d11347c5..146474068affd 100644 --- a/substrate/node/runtime/wasm/Cargo.lock +++ b/substrate/node/runtime/wasm/Cargo.lock @@ -2589,6 +2589,7 @@ dependencies = [ name = "substrate-consensus-aura-primitives" version = "0.1.0" dependencies = [ + "sr-primitives 0.1.0", "substrate-client 0.1.0", ] diff --git a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index cbe64d746792e..fef986a4f7864 100644 Binary files a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ