@@ -19,7 +19,8 @@ use core::marker::PhantomData;
19
19
use finality_grandpa:: Chain ;
20
20
use ismp:: {
21
21
consensus:: {
22
- ConsensusClient , ConsensusStateId , StateCommitment , StateMachineClient , VerifiedCommitments ,
22
+ ConsensusClient , ConsensusClientId , ConsensusStateId , StateCommitment , StateMachineClient ,
23
+ VerifiedCommitments ,
23
24
} ,
24
25
error:: Error ,
25
26
host:: { IsmpHost , StateMachine } ,
@@ -37,20 +38,26 @@ use verifier::{
37
38
verify_grandpa_finality_proof, verify_parachain_headers_with_grandpa_finality_proof,
38
39
} ;
39
40
40
- pub const POLKADOT_CONSENSUS_STATE_ID : [ u8 ; 8 ] = * b" polkadot" ;
41
- pub const KUSAMA_CONSENSUS_STATE_ID : [ u8 ; 8 ] = * b"_kusama_ " ;
41
+ /// [`ConsensusStateId`] for the polkadot relay chain
42
+ pub const POLKADOT_CONSENSUS_STATE_ID : ConsensusStateId = * b"polk " ;
42
43
43
- pub struct GrandpaConsensusClient < T , H > ( PhantomData < ( T , H ) > ) ;
44
+ /// [`ConsensusStateId`] for the kusama relay chain
45
+ pub const KUSAMA_CONSENSUS_STATE_ID : ConsensusStateId = * b"sama" ;
44
46
45
- impl < T , H > Default for GrandpaConsensusClient < T , H > {
47
+ /// [`ConsensusClientId`] for GRANDPA consensus
48
+ pub const GRANDPA_CONSENSUS_ID : ConsensusClientId = * b"GRAN" ;
49
+
50
+ pub struct GrandpaConsensusClient < T > ( PhantomData < T > ) ;
51
+
52
+ impl < T > Default for GrandpaConsensusClient < T > {
46
53
fn default ( ) -> Self {
47
54
Self ( PhantomData )
48
55
}
49
56
}
50
57
51
- impl < T , H > ConsensusClient for GrandpaConsensusClient < T , H >
58
+ impl < T > ConsensusClient for GrandpaConsensusClient < T >
52
59
where
53
- H : Header < Hash = H256 , Number = u32 > ,
60
+ T :: Header : Header < Hash = H256 , Number = u32 > ,
54
61
T : pallet_ismp:: Config + super :: Config ,
55
62
T :: BlockNumber : Into < u32 > ,
56
63
T :: Hash : From < H256 > ,
@@ -197,15 +204,15 @@ where
197
204
) )
198
205
} ) ?;
199
206
200
- let first_proof: FinalityProof < H > =
201
- codec :: Decode :: decode ( & mut & proof_1 [ .. ] ) . map_err ( |e| {
207
+ let first_proof: FinalityProof < T :: Header > = codec :: Decode :: decode ( & mut & proof_1 [ .. ] )
208
+ . map_err ( |e| {
202
209
Error :: ImplementationSpecific ( format ! (
203
210
"Cannot decode first finality proof from proof_1 bytes: {e:?}" ,
204
211
) )
205
212
} ) ?;
206
213
207
- let second_proof: FinalityProof < H > =
208
- codec :: Decode :: decode ( & mut & proof_2 [ .. ] ) . map_err ( |e| {
214
+ let second_proof: FinalityProof < T :: Header > = codec :: Decode :: decode ( & mut & proof_2 [ .. ] )
215
+ . map_err ( |e| {
209
216
Error :: ImplementationSpecific ( format ! (
210
217
"Cannot decode second finality proof from proof_2 bytes: {e:?}" ,
211
218
) )
@@ -217,13 +224,13 @@ where
217
224
) ) )
218
225
}
219
226
220
- let first_headers = AncestryChain :: < H > :: new ( & first_proof. unknown_headers ) ;
227
+ let first_headers = AncestryChain :: < T :: Header > :: new ( & first_proof. unknown_headers ) ;
221
228
let first_target =
222
229
first_proof. unknown_headers . iter ( ) . max_by_key ( |h| * h. number ( ) ) . ok_or_else ( || {
223
230
Error :: ImplementationSpecific ( format ! ( "Unknown headers can't be empty!" ) )
224
231
} ) ?;
225
232
226
- let second_headers = AncestryChain :: < H > :: new ( & second_proof. unknown_headers ) ;
233
+ let second_headers = AncestryChain :: < T :: Header > :: new ( & second_proof. unknown_headers ) ;
227
234
let second_target =
228
235
second_proof. unknown_headers . iter ( ) . max_by_key ( |h| * h. number ( ) ) . ok_or_else ( || {
229
236
Error :: ImplementationSpecific ( format ! ( "Unknown headers can't be empty!" ) )
@@ -261,14 +268,16 @@ where
261
268
}
262
269
263
270
let first_justification =
264
- GrandpaJustification :: < H > :: decode ( & mut & first_proof. justification [ ..] ) . map_err (
265
- |_| Error :: ImplementationSpecific ( format ! ( "Could not decode first justification" ) ) ,
266
- ) ?;
271
+ GrandpaJustification :: < T :: Header > :: decode ( & mut & first_proof. justification [ ..] )
272
+ . map_err ( |_| {
273
+ Error :: ImplementationSpecific ( format ! ( "Could not decode first justification" ) )
274
+ } ) ?;
267
275
268
276
let second_justification =
269
- GrandpaJustification :: < H > :: decode ( & mut & second_proof. justification [ ..] ) . map_err (
270
- |_| Error :: ImplementationSpecific ( format ! ( "Could not decode second justification" ) ) ,
271
- ) ?;
277
+ GrandpaJustification :: < T :: Header > :: decode ( & mut & second_proof. justification [ ..] )
278
+ . map_err ( |_| {
279
+ Error :: ImplementationSpecific ( format ! ( "Could not decode second justification" ) )
280
+ } ) ?;
272
281
273
282
if first_proof. block != first_justification. commit . target_hash ||
274
283
second_proof. block != second_justification. commit . target_hash
0 commit comments