@@ -34,6 +34,13 @@ use crate::{
3434 DipOriginInfo , DipRelaychainStateProofVerifierError , RelayDipDidProof , RevealedDidKey ,
3535} ;
3636
37+ const PARACHAIN_HEAD_PROOF_TOO_MANY_LEAVES_ERROR_CODE : u8 = 0 ;
38+ const PARACHAIN_HEAD_PROOF_LEAF_TOO_LARGE_ERROR_CODE : u8 = 1 ;
39+ const DIP_COMMITMENT_PROOF_TOO_MANY_LEAVES_ERROR_CODE : u8 = 2 ;
40+ const DIP_COMMITMENT_PROOF_LEAF_TOO_LARGE_ERROR_CODE : u8 = 3 ;
41+ const DIP_PROOF_TOO_MANY_LEAVES_ERROR_CODE : u8 = 4 ;
42+ const DIP_PROOF_LEAF_TOO_LARGE_ERROR_CODE : u8 = 5 ;
43+
3744/// Proof verifier configured given a specific KILT runtime implementation.
3845///
3946/// The generic types are the following:
@@ -160,15 +167,19 @@ impl<
160167 ensure ! (
161168 proof_without_header. provider_head_proof. proof. len( )
162169 <= MAX_PROVIDER_HEAD_PROOF_LEAVE_COUNT . saturated_into( ) ,
163- DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( 0 )
170+ DipRelaychainStateProofVerifierError :: ProofComponentTooLarge (
171+ PARACHAIN_HEAD_PROOF_TOO_MANY_LEAVES_ERROR_CODE
172+ )
164173 ) ;
165174 ensure ! (
166175 proof_without_header
167176 . provider_head_proof
168177 . proof
169178 . iter( )
170179 . all( |l| l. len( ) <= MAX_PROVIDER_HEAD_PROOF_LEAVE_SIZE . saturated_into( ) ) ,
171- DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( 1 )
180+ DipRelaychainStateProofVerifierError :: ProofComponentTooLarge (
181+ PARACHAIN_HEAD_PROOF_LEAF_TOO_LARGE_ERROR_CODE
182+ )
172183 ) ;
173184 let proof_without_relaychain = proof_without_header
174185 . verify_provider_head_proof :: < ConsumerRuntime :: Hashing , HeaderFor < KiltRuntime > > ( KILT_PARA_ID )
@@ -178,15 +189,19 @@ impl<
178189 ensure ! (
179190 proof_without_relaychain. dip_commitment_proof. 0 . len( )
180191 <= MAX_DIP_COMMITMENT_PROOF_LEAVE_COUNT . saturated_into( ) ,
181- DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( 2 )
192+ DipRelaychainStateProofVerifierError :: ProofComponentTooLarge (
193+ DIP_COMMITMENT_PROOF_TOO_MANY_LEAVES_ERROR_CODE
194+ )
182195 ) ;
183196 ensure ! (
184197 proof_without_relaychain
185198 . dip_commitment_proof
186199 . 0
187200 . iter( )
188201 . all( |l| l. len( ) <= MAX_DIP_COMMITMENT_PROOF_LEAVE_SIZE . saturated_into( ) ) ,
189- DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( 3 )
202+ DipRelaychainStateProofVerifierError :: ProofComponentTooLarge (
203+ DIP_COMMITMENT_PROOF_LEAF_TOO_LARGE_ERROR_CODE
204+ )
190205 ) ;
191206 let proof_without_parachain = proof_without_relaychain
192207 . verify_dip_commitment_proof_for_subject :: < KiltRuntime :: Hashing , KiltRuntime > ( subject)
@@ -195,15 +210,15 @@ impl<
195210 // 4. Verify DIP Merkle proof.
196211 ensure ! (
197212 proof_without_parachain. dip_proof. blinded. len( ) <= MAX_DID_MERKLE_PROOF_LEAVE_COUNT . saturated_into( ) ,
198- DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( 4 )
213+ DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( DIP_PROOF_TOO_MANY_LEAVES_ERROR_CODE )
199214 ) ;
200215 ensure ! (
201216 proof_without_parachain
202217 . dip_proof
203218 . blinded
204219 . iter( )
205220 . all( |l| l. len( ) <= MAX_DID_MERKLE_PROOF_LEAVE_SIZE . saturated_into( ) ) ,
206- DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( 5 )
221+ DipRelaychainStateProofVerifierError :: ProofComponentTooLarge ( DIP_PROOF_LEAF_TOO_LARGE_ERROR_CODE )
207222 ) ;
208223 let proof_without_dip_merkle = proof_without_parachain
209224 . verify_dip_proof :: < KiltRuntime :: Hashing , MAX_DID_MERKLE_LEAVES_REVEALED > ( )
0 commit comments