diff --git a/substrate/core/client/src/block_builder/block_builder.rs b/substrate/core/client/src/block_builder/block_builder.rs index 7d5b867e3a..cb67db5adf 100644 --- a/substrate/core/client/src/block_builder/block_builder.rs +++ b/substrate/core/client/src/block_builder/block_builder.rs @@ -39,7 +39,7 @@ impl<'a, Block, A> BlockBuilder<'a, Block, A> where Block: BlockT, A: ProvideRuntimeApi + HeaderBackend + 'a, - A::Api: BlockBuilderApi, + A::Api: BlockBuilderApi + Core, { /// Create a new instance of builder from the given client, building on the latest block. pub fn new(api: &'a A) -> error::Result { @@ -84,7 +84,7 @@ where block_id: &BlockId, xt: Block::Extrinsic, extrinsics: &mut Vec - ) -> error::Result<()> where T: BlockBuilderApi { + ) -> error::Result<()> where T: BlockBuilderApi + Core { api.map_api_result(|api| { match api.apply_extrinsic(block_id, &xt)? { Ok(ApplyOutcome::Success) | Ok(ApplyOutcome::Fail) => { diff --git a/substrate/core/client/src/client.rs b/substrate/core/client/src/client.rs index 03cefca49e..df03cc8e0e 100644 --- a/substrate/core/client/src/client.rs +++ b/substrate/core/client/src/client.rs @@ -547,7 +547,7 @@ impl Client where &self ) -> error::Result> where E: Clone + Send + Sync, - RA: BlockBuilderAPI + RA: BlockBuilderAPI + CoreAPI, { block_builder::BlockBuilder::new(self) } @@ -557,7 +557,7 @@ impl Client where &self, parent: &BlockId ) -> error::Result> where E: Clone + Send + Sync, - RA: BlockBuilderAPI + RA: BlockBuilderAPI + CoreAPI, { block_builder::BlockBuilder::at_block(parent, &self) } @@ -568,7 +568,7 @@ impl Client where at: Block::Hash, body: &Option> ) -> error::Result> where - RA: TaggedTransactionQueue, + RA: TaggedTransactionQueue + CoreAPI, E: CallExecutor + Send + Sync + Clone, { let id = BlockId::Hash(at); @@ -604,7 +604,7 @@ impl Client where finalized: bool, aux: Vec<(Vec, Option>)>, ) -> error::Result where - RA: TaggedTransactionQueue, + RA: TaggedTransactionQueue + CoreAPI, E: CallExecutor + Send + Sync + Clone, { let parent_hash = import_headers.post().parent_hash().clone(); @@ -1058,7 +1058,7 @@ impl consensus::BlockImport for Client B: backend::Backend, E: CallExecutor + Clone + Send + Sync, Block: BlockT, - RA: TaggedTransactionQueue + RA: TaggedTransactionQueue + CoreAPI, { type Error = Error; diff --git a/substrate/core/client/src/runtime_api/macros.rs b/substrate/core/client/src/runtime_api/macros.rs index b58f2143c8..ad13d8b265 100644 --- a/substrate/core/client/src/runtime_api/macros.rs +++ b/substrate/core/client/src/runtime_api/macros.rs @@ -347,7 +347,7 @@ macro_rules! decl_runtime_apis { ) => { $( #[$attr] )* #[cfg(feature = "std")] - pub trait $name < $( $generic_param_parsed $( : $generic_bound_parsed )* ),* > : $crate::runtime_api::Core { + pub trait $name < $( $generic_param_parsed $( : $generic_bound_parsed )* ),* > { $( type $client_generic_param $( : $client_generic_bound )*; )* $( diff --git a/substrate/core/client/src/runtime_api/mod.rs b/substrate/core/client/src/runtime_api/mod.rs index e151718360..fd3bc5f172 100644 --- a/substrate/core/client/src/runtime_api/mod.rs +++ b/substrate/core/client/src/runtime_api/mod.rs @@ -23,7 +23,7 @@ pub use state_machine::OverlayedChanges; #[doc(hidden)] pub use runtime_primitives::{traits::Block as BlockT, generic::BlockId}; #[cfg(feature = "std")] -use runtime_primitives::traits::ApiRef; +pub use runtime_primitives::traits::ApiRef; pub use runtime_version::ApiId; #[doc(hidden)] pub use rstd::slice; diff --git a/substrate/core/finality-grandpa/src/lib.rs b/substrate/core/finality-grandpa/src/lib.rs index 60f56776da..7aa377410f 100644 --- a/substrate/core/finality-grandpa/src/lib.rs +++ b/substrate/core/finality-grandpa/src/lib.rs @@ -84,7 +84,7 @@ use futures::stream::Fuse; use futures::sync::mpsc; use client::{Client, error::Error as ClientError, ImportNotifications, backend::Backend, CallExecutor}; use client::blockchain::HeaderBackend; -use client::runtime_api::TaggedTransactionQueue; +use client::runtime_api::{Core as CoreAPI, TaggedTransactionQueue}; use codec::{Encode, Decode}; use consensus_common::{BlockImport, ImportBlock, ImportResult}; use runtime_primitives::traits::{ @@ -775,16 +775,16 @@ impl, N, RA> voter::Environment, RA> { - inner: Arc>, +pub struct GrandpaBlockImport { + import: Import, authority_set: SharedAuthoritySet>, + api: Api, } -impl, RA> BlockImport for GrandpaBlockImport where - B: Backend + 'static, - E: CallExecutor + 'static + Clone + Send + Sync, - DigestFor: Encode, - RA: GrandpaApi + TaggedTransactionQueue, +impl> BlockImport for GrandpaBlockImport where + Import: BlockImport, + Api: ProvideRuntimeApi, + Api::Api: GrandpaApi, { type Error = ClientError; @@ -793,7 +793,7 @@ impl, RA> BlockImport for GrandpaBlockImpo { use authorities::PendingChange; - let maybe_change = self.inner.runtime_api().grandpa_pending_change( + let maybe_change = self.api.runtime_api().grandpa_pending_change( &BlockId::hash(*block.header.parent_hash()), &block.header.digest().clone(), )?; @@ -818,7 +818,7 @@ impl, RA> BlockImport for GrandpaBlockImpo (old_set, authorities) }); - let result = self.inner.import_block(block, new_authorities); + let result = self.import.import_block(block, new_authorities); if let Err(ref e) = result { if let Some((old_set, mut authorities)) = just_in_case { debug!(target: "afg", "Restoring old set after block import error: {:?}", e); @@ -832,15 +832,15 @@ impl, RA> BlockImport for GrandpaBlockImpo /// Half of a link between a block-import worker and a the background voter. // This should remain non-clone. -pub struct LinkHalf, RA> { - client: Arc>, +pub struct LinkHalf { + client: C, authority_set: SharedAuthoritySet>, } /// Make block importer and link half necessary to tie the background voter /// to it. -pub fn block_import, RA>(client: Arc>) - -> Result<(GrandpaBlockImport, LinkHalf), ClientError> +pub fn block_import(client: Arc>) + -> Result<(GrandpaBlockImport, LinkHalf), ClientError> where B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, @@ -881,7 +881,7 @@ pub fn block_import, RA>(client: Arc, N, RA>( config: Config, - link: LinkHalf, + link: LinkHalf>, network: N, ) -> ::client::error::Result> where Block::Hash: Ord, diff --git a/substrate/core/test-client/src/block_builder_ext.rs b/substrate/core/test-client/src/block_builder_ext.rs index 3c334b07a1..81e4bf756c 100644 --- a/substrate/core/test-client/src/block_builder_ext.rs +++ b/substrate/core/test-client/src/block_builder_ext.rs @@ -22,6 +22,7 @@ use keyring; use runtime; use runtime_primitives::traits::ProvideRuntimeApi; use client::block_builder::api::BlockBuilder; +use client::runtime_api::Core as CoreAPI; /// Extension trait for test block builder. pub trait BlockBuilderExt { @@ -31,7 +32,7 @@ pub trait BlockBuilderExt { impl<'a, A> BlockBuilderExt for client::block_builder::BlockBuilder<'a, runtime::Block, A> where A: ProvideRuntimeApi + client::blockchain::HeaderBackend + 'a, - A::Api: BlockBuilder + A::Api: BlockBuilder + CoreAPI, { fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error> { self.push(sign_tx(transfer))