Skip to content

Commit

Permalink
fix connection+channel ack: only acccept acks on INIT states
Browse files Browse the repository at this point in the history
  • Loading branch information
avahowell committed May 14, 2024
1 parent 9f4abd0 commit c4e51bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,10 @@ async fn verify_previous_connection<S: StateRead>(

// 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");
Expand Down

0 comments on commit c4e51bc

Please sign in to comment.