From 6838d5c9220dd1237234c5480b67e4568c3d2a4f Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 30 Oct 2022 03:26:31 -0400 Subject: [PATCH] Clean generics in Tendermint with a monolith with associated types --- Cargo.lock | 1 + substrate/tendermint/client/Cargo.toml | 1 + .../tendermint/client/src/block_import.rs | 36 +--- .../tendermint/client/src/import_queue.rs | 44 ++--- substrate/tendermint/client/src/lib.rs | 46 ++++- substrate/tendermint/client/src/tendermint.rs | 172 ++++++------------ substrate/tendermint/client/src/types.rs | 75 ++++++++ substrate/tendermint/client/src/validators.rs | 78 ++------ substrate/tendermint/client/src/verifier.rs | 34 +--- 9 files changed, 218 insertions(+), 269 deletions(-) create mode 100644 substrate/tendermint/client/src/types.rs diff --git a/Cargo.lock b/Cargo.lock index ebf24e6d..2b6ba170 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7536,6 +7536,7 @@ dependencies = [ "pallet-session", "sc-basic-authorship", "sc-client-api", + "sc-client-db", "sc-consensus", "sc-executor", "sc-network", diff --git a/substrate/tendermint/client/Cargo.toml b/substrate/tendermint/client/Cargo.toml index 8e0a9e5a..3b2f2586 100644 --- a/substrate/tendermint/client/Cargo.toml +++ b/substrate/tendermint/client/Cargo.toml @@ -38,6 +38,7 @@ sc-executor = { git = "https://github.com/serai-dex/substrate" } sc-network = { git = "https://github.com/serai-dex/substrate" } sc-network-gossip = { git = "https://github.com/serai-dex/substrate" } sc-service = { git = "https://github.com/serai-dex/substrate" } +sc-client-db = { git = "https://github.com/serai-dex/substrate" } sc-client-api = { git = "https://github.com/serai-dex/substrate" } sc-consensus = { git = "https://github.com/serai-dex/substrate" } diff --git a/substrate/tendermint/client/src/block_import.rs b/substrate/tendermint/client/src/block_import.rs index ae654351..c2e3b9d9 100644 --- a/substrate/tendermint/client/src/block_import.rs +++ b/substrate/tendermint/client/src/block_import.rs @@ -2,45 +2,25 @@ use std::{sync::Arc, collections::HashMap}; use async_trait::async_trait; -use sp_inherents::CreateInherentDataProviders; -use sp_runtime::traits::Block; -use sp_api::TransactionFor; - -use sp_consensus::{Error, CacheKeyId, Environment}; +use sp_consensus::{Error, CacheKeyId}; use sc_consensus::{BlockCheckParams, BlockImportParams, ImportResult, BlockImport}; -use sc_client_api::Backend; - -use sp_tendermint::TendermintApi; - -use crate::{ - tendermint::{TendermintClient, TendermintImport}, - Announce, -}; +use crate::{types::TendermintAuthor, tendermint::TendermintImport}; #[async_trait] -impl< - B: Block, - Be: Backend + 'static, - C: TendermintClient, - CIDP: CreateInherentDataProviders + 'static, - E: Send + Sync + Environment + 'static, - A: Announce, - > BlockImport for TendermintImport +impl BlockImport for TendermintImport where - TransactionFor: Send + Sync + 'static, - Arc: BlockImport>, - as BlockImport>::Error: Into, - C::Api: TendermintApi, + Arc: BlockImport, + as BlockImport>::Error: Into, { type Error = Error; - type Transaction = TransactionFor; + type Transaction = T::BackendTransaction; // TODO: Is there a DoS where you send a block without justifications, causing it to error, // yet adding it to the blacklist in the process preventing further syncing? async fn check_block( &mut self, - mut block: BlockCheckParams, + mut block: BlockCheckParams, ) -> Result { self.verify_order(block.parent_hash, block.number)?; @@ -55,7 +35,7 @@ where async fn import_block( &mut self, - mut block: BlockImportParams>, + mut block: BlockImportParams, new_cache: HashMap>, ) -> Result { self.check(&mut block).await?; diff --git a/substrate/tendermint/client/src/import_queue.rs b/substrate/tendermint/client/src/import_queue.rs index 14256978..aaf7e282 100644 --- a/substrate/tendermint/client/src/import_queue.rs +++ b/substrate/tendermint/client/src/import_queue.rs @@ -8,15 +8,14 @@ use std::{ }; use sp_core::Decode; -use sp_inherents::CreateInherentDataProviders; use sp_runtime::traits::{Header, Block}; -use sp_api::{BlockId, TransactionFor}; +use sp_api::BlockId; -use sp_consensus::{Error, Environment}; +use sp_consensus::Error; use sc_consensus::{BlockImportStatus, BlockImportError, BlockImport, Link, BasicQueue}; use sc_service::ImportQueue; -use sc_client_api::Backend; +use sc_client_api::{HeaderBackend, BlockBackend}; use substrate_prometheus_endpoint::Registry; @@ -25,13 +24,9 @@ use tendermint_machine::{ TendermintMachine, }; -use sp_tendermint::TendermintApi; - use crate::{ - CONSENSUS_ID, - validators::TendermintValidators, - tendermint::{TendermintClient, TendermintImport}, - Announce, + CONSENSUS_ID, types::TendermintAuthor, validators::TendermintValidators, + tendermint::TendermintImport, }; pub type TendermintImportQueue = BasicQueue; @@ -82,28 +77,19 @@ impl<'a, B: Block, T: Send> Future for ImportFuture<'a, B, T> { } } -pub fn import_queue< - B: Block, - Be: Backend + 'static, - C: TendermintClient, - CIDP: CreateInherentDataProviders + 'static, - E: Send + Sync + Environment + 'static, - A: Announce, ->( - client: Arc, - announce: A, - providers: Arc, - env: E, +pub fn import_queue( + client: Arc, + announce: T::Announce, + providers: Arc, + env: T::Environment, spawner: &impl sp_core::traits::SpawnEssentialNamed, registry: Option<&Registry>, -) -> (impl Future, TendermintImportQueue>) +) -> (impl Future, TendermintImportQueue) where - TransactionFor: Send + Sync + 'static, - Arc: BlockImport>, - as BlockImport>::Error: Into, - C::Api: TendermintApi, + Arc: BlockImport, + as BlockImport>::Error: Into, { - let import = TendermintImport::new(client, announce, providers, env); + let import = TendermintImport::::new(client, announce, providers, env); let authority = { let machine_clone = import.machine.clone(); @@ -120,7 +106,7 @@ where Ok(best) => BlockNumber(best + 1), Err(_) => panic!("BlockNumber exceeded u64"), }, - Commit::>::decode( + Commit::>::decode( &mut import_clone .client .justifications(&BlockId::Number(best)) diff --git a/substrate/tendermint/client/src/lib.rs b/substrate/tendermint/client/src/lib.rs index e567c0cc..0a552eb0 100644 --- a/substrate/tendermint/client/src/lib.rs +++ b/substrate/tendermint/client/src/lib.rs @@ -1,7 +1,9 @@ -use std::{sync::Arc, future::Future}; +use std::{marker::PhantomData, boxed::Box, sync::Arc, future::Future, error::Error}; use sp_runtime::traits::Block as BlockTrait; -use sp_api::TransactionFor; +use sp_inherents::CreateInherentDataProviders; +use sp_consensus::DisableProofRecording; +use sp_api::{TransactionFor, ProvideRuntimeApi}; use sc_executor::{NativeVersion, NativeExecutionDispatch, NativeElseWasmExecutor}; use sc_transaction_pool::FullPool; @@ -11,6 +13,9 @@ use substrate_prometheus_endpoint::Registry; use serai_runtime::{self, opaque::Block, RuntimeApi}; +mod types; +use types::{TendermintClientMinimal, TendermintAuthor}; + mod validators; mod tendermint; @@ -49,6 +54,39 @@ pub trait Announce: Send + Sync + Clone + 'static { fn announce(&self, hash: B::Hash); } +struct Cidp; +#[async_trait::async_trait] +impl CreateInherentDataProviders for Cidp { + type InherentDataProviders = (sp_timestamp::InherentDataProvider,); + async fn create_inherent_data_providers( + &self, + _: ::Hash, + _: (), + ) -> Result> { + Ok((sp_timestamp::InherentDataProvider::from_system_time(),)) + } +} + +struct TendermintAuthorFirm>(PhantomData); +impl> TendermintClientMinimal for TendermintAuthorFirm { + type Block = Block; + type Backend = sc_client_db::Backend; + type Api = >::Api; + type Client = FullClient; +} + +impl> TendermintAuthor for TendermintAuthorFirm { + type CIDP = Cidp; + type Environment = sc_basic_authorship::ProposerFactory< + FullPool, + Self::Backend, + Self::Client, + DisableProofRecording, + >; + + type Announce = A; +} + pub fn import_queue>( task_manager: &TaskManager, client: Arc, @@ -56,10 +94,10 @@ pub fn import_queue>( pool: Arc>, registry: Option<&Registry>, ) -> (impl Future, TendermintImportQueue>) { - import_queue::import_queue( + import_queue::import_queue::>( client.clone(), announce, - Arc::new(|_, _| async { Ok(sp_timestamp::InherentDataProvider::from_system_time()) }), + Arc::new(Cidp), sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client, diff --git a/substrate/tendermint/client/src/tendermint.rs b/substrate/tendermint/client/src/tendermint.rs index a2ab4bd8..d40b67bd 100644 --- a/substrate/tendermint/client/src/tendermint.rs +++ b/substrate/tendermint/client/src/tendermint.rs @@ -17,103 +17,48 @@ use sp_runtime::{ Digest, Justification, }; use sp_blockchain::HeaderBackend; -use sp_api::{BlockId, TransactionFor, ProvideRuntimeApi}; +use sp_api::BlockId; use sp_consensus::{Error, BlockOrigin, Proposer, Environment}; -use sc_consensus::{ForkChoiceStrategy, BlockImportParams, BlockImport, import_queue::IncomingBlock}; +use sc_consensus::{ForkChoiceStrategy, BlockImportParams, import_queue::IncomingBlock}; use sc_service::ImportQueue; -use sc_client_api::{BlockBackend, Backend, Finalizer}; +use sc_client_api::Finalizer; use tendermint_machine::{ ext::{BlockError, Commit, Network}, SignedMessage, TendermintHandle, }; -use sp_tendermint::TendermintApi; - use crate::{ CONSENSUS_ID, + types::TendermintAuthor, validators::TendermintValidators, import_queue::{ImportFuture, TendermintImportQueue}, Announce, }; -pub trait TendermintClient + 'static>: - Send - + Sync - + HeaderBackend - + BlockBackend - + BlockImport> - + Finalizer - + ProvideRuntimeApi - + 'static -where - TransactionFor: Send + Sync + 'static, - Self::Api: TendermintApi, -{ -} -impl< - B: Send + Sync + Block + 'static, - Be: Send + Sync + Backend + 'static, - C: Send - + Sync - + HeaderBackend - + BlockBackend - + BlockImport> - + Finalizer - + ProvideRuntimeApi - + 'static, - > TendermintClient for C -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ -} +pub(crate) struct TendermintImport { + _ta: PhantomData, -pub(crate) struct TendermintImport< - B: Block, - Be: Backend + 'static, - C: TendermintClient, - CIDP: CreateInherentDataProviders + 'static, - E: Send + Sync + Environment + 'static, - A: Announce, -> where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ - _block: PhantomData, - _backend: PhantomData, + validators: Arc>, - validators: Arc>, - - importing_block: Arc>>, + importing_block: Arc::Hash>>>, pub(crate) machine: Arc>>>, - pub(crate) client: Arc, - announce: A, - providers: Arc, + pub(crate) client: Arc, + announce: T::Announce, + providers: Arc, - env: Arc>, - pub(crate) queue: Arc>>>>, + env: Arc>, + pub(crate) queue: + Arc>>>, } -impl< - B: Block, - Be: Backend + 'static, - C: TendermintClient, - CIDP: CreateInherentDataProviders + 'static, - E: Send + Sync + Environment + 'static, - A: Announce, - > Clone for TendermintImport -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ +impl Clone for TendermintImport { fn clone(&self) -> Self { TendermintImport { - _block: PhantomData, - _backend: PhantomData, + _ta: PhantomData, validators: self.validators.clone(), @@ -130,27 +75,15 @@ where } } -impl< - B: Block, - Be: Backend + 'static, - C: TendermintClient, - CIDP: CreateInherentDataProviders + 'static, - E: Send + Sync + Environment + 'static, - A: Announce, - > TendermintImport -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ +impl TendermintImport { pub(crate) fn new( - client: Arc, - announce: A, - providers: Arc, - env: E, - ) -> TendermintImport { + client: Arc, + announce: T::Announce, + providers: Arc, + env: T::Environment, + ) -> TendermintImport { TendermintImport { - _block: PhantomData, - _backend: PhantomData, + _ta: PhantomData, validators: Arc::new(TendermintValidators::new(client.clone())), @@ -168,8 +101,8 @@ where async fn check_inherents( &self, - block: B, - providers: CIDP::InherentDataProviders, + block: T::Block, + providers: >::InherentDataProviders, ) -> Result<(), Error> { // TODO Ok(()) @@ -178,8 +111,8 @@ where // Ensure this is part of a sequential import pub(crate) fn verify_order( &self, - parent: B::Hash, - number: ::Number, + parent: ::Hash, + number: <::Header as Header>::Number, ) -> Result<(), Error> { let info = self.client.info(); if (info.best_hash != parent) || ((info.best_number + 1u16.into()) != number) { @@ -193,7 +126,7 @@ where // Tendermint's propose message could be rewritten as a seal OR Tendermint could produce blocks // which this checks the proposer slot for, and then tells the Tendermint machine // While those would be more seamless with Substrate, there's no actual benefit to doing so - fn verify_origin(&self, hash: B::Hash) -> Result<(), Error> { + fn verify_origin(&self, hash: ::Hash) -> Result<(), Error> { if let Some(tm_hash) = *self.importing_block.read().unwrap() { if hash == tm_hash { return Ok(()); @@ -205,14 +138,14 @@ where // Errors if the justification isn't valid pub(crate) fn verify_justification( &self, - hash: B::Hash, + hash: ::Hash, justification: &Justification, ) -> Result<(), Error> { if justification.0 != CONSENSUS_ID { Err(Error::InvalidJustification)?; } - let commit: Commit> = + let commit: Commit> = Commit::decode(&mut justification.1.as_ref()).map_err(|_| Error::InvalidJustification)?; if !self.verify_commit(hash, &commit) { Err(Error::InvalidJustification)?; @@ -223,7 +156,10 @@ where // Verifies the justifications aren't malformed, not that the block is justified // Errors if justifications is neither empty nor a sinlge Tendermint justification // If the block does have a justification, finalized will be set to true - fn verify_justifications(&self, block: &mut BlockImportParams) -> Result<(), Error> { + fn verify_justifications( + &self, + block: &mut BlockImportParams, + ) -> Result<(), Error> { if !block.finalized { if let Some(justifications) = &block.justifications { let mut iter = justifications.iter(); @@ -238,7 +174,10 @@ where Ok(()) } - pub(crate) async fn check(&self, block: &mut BlockImportParams) -> Result<(), Error> { + pub(crate) async fn check( + &self, + block: &mut BlockImportParams, + ) -> Result<(), Error> { if block.finalized { if block.fork_choice.is_none() { // Since we alw1ays set the fork choice, this means something else marked the block as @@ -261,7 +200,7 @@ where if let Some(body) = block.body.clone() { self .check_inherents( - B::new(block.header.clone(), body), + T::Block::new(block.header.clone(), body), self.providers.create_inherent_data_providers(*block.header.parent_hash(), ()).await?, ) .await?; @@ -281,7 +220,7 @@ where Ok(()) } - pub(crate) async fn get_proposal(&mut self, header: &B::Header) -> B { + pub(crate) async fn get_proposal(&mut self, header: &::Header) -> T::Block { let inherent_data = match self.providers.create_inherent_data_providers(header.hash(), ()).await { Ok(providers) => match providers.create_inherent_data() { @@ -315,30 +254,19 @@ where } #[async_trait] -impl< - B: Block, - Be: Backend + 'static, - C: TendermintClient, - CIDP: CreateInherentDataProviders + 'static, - E: Send + Sync + Environment + 'static, - A: Announce, - > Network for TendermintImport -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ +impl Network for TendermintImport { type ValidatorId = u16; - type SignatureScheme = TendermintValidators; - type Weights = TendermintValidators; - type Block = B; + type SignatureScheme = TendermintValidators; + type Weights = TendermintValidators; + type Block = T::Block; const BLOCK_TIME: u32 = { (serai_runtime::MILLISECS_PER_BLOCK / 1000) as u32 }; - fn signature_scheme(&self) -> Arc> { + fn signature_scheme(&self) -> Arc> { self.validators.clone() } - fn weights(&self) -> Arc> { + fn weights(&self) -> Arc> { self.validators.clone() } @@ -362,7 +290,7 @@ where // the node. // // When Tendermint completes, the block is finalized, setting it as the tip regardless of work. - async fn validate(&mut self, block: &B) -> Result<(), BlockError> { + async fn validate(&mut self, block: &T::Block) -> Result<(), BlockError> { let hash = block.hash(); let (header, body) = block.clone().deconstruct(); let parent = *header.parent_hash(); @@ -407,7 +335,11 @@ where Ok(()) } - async fn add_block(&mut self, block: B, commit: Commit>) -> B { + async fn add_block( + &mut self, + block: T::Block, + commit: Commit>, + ) -> T::Block { let hash = block.hash(); let justification = (CONSENSUS_ID, commit.encode()); debug_assert!(self.verify_justification(hash, &justification).is_ok()); diff --git a/substrate/tendermint/client/src/types.rs b/substrate/tendermint/client/src/types.rs new file mode 100644 index 00000000..0573a694 --- /dev/null +++ b/substrate/tendermint/client/src/types.rs @@ -0,0 +1,75 @@ +use sp_inherents::CreateInherentDataProviders; +use sp_runtime::traits::{Header, Block}; + +use sp_blockchain::HeaderBackend; +use sp_api::{StateBackend, StateBackendFor, TransactionFor, ApiExt, ProvideRuntimeApi}; + +use sp_consensus::Environment; +use sc_consensus::BlockImport; + +use sc_client_api::{BlockBackend, Backend, Finalizer}; + +use sp_tendermint::TendermintApi; + +use crate::Announce; + +/// Trait consolidating all generics required by sc_tendermint for processing. +pub trait TendermintClient: Send + Sync + 'static { + type Block: Block; + type Backend: Backend + 'static; + + /// TransactionFor + type BackendTransaction: Send + Sync + 'static; + /// StateBackendFor + type StateBackend: StateBackend< + <::Header as Header>::Hashing, + Transaction = Self::BackendTransaction, + >; + // Client::Api + type Api: ApiExt + TendermintApi; + type Client: Send + + Sync + + HeaderBackend + + BlockBackend + + BlockImport + + Finalizer + + ProvideRuntimeApi + + 'static; +} + +/// Trait implementable on firm types to automatically provide a full TendermintClient impl. +pub trait TendermintClientMinimal: Send + Sync + 'static { + type Block: Block; + type Backend: Backend + 'static; + type Api: ApiExt + TendermintApi; + type Client: Send + + Sync + + HeaderBackend + + BlockBackend + + BlockImport> + + Finalizer + + ProvideRuntimeApi + + 'static; +} + +impl TendermintClient for T +where + >::Api: TendermintApi, + TransactionFor: Send + Sync + 'static, +{ + type Block = T::Block; + type Backend = T::Backend; + + type BackendTransaction = TransactionFor; + type StateBackend = StateBackendFor; + type Api = >::Api; + type Client = T::Client; +} + +/// Trait consolidating additional generics required by sc_tendermint for authoring. +pub trait TendermintAuthor: TendermintClient { + type CIDP: CreateInherentDataProviders + 'static; + type Environment: Send + Sync + Environment + 'static; + + type Announce: Announce; +} diff --git a/substrate/tendermint/client/src/validators.rs b/substrate/tendermint/client/src/validators.rs index 45511aac..c21e3274 100644 --- a/substrate/tendermint/client/src/validators.rs +++ b/substrate/tendermint/client/src/validators.rs @@ -6,17 +6,16 @@ use sp_application_crypto::{ sr25519::{Public, Pair, Signature}, }; -use sp_runtime::traits::Block; use sp_staking::SessionIndex; -use sp_api::{BlockId, TransactionFor}; +use sp_api::{BlockId, ProvideRuntimeApi}; -use sc_client_api::Backend; +use sc_client_api::HeaderBackend; use tendermint_machine::ext::{BlockNumber, Round, Weights, SignatureScheme}; use sp_tendermint::TendermintApi; -use crate::tendermint::TendermintClient; +use crate::types::TendermintClient; struct TendermintValidatorsStruct { session: SessionIndex, @@ -29,13 +28,7 @@ struct TendermintValidatorsStruct { } impl TendermintValidatorsStruct { - fn from_module + 'static, C: TendermintClient>( - client: &Arc, - ) -> TendermintValidatorsStruct - where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, - { + fn from_module(client: &Arc) -> TendermintValidatorsStruct { let last = client.info().best_hash; let api = client.runtime_api(); let session = api.current_session(&BlockId::Hash(last)).unwrap(); @@ -56,23 +49,13 @@ impl TendermintValidatorsStruct { } // Wrap every access of the validators struct in something which forces calling refresh -struct Refresh + 'static, C: TendermintClient> -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ - _block: PhantomData, - _backend: PhantomData, - - client: Arc, +struct Refresh { + _tc: PhantomData, + client: Arc, _refresh: Arc>, } -impl + 'static, C: TendermintClient> Refresh -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ +impl Refresh { // If the session has changed, re-create the struct with the data on it fn refresh(&self) { let session = self._refresh.read().unwrap().session; @@ -83,16 +66,12 @@ where .current_session(&BlockId::Hash(self.client.info().best_hash)) .unwrap() { - *self._refresh.write().unwrap() = TendermintValidatorsStruct::from_module(&self.client); + *self._refresh.write().unwrap() = TendermintValidatorsStruct::from_module::(&self.client); } } } -impl + 'static, C: TendermintClient> Deref for Refresh -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ +impl Deref for Refresh { type Target = RwLock; fn deref(&self) -> &RwLock { self.refresh(); @@ -100,37 +79,19 @@ where } } -pub(crate) struct TendermintValidators< - B: Block, - Be: Backend + 'static, - C: TendermintClient, ->(Refresh) -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi; +pub(crate) struct TendermintValidators(Refresh); -impl + 'static, C: TendermintClient> TendermintValidators -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ - pub(crate) fn new(client: Arc) -> TendermintValidators { +impl TendermintValidators { + pub(crate) fn new(client: Arc) -> TendermintValidators { TendermintValidators(Refresh { - _block: PhantomData, - _backend: PhantomData, - - _refresh: Arc::new(RwLock::new(TendermintValidatorsStruct::from_module(&client))), + _tc: PhantomData, + _refresh: Arc::new(RwLock::new(TendermintValidatorsStruct::from_module::(&client))), client, }) } } -impl + 'static, C: TendermintClient> SignatureScheme - for TendermintValidators -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ +impl SignatureScheme for TendermintValidators { type ValidatorId = u16; type Signature = Signature; type AggregateSignature = Vec; @@ -160,12 +121,7 @@ where } } -impl + 'static, C: TendermintClient> Weights - for TendermintValidators -where - TransactionFor: Send + Sync + 'static, - C::Api: TendermintApi, -{ +impl Weights for TendermintValidators { type ValidatorId = u16; fn total_weight(&self) -> u64 { diff --git a/substrate/tendermint/client/src/verifier.rs b/substrate/tendermint/client/src/verifier.rs index b587a52e..d064a84f 100644 --- a/substrate/tendermint/client/src/verifier.rs +++ b/substrate/tendermint/client/src/verifier.rs @@ -2,41 +2,21 @@ use std::sync::Arc; use async_trait::async_trait; -use sp_inherents::CreateInherentDataProviders; -use sp_runtime::traits::Block; -use sp_api::TransactionFor; - -use sp_consensus::{Error, CacheKeyId, Environment}; +use sp_consensus::{Error, CacheKeyId}; use sc_consensus::{BlockImportParams, BlockImport, Verifier}; -use sc_client_api::Backend; - -use sp_tendermint::TendermintApi; - -use crate::{ - tendermint::{TendermintClient, TendermintImport}, - Announce, -}; +use crate::{types::TendermintAuthor, tendermint::TendermintImport}; #[async_trait] -impl< - B: Block, - Be: Backend + 'static, - C: TendermintClient, - CIDP: CreateInherentDataProviders + 'static, - E: Send + Sync + Environment + 'static, - A: Announce, - > Verifier for TendermintImport +impl Verifier for TendermintImport where - TransactionFor: Send + Sync + 'static, - Arc: BlockImport>, - as BlockImport>::Error: Into, - C::Api: TendermintApi, + Arc: BlockImport, + as BlockImport>::Error: Into, { async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result<(BlockImportParams, Option)>>), String> { + mut block: BlockImportParams, + ) -> Result<(BlockImportParams, Option)>>), String> { self.check(&mut block).await.map_err(|e| format!("{}", e))?; Ok((block, None)) }