-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into bko-bridges-backpor…
…ts-and-nits
- Loading branch information
Showing
70 changed files
with
219 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Cumulus. | ||
|
||
// Cumulus is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Cumulus is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Aura-related primitives for cumulus parachain collators. | ||
use codec::Codec; | ||
use cumulus_primitives_aura::AuraUnincludedSegmentApi; | ||
use cumulus_primitives_core::BlockT; | ||
use sp_consensus_aura::AuraApi; | ||
use sp_runtime::app_crypto::{AppCrypto, AppPair, AppSignature, Pair}; | ||
|
||
/// Convenience trait for defining the basic bounds of an `AuraId`. | ||
pub trait AuraIdT: AppCrypto<Pair = Self::BoundedPair> + Codec + Send { | ||
/// Extra bounds for the `Pair`. | ||
type BoundedPair: AppPair + AppCrypto<Signature = Self::BoundedSignature>; | ||
|
||
/// Extra bounds for the `Signature`. | ||
type BoundedSignature: AppSignature | ||
+ TryFrom<Vec<u8>> | ||
+ std::hash::Hash | ||
+ sp_runtime::traits::Member | ||
+ Codec; | ||
} | ||
|
||
impl<T> AuraIdT for T | ||
where | ||
T: AppCrypto + Codec + Send + Sync, | ||
<<T as AppCrypto>::Pair as AppCrypto>::Signature: | ||
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec, | ||
{ | ||
type BoundedPair = <T as AppCrypto>::Pair; | ||
type BoundedSignature = <<T as AppCrypto>::Pair as AppCrypto>::Signature; | ||
} | ||
|
||
/// Convenience trait for defining the basic bounds of a parachain runtime that supports | ||
/// the Aura consensus. | ||
pub trait AuraRuntimeApi<Block: BlockT, AuraId: AuraIdT>: | ||
sp_api::ApiExt<Block> | ||
+ AuraApi<Block, <AuraId::BoundedPair as Pair>::Public> | ||
+ AuraUnincludedSegmentApi<Block> | ||
+ Sized | ||
{ | ||
/// Check if the runtime has the Aura API. | ||
fn has_aura_api(&self, at: Block::Hash) -> bool { | ||
self.has_api::<dyn AuraApi<Block, <AuraId::BoundedPair as Pair>::Public>>(at) | ||
.unwrap_or(false) | ||
} | ||
} | ||
|
||
impl<T, Block: BlockT, AuraId: AuraIdT> AuraRuntimeApi<Block, AuraId> for T where | ||
T: sp_api::ApiExt<Block> | ||
+ AuraApi<Block, <AuraId::BoundedPair as Pair>::Public> | ||
+ AuraUnincludedSegmentApi<Block> | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Cumulus. | ||
|
||
// Cumulus is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Cumulus is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Cumulus parachain collator primitives. | ||
#![warn(missing_docs)] | ||
|
||
pub mod aura; | ||
|
||
use cumulus_primitives_core::CollectCollationInfo; | ||
use sp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, Metadata}; | ||
use sp_block_builder::BlockBuilder; | ||
use sp_runtime::traits::Block as BlockT; | ||
use sp_session::SessionKeys; | ||
use sp_transaction_pool::runtime_api::TaggedTransactionQueue; | ||
|
||
/// Convenience trait that defines the basic bounds for the `RuntimeApi` of a parachain node. | ||
pub trait NodeRuntimeApi<Block: BlockT>: | ||
ApiExt<Block> | ||
+ Metadata<Block> | ||
+ SessionKeys<Block> | ||
+ BlockBuilder<Block> | ||
+ TaggedTransactionQueue<Block> | ||
+ CollectCollationInfo<Block> | ||
+ Sized | ||
{ | ||
} | ||
|
||
impl<T, Block: BlockT> NodeRuntimeApi<Block> for T where | ||
T: ApiExt<Block> | ||
+ Metadata<Block> | ||
+ SessionKeys<Block> | ||
+ BlockBuilder<Block> | ||
+ TaggedTransactionQueue<Block> | ||
+ CollectCollationInfo<Block> | ||
{ | ||
} | ||
|
||
/// Convenience trait that defines the basic bounds for the `ConstructRuntimeApi` of a parachain | ||
/// node. | ||
pub trait ConstructNodeRuntimeApi<Block: BlockT, C: CallApiAt<Block>>: | ||
ConstructRuntimeApi<Block, C, RuntimeApi = Self::BoundedRuntimeApi> + Send + Sync + 'static | ||
{ | ||
/// Basic bounds for the `RuntimeApi` of a parachain node. | ||
type BoundedRuntimeApi: NodeRuntimeApi<Block>; | ||
} | ||
|
||
impl<T, Block: BlockT, C: CallApiAt<Block>> ConstructNodeRuntimeApi<Block, C> for T | ||
where | ||
T: ConstructRuntimeApi<Block, C> + Send + Sync + 'static, | ||
T::RuntimeApi: NodeRuntimeApi<Block>, | ||
{ | ||
type BoundedRuntimeApi = T::RuntimeApi; | ||
} |
Oops, something went wrong.