@@ -348,7 +348,7 @@ impl TendermintLightClient {
348348 . clone ( ) ,
349349 ) ;
350350
351- let prev_states = self . make_prev_states (
351+ let ( prev_states, trusted_consensus_state_timestamps ) = self . make_prev_states (
352352 ctx,
353353 & client_id,
354354 & client_state,
@@ -357,12 +357,29 @@ impl TendermintLightClient {
357357 misbehaviour. header2( ) . trusted_height. into( ) ,
358358 ] ,
359359 ) ?;
360-
360+ let lc_opts = client_state . as_light_client_options ( ) . unwrap ( ) ;
361361 Ok ( MisbehaviourData {
362362 new_any_client_state : new_client_state. into ( ) ,
363363 message : MisbehaviourProxyMessage {
364364 prev_states,
365- context : ValidationContext :: Empty ,
365+ context : TrustingPeriodContext :: new (
366+ lc_opts. trusting_period ,
367+ lc_opts. clock_drift ,
368+ misbehaviour. header1 ( ) . timestamp ( ) . into ( ) ,
369+ trusted_consensus_state_timestamps[ 0 ] ,
370+ )
371+ . aggregate ( TrustingPeriodContext :: new (
372+ lc_opts. trusting_period ,
373+ lc_opts. clock_drift ,
374+ misbehaviour. header2 ( ) . timestamp ( ) . into ( ) ,
375+ trusted_consensus_state_timestamps[ 1 ] ,
376+ ) )
377+ . map_err ( |e| {
378+ Error :: ics02 ( ICS02Error :: ClientSpecific {
379+ description : e. to_string ( ) ,
380+ } )
381+ } ) ?
382+ . into ( ) ,
366383 client_message : Any :: from ( misbehaviour) ,
367384 } ,
368385 } )
@@ -374,8 +391,9 @@ impl TendermintLightClient {
374391 client_id : & ClientId ,
375392 client_state : & ClientState ,
376393 heights : Vec < Height > ,
377- ) -> Result < Vec < PrevState > , LightClientError > {
394+ ) -> Result < ( Vec < PrevState > , Vec < Time > ) , LightClientError > {
378395 let mut prev_states = Vec :: new ( ) ;
396+ let mut timestamps = Vec :: new ( ) ;
379397 for height in heights {
380398 let ibc_height = height. try_into ( ) . map_err ( Error :: ics02) ?;
381399 let consensus_state: ConsensusState = ctx
@@ -387,13 +405,15 @@ impl TendermintLightClient {
387405 } )
388406 } ) ?
389407 . try_into ( ) ?;
408+ let timestamp = consensus_state. timestamp ( ) . into ( ) ;
390409 let prev_state_id = gen_state_id ( canonicalize_state ( client_state) , consensus_state) ?;
391410 prev_states. push ( PrevState {
392411 height,
393412 state_id : prev_state_id,
394413 } ) ;
414+ timestamps. push ( timestamp) ;
395415 }
396- Ok ( prev_states)
416+ Ok ( ( prev_states, timestamps ) )
397417 }
398418}
399419
0 commit comments