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 MsgTimeoutOnClose to verify the proof of the channel #2535

Merged
merged 6 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion modules/src/core/ics04_channel/handler/timeout_on_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::core::ics04_channel::{
use crate::events::IbcEvent;
use crate::handler::{HandlerOutput, HandlerResult};
use crate::prelude::*;
use crate::proofs::{ProofError, Proofs};

pub fn process(
ctx: &dyn ChannelReader,
Expand Down Expand Up @@ -75,13 +76,20 @@ pub fn process(
source_channel_end.version().clone(),
);

// The message's proofs have the channel proof as `other_proof`
let proof_close = match msg.proofs.other_proof() {
Some(p) => p.clone(),
None => return Err(Error::invalid_proof(ProofError::empty_proof())),
};
let proofs = Proofs::new(proof_close, None, None, None, msg.proofs.height())
.map_err(Error::invalid_proof)?;
verify_channel_proofs(
ctx,
msg.proofs.height(),
&source_channel_end,
&connection_end,
&expected_channel_end,
&msg.proofs,
&proofs,
)?;

let result = if source_channel_end.order_matches(&Order::Ordered) {
Expand Down
7 changes: 6 additions & 1 deletion modules/src/core/ics04_channel/msgs/timeout_on_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ impl TryFrom<RawMsgTimeoutOnClose> for MsgTimeoutOnClose {
.map_err(Error::invalid_proof)?,
None,
None,
None,
Some(
raw_msg
.proof_close
.try_into()
.map_err(Error::invalid_proof)?,
),
raw_msg
.proof_height
.and_then(|raw_height| raw_height.try_into().ok())
Expand Down