From aabb6baba8347cf7db3a7d9513c44a9c8e835ac1 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 | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/modules/tendermint-lc/src/client.rs b/modules/tendermint-lc/src/client.rs index 40c724ac..9082ffdf 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,30 @@ 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: ValidationContext::TrustingPeriod(TrustingPeriodContext::new( + lc_opts.trusting_period, + lc_opts.clock_drift, + misbehaviour.header1().timestamp().into(), + trusted_consensus_state_timestamps[0], + )) + .aggregate(ValidationContext::TrustingPeriod( + 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(), + }) + })?, client_message: Any::from(misbehaviour), }, }) @@ -374,8 +392,9 @@ impl TendermintLightClient { client_id: &ClientId, client_state: &ClientState, heights: Vec, - ) -> Result, LightClientError> { + ) -> Result<(Vec, Vec