Skip to content

Commit

Permalink
imp: recv packet timeout check
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Jul 30, 2024
1 parent de40b9b commit 87aaa0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion contracts/ics26-router/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ mod execute {
#[allow(clippy::needless_pass_by_value)]
pub fn recv_packet(
deps: DepsMut,
_env: Env,
env: Env,
info: MessageInfo,
msg: RecvPacketMsg,
) -> Result<Response, ContractError> {
Expand Down Expand Up @@ -229,6 +229,9 @@ mod execute {
.client_querier(packet.destination_channel.as_str())?
.verify_membership(verify_membership_msg)?;

// Ensure the timeout is valid.
utils::timeout::validate(&env, &packet.timeout)?;

state::helpers::set_packet_receipt(deps.storage, &packet)?;

let event = events::recv_packet::success(&packet);
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/utils/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn validate(env: &Env, timeout: &IbcTimeout) -> Result<(), ContractError> {
.timestamp()
.ok_or(ContractError::EmptyTimestamp)
.and_then(|ts| {
if env.block.time > ts {
if env.block.time >= ts {
return Err(ContractError::invalid_timeout_timestamp(
env.block.time.seconds(),
ts.seconds(),
Expand Down

0 comments on commit 87aaa0f

Please sign in to comment.