Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibc: show client expiry status in channel query #3953

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

avahowell
Copy link
Contributor

Improves ibc q channel(s) so that it will show the status as 'CLIENT EXPIRED' if the underlying client for a channel has expired.

@cratelyn cratelyn added A-IBC Area: IBC integration with Penumbra C-enhancement Category: an enhancement to the codebase labels Mar 5, 2024
Comment on lines +182 to +191
let mut state_str = State::from_i32(channel.state).unwrap().to_string();

let current_time: time::OffsetDateTime = SystemTime::now().into();
let current_time_tm: tendermint::Time = current_time.try_into()?;

let time_elapsed =
current_time_tm.duration_since(tendermint_consensus_state.timestamp)?;
if client_state.expired(time_elapsed) {
state_str = "CLIENT EXPIRED".to_string();
}
Copy link
Contributor

@cratelyn cratelyn Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block is more or less duplicated further down on line 273. it'd be nice* to factor this out into a small helper function or method of tendermint_consensus_state that would do this for us.

expired is already there, so maybe client_state.is_now_expired() -> bool could just use SystemTime::now() and then call expired.

* i shan't block on this, but noticed the duplication

@conorsch
Copy link
Contributor

conorsch commented Mar 6, 2024

For comparison's sake, here's what the change looks like.

Before:

before

###After:
after

Note that the State column shows the expiry info.

@conorsch conorsch merged commit d3bbe4c into main Mar 6, 2024
6 checks passed
@conorsch conorsch deleted the ibc-channel-state-expired-client branch March 6, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-IBC Area: IBC integration with Penumbra C-enhancement Category: an enhancement to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants