Skip to content

Commit

Permalink
fix: expire client when elapsed time from trusted equals trusting period
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Jul 24, 2024
1 parent d995df7 commit 3d9f02f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [ibc-client-tendermint] Expire a client when the elapsed time from a trusted
header equals the trusting period, to stay consistent with the expiry logic in
`tendermint-rs` ([\#1239](https://github.com/cosmos/ibc-rs/issues/1239))
5 changes: 4 additions & 1 deletion ibc-clients/ics07-tendermint/src/client_state/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ where
if let Some(elapsed_since_latest_consensus_state) =
now.duration_since(&latest_consensus_state.timestamp().into())
{
if elapsed_since_latest_consensus_state > client_state.trusting_period {
// Note: The equality is considered as expired to stay consistent with
// the check in tendermint-rs, where a header at `trusted_header_time +
// trusting_period` is considered as expired.
if elapsed_since_latest_consensus_state >= client_state.trusting_period {
return Ok(Status::Expired);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/tests/core/ics02_client/update_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ fn test_expired_client() {
);

while ctx.ibc_store.host_timestamp().expect("no error")
< (timestamp + trusting_period).expect("no error")
<= (timestamp + trusting_period).expect("no error")
{
ctx.advance_block_height();
}
Expand Down

0 comments on commit 3d9f02f

Please sign in to comment.