From 420be9656f0dbb7ebd7bec86edbe04dd24c14626 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Tue, 6 Feb 2024 18:43:00 +0900 Subject: [PATCH] tendermint-lc: set TrustingPeriodContext to message Signed-off-by: Jun Kimura --- modules/tendermint-lc/src/client.rs | 30 ++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/tendermint-lc/src/client.rs b/modules/tendermint-lc/src/client.rs index 40c724ac..c3ad65d7 100644 --- a/modules/tendermint-lc/src/client.rs +++ b/modules/tendermint-lc/src/client.rs @@ -348,7 +348,7 @@ impl TendermintLightClient { .clone(), ); - let prev_states = self.make_prev_states( + let (prev_states, trusted_consensus_state_timestamps) = self.make_prev_states( ctx, &client_id, &client_state, @@ -357,12 +357,29 @@ impl TendermintLightClient { misbehaviour.header2().trusted_height.into(), ], )?; - + let lc_opts = client_state.as_light_client_options().unwrap(); Ok(MisbehaviourData { new_any_client_state: new_client_state.into(), message: MisbehaviourProxyMessage { prev_states, - context: ValidationContext::Empty, + context: TrustingPeriodContext::new( + lc_opts.trusting_period, + lc_opts.clock_drift, + misbehaviour.header1().timestamp().into(), + trusted_consensus_state_timestamps[0], + ) + .aggregate(TrustingPeriodContext::new( + lc_opts.trusting_period, + lc_opts.clock_drift, + misbehaviour.header2().timestamp().into(), + trusted_consensus_state_timestamps[1], + )) + .map_err(|e| { + Error::ics02(ICS02Error::ClientSpecific { + description: e.to_string(), + }) + })? + .into(), client_message: Any::from(misbehaviour), }, }) @@ -374,8 +391,9 @@ impl TendermintLightClient { client_id: &ClientId, client_state: &ClientState, heights: Vec, - ) -> Result, LightClientError> { + ) -> Result<(Vec, Vec