@@ -23,7 +23,6 @@ pub fn verify_header_update(
2323 return Err ( VerificationError :: Invalid ( "Trusted state is frozen" . to_string ( ) ) ) ;
2424 }
2525
26-
2726 let chain_id = Id :: try_from ( trusted_state. chain_id . clone ( ) )
2827 . map_err ( |e| VerificationError :: Invalid ( e. to_string ( ) ) ) ?;
2928 let height = Height :: try_from ( trusted_state. height )
@@ -53,7 +52,7 @@ pub fn verify_header_update(
5352 next_validators : Some ( & next_validators_proof) ,
5453 } ;
5554
56- let verifier_options = convert_verification_options ( & options) ?;
55+ let verifier_options = convert_verification_options ( & options, trusted_state . trusting_period_duration ( ) ) ?;
5756 let now = convert_timestamp ( current_time) ?;
5857
5958 let verifier = ProdVerifier :: default ( ) ;
@@ -115,7 +114,7 @@ pub fn verify_misbehaviour_header(
115114 next_validators : Some ( & next_validators_proof) ,
116115 } ;
117116
118- let verifier_options = convert_verification_options ( & options) ?;
117+ let verifier_options = convert_verification_options ( & options, trusted_state . trusting_period_duration ( ) ) ?;
119118 let now = convert_timestamp ( current_time) ?;
120119
121120 let verifier = ProdVerifier :: default ( ) ;
@@ -213,6 +212,7 @@ pub fn verify_commit_against_trusted(
213212 next_validators_hash,
214213 } ;
215214
215+ // Convert consensus proof
216216 let validators = ValidatorSet :: new ( consensus_proof. validators . clone ( ) , None ) ;
217217 let next_validators_proof = ValidatorSet :: new (
218218 consensus_proof. next_validators . clone ( ) . unwrap_or_default ( ) ,
@@ -225,7 +225,7 @@ pub fn verify_commit_against_trusted(
225225 next_validators : Some ( & next_validators_proof) ,
226226 } ;
227227
228- let verifier_options = convert_verification_options ( options) ?;
228+ let verifier_options = convert_verification_options ( options, trusted_state . trusting_period_duration ( ) ) ?;
229229 let verifier = ProdVerifier :: default ( ) ;
230230
231231 let result = verifier. verify_commit_against_trusted (
@@ -317,7 +317,7 @@ pub fn validate_consensus_proof_against_trusted(
317317
318318// Helper functions for type conversion
319319
320- fn convert_verification_options ( options : & VerificationOptions ) -> Result < Options , VerificationError > {
320+ fn convert_verification_options ( options : & VerificationOptions , trusting_period : Duration ) -> Result < Options , VerificationError > {
321321 let trust_threshold = TrustThreshold :: new (
322322 options. trust_threshold_numerator ,
323323 options. trust_threshold_denominator
@@ -327,7 +327,7 @@ fn convert_verification_options(options: &VerificationOptions) -> Result<Options
327327
328328 Ok ( Options {
329329 trust_threshold,
330- trusting_period : Duration :: from_secs ( 3600 ) , // Default 1 hour, should be configurable
330+ trusting_period,
331331 clock_drift : options. clock_drift_duration ( ) ,
332332 } )
333333}
0 commit comments