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

Fix issue with PacketReceiptNotFound error returned by get_packet_receipt method #410

Merged
merged 5 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fix the caught error by `get_packet_receipt` under `val_exec_ctx` feature when
the packet receipt is not found
([#409](https://github.com/cosmos/ibc-rs/issues/409))
24 changes: 14 additions & 10 deletions crates/ibc/src/core/ics04_channel/handler/recv_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::events::IbcEvent;
use crate::handler::{HandlerOutput, HandlerResult};
use crate::timestamp::Expiry;
use alloc::string::ToString;

#[cfg(feature = "val_exec_ctx")]
pub(crate) use val_exec_ctx::*;
Expand Down Expand Up @@ -128,12 +127,21 @@ pub(crate) mod val_exec_ctx {
validate_write_acknowledgement(ctx_b, msg)?;
}
} else {
ctx_b.get_packet_receipt(&(
let packet_rec = ctx_b.get_packet_receipt(&(
msg.packet.port_on_b.clone(),
msg.packet.chan_on_b.clone(),
msg.packet.sequence,
))?;

));
match packet_rec {
Ok(_receipt) => {}
Err(ContextError::PacketError(PacketError::PacketReceiptNotFound { sequence }))
if sequence == msg.packet.sequence => {}
Err(_) => {
return Err(ContextError::PacketError(
PacketError::ImplementationSpecific,
))
Farhad-Shabani marked this conversation as resolved.
Show resolved Hide resolved
}
}
// Case where the recvPacket is successful and an
// acknowledgement will be written (not a no-op)
validate_write_acknowledgement(ctx_b, msg)?;
Expand Down Expand Up @@ -305,12 +313,8 @@ pub(crate) fn process<Ctx: ChannelReader>(

match packet_rec {
Ok(_receipt) => PacketResult::Recv(RecvPacketResult::NoOp),
Err(e)
if e.to_string()
== PacketError::PacketReceiptNotFound {
sequence: msg.packet.sequence,
}
.to_string() =>
Err(PacketError::PacketReceiptNotFound { sequence })
if sequence == msg.packet.sequence =>
{
// store a receipt that does not contain any data
PacketResult::Recv(RecvPacketResult::Unordered {
Expand Down