From c4e51bc89abdc102ef4840ffa240602d63f1b85c Mon Sep 17 00:00:00 2001 From: Ava Howell Date: Tue, 14 May 2024 14:51:33 -0700 Subject: [PATCH] fix connection+channel ack: only acccept acks on INIT states --- .../ibc/src/component/msg_handler/channel_open_ack.rs | 2 +- .../ibc/src/component/msg_handler/connection_open_ack.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/core/component/ibc/src/component/msg_handler/channel_open_ack.rs b/crates/core/component/ibc/src/component/msg_handler/channel_open_ack.rs index 9f1c88a94a..3e7accd673 100644 --- a/crates/core/component/ibc/src/component/msg_handler/channel_open_ack.rs +++ b/crates/core/component/ibc/src/component/msg_handler/channel_open_ack.rs @@ -110,7 +110,7 @@ impl MsgHandler for MsgChannelOpenAck { } fn channel_state_is_correct(channel: &ChannelEnd) -> anyhow::Result<()> { - if channel.state == ChannelState::Init || channel.state == ChannelState::TryOpen { + if channel.state == ChannelState::Init { Ok(()) } else { Err(anyhow::anyhow!("channel is not in the correct state")) diff --git a/crates/core/component/ibc/src/component/msg_handler/connection_open_ack.rs b/crates/core/component/ibc/src/component/msg_handler/connection_open_ack.rs index cd896d7bea..661d9feb6c 100644 --- a/crates/core/component/ibc/src/component/msg_handler/connection_open_ack.rs +++ b/crates/core/component/ibc/src/component/msg_handler/connection_open_ack.rs @@ -230,11 +230,10 @@ async fn verify_previous_connection( // see // https://github.com/cosmos/ibc/blob/master/spec/core/ics-003-connection-semantics/README.md + // // for this validation logic - let state_is_consistent = connection.state_matches(&State::Init) - && connection.versions.contains(&msg.version) - || connection.state_matches(&State::TryOpen) - && connection.versions.get(0).eq(&Some(&msg.version)); + let state_is_consistent = + connection.state_matches(&State::Init) && connection.versions.contains(&msg.version); if !state_is_consistent { anyhow::bail!("connection is not in the correct state");