Skip to content

Commit

Permalink
add trusting period validation for misbehaviour
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Nov 5, 2024
1 parent e435435 commit adabf46
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/ibc/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl<const SYNC_COMMITTEE_SIZE: usize> Ics2ClientState for ClientState<SYNC_COMM

let cc = self.build_context(ctx);
let trusted_consensus_state = TrustedConsensusState::new(
consensus_state,
consensus_state.clone(),
misbehaviour.trusted_sync_committee.sync_committee,
misbehaviour.trusted_sync_committee.is_next,
)?;
Expand All @@ -428,6 +428,17 @@ impl<const SYNC_COMMITTEE_SIZE: usize> Ics2ClientState for ClientState<SYNC_COMM
.validate_misbehaviour(&cc, &trusted_consensus_state, misbehaviour.data)
.map_err(Error::VerificationError)?;

let host_timestamp = ctx
.host_timestamp()
.map_err(|e| ClientError::ClientSpecific {
description: e.to_string(),
})?;
validate_state_timestamp_within_trusting_period(
host_timestamp,
self.trusting_period,
consensus_state.timestamp,
)?;

// found misbehaviour
Ok(self
.clone()
Expand Down

0 comments on commit adabf46

Please sign in to comment.