Skip to content

Commit

Permalink
ibc: error on attempts to send packets with expired client
Browse files Browse the repository at this point in the history
  • Loading branch information
avahowell committed Mar 1, 2024
1 parent 553b344 commit 6f95faf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/core/component/ibc/src/component/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ibc_types::core::{
channel::{channel::State as ChannelState, events, ChannelId, Packet, PortId},
client::Height,
};
use penumbra_sct::component::clock::EpochRead;

use crate::component::{
channel::{StateReadExt as _, StateWriteExt as _},
Expand Down Expand Up @@ -129,6 +130,17 @@ pub trait SendPacketRead: StateRead {
anyhow::bail!("client {} is frozen", &connection.client_id);
}

let latest_consensus_state = self
.get_verified_consensus_state(&client_state.latest_height(), &connection.client_id)
.await?;

let current_block_time = self.get_block_timestamp().await?;
let time_elapsed = current_block_time.duration_since(latest_consensus_state.timestamp)?;

if client_state.expired(time_elapsed) {
anyhow::bail!("client {} is expired", &connection.client_id);
}

let latest_height = client_state.latest_height();

// check that time timeout height hasn't already passed in the local client tracking the
Expand Down

0 comments on commit 6f95faf

Please sign in to comment.