@@ -35,7 +35,7 @@ use sc_consensus_slots::{CheckedHeader, check_equivocation};
3535use sc_telemetry:: { CONSENSUS_DEBUG , CONSENSUS_TRACE , TelemetryHandle , telemetry} ;
3636use sp_api:: { ApiExt , ProvideRuntimeApi } ;
3737use sp_block_builder:: BlockBuilder as BlockBuilderApi ;
38- use sp_blockchain:: HeaderBackend ;
38+ use sp_blockchain:: { HeaderBackend , HeaderMetadata } ;
3939use sp_consensus:: Error as ConsensusError ;
4040use sp_consensus_aura:: AuraApi ;
4141use sp_consensus_slots:: Slot ;
@@ -107,25 +107,25 @@ where
107107}
108108
109109/// A verifier for Aura blocks, with added ID phantom type.
110- pub struct AuraVerifier < C , P , CIDP , N , ID > {
110+ pub struct AuraVerifier < C , P : Pair , CIDP , B : BlockT , ID > {
111111 client : Arc < C > ,
112112 create_inherent_data_providers : CIDP ,
113113 check_for_equivocation : CheckForEquivocation ,
114114 telemetry : Option < TelemetryHandle > ,
115- compatibility_mode : CompatibilityMode < N > ,
115+ compatibility_mode : CompatibilityMode < NumberFor < B > > ,
116116 _phantom : PhantomData < ( fn ( ) -> P , ID ) > ,
117117}
118118
119- impl < C , P , CIDP , N , ID > AuraVerifier < C , P , CIDP , N , ID > {
119+ impl < C , P : Pair , CIDP , B : BlockT , ID > AuraVerifier < C , P , CIDP , B , ID > {
120120 pub ( crate ) fn new (
121121 client : Arc < C > ,
122122 create_inherent_data_providers : CIDP ,
123123 check_for_equivocation : CheckForEquivocation ,
124124 telemetry : Option < TelemetryHandle > ,
125- compatibility_mode : CompatibilityMode < N > ,
125+ compatibility_mode : CompatibilityMode < NumberFor < B > > ,
126126 ) -> Self {
127127 Self {
128- client,
128+ client : client . clone ( ) ,
129129 create_inherent_data_providers,
130130 check_for_equivocation,
131131 telemetry,
@@ -135,47 +135,16 @@ impl<C, P, CIDP, N, ID> AuraVerifier<C, P, CIDP, N, ID> {
135135 }
136136}
137137
138- impl < C , P , CIDP , N , ID > AuraVerifier < C , P , CIDP , N , ID >
139- where
140- CIDP : Send ,
141- {
142- async fn check_inherents < B : BlockT > (
143- & self ,
144- block : B ,
145- at_hash : B :: Hash ,
146- inherent_data_providers : CIDP :: InherentDataProviders ,
147- ) -> Result < ( ) , Error < B > >
148- where
149- C : ProvideRuntimeApi < B > ,
150- C :: Api : BlockBuilderApi < B > ,
151- CIDP : CreateInherentDataProviders < B , ( Slot , <ID as InherentDigest >:: Value ) > ,
152- ID : InherentDigest ,
153- {
154- let inherent_data = create_inherent_data :: < B > ( & inherent_data_providers) . await ?;
155-
156- let inherent_res = self
157- . client
158- . runtime_api ( )
159- . check_inherents ( at_hash, block, inherent_data)
160- . map_err ( |e| Error :: Client ( e. into ( ) ) ) ?;
161-
162- if !inherent_res. ok ( ) {
163- for ( i, e) in inherent_res. into_errors ( ) {
164- match inherent_data_providers. try_handle_error ( & i, & e) . await {
165- Some ( res) => res. map_err ( Error :: Inherent ) ?,
166- None => return Err ( Error :: UnknownInherentError ( i) ) ,
167- }
168- }
169- }
170-
171- Ok ( ( ) )
172- }
173- }
174-
175138#[ async_trait:: async_trait]
176- impl < B : BlockT , C , P , CIDP , ID > Verifier < B > for AuraVerifier < C , P , CIDP , NumberFor < B > , ID >
139+ impl < B , C , P , CIDP , ID > Verifier < B > for AuraVerifier < C , P , CIDP , B , ID >
177140where
178- C : ProvideRuntimeApi < B > + Send + Sync + AuxStore ,
141+ B : BlockT ,
142+ C : HeaderBackend < B >
143+ + HeaderMetadata < B , Error = sp_blockchain:: Error >
144+ + ProvideRuntimeApi < B >
145+ + Send
146+ + Sync
147+ + sc_client_api:: backend:: AuxStore ,
179148 C :: Api : BlockBuilderApi < B > + AuraApi < B , AuthorityId < P > > + ApiExt < B > ,
180149 P : Pair ,
181150 P :: Public : Codec + Debug ,
@@ -255,13 +224,17 @@ where
255224 . has_api_with :: < dyn BlockBuilderApi < B > , _ > ( parent_hash, |v| v >= 2 )
256225 . map_err ( |e| e. to_string ( ) ) ?
257226 {
258- self . check_inherents (
259- new_block. clone ( ) ,
227+ let inherent_data =
228+ create_inherent_data :: < B > ( & inherent_data_providers) . await ?;
229+ sp_block_builder:: check_inherents_with_data (
230+ self . client . clone ( ) ,
260231 parent_hash,
261- inherent_data_providers,
232+ new_block. clone ( ) ,
233+ & inherent_data_providers,
234+ inherent_data,
262235 )
263236 . await
264- . map_err ( |e| e . to_string ( ) ) ?;
237+ . map_err ( |e| format ! ( "Error checking block inherents {:?}" , e ) ) ?;
265238 }
266239
267240 let ( _, inner_body) = new_block. deconstruct ( ) ;
@@ -323,7 +296,8 @@ where
323296 + Sync
324297 + AuxStore
325298 + UsageProvider < Block >
326- + HeaderBackend < Block > ,
299+ + HeaderBackend < Block >
300+ + HeaderMetadata < Block , Error = sp_blockchain:: Error > ,
327301 I : BlockImport < Block , Error = ConsensusError > + Send + Sync + ' static ,
328302 P : Pair + ' static ,
329303 P :: Public : Codec + Debug ,
0 commit comments