From 0657501c9170f9ec5bc2ff05975fcc9069197f93 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 31 Mar 2023 11:17:43 -0500 Subject: [PATCH 01/99] Add new channel states --- .../relayer-types/src/core/ics04_channel/channel.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 8b675e1c51..9291d67c48 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -371,6 +371,12 @@ impl FromStr for Order { } } +/// The possible state variants that a channel can exhibit. +/// +/// These are encoded with integer discriminants so that there is +/// an easy way to compare channel states against one another. More +/// explicitly, there is a partial ordering around the channel state +/// variants, with the `Uninitialized` state being the smallest. #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum State { Uninitialized = 0, @@ -378,6 +384,8 @@ pub enum State { TryOpen = 2, Open = 3, Closed = 4, + InitUpgrade = 5, + TryUpgrade = 6, } impl State { @@ -389,6 +397,8 @@ impl State { Self::TryOpen => "TRYOPEN", Self::Open => "OPEN", Self::Closed => "CLOSED", + Self::InitUpgrade => "INITUPGRADE", + Self::TryUpgrade => "TRYUPGRADE", } } @@ -400,6 +410,8 @@ impl State { 2 => Ok(Self::TryOpen), 3 => Ok(Self::Open), 4 => Ok(Self::Closed), + 5 => Ok(Self::InitUpgrade), + 6 => Ok(Self::TryUpgrade), _ => Err(Error::unknown_state(s)), } } From b3b0ebcfd1819c98f7c5c28ba1a13b2f0edaebc3 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 31 Mar 2023 12:34:45 -0500 Subject: [PATCH 02/99] Change channel state enum discriminants --- .../relayer-types/src/core/ics04_channel/channel.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 9291d67c48..e273dbea87 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -383,9 +383,9 @@ pub enum State { Init = 1, TryOpen = 2, Open = 3, - Closed = 4, - InitUpgrade = 5, - TryUpgrade = 6, + InitUpgrade = 4, + TryUpgrade = 5, + Closed = 6, } impl State { @@ -409,9 +409,9 @@ impl State { 1 => Ok(Self::Init), 2 => Ok(Self::TryOpen), 3 => Ok(Self::Open), - 4 => Ok(Self::Closed), - 5 => Ok(Self::InitUpgrade), - 6 => Ok(Self::TryUpgrade), + 4 => Ok(Self::InitUpgrade), + 5 => Ok(Self::TryUpgrade), + 6 => Ok(Self::Closed), _ => Err(Error::unknown_state(s)), } } From b8b0c2f80dad0c9d90cbecafdc77139fac9edadf Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 31 Mar 2023 14:27:24 -0500 Subject: [PATCH 03/99] Update channel state doc comment --- crates/relayer-types/src/core/ics04_channel/channel.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index e273dbea87..66c4b982c5 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -375,8 +375,9 @@ impl FromStr for Order { /// /// These are encoded with integer discriminants so that there is /// an easy way to compare channel states against one another. More -/// explicitly, there is a partial ordering around the channel state -/// variants, with the `Uninitialized` state being the smallest. +/// explicitly, this is an attempt to capture the lifecycle of a +/// channel, beginning from the `Uninitialized` state, through the +/// `Open` state, before finally being `Closed`. #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum State { Uninitialized = 0, From 98dd3fc2169894c769a2d246b985eadd41941ab9 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 4 Apr 2023 15:03:46 -0500 Subject: [PATCH 04/99] Stub out channel upgrade CLI commands --- crates/relayer-cli/src/commands/tx/channel.rs | 132 ++++++++++++++++++ crates/relayer/src/channel.rs | 16 +-- 2 files changed, 140 insertions(+), 8 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 18ee4d2565..918d6ef7b2 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -666,6 +666,138 @@ impl Runnable for TxChanCloseConfirmCmd { } } +/// Build and send a `ChanUpgradeInit` message to a destination +/// chain that the source chain has an already-existing channel open +/// with, signaling the intent by the source chain to perform +/// the channel upgrade handshake. +#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] +pub struct TxChanUpgradeInitCmd { + #[clap( + long = "dst-chain", + required = true, + value_name = "DST_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination chain" + )] + dst_chain_id: ChainId, + + #[clap( + long = "src-chain", + required = true, + value_name = "SRC_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the source chain" + )] + src_chain_id: ChainId, + + #[clap( + long = "dst-connection", + visible_alias = "dst-conn", + required = true, + value_name = "DST_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection" + )] + dst_conn_id: ConnectionId, + + #[clap( + long = "dst-port", + required = true, + value_name = "DST_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination port" + )] + dst_port_id: PortId, + + #[clap( + long = "src-port", + required = true, + value_name = "SRC_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the source port" + )] + src_port_id: PortId, +} + +impl Runnable for TxChanUpgradeInitCmd { + fn run(&self) {} +} + +/// Build and send a `ChanUpgradeTry` message in response to +/// a `ChanUpgradeInnit` message, signaling the chain's intent to +/// cooperate with the source chain on upgrading the specified channel +/// and initiating the upgrade handshake. +#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] +pub struct TxChanUpgradeTryCmd { + #[clap( + long = "dst-chain", + required = true, + value_name = "DST_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination chain" + )] + dst_chain_id: ChainId, + + #[clap( + long = "src-chain", + required = true, + value_name = "SRC_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the source chain" + )] + src_chain_id: ChainId, + + #[clap( + long = "dst-connection", + visible_alias = "dst-conn", + required = true, + value_name = "DST_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection" + )] + dst_conn_id: ConnectionId, + + #[clap( + long = "dst-port", + required = true, + value_name = "DST_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination port" + )] + dst_port_id: PortId, + + #[clap( + long = "src-port", + required = true, + value_name = "SRC_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the source port" + )] + src_port_id: PortId, + + #[clap( + long = "src-channel", + visible_alias = "src-chan", + required = true, + value_name = "SRC_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" + )] + src_chan_id: ChannelId, + + #[clap( + long = "dst-channel", + visible_alias = "dst-chan", + value_name = "DST_CHANNEL_ID", + help = "Identifier of the destination channel (optional)" + )] + dst_chan_id: Option, +} + +impl Runnable for TxChanUpgradeTryCmd { + fn run(&self) {} +} + #[cfg(test)] mod tests { use super::{ diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index c97d09ce34..298ffae4e8 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -610,7 +610,7 @@ impl Channel { ); match (a_state, b_state) { - // send the Init message to chain a (source) + // send the Init message to chain A (source) (State::Uninitialized, State::Uninitialized) => { let event = self .flipped() @@ -623,7 +623,7 @@ impl Channel { self.a_side.channel_id = Some(channel_id.clone()); } - // send the Try message to chain a (source) + // send the Try message to chain A (source) (State::Uninitialized, State::Init) | (State::Init, State::Init) => { let event = self.flipped().build_chan_open_try_and_send().map_err(|e| { error!("failed ChanOpenTry {}: {}", self.a_side, e); @@ -634,7 +634,7 @@ impl Channel { self.a_side.channel_id = Some(channel_id.clone()); } - // send the Try message to chain b (destination) + // send the Try message to chain B (destination) (State::Init, State::Uninitialized) => { let event = self.build_chan_open_try_and_send().map_err(|e| { error!("failed ChanOpenTry {}: {}", self.b_side, e); @@ -645,7 +645,7 @@ impl Channel { self.b_side.channel_id = Some(channel_id.clone()); } - // send the Ack message to chain a (source) + // send the Ack message to chain A (source) (State::Init, State::TryOpen) | (State::TryOpen, State::TryOpen) => { self.flipped().build_chan_open_ack_and_send().map_err(|e| { error!("failed ChanOpenAck {}: {}", self.a_side, e); @@ -653,7 +653,7 @@ impl Channel { })?; } - // send the Ack message to chain b (destination) + // send the Ack message to chain B (destination) (State::TryOpen, State::Init) => { self.build_chan_open_ack_and_send().map_err(|e| { error!("failed ChanOpenAck {}: {}", self.b_side, e); @@ -661,7 +661,7 @@ impl Channel { })?; } - // send the Confirm message to chain b (destination) + // send the Confirm message to chain B (destination) (State::Open, State::TryOpen) => { self.build_chan_open_confirm_and_send().map_err(|e| { error!("failed ChanOpenConfirm {}: {}", self.b_side, e); @@ -669,7 +669,7 @@ impl Channel { })?; } - // send the Confirm message to chain a (source) + // send the Confirm message to chain A (source) (State::TryOpen, State::Open) => { self.flipped() .build_chan_open_confirm_and_send() @@ -903,7 +903,7 @@ impl Channel { } /// Retrieves the channel from destination and compares it - /// against the expected channel. built from the message type [`ChannelMsgType`]. + /// against the expected channel. Built from the message type [`ChannelMsgType`]. /// /// If the expected and the destination channels are compatible, /// returns the expected channel From ca83021c5dcfa2b5b1ad242b7c55a7838e934803 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 5 Apr 2023 09:21:50 -0500 Subject: [PATCH 05/99] Use tx_chan_cmd macro for TxChanOpenInit command --- crates/relayer-cli/src/commands/tx/channel.rs | 90 +++++++++---------- 1 file changed, 40 insertions(+), 50 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 918d6ef7b2..5a204eaf11 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -16,6 +16,19 @@ use crate::conclude::Output; use crate::error::Error; use crate::prelude::*; +/// Macro that generates the `Runnable::run` implementation for a +/// `tx channel` subcommand. +/// +/// The macro takes the following arguments: +/// - `$dbg_string`: a string literal that will be used to identify the subcommand +/// in debug logs +/// - `$func`: the method that will be called to build and send the `Channel` message +/// - `$self`: the type that `Runnable` is being implemented for +/// - `$chan`: a closure that specifies how to build the `Channel` object +/// +/// The macro spawns a `ChainHandlePair`, fetches the destination connection, +/// creates a `Channel` object via the closure, and then calls the `$func` method +/// with the `Channel` object. macro_rules! tx_chan_cmd { ($dbg_string:literal, $func:ident, $self:expr, $chan:expr) => { let config = app_config(); @@ -110,56 +123,33 @@ pub struct TxChanOpenInitCmd { impl Runnable for TxChanOpenInitCmd { fn run(&self) { - let config = app_config(); - - let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { - Ok(chains) => chains, - Err(e) => Output::error(e).exit(), - }; - - // Retrieve the connection - let dst_connection = match chains.dst.query_connection( - QueryConnectionRequest { - connection_id: self.dst_conn_id.clone(), - height: QueryHeight::Latest, - }, - IncludeProof::No, - ) { - Ok((connection, _)) => connection, - Err(e) => Output::error(e).exit(), - }; - - let channel = Channel { - connection_delay: Default::default(), - ordering: self.order, - a_side: ChannelSide::new( - chains.src, - ClientId::default(), - ConnectionId::default(), - self.src_port_id.clone(), - None, - None, - ), - b_side: ChannelSide::new( - chains.dst, - dst_connection.client_id().clone(), - self.dst_conn_id.clone(), - self.dst_port_id.clone(), - None, - None, - ), - }; - - info!("message ChanOpenInit: {}", channel); - - let res: Result = channel - .build_chan_open_init_and_send() - .map_err(Error::channel); - - match res { - Ok(receipt) => Output::success(receipt).exit(), - Err(e) => Output::error(e).exit(), - } + tx_chan_cmd!( + "ChanOpenInit", + build_chan_open_init_and_send, + self, + |chains: ChainHandlePair, dst_connection: ConnectionEnd| { + Channel { + connection_delay: Default::default(), + ordering: self.order, + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + None, + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + None, + None, + ), + } + } + ); } } From ed2cab221385ca2edee188f647319cde5ea632a5 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 5 Apr 2023 11:23:19 -0500 Subject: [PATCH 06/99] Stub out build_channel_upgrade_init function --- crates/relayer-cli/src/commands/tx/channel.rs | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 5a204eaf11..27c0bdd9a1 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -707,10 +707,58 @@ pub struct TxChanUpgradeInitCmd { help = "Identifier of the source port" )] src_port_id: PortId, + + #[clap( + long = "dst-channel", + visible_alias = "dst-chan", + required = true, + value_name = "DST_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination channel (required)" + )] + dst_chan_id: ChannelId, + + #[clap( + long = "src-channel", + visible_alias = "src-chan", + required = true, + value_name = "SRC_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" + )] + src_chan_id: ChannelId, } impl Runnable for TxChanUpgradeInitCmd { - fn run(&self) {} + fn run(&self) { + tx_chan_cmd!( + "ChanUpgradeInit", + build_chan_upgrade_init_and_send, + self, + |chains: ChainHandlePair, dst_connection: ConnectionEnd| { + Channel { + connection_delay: Default::default(), + ordering: Order::default(), + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + Some(self.src_chan_id.clone()), + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + Some(self.dst_chan_id.clone()), + None, + ), + } + } + ) + } } /// Build and send a `ChanUpgradeTry` message in response to From df882ffd2fff0f7086f9120aa9340d0d3feab2fa Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 5 Apr 2023 16:04:07 -0500 Subject: [PATCH 07/99] Add MsgChannelUpgradeInit type --- .../src/core/ics04_channel/msgs.rs | 4 + .../ics04_channel/msgs/chan_close_init.rs | 2 - .../core/ics04_channel/msgs/chan_open_init.rs | 2 - .../ics04_channel/msgs/chan_upgrade_init.rs | 142 ++++++++++++++++++ crates/relayer/src/channel.rs | 37 +++++ 5 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs diff --git a/crates/relayer-types/src/core/ics04_channel/msgs.rs b/crates/relayer-types/src/core/ics04_channel/msgs.rs index c69f2e267f..797459d050 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs.rs @@ -22,6 +22,10 @@ pub mod chan_open_try; pub mod chan_close_confirm; pub mod chan_close_init; +// Upgrade handshake messages. +pub mod chan_upgrade_init; +// pub mod chan_upgrade_try; + // Packet specific messages. pub mod acknowledgement; pub mod recv_packet; diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_init.rs index 20e3f25043..4e54182fcf 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_init.rs @@ -11,9 +11,7 @@ use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseInit"; -/// /// Message definition for the first step in the channel close handshake (`ChanCloseInit` datagram). -/// #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelCloseInit { pub port_id: PortId, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_init.rs index f9ade01ac8..73ec371ca9 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_init.rs @@ -10,9 +10,7 @@ use ibc_proto::protobuf::Protobuf; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenInit"; -/// /// Message definition for the first step in the channel open handshake (`ChanOpenInit` datagram). -/// #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenInit { pub port_id: PortId, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs new file mode 100644 index 0000000000..4700db0d2a --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -0,0 +1,142 @@ +use crate::prelude::*; + +use ibc_proto::protobuf::Protobuf; + +use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; + +use crate::core::ics04_channel::error::Error; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; +use crate::tx_msg::Msg; + +pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; + +/// Message definition for the first step in the channel +/// upgrade handshake (`ChanUpgradeInit` datagram). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgChannelUpgradeInit { + pub port_id: PortId, + pub channel_id: ChannelId, + pub channel: ChannelEnd, + pub signer: Signer, +} + +impl MsgChannelUpgradeInit { + pub fn new(port_id: PortId, channel_id: ChannelId, channel: ChannelEnd, signer: Signer) -> Self { + Self { + port_id, + channel_id, + signer, + } + } +} + +impl Msg for MsgChannelUpgradeInit { + type ValidationError = Error; + type Raw = RawMsgChannelUpgradeInit; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + +impl Protobuf for MsgChannelUpgradeInit {} + +impl TryFrom for MsgChannelUpgradeInit { + type Error = Error; + + fn try_from(raw_msg: RawMsgChannelUpgradeInit) -> Result { + Ok(MsgChannelUpgradeInit { + port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, + channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, + signer: raw_msg.signer.parse().map_err(Error::signer)?, + }) + } +} + +impl From for RawMsgChannelUpgradeInit { + fn from(domain_msg: MsgChannelUpgradeInit) -> Self { + Self { + port_id: domain_msg.port_id.to_string(), + channel_id: domain_msg.channel_id.to_string(), + signer: domain_msg.signer.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use crate::prelude::*; + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; + + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::test_utils::get_dummy_bech32_account; + + /// Returns a dummy `RawMsgChannelUpgadeInit`, for testing only! + pub fn get_dummy_raw_msg_chan_upgrade_init() -> RawMsgChannelUpgradeInit { + RawMsgChannelUpgradeInit { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + signer: get_dummy_bech32_account(), + } + } +} + +#[cfg(test)] +mod tests { + use crate::prelude::*; + + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; + + use crate::core::ics04_channel::msgs::chan_upgrade_init::test_util::get_dummy_raw_msg_chan_upgrade_init; + use crate::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; + + #[test] + fn parse_channel_upgrade_init_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeInit, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_init(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeInit { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeInit { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeInit { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + ] + } +} \ No newline at end of file diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 298ffae4e8..70dfdd98f8 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1465,6 +1465,43 @@ impl Channel { } } + pub fn build_chan_upgrade_init(&self) -> Result, ChannelError> { + // Destination channel ID must be specified + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + // Channel must exist on destination + self.dst_chain() + .query_channel( + QueryChannelRequest { + port_id: self.dst_port_id().clone(), + channel_id: dst_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; + + let signer = self + .dst_chain() + .get_signer() + .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; + + // Build the domain type message + let new_msg = MsgChannelUpgradeInit { + port_id: self.dst_port_id().clone(), + channel_id: dst_channel_id.clone(), + signer, + }; + + Ok(vec![new_msg.to_any()]) + } + + pub fn build_chan_upgrade_init_and_send(&self) -> Result { + + } + pub fn map_chain( self, mapper_a: impl Fn(ChainA) -> ChainC, From 991596518bf0abb46a7b1da435cdf2acaaba55c8 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 6 Apr 2023 10:12:56 -0500 Subject: [PATCH 08/99] Add more tests for MsgChannelUpgradeInit message type --- .../core/ics04_channel/msgs/chan_open_try.rs | 2 - .../ics04_channel/msgs/chan_upgrade_init.rs | 52 ++++++++++++++++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs index 51e684ca65..d1b952bcae 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs @@ -15,9 +15,7 @@ use core::str::FromStr; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenTry"; -/// /// Message definition for the second step in the channel open handshake (`ChanOpenTry` datagram). -/// #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenTry { pub port_id: PortId, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 4700db0d2a..8e646f14f6 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -17,7 +17,6 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; pub struct MsgChannelUpgradeInit { pub port_id: PortId, pub channel_id: ChannelId, - pub channel: ChannelEnd, pub signer: Signer, } @@ -114,7 +113,7 @@ mod tests { want_pass: true, }, Test { - name "Correct port ID".to_string(), + name: "Correct port ID".to_string(), raw: RawMsgChannelUpgradeInit { port_id: "p36".to_string(), ..default_raw_msg.clone() @@ -137,6 +136,55 @@ mod tests { }, want_pass: false, }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeInit { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeInit { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeInit { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeInit::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "MsgChannelUpgradeInit::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_init(); + let msg = MsgChannelUpgradeInit::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeInit::from(msg.clone()); + let msg_back = MsgChannelUpgradeInit::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); } } \ No newline at end of file From d6e0e16201392e626e709d76eedf00e8e8d7144b Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 6 Apr 2023 14:42:28 -0500 Subject: [PATCH 09/99] Add chan_upgrade_try file for MsgChannelUpgradeTry message type --- .../src/core/ics04_channel/msgs/chan_close_confirm.rs | 2 -- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs index ce53866ab1..e288201c82 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs @@ -12,10 +12,8 @@ use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseConfirm"; -/// /// Message definition for the second step in the channel close handshake (the `ChanCloseConfirm` /// datagram). -/// #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelCloseConfirm { pub port_id: PortId, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs new file mode 100644 index 0000000000..0bc3c003c5 --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -0,0 +1,8 @@ +use crate::prelude::*; + +pub const type TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeTry"; + +/// Message definition for the second step of the channel upgrade +/// handshake (the `ChanUpgradeTry` datagram). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgChannelUpgradeTry {} \ No newline at end of file From 0e15393e21b5f7195fb3983a51d2bba4d98c7602 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 6 Apr 2023 19:30:59 -0500 Subject: [PATCH 10/99] Add build_chan_upgrade_init_and_send method --- crates/relayer-types/src/events.rs | 14 ++++++++++++++ crates/relayer/src/channel.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index 5a962c266f..a59aff3294 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -161,6 +161,8 @@ pub enum IbcEventType { OpenConfirmChannel, CloseInitChannel, CloseConfirmChannel, + UpgradeInitChannel, + UpgradeTryChannel, SendPacket, ReceivePacket, WriteAck, @@ -193,6 +195,8 @@ impl IbcEventType { IbcEventType::OpenConfirmChannel => CHANNEL_OPEN_CONFIRM_EVENT, IbcEventType::CloseInitChannel => CHANNEL_CLOSE_INIT_EVENT, IbcEventType::CloseConfirmChannel => CHANNEL_CLOSE_CONFIRM_EVENT, + IbcEventType::UpgradeInitChannel => CHANNEL_UPGRADE_INIT_EVENT, + IbcEventType::UpgradeTryChannel => CHANNEL_UPGRADE_TRY_EVENT, IbcEventType::SendPacket => SEND_PACKET_EVENT, IbcEventType::ReceivePacket => RECEIVE_PACKET_EVENT, IbcEventType::WriteAck => WRITE_ACK_EVENT, @@ -229,6 +233,8 @@ impl FromStr for IbcEventType { CHANNEL_OPEN_CONFIRM_EVENT => Ok(IbcEventType::OpenConfirmChannel), CHANNEL_CLOSE_INIT_EVENT => Ok(IbcEventType::CloseInitChannel), CHANNEL_CLOSE_CONFIRM_EVENT => Ok(IbcEventType::CloseConfirmChannel), + CHANNEL_UPGRADE_INIT_EVENT => Ok(IbcEventType::UpgradeInitChannel), + CHANNEL_UPGRADE_TRY_EVENT => Ok(IbcEventType::UpgradeTryChannel), SEND_PACKET_EVENT => Ok(IbcEventType::SendPacket), RECEIVE_PACKET_EVENT => Ok(IbcEventType::ReceivePacket), WRITE_ACK_EVENT => Ok(IbcEventType::WriteAck), @@ -267,6 +273,8 @@ pub enum IbcEvent { OpenConfirmChannel(ChannelEvents::OpenConfirm), CloseInitChannel(ChannelEvents::CloseInit), CloseConfirmChannel(ChannelEvents::CloseConfirm), + UpgradeInitChannel(ChannelEvents::UpgradeInit), + UpgradeTryChannel(ChannelEvents::UpgradeTry), SendPacket(ChannelEvents::SendPacket), ReceivePacket(ChannelEvents::ReceivePacket), @@ -306,6 +314,8 @@ impl Display for IbcEvent { IbcEvent::OpenConfirmChannel(ev) => write!(f, "OpenConfirmChannel({ev})"), IbcEvent::CloseInitChannel(ev) => write!(f, "CloseInitChannel({ev})"), IbcEvent::CloseConfirmChannel(ev) => write!(f, "CloseConfirmChannel({ev})"), + IbcEvent::UpgradeInitChannel(ev) => write!(f, "UpgradeInitChannel({ev})"), + IbcEvent::UpgradeTryChannel(ev) => write!(f, "UpgradeTryChannel({ev})"), IbcEvent::SendPacket(ev) => write!(f, "SendPacket({ev})"), IbcEvent::ReceivePacket(ev) => write!(f, "ReceivePacket({ev})"), @@ -345,6 +355,8 @@ impl TryFrom for abci::Event { IbcEvent::OpenConfirmChannel(event) => event.into(), IbcEvent::CloseInitChannel(event) => event.into(), IbcEvent::CloseConfirmChannel(event) => event.into(), + IbcEvent::UpgradeInitChannel(event) => event.into(), + IbcEvent::UpgradeTryChannel(event) => event.into(), IbcEvent::SendPacket(event) => event.try_into().map_err(Error::channel)?, IbcEvent::ReceivePacket(event) => event.try_into().map_err(Error::channel)?, IbcEvent::WriteAcknowledgement(event) => event.try_into().map_err(Error::channel)?, @@ -387,6 +399,8 @@ impl IbcEvent { IbcEvent::OpenConfirmChannel(_) => IbcEventType::OpenConfirmChannel, IbcEvent::CloseInitChannel(_) => IbcEventType::CloseInitChannel, IbcEvent::CloseConfirmChannel(_) => IbcEventType::CloseConfirmChannel, + IbcEvent::UpgradeInitChannel(_) => IbcEventType::UpgradeInitChannel, + IbcEvent::UpgradeTryChannel(_) => IbcEventType::UpgradeTryChannel, IbcEvent::SendPacket(_) => IbcEventType::SendPacket, IbcEvent::ReceivePacket(_) => IbcEventType::ReceivePacket, IbcEvent::WriteAcknowledgement(_) => IbcEventType::WriteAck, diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 70dfdd98f8..bce2ce5fd1 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1499,7 +1499,34 @@ impl Channel { } pub fn build_chan_upgrade_init_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_init()?; + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeInit"); + + let events = self + .dst_chain() + .send_messages_and_wait_commit(tm) + .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; + + // Find the relevant event for channel upgrade init + let result = events + .into_iter() + .find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeInitChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event("no channel upgrade init event was in the response".to_string()) + })?; + + match &result.event { + IbcEvent::UpgradeInitChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), + } } pub fn map_chain( From 4107486033e928a4280c8d496ff5cb090491cdc8 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 7 Apr 2023 13:18:34 -0500 Subject: [PATCH 11/99] Add UpgradeInit and UpgradeTry ChannelEvents --- .../src/core/ics04_channel/events.rs | 134 ++++++++++++++++++ .../ics04_channel/msgs/chan_upgrade_init.rs | 2 +- crates/relayer-types/src/events.rs | 2 + 3 files changed, 137 insertions(+), 1 deletion(-) diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index 0d0c870e58..c16ed75b2e 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -471,6 +471,138 @@ impl EventType for CloseConfirm { } } +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeInit { + pub port_id: PortId, + pub channel_id: ChannelId, + pub connection_id: ConnectionId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: ChannelId, +} + +impl Display for UpgradeInit { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + match &self.counterparty_channel_id { + Some(counterparty_channel_id) => write!(f, "UpgradeInit {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: {} }}", self.port_id, self.channel_id, self.connection_id, self.counterparty_port_id, counterparty_channel_id), + None => write!(f, "UpgradeInit {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: None }}", self.port_id, self.channel_id, self.connection_id, self.counterparty_port_id), + } + } +} + +impl From for Attributes { + fn from(ev: UpgradeInit) -> Self { + Self { + port_id: ev.port_id, + channel_id: Some(ev.channel_id), + connection_id: ev.connection_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: Some(ev.counterparty_channel_id), + } + } +} + +impl UpgradeInit { + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + &self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeInit { + type Error = EventError; + + fn try_from(attrs: Attributes) -> Result { + if let Some(channel_id) = attrs.channel_id { + Ok(Self { + port_id: attrs.port_id.clone(), + channel_id: channel_id.clone(), + connection_id: attrs.connection_id.clone(), + counterparty_port_id: attrs.counterparty_port_id.clone(), + counterparty_channel_id: attrs.counterparty_channel_id, + }) + } else { + Err(EventError::channel(Error::missing_channel_id())) + } + } +} + +impl From for IbcEvent { + fn from(v: UpgradeInit) -> Self { + IbcEvent::UpgradeInitChannel(v) + } +} + +impl EventType for UpgradeInit { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeInitChannel + } +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeTry { + pub port_id: PortId, + pub channel_id: Option, + pub connection_id: ConnectionId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, +} + +impl Display for UpgradeTry { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + match (&self.channel_id, &self.counterparty_channel_id) { + (Some(channel_id), Some(counterparty_channel_id)) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: {} }}", self.port_id, channel_id, self.connection_id, self.counterparty_port_id, counterparty_channel_id), + (Some(channel_id), None) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: None }}", self.port_id, channel_id, self.connection_id, self.counterparty_port_id), + (None, Some(counterparty_channel_id)) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: None, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: {} }}", self.port_id, self.connection_id, self.counterparty_port_id, counterparty_channel_id), + (None, None) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: None, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: None }}", self.port_id, self.connection_id, self.counterparty_port_id), + } + } +} + +impl From for Attributes { + fn from(ev: UpgradeTry) -> Self { + Self { + port_id: ev.port_id, + channel_id: ev.channel_id, + connection_id: ev.connection_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: ev.counterparty_channel_id, + } + } +} + +impl UpgradeTry { + pub fn channel_id(&self) -> Option<&ChannelId> { + self.channel_id.as_ref() + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } +} + +impl From for IbcEvent { + fn from(v: UpgradeTry) -> Self { + IbcEvent::UpgradeTryChannel(v) + } +} + +impl EventType for UpgradeTry { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeTryChannel + } +} + macro_rules! impl_try_from_attribute_for_event { ($($event:ty),+) => { $(impl TryFrom for $event { @@ -512,6 +644,8 @@ impl_from_ibc_to_abci_event!( OpenConfirm, CloseInit, CloseConfirm + UpgradeInit, + UpgradeTry, ); #[derive(Clone, Debug, PartialEq, Eq, Serialize)] diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 8e646f14f6..4e45d8d245 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -21,7 +21,7 @@ pub struct MsgChannelUpgradeInit { } impl MsgChannelUpgradeInit { - pub fn new(port_id: PortId, channel_id: ChannelId, channel: ChannelEnd, signer: Signer) -> Self { + pub fn new(port_id: PortId, channel_id: ChannelId, signer: Signer) -> Self { Self { port_id, channel_id, diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index a59aff3294..90b04a7784 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -130,6 +130,8 @@ const CHANNEL_OPEN_ACK_EVENT: &str = "channel_open_ack"; const CHANNEL_OPEN_CONFIRM_EVENT: &str = "channel_open_confirm"; const CHANNEL_CLOSE_INIT_EVENT: &str = "channel_close_init"; const CHANNEL_CLOSE_CONFIRM_EVENT: &str = "channel_close_confirm"; +const CHANNEL_UPGRADE_INIT_EVENT: &str = "channel_upgrade_init"; +const CHANNEL_UPGRADE_TRY_EVENT: &str = "channel_upgrade_try"; /// Packet event types const SEND_PACKET_EVENT: &str = "send_packet"; const RECEIVE_PACKET_EVENT: &str = "receive_packet"; From 6baee8fd1b6b203f2ac77c55659f0754ecc2afb8 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 7 Apr 2023 13:23:21 -0500 Subject: [PATCH 12/99] Fix compilation errors with UpgradeInit and UpgradeTry impls --- crates/relayer-types/src/core/ics04_channel/events.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index c16ed75b2e..a156b4d438 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -477,7 +477,7 @@ pub struct UpgradeInit { pub channel_id: ChannelId, pub connection_id: ConnectionId, pub counterparty_port_id: PortId, - pub counterparty_channel_id: ChannelId, + pub counterparty_channel_id: Option, } impl Display for UpgradeInit { @@ -496,7 +496,7 @@ impl From for Attributes { channel_id: Some(ev.channel_id), connection_id: ev.connection_id, counterparty_port_id: ev.counterparty_port_id, - counterparty_channel_id: Some(ev.counterparty_channel_id), + counterparty_channel_id: ev.counterparty_channel_id, } } } @@ -515,7 +515,7 @@ impl UpgradeInit { } pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { - &self.counterparty_channel_id.as_ref() + self.counterparty_channel_id.as_ref() } } @@ -523,7 +523,7 @@ impl TryFrom for UpgradeInit { type Error = EventError; fn try_from(attrs: Attributes) -> Result { - if let Some(channel_id) = attrs.channel_id { + if let Some(channel_id) = attrs.channel_id() { Ok(Self { port_id: attrs.port_id.clone(), channel_id: channel_id.clone(), @@ -644,8 +644,6 @@ impl_from_ibc_to_abci_event!( OpenConfirm, CloseInit, CloseConfirm - UpgradeInit, - UpgradeTry, ); #[derive(Clone, Debug, PartialEq, Eq, Serialize)] From 3f80bfc93982ae1ebb5b742ca1bd9d2de00dc525 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 12 Apr 2023 09:42:06 -0500 Subject: [PATCH 13/99] Stub out MsgChannelUpgradeTry --- crates/relayer-cli/src/commands/tx/channel.rs | 14 +- .../src/core/ics04_channel/channel.rs | 8 +- .../ics04_channel/msgs/chan_upgrade_init.rs | 4 +- .../ics04_channel/msgs/chan_upgrade_try.rs | 186 +++++++++++++++++- crates/relayer/src/channel.rs | 4 +- 5 files changed, 200 insertions(+), 16 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 27c0bdd9a1..ef56b63662 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -16,17 +16,17 @@ use crate::conclude::Output; use crate::error::Error; use crate::prelude::*; -/// Macro that generates the `Runnable::run` implementation for a +/// Macro that generates the `Runnable::run` implementation for a /// `tx channel` subcommand. -/// +/// /// The macro takes the following arguments: /// - `$dbg_string`: a string literal that will be used to identify the subcommand /// in debug logs /// - `$func`: the method that will be called to build and send the `Channel` message -/// - `$self`: the type that `Runnable` is being implemented for +/// - `$self`: the type that `Runnable` is being implemented for /// - `$chan`: a closure that specifies how to build the `Channel` object -/// -/// The macro spawns a `ChainHandlePair`, fetches the destination connection, +/// +/// The macro spawns a `ChainHandlePair`, fetches the destination connection, /// creates a `Channel` object via the closure, and then calls the `$func` method /// with the `Channel` object. macro_rules! tx_chan_cmd { @@ -657,7 +657,7 @@ impl Runnable for TxChanCloseConfirmCmd { } /// Build and send a `ChanUpgradeInit` message to a destination -/// chain that the source chain has an already-existing channel open +/// chain that the source chain has an already-existing channel open /// with, signaling the intent by the source chain to perform /// the channel upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] @@ -762,7 +762,7 @@ impl Runnable for TxChanUpgradeInitCmd { } /// Build and send a `ChanUpgradeTry` message in response to -/// a `ChanUpgradeInnit` message, signaling the chain's intent to +/// a `ChanUpgradeInnit` message, signaling the chain's intent to /// cooperate with the source chain on upgrading the specified channel /// and initiating the upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 66c4b982c5..6135a91f9d 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -372,10 +372,10 @@ impl FromStr for Order { } /// The possible state variants that a channel can exhibit. -/// -/// These are encoded with integer discriminants so that there is -/// an easy way to compare channel states against one another. More -/// explicitly, this is an attempt to capture the lifecycle of a +/// +/// These are encoded with integer discriminants so that there is +/// an easy way to compare channel states against one another. More +/// explicitly, this is an attempt to capture the lifecycle of a /// channel, beginning from the `Uninitialized` state, through the /// `Open` state, before finally being `Closed`. #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 4e45d8d245..523c6f609a 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -11,7 +11,7 @@ use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; -/// Message definition for the first step in the channel +/// Message definition for the first step in the channel /// upgrade handshake (`ChanUpgradeInit` datagram). #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelUpgradeInit { @@ -187,4 +187,4 @@ mod tests { assert_eq!(raw, raw_back); assert_eq!(msg, msg_back); } -} \ No newline at end of file +} diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 0bc3c003c5..f9891f7701 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -1,8 +1,190 @@ use crate::prelude::*; -pub const type TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeTry"; +use ibc_proto::protobuf::Protobuf; + +use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + +use crate::core::ics04_channel::error::Error; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; +use crate::tx_msg::Msg; + +pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeTry"; /// Message definition for the second step of the channel upgrade /// handshake (the `ChanUpgradeTry` datagram). #[derive(Clone, Debug, PartialEq, Eq)] -pub struct MsgChannelUpgradeTry {} \ No newline at end of file +pub struct MsgChannelUpgradeTry { + pub port_id: PortId, + pub channel_id: ChannelId, + pub signer: Signer, +} + +impl MsgChannelUpgradeTry { + pub fn new(port_id: PortId, channel_id: ChannelId, signer: Signer) -> Self { + Self { + port_id, + channel_id, + signer, + } + } +} + +impl Msg for MsgChannelUpgradeTry { + type ValidationError = Error; + type Raw = RawMsgChannelUpgradeTry; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + +impl Protobuf for MsgChannelUpgradeTry {} + +impl TryFrom for MsgChannelUpgradeTry { + type Error = Error; + + fn try_from(raw_msg: RawMsgChannelUpgradeTry) -> Result { + Ok(MsgChannelUpgradeTry { + port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, + channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, + signer: raw_msg.signer.parse().map_err(Error::signer)?, + }) + } +} + +impl From for RawMsgChannelUpgradeTry { + fn from(domain_msg: MsgChannelUpgradeTry) -> Self { + RawMsgChannelUpgradeTry { + port_id: domain_msg.port_id.to_string(), + channel_id: domain_msg.channel_id.to_string(), + signer: domain_msg.signer.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use crate::prelude::*; + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::test_utils::get_dummy_bech32_account; + + /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! + pub fn get_dummy_raw_chan_upgrade_try() -> RawMsgChannelOpenTry { + RawMsgChannelUpgradeTry { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + signer: get_dummy_bech32_account(), + } + } +} + +#[cfg(test)] +mod tests { + use crate::prelude::*; + + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + + use crate::core::ics04_channel::msgs::chan_upgrade_init::test_util::get_dummy_raw_msg_chan_upgrade_init; + use crate::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeTry; + + #[test] + fn parse_channel_upgrade_init_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeTry, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_init(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name: "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeTry { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeTry { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeTry { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeTry { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeTry { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeTry { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeTry::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "MsgChannelUpgradeTry::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_init(); + let msg = MsgChannelUpgradeTry::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeTry::from(msg.clone()); + let msg_back = MsgChannelUpgradeTry::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); + } +} \ No newline at end of file diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index bce2ce5fd1..cff7838882 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1516,7 +1516,9 @@ impl Channel { || matches!(event_with_height.event, IbcEvent::ChainError(_)) }) .ok_or_else(|| { - ChannelError::missing_event("no channel upgrade init event was in the response".to_string()) + ChannelError::missing_event( + "no channel upgrade init event was in the response".to_string(), + ) })?; match &result.event { From 99560ff661e4d46207e0ea7febedd62f14943545 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 12 Apr 2023 15:08:52 -0500 Subject: [PATCH 14/99] Add missing fields to MsgChannelUpgradeInit --- .../src/core/ics04_channel/error.rs | 5 ++- .../ics04_channel/msgs/chan_upgrade_init.rs | 45 ++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index 64f7ccfd72..ce5e630c82 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -94,11 +94,14 @@ define_error! { | _ | { "missing counterparty" }, NoCommonVersion - | _ | { "no commong version" }, + | _ | { "no common version" }, MissingChannel | _ | { "missing channel end" }, + MissingProposedUpgradeChannel, + | _ | { "missing proposed upgrade channel" }, + InvalidVersionLengthConnection | _ | { "single version must be negociated on connection before opening channel" }, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 523c6f609a..a83f81d1c2 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -1,10 +1,12 @@ -use crate::prelude::*; +use crate::timestamp::Timestamp; +use crate::{prelude::*, Height}; use ibc_proto::protobuf::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::channel::ChannelEnd; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::signer::Signer; use crate::tx_msg::Msg; @@ -17,14 +19,27 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; pub struct MsgChannelUpgradeInit { pub port_id: PortId, pub channel_id: ChannelId, + pub proposed_upgrade_channel: Option, + pub timeout_height: Option, + pub timeout_timestamp: Timestamp, pub signer: Signer, } impl MsgChannelUpgradeInit { - pub fn new(port_id: PortId, channel_id: ChannelId, signer: Signer) -> Self { + pub fn new( + port_id: PortId, + channel_id: ChannelId, + proposed_upgrade_channel: Option, + timeout_height: Option, + timeout_timestamp: Timestamp, + signer: Signer + ) -> Self { Self { port_id, channel_id, + proposed_upgrade_channel, + timeout_height, + timeout_timestamp, signer, } } @@ -41,6 +56,17 @@ impl Msg for MsgChannelUpgradeInit { fn type_url(&self) -> String { TYPE_URL.to_string() } + + fn validate_basic(&self) -> Result<(), Self::ValidationError> { + self.proposed_upgrade_channel + .as_ref() + .ok_or(Error::missing_proposed_upgrade_channel())? + .validate_basic()?; + self.timeout_height + .as_ref() + .ok_or(Error::missing_timeout_height())? + .validate_basic()? + } } impl Protobuf for MsgChannelUpgradeInit {} @@ -49,10 +75,18 @@ impl TryFrom for MsgChannelUpgradeInit { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeInit) -> Result { + let channel_end: ChannelEnd = raw_msg + .proposed_upgrade_channel + .ok_or_else(Error::missing_proposed_upgrade_channel)? + .try_into()?; + Ok(MsgChannelUpgradeInit { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, + proposed_upgrade_channel: Some(channel_end), + timeout_height: raw_msg.timeout_height.map(Height::try_from).transpose()?, + timeout_timestamp: raw_msg.timeout_timestamp.into(), }) } } @@ -63,12 +97,16 @@ impl From for RawMsgChannelUpgradeInit { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), signer: domain_msg.signer.to_string(), + proposed_upgrade_channel: domain_msg.proposed_upgrade_channel.map(Into::into), + timeout_height: domain_msg.timeout_height.map(Into::into), + timeout_timestamp: domain_msg.timeout_timestamp.into(), } } } #[cfg(test)] pub mod test_util { + use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; use crate::prelude::*; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; @@ -81,6 +119,9 @@ pub mod test_util { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), signer: get_dummy_bech32_account(), + proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), + timeout_height: Some(Height::new(0, 10).into()), + timeout_timestamp: Timestamp::now().into(), } } } From 00691d8e64b5c26fc41f1258ddf012a5ed85a0bf Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 13 Apr 2023 16:41:31 +0200 Subject: [PATCH 15/99] Use ibc-proto branch with channel upgrade messages --- Cargo.lock | 3 +- Cargo.toml | 4 +- .../src/core/ics04_channel/error.rs | 8 ++- .../src/core/ics04_channel/events.rs | 2 + .../core/ics04_channel/msgs/chan_open_try.rs | 17 +++--- .../ics04_channel/msgs/chan_upgrade_init.rs | 55 +++++++++++-------- crates/relayer-types/src/tx_msg.rs | 3 +- crates/relayer/src/channel.rs | 20 +++++-- 8 files changed, 69 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bcc9a2cfbc..1464a2a758 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1745,8 +1745,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364c9dad4c898411ddfdcc990800c229cd7018c16ab1360395e4637458032198" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#e64f2bbb1746ec83aff65197c22783dc3d00a68b" dependencies = [ "base64 0.21.0", "bytes", diff --git a/Cargo.toml b/Cargo.toml index b699e89ee8..bb8aefd793 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ members = [ "tools/query-events", ] -# [patch.crates-io] -# ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "main" } +[patch.crates-io] +ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "romac/channel-upgrade-only" } # tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "main" } # tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "main" } # tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "main" } diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index ce5e630c82..fd1e68731a 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -79,7 +79,11 @@ define_error! { | _ | { "packet data bytes cannot be empty" }, InvalidTimeoutHeight - | _ | { "invalid timeout height for the packet" }, + | _ | { "invalid timeout height" }, + + InvalidTimeoutTimestamp + [ crate::timestamp::ParseTimestampError ] + | _ | { "invalid timeout timestamp" }, InvalidPacket | _ | { "invalid packet" }, @@ -99,7 +103,7 @@ define_error! { MissingChannel | _ | { "missing channel end" }, - MissingProposedUpgradeChannel, + MissingProposedUpgradeChannel | _ | { "missing proposed upgrade channel" }, InvalidVersionLengthConnection diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index a156b4d438..dab8d148fe 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -642,6 +642,8 @@ impl_from_ibc_to_abci_event!( OpenTry, OpenAck, OpenConfirm, + UpgradeInit, + UpgradeTry, CloseInit, CloseConfirm ); diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs index d1b952bcae..b2eb8c5f24 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs @@ -1,7 +1,6 @@ use crate::core::ics04_channel::channel::ChannelEnd; use crate::core::ics04_channel::error::Error as ChannelError; use crate::core::ics04_channel::version::Version; -use crate::core::ics24_host::error::ValidationError; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::prelude::*; use crate::proofs::Proofs; @@ -58,11 +57,14 @@ impl Msg for MsgChannelOpenTry { TYPE_URL.to_string() } - fn validate_basic(&self) -> Result<(), ValidationError> { - match self.channel.counterparty().channel_id() { - None => Err(ValidationError::invalid_counterparty_channel_id()), - Some(_c) => Ok(()), - } + fn validate_basic(&self) -> Result<(), Self::ValidationError> { + // TODO: adapt error + // match self.channel.counterparty().channel_id() { + // None => Err(ValidationError::invalid_counterparty_channel_id()), + // Some(_c) => Ok(()), + // } + + Ok(()) } } @@ -106,8 +108,7 @@ impl TryFrom for MsgChannelOpenTry { signer: raw_msg.signer.parse().map_err(ChannelError::signer)?, }; - msg.validate_basic() - .map_err(ChannelError::invalid_counterparty_channel_id)?; + msg.validate_basic()?; Ok(msg) } diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index a83f81d1c2..e076174068 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -5,8 +5,8 @@ use ibc_proto::protobuf::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; -use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::channel::ChannelEnd; +use crate::core::ics04_channel::error::Error; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::signer::Signer; use crate::tx_msg::Msg; @@ -27,12 +27,12 @@ pub struct MsgChannelUpgradeInit { impl MsgChannelUpgradeInit { pub fn new( - port_id: PortId, - channel_id: ChannelId, - proposed_upgrade_channel: Option, - timeout_height: Option, + port_id: PortId, + channel_id: ChannelId, + proposed_upgrade_channel: Option, + timeout_height: Option, timeout_timestamp: Timestamp, - signer: Signer + signer: Signer, ) -> Self { Self { port_id, @@ -58,14 +58,18 @@ impl Msg for MsgChannelUpgradeInit { } fn validate_basic(&self) -> Result<(), Self::ValidationError> { - self.proposed_upgrade_channel - .as_ref() - .ok_or(Error::missing_proposed_upgrade_channel())? - .validate_basic()?; - self.timeout_height - .as_ref() - .ok_or(Error::missing_timeout_height())? - .validate_basic()? + // self.proposed_upgrade_channel + // .as_ref() + // .ok_or(Error::missing_proposed_upgrade_channel())? + // .validate_basic()?; + + // TODO: wrap error + // self.timeout_height + // .as_ref() + // .ok_or(Error::missing_timeout_height())? + // .validate_basic()?; + + Ok(()) } } @@ -85,8 +89,13 @@ impl TryFrom for MsgChannelUpgradeInit { channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, proposed_upgrade_channel: Some(channel_end), - timeout_height: raw_msg.timeout_height.map(Height::try_from).transpose()?, - timeout_timestamp: raw_msg.timeout_timestamp.into(), + timeout_height: raw_msg + .timeout_height + .map(Height::try_from) + .transpose() + .map_err(|_| Error::invalid_timeout_height())?, + timeout_timestamp: Timestamp::from_nanoseconds(raw_msg.timeout_timestamp) + .map_err(Error::invalid_timeout_timestamp)?, }) } } @@ -99,19 +108,21 @@ impl From for RawMsgChannelUpgradeInit { signer: domain_msg.signer.to_string(), proposed_upgrade_channel: domain_msg.proposed_upgrade_channel.map(Into::into), timeout_height: domain_msg.timeout_height.map(Into::into), - timeout_timestamp: domain_msg.timeout_timestamp.into(), + timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(), } } } #[cfg(test)] pub mod test_util { - use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; - use crate::prelude::*; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; + use crate::core::ics02_client::height::Height; + use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::prelude::*; use crate::test_utils::get_dummy_bech32_account; + use crate::timestamp::Timestamp; /// Returns a dummy `RawMsgChannelUpgadeInit`, for testing only! pub fn get_dummy_raw_msg_chan_upgrade_init() -> RawMsgChannelUpgradeInit { @@ -120,8 +131,8 @@ pub mod test_util { channel_id: ChannelId::default().to_string(), signer: get_dummy_bech32_account(), proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), - timeout_height: Some(Height::new(0, 10).into()), - timeout_timestamp: Timestamp::now().into(), + timeout_height: Some(Height::new(0, 10).unwrap().into()), + timeout_timestamp: Timestamp::now().nanoseconds(), } } } @@ -197,7 +208,7 @@ mod tests { name: "Channel name too long".to_string(), raw: RawMsgChannelUpgradeInit { channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), - ..default_raw_msg.clone() + ..default_raw_msg }, want_pass: false, }, diff --git a/crates/relayer-types/src/tx_msg.rs b/crates/relayer-types/src/tx_msg.rs index c3ac9eea28..debd633c2e 100644 --- a/crates/relayer-types/src/tx_msg.rs +++ b/crates/relayer-types/src/tx_msg.rs @@ -1,7 +1,6 @@ use ibc_proto::google::protobuf::Any; use prost::{EncodeError, Message}; -use crate::core::ics24_host::error::ValidationError; use crate::prelude::*; pub trait Msg: Clone { @@ -33,7 +32,7 @@ pub trait Msg: Clone { }) } - fn validate_basic(&self) -> Result<(), ValidationError> { + fn validate_basic(&self) -> Result<(), Self::ValidationError> { Ok(()) } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index cff7838882..d05e8b59d5 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,3 +1,6 @@ +pub use error::ChannelError; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; + use core::fmt::{Display, Error as FmtError, Formatter}; use core::time::Duration; @@ -5,7 +8,6 @@ use ibc_proto::google::protobuf::Any; use serde::Serialize; use tracing::{debug, error, info, warn}; -pub use error::ChannelError; use ibc_relayer_types::core::ics04_channel::channel::{ ChannelEnd, Counterparty, IdentifiedChannelEnd, Order, State, }; @@ -1483,16 +1485,24 @@ impl Channel { ) .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; + // Build the domain type message + #[allow(unused_variables)] let signer = self .dst_chain() .get_signer() .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; // Build the domain type message - let new_msg = MsgChannelUpgradeInit { - port_id: self.dst_port_id().clone(), - channel_id: dst_channel_id.clone(), - signer, + #[allow(clippy::diverging_sub_expression, unreachable_code, unused_variables)] + let new_msg = { + MsgChannelUpgradeInit { + port_id: todo!(), + channel_id: todo!(), + proposed_upgrade_channel: todo!(), + timeout_height: todo!(), + timeout_timestamp: todo!(), + signer, + } }; Ok(vec![new_msg.to_any()]) From c571933bd9c11bac6faad726995a88a4dca314f3 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 13 Apr 2023 17:02:17 +0200 Subject: [PATCH 16/99] Fill in todos --- .../src/core/ics04_channel/channel.rs | 2 + .../ics04_channel/msgs/chan_upgrade_init.rs | 65 +++++++++--------- crates/relayer/src/channel.rs | 67 ++++++++++++++----- 3 files changed, 89 insertions(+), 45 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 6135a91f9d..32c97ca812 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -323,6 +323,8 @@ impl From for RawCounterparty { } } +pub type Ordering = Order; + #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] pub enum Order { None = 0, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index e076174068..a39391e519 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -19,9 +19,9 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; pub struct MsgChannelUpgradeInit { pub port_id: PortId, pub channel_id: ChannelId, - pub proposed_upgrade_channel: Option, + pub proposed_upgrade_channel: ChannelEnd, pub timeout_height: Option, - pub timeout_timestamp: Timestamp, + pub timeout_timestamp: Option, pub signer: Signer, } @@ -29,11 +29,18 @@ impl MsgChannelUpgradeInit { pub fn new( port_id: PortId, channel_id: ChannelId, - proposed_upgrade_channel: Option, + proposed_upgrade_channel: ChannelEnd, timeout_height: Option, - timeout_timestamp: Timestamp, + timeout_timestamp: Option, signer: Signer, ) -> Self { + // TODO: Check that either timeout_height or timeout_timestamp is set. + // Maybe model them as an enum + // enum UpgradeTimout { + // Height(Height), + // Timestamp(Timestamp), + // } + Self { port_id, channel_id, @@ -56,21 +63,6 @@ impl Msg for MsgChannelUpgradeInit { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn validate_basic(&self) -> Result<(), Self::ValidationError> { - // self.proposed_upgrade_channel - // .as_ref() - // .ok_or(Error::missing_proposed_upgrade_channel())? - // .validate_basic()?; - - // TODO: wrap error - // self.timeout_height - // .as_ref() - // .ok_or(Error::missing_timeout_height())? - // .validate_basic()?; - - Ok(()) - } } impl Protobuf for MsgChannelUpgradeInit {} @@ -79,23 +71,33 @@ impl TryFrom for MsgChannelUpgradeInit { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeInit) -> Result { - let channel_end: ChannelEnd = raw_msg + let proposed_upgrade_channel: ChannelEnd = raw_msg .proposed_upgrade_channel .ok_or_else(Error::missing_proposed_upgrade_channel)? .try_into()?; + // TODO: Check that either timeout_height or timeout_timestamp is set. + + let timeout_height = raw_msg + .timeout_height + .map(Height::try_from) + .transpose() + .map_err(|_| Error::invalid_timeout_height())?; + + let timeout_timestamp = Some(raw_msg.timeout_timestamp) + .filter(|&ts| ts != 0) + .map(|raw_ts| { + Timestamp::from_nanoseconds(raw_ts).map_err(Error::invalid_timeout_timestamp) + }) + .transpose()?; + Ok(MsgChannelUpgradeInit { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, - proposed_upgrade_channel: Some(channel_end), - timeout_height: raw_msg - .timeout_height - .map(Height::try_from) - .transpose() - .map_err(|_| Error::invalid_timeout_height())?, - timeout_timestamp: Timestamp::from_nanoseconds(raw_msg.timeout_timestamp) - .map_err(Error::invalid_timeout_timestamp)?, + proposed_upgrade_channel, + timeout_height, + timeout_timestamp, }) } } @@ -106,9 +108,12 @@ impl From for RawMsgChannelUpgradeInit { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), signer: domain_msg.signer.to_string(), - proposed_upgrade_channel: domain_msg.proposed_upgrade_channel.map(Into::into), + proposed_upgrade_channel: Some(domain_msg.proposed_upgrade_channel.into()), timeout_height: domain_msg.timeout_height.map(Into::into), - timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(), + timeout_timestamp: domain_msg + .timeout_timestamp + .map(|ts| ts.nanoseconds()) + .unwrap_or(0), } } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index d05e8b59d5..e4a4cd3431 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,5 +1,6 @@ pub use error::ChannelError; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; +use ibc_relayer_types::timestamp::Timestamp; use core::fmt::{Display, Error as FmtError, Formatter}; use core::time::Duration; @@ -1467,40 +1468,63 @@ impl Channel { } } - pub fn build_chan_upgrade_init(&self) -> Result, ChannelError> { - // Destination channel ID must be specified - let dst_channel_id = self + pub fn build_chan_upgrade_init( + &self, + new_version: Option, + new_ordering: Option, + new_connection_hops: Option>, + timeout_height: Option, + timeout_timestamp: Option, + ) -> Result, ChannelError> { + // XXX: do we query/upgrade the source or destination channel? + + // Destination channel ID must exist + let channel_id = self .dst_channel_id() .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + let port_id = self.dst_port_id(); + // Channel must exist on destination - self.dst_chain() + let (mut channel_end, _proof) = self + .dst_chain() .query_channel( QueryChannelRequest { - port_id: self.dst_port_id().clone(), - channel_id: dst_channel_id.clone(), + port_id: port_id.clone(), + channel_id: channel_id.clone(), height: QueryHeight::Latest, }, IncludeProof::No, ) .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; + // Build the proposed channel end + if let Some(new_version) = new_version { + channel_end.version = new_version; + } + + if let Some(new_ordering) = new_ordering { + channel_end.ordering = new_ordering; + } + + if let Some(new_connection_hops) = new_connection_hops { + channel_end.connection_hops = new_connection_hops; + } + // Build the domain type message - #[allow(unused_variables)] let signer = self .dst_chain() .get_signer() .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; // Build the domain type message - #[allow(clippy::diverging_sub_expression, unreachable_code, unused_variables)] let new_msg = { MsgChannelUpgradeInit { - port_id: todo!(), - channel_id: todo!(), - proposed_upgrade_channel: todo!(), - timeout_height: todo!(), - timeout_timestamp: todo!(), + port_id: port_id.clone(), + channel_id: channel_id.clone(), + proposed_upgrade_channel: channel_end, + timeout_height, + timeout_timestamp, signer, } }; @@ -1508,8 +1532,21 @@ impl Channel { Ok(vec![new_msg.to_any()]) } - pub fn build_chan_upgrade_init_and_send(&self) -> Result { - let dst_msgs = self.build_chan_upgrade_init()?; + pub fn build_chan_upgrade_init_and_send( + &self, + new_version: Option, + new_ordering: Option, + new_connection_hops: Option>, + timeout_height: Option, + timeout_timestamp: Option, + ) -> Result { + let dst_msgs = self.build_chan_upgrade_init( + new_version, + new_ordering, + new_connection_hops, + timeout_height, + timeout_timestamp, + )?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeInit"); From feb4f7fccd819c906e25852b2d0f0ece5278f3f6 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 13 Apr 2023 17:07:02 +0200 Subject: [PATCH 17/99] Comment out code in tx chan-upgrade-init and add todos --- crates/relayer-cli/src/commands/tx/channel.rs | 62 +++++++++++-------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index ef56b63662..8fb1042b27 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -656,6 +656,11 @@ impl Runnable for TxChanCloseConfirmCmd { } } +// FIXME: Since the channel already exists, we don't need both the src and dst chain, +// only the src/dst chain and src/dst channel. +// +// TODO: Add arguments for version, ordering, connection hops and timeouts. + /// Build and send a `ChanUpgradeInit` message to a destination /// chain that the source chain has an already-existing channel open /// with, signaling the intent by the source chain to perform @@ -731,33 +736,36 @@ pub struct TxChanUpgradeInitCmd { impl Runnable for TxChanUpgradeInitCmd { fn run(&self) { - tx_chan_cmd!( - "ChanUpgradeInit", - build_chan_upgrade_init_and_send, - self, - |chains: ChainHandlePair, dst_connection: ConnectionEnd| { - Channel { - connection_delay: Default::default(), - ordering: Order::default(), - a_side: ChannelSide::new( - chains.src, - ClientId::default(), - ConnectionId::default(), - self.src_port_id.clone(), - Some(self.src_chan_id.clone()), - None, - ), - b_side: ChannelSide::new( - chains.dst, - dst_connection.client_id().clone(), - self.dst_conn_id.clone(), - self.dst_port_id.clone(), - Some(self.dst_chan_id.clone()), - None, - ), - } - } - ) + // TODO: Take version, connections hops, ordering and timeouts and hops from the arguments + // and pass them to build_chan_upgrade_init_and_send + + // tx_chan_cmd!( + // "ChanUpgradeInit", + // build_chan_upgrade_init_and_send, + // self, + // |chains: ChainHandlePair, dst_connection: ConnectionEnd| { + // Channel { + // connection_delay: Default::default(), + // ordering: Order::default(), + // a_side: ChannelSide::new( + // chains.src, + // ClientId::default(), + // ConnectionId::default(), + // self.src_port_id.clone(), + // Some(self.src_chan_id.clone()), + // None, + // ), + // b_side: ChannelSide::new( + // chains.dst, + // dst_connection.client_id().clone(), + // self.dst_conn_id.clone(), + // self.dst_port_id.clone(), + // Some(self.dst_chan_id.clone()), + // None, + // ), + // } + // } + // ); } } From 410cb5e7eb4a75e7b79a4580350119ce508e4167 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 13 Apr 2023 17:14:21 +0200 Subject: [PATCH 18/99] Add `UpgradeTimeout` enum --- .../src/core/ics04_channel/error.rs | 3 + .../ics04_channel/msgs/chan_upgrade_init.rs | 67 +++++++++++++------ crates/relayer/src/channel.rs | 23 +++---- 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index fd1e68731a..ccfcf41126 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -103,6 +103,9 @@ define_error! { MissingChannel | _ | { "missing channel end" }, + MissingUpgradeTimeout + | _ | { "missing upgrade timeout, either a height or a timestamp must be set" }, + MissingProposedUpgradeChannel | _ | { "missing proposed upgrade channel" }, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index a39391e519..851e94f258 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -13,6 +13,41 @@ use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum UpgradeTimeout { + /// Timeout height indicates the height at which the counterparty + /// must no longer proceed with the upgrade handshake. + /// The chains will then preserve their original channel and the upgrade handshake is aborted + Height(Height), + + /// Timeout timestamp indicates the time on the counterparty at which + /// the counterparty must no longer proceed with the upgrade handshake. + /// The chains will then preserve their original channel and the upgrade handshake is aborted. + Timestamp(Timestamp), + + /// Both timeouts are set. + Both(Height, Timestamp), +} + +impl UpgradeTimeout { + pub fn new(height: Option, timestamp: Option) -> Result { + match (height, timestamp) { + (Some(height), None) => Ok(UpgradeTimeout::Height(height)), + (None, Some(timestamp)) => Ok(UpgradeTimeout::Timestamp(timestamp)), + (Some(height), Some(timestamp)) => Ok(UpgradeTimeout::Both(height, timestamp)), + (None, None) => Err(Error::missing_upgrade_timeout()), + } + } + + pub fn into_tuple(self) -> (Option, Option) { + match self { + UpgradeTimeout::Height(height) => (Some(height), None), + UpgradeTimeout::Timestamp(timestamp) => (None, Some(timestamp)), + UpgradeTimeout::Both(height, timestamp) => (Some(height), Some(timestamp)), + } + } +} + /// Message definition for the first step in the channel /// upgrade handshake (`ChanUpgradeInit` datagram). #[derive(Clone, Debug, PartialEq, Eq)] @@ -20,8 +55,7 @@ pub struct MsgChannelUpgradeInit { pub port_id: PortId, pub channel_id: ChannelId, pub proposed_upgrade_channel: ChannelEnd, - pub timeout_height: Option, - pub timeout_timestamp: Option, + pub timeout: UpgradeTimeout, pub signer: Signer, } @@ -30,23 +64,14 @@ impl MsgChannelUpgradeInit { port_id: PortId, channel_id: ChannelId, proposed_upgrade_channel: ChannelEnd, - timeout_height: Option, - timeout_timestamp: Option, + timeout: UpgradeTimeout, signer: Signer, ) -> Self { - // TODO: Check that either timeout_height or timeout_timestamp is set. - // Maybe model them as an enum - // enum UpgradeTimout { - // Height(Height), - // Timestamp(Timestamp), - // } - Self { port_id, channel_id, proposed_upgrade_channel, - timeout_height, - timeout_timestamp, + timeout, signer, } } @@ -76,8 +101,6 @@ impl TryFrom for MsgChannelUpgradeInit { .ok_or_else(Error::missing_proposed_upgrade_channel)? .try_into()?; - // TODO: Check that either timeout_height or timeout_timestamp is set. - let timeout_height = raw_msg .timeout_height .map(Height::try_from) @@ -91,29 +114,29 @@ impl TryFrom for MsgChannelUpgradeInit { }) .transpose()?; + let timeout = UpgradeTimeout::new(timeout_height, timeout_timestamp)?; + Ok(MsgChannelUpgradeInit { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, proposed_upgrade_channel, - timeout_height, - timeout_timestamp, + timeout, }) } } impl From for RawMsgChannelUpgradeInit { fn from(domain_msg: MsgChannelUpgradeInit) -> Self { + let (timeout_height, timeout_timestamp) = domain_msg.timeout.into_tuple(); + Self { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), signer: domain_msg.signer.to_string(), proposed_upgrade_channel: Some(domain_msg.proposed_upgrade_channel.into()), - timeout_height: domain_msg.timeout_height.map(Into::into), - timeout_timestamp: domain_msg - .timeout_timestamp - .map(|ts| ts.nanoseconds()) - .unwrap_or(0), + timeout_height: timeout_height.map(Into::into), + timeout_timestamp: timeout_timestamp.map(|ts| ts.nanoseconds()).unwrap_or(0), } } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index e4a4cd3431..05bbd6146c 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,6 +1,4 @@ pub use error::ChannelError; -use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; -use ibc_relayer_types::timestamp::Timestamp; use core::fmt::{Display, Error as FmtError, Formatter}; use core::time::Duration; @@ -18,6 +16,9 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenA use ibc_relayer_types::core::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::{ + MsgChannelUpgradeInit, UpgradeTimeout, +}; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; @@ -1473,8 +1474,7 @@ impl Channel { new_version: Option, new_ordering: Option, new_connection_hops: Option>, - timeout_height: Option, - timeout_timestamp: Option, + timeout: UpgradeTimeout, ) -> Result, ChannelError> { // XXX: do we query/upgrade the source or destination channel? @@ -1523,8 +1523,7 @@ impl Channel { port_id: port_id.clone(), channel_id: channel_id.clone(), proposed_upgrade_channel: channel_end, - timeout_height, - timeout_timestamp, + timeout, signer, } }; @@ -1537,16 +1536,10 @@ impl Channel { new_version: Option, new_ordering: Option, new_connection_hops: Option>, - timeout_height: Option, - timeout_timestamp: Option, + timeout: UpgradeTimeout, ) -> Result { - let dst_msgs = self.build_chan_upgrade_init( - new_version, - new_ordering, - new_connection_hops, - timeout_height, - timeout_timestamp, - )?; + let dst_msgs = + self.build_chan_upgrade_init(new_version, new_ordering, new_connection_hops, timeout)?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeInit"); From 111b3c5a1d97ba0317612174be6800c1ac51f9f9 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 13 Apr 2023 10:27:50 -0500 Subject: [PATCH 19/99] Fleshing out MsgChannelUpgradeTry --- .../src/core/ics04_channel/msgs.rs | 2 +- .../ics04_channel/msgs/chan_upgrade_init.rs | 14 +- .../ics04_channel/msgs/chan_upgrade_try.rs | 120 +++++++++++++++++- 3 files changed, 128 insertions(+), 8 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs.rs b/crates/relayer-types/src/core/ics04_channel/msgs.rs index 797459d050..830e1cfff1 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs.rs @@ -24,7 +24,7 @@ pub mod chan_close_init; // Upgrade handshake messages. pub mod chan_upgrade_init; -// pub mod chan_upgrade_try; +pub mod chan_upgrade_try; // Packet specific messages. pub mod acknowledgement; diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index a83f81d1c2..5dac648ea3 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -58,6 +58,10 @@ impl Msg for MsgChannelUpgradeInit { } fn validate_basic(&self) -> Result<(), Self::ValidationError> { + self.port_id.validate_basic()?; + self.channel_id.validate_basic()?; + self.signer.validate_basic()?; + self.proposed_upgrade_channel .as_ref() .ok_or(Error::missing_proposed_upgrade_channel())? @@ -80,14 +84,18 @@ impl TryFrom for MsgChannelUpgradeInit { .ok_or_else(Error::missing_proposed_upgrade_channel)? .try_into()?; - Ok(MsgChannelUpgradeInit { + let msg = MsgChannelUpgradeInit { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, proposed_upgrade_channel: Some(channel_end), timeout_height: raw_msg.timeout_height.map(Height::try_from).transpose()?, timeout_timestamp: raw_msg.timeout_timestamp.into(), - }) + }; + + msg.validate_basic()?; + + Ok(msg) } } @@ -120,7 +128,7 @@ pub mod test_util { channel_id: ChannelId::default().to_string(), signer: get_dummy_bech32_account(), proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), - timeout_height: Some(Height::new(0, 10).into()), + timeout_height: Some(get_dummy_raw_height()), timeout_timestamp: Timestamp::now().into(), } } diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index f9891f7701..33636adbfa 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -1,11 +1,14 @@ -use crate::prelude::*; +use crate::timestamp::Timestamp; +use crate::{prelude::*, Height}; use ibc_proto::protobuf::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::channel::ChannelEnd; use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::core::ics23_commitment::commitment::CommitmentProofBytes; use crate::signer::Signer; use crate::tx_msg::Msg; @@ -18,14 +21,45 @@ pub struct MsgChannelUpgradeTry { pub port_id: PortId, pub channel_id: ChannelId, pub signer: Signer, + pub counterparty_channel: Option, + pub counterparty_sequence: u64, + pub proposed_upgrade_channel: Option, + pub timeout_height: Option, + pub timeout_timestamp: Timestamp, + pub proof_channel: CommitmentProofBytes, + pub proof_upgrade_timeout: CommitmentProofBytes, + pub proof_upgrade_sequence: CommitmentProofBytes, + pub proof_height: Option, } impl MsgChannelUpgradeTry { - pub fn new(port_id: PortId, channel_id: ChannelId, signer: Signer) -> Self { + pub fn new( + port_id: PortId, + channel_id: ChannelId, + signer: Signer, + counterparty_channel: Option, + counterparty_sequence: u64, + proposed_upgrade_channel: Option, + timeout_height: Option, + timeout_timestamp: Timestamp, + proof_channel: CommitmentProofBytes, + proof_upgrade_timeout: CommitmentProofBytes, + proof_upgrade_sequence: CommitmentProofBytes, + proof_height: Option, + ) -> Self { Self { port_id, channel_id, signer, + counterparty_channel, + counterparty_sequence, + proposed_upgrade_channel, + timeout_height, + timeout_timestamp, + proof_channel, + proof_upgrade_timeout, + proof_upgrade_sequence, + proof_height, } } } @@ -41,6 +75,47 @@ impl Msg for MsgChannelUpgradeTry { fn type_url(&self) -> String { TYPE_URL.to_string() } + + fn validate_basic(&self) -> Result<(), Self::ValidationError> { + self.port_id.validate_basic()?; + self.channel_id.validate_basic()?; + self.signer.validate_basic()?; + + self.proposed_upgrade_channel + .as_ref() + .ok_or_else(|| Error::missing_proposed_channel())? + .validate_basic()?; + self.timeout_height + .as_ref() + .ok_or_else(|| Error::missing_timeout_height())? + .validate_basic()?; + + if self.counterparty_sequence == 0 { + return Err(Error::invalid_counterparty_sequence(self.counterparty_sequence)); + } + + if self.timeout_timestamp.is_zero() { + return Err(Error::invalid_timeout()); + } + + if self.proof_channel.is_empty() { + return Err(Error::empty_proof()); + } + + if self.proof_upgrade_timeout.is_empty() { + return Err(Error::empty_proof()); + } + + if self.proof_upgrade_sequence.is_empty() { + return Err(Error::empty_proof()); + } + + if self.proof_height.is_none() { + return Err(Error::empty_proof_height()); + } + + Ok(()) + } } impl Protobuf for MsgChannelUpgradeTry {} @@ -49,11 +124,33 @@ impl TryFrom for MsgChannelUpgradeTry { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeTry) -> Result { - Ok(MsgChannelUpgradeTry { + let counterparty_channel: ChannelEnd = raw_msg + .counterparty_channel + .ok_or_else(|| Error::missing_counterparty_channel())? + .try_into()?; + let proposed_upgrade_channel: ChannelEnd = raw_msg + .proposed_upgrade_channel + .ok_or_else(|| Error::missing_proposed_channel())? + .try_into()?; + + let msg = MsgChannelUpgradeTry { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, - }) + counterparty_channel: Some(counterparty_channel), + proposed_upgrade_channel: Some(proposed_upgrade_channel), + counterparty_sequence: raw_msg.counterparty_sequence, + timeout_height: raw_msg.timeout_height.map(Height::from), + timeout_timestamp: raw_msg.timeout_timestamp.into(), + proof_channel: raw_msg.proof_channel.into(), + proof_upgrade_timeout: raw_msg.proof_upgrade_timeout.into(), + proof_upgrade_sequence: raw_msg.proof_upgrade_sequence.into(), + proof_height: raw_msg.proof_height.map(Height::from), + }; + + msg.validate_basic()?; + + Ok(msg) } } @@ -63,6 +160,15 @@ impl From for RawMsgChannelUpgradeTry { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), signer: domain_msg.signer.to_string(), + counterparty_channel: domain_msg.counterparty_channel.map(Into::into), + counterparty_sequence: domain_msg.counterparty_sequence, + proposed_upgrade_channel: domain_msg.proposed_upgrade_channel.map(Into::into), + timeout_height: domain_msg.timeout_height.map(Into::into), + timeout_timestamp: domain_msg.timeout_timestamp.into(), + proof_channel: domain_msg.proof_channel.into(), + proof_upgrade_timeout: domain_msg.proof_upgrade_timeout.into(), + proof_upgrade_sequence: domain_msg.proof_upgrade_sequence.into(), + proof_height: domain_msg.proof_height.map(Into::into), } } } @@ -72,6 +178,7 @@ pub mod test_util { use crate::prelude::*; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::test_utils::get_dummy_bech32_account; @@ -81,6 +188,11 @@ pub mod test_util { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), signer: get_dummy_bech32_account(), + counterparty_channel: Some(get_dummy_raw_channel_end()), + counterparty_sequence: 1, + proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), + timeout_height: Some(get_dummy_raw_height()), + timeout_timestamp: Timestamp::now().into(), } } } From ca22ecdf6dac3a4f56b27a44e50e5510085bf7b8 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 13 Apr 2023 11:22:23 -0500 Subject: [PATCH 20/99] Clean up MsgChannelUpgradeTry --- .../ics04_channel/msgs/chan_upgrade_init.rs | 36 +----- .../ics04_channel/msgs/chan_upgrade_try.rs | 108 ++++++------------ .../src/core/ics04_channel/timeout.rs | 38 ++++++ crates/relayer-types/src/proofs.rs | 2 +- 4 files changed, 78 insertions(+), 106 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 1cad77fefd..93cc3a7ffb 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -7,47 +7,13 @@ use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpg use crate::core::ics04_channel::channel::ChannelEnd; use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::timeout::UpgradeTimeout; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::signer::Signer; use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum UpgradeTimeout { - /// Timeout height indicates the height at which the counterparty - /// must no longer proceed with the upgrade handshake. - /// The chains will then preserve their original channel and the upgrade handshake is aborted - Height(Height), - - /// Timeout timestamp indicates the time on the counterparty at which - /// the counterparty must no longer proceed with the upgrade handshake. - /// The chains will then preserve their original channel and the upgrade handshake is aborted. - Timestamp(Timestamp), - - /// Both timeouts are set. - Both(Height, Timestamp), -} - -impl UpgradeTimeout { - pub fn new(height: Option, timestamp: Option) -> Result { - match (height, timestamp) { - (Some(height), None) => Ok(UpgradeTimeout::Height(height)), - (None, Some(timestamp)) => Ok(UpgradeTimeout::Timestamp(timestamp)), - (Some(height), Some(timestamp)) => Ok(UpgradeTimeout::Both(height, timestamp)), - (None, None) => Err(Error::missing_upgrade_timeout()), - } - } - - pub fn into_tuple(self) -> (Option, Option) { - match self { - UpgradeTimeout::Height(height) => (Some(height), None), - UpgradeTimeout::Timestamp(timestamp) => (None, Some(timestamp)), - UpgradeTimeout::Both(height, timestamp) => (Some(height), Some(timestamp)), - } - } -} - /// Message definition for the first step in the channel /// upgrade handshake (`ChanUpgradeInit` datagram). #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 33636adbfa..c6d37c81ba 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -7,6 +7,7 @@ use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgr use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::channel::ChannelEnd; +use crate::core::ics04_channel::timeout::UpgradeTimeout; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::core::ics23_commitment::commitment::CommitmentProofBytes; use crate::signer::Signer; @@ -21,15 +22,14 @@ pub struct MsgChannelUpgradeTry { pub port_id: PortId, pub channel_id: ChannelId, pub signer: Signer, - pub counterparty_channel: Option, + pub counterparty_channel: ChannelEnd, pub counterparty_sequence: u64, - pub proposed_upgrade_channel: Option, - pub timeout_height: Option, - pub timeout_timestamp: Timestamp, + pub proposed_upgrade_channel: ChannelEnd, + pub timeout: UpgradeTimeout, pub proof_channel: CommitmentProofBytes, pub proof_upgrade_timeout: CommitmentProofBytes, pub proof_upgrade_sequence: CommitmentProofBytes, - pub proof_height: Option, + pub proof_height: Height, } impl MsgChannelUpgradeTry { @@ -37,15 +37,14 @@ impl MsgChannelUpgradeTry { port_id: PortId, channel_id: ChannelId, signer: Signer, - counterparty_channel: Option, + counterparty_channel: ChannelEnd, + proposed_upgrade_channel: ChannelEnd, counterparty_sequence: u64, - proposed_upgrade_channel: Option, - timeout_height: Option, - timeout_timestamp: Timestamp, + timeout: UpgradeTimeout, proof_channel: CommitmentProofBytes, proof_upgrade_timeout: CommitmentProofBytes, proof_upgrade_sequence: CommitmentProofBytes, - proof_height: Option, + proof_height: Height, ) -> Self { Self { port_id, @@ -54,8 +53,7 @@ impl MsgChannelUpgradeTry { counterparty_channel, counterparty_sequence, proposed_upgrade_channel, - timeout_height, - timeout_timestamp, + timeout, proof_channel, proof_upgrade_timeout, proof_upgrade_sequence, @@ -75,47 +73,6 @@ impl Msg for MsgChannelUpgradeTry { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn validate_basic(&self) -> Result<(), Self::ValidationError> { - self.port_id.validate_basic()?; - self.channel_id.validate_basic()?; - self.signer.validate_basic()?; - - self.proposed_upgrade_channel - .as_ref() - .ok_or_else(|| Error::missing_proposed_channel())? - .validate_basic()?; - self.timeout_height - .as_ref() - .ok_or_else(|| Error::missing_timeout_height())? - .validate_basic()?; - - if self.counterparty_sequence == 0 { - return Err(Error::invalid_counterparty_sequence(self.counterparty_sequence)); - } - - if self.timeout_timestamp.is_zero() { - return Err(Error::invalid_timeout()); - } - - if self.proof_channel.is_empty() { - return Err(Error::empty_proof()); - } - - if self.proof_upgrade_timeout.is_empty() { - return Err(Error::empty_proof()); - } - - if self.proof_upgrade_sequence.is_empty() { - return Err(Error::empty_proof()); - } - - if self.proof_height.is_none() { - return Err(Error::empty_proof_height()); - } - - Ok(()) - } } impl Protobuf for MsgChannelUpgradeTry {} @@ -126,49 +83,60 @@ impl TryFrom for MsgChannelUpgradeTry { fn try_from(raw_msg: RawMsgChannelUpgradeTry) -> Result { let counterparty_channel: ChannelEnd = raw_msg .counterparty_channel - .ok_or_else(|| Error::missing_counterparty_channel())? .try_into()?; + let proposed_upgrade_channel: ChannelEnd = raw_msg .proposed_upgrade_channel - .ok_or_else(|| Error::missing_proposed_channel())? .try_into()?; - let msg = MsgChannelUpgradeTry { + let timeout_height = raw_msg + .timeout_height + .map(Height::try_from) + .transpose() + .map_err(|_| Error::invalid_timeout_height())?; + + let timeout_timestamp = Some(raw_msg.timeout_timestamp) + .filter(|&ts| ts != 0) + .map(|raw_ts| { + Timestamp::from_nanoseconds(raw_ts).map_err(Error::invalid_timeout_timestamp) + }) + .transpose()?; + + let timeout = UpgradeTimeout::new(timeout_height, timeout_timestamp)?; + + Ok(MsgChannelUpgradeTry { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, - counterparty_channel: Some(counterparty_channel), - proposed_upgrade_channel: Some(proposed_upgrade_channel), + counterparty_channel: counterparty_channel, + proposed_upgrade_channel: proposed_upgrade_channel, counterparty_sequence: raw_msg.counterparty_sequence, - timeout_height: raw_msg.timeout_height.map(Height::from), - timeout_timestamp: raw_msg.timeout_timestamp.into(), + timeout, proof_channel: raw_msg.proof_channel.into(), proof_upgrade_timeout: raw_msg.proof_upgrade_timeout.into(), proof_upgrade_sequence: raw_msg.proof_upgrade_sequence.into(), proof_height: raw_msg.proof_height.map(Height::from), - }; - - msg.validate_basic()?; - - Ok(msg) + }) } } impl From for RawMsgChannelUpgradeTry { fn from(domain_msg: MsgChannelUpgradeTry) -> Self { + let (timeout_height, timeout_timestamp) = domain_msg.timeout.into_tuple(); + RawMsgChannelUpgradeTry { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), signer: domain_msg.signer.to_string(), - counterparty_channel: domain_msg.counterparty_channel.map(Into::into), + counterparty_channel: Some(domain_msg.counterparty_channel.into()), counterparty_sequence: domain_msg.counterparty_sequence, - proposed_upgrade_channel: domain_msg.proposed_upgrade_channel.map(Into::into), - timeout_height: domain_msg.timeout_height.map(Into::into), - timeout_timestamp: domain_msg.timeout_timestamp.into(), + proposed_upgrade_channel: Some(domain_msg.proposed_upgrade_channel.into()), + timeout_height: timeout_height.map(Into::into), + timeout_timestamp: timeout_timestamp.map(|ts| ts.nanoseconds()).unwrap_or(0), proof_channel: domain_msg.proof_channel.into(), proof_upgrade_timeout: domain_msg.proof_upgrade_timeout.into(), proof_upgrade_sequence: domain_msg.proof_upgrade_sequence.into(), - proof_height: domain_msg.proof_height.map(Into::into), + proof_height: Some(domain_msg.proof_height.into()), } } } diff --git a/crates/relayer-types/src/core/ics04_channel/timeout.rs b/crates/relayer-types/src/core/ics04_channel/timeout.rs index f9af21a514..8c76a7d2ce 100644 --- a/crates/relayer-types/src/core/ics04_channel/timeout.rs +++ b/crates/relayer-types/src/core/ics04_channel/timeout.rs @@ -181,3 +181,41 @@ impl<'de> Deserialize<'de> for TimeoutHeight { }) } } + +/// A composite of timeout height and timeout timestamp types, useful for when +/// performing a channel upgrade handshake, as there are cases when only timeout +/// height is set, only timeout timestamp is set, or both are set. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum UpgradeTimeout { + /// Timeout height indicates the height at which the counterparty + /// must no longer proceed with the upgrade handshake. + /// The chains will then preserve their original channel and the upgrade handshake is aborted + Height(Height), + + /// Timeout timestamp indicates the time on the counterparty at which + /// the counterparty must no longer proceed with the upgrade handshake. + /// The chains will then preserve their original channel and the upgrade handshake is aborted. + Timestamp(Timestamp), + + /// Both timeouts are set. + Both(Height, Timestamp), +} + +impl UpgradeTimeout { + pub fn new(height: Option, timestamp: Option) -> Result { + match (height, timestamp) { + (Some(height), None) => Ok(UpgradeTimeout::Height(height)), + (None, Some(timestamp)) => Ok(UpgradeTimeout::Timestamp(timestamp)), + (Some(height), Some(timestamp)) => Ok(UpgradeTimeout::Both(height, timestamp)), + (None, None) => Err(Error::missing_upgrade_timeout()), + } + } + + pub fn into_tuple(self) -> (Option, Option) { + match self { + UpgradeTimeout::Height(height) => (Some(height), None), + UpgradeTimeout::Timestamp(timestamp) => (None, Some(timestamp)), + UpgradeTimeout::Both(height, timestamp) => (Some(height), Some(timestamp)), + } + } +} \ No newline at end of file diff --git a/crates/relayer-types/src/proofs.rs b/crates/relayer-types/src/proofs.rs index e41021e7dc..7c009a904c 100644 --- a/crates/relayer-types/src/proofs.rs +++ b/crates/relayer-types/src/proofs.rs @@ -106,4 +106,4 @@ impl ConsensusProof { pub fn proof(&self) -> &CommitmentProofBytes { &self.proof } -} +} \ No newline at end of file From 168be506186b464477141dbcc9df4ffb15d72ef9 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 13 Apr 2023 12:06:49 -0500 Subject: [PATCH 21/99] Clean up MsgChannelUpgradeTry --- .../src/core/ics04_channel/error.rs | 6 ++++++ .../ics04_channel/msgs/chan_upgrade_init.rs | 3 ++- .../ics04_channel/msgs/chan_upgrade_try.rs | 20 +++++++++++++------ .../src/core/ics04_channel/timeout.rs | 9 ++++++--- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index ccfcf41126..320c976bca 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -109,6 +109,12 @@ define_error! { MissingProposedUpgradeChannel | _ | { "missing proposed upgrade channel" }, + MissingProofHeight + | _ | { "missing proof height" }, + + InvalidProofHeight + | _ | { "invalid proof height" }, + InvalidVersionLengthConnection | _ | { "single version must be negociated on connection before opening channel" }, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 93cc3a7ffb..0a4f2ac208 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -62,8 +62,9 @@ impl TryFrom for MsgChannelUpgradeInit { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeInit) -> Result { - let proposed_upgrade_channel: ChannelEnd = raw_msg + let proposed_upgrade_channel = raw_msg .proposed_upgrade_channel + .ok_or_else(Error::missing_proposed_upgrade_channel)? .try_into()?; let timeout_height = raw_msg diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index c6d37c81ba..e72d40cf7c 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -81,12 +81,14 @@ impl TryFrom for MsgChannelUpgradeTry { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeTry) -> Result { - let counterparty_channel: ChannelEnd = raw_msg + let counterparty_channel = raw_msg .counterparty_channel + .ok_or_else(Error::missing_channel)? .try_into()?; - let proposed_upgrade_channel: ChannelEnd = raw_msg + let proposed_upgrade_channel = raw_msg .proposed_upgrade_channel + .ok_or_else(Error::missing_proposed_upgrade_channel)? .try_into()?; let timeout_height = raw_msg @@ -104,6 +106,12 @@ impl TryFrom for MsgChannelUpgradeTry { let timeout = UpgradeTimeout::new(timeout_height, timeout_timestamp)?; + let proof_height = raw_msg + .proof_height + .ok_or_else(Error::missing_proof_height)? + .try_into() + .map_err(Error::invalid_proof_height)?; + Ok(MsgChannelUpgradeTry { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, @@ -112,10 +120,10 @@ impl TryFrom for MsgChannelUpgradeTry { proposed_upgrade_channel: proposed_upgrade_channel, counterparty_sequence: raw_msg.counterparty_sequence, timeout, - proof_channel: raw_msg.proof_channel.into(), - proof_upgrade_timeout: raw_msg.proof_upgrade_timeout.into(), - proof_upgrade_sequence: raw_msg.proof_upgrade_sequence.into(), - proof_height: raw_msg.proof_height.map(Height::from), + proof_channel: raw_msg.proof_channel.try_into().map_err(Error::invalid_proof)?, + proof_upgrade_timeout: raw_msg.proof_upgrade_timeout.try_into().map_err(Error::invalid_proof)?, + proof_upgrade_sequence: raw_msg.proof_upgrade_sequence.try_into().map_err(Error::invalid_proof)?, + proof_height, }) } } diff --git a/crates/relayer-types/src/core/ics04_channel/timeout.rs b/crates/relayer-types/src/core/ics04_channel/timeout.rs index 8c76a7d2ce..9ad89d6b86 100644 --- a/crates/relayer-types/src/core/ics04_channel/timeout.rs +++ b/crates/relayer-types/src/core/ics04_channel/timeout.rs @@ -1,11 +1,14 @@ +use crate::prelude::*; + use core::fmt::{Display, Error as FmtError, Formatter}; use serde::{Deserialize, Serialize}; use ibc_proto::ibc::core::client::v1::Height as RawHeight; +use crate::timestamp::Timestamp; +use crate::core::ics04_channel::error::Error as ChannelError; use crate::core::ics02_client::{error::Error as ICS2Error, height::Height}; -use crate::prelude::*; /// Indicates a consensus height on the destination chain after which the packet /// will no longer be processed, and will instead count as having timed-out. @@ -202,12 +205,12 @@ pub enum UpgradeTimeout { } impl UpgradeTimeout { - pub fn new(height: Option, timestamp: Option) -> Result { + pub fn new(height: Option, timestamp: Option) -> Result { match (height, timestamp) { (Some(height), None) => Ok(UpgradeTimeout::Height(height)), (None, Some(timestamp)) => Ok(UpgradeTimeout::Timestamp(timestamp)), (Some(height), Some(timestamp)) => Ok(UpgradeTimeout::Both(height, timestamp)), - (None, None) => Err(Error::missing_upgrade_timeout()), + (None, None) => Err(ChannelError::missing_upgrade_timeout()), } } From cc8b9b238e264515b92aea7089e7a0eaf67bed8f Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 14 Apr 2023 11:14:59 -0500 Subject: [PATCH 22/99] Fix error conversion --- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 2 +- crates/relayer/src/channel.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index e72d40cf7c..5a82e7dc04 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -110,7 +110,7 @@ impl TryFrom for MsgChannelUpgradeTry { .proof_height .ok_or_else(Error::missing_proof_height)? .try_into() - .map_err(Error::invalid_proof_height)?; + .map_err(|_| Error::invalid_proof_height())?; Ok(MsgChannelUpgradeTry { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 05bbd6146c..2585638a48 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -16,9 +16,8 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenA use ibc_relayer_types::core::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; -use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::{ - MsgChannelUpgradeInit, UpgradeTimeout, -}; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; +use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; @@ -1476,8 +1475,6 @@ impl Channel { new_connection_hops: Option>, timeout: UpgradeTimeout, ) -> Result, ChannelError> { - // XXX: do we query/upgrade the source or destination channel? - // Destination channel ID must exist let channel_id = self .dst_channel_id() From 3cfb4da47521ab08a4b2fbad656db37c61cc8eec Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 17 Apr 2023 15:17:32 +0200 Subject: [PATCH 23/99] Formatting and clippy --- .../ics04_channel/msgs/chan_upgrade_try.rs | 31 ++++++++++++------- .../src/core/ics04_channel/timeout.rs | 8 ++--- crates/relayer-types/src/proofs.rs | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 5a82e7dc04..2cfccdcae5 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -5,17 +5,17 @@ use ibc_proto::protobuf::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; -use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::channel::ChannelEnd; +use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::timeout::UpgradeTimeout; -use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::core::ics23_commitment::commitment::CommitmentProofBytes; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::signer::Signer; use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeTry"; -/// Message definition for the second step of the channel upgrade +/// Message definition for the second step of the channel upgrade /// handshake (the `ChanUpgradeTry` datagram). #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelUpgradeTry { @@ -34,8 +34,8 @@ pub struct MsgChannelUpgradeTry { impl MsgChannelUpgradeTry { pub fn new( - port_id: PortId, - channel_id: ChannelId, + port_id: PortId, + channel_id: ChannelId, signer: Signer, counterparty_channel: ChannelEnd, proposed_upgrade_channel: ChannelEnd, @@ -116,13 +116,22 @@ impl TryFrom for MsgChannelUpgradeTry { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, - counterparty_channel: counterparty_channel, - proposed_upgrade_channel: proposed_upgrade_channel, + counterparty_channel, + proposed_upgrade_channel, counterparty_sequence: raw_msg.counterparty_sequence, timeout, - proof_channel: raw_msg.proof_channel.try_into().map_err(Error::invalid_proof)?, - proof_upgrade_timeout: raw_msg.proof_upgrade_timeout.try_into().map_err(Error::invalid_proof)?, - proof_upgrade_sequence: raw_msg.proof_upgrade_sequence.try_into().map_err(Error::invalid_proof)?, + proof_channel: raw_msg + .proof_channel + .try_into() + .map_err(Error::invalid_proof)?, + proof_upgrade_timeout: raw_msg + .proof_upgrade_timeout + .try_into() + .map_err(Error::invalid_proof)?, + proof_upgrade_sequence: raw_msg + .proof_upgrade_sequence + .try_into() + .map_err(Error::invalid_proof)?, proof_height, }) } @@ -275,4 +284,4 @@ mod tests { assert_eq!(raw, raw_back); assert_eq!(msg, msg_back); } -} \ No newline at end of file +} diff --git a/crates/relayer-types/src/core/ics04_channel/timeout.rs b/crates/relayer-types/src/core/ics04_channel/timeout.rs index 9ad89d6b86..4b2fc58254 100644 --- a/crates/relayer-types/src/core/ics04_channel/timeout.rs +++ b/crates/relayer-types/src/core/ics04_channel/timeout.rs @@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize}; use ibc_proto::ibc::core::client::v1::Height as RawHeight; -use crate::timestamp::Timestamp; -use crate::core::ics04_channel::error::Error as ChannelError; use crate::core::ics02_client::{error::Error as ICS2Error, height::Height}; +use crate::core::ics04_channel::error::Error as ChannelError; +use crate::timestamp::Timestamp; /// Indicates a consensus height on the destination chain after which the packet /// will no longer be processed, and will instead count as having timed-out. @@ -185,7 +185,7 @@ impl<'de> Deserialize<'de> for TimeoutHeight { } } -/// A composite of timeout height and timeout timestamp types, useful for when +/// A composite of timeout height and timeout timestamp types, useful for when /// performing a channel upgrade handshake, as there are cases when only timeout /// height is set, only timeout timestamp is set, or both are set. #[derive(Clone, Debug, PartialEq, Eq)] @@ -221,4 +221,4 @@ impl UpgradeTimeout { UpgradeTimeout::Both(height, timestamp) => (Some(height), Some(timestamp)), } } -} \ No newline at end of file +} diff --git a/crates/relayer-types/src/proofs.rs b/crates/relayer-types/src/proofs.rs index 7c009a904c..e41021e7dc 100644 --- a/crates/relayer-types/src/proofs.rs +++ b/crates/relayer-types/src/proofs.rs @@ -106,4 +106,4 @@ impl ConsensusProof { pub fn proof(&self) -> &CommitmentProofBytes { &self.proof } -} \ No newline at end of file +} From 27c2361f732fb032fce74a99d5a2fab7a0251caa Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 17 Apr 2023 15:21:08 +0200 Subject: [PATCH 24/99] Disable tests and fix more clippy warnings --- .../ics04_channel/msgs/chan_upgrade_init.rs | 2 +- .../ics04_channel/msgs/chan_upgrade_try.rs | 255 +++++++++--------- 2 files changed, 129 insertions(+), 128 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 0a4f2ac208..a5ef2049d0 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -202,7 +202,7 @@ mod tests { name: "Channel name too long".to_string(), raw: RawMsgChannelUpgradeInit { channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), - ..default_raw_msg + ..default_raw_msg.clone() }, want_pass: false, }, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 2cfccdcae5..2122d1b9df 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -33,6 +33,7 @@ pub struct MsgChannelUpgradeTry { } impl MsgChannelUpgradeTry { + #[allow(clippy::too_many_arguments)] pub fn new( port_id: PortId, channel_id: ChannelId, @@ -158,130 +159,130 @@ impl From for RawMsgChannelUpgradeTry { } } -#[cfg(test)] -pub mod test_util { - use crate::prelude::*; - use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; - - use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; - use crate::core::ics24_host::identifier::{ChannelId, PortId}; - use crate::test_utils::get_dummy_bech32_account; - - /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! - pub fn get_dummy_raw_chan_upgrade_try() -> RawMsgChannelOpenTry { - RawMsgChannelUpgradeTry { - port_id: PortId::default().to_string(), - channel_id: ChannelId::default().to_string(), - signer: get_dummy_bech32_account(), - counterparty_channel: Some(get_dummy_raw_channel_end()), - counterparty_sequence: 1, - proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), - timeout_height: Some(get_dummy_raw_height()), - timeout_timestamp: Timestamp::now().into(), - } - } -} - -#[cfg(test)] -mod tests { - use crate::prelude::*; - - use test_log::test; - - use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; - - use crate::core::ics04_channel::msgs::chan_upgrade_init::test_util::get_dummy_raw_msg_chan_upgrade_init; - use crate::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeTry; - - #[test] - fn parse_channel_upgrade_init_msg() { - struct Test { - name: String, - raw: RawMsgChannelUpgradeTry, - want_pass: bool, - } - - let default_raw_msg = get_dummy_raw_msg_chan_upgrade_init(); - - let tests: Vec = vec![ - Test { - name: "Good parameters".to_string(), - raw: default_raw_msg.clone(), - want_pass: true, - }, - Test { - name: "Correct port ID".to_string(), - raw: RawMsgChannelUpgradeTry { - port_id: "p36".to_string(), - ..default_raw_msg.clone() - }, - want_pass: true, - }, - Test { - name: "Port too short".to_string(), - raw: RawMsgChannelUpgradeTry { - port_id: "p".to_string(), - ..default_raw_msg.clone() - }, - want_pass: false, - }, - Test { - name: "Port too long".to_string(), - raw: RawMsgChannelUpgradeTry { - port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), - ..default_raw_msg.clone() - }, - want_pass: false, - }, - Test { - name: "Correct channel ID".to_string(), - raw: RawMsgChannelUpgradeTry { - channel_id: "channel-2".to_string(), - ..default_raw_msg.clone() - }, - want_pass: true, - }, - Test { - name: "Channel name too short".to_string(), - raw: RawMsgChannelUpgradeTry { - channel_id: "c".to_string(), - ..default_raw_msg.clone() - }, - want_pass: false, - }, - Test { - name: "Channel name too long".to_string(), - raw: RawMsgChannelUpgradeTry { - channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), - ..default_raw_msg.clone() - }, - want_pass: false, - }, - ] - .into_iter() - .collect(); - - for test in tests { - let res = MsgChannelUpgradeTry::try_from(test.raw.clone()); - - assert_eq!( - test.want_pass, - res.is_ok(), - "MsgChannelUpgradeTry::try_from failed for test {}, \nraw msg {:?} with err {:?}", - test.name, - test.raw, - res.err() - ); - } - } - - #[test] - fn to_and_from() { - let raw = get_dummy_raw_msg_chan_upgrade_init(); - let msg = MsgChannelUpgradeTry::try_from(raw.clone()).unwrap(); - let raw_back = RawMsgChannelUpgradeTry::from(msg.clone()); - let msg_back = MsgChannelUpgradeTry::try_from(raw_back.clone()).unwrap(); - assert_eq!(raw, raw_back); - assert_eq!(msg, msg_back); - } -} +// #[cfg(test)] +// pub mod test_util { +// use crate::prelude::*; +// use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + +// use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; +// use crate::core::ics24_host::identifier::{ChannelId, PortId}; +// use crate::test_utils::get_dummy_bech32_account; + +// /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! +// pub fn get_dummy_raw_chan_upgrade_try() -> RawMsgChannelUpgradeTry { +// RawMsgChannelUpgradeTry { +// port_id: PortId::default().to_string(), +// channel_id: ChannelId::default().to_string(), +// signer: get_dummy_bech32_account(), +// counterparty_channel: Some(get_dummy_raw_channel_end()), +// counterparty_sequence: 1, +// proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), +// timeout_height: Some(get_dummy_raw_height()), +// timeout_timestamp: Timestamp::now().into(), +// } +// } +// } + +// #[cfg(test)] +// mod tests { +// use crate::prelude::*; + +// use test_log::test; + +// use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + +// use crate::core::ics04_channel::msgs::chan_upgrade_init::test_util::get_dummy_raw_msg_chan_upgrade_init; +// use crate::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeTry; + +// #[test] +// fn parse_channel_upgrade_init_msg() { +// struct Test { +// name: String, +// raw: RawMsgChannelUpgradeTry, +// want_pass: bool, +// } + +// let default_raw_msg = get_dummy_raw_msg_chan_upgrade_init(); + +// let tests: Vec = vec![ +// Test { +// name: "Good parameters".to_string(), +// raw: default_raw_msg.clone(), +// want_pass: true, +// }, +// Test { +// name: "Correct port ID".to_string(), +// raw: RawMsgChannelUpgradeTry { +// port_id: "p36".to_string(), +// ..default_raw_msg.clone() +// }, +// want_pass: true, +// }, +// Test { +// name: "Port too short".to_string(), +// raw: RawMsgChannelUpgradeTry { +// port_id: "p".to_string(), +// ..default_raw_msg.clone() +// }, +// want_pass: false, +// }, +// Test { +// name: "Port too long".to_string(), +// raw: RawMsgChannelUpgradeTry { +// port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), +// ..default_raw_msg.clone() +// }, +// want_pass: false, +// }, +// Test { +// name: "Correct channel ID".to_string(), +// raw: RawMsgChannelUpgradeTry { +// channel_id: "channel-2".to_string(), +// ..default_raw_msg.clone() +// }, +// want_pass: true, +// }, +// Test { +// name: "Channel name too short".to_string(), +// raw: RawMsgChannelUpgradeTry { +// channel_id: "c".to_string(), +// ..default_raw_msg.clone() +// }, +// want_pass: false, +// }, +// Test { +// name: "Channel name too long".to_string(), +// raw: RawMsgChannelUpgradeTry { +// channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), +// ..default_raw_msg.clone() +// }, +// want_pass: false, +// }, +// ] +// .into_iter() +// .collect(); + +// for test in tests { +// let res = MsgChannelUpgradeTry::try_from(test.raw.clone()); + +// assert_eq!( +// test.want_pass, +// res.is_ok(), +// "MsgChannelUpgradeTry::try_from failed for test {}, \nraw msg {:?} with err {:?}", +// test.name, +// test.raw, +// res.err() +// ); +// } +// } + +// #[test] +// fn to_and_from() { +// let raw = get_dummy_raw_msg_chan_upgrade_init(); +// let msg = MsgChannelUpgradeTry::try_from(raw.clone()).unwrap(); +// let raw_back = RawMsgChannelUpgradeTry::from(msg.clone()); +// let msg_back = MsgChannelUpgradeTry::try_from(raw_back.clone()).unwrap(); +// assert_eq!(raw, raw_back); +// assert_eq!(msg, msg_back); +// } +// } From b131e275bf0110dd223f684bd6762dd785bb1b8a Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 17 Apr 2023 15:27:25 +0200 Subject: [PATCH 25/99] Re-enable tests --- .../ics04_channel/msgs/chan_upgrade_try.rs | 265 +++++++++--------- 1 file changed, 138 insertions(+), 127 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 2122d1b9df..9def0fbf5a 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -159,130 +159,141 @@ impl From for RawMsgChannelUpgradeTry { } } -// #[cfg(test)] -// pub mod test_util { -// use crate::prelude::*; -// use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; - -// use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; -// use crate::core::ics24_host::identifier::{ChannelId, PortId}; -// use crate::test_utils::get_dummy_bech32_account; - -// /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! -// pub fn get_dummy_raw_chan_upgrade_try() -> RawMsgChannelUpgradeTry { -// RawMsgChannelUpgradeTry { -// port_id: PortId::default().to_string(), -// channel_id: ChannelId::default().to_string(), -// signer: get_dummy_bech32_account(), -// counterparty_channel: Some(get_dummy_raw_channel_end()), -// counterparty_sequence: 1, -// proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), -// timeout_height: Some(get_dummy_raw_height()), -// timeout_timestamp: Timestamp::now().into(), -// } -// } -// } - -// #[cfg(test)] -// mod tests { -// use crate::prelude::*; - -// use test_log::test; - -// use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; - -// use crate::core::ics04_channel::msgs::chan_upgrade_init::test_util::get_dummy_raw_msg_chan_upgrade_init; -// use crate::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeTry; - -// #[test] -// fn parse_channel_upgrade_init_msg() { -// struct Test { -// name: String, -// raw: RawMsgChannelUpgradeTry, -// want_pass: bool, -// } - -// let default_raw_msg = get_dummy_raw_msg_chan_upgrade_init(); - -// let tests: Vec = vec![ -// Test { -// name: "Good parameters".to_string(), -// raw: default_raw_msg.clone(), -// want_pass: true, -// }, -// Test { -// name: "Correct port ID".to_string(), -// raw: RawMsgChannelUpgradeTry { -// port_id: "p36".to_string(), -// ..default_raw_msg.clone() -// }, -// want_pass: true, -// }, -// Test { -// name: "Port too short".to_string(), -// raw: RawMsgChannelUpgradeTry { -// port_id: "p".to_string(), -// ..default_raw_msg.clone() -// }, -// want_pass: false, -// }, -// Test { -// name: "Port too long".to_string(), -// raw: RawMsgChannelUpgradeTry { -// port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), -// ..default_raw_msg.clone() -// }, -// want_pass: false, -// }, -// Test { -// name: "Correct channel ID".to_string(), -// raw: RawMsgChannelUpgradeTry { -// channel_id: "channel-2".to_string(), -// ..default_raw_msg.clone() -// }, -// want_pass: true, -// }, -// Test { -// name: "Channel name too short".to_string(), -// raw: RawMsgChannelUpgradeTry { -// channel_id: "c".to_string(), -// ..default_raw_msg.clone() -// }, -// want_pass: false, -// }, -// Test { -// name: "Channel name too long".to_string(), -// raw: RawMsgChannelUpgradeTry { -// channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), -// ..default_raw_msg.clone() -// }, -// want_pass: false, -// }, -// ] -// .into_iter() -// .collect(); - -// for test in tests { -// let res = MsgChannelUpgradeTry::try_from(test.raw.clone()); - -// assert_eq!( -// test.want_pass, -// res.is_ok(), -// "MsgChannelUpgradeTry::try_from failed for test {}, \nraw msg {:?} with err {:?}", -// test.name, -// test.raw, -// res.err() -// ); -// } -// } - -// #[test] -// fn to_and_from() { -// let raw = get_dummy_raw_msg_chan_upgrade_init(); -// let msg = MsgChannelUpgradeTry::try_from(raw.clone()).unwrap(); -// let raw_back = RawMsgChannelUpgradeTry::from(msg.clone()); -// let msg_back = MsgChannelUpgradeTry::try_from(raw_back.clone()).unwrap(); -// assert_eq!(raw, raw_back); -// assert_eq!(msg, msg_back); -// } -// } +#[cfg(test)] +pub mod test_util { + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + use ibc_proto::ibc::core::client::v1::Height; + + use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::prelude::*; + use crate::test_utils::get_dummy_bech32_account; + + /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! + pub fn get_dummy_raw_msg_chan_upgrade_try() -> RawMsgChannelUpgradeTry { + RawMsgChannelUpgradeTry { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + signer: get_dummy_bech32_account(), + counterparty_channel: Some(get_dummy_raw_channel_end()), + counterparty_sequence: 1, + proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), + timeout_height: Some(Height { + revision_number: 1, + revision_height: 1, + }), + timeout_timestamp: 1681737922, + proof_channel: vec![], + proof_upgrade_timeout: vec![], + proof_upgrade_sequence: vec![], + proof_height: Some(Height { + revision_number: 1, + revision_height: 1, + }), + } + } +} + +#[cfg(test)] +mod tests { + use crate::prelude::*; + + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; + + use crate::core::ics04_channel::msgs::chan_upgrade_try::test_util::get_dummy_raw_msg_chan_upgrade_try; + use crate::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; + + #[test] + fn parse_channel_upgrade_init_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeTry, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_try(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name: "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeTry { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeTry { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeTry { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeTry { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeTry { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeTry { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg + }, + want_pass: false, + }, + ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeTry::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "MsgChannelUpgradeTry::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_try(); + let msg = MsgChannelUpgradeTry::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeTry::from(msg.clone()); + let msg_back = MsgChannelUpgradeTry::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); + } +} From a2b9c99d8f8a1772b78ce5e85c2a2313921b04c6 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Mon, 17 Apr 2023 12:52:57 -0500 Subject: [PATCH 26/99] Wrap up channel upgrade init CLI --- crates/relayer-cli/src/commands/tx/channel.rs | 156 +++++++++++------- .../src/core/ics04_channel/channel.rs | 22 ++- crates/relayer/src/channel.rs | 28 +++- crates/relayer/src/channel/error.rs | 9 + 4 files changed, 146 insertions(+), 69 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 8fb1042b27..2bd63fc7d5 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -4,8 +4,12 @@ use abscissa_core::{Command, Runnable}; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryConnectionRequest, QueryHeight}; use ibc_relayer::channel::{Channel, ChannelSide}; + +use ibc_relayer_types::Height; +use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd; use ibc_relayer_types::core::ics04_channel::channel::Order; +use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; @@ -656,11 +660,6 @@ impl Runnable for TxChanCloseConfirmCmd { } } -// FIXME: Since the channel already exists, we don't need both the src and dst chain, -// only the src/dst chain and src/dst channel. -// -// TODO: Add arguments for version, ordering, connection hops and timeouts. - /// Build and send a `ChanUpgradeInit` message to a destination /// chain that the source chain has an already-existing channel open /// with, signaling the intent by the source chain to perform @@ -668,22 +667,22 @@ impl Runnable for TxChanCloseConfirmCmd { #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] pub struct TxChanUpgradeInitCmd { #[clap( - long = "dst-chain", + long = "src-chain", required = true, - value_name = "DST_CHAIN_ID", + value_name = "SRC_CHAIN_ID", help_heading = "REQUIRED", - help = "Identifier of the destination chain" + help = "Identifier of the source chain" )] - dst_chain_id: ChainId, + src_chain_id: ChainId, #[clap( - long = "src-chain", + long = "dst-chain", required = true, - value_name = "SRC_CHAIN_ID", + value_name = "DST_CHAIN_ID", help_heading = "REQUIRED", - help = "Identifier of the source chain" + help = "Identifier of the destination chain" )] - src_chain_id: ChainId, + dst_chain_id: ChainId, #[clap( long = "dst-connection", @@ -704,68 +703,105 @@ pub struct TxChanUpgradeInitCmd { )] dst_port_id: PortId, - #[clap( - long = "src-port", - required = true, - value_name = "SRC_PORT_ID", - help_heading = "REQUIRED", - help = "Identifier of the source port" - )] - src_port_id: PortId, - #[clap( long = "dst-channel", visible_alias = "dst-chan", required = true, value_name = "DST_CHANNEL_ID", help_heading = "REQUIRED", - help = "Identifier of the destination channel (required)" + help = "Identifier of the destination channel" )] dst_chan_id: ChannelId, #[clap( - long = "src-channel", - visible_alias = "src-chan", - required = true, - value_name = "SRC_CHANNEL_ID", - help_heading = "REQUIRED", - help = "Identifier of the source channel (required)" + long = "version", + required = false, + value_name = "VERSION", + help = "Version of the channel that both chains will upgrade to. Defaults to the version of the initiating chain if not specified." )] - src_chan_id: ChannelId, + version: Option, + + #[clap( + long = "ordering", + required = false, + value_name = "ORDERING", + help = "Ordering of the channel that both chains will upgrade to. Note that the a channel may only be upgraded from a stricter ordering to a less strict ordering, i.e., from ORDERED to UNORDERED. Defaults to the ordering of the initiating chain if not specified." + )] + ordering: Option, + + #[clap( + long = "connection-hops", + required = false, + value_name = "CONNECTION_HOPS", + help = "Set of connection hops for the channel that both chains will upgrade to. Defaults to the connection hops of the initiating chain if not specified." + )] + connection_hops: Option>, + + #[clap( + long = "timeout-height", + required = false, + value_name = "TIMEOUT_HEIGHT", + help = "Height that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout timestamp is specified." + )] + timeout_height: Option, + + #[clap( + long = "timeout-timestamp", + required = false, + value_name = "TIMEOUT_TIMESTAMP", + help = "Timestamp that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout height is specified." + )] + timeout_timestamp: Option, } impl Runnable for TxChanUpgradeInitCmd { fn run(&self) { - // TODO: Take version, connections hops, ordering and timeouts and hops from the arguments - // and pass them to build_chan_upgrade_init_and_send - - // tx_chan_cmd!( - // "ChanUpgradeInit", - // build_chan_upgrade_init_and_send, - // self, - // |chains: ChainHandlePair, dst_connection: ConnectionEnd| { - // Channel { - // connection_delay: Default::default(), - // ordering: Order::default(), - // a_side: ChannelSide::new( - // chains.src, - // ClientId::default(), - // ConnectionId::default(), - // self.src_port_id.clone(), - // Some(self.src_chan_id.clone()), - // None, - // ), - // b_side: ChannelSide::new( - // chains.dst, - // dst_connection.client_id().clone(), - // self.dst_conn_id.clone(), - // self.dst_port_id.clone(), - // Some(self.dst_chan_id.clone()), - // None, - // ), - // } - // } - // ); + let config = app_config(); + + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { + Ok(chains) => chains, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Fetch the Channel that will facilitate the communication between the channel ends + // being upgraded. This channel is assumed to already exist on the destination chain. + let channel = Channel { + connection_delay: Default::default(), + ordering: Order::default(), + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + PortId::default(), + None, + None, + ), + b_side: ChannelSide::new( + chains.dst, + ClientId::default(), + ConnectionId::default(), + self.dst_port_id.clone(), + Some(self.dst_chan_id.clone()), + None, + ), + }; + + info!("message ChanUpgradeInit: {}", channel); + + let res: Result = channel + .build_chan_upgrade_init_and_send( + self.version.clone(), + self.ordering.clone(), + self.connection_hops.clone(), + self.timeout_height.clone(), + self.timeout_timestamp.clone(), + ) + .map_err(Error::channel); + + match res { + Ok(receipt) => Output::success(receipt).exit(), + Err(e) => Output::error(e).exit(), + } } } diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 32c97ca812..8c82465e51 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -325,7 +325,7 @@ impl From for RawCounterparty { pub type Ordering = Order; -#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, Default, PartialOrd, Ord)] pub enum Order { None = 0, #[default] @@ -382,13 +382,25 @@ impl FromStr for Order { /// `Open` state, before finally being `Closed`. #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum State { + /// Default state Uninitialized = 0, + /// A channel has just started the opening handshake. Init = 1, + /// A channel has acknowledged the handshake step on the counterparty chain. TryOpen = 2, + /// A channel has completed the handshake step. Open channels are ready to + /// send and receive packets. Open = 3, - InitUpgrade = 4, - TryUpgrade = 5, - Closed = 6, + /// A channel has been closed and can no longer be used to send or receive + /// packets. + Closed = 4, + /// A channel has just started the upgrade handshake. The chain that is + /// proposing the upgrade should set the channel state from OPEN to INITUPGRADE. + InitUpgrade = 5, + /// A channel has acknowledged the upgrade handshake step on the counterparty chain. + /// The counterparty chain that accepts the upgrade should set the channel state from + /// OPEN to TRYUPGRADE. + TryUpgrade = 6, } impl State { @@ -439,6 +451,8 @@ impl State { /// assert!(!State::Closed.less_or_equal_progress(State::Open)); /// ``` pub fn less_or_equal_progress(self, other: Self) -> bool { + // TODO: Rewrite this function to explicitly compare the states, not relying + // on their integer representations. self as u32 <= other as u32 } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 2585638a48..3cbc404ff0 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -7,6 +7,7 @@ use ibc_proto::google::protobuf::Any; use serde::Serialize; use tracing::{debug, error, info, warn}; +use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::core::ics04_channel::channel::{ ChannelEnd, Counterparty, IdentifiedChannelEnd, Order, State, }; @@ -1494,20 +1495,30 @@ impl Channel { IncludeProof::No, ) .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; + + if channel_end.state != State::Open { + return Err(ChannelError::invalid_channel_upgrade_state()); + } + + let new_ordering = new_ordering.unwrap_or(Default::default()); + + if new_ordering > channel_end.ordering { + return Err(ChannelError::invalid_channel_upgrade_ordering()); + } // Build the proposed channel end if let Some(new_version) = new_version { channel_end.version = new_version; } - if let Some(new_ordering) = new_ordering { - channel_end.ordering = new_ordering; - } - if let Some(new_connection_hops) = new_connection_hops { channel_end.connection_hops = new_connection_hops; } + channel_end.state = State::InitUpgrade; + + channel_end.ordering = new_ordering; + // Build the domain type message let signer = self .dst_chain() @@ -1533,8 +1544,15 @@ impl Channel { new_version: Option, new_ordering: Option, new_connection_hops: Option>, - timeout: UpgradeTimeout, + timeout_height: Option, + timeout_timestamp: Option, ) -> Result { + let timeout = if let Ok(timeout) = UpgradeTimeout::new(timeout_height, timeout_timestamp) { + timeout + } else { + return Err(ChannelError::invalid_channel_upgrade_timeout()); + }; + let dst_msgs = self.build_chan_upgrade_init(new_version, new_ordering, new_connection_hops, timeout)?; diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 7fc820ce89..40566efde3 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -34,6 +34,15 @@ define_error! { e.reason) }, + InvalidChannelUpgradeOrdering + |_| { "attempted to upgrade a channel to a more strict ordring, which is not allowed" }, + + InvalidChannelUpgradeState + |_| { "attempted to upgrade a channel that is not in the OPEN state" }, + + InvalidChannelUpgradeTimeout + |_| { "attempted to upgrade a channel without supplying at least one of timeout height or timeout timestamp" }, + MissingLocalChannelId |_| { "failed due to missing local channel id" }, From 90c049e7c89f726a0716548554b6bd6baf0764ab Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Mon, 17 Apr 2023 13:06:45 -0500 Subject: [PATCH 27/99] Cargo fmt --- crates/relayer-cli/src/commands/tx/channel.rs | 4 ++-- crates/relayer-types/src/core/ics04_channel/channel.rs | 4 ++-- crates/relayer/src/channel.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 2bd63fc7d5..ec8298dbb9 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -5,8 +5,6 @@ use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryConnectionRequest, QueryHeight}; use ibc_relayer::channel::{Channel, ChannelSide}; -use ibc_relayer_types::Height; -use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd; use ibc_relayer_types::core::ics04_channel::channel::Order; use ibc_relayer_types::core::ics04_channel::version::Version; @@ -14,6 +12,8 @@ use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; use ibc_relayer_types::events::IbcEvent; +use ibc_relayer_types::timestamp::Timestamp; +use ibc_relayer_types::Height; use crate::cli_utils::ChainHandlePair; use crate::conclude::Output; diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 8c82465e51..0230938c8e 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -394,7 +394,7 @@ pub enum State { /// A channel has been closed and can no longer be used to send or receive /// packets. Closed = 4, - /// A channel has just started the upgrade handshake. The chain that is + /// A channel has just started the upgrade handshake. The chain that is /// proposing the upgrade should set the channel state from OPEN to INITUPGRADE. InitUpgrade = 5, /// A channel has acknowledged the upgrade handshake step on the counterparty chain. @@ -452,7 +452,7 @@ impl State { /// ``` pub fn less_or_equal_progress(self, other: Self) -> bool { // TODO: Rewrite this function to explicitly compare the states, not relying - // on their integer representations. + // on their integer representations. self as u32 <= other as u32 } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 3cbc404ff0..fd17a743a6 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -7,7 +7,6 @@ use ibc_proto::google::protobuf::Any; use serde::Serialize; use tracing::{debug, error, info, warn}; -use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::core::ics04_channel::channel::{ ChannelEnd, Counterparty, IdentifiedChannelEnd, Order, State, }; @@ -23,6 +22,7 @@ use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; use ibc_relayer_types::events::IbcEvent; +use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; use ibc_relayer_types::Height; @@ -1495,7 +1495,7 @@ impl Channel { IncludeProof::No, ) .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; - + if channel_end.state != State::Open { return Err(ChannelError::invalid_channel_upgrade_state()); } From c895ae52822ff5d3a7a8d2829916499a277ac3b0 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Mon, 17 Apr 2023 13:11:05 -0500 Subject: [PATCH 28/99] Remove unnecessary CLI parameter --- crates/relayer-cli/src/commands/tx/channel.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index ec8298dbb9..aa981b3e8b 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -684,16 +684,6 @@ pub struct TxChanUpgradeInitCmd { )] dst_chain_id: ChainId, - #[clap( - long = "dst-connection", - visible_alias = "dst-conn", - required = true, - value_name = "DST_CONNECTION_ID", - help_heading = "REQUIRED", - help = "Identifier of the destination connection" - )] - dst_conn_id: ConnectionId, - #[clap( long = "dst-port", required = true, From 67893a89e21ba1c6838674525d34907000ce19b8 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 18 Apr 2023 09:45:41 +0200 Subject: [PATCH 29/99] Pass an `UpgradeTimeout` to `.build_chan_upgrade_init_and_send` --- crates/relayer-cli/src/commands/tx/channel.rs | 14 +++++++++++--- crates/relayer/src/channel.rs | 10 +--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index aa981b3e8b..56ae21a102 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -7,6 +7,7 @@ use ibc_relayer::channel::{Channel, ChannelSide}; use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd; use ibc_relayer_types::core::ics04_channel::channel::Order; +use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, @@ -748,6 +749,14 @@ impl Runnable for TxChanUpgradeInitCmd { fn run(&self) { let config = app_config(); + // Check that at least one of timeout_height and timeout_timestamp has been provided + let Ok(timeout) = UpgradeTimeout::new(self.timeout_height, self.timeout_timestamp) else { + Output::error( + "At least one of --timeout-height or --timeout-timestamp must be specified.", + ) + .exit(); + }; + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { Ok(chains) => chains, Err(e) => Output::error(format!("{}", e)).exit(), @@ -781,10 +790,9 @@ impl Runnable for TxChanUpgradeInitCmd { let res: Result = channel .build_chan_upgrade_init_and_send( self.version.clone(), - self.ordering.clone(), + self.ordering, self.connection_hops.clone(), - self.timeout_height.clone(), - self.timeout_timestamp.clone(), + timeout, ) .map_err(Error::channel); diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index fd17a743a6..0da398489e 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -22,7 +22,6 @@ use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; use ibc_relayer_types::events::IbcEvent; -use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; use ibc_relayer_types::Height; @@ -1544,15 +1543,8 @@ impl Channel { new_version: Option, new_ordering: Option, new_connection_hops: Option>, - timeout_height: Option, - timeout_timestamp: Option, + timeout: UpgradeTimeout, ) -> Result { - let timeout = if let Ok(timeout) = UpgradeTimeout::new(timeout_height, timeout_timestamp) { - timeout - } else { - return Err(ChannelError::invalid_channel_upgrade_timeout()); - }; - let dst_msgs = self.build_chan_upgrade_init(new_version, new_ordering, new_connection_hops, timeout)?; From e48553db10e072aee4dbc8631eb2f5a8b0d6afaf Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 18 Apr 2023 14:37:36 +0200 Subject: [PATCH 30/99] Fix bug when converting integer to channel state --- crates/relayer-types/src/core/ics04_channel/channel.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 0230938c8e..ba37b733b6 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -424,9 +424,9 @@ impl State { 1 => Ok(Self::Init), 2 => Ok(Self::TryOpen), 3 => Ok(Self::Open), - 4 => Ok(Self::InitUpgrade), - 5 => Ok(Self::TryUpgrade), - 6 => Ok(Self::Closed), + 4 => Ok(Self::Closed), + 5 => Ok(Self::InitUpgrade), + 6 => Ok(Self::TryUpgrade), _ => Err(Error::unknown_state(s)), } } From 1a00b3992b5d570992f1c9bea580d590cee3c6ef Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 18 Apr 2023 14:37:49 +0200 Subject: [PATCH 31/99] Proper implementation of `State::less_or_equal_progress` --- .../src/core/ics04_channel/channel.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index ba37b733b6..7737286a11 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -451,9 +451,20 @@ impl State { /// assert!(!State::Closed.less_or_equal_progress(State::Open)); /// ``` pub fn less_or_equal_progress(self, other: Self) -> bool { - // TODO: Rewrite this function to explicitly compare the states, not relying - // on their integer representations. - self as u32 <= other as u32 + use State::*; + + match self { + Uninitialized => true, + + Init => !matches!(other, Uninitialized), + TryOpen => !matches!(other, Uninitialized | Init), + Open => !matches!(other, Uninitialized | Init | TryOpen), + + InitUpgrade => !matches!(other, Uninitialized | Init | TryOpen | Open), + TryUpgrade => !matches!(other, Uninitialized | Init | TryOpen | Open | InitUpgrade), + + Closed => false, + } } } From 47c1d0c80e8362b10b2f9c8dc1594413a32b6642 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 12:31:30 -0500 Subject: [PATCH 32/99] Fix broken test --- .../src/core/ics04_channel/msgs/chan_upgrade_init.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index a5ef2049d0..ec196371c5 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -207,13 +207,14 @@ mod tests { want_pass: false, }, Test { - name: "Timeout timestamp is 0".to_string(), + name: "Timeout timestamp is 0 and no timeout height provided".to_string(), raw: RawMsgChannelUpgradeInit { + timeout_height: None, timeout_timestamp: 0, ..default_raw_msg }, want_pass: false, - } + }, ] .into_iter() .collect(); From 59734bdc95030b4f41bde9ae9e4985f17c2d793f Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 12:44:18 -0500 Subject: [PATCH 33/99] Ignore channel upgrade try tests for now --- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 9def0fbf5a..3549d2ce49 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -206,6 +206,7 @@ mod tests { use crate::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; #[test] + #[ignore] fn parse_channel_upgrade_init_msg() { struct Test { name: String, @@ -288,6 +289,7 @@ mod tests { } #[test] + #[ignore] fn to_and_from() { let raw = get_dummy_raw_msg_chan_upgrade_try(); let msg = MsgChannelUpgradeTry::try_from(raw.clone()).unwrap(); From 056b819ab6dbe0215f402a29148592c6f6fdebcc Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 13:22:20 -0500 Subject: [PATCH 34/99] Fix channel upgrade try tests --- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 3549d2ce49..27af6bd037 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -167,7 +167,7 @@ pub mod test_util { use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::prelude::*; - use crate::test_utils::get_dummy_bech32_account; + use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! pub fn get_dummy_raw_msg_chan_upgrade_try() -> RawMsgChannelUpgradeTry { @@ -183,9 +183,9 @@ pub mod test_util { revision_height: 1, }), timeout_timestamp: 1681737922, - proof_channel: vec![], - proof_upgrade_timeout: vec![], - proof_upgrade_sequence: vec![], + proof_channel: get_dummy_proof(), + proof_upgrade_timeout: get_dummy_proof(), + proof_upgrade_sequence: get_dummy_proof(), proof_height: Some(Height { revision_number: 1, revision_height: 1, @@ -206,7 +206,6 @@ mod tests { use crate::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; #[test] - #[ignore] fn parse_channel_upgrade_init_msg() { struct Test { name: String, @@ -289,7 +288,6 @@ mod tests { } #[test] - #[ignore] fn to_and_from() { let raw = get_dummy_raw_msg_chan_upgrade_try(); let msg = MsgChannelUpgradeTry::try_from(raw.clone()).unwrap(); From cdb3e18d3423aa0a8879b981d2dd66f29a47e719 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 14:35:44 -0500 Subject: [PATCH 35/99] Stub out build_channel_upgrade_try --- .../ics04_channel/msgs/chan_upgrade_try.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 27af6bd037..fcd406977a 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -269,6 +269,30 @@ mod tests { }, want_pass: false, }, + Test { + name: "Empty proof channel".to_string(), + raw: RawMsgChannelUpgradeTry { + proof_channel: vec![], + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Empty proof upgrade timeout".to_string(), + raw: RawMsgChannelUpgradeTry { + proof_upgrade_timeout: vec![], + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Empty proof upgrade sequence".to_string(), + raw: RawMsgChannelUpgradeTry { + proof_upgrade_sequence: vec![], + ..default_raw_msg.clone() + }, + want_pass: false, + } ] .into_iter() .collect(); From cf1afa5bfa1c8e194ed2400b9c04f8262712227e Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 14:36:23 -0500 Subject: [PATCH 36/99] Stub out build_channel_upgrade_try --- crates/relayer/src/channel.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 0da398489e..2d86faaf5f 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1578,6 +1578,9 @@ impl Channel { } } + + pub fn build_chan_upgrade_try(&self) -> Result, ChannelError> {} + pub fn map_chain( self, mapper_a: impl Fn(ChainA) -> ChainC, From 73296b7574f2568b47b9bfd2f36e516c7866d531 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 14:52:14 -0500 Subject: [PATCH 37/99] Fix return type of build_chan_upgrade_try --- crates/relayer/src/channel.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 2d86faaf5f..31e8bbfbcf 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1579,7 +1579,9 @@ impl Channel { } - pub fn build_chan_upgrade_try(&self) -> Result, ChannelError> {} + pub fn build_chan_upgrade_try(&self) -> Result, ChannelError> { + Ok(vec![]) + } pub fn map_chain( self, From ba248af2e5c30d3b9bcec9ddb1c318c10e5d7705 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 14:54:42 -0500 Subject: [PATCH 38/99] Cargo fmt --- crates/relayer/src/channel.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 31e8bbfbcf..a16eb1a656 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1578,7 +1578,6 @@ impl Channel { } } - pub fn build_chan_upgrade_try(&self) -> Result, ChannelError> { Ok(vec![]) } From eba95e76fde929b2355bf1ad21c3677053c9dbc6 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 15:00:36 -0500 Subject: [PATCH 39/99] Remove stub function --- crates/relayer/src/channel.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index a16eb1a656..0da398489e 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1578,10 +1578,6 @@ impl Channel { } } - pub fn build_chan_upgrade_try(&self) -> Result, ChannelError> { - Ok(vec![]) - } - pub fn map_chain( self, mapper_a: impl Fn(ChainA) -> ChainC, From f6c1bd33aa1010667c4df461a88b36a6559df0ca Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 15:52:11 -0500 Subject: [PATCH 40/99] Add missing clone --- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index fcd406977a..7e7e1d8015 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -265,7 +265,7 @@ mod tests { name: "Channel name too long".to_string(), raw: RawMsgChannelUpgradeTry { channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), - ..default_raw_msg + ..default_raw_msg.clone() }, want_pass: false, }, From d3a5f50b94239746ad1e6814914f6dcddd64857e Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 18 Apr 2023 16:00:25 -0500 Subject: [PATCH 41/99] Remove redundant clone --- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 7e7e1d8015..cfa4f0e014 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -289,7 +289,7 @@ mod tests { name: "Empty proof upgrade sequence".to_string(), raw: RawMsgChannelUpgradeTry { proof_upgrade_sequence: vec![], - ..default_raw_msg.clone() + ..default_raw_msg }, want_pass: false, } From 3253b2b0df6d9a1c8bd8e8eb9dc358a862649f65 Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Wed, 19 Apr 2023 09:32:42 +0200 Subject: [PATCH 42/99] Add integration tests for channel upgradability (#3247) * Add test for ChannelUpgradeInit step * Add conditional check 'channel-upgrade' to channel upgradability tests * Improve info message * Update event processing for UpgradeInit * Update UpgradeInit step test * Rename ChannelUpgradeInit test * Improve channel upgrade steps assertion * Add ChannelUpgradeAssertionAttributes struct for tests * Update tests after merge * Fix channel upgrade init step tests --- crates/relayer-types/src/events.rs | 1 + crates/relayer/src/cache.rs | 3 + crates/relayer/src/channel.rs | 1 + crates/relayer/src/event.rs | 13 + tools/integration-test/Cargo.toml | 1 + .../channel_upgrade/manual_channel_upgrade.rs | 131 ++++++++++ .../src/tests/channel_upgrade/mod.rs | 1 + tools/integration-test/src/tests/mod.rs | 3 + .../src/bootstrap/binary/chain.rs | 8 +- tools/test-framework/src/relayer/channel.rs | 225 +++++++++++++++++- tools/test-framework/src/relayer/driver.rs | 6 +- 11 files changed, 387 insertions(+), 6 deletions(-) create mode 100644 tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs create mode 100644 tools/integration-test/src/tests/channel_upgrade/mod.rs diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index 90b04a7784..91834f1a10 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -423,6 +423,7 @@ impl IbcEvent { IbcEvent::OpenTryChannel(ev) => Some(ev.into()), IbcEvent::OpenAckChannel(ev) => Some(ev.into()), IbcEvent::OpenConfirmChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeInitChannel(ev) => Some(ev.into()), _ => None, } } diff --git a/crates/relayer/src/cache.rs b/crates/relayer/src/cache.rs index 474f44ab4f..73038e7245 100644 --- a/crates/relayer/src/cache.rs +++ b/crates/relayer/src/cache.rs @@ -99,6 +99,9 @@ impl Cache { where F: FnOnce() -> Result, { + // FIXME: If a channel being upgraded is queried using Latest + // Height, it might return the wrong Channel End information. + // Find an alternative to avoid this issue if let Some(chan) = self.channels.get(id) { // If cache hit, return it. Ok((chan, CacheStatus::Hit)) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 0da398489e..f2e40b2f10 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1598,6 +1598,7 @@ pub fn extract_channel_id(event: &IbcEvent) -> Result<&ChannelId, ChannelError> IbcEvent::OpenTryChannel(ev) => ev.channel_id(), IbcEvent::OpenAckChannel(ev) => ev.channel_id(), IbcEvent::OpenConfirmChannel(ev) => ev.channel_id(), + IbcEvent::UpgradeInitChannel(ev) => Some(ev.channel_id()), _ => None, } .ok_or_else(|| ChannelError::missing_event("cannot extract channel_id from result".to_string())) diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index 0ed811c66e..55f7e9b7bd 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -109,6 +109,9 @@ pub fn ibc_event_try_from_abci_event(abci_event: &AbciEvent) -> Result Ok(IbcEvent::UpgradeInitChannel( + channel_upgrade_init_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, + )), Ok(IbcEventType::SendPacket) => Ok(IbcEvent::SendPacket( send_packet_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), @@ -250,6 +253,16 @@ pub fn channel_close_confirm_try_from_abci_event( } } +pub fn channel_upgrade_init_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeInit::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + pub fn send_packet_try_from_abci_event( abci_event: &AbciEvent, ) -> Result { diff --git a/tools/integration-test/Cargo.toml b/tools/integration-test/Cargo.toml index b5a12a0b95..9128941881 100644 --- a/tools/integration-test/Cargo.toml +++ b/tools/integration-test/Cargo.toml @@ -36,6 +36,7 @@ experimental = [] mbt = [] forward-packet = [] ics31 = [] +channel-upgrade = [] [[bin]] name = "test_setup_with_binary_channel" diff --git a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs new file mode 100644 index 0000000000..70eeb5965a --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs @@ -0,0 +1,131 @@ +use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; +use ibc_relayer_types::core::{ics02_client::height::Height, ics04_channel::version::Version}; +use ibc_test_framework::prelude::*; +use ibc_test_framework::relayer::channel::{ + assert_eventually_channel_established, assert_eventually_channel_upgrade_init, + init_channel_upgrade, ChannelUpgradeAssertionAttributes, +}; + +#[test] +fn test_channel_upgrade_init_handshake() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeInitHandshake) +} + +pub struct ChannelUpgradeInitHandshake; + +impl TestOverrides for ChannelUpgradeInitHandshake { + fn modify_test_config(&self, config: &mut TestConfig) { + config.bootstrap_with_random_ids = false; + } + + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.connections.enabled = true; + + config.mode.channels.enabled = false; + config.mode.packets.enabled = false; + config.mode.clients.enabled = false; + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeInitHandshake { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + let new_ordering = None; + let new_connection_hops = None; + + // Only Version is changed in this test. + let upgrade_attrs = ChannelUpgradeAssertionAttributes::new( + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + old_version, + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + ); + + let timeout_height = Height::new( + ChainId::chain_version(chains.chain_id_b().0.to_string().as_str()), + 120, + ) + .map_err(|e| eyre!("error creating height for timeout height: {e}"))?; + let timeout = UpgradeTimeout::Height(timeout_height); + + info!("Initialise channel upgrade process..."); + + let (channel_id_on_b, _) = init_channel_upgrade( + &chains.handle_a, + &chains.handle_b, + channel, + Some(new_version), + new_ordering, + new_connection_hops, + timeout, + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + assert_eventually_channel_upgrade_init( + &chains.handle_b, + &chains.handle_a, + &channel_id_on_b.as_ref(), + &channels.port_b.as_ref(), + &upgrade_attrs, + )?; + + Ok(()) + } +} diff --git a/tools/integration-test/src/tests/channel_upgrade/mod.rs b/tools/integration-test/src/tests/channel_upgrade/mod.rs new file mode 100644 index 0000000000..f5fee49272 --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/mod.rs @@ -0,0 +1 @@ +pub mod manual_channel_upgrade; diff --git a/tools/integration-test/src/tests/mod.rs b/tools/integration-test/src/tests/mod.rs index 15af40d757..1ff7b01fb0 100644 --- a/tools/integration-test/src/tests/mod.rs +++ b/tools/integration-test/src/tests/mod.rs @@ -25,6 +25,9 @@ pub mod tendermint; pub mod ternary_transfer; pub mod transfer; +#[cfg(any(doc, feature = "channel-upgrade"))] +pub mod channel_upgrade; + #[cfg(any(doc, feature = "ics29-fee"))] pub mod fee; diff --git a/tools/test-framework/src/bootstrap/binary/chain.rs b/tools/test-framework/src/bootstrap/binary/chain.rs index 5ed3029807..6caa841f15 100644 --- a/tools/test-framework/src/bootstrap/binary/chain.rs +++ b/tools/test-framework/src/bootstrap/binary/chain.rs @@ -4,7 +4,7 @@ */ use eyre::Report as Error; -use ibc_relayer::chain::handle::{ChainHandle, CountingAndCachingChainHandle}; +use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle, CountingChainHandle}; use ibc_relayer::config::Config; use ibc_relayer::error::ErrorDetail as RelayerErrorDetail; use ibc_relayer::foreign_client::{ @@ -241,8 +241,10 @@ pub fn add_keys_to_chain_handle( Create a new [`SharedRegistry`] that uses [`CountingAndCachingChainHandle`] as the [`ChainHandle`] implementation. */ -pub fn new_registry(config: Config) -> SharedRegistry { - >::new(config) +// FIXME: Temporarily disable CachingChainHandle for Chain Upgrade tests as the +// caching causes the queried Channel End to not have the correct information. +pub fn new_registry(config: Config) -> SharedRegistry> { + >>::new(config) } /** diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index 91d9043270..2057bdc57e 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -3,8 +3,10 @@ use eyre::eyre; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; use ibc_relayer::channel::{extract_channel_id, Channel, ChannelSide}; -use ibc_relayer_types::core::ics04_channel::channel::State as ChannelState; use ibc_relayer_types::core::ics04_channel::channel::{ChannelEnd, IdentifiedChannelEnd, Order}; +use ibc_relayer_types::core::ics04_channel::channel::{Ordering, State as ChannelState}; +use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; +use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::ConnectionId; use crate::error::Error; @@ -33,6 +35,73 @@ impl TaggedChannelEndExt } } +pub struct ChannelUpgradeAssertionAttributes { + old_version: Version, + old_ordering: Ordering, + old_connection_hops_a: Vec, + old_connection_hops_b: Vec, + new_version: Version, + new_ordering: Ordering, + new_connection_hops_a: Vec, + new_connection_hops_b: Vec, +} + +impl ChannelUpgradeAssertionAttributes { + pub fn new( + old_version: Version, + old_ordering: Ordering, + old_connection_hops_a: Vec, + old_connection_hops_b: Vec, + new_version: Version, + new_ordering: Ordering, + new_connection_hops_a: Vec, + new_connection_hops_b: Vec, + ) -> Self { + Self { + old_version, + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + new_version, + new_ordering, + new_connection_hops_a, + new_connection_hops_b, + } + } + + pub fn old_version(&self) -> &Version { + &self.old_version + } + + pub fn old_ordering(&self) -> &Ordering { + &self.old_ordering + } + + pub fn old_connection_hops_a(&self) -> &Vec { + &self.old_connection_hops_a + } + + pub fn old_connection_hops_b(&self) -> &Vec { + &self.old_connection_hops_b + } + + pub fn new_version(&self) -> &Version { + &self.new_version + } + + pub fn new_ordering(&self) -> &Ordering { + &self.new_ordering + } + + pub fn new_connection_hops_a(&self) -> &Vec { + &self.new_connection_hops_a + } + + pub fn new_connection_hops_b(&self) -> &Vec { + &self.new_connection_hops_b + } +} + pub fn init_channel( handle_a: &ChainA, handle_b: &ChainB, @@ -207,3 +276,157 @@ pub fn assert_eventually_channel_established( + handle_a: &ChainA, + handle_b: &ChainB, + channel: Channel, + new_version: Option, + new_ordering: Option, + new_connection_hops: Option>, + timeout: UpgradeTimeout, +) -> Result<(TaggedChannelId, Channel), Error> { + let event = channel.build_chan_upgrade_init_and_send( + new_version, + new_ordering, + new_connection_hops, + timeout, + )?; + let channel_id = extract_channel_id(&event)?.clone(); + let channel2 = Channel::restore_from_event(handle_b.clone(), handle_a.clone(), event)?; + Ok((DualTagged::new(channel_id), channel2)) +} + +pub fn assert_eventually_channel_upgrade_init( + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + upgrade_attrs: &ChannelUpgradeAssertionAttributes, +) -> Result, Error> { + assert_eventually_succeed( + "channel upgrade should be initialised", + 20, + Duration::from_secs(1), + || { + assert_eventually_succeed( + "channel upgrade should be initialised", + 20, + Duration::from_secs(1), + || { + assert_channel_upgrade_state( + ChannelState::InitUpgrade, + ChannelState::Open, + handle_a, + handle_b, + channel_id_a, + port_id_a, + upgrade_attrs, + ) + }, + ) + }, + ) +} + +fn assert_channel_upgrade_state( + a_side_state: ChannelState, + b_side_state: ChannelState, + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + upgrade_attrs: &ChannelUpgradeAssertionAttributes, +) -> Result, Error> { + let channel_end_a = query_channel_end(handle_a, channel_id_a, port_id_a)?; + + if !channel_end_a.value().state_matches(&a_side_state) { + return Err(Error::generic(eyre!( + "expected channel end A to `{}`, but is instead `{}`", + a_side_state, + channel_end_a.value().state() + ))); + } + + if !channel_end_a + .value() + .version_matches(upgrade_attrs.new_version()) + { + return Err(Error::generic(eyre!( + "expected channel end A version to be `{}`, but it is instead `{}`", + upgrade_attrs.new_version(), + channel_end_a.value().version() + ))); + } + + if !channel_end_a + .value() + .order_matches(upgrade_attrs.new_ordering()) + { + return Err(Error::generic(eyre!( + "expected channel end A ordering to be `{}`, but it is instead `{}`", + upgrade_attrs.new_ordering(), + channel_end_a.value().ordering() + ))); + } + + if !channel_end_a + .value() + .connection_hops_matches(upgrade_attrs.new_connection_hops_a()) + { + return Err(Error::generic(eyre!( + "expected channel end A connection hops to be `{:?}`, but it is instead `{:?}`", + upgrade_attrs.new_connection_hops_a(), + channel_end_a.value().connection_hops() + ))); + } + + let channel_id_b = channel_end_a + .tagged_counterparty_channel_id() + .ok_or_else(|| eyre!("expected counterparty channel id to present on open channel"))?; + + let port_id_b = channel_end_a.tagged_counterparty_port_id(); + + let channel_end_b = query_channel_end(handle_b, &channel_id_b.as_ref(), &port_id_b.as_ref())?; + + if !channel_end_b.value().state_matches(&b_side_state) { + return Err(Error::generic(eyre!( + "expected channel end B to be in open state" + ))); + } + + if !channel_end_b + .value() + .version_matches(upgrade_attrs.old_version()) + { + return Err(Error::generic(eyre!( + "expected channel end B version to be `{}`, but it is instead `{}`", + upgrade_attrs.new_version(), + channel_end_b.value().version() + ))); + } + + if !channel_end_b + .value() + .order_matches(upgrade_attrs.old_ordering()) + { + return Err(Error::generic(eyre!( + "expected channel end B ordering to be `{}`, but it is instead `{}`", + upgrade_attrs.new_ordering(), + channel_end_b.value().ordering() + ))); + } + + if !channel_end_b + .value() + .connection_hops_matches(upgrade_attrs.old_connection_hops_b()) + { + return Err(Error::generic(eyre!( + "expected channel end B connection hops to be `{:?}`, but it is instead `{:?}`", + upgrade_attrs.new_connection_hops_b(), + channel_end_b.value().connection_hops() + ))); + } + + Ok(channel_id_b) +} diff --git a/tools/test-framework/src/relayer/driver.rs b/tools/test-framework/src/relayer/driver.rs index 4e16c3483d..1b29af94f3 100644 --- a/tools/test-framework/src/relayer/driver.rs +++ b/tools/test-framework/src/relayer/driver.rs @@ -2,7 +2,7 @@ Driver for spawning the relayer. */ -use ibc_relayer::chain::handle::CountingAndCachingChainHandle; +use ibc_relayer::chain::handle::{BaseChainHandle, CountingChainHandle}; use ibc_relayer::config::Config; use ibc_relayer::registry::SharedRegistry; use ibc_relayer::supervisor::{spawn_supervisor, SupervisorHandle, SupervisorOptions}; @@ -41,7 +41,9 @@ pub struct RelayerDriver { Use this shared registry when spawning new supervisor using [`spawn_supervisor`](ibc_relayer::supervisor::spawn_supervisor). */ - pub registry: SharedRegistry, + // FIXME: Temporarily disable CachingChainHandle for Chain Upgrade tests as the + // caching causes the queried Channel End to not have the correct information. + pub registry: SharedRegistry>, /** Whether the driver should hang the test when the continuation From b46d3d0bde9cdf5d3a154d0067bf4e08baffbb2c Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 19 Apr 2023 10:44:27 +0200 Subject: [PATCH 43/99] Fix check for new channel ordering --- .../src/core/ics04_channel/channel.rs | 31 +++++++------------ crates/relayer/src/channel.rs | 10 +++--- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 7737286a11..dccacce502 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -327,7 +327,7 @@ pub type Ordering = Order; #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, Default, PartialOrd, Ord)] pub enum Order { - None = 0, + Uninitialized = 0, #[default] Unordered = 1, Ordered = 2, @@ -343,7 +343,7 @@ impl Order { /// Yields the Order as a string pub fn as_str(&self) -> &'static str { match self { - Self::None => "UNINITIALIZED", + Self::Uninitialized => "UNINITIALIZED", Self::Unordered => "ORDER_UNORDERED", Self::Ordered => "ORDER_ORDERED", } @@ -352,9 +352,10 @@ impl Order { // Parses the Order out from a i32. pub fn from_i32(nr: i32) -> Result { match nr { - 0 => Ok(Self::None), + 0 => Ok(Self::Uninitialized), 1 => Ok(Self::Unordered), 2 => Ok(Self::Ordered), + _ => Err(Error::unknown_order_type(nr.to_string())), } } @@ -365,7 +366,7 @@ impl FromStr for Order { fn from_str(s: &str) -> Result { match s.to_lowercase().trim_start_matches("order_") { - "uninitialized" => Ok(Self::None), + "uninitialized" => Ok(Self::Uninitialized), "unordered" => Ok(Self::Unordered), "ordered" => Ok(Self::Ordered), _ => Err(Error::unknown_order_type(s.to_string())), @@ -610,29 +611,24 @@ mod tests { struct Test { ordering: &'static str, - want_res: Order, - want_err: bool, + want_res: Option, } let tests: Vec = vec![ Test { ordering: "UNINITIALIZED", - want_res: Order::None, - want_err: false, + want_res: Some(Order::Uninitialized), }, Test { ordering: "UNORDERED", - want_res: Order::Unordered, - want_err: false, + want_res: Some(Order::Unordered), }, Test { ordering: "ORDERED", - want_res: Order::Ordered, - want_err: false, + want_res: Some(Order::Ordered), }, Test { ordering: "UNKNOWN_ORDER", - want_res: Order::None, - want_err: true, + want_res: None, }, ] .into_iter() @@ -640,11 +636,8 @@ mod tests { for test in tests { match Order::from_str(test.ordering) { - Ok(res) => { - assert!(!test.want_err); - assert_eq!(test.want_res, res); - } - Err(_) => assert!(test.want_err, "parse failed"), + Ok(res) => assert_eq!(test.want_res, Some(res)), + Err(_) => assert!(test.want_res.is_none(), "parse failed"), } } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index f2e40b2f10..a4f8b984a9 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1499,10 +1499,12 @@ impl Channel { return Err(ChannelError::invalid_channel_upgrade_state()); } - let new_ordering = new_ordering.unwrap_or(Default::default()); + if let Some(new_ordering) = new_ordering { + if new_ordering == Order::Uninitialized || new_ordering > channel_end.ordering { + return Err(ChannelError::invalid_channel_upgrade_ordering()); + } - if new_ordering > channel_end.ordering { - return Err(ChannelError::invalid_channel_upgrade_ordering()); + channel_end.ordering = new_ordering; } // Build the proposed channel end @@ -1516,8 +1518,6 @@ impl Channel { channel_end.state = State::InitUpgrade; - channel_end.ordering = new_ordering; - // Build the domain type message let signer = self .dst_chain() From fa873024a2ca5464f36b429f53b2930324a80c92 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 19 Apr 2023 08:15:00 -0500 Subject: [PATCH 44/99] Fix broken doc comment link --- tools/test-framework/src/bootstrap/binary/chain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-framework/src/bootstrap/binary/chain.rs b/tools/test-framework/src/bootstrap/binary/chain.rs index 6caa841f15..6763385ddb 100644 --- a/tools/test-framework/src/bootstrap/binary/chain.rs +++ b/tools/test-framework/src/bootstrap/binary/chain.rs @@ -238,7 +238,7 @@ pub fn add_keys_to_chain_handle( } /** - Create a new [`SharedRegistry`] that uses [`CountingAndCachingChainHandle`] + Create a new [`SharedRegistry`] that uses [`ibc_relayer::chain::handle::CountingAndCachingChainHandle`] as the [`ChainHandle`] implementation. */ // FIXME: Temporarily disable CachingChainHandle for Chain Upgrade tests as the From feea74bf3892d67c4a2ce5129a127ded443a6232 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 19 Apr 2023 12:12:00 -0500 Subject: [PATCH 45/99] Progress on build_chan_upgrade_try --- crates/relayer/src/channel.rs | 65 +++++++++++++++++++++++++++++ crates/relayer/src/channel/error.rs | 8 ++++ 2 files changed, 73 insertions(+) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 6e716ba6a3..1f78ef3b5e 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -18,6 +18,7 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpen use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; +use ibc_relayer_types::core::ics23_commitment::commitment::CommitmentProofBytes; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; @@ -1578,6 +1579,70 @@ impl Channel { } } + pub fn build_chan_upgrade_try(&self, timeout: UpgradeTimeout) -> Result, ChannelError> { + // Source channel ID must exist + let src_channel_id = self + .src_channel_id() + .ok_or_else(ChannelError::missing_local_channel_id)?; + + // Channel must exist on the souce chain + let (channe_end, maybe_channel_proof) = self + .src_chain() + .query_channel( + QueryChannelRequest { + port_id: self.src_port_id().clone(), + channel_id: src_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::Yes + ) + .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; + + if channel_end.counterparty().port_id() != self.dst_port_id() { + return Err(ChannelError::mismatch_port( + self.dst_chain().id(), + self.dst_port_id().clone(), + self.src_chain().id(), + src_channel.counterparty().port_id().clone(), + src_channel_id.clone(), + )); + } + + let Some(channel_proof) = maybe_channel_proof else { + return Err(ChannelError::missing_channel_proof()); + }; + + let channel_proof_bytes = CommitmentProofBytes::try_from(channel_proof).map_err(Error::malformed_proof)?; + + if channel_end.state != State::InitUpgrade { + return Err(ChannelError::invalid_channel_upgrade_state()); + } + + channel_end.state = State::TryUpgrade; + + let signer = self + .dst_chain() + .get_signer() + .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; + + // Build the domain type message + let new_msg = MsgChannelUpgradeTry { + port_id: port_id.clone(), + channel_id: channel_id.clone(), + proposed_upgrade_channel: channel_end, + signer, + counterparty_channel, + counterparty_sequence, + timeout, + proof_channel: channel_proof_bytes, + proof_upgrade_timeout, + proof_upgrade_sequence, + proof_height, + }; + + Ok(vec![new_msg.to_any()]) + } + pub fn map_chain( self, mapper_a: impl Fn(ChainA) -> ChainC, diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 40566efde3..186c61e0de 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -8,6 +8,7 @@ use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, PortChannelId, PortId, }; use ibc_relayer_types::events::IbcEvent; +use ibc_relayer_types::proofs::ProofError; use crate::error::Error as RelayerError; use crate::foreign_client::{ForeignClientError, HasExpiredOrFrozenError}; @@ -62,6 +63,13 @@ define_error! { MissingChannelOnDestination |_| { "missing channel on destination chain" }, + MissingChannelProof + |_| { "missing channel proof" }, + + MalformedProof + [ ProofError ] + |_| { "malformed proof" }, + ChannelProof [ RelayerError ] |_| { "failed to build channel proofs" }, From 6fe71ccfd0e6f291cb96d24ee57d2bc92a7938aa Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 19 Apr 2023 14:18:43 -0500 Subject: [PATCH 46/99] Progress on build_chan_upgrade_try --- crates/relayer/src/channel.rs | 20 ++++++++++++-------- crates/relayer/src/channel/error.rs | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 1f78ef3b5e..7f02d90a35 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -17,8 +17,8 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_confirm::MsgChannelO use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; -use ibc_relayer_types::core::ics23_commitment::commitment::CommitmentProofBytes; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; @@ -1585,12 +1585,14 @@ impl Channel { .src_channel_id() .ok_or_else(ChannelError::missing_local_channel_id)?; + let src_port_id = self.src_port_id(); + // Channel must exist on the souce chain - let (channe_end, maybe_channel_proof) = self + let (channel_end, maybe_channel_proof) = self .src_chain() .query_channel( QueryChannelRequest { - port_id: self.src_port_id().clone(), + port_id: src_port_id.clone(), channel_id: src_channel_id.clone(), height: QueryHeight::Latest, }, @@ -1608,6 +1610,8 @@ impl Channel { )); } + let mut proposed_upgrade_channel = channel_end.clone(); + let Some(channel_proof) = maybe_channel_proof else { return Err(ChannelError::missing_channel_proof()); }; @@ -1618,7 +1622,7 @@ impl Channel { return Err(ChannelError::invalid_channel_upgrade_state()); } - channel_end.state = State::TryUpgrade; + proposed_upgrade_channel.state = State::TryUpgrade; let signer = self .dst_chain() @@ -1627,11 +1631,11 @@ impl Channel { // Build the domain type message let new_msg = MsgChannelUpgradeTry { - port_id: port_id.clone(), - channel_id: channel_id.clone(), - proposed_upgrade_channel: channel_end, + port_id: src_port_id.clone(), + channel_id: src_channel_id.clone(), + proposed_upgrade_channel, signer, - counterparty_channel, + counterparty_channel: channel_end, counterparty_sequence, timeout, proof_channel: channel_proof_bytes, diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 186c61e0de..42c4e8c100 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -65,7 +65,7 @@ define_error! { MissingChannelProof |_| { "missing channel proof" }, - + MalformedProof [ ProofError ] |_| { "malformed proof" }, From 9243470151a953ab88cab81e1c8f61e8df4f57ec Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 20 Apr 2023 13:39:37 +0200 Subject: [PATCH 47/99] Update ChanUpgradeInit step to use new design improvements --- Cargo.lock | 206 +++++++++--------- crates/relayer-cli/src/commands/tx.rs | 3 + .../src/core/ics04_channel/channel.rs | 9 + .../src/core/ics04_channel/error.rs | 5 +- .../src/core/ics04_channel/mod.rs | 1 + .../ics04_channel/msgs/chan_upgrade_init.rs | 70 +++--- .../src/core/ics04_channel/timeout.rs | 41 ++++ .../src/core/ics04_channel/upgrade_fields.rs | 82 +++++++ crates/relayer/src/channel.rs | 34 ++- crates/relayer/src/channel/error.rs | 2 +- 10 files changed, 300 insertions(+), 153 deletions(-) create mode 100644 crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs diff --git a/Cargo.lock b/Cargo.lock index f54591f3ba..a1c6e8140e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,42 +89,51 @@ dependencies = [ [[package]] name = "anstream" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f" +checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" dependencies = [ "anstyle", "anstyle-parse", + "anstyle-query", "anstyle-wincon", - "concolor-override", - "concolor-query", + "colorchoice", "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "0.3.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" [[package]] name = "anstyle-parse" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "anstyle-wincon" -version = "0.2.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" +checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" dependencies = [ "anstyle", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -158,7 +167,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -169,7 +178,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -207,9 +216,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.12" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f8ccfd9221ee7d1f3d4b33e1f8319b3a81ed8f61f2ea40b37b859794b4491" +checksum = "113713495a32dd0ab52baf5c10044725aa3aec00b31beda84218e469029b72a3" dependencies = [ "async-trait", "axum-core", @@ -239,9 +248,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2f958c80c248b34b9a877a643811be8dbca03ca5ba827f2b63baf3a81e5fc4e" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", "bytes", @@ -505,18 +514,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.1" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" +checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.2.1" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f" +checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" dependencies = [ "anstream", "anstyle", @@ -542,7 +551,7 @@ version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01c22dcfb410883764b29953103d9ef7bb8fe21b3fa1158bc99986c2067294bd" dependencies = [ - "clap 4.2.1", + "clap 4.2.4", ] [[package]] @@ -611,19 +620,10 @@ dependencies = [ ] [[package]] -name = "concolor-override" +name = "colorchoice" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f" - -[[package]] -name = "concolor-query" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" -dependencies = [ - "windows-sys 0.45.0", -] +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "console" @@ -820,7 +820,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -837,7 +837,7 @@ checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -881,9 +881,9 @@ dependencies = [ [[package]] name = "dialoguer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af3c796f3b0b408d9fd581611b47fa850821fcb84aa640b83a3c1a5be2d691f2" +checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" dependencies = [ "console", "shell-words", @@ -1089,13 +1089,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1158,14 +1158,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall 0.2.16", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1284,7 +1284,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -1340,9 +1340,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1359,9 +1359,9 @@ checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" [[package]] name = "gitignore" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78aa90e4620c1498ac434c06ba6e521b525794bbdacf085d490cc794b4a2f9a4" +checksum = "7d051488d9a601181a9b90c9ad8ae7e8251d642ddd2463008f2f5019d255bd89" dependencies = [ "glob", ] @@ -1405,9 +1405,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" dependencies = [ "bytes", "fnv", @@ -1599,9 +1599,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.25" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -1745,7 +1745,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.29.0" -source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#e64f2bbb1746ec83aff65197c22783dc3d00a68b" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#d9450a59e95d8573f936fef6a4e0e201bd6fa40f" dependencies = [ "base64 0.21.0", "bytes", @@ -1817,7 +1817,7 @@ dependencies = [ "tonic", "tracing", "tracing-subscriber", - "uuid 1.3.0", + "uuid 1.3.1", ] [[package]] @@ -2045,13 +2045,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2062,14 +2062,14 @@ checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2160,9 +2160,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "9b085a4f2cde5781fc4b1717f2e86c62f5cda49de7ba99a7c2eae02b61c9064c" [[package]] name = "lock_api" @@ -2248,7 +2248,7 @@ dependencies = [ "ammonia", "anyhow", "chrono", - "clap 4.2.1", + "clap 4.2.4", "clap_complete 4.2.0", "elasticlunr-rs", "env_logger 0.10.0", @@ -2362,7 +2362,7 @@ dependencies = [ "tagptr", "thiserror", "triomphe", - "uuid 1.3.0", + "uuid 1.3.1", ] [[package]] @@ -2696,7 +2696,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -2853,9 +2853,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", "prost-derive", @@ -2863,9 +2863,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", @@ -2876,9 +2876,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ "prost", ] @@ -2998,7 +2998,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -3043,7 +3043,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", "redox_syscall 0.2.16", "thiserror", ] @@ -3156,9 +3156,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -3177,16 +3177,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.7" +version = "0.37.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d" +checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -3471,9 +3471,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.159" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" dependencies = [ "serde_derive", ] @@ -3499,20 +3499,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.159" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -3536,7 +3536,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -3553,9 +3553,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.19" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82e6c8c047aa50a7328632d067bcae6ef38772a79e28daf32f735e0e4f3dd10" +checksum = "d9d684e3ec7de3bf5466b32bd75303ac16f0736426e5a4e0d6e489559ce1249c" dependencies = [ "indexmap", "itoa", @@ -3626,9 +3626,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "54c2bb1a323307527314a36bfb73f24febb08ce2b8a554bf4ffd6f51ad15198c" dependencies = [ "digest 0.10.6", "keccak", @@ -3836,9 +3836,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -3991,7 +3991,7 @@ dependencies = [ "bytes", "flex-error", "futures", - "getrandom 0.2.8", + "getrandom 0.2.9", "http", "hyper", "hyper-proxy", @@ -4095,7 +4095,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -4214,7 +4214,7 @@ checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -4297,9 +4297,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bd8e87955eb13c1986671838177d6792cdc52af9bffced0d2c8a9a7f741ab3" +checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" dependencies = [ "async-stream", "async-trait", @@ -4552,9 +4552,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "unsafe-libyaml" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2024452afd3874bf539695e04af6732ba06517424dbf958fdb16a01f3bef6c" +checksum = "1865806a559042e51ab5414598446a5871b561d21b6764f2eabb0dd481d880a6" [[package]] name = "untrusted" @@ -4599,11 +4599,11 @@ checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "uuid" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" +checksum = "5b55a3fef2a1e3b3a00ce878640918820d3c51081576ac657d23af9fc7928fdb" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -5016,5 +5016,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] diff --git a/crates/relayer-cli/src/commands/tx.rs b/crates/relayer-cli/src/commands/tx.rs index f8cadf766b..d434fa6f3c 100644 --- a/crates/relayer-cli/src/commands/tx.rs +++ b/crates/relayer-cli/src/commands/tx.rs @@ -44,6 +44,9 @@ pub enum TxCmd { /// Confirm the closing of a channel (ChannelCloseConfirm) ChanCloseConfirm(channel::TxChanCloseConfirmCmd), + // TODO + ChanUpgradeInit(channel::TxChanUpgradeInitCmd), + /// Send a fungible token transfer test transaction (ICS20 MsgTransfer) FtTransfer(transfer::TxIcs20MsgTransferCmd), diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 7546ab94af..0e507cc0a0 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -12,6 +12,7 @@ use ibc_proto::ibc::core::channel::v1::{ IdentifiedChannel as RawIdentifiedChannel, }; +use crate::core::ics04_channel::packet::Sequence; use crate::core::ics04_channel::{error::Error, version::Version}; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; @@ -44,6 +45,7 @@ impl TryFrom for IdentifiedChannelEnd { counterparty: value.counterparty, connection_hops: value.connection_hops, version: value.version, + upgrade_sequence: 0, // FIXME: proto IdentifiedChannel does not have this field, should we default to 0 ? }; Ok(IdentifiedChannelEnd { @@ -80,6 +82,7 @@ pub struct ChannelEnd { pub remote: Counterparty, pub connection_hops: Vec, pub version: Version, + pub upgraded_sequence: Sequence, } impl Display for ChannelEnd { @@ -100,6 +103,7 @@ impl Default for ChannelEnd { remote: Counterparty::default(), connection_hops: Vec::new(), version: Version::default(), + upgraded_sequence: Sequence::from(0), // The value of 0 indicates the channel has never been upgraded } } } @@ -140,6 +144,7 @@ impl TryFrom for ChannelEnd { remote, connection_hops, version, + Sequence::from(value.upgrade_sequence), )) } } @@ -156,6 +161,7 @@ impl From for RawChannel { .map(|v| v.as_str().to_string()) .collect(), version: value.version.to_string(), + upgrade_sequence: value.upgraded_sequence.into(), } } } @@ -168,6 +174,7 @@ impl ChannelEnd { remote: Counterparty, connection_hops: Vec, version: Version, + upgraded_sequence: Sequence, ) -> Self { Self { state, @@ -175,6 +182,7 @@ impl ChannelEnd { remote, connection_hops, version, + upgraded_sequence, } } @@ -498,6 +506,7 @@ pub mod test_util { counterparty: Some(get_dummy_raw_counterparty()), connection_hops: vec![ConnectionId::default().to_string()], version: "ics20".to_string(), // The version is not validated. + upgrade_sequence: 0, // The value of 0 indicates the channel has never been upgraded } } } diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index 320c976bca..84b9a29313 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -359,7 +359,10 @@ define_error! { AbciConversionFailed { abci_event: String } - | e | { format_args!("Failed to convert abci event to IbcEvent: {}", e.abci_event)} + | e | { format_args!("Failed to convert abci event to IbcEvent: {}", e.abci_event)}, + + ParseConnectionHopsVector + | _ | { "error converting vector of String to vector of ConnectionId" } } } diff --git a/crates/relayer-types/src/core/ics04_channel/mod.rs b/crates/relayer-types/src/core/ics04_channel/mod.rs index 21d1378da6..4bf63432aa 100644 --- a/crates/relayer-types/src/core/ics04_channel/mod.rs +++ b/crates/relayer-types/src/core/ics04_channel/mod.rs @@ -9,4 +9,5 @@ pub mod msgs; pub mod packet; pub mod packet_id; pub mod timeout; +pub mod upgrade_fields; pub mod version; diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index ec196371c5..88936468d7 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -1,11 +1,9 @@ -use crate::timestamp::Timestamp; -use crate::{prelude::*, Height}; - -use ibc_proto::protobuf::Protobuf; +use crate::core::ics04_channel::upgrade_fields::UpgradeFields; +use crate::prelude::*; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; +use ibc_proto::protobuf::Protobuf; -use crate::core::ics04_channel::channel::ChannelEnd; use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::timeout::UpgradeTimeout; use crate::core::ics24_host::identifier::{ChannelId, PortId}; @@ -20,7 +18,7 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeInit"; pub struct MsgChannelUpgradeInit { pub port_id: PortId, pub channel_id: ChannelId, - pub proposed_upgrade_channel: ChannelEnd, + pub fields: UpgradeFields, pub timeout: UpgradeTimeout, pub signer: Signer, } @@ -29,14 +27,14 @@ impl MsgChannelUpgradeInit { pub fn new( port_id: PortId, channel_id: ChannelId, - proposed_upgrade_channel: ChannelEnd, + fields: UpgradeFields, timeout: UpgradeTimeout, signer: Signer, ) -> Self { Self { port_id, channel_id, - proposed_upgrade_channel, + fields, timeout, signer, } @@ -62,31 +60,24 @@ impl TryFrom for MsgChannelUpgradeInit { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeInit) -> Result { - let proposed_upgrade_channel = raw_msg - .proposed_upgrade_channel - .ok_or_else(Error::missing_proposed_upgrade_channel)? - .try_into()?; - - let timeout_height = raw_msg - .timeout_height - .map(Height::try_from) - .transpose() - .map_err(|_| Error::invalid_timeout_height())?; - - let timeout_timestamp = Some(raw_msg.timeout_timestamp) - .filter(|&ts| ts != 0) - .map(|raw_ts| { - Timestamp::from_nanoseconds(raw_ts).map_err(Error::invalid_timeout_timestamp) - }) - .transpose()?; - - let timeout = UpgradeTimeout::new(timeout_height, timeout_timestamp)?; + let raw_timeout = raw_msg + .timeout + .ok_or(Self::Error::missing_upgrade_timeout())?; + + let timeout = UpgradeTimeout::try_from(raw_timeout) + .map_err(|_| Self::Error::invalid_timeout_height())?; + + let raw_fields = raw_msg + .fields + .ok_or(Self::Error::missing_upgrade_timeout())?; + + let fields = UpgradeFields::try_from(raw_fields)?; Ok(MsgChannelUpgradeInit { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, - proposed_upgrade_channel, + fields, timeout, }) } @@ -94,15 +85,12 @@ impl TryFrom for MsgChannelUpgradeInit { impl From for RawMsgChannelUpgradeInit { fn from(domain_msg: MsgChannelUpgradeInit) -> Self { - let (timeout_height, timeout_timestamp) = domain_msg.timeout.into_tuple(); - Self { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), signer: domain_msg.signer.to_string(), - proposed_upgrade_channel: Some(domain_msg.proposed_upgrade_channel.into()), - timeout_height: timeout_height.map(Into::into), - timeout_timestamp: timeout_timestamp.map(|ts| ts.nanoseconds()).unwrap_or(0), + fields: Some(domain_msg.fields.into()), + timeout: Some(domain_msg.timeout.into()), } } } @@ -110,9 +98,10 @@ impl From for RawMsgChannelUpgradeInit { #[cfg(test)] pub mod test_util { use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; + use ibc_proto::ibc::core::channel::v1::UpgradeTimeout as RawUpgradeTimeout; use crate::core::ics02_client::height::Height; - use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; + use crate::core::ics04_channel::upgrade_fields::test_util::get_dummy_upgrade_fields; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::prelude::*; use crate::test_utils::get_dummy_bech32_account; @@ -120,13 +109,16 @@ pub mod test_util { /// Returns a dummy `RawMsgChannelUpgadeInit`, for testing only! pub fn get_dummy_raw_msg_chan_upgrade_init() -> RawMsgChannelUpgradeInit { + let dummy_timeout = RawUpgradeTimeout { + height: Some(Height::new(0, 10).unwrap().into()), + timestamp: Timestamp::now().nanoseconds(), + }; RawMsgChannelUpgradeInit { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), signer: get_dummy_bech32_account(), - proposed_upgrade_channel: Some(get_dummy_raw_channel_end()), - timeout_height: Some(Height::new(0, 10).unwrap().into()), - timeout_timestamp: Timestamp::now().nanoseconds(), + fields: Some(get_dummy_upgrade_fields()), + timeout: Some(dummy_timeout), } } } @@ -138,6 +130,7 @@ mod tests { use test_log::test; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; + use ibc_proto::ibc::core::channel::v1::UpgradeTimeout as RawUpgradeTimeout; use crate::core::ics04_channel::msgs::chan_upgrade_init::test_util::get_dummy_raw_msg_chan_upgrade_init; use crate::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; @@ -209,8 +202,7 @@ mod tests { Test { name: "Timeout timestamp is 0 and no timeout height provided".to_string(), raw: RawMsgChannelUpgradeInit { - timeout_height: None, - timeout_timestamp: 0, + timeout: Some(RawUpgradeTimeout { height: None, timestamp: 0 }), ..default_raw_msg }, want_pass: false, diff --git a/crates/relayer-types/src/core/ics04_channel/timeout.rs b/crates/relayer-types/src/core/ics04_channel/timeout.rs index 4b2fc58254..5881976c56 100644 --- a/crates/relayer-types/src/core/ics04_channel/timeout.rs +++ b/crates/relayer-types/src/core/ics04_channel/timeout.rs @@ -4,7 +4,9 @@ use core::fmt::{Display, Error as FmtError, Formatter}; use serde::{Deserialize, Serialize}; +use ibc_proto::ibc::core::channel::v1::UpgradeTimeout as RawUpgradeTimeout; use ibc_proto::ibc::core::client::v1::Height as RawHeight; +use ibc_proto::protobuf::Protobuf; use crate::core::ics02_client::{error::Error as ICS2Error, height::Height}; use crate::core::ics04_channel::error::Error as ChannelError; @@ -222,3 +224,42 @@ impl UpgradeTimeout { } } } + +impl Protobuf for UpgradeTimeout {} + +impl TryFrom for UpgradeTimeout { + type Error = ChannelError; + + fn try_from(value: RawUpgradeTimeout) -> Result { + let timeout_height = value + .height + .map(Height::try_from) + .transpose() + .map_err(|_| Self::Error::invalid_timeout_height())?; + + let timeout_timestamp = Timestamp::from_nanoseconds(value.timestamp) + .map_err(|_| Self::Error::invalid_timeout_timestamp) + .ok(); + + Self::new(timeout_height, timeout_timestamp) + } +} + +impl From for RawUpgradeTimeout { + fn from(value: UpgradeTimeout) -> Self { + match value { + UpgradeTimeout::Height(height) => Self { + height: RawHeight::try_from(height).ok(), + timestamp: 0, + }, + UpgradeTimeout::Timestamp(timestamp) => Self { + height: None, + timestamp: timestamp.nanoseconds(), + }, + UpgradeTimeout::Both(height, timestamp) => Self { + height: RawHeight::try_from(height).ok(), + timestamp: timestamp.nanoseconds(), + }, + } + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs new file mode 100644 index 0000000000..f8511e01b9 --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs @@ -0,0 +1,82 @@ +use core::str::FromStr; + +use alloc::string::ToString; +use alloc::vec::Vec; +use ibc_proto::ibc::core::channel::v1::UpgradeFields as RawUpgradeFields; +use ibc_proto::protobuf::Protobuf; +use itertools::Itertools; + +use crate::core::ics04_channel::channel::Ordering; +use crate::core::ics04_channel::error::Error as ChannelError; +use crate::core::ics04_channel::version::Version; +use crate::core::ics24_host::identifier::ConnectionId; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct UpgradeFields { + ordering: Ordering, + connection_hops: Vec, + version: Version, +} + +impl UpgradeFields { + pub fn new(ordering: Ordering, connection_hops: Vec, version: Version) -> Self { + Self { + ordering, + connection_hops, + version, + } + } +} + +impl Protobuf for UpgradeFields {} + +impl TryFrom for UpgradeFields { + type Error = ChannelError; + + fn try_from(value: RawUpgradeFields) -> Result { + let ordering = Ordering::from_i32(value.ordering)?; + let (connection_hops, failures): (Vec<_>, Vec<_>) = value + .connection_hops + .iter() + .partition_map(|id| match ConnectionId::from_str(id) { + Ok(connection_id) => itertools::Either::Left(connection_id), + Err(e) => itertools::Either::Right((id.clone(), e)), + }); + if !failures.is_empty() { + // FIXME use failure vector to output more information + return Err(Self::Error::parse_connection_hops_vector()); + } + let version = Version::from(value.version); + + Ok(Self::new(ordering, connection_hops, version)) + } +} + +impl From for RawUpgradeFields { + fn from(value: UpgradeFields) -> Self { + let raw_connection_hops = value + .connection_hops + .iter() + .map(|id| id.to_string()) + .collect(); + Self { + ordering: value.ordering as i32, + connection_hops: raw_connection_hops, + version: value.version.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use alloc::{string::ToString, vec}; + use ibc_proto::ibc::core::channel::v1::UpgradeFields as RawUpgradeFields; + + pub fn get_dummy_upgrade_fields() -> RawUpgradeFields { + RawUpgradeFields { + ordering: 1, + connection_hops: vec![], + version: "ics20".to_string(), + } + } +} diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 1f78ef3b5e..825f1d5d0d 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,4 +1,6 @@ pub use error::ChannelError; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; +use ibc_relayer_types::core::ics04_channel::upgrade_fields::UpgradeFields; use core::fmt::{Display, Error as FmtError, Formatter}; use core::time::Duration; @@ -863,6 +865,7 @@ impl Channel { counterparty, vec![self.dst_connection_id().clone()], version, + Sequence::from(0), ); // Build the domain type message @@ -942,6 +945,7 @@ impl Channel { counterparty, vec![self.dst_connection_id().clone()], Version::empty(), + Sequence::from(0), ); // Retrieve existing channel @@ -1033,6 +1037,7 @@ impl Channel { counterparty, vec![self.dst_connection_id().clone()], version, + Sequence::from(0), ); // Get signer @@ -1519,6 +1524,12 @@ impl Channel { channel_end.state = State::InitUpgrade; + let fields = UpgradeFields::new( + channel_end.ordering, + channel_end.connection_hops, + channel_end.version, + ); + // Build the domain type message let signer = self .dst_chain() @@ -1530,7 +1541,7 @@ impl Channel { MsgChannelUpgradeInit { port_id: port_id.clone(), channel_id: channel_id.clone(), - proposed_upgrade_channel: channel_end, + fields, timeout, signer, } @@ -1579,14 +1590,17 @@ impl Channel { } } - pub fn build_chan_upgrade_try(&self, timeout: UpgradeTimeout) -> Result, ChannelError> { + pub fn build_chan_upgrade_try( + &self, + _timeout: UpgradeTimeout, + ) -> Result, ChannelError> { // Source channel ID must exist let src_channel_id = self .src_channel_id() .ok_or_else(ChannelError::missing_local_channel_id)?; // Channel must exist on the souce chain - let (channe_end, maybe_channel_proof) = self + let (mut channel_end, maybe_channel_proof) = self .src_chain() .query_channel( QueryChannelRequest { @@ -1594,7 +1608,7 @@ impl Channel { channel_id: src_channel_id.clone(), height: QueryHeight::Latest, }, - IncludeProof::Yes + IncludeProof::Yes, ) .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; @@ -1603,7 +1617,7 @@ impl Channel { self.dst_chain().id(), self.dst_port_id().clone(), self.src_chain().id(), - src_channel.counterparty().port_id().clone(), + self.src_port_id().clone(), src_channel_id.clone(), )); } @@ -1612,7 +1626,8 @@ impl Channel { return Err(ChannelError::missing_channel_proof()); }; - let channel_proof_bytes = CommitmentProofBytes::try_from(channel_proof).map_err(Error::malformed_proof)?; + let _channel_proof_bytes = + CommitmentProofBytes::try_from(channel_proof).map_err(ChannelError::malformed_proof)?; if channel_end.state != State::InitUpgrade { return Err(ChannelError::invalid_channel_upgrade_state()); @@ -1620,13 +1635,13 @@ impl Channel { channel_end.state = State::TryUpgrade; - let signer = self + let _signer = self .dst_chain() .get_signer() .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; // Build the domain type message - let new_msg = MsgChannelUpgradeTry { + /*let new_msg = MsgChannelUpgradeTry { port_id: port_id.clone(), channel_id: channel_id.clone(), proposed_upgrade_channel: channel_end, @@ -1640,7 +1655,8 @@ impl Channel { proof_height, }; - Ok(vec![new_msg.to_any()]) + Ok(vec![new_msg.to_any()])*/ + Ok(vec![]) } pub fn map_chain( diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 186c61e0de..42c4e8c100 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -65,7 +65,7 @@ define_error! { MissingChannelProof |_| { "missing channel proof" }, - + MalformedProof [ ProofError ] |_| { "malformed proof" }, From b07c03dd6146425671415f776e412640a2b0cbd0 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 20 Apr 2023 13:58:46 +0200 Subject: [PATCH 48/99] Nicely report connection id parsing failures --- .../src/core/ics04_channel/error.rs | 18 +++++++++++---- .../src/core/ics04_channel/upgrade_fields.rs | 6 +++-- .../src/core/ics24_host/error.rs | 23 ++++++++++++++++--- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index 84b9a29313..5c8c8d6aff 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -13,6 +13,7 @@ use crate::Height; use flex_error::{define_error, TraceError}; use ibc_proto::protobuf::Error as TendermintError; +use itertools::Itertools; define_error! { #[derive(Debug, PartialEq, Eq)] @@ -67,9 +68,10 @@ define_error! { MissingNextRecvSeq { port_id: PortId, channel_id: ChannelId } | e | { - format_args!("Missing sequence number for receiving packets on port {0} and channel {1}", - e.port_id, - e.channel_id) + format_args!( + "Missing sequence number for receiving packets on port {0} and channel {1}", + e.port_id, e.channel_id + ) }, ZeroPacketSequence @@ -362,7 +364,15 @@ define_error! { | e | { format_args!("Failed to convert abci event to IbcEvent: {}", e.abci_event)}, ParseConnectionHopsVector - | _ | { "error converting vector of String to vector of ConnectionId" } + { failures: Vec<(String, ValidationError)> } + | e | { + let failures = e.failures + .iter() + .map(|(s, e)| format!("\"{}\": {}", s, e)) + .join(", "); + + format!("error parsing a vector of ConnectionId: {}", failures) + } } } diff --git a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs index f8511e01b9..2afbaed512 100644 --- a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs +++ b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs @@ -35,6 +35,7 @@ impl TryFrom for UpgradeFields { fn try_from(value: RawUpgradeFields) -> Result { let ordering = Ordering::from_i32(value.ordering)?; + let (connection_hops, failures): (Vec<_>, Vec<_>) = value .connection_hops .iter() @@ -42,10 +43,11 @@ impl TryFrom for UpgradeFields { Ok(connection_id) => itertools::Either::Left(connection_id), Err(e) => itertools::Either::Right((id.clone(), e)), }); + if !failures.is_empty() { - // FIXME use failure vector to output more information - return Err(Self::Error::parse_connection_hops_vector()); + return Err(Self::Error::parse_connection_hops_vector(failures)); } + let version = Version::from(value.version); Ok(Self::new(ordering, connection_hops, version)) diff --git a/crates/relayer-types/src/core/ics24_host/error.rs b/crates/relayer-types/src/core/ics24_host/error.rs index 0221414211..794456bfc9 100644 --- a/crates/relayer-types/src/core/ics24_host/error.rs +++ b/crates/relayer-types/src/core/ics24_host/error.rs @@ -17,11 +17,20 @@ define_error! { min: usize, max: usize, } - | e | { format_args!("identifier {0} has invalid length {1} must be between {2}-{3} characters", e.id, e.length, e.min, e.max) }, + | e | { + format_args!( + "identifier {0} has invalid length {1} must be between {2}-{3} characters", + e.id, e.length, e.min, e.max + ) + }, InvalidCharacter { id: String } - | e | { format_args!("identifier {0} must only contain alphanumeric characters or `.`, `_`, `+`, `-`, `#`, - `[`, `]`, `<`, `>`", e.id) }, + | e | { + format_args!( + "identifier {0} must only contain alphanumeric characters or `.`, `_`, `+`, `-`, `#`, - `[`, `]`, `<`, `>`", e.id + ) + }, Empty | _ | { "identifier cannot be empty" }, @@ -31,6 +40,14 @@ define_error! { | e | { format_args!("chain identifiers are expected to be in epoch format {0}", e.id) }, InvalidCounterpartyChannelId - |_| { "Invalid channel id in counterparty" } + |_| { "invalid channel id in counterparty" } } } + +impl PartialEq for ValidationError { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl Eq for ValidationError {} From 0b303451dbc44133ba80b5500a39261095a3b384 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 20 Apr 2023 10:33:22 -0500 Subject: [PATCH 49/99] Document some fields of MsgChannelUpgradeTry --- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 8 ++++++++ crates/relayer/src/channel.rs | 9 +++++++++ crates/relayer/src/channel/error.rs | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index cfa4f0e014..ef033fc67a 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -19,16 +19,24 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeTry"; /// handshake (the `ChanUpgradeTry` datagram). #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelUpgradeTry { + /// The port identifier of the counterparty chain (the upgrade handshake originator). pub port_id: PortId, + /// The channel identifier of the counterparty chain (the upgrade handshake originator). pub channel_id: ChannelId, pub signer: Signer, + /// The channel end of the counterparty chain. pub counterparty_channel: ChannelEnd, + /// The sequence number of the counterparty channel end. This is used to keep track + /// of how many upgrade attempts have occurred for the given channel. pub counterparty_sequence: u64, + /// The ultimate state of the channel end after the upgrade is completed. pub proposed_upgrade_channel: ChannelEnd, + /// The height and/or timestamp after which the upgrade will be timed out. pub timeout: UpgradeTimeout, pub proof_channel: CommitmentProofBytes, pub proof_upgrade_timeout: CommitmentProofBytes, pub proof_upgrade_sequence: CommitmentProofBytes, + /// The height at whch the proofs were queried. pub proof_height: Height, } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 72455d8aa7..8a3df7c27a 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1624,6 +1624,15 @@ impl Channel { )); } + let counterparty_ordering = channel_end.ordering(); + + if *counterparty_ordering != self.ordering { + return Err(ChannelError::invalid_ordering( + counterparty_ordering, + self.ordering, + )); + } + let mut proposed_upgrade_channel = channel_end.clone(); let Some(channel_proof) = maybe_channel_proof else { diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 42c4e8c100..44c4a8cb29 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -74,6 +74,16 @@ define_error! { [ RelayerError ] |_| { "failed to build channel proofs" }, + InvalidOrdering + { + channel_ordering: Ordering, + counterparty_ordering: Ordering, + } + | e | { + format_args!("channel ordering '{0}' does not match counterparty ordering '{1}'", + e.channel_ordering, e.counterparty_ordering) + }, + ClientOperation { client_id: ClientId, From 01216d01b13e7b62f36da8f3bc47178338a564fc Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 20 Apr 2023 11:06:21 -0500 Subject: [PATCH 50/99] Add build_chan_upgrade_try_and_send fn --- .../ics04_channel/msgs/chan_upgrade_try.rs | 6 ++-- crates/relayer/src/channel.rs | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index ef033fc67a..1015fabed3 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -26,17 +26,17 @@ pub struct MsgChannelUpgradeTry { pub signer: Signer, /// The channel end of the counterparty chain. pub counterparty_channel: ChannelEnd, - /// The sequence number of the counterparty channel end. This is used to keep track + /// The sequence number of the counterparty channel end. This is used to keep track /// of how many upgrade attempts have occurred for the given channel. pub counterparty_sequence: u64, /// The ultimate state of the channel end after the upgrade is completed. pub proposed_upgrade_channel: ChannelEnd, - /// The height and/or timestamp after which the upgrade will be timed out. + /// The height and/or timestamp after which the upgrade will be timed out. pub timeout: UpgradeTimeout, pub proof_channel: CommitmentProofBytes, pub proof_upgrade_timeout: CommitmentProofBytes, pub proof_upgrade_sequence: CommitmentProofBytes, - /// The height at whch the proofs were queried. + /// The height at whch the proofs were queried. pub proof_height: Height, } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 8a3df7c27a..5f2eaa9e17 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1672,6 +1672,39 @@ impl Channel { Ok(vec![]) } + pub fn build_chan_upgrade_try_and_send(&self, timeout: UpgradeTimeout) -> Result { + let dst_msgs = self.build_chan_upgrade_try(timeout)?; + + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTry"); + + let events = self + .dst_chain() + .send_messages_and_wait_commit(tm) + .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; + + // Find the relevant event for channel upgrade try + let result = events + .into_iter() + .find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no channel upgrade try event was in the response".to_string(), + ) + })?; + + match &result.event { + IbcEvent::UpgradeTryChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), + } + } + pub fn map_chain( self, mapper_a: impl Fn(ChainA) -> ChainC, From e977d1d11f320a8917eae0473987658405a1f5c8 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 20 Apr 2023 11:11:37 -0500 Subject: [PATCH 51/99] Cargo fmt --- crates/relayer/src/channel.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 5f2eaa9e17..2a739195fb 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1672,7 +1672,10 @@ impl Channel { Ok(vec![]) } - pub fn build_chan_upgrade_try_and_send(&self, timeout: UpgradeTimeout) -> Result { + pub fn build_chan_upgrade_try_and_send( + &self, + timeout: UpgradeTimeout, + ) -> Result { let dst_msgs = self.build_chan_upgrade_try(timeout)?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTry"); From 65d265f3d779f424a0ea3845aa94ed0e7632bad4 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 21 Apr 2023 10:12:40 +0200 Subject: [PATCH 52/99] Update UpgradeInit to mirror event attributers from 'channel_upgrade_init' event --- .../src/core/ics04_channel/events.rs | 154 +++++++++++++++--- crates/relayer-types/src/events.rs | 1 - crates/relayer/src/event.rs | 76 ++++++++- 3 files changed, 201 insertions(+), 30 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index dab8d148fe..b71d5a6b79 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -5,8 +5,11 @@ use core::str; use serde_derive::{Deserialize, Serialize}; use tendermint::abci; +use crate::core::ics04_channel::channel::Ordering; use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::packet::Packet; +use crate::core::ics04_channel::packet::Sequence; +use crate::core::ics04_channel::version::Version; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; use crate::events::{Error as EventError, IbcEvent, IbcEventType}; use crate::prelude::*; @@ -30,6 +33,12 @@ pub const PKT_TIMEOUT_HEIGHT_ATTRIBUTE_KEY: &str = "packet_timeout_height"; pub const PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY: &str = "packet_timeout_timestamp"; pub const PKT_ACK_ATTRIBUTE_KEY: &str = "packet_ack"; +/// Channel upgrade attribute keys +pub const UPGRADE_CONNECTION_HOPS: &str = "upgrade_connection_hops"; +pub const UPGRADE_VERSION: &str = "upgrade_version"; +pub const UPGRADE_SEQUENCE: &str = "upgrade_sequence"; +pub const UPGRADE_ORDERING: &str = "upgrade_ordering"; + #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] pub struct Attributes { pub port_id: PortId, @@ -125,10 +134,90 @@ impl TryFrom for Vec { } } +#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] +pub struct UpgradeAttributes { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, +} + +impl UpgradeAttributes {} + +impl Display for UpgradeAttributes { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering + ) + } +} pub trait EventType { fn event_type() -> IbcEventType; } +/// Convert channel upgrade attributes to Tendermint ABCI tags +impl From for Vec { + fn from(a: UpgradeAttributes) -> Self { + let mut attributes: Vec = vec![]; + + let port_id: abci::EventAttribute = (PORT_ID_ATTRIBUTE_KEY, a.port_id.as_str()).into(); + attributes.push(port_id); + + let channel_id: abci::EventAttribute = + (CHANNEL_ID_ATTRIBUTE_KEY, a.channel_id.as_str()).into(); + attributes.push(channel_id); + + let counterparty_port_id = ( + COUNTERPARTY_PORT_ID_ATTRIBUTE_KEY, + a.counterparty_port_id.as_str(), + ) + .into(); + + attributes.push(counterparty_port_id); + let channel_id = (COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY, a.channel_id.as_str()).into(); + attributes.push(channel_id); + + let mut hops = "".to_owned(); + let mut hops_iterator = a.upgrade_connection_hops.iter().peekable(); + + while let Some(hop) = hops_iterator.next() { + hops = format!("{hops}{hop}"); + // If it is not the last element, add separator. + if hops_iterator.peek().is_some() { + hops = format!("{hops}, "); + } + } + + let upgrade_connection_hops = (UPGRADE_CONNECTION_HOPS, hops.as_str()).into(); + attributes.push(upgrade_connection_hops); + + let upgrade_version = (UPGRADE_VERSION, a.upgrade_version.0.as_str()).into(); + attributes.push(upgrade_version); + + let upgrade_sequence = (UPGRADE_SEQUENCE, a.upgrade_sequence.to_string().as_str()).into(); + attributes.push(upgrade_sequence); + + let upgrade_ordering = (UPGRADE_ORDERING, a.upgrade_ordering.as_str()).into(); + attributes.push(upgrade_ordering); + + attributes + } +} + #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct OpenInit { pub port_id: PortId, @@ -475,28 +564,53 @@ impl EventType for CloseConfirm { pub struct UpgradeInit { pub port_id: PortId, pub channel_id: ChannelId, - pub connection_id: ConnectionId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, } impl Display for UpgradeInit { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { - match &self.counterparty_channel_id { - Some(counterparty_channel_id) => write!(f, "UpgradeInit {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: {} }}", self.port_id, self.channel_id, self.connection_id, self.counterparty_port_id, counterparty_channel_id), - None => write!(f, "UpgradeInit {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: None }}", self.port_id, self.channel_id, self.connection_id, self.counterparty_port_id), + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering + ) } } -impl From for Attributes { +impl From for UpgradeAttributes { fn from(ev: UpgradeInit) -> Self { Self { port_id: ev.port_id, - channel_id: Some(ev.channel_id), - connection_id: ev.connection_id, + channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, + upgrade_connection_hops: ev.upgrade_connection_hops, + upgrade_version: ev.upgrade_version, + upgrade_sequence: ev.upgrade_sequence, + upgrade_ordering: ev.upgrade_ordering, + } + } +} + +impl From for abci::Event { + fn from(value: UpgradeInit) -> Self { + let kind = UpgradeInit::event_type().as_str().to_owned(); + Self { + kind, + attributes: UpgradeAttributes::from(value).into(), } } } @@ -519,21 +633,20 @@ impl UpgradeInit { } } -impl TryFrom for UpgradeInit { +impl TryFrom for UpgradeInit { type Error = EventError; - fn try_from(attrs: Attributes) -> Result { - if let Some(channel_id) = attrs.channel_id() { - Ok(Self { - port_id: attrs.port_id.clone(), - channel_id: channel_id.clone(), - connection_id: attrs.connection_id.clone(), - counterparty_port_id: attrs.counterparty_port_id.clone(), - counterparty_channel_id: attrs.counterparty_channel_id, - }) - } else { - Err(EventError::channel(Error::missing_channel_id())) - } + fn try_from(attrs: UpgradeAttributes) -> Result { + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_connection_hops: attrs.upgrade_connection_hops, + upgrade_version: attrs.upgrade_version, + upgrade_sequence: attrs.upgrade_sequence, + upgrade_ordering: attrs.upgrade_ordering, + }) } } @@ -642,7 +755,6 @@ impl_from_ibc_to_abci_event!( OpenTry, OpenAck, OpenConfirm, - UpgradeInit, UpgradeTry, CloseInit, CloseConfirm diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index 91834f1a10..90b04a7784 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -423,7 +423,6 @@ impl IbcEvent { IbcEvent::OpenTryChannel(ev) => Some(ev.into()), IbcEvent::OpenAckChannel(ev) => Some(ev.into()), IbcEvent::OpenConfirmChannel(ev) => Some(ev.into()), - IbcEvent::UpgradeInitChannel(ev) => Some(ev.into()), _ => None, } } diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index 55f7e9b7bd..f497aa8489 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -2,26 +2,34 @@ use core::fmt::{Display, Error as FmtError, Formatter}; use ibc_relayer_types::{ applications::ics29_fee::events::{DistributeFeePacket, IncentivizedPacket}, applications::ics31_icq::events::CrossChainQueryPacket, - core::ics02_client::{ - error::Error as ClientError, - events::{self as client_events, Attributes as ClientAttributes, HEADER_ATTRIBUTE_KEY}, - header::Header, - height::HeightErrorDetail, - }, core::ics03_connection::{ error::Error as ConnectionError, events::{self as connection_events, Attributes as ConnectionAttributes}, }, core::ics04_channel::{ error::Error as ChannelError, - events::{self as channel_events, Attributes as ChannelAttributes}, + events::{ + self as channel_events, Attributes as ChannelAttributes, + UpgradeAttributes as ChannelUpgradeAttributes, + }, packet::Packet, timeout::TimeoutHeight, }, + core::{ + ics02_client::{ + error::Error as ClientError, + events::{self as client_events, Attributes as ClientAttributes, HEADER_ATTRIBUTE_KEY}, + header::Header, + height::HeightErrorDetail, + }, + ics04_channel::{channel::Ordering, packet::Sequence, version::Version}, + ics24_host::identifier::ConnectionId, + }, events::{Error as IbcEventError, IbcEvent, IbcEventType}, Height, }; use serde::Serialize; +use std::str::FromStr; use tendermint::abci::Event as AbciEvent; use crate::light_client::decode_header; @@ -256,7 +264,7 @@ pub fn channel_close_confirm_try_from_abci_event( pub fn channel_upgrade_init_try_from_abci_event( abci_event: &AbciEvent, ) -> Result { - match channel_extract_attributes_from_tx(abci_event) { + match channel_upgrade_extract_attributes_from_tx(abci_event) { Ok(attrs) => channel_events::UpgradeInit::try_from(attrs) .map_err(|_| ChannelError::implementation_specific()), Err(e) => Err(e), @@ -410,6 +418,58 @@ fn channel_extract_attributes_from_tx( Ok(attr) } +fn channel_upgrade_extract_attributes_from_tx( + event: &AbciEvent, +) -> Result { + let mut attr = ChannelUpgradeAttributes::default(); + + for tag in &event.attributes { + let key = tag.key.as_str(); + let value = tag.value.as_str(); + match key { + channel_events::PORT_ID_ATTRIBUTE_KEY => { + attr.port_id = value.parse().map_err(ChannelError::identifier)? + } + channel_events::CHANNEL_ID_ATTRIBUTE_KEY => { + attr.channel_id = value.parse().map_err(ChannelError::identifier)?; + } + channel_events::COUNTERPARTY_PORT_ID_ATTRIBUTE_KEY => { + attr.counterparty_port_id = value.parse().map_err(ChannelError::identifier)?; + } + channel_events::COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY => { + attr.counterparty_channel_id = value.parse().ok(); + } + channel_events::UPGRADE_CONNECTION_HOPS => { + let mut hops = vec![]; + for hop_str in value.trim().split(',') { + let hop = ConnectionId::from_str(hop_str).map_err(ChannelError::identifier)?; + hops.push(hop); + } + attr.upgrade_connection_hops = hops; + } + channel_events::UPGRADE_VERSION => { + attr.upgrade_version = Version(value.to_string()); + } + channel_events::UPGRADE_SEQUENCE => { + attr.upgrade_sequence = + Sequence::from(value.parse::().map_err(|e| { + ChannelError::invalid_string_as_sequence(value.to_string(), e) + })?); + } + channel_events::UPGRADE_ORDERING => { + attr.upgrade_ordering = Ordering::from_i32( + value + .parse::() + .map_err(|_| ChannelError::unknown_order_type(value.to_string()))?, + )?; + } + _ => {} + } + } + + Ok(attr) +} + pub fn extract_packet_and_write_ack_from_tx( event: &AbciEvent, ) -> Result<(Packet, Vec), ChannelError> { From d50b89a1d08f501dcbcbb1abffcda78add3a7ce3 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 21 Apr 2023 10:18:57 +0200 Subject: [PATCH 53/99] Treat timestamp 0 as no timestamp --- .../relayer-types/src/core/ics04_channel/error.rs | 3 +++ .../core/ics04_channel/msgs/chan_upgrade_init.rs | 13 +++---------- .../src/core/ics04_channel/msgs/chan_upgrade_try.rs | 2 +- .../relayer-types/src/core/ics04_channel/timeout.rs | 3 ++- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index 5c8c8d6aff..821bdefb14 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -108,6 +108,9 @@ define_error! { MissingUpgradeTimeout | _ | { "missing upgrade timeout, either a height or a timestamp must be set" }, + MissingUpgradeFields + | _ | { "missing upgrade fields" }, + MissingProposedUpgradeChannel | _ | { "missing proposed upgrade channel" }, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 88936468d7..943d6d773a 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -60,17 +60,10 @@ impl TryFrom for MsgChannelUpgradeInit { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeInit) -> Result { - let raw_timeout = raw_msg - .timeout - .ok_or(Self::Error::missing_upgrade_timeout())?; - - let timeout = UpgradeTimeout::try_from(raw_timeout) - .map_err(|_| Self::Error::invalid_timeout_height())?; - - let raw_fields = raw_msg - .fields - .ok_or(Self::Error::missing_upgrade_timeout())?; + let raw_timeout = raw_msg.timeout.ok_or(Error::missing_upgrade_timeout())?; + let timeout = UpgradeTimeout::try_from(raw_timeout)?; + let raw_fields = raw_msg.fields.ok_or(Error::missing_upgrade_fields())?; let fields = UpgradeFields::try_from(raw_fields)?; Ok(MsgChannelUpgradeInit { diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index cfa4f0e014..2f8fdd7887 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -206,7 +206,7 @@ mod tests { use crate::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; #[test] - fn parse_channel_upgrade_init_msg() { + fn parse_channel_upgrade_try_msg() { struct Test { name: String, raw: RawMsgChannelUpgradeTry, diff --git a/crates/relayer-types/src/core/ics04_channel/timeout.rs b/crates/relayer-types/src/core/ics04_channel/timeout.rs index 5881976c56..943cd70cce 100644 --- a/crates/relayer-types/src/core/ics04_channel/timeout.rs +++ b/crates/relayer-types/src/core/ics04_channel/timeout.rs @@ -239,7 +239,8 @@ impl TryFrom for UpgradeTimeout { let timeout_timestamp = Timestamp::from_nanoseconds(value.timestamp) .map_err(|_| Self::Error::invalid_timeout_timestamp) - .ok(); + .ok() + .filter(|ts| ts.nanoseconds() > 0); Self::new(timeout_height, timeout_timestamp) } From 3a7acdddd88b4802d17c3dcfbffedbf9e5f7c8cb Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 21 Apr 2023 10:53:51 +0200 Subject: [PATCH 54/99] Fix parsing UpgradeAttributes and improve ChanUpgradeInit test --- crates/relayer/src/event.rs | 6 +----- .../tests/channel_upgrade/manual_channel_upgrade.rs | 6 ++---- tools/test-framework/src/relayer/channel.rs | 10 +++------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index f497aa8489..8f44db670e 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -457,11 +457,7 @@ fn channel_upgrade_extract_attributes_from_tx( })?); } channel_events::UPGRADE_ORDERING => { - attr.upgrade_ordering = Ordering::from_i32( - value - .parse::() - .map_err(|_| ChannelError::unknown_order_type(value.to_string()))?, - )?; + attr.upgrade_ordering = Ordering::from_str(value)?; } _ => {} } diff --git a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs index 70eeb5965a..b5c27ec583 100644 --- a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs +++ b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs @@ -106,9 +106,7 @@ impl BinaryChannelTest for ChannelUpgradeInitHandshake { info!("Initialise channel upgrade process..."); - let (channel_id_on_b, _) = init_channel_upgrade( - &chains.handle_a, - &chains.handle_b, + init_channel_upgrade( channel, Some(new_version), new_ordering, @@ -121,7 +119,7 @@ impl BinaryChannelTest for ChannelUpgradeInitHandshake { assert_eventually_channel_upgrade_init( &chains.handle_b, &chains.handle_a, - &channel_id_on_b.as_ref(), + &channels.channel_id_b.as_ref(), &channels.port_b.as_ref(), &upgrade_attrs, )?; diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index dce8f7c147..532eea86a9 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -279,23 +279,19 @@ pub fn assert_eventually_channel_established( - handle_a: &ChainA, - handle_b: &ChainB, channel: Channel, new_version: Option, new_ordering: Option, new_connection_hops: Option>, timeout: UpgradeTimeout, -) -> Result<(TaggedChannelId, Channel), Error> { - let event = channel.build_chan_upgrade_init_and_send( +) -> Result<(), Error> { + channel.build_chan_upgrade_init_and_send( new_version, new_ordering, new_connection_hops, timeout, )?; - let channel_id = extract_channel_id(&event)?.clone(); - let channel2 = Channel::restore_from_event(handle_b.clone(), handle_a.clone(), event)?; - Ok((DualTagged::new(channel_id), channel2)) + Ok(()) } pub fn assert_eventually_channel_upgrade_init( From 8e6813d22527b67fb73b07a5b9a94b6a1a8b4c4f Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 21 Apr 2023 09:32:49 +0200 Subject: [PATCH 55/99] Add Hermes data requirements document (#3262) * Add Hermes data requirements document * Update data requirement for some endpoints with actual data being used * Add headers * Fix Order -> Ordering doc comment links * Apply suggestions from code review Co-authored-by: Anca Zamfir Signed-off-by: Romain Ruetschi --------- Signed-off-by: Romain Ruetschi Co-authored-by: Sean Chen Co-authored-by: Anca Zamfir --- docs/spec/README.md | 4 +- docs/spec/relayer/Data-Requirements.md | 153 ++++++++++++++++++ .../src/framework/binary/channel.rs | 2 +- .../test-framework/src/framework/overrides.rs | 4 +- 4 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 docs/spec/relayer/Data-Requirements.md diff --git a/docs/spec/README.md b/docs/spec/README.md index 6adf6bb24d..420e352f92 100644 --- a/docs/spec/README.md +++ b/docs/spec/README.md @@ -1,7 +1,5 @@ # Specification and verification of IBC protocols * [tla](./tla) comprises TLA+ specification for the IBC specification. - - * [connection-handshake](./connection-handshake) [Deprecated] contains English and TLA+ specifications for the IBC Connection Handshake Protocol (ICS 003). - * [relayer](./relayer) contains English specification of the relayer. + * [connection-handshake](./connection-handshake) [Deprecated] contains English and TLA+ specifications for the IBC Connection Handshake Protocol (ICS 003). diff --git a/docs/spec/relayer/Data-Requirements.md b/docs/spec/relayer/Data-Requirements.md new file mode 100644 index 0000000000..328200f764 --- /dev/null +++ b/docs/spec/relayer/Data-Requirements.md @@ -0,0 +1,153 @@ +# Hermes IBC Relayer Data Requirements + +## Table of Contents + +- [CometBFT RPC](#cometbft-rpc) + * [`/health`](#--health-) + * [`/consensus_params`](#--consensus-params-) + * [`/status`](#--status-) + * [`/header`](#--header-) + * [`/abci_query`](#--abci-query-) + * [`/tx_search`](#--tx-search-) + * [`/block_search`](#--block-search-) + * [`/block_results`](#--block-results-) + * [`/broadcast_tx_sync`](#--broadcast-tx-sync-) +- [CometBFT WebSocket](#cometbft-websocket) + +## CometBFT RPC + +The following endpoints (or equivalent) are necessary for operating the relayer. +They are ordered from lowest to highest impact roughly, i.e., the first endpoint in the list is the least important and least frequently required. + +### `/health` + +- Needed for basic check to assess node health. +- Not needed for IBC relaying strictly speaking. +- Only used once, at relayer startup during health check. + +### `/consensus_params` + +- Needed for basic check to validate relayer configuration. +- Specifically, used for fetching `consensus_params.block.max_bytes` and `consensus_params.block.max_gas` parameters. +- Not needed for IBC relaying strictly speaking. +- Only used once, at relayer startup during health check. +- **Response fields used:** + - `block.max_bytes` + - `block.max_gas` + +### `/status` + +Used in two situations: + +1. At relayer startup to fetch `node_info.id`, for initializing the light client component. + - Also at startup to fetch `node_info.other.tx_index`, during health check. + - Also at startup to fetch `node_info.network`, i.e., the network identifier, during health check. + - Also at startup to assert that `sync_info.catching_up` is false, during health check. +2. To fetch `sync_info.latest_block_time` and `sync_info.latest_block_height` and `sync_info.catching_up` used in many methods, often alongside `node_info.network`, for example: + a. As a dependency, because the `latest_block_height` parameter is necessary in calling the `/consensus_params` RPC, during health check. + b. Needed in channel handshake (open try, ack, confirm; close confirm). + c. In connection handshake (open try, ack, confirm), for both the source chain (to update client), and destination chain (to construct proofs). Note: It seems like we bombard the node with /status queries, but most of the queries hit the Hermes in-process cache. + d. For updating clients during everyday IBC relaying. In case there is non-zero connection delay, we again bombard the node with /status queries. + +### `/header` + +- To pull the header in the latest block that the application committed, in order to compute the latest app height and app timestamp +- To get the a block header at a specific/latest height and extract the consensus state from it + +### `/abci_query` + +Used in two situations: +1. To obtain the client upgraded state, while the relayer is handling chain upgrades. +2. To construct proofs for every IBC message relayed. + - This method is used very frequently and is critical for IBC relaying! + - Does not seem to impact performance of relaying, i.e., this method does not seem particularly slow or problematic. + +> Note: We use `/header` and `/abci_query` together (see https://github.com/tendermint/tendermint/issues/8248) + +### `/tx_search` + +In four situations: + +1. Query to obtain transaction events, for confirming if packets are committed to the blockchain. + - Not needed on the critical path of packet relaying. Used very often as part of packet confirmation. + - Pattern: `tx.hash == XYZ` +2. Query to obtain client update events: (a) for the misbehavior detection task, and (b) for relaying packets on connections that have non-zero delay. + - Used rarely in practice because all connections have 0 delay and often misbehavior detection is disabled. + - Pattern: `update_client.client_id == 07-tendermint-X && update_client.consensus_height == X-Y` +3. Query for the success/error status of a transaction immediately after it was broadcast. + - Used rarely: at bootstrap (to register counterparty payee address for fees) or when transactions need to be sent sequentially (eg workaround for priority mempool or corner cases to avoid sequence mismatch). + - Pattern: `tx.hash == XYZ` +4. Query to obtain packet events that occurred at or before a specified height. Required because application state does not store the full packet data which is needed to build and relay the packet messages. + - Pattern: `send_packet.packet_src_channel == X && send_packet.packet_src_port == X && send_packet.packet_dst_channel == X && send_packet.packet_dst_port == X && send_packet.packet_sequence == X`. Also for `write_acknowledgement` packet events. + - Used relatively often, on start and then for every `z` blocks, where `clear_interval = z` (default `z = 100`). + +**Response fields used**: +- `txs[].height` +- `txs[].tx_result.events` + +### `/block_search` + +The use-case is similar to point (4) from `/tx_search`. We use it to obtain packet events from block data, used relatively often, on start and then for every `z` blocks, where `clear_interval = z` (default `z = 100`). + +#### Pattern +`send_packet.packet_src_channel == X && send_packet.packet_src_port == X && send_packet.packet_dst_channel == X && send_packet.packet_dst_port == X && send_packet.packet_sequence == X`. +Also for `write_acknowledgement` packet events. + +**Note:** Always used in conjunction with `block_results`. + The `block_search` is used to determine the `Block` that included a packet event. Then `block_search` is used with the block's height to extract the packet event. + +**Response fields used:** +- `blocks[].block.header.height` + +### `/block_results` + +Used in two situations ([diagram for reference](https://app.excalidraw.com/l/4XqkU6POmGI/9jbKsT6mHxf)): + +1. Similar to point (4) from `/tx_search`: Used In conjunction with `block_search` and `tx_search` for periodic packet clearing. + - Pattern: `/block_results?height=X` where X is a specific height, obtained with `block_results`, where a block has relevant packet events. Only `begin_block_events` and `end_block_events` are used in this case. +2. For CLIs `tx packet-recv` and `tx packet-ack` when the user passes the flag `--packet-data-query-height=X`. + +**Response fields used:** +- `begin_block_events` +- `end_block_events` +- `height` +- `tx_results[].events` + +### `/broadcast_tx_sync` + +- For submitting transactions into the mempool. + +__Note__: The above list is partly inspired from [cosmos-sdk/#11012](https://github.com/cosmos/cosmos-sdk/issues/11012) but extended and updated. + +## CometBFT WebSocket + +The relayer connects to the node's CometBFT websocket interface and subscribes to the following events: +- for events that have type `NewBlock` +- for events that have type `Tx` and are IBC client, connection, and channel, i.e., + - `message.module == "ibc_client"` + - `message.module == "ibc_connection"` + - `message.module == "ibc_channel"` +- eventually the relayer should avoid using the non-standard, ibc-go specific `message.module` key and instead use the following queries: + - `EXISTS create_client` + - `EXISTS update_client` + - `EXISTS client_misbehaviour` + - `EXISTS connection_open_init` + - `EXISTS connection_open_try` + - `EXISTS connection_open_ack` + - `EXISTS connection_open_confirm` + - `EXISTS channel_open_init` + - `EXISTS channel_open_try` + - `EXISTS channel_open_ack` + - `EXISTS channel_open_confirm` + - `EXISTS channel_close_init` + - `EXISTS channel_close_confirm` + - `EXISTS channel_upgrade_init` + - `EXISTS channel_upgrade_try` + - `EXISTS channel_upgrade_ack` + - `EXISTS channel_upgrade_confirm` + - `EXISTS send_packet` + - `EXISTS recv_packet` + - `EXISTS write_acknowledgement` + - `EXISTS acknowledge_packet` + - `EXISTS timeout_packet` + diff --git a/tools/test-framework/src/framework/binary/channel.rs b/tools/test-framework/src/framework/binary/channel.rs index 6978540caa..7380249464 100644 --- a/tools/test-framework/src/framework/binary/channel.rs +++ b/tools/test-framework/src/framework/binary/channel.rs @@ -134,7 +134,7 @@ pub trait PortsOverride { */ pub trait ChannelOrderOverride { /** - Return the channel ordering as [`Order`]. + Return the channel ordering as [`Ordering`]. */ fn channel_order(&self) -> Ordering; } diff --git a/tools/test-framework/src/framework/overrides.rs b/tools/test-framework/src/framework/overrides.rs index eeb8e0bc73..0338224469 100644 --- a/tools/test-framework/src/framework/overrides.rs +++ b/tools/test-framework/src/framework/overrides.rs @@ -127,8 +127,8 @@ pub trait TestOverrides { } /** - Return the channel ordering used for creating channels as [`Order`]. - Defaults to [`Order::Unordered`]. + Return the channel ordering used for creating channels as [`Ordering`]. + Defaults to [`Ordering::Unordered`]. Implemented for [`ChannelOrderOverride`]. */ From fc911afdea21e606edb66ce2274550527f927a31 Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:58:47 +0200 Subject: [PATCH 56/99] Update nix flake to use simd v7.0.0 (#3264) --- flake.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 5c55877a8f..62f432e68d 100644 --- a/flake.lock +++ b/flake.lock @@ -89,11 +89,11 @@ "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1681389138, - "narHash": "sha256-D2Tmf74uUgD2Nuf2TVAHqLDkGt+9J+P1knUE3Fa95Yk=", + "lastModified": 1682076511, + "narHash": "sha256-WsRmK7gMhfSPmPufBHGgzXs6L5P2N6Z46KXQcJunKgE=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "2d5bcc841835830534cc615c8952b0238ed59073", + "rev": "b52c0d3c2b93c7839374c0be8d7ab33d64ebe2ed", "type": "github" }, "original": { @@ -445,17 +445,17 @@ "ibc-go-v7-src": { "flake": false, "locked": { - "lastModified": 1674120235, - "narHash": "sha256-y2BRN5Ig4XSeT360LdwtsPtHud4JB33R3vXl/J+FHNM=", + "lastModified": 1678970403, + "narHash": "sha256-vdsDqLHpP0Bp0j8gtDOdouzyQXKioZsxJA+znkQw6JY=", "owner": "cosmos", "repo": "ibc-go", - "rev": "0a427c6d93e8f9d20c61b45e36f6e1fe73e37f37", + "rev": "7fb65c76000f207ece1b83d8950e3aaff3dfc0e7", "type": "github" }, "original": { "owner": "cosmos", + "ref": "v7.0.0", "repo": "ibc-go", - "rev": "0a427c6d93e8f9d20c61b45e36f6e1fe73e37f37", "type": "github" } }, @@ -642,11 +642,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "lastModified": 1682018913, + "narHash": "sha256-Eo2ZkWB8+qy8fnmxtJUNJl6HHYYAgXDR29+OwDIzm1Q=", "owner": "nixos", "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "rev": "7048a48bc79b4361f77740420000d2b5454b0df7", "type": "github" }, "original": { From e02acdfafd0f66d09176c2c55cd8b5ea782e9fa7 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 21 Apr 2023 11:01:10 -0500 Subject: [PATCH 57/99] Address compiler errors for now --- .../src/core/ics04_channel/events.rs | 1 + crates/relayer/src/channel.rs | 25 ++++++++++--------- crates/relayer/src/channel/error.rs | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index b71d5a6b79..80434306ae 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -134,6 +134,7 @@ impl TryFrom for Vec { } } +/// The attributes emitted by upon receiving a channel upgrade init message. #[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] pub struct UpgradeAttributes { pub port_id: PortId, diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 2a739195fb..5c8cc36480 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -19,8 +19,9 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_confirm::MsgChannelO use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; -use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; +// use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; +use ibc_relayer_types::core::ics23_commitment::commitment::CommitmentProofBytes; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; @@ -1513,7 +1514,6 @@ impl Channel { channel_end.ordering = new_ordering; } - // Build the proposed channel end if let Some(new_version) = new_version { channel_end.version = new_version; } @@ -1522,15 +1522,12 @@ impl Channel { channel_end.connection_hops = new_connection_hops; } - channel_end.state = State::InitUpgrade; - let fields = UpgradeFields::new( channel_end.ordering, channel_end.connection_hops, channel_end.version, ); - // Build the domain type message let signer = self .dst_chain() .get_signer() @@ -1601,8 +1598,9 @@ impl Channel { let src_port_id = self.src_port_id(); - // Channel must exist on the souce chain - let (mut channel_end, maybe_channel_proof) = self + // Fetch the src channel end that will be upgraded by the upgrade handshake + // Querying for the Channel End now includes the upgrade sequence number + let (channel_end, maybe_channel_proof) = self .src_chain() .query_channel( QueryChannelRequest { @@ -1614,6 +1612,7 @@ impl Channel { ) .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; + // TODO: Is this check necessary? if channel_end.counterparty().port_id() != self.dst_port_id() { return Err(ChannelError::mismatch_port( self.dst_chain().id(), @@ -1626,15 +1625,19 @@ impl Channel { let counterparty_ordering = channel_end.ordering(); + // We're assuming here that so long as the orderings match between the + // two channel ends, that the ordering on this channel end is valid + // as far as going from a stricter order to a less strict ordering + // So we aren't explicitly checking for that here like we did in the + // build_chan_upgrade_init function + // TODO: Make sure this assumption is correct if *counterparty_ordering != self.ordering { return Err(ChannelError::invalid_ordering( - counterparty_ordering, self.ordering, + *counterparty_ordering, )); } - let mut proposed_upgrade_channel = channel_end.clone(); - let Some(channel_proof) = maybe_channel_proof else { return Err(ChannelError::missing_channel_proof()); }; @@ -1646,8 +1649,6 @@ impl Channel { return Err(ChannelError::invalid_channel_upgrade_state()); } - proposed_upgrade_channel.state = State::TryUpgrade; - let _signer = self .dst_chain() .get_signer() diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 44c4a8cb29..5acba6b551 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -3,7 +3,7 @@ use core::time::Duration; use flex_error::{define_error, ErrorMessageTracer}; use ibc_relayer_types::core::ics02_client::error::Error as ClientError; -use ibc_relayer_types::core::ics04_channel::channel::State; +use ibc_relayer_types::core::ics04_channel::channel::{State, Ordering}; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, PortChannelId, PortId, }; From ace5a213ede88e1ba60c043494d212c9c7d584b9 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 21 Apr 2023 11:02:36 -0500 Subject: [PATCH 58/99] Cargo fmt --- crates/relayer/src/channel.rs | 10 +++++----- crates/relayer/src/channel/error.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 5c8cc36480..3d18752965 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1598,8 +1598,8 @@ impl Channel { let src_port_id = self.src_port_id(); - // Fetch the src channel end that will be upgraded by the upgrade handshake - // Querying for the Channel End now includes the upgrade sequence number + // Fetch the src channel end that will be upgraded by the upgrade handshake + // Querying for the Channel End now includes the upgrade sequence number let (channel_end, maybe_channel_proof) = self .src_chain() .query_channel( @@ -1626,11 +1626,11 @@ impl Channel { let counterparty_ordering = channel_end.ordering(); // We're assuming here that so long as the orderings match between the - // two channel ends, that the ordering on this channel end is valid - // as far as going from a stricter order to a less strict ordering + // two channel ends, that the ordering on this channel end is valid + // as far as going from a stricter order to a less strict ordering // So we aren't explicitly checking for that here like we did in the // build_chan_upgrade_init function - // TODO: Make sure this assumption is correct + // TODO: Make sure this assumption is correct if *counterparty_ordering != self.ordering { return Err(ChannelError::invalid_ordering( self.ordering, diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 5acba6b551..d1e4e1138c 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -3,7 +3,7 @@ use core::time::Duration; use flex_error::{define_error, ErrorMessageTracer}; use ibc_relayer_types::core::ics02_client::error::Error as ClientError; -use ibc_relayer_types::core::ics04_channel::channel::{State, Ordering}; +use ibc_relayer_types::core::ics04_channel::channel::{Ordering, State}; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, PortChannelId, PortId, }; From 68cd401d8fc6e3c10a083ab892a9d237b88eece2 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Sat, 22 Apr 2023 11:17:16 +0200 Subject: [PATCH 59/99] Add channel-upgrade job to the CI --- .github/workflows/integration.yaml | 41 ++++++++++++++++++++++++++++++ flake.lock | 25 +++++++++++++++--- flake.nix | 3 ++- 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index f9d6c42713..bd5b36d73c 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -310,6 +310,46 @@ jobs: test -p ibc-integration-test --features ics31 --no-fail-fast -- \ --nocapture --test-threads=1 ics31:: + channel-upgrade: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + chain: + - package: ibc-go-v7-channel-upgrade + command: simd + account_prefix: cosmos + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install + install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' + extra_nix_config: | + experimental-features = nix-command flakes + - uses: cachix/cachix-action@v12 + with: + name: cosmos + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: Swatinem/rust-cache@v1 + - uses: actions-rs/cargo@v1 + with: + command: test + args: -p ibc-integration-test --features channel-upgrade --no-fail-fast --no-run + - env: + RUST_LOG: debug + RUST_BACKTRACE: 1 + NO_COLOR_LOG: 1 + CHAIN_COMMAND_PATHS: ${{ matrix.chain.command }} + ACCOUNT_PREFIXES: ${{ matrix.chain.account_prefix }} + run: | + nix shell ${{ matrix.chain.package }} -c cargo \ + test -p ibc-integration-test --features channel-upgrade --no-fail-fast -- \ + --nocapture --test-threads=1 channel_upgrade:: + model-based-test: runs-on: ubuntu-20.04 timeout-minutes: 60 @@ -337,6 +377,7 @@ jobs: with: command: test args: -p ibc-integration-test --features mbt --no-fail-fast --no-run + # Disable running MBT tests until flakiness is addressed # - env: # RUST_LOG: debug diff --git a/flake.lock b/flake.lock index 62f432e68d..c489b6e8a3 100644 --- a/flake.lock +++ b/flake.lock @@ -54,6 +54,7 @@ "ibc-go-v4-src": "ibc-go-v4-src", "ibc-go-v5-src": "ibc-go-v5-src", "ibc-go-v6-src": "ibc-go-v6-src", + "ibc-go-v7-channel-upgrade-src": "ibc-go-v7-channel-upgrade-src", "ibc-go-v7-src": "ibc-go-v7-src", "ibc-rs-src": "ibc-rs-src", "ica-src": "ica-src", @@ -89,15 +90,16 @@ "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1682076511, - "narHash": "sha256-WsRmK7gMhfSPmPufBHGgzXs6L5P2N6Z46KXQcJunKgE=", + "lastModified": 1682153954, + "narHash": "sha256-nkkokaQz8vkpY92TAb4eAxM+UYcdZV4rNGdOb6+IKJ4=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "b52c0d3c2b93c7839374c0be8d7ab33d64ebe2ed", + "rev": "3d788d73a2d96b364a2845146bc25f8ed6b567fd", "type": "github" }, "original": { "owner": "informalsystems", + "ref": "ibc-go-channel-upgrade", "repo": "cosmos.nix", "type": "github" } @@ -442,6 +444,23 @@ "type": "github" } }, + "ibc-go-v7-channel-upgrade-src": { + "flake": false, + "locked": { + "lastModified": 1681914625, + "narHash": "sha256-MaUx988kvPc5AAlDiEPB0o0t+h+JyB3LsEFvPOvogQE=", + "owner": "cosmos", + "repo": "ibc-go", + "rev": "81a709b49a42504737d25be0e812d830f9a0897c", + "type": "github" + }, + "original": { + "owner": "cosmos", + "repo": "ibc-go", + "rev": "81a709b49a42504737d25be0e812d830f9a0897c", + "type": "github" + } + }, "ibc-go-v7-src": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 25d936aff4..5c31fec479 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,7 @@ inputs = { nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable; flake-utils.url = github:numtide/flake-utils; - cosmos-nix.url = github:informalsystems/cosmos.nix; + cosmos-nix.url = github:informalsystems/cosmos.nix/ibc-go-channel-upgrade; }; outputs = inputs: @@ -44,6 +44,7 @@ ibc-go-v5-simapp ibc-go-v6-simapp ibc-go-v7-simapp + ibc-go-v7-channel-upgrade apalache evmos juno From e28ddcc78c7fb6faf5af5057de34bb31413111d5 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Sat, 22 Apr 2023 11:17:33 +0200 Subject: [PATCH 60/99] Format flake.nix --- flake.nix | 92 +++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/flake.nix b/flake.nix index 5c31fec479..7acd6f4c32 100644 --- a/flake.nix +++ b/flake.nix @@ -7,54 +7,52 @@ cosmos-nix.url = github:informalsystems/cosmos.nix/ibc-go-channel-upgrade; }; - outputs = inputs: - let - utils = inputs.flake-utils.lib; - in + outputs = inputs: let + utils = inputs.flake-utils.lib; + in utils.eachSystem - [ - "aarch64-linux" - "aarch64-darwin" - "x86_64-darwin" - "x86_64-linux" - ] - (system: - let - nixpkgs = import inputs.nixpkgs { - inherit system; - }; + [ + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + "x86_64-linux" + ] + (system: let + nixpkgs = import inputs.nixpkgs { + inherit system; + }; - cosmos-nix = inputs.cosmos-nix.packages.${system}; - in - { - packages = { - inherit (cosmos-nix) - gaia5 - gaia6 - gaia7 - gaia8 - gaia9 - ica - osmosis - wasmd - gaia6-ordered - ibc-go-v2-simapp - ibc-go-v3-simapp - ibc-go-v4-simapp - ibc-go-v5-simapp - ibc-go-v6-simapp - ibc-go-v7-simapp - ibc-go-v7-channel-upgrade - apalache - evmos - juno - stride - stride-no-admin - ; + cosmos-nix = inputs.cosmos-nix.packages.${system}; + in { + packages = { + inherit + (cosmos-nix) + gaia5 + gaia6 + gaia7 + gaia8 + gaia9 + ica + osmosis + wasmd + gaia6-ordered + ibc-go-v2-simapp + ibc-go-v3-simapp + ibc-go-v4-simapp + ibc-go-v5-simapp + ibc-go-v6-simapp + ibc-go-v7-simapp + ibc-go-v7-channel-upgrade + apalache + evmos + juno + stride + stride-no-admin + ; - python = nixpkgs.python3.withPackages (p: [ - p.toml - ]); - }; - }); + python = nixpkgs.python3.withPackages (p: [ + p.toml + ]); + }; + }); } From 92f1d745bd74ad9fd819b0de7257b04b6c61b3ac Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Sat, 22 Apr 2023 11:29:58 +0200 Subject: [PATCH 61/99] Fix test --- .github/workflows/integration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index bd5b36d73c..bf50656ca7 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -346,7 +346,7 @@ jobs: CHAIN_COMMAND_PATHS: ${{ matrix.chain.command }} ACCOUNT_PREFIXES: ${{ matrix.chain.account_prefix }} run: | - nix shell ${{ matrix.chain.package }} -c cargo \ + nix shell .#${{ matrix.chain.package }} -c cargo \ test -p ibc-integration-test --features channel-upgrade --no-fail-fast -- \ --nocapture --test-threads=1 channel_upgrade:: From b262fc21a6d444b24ab0eeb73d9431ee0bdcfe3c Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Sat, 22 Apr 2023 12:20:09 +0200 Subject: [PATCH 62/99] Update guide templates --- crates/relayer-cli/src/commands/tx.rs | 2 +- crates/relayer-cli/src/commands/tx/channel.rs | 10 ++-- .../commands/hermes/tx/chan-upgrade-init_1.md | 1 + guide/src/templates/help_templates/tx.md | 1 + .../help_templates/tx/chan-upgrade-init.md | 49 +++++++++++++++++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md create mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-init.md diff --git a/crates/relayer-cli/src/commands/tx.rs b/crates/relayer-cli/src/commands/tx.rs index d434fa6f3c..b670d65972 100644 --- a/crates/relayer-cli/src/commands/tx.rs +++ b/crates/relayer-cli/src/commands/tx.rs @@ -44,7 +44,7 @@ pub enum TxCmd { /// Confirm the closing of a channel (ChannelCloseConfirm) ChanCloseConfirm(channel::TxChanCloseConfirmCmd), - // TODO + /// Initiate a channel upgrade (ChannelUpgradeInit) ChanUpgradeInit(channel::TxChanUpgradeInitCmd), /// Send a fungible token transfer test transaction (ICS20 MsgTransfer) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index df494070ce..ff59e2cf32 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -661,7 +661,9 @@ impl Runnable for TxChanCloseConfirmCmd { } } -/// Build and send a `ChanUpgradeInit` message to a destination +/// Initiate a channel upgrade (ChannelUpgradeInit) +/// +/// Build and send a `ChannelUpgradeInit` message to a destination /// chain that the source chain has an already-existing channel open /// with, signaling the intent by the source chain to perform /// the channel upgrade handshake. @@ -803,8 +805,10 @@ impl Runnable for TxChanUpgradeInitCmd { } } -/// Build and send a `ChanUpgradeTry` message in response to -/// a `ChanUpgradeInnit` message, signaling the chain's intent to +/// Relay the upgrade attempt (ChannelUpgradeTry) +/// +/// Build and send a `ChannelUpgradeTry` message in response to +/// a `ChannelUpgradeInnit` message, signaling the chain's intent to /// cooperate with the source chain on upgrading the specified channel /// and initiating the upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md new file mode 100644 index 0000000000..cfe87a3bcd --- /dev/null +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md @@ -0,0 +1 @@ +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-init[[#OPTIONS]] --src-chain [[#SRC_CHAIN_ID]] --dst-chain [[#DST_CHAIN_ID]] --dst-port [[#DST_PORT_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/help_templates/tx.md b/guide/src/templates/help_templates/tx.md index 02590775c2..8386a68a87 100644 --- a/guide/src/templates/help_templates/tx.md +++ b/guide/src/templates/help_templates/tx.md @@ -14,6 +14,7 @@ SUBCOMMANDS: chan-open-confirm Confirm opening of a channel (ChannelOpenConfirm) chan-open-init Initialize a channel (ChannelOpenInit) chan-open-try Relay the channel attempt (ChannelOpenTry) + chan-upgrade-init Initiate a channel upgrade (ChannelUpgradeInit) conn-ack Relay acknowledgment of a connection attempt (ConnectionOpenAck) conn-confirm Confirm opening of a connection (ConnectionOpenConfirm) conn-init Initialize a connection (ConnectionOpenInit) diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-init.md b/guide/src/templates/help_templates/tx/chan-upgrade-init.md new file mode 100644 index 0000000000..af8c68965a --- /dev/null +++ b/guide/src/templates/help_templates/tx/chan-upgrade-init.md @@ -0,0 +1,49 @@ +DESCRIPTION: +Initiate a channel upgrade (ChannelUpgradeInit) + +Build and send a `ChannelUpgradeInit` message to a destination chain that the source chain has an +already-existing channel open with, signaling the intent by the source chain to perform the channel +upgrade handshake. + +USAGE: + hermes tx chan-upgrade-init [OPTIONS] --src-chain --dst-chain --dst-port --dst-channel + +OPTIONS: + --connection-hops + Set of connection hops for the channel that both chains will upgrade to. Defaults to the + connection hops of the initiating chain if not specified. + + -h, --help + Print help information + + --ordering + Ordering of the channel that both chains will upgrade to. Note that the a channel may + only be upgraded from a stricter ordering to a less strict ordering, i.e., from ORDERED + to UNORDERED. Defaults to the ordering of the initiating chain if not specified. + + --timeout-height + Height that, once it has been surpassed on the originating chain, the upgrade will time + out. Required if no timeout timestamp is specified. + + --timeout-timestamp + Timestamp that, once it has been surpassed on the originating chain, the upgrade will + time out. Required if no timeout height is specified. + + --version + Version of the channel that both chains will upgrade to. Defaults to the version of the + initiating chain if not specified. + +REQUIRED: + --dst-chain + Identifier of the destination chain + + --dst-channel + Identifier of the destination channel + + [aliases: dst-chan] + + --dst-port + Identifier of the destination port + + --src-chain + Identifier of the source chain From b8ce0a7dfcbe20ccb1ec7f9242c57cf970f39ddb Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Sat, 22 Apr 2023 12:24:44 +0200 Subject: [PATCH 63/99] Expose `tx chan-upgrade-try` command --- crates/relayer-cli/src/commands/tx.rs | 3 ++ crates/relayer-cli/src/commands/tx/channel.rs | 2 +- .../commands/hermes/tx/chan-upgrade-try_1.md | 1 + guide/src/templates/help_templates/tx.md | 1 + .../help_templates/tx/chan-upgrade-init.md | 21 +++---------- .../help_templates/tx/chan-upgrade-try.md | 31 +++++++++++++++++++ 6 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md create mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-try.md diff --git a/crates/relayer-cli/src/commands/tx.rs b/crates/relayer-cli/src/commands/tx.rs index b670d65972..6d65e6f976 100644 --- a/crates/relayer-cli/src/commands/tx.rs +++ b/crates/relayer-cli/src/commands/tx.rs @@ -47,6 +47,9 @@ pub enum TxCmd { /// Initiate a channel upgrade (ChannelUpgradeInit) ChanUpgradeInit(channel::TxChanUpgradeInitCmd), + /// Relay the channel upgrade attempt (ChannelUpgradeTry) + ChanUpgradeTry(channel::TxChanUpgradeTryCmd), + /// Send a fungible token transfer test transaction (ICS20 MsgTransfer) FtTransfer(transfer::TxIcs20MsgTransferCmd), diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index ff59e2cf32..e54bc7ffd9 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -805,7 +805,7 @@ impl Runnable for TxChanUpgradeInitCmd { } } -/// Relay the upgrade attempt (ChannelUpgradeTry) +/// Relay the channel upgrade attempt (ChannelUpgradeTry) /// /// Build and send a `ChannelUpgradeTry` message in response to /// a `ChannelUpgradeInnit` message, signaling the chain's intent to diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md new file mode 100644 index 0000000000..6dd8adecaa --- /dev/null +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md @@ -0,0 +1 @@ +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-try[[#OPTIONS]] --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/help_templates/tx.md b/guide/src/templates/help_templates/tx.md index 8386a68a87..f968b2655d 100644 --- a/guide/src/templates/help_templates/tx.md +++ b/guide/src/templates/help_templates/tx.md @@ -15,6 +15,7 @@ SUBCOMMANDS: chan-open-init Initialize a channel (ChannelOpenInit) chan-open-try Relay the channel attempt (ChannelOpenTry) chan-upgrade-init Initiate a channel upgrade (ChannelUpgradeInit) + chan-upgrade-try Relay the channel upgrade attempt (ChannelUpgradeTry) conn-ack Relay acknowledgment of a connection attempt (ConnectionOpenAck) conn-confirm Confirm opening of a connection (ConnectionOpenConfirm) conn-init Initialize a connection (ConnectionOpenInit) diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-init.md b/guide/src/templates/help_templates/tx/chan-upgrade-init.md index af8c68965a..bdeccaeb29 100644 --- a/guide/src/templates/help_templates/tx/chan-upgrade-init.md +++ b/guide/src/templates/help_templates/tx/chan-upgrade-init.md @@ -1,10 +1,6 @@ DESCRIPTION: Initiate a channel upgrade (ChannelUpgradeInit) -Build and send a `ChannelUpgradeInit` message to a destination chain that the source chain has an -already-existing channel open with, signaling the intent by the source chain to perform the channel -upgrade handshake. - USAGE: hermes tx chan-upgrade-init [OPTIONS] --src-chain --dst-chain --dst-port --dst-channel @@ -34,16 +30,7 @@ OPTIONS: initiating chain if not specified. REQUIRED: - --dst-chain - Identifier of the destination chain - - --dst-channel - Identifier of the destination channel - - [aliases: dst-chan] - - --dst-port - Identifier of the destination port - - --src-chain - Identifier of the source chain + --dst-chain Identifier of the destination chain + --dst-channel Identifier of the destination channel [aliases: dst-chan] + --dst-port Identifier of the destination port + --src-chain Identifier of the source chain diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-try.md b/guide/src/templates/help_templates/tx/chan-upgrade-try.md new file mode 100644 index 0000000000..750d567599 --- /dev/null +++ b/guide/src/templates/help_templates/tx/chan-upgrade-try.md @@ -0,0 +1,31 @@ +DESCRIPTION: +Relay the channel upgrade attempt (ChannelUpgradeTry) + +USAGE: + hermes tx chan-upgrade-try [OPTIONS] --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel + +OPTIONS: + --dst-channel + Identifier of the destination channel (optional) [aliases: dst-chan] + + -h, --help + Print help information + +REQUIRED: + --dst-chain + Identifier of the destination chain + + --dst-connection + Identifier of the destination connection [aliases: dst-conn] + + --dst-port + Identifier of the destination port + + --src-chain + Identifier of the source chain + + --src-channel + Identifier of the source channel (required) [aliases: src-chan] + + --src-port + Identifier of the source port From 8a271b448b8489390cf8721290c980f4f875a03a Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 21 Jun 2023 13:54:47 +0200 Subject: [PATCH 64/99] Update TRY ste implementation for channel upgrade --- .../ics04_channel/msgs/chan_upgrade_try.rs | 2 +- crates/relayer/src/chain/cosmos.rs | 8 +- crates/relayer/src/chain/cosmos/query.rs | 1 + .../relayer/src/chain/cosmos/query/upgrade.rs | 26 ++++ crates/relayer/src/chain/endpoint.rs | 3 + crates/relayer/src/chain/handle.rs | 8 ++ crates/relayer/src/chain/handle/base.rs | 9 +- crates/relayer/src/chain/handle/cache.rs | 6 + crates/relayer/src/chain/handle/counting.rs | 6 + crates/relayer/src/chain/runtime.rs | 20 ++- crates/relayer/src/channel.rs | 121 +++++++++++++++--- tools/test-framework/src/relayer/chain.rs | 5 + 12 files changed, 193 insertions(+), 22 deletions(-) create mode 100644 crates/relayer/src/chain/cosmos/query/upgrade.rs diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index e93c6c99ea..8ed0fa43b1 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -30,7 +30,7 @@ pub struct MsgChannelUpgradeTry { pub counterparty_upgrade_sequence: Sequence, pub proof_channel: CommitmentProofBytes, pub proof_upgrade: CommitmentProofBytes, - /// The height at whch the proofs were queried. + /// The height at which the proofs were queried. pub proof_height: Height, pub signer: Signer, } diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index 94bd7bf8dd..eb9d7a7b16 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -18,7 +18,7 @@ use tracing::{error, instrument, trace, warn}; use ibc_proto::cosmos::{ base::node::v1beta1::ConfigResponse, staking::v1beta1::Params as StakingParams, }; - +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; use ibc_proto::interchain_security::ccv::consumer::v1::Params as CcvConsumerParams; use ibc_proto::ibc::apps::fee::v1::{ @@ -82,6 +82,7 @@ use crate::chain::cosmos::query::status::query_status; use crate::chain::cosmos::query::tx::{ filter_matching_event, query_packets_from_block, query_packets_from_txs, query_txs, }; +use crate::chain::cosmos::query::upgrade::query_upgrade; use crate::chain::cosmos::query::{abci_query, fetch_version_specs, packet_query, QueryResponse}; use crate::chain::cosmos::types::account::Account; use crate::chain::cosmos::types::config::TxConfig; @@ -2209,6 +2210,11 @@ impl ChainEndpoint for CosmosSdkChain { self.block_on(query_incentivized_packet(&self.grpc_addr, request))?; Ok(incentivized_response) } + + fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { + let upgrade_response = self.block_on(query_upgrade(&self.grpc_addr, request))?; + Ok(upgrade_response) + } } fn sort_events_by_sequence(events: &mut [IbcEventWithHeight]) { diff --git a/crates/relayer/src/chain/cosmos/query.rs b/crates/relayer/src/chain/cosmos/query.rs index 4869056b7b..1a011d8e49 100644 --- a/crates/relayer/src/chain/cosmos/query.rs +++ b/crates/relayer/src/chain/cosmos/query.rs @@ -22,6 +22,7 @@ pub mod denom_trace; pub mod fee; pub mod status; pub mod tx; +pub mod upgrade; /// Generic query response type #[derive(Clone, Debug, PartialEq)] diff --git a/crates/relayer/src/chain/cosmos/query/upgrade.rs b/crates/relayer/src/chain/cosmos/query/upgrade.rs new file mode 100644 index 0000000000..f7807ad39d --- /dev/null +++ b/crates/relayer/src/chain/cosmos/query/upgrade.rs @@ -0,0 +1,26 @@ +use http::uri::Uri; + +use crate::config::default::max_grpc_decoding_size; +use crate::error::Error; +use ibc_proto::ibc::core::channel::v1::{ + query_client::QueryClient, QueryUpgradeRequest, QueryUpgradeResponse, +}; + +/// Query the upgrade for a port and channel. +pub async fn query_upgrade( + grpc_address: &Uri, + request: QueryUpgradeRequest, +) -> Result { + let mut client = QueryClient::connect(grpc_address.clone()) + .await + .map_err(Error::grpc_transport)?; + + client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize); + + let response = client + .upgrade(tonic::Request::new(request)) + .await + .map_err(|e| Error::grpc_status(e, "query_incentivized_packet".to_owned()))?; + + Ok(response.into_inner()) +} diff --git a/crates/relayer/src/chain/endpoint.rs b/crates/relayer/src/chain/endpoint.rs index 3752f25a51..4534af9ea3 100644 --- a/crates/relayer/src/chain/endpoint.rs +++ b/crates/relayer/src/chain/endpoint.rs @@ -1,5 +1,6 @@ use alloc::sync::Arc; use core::convert::TryFrom; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; use tokio::runtime::Runtime as TokioRuntime; @@ -686,4 +687,6 @@ pub trait ChainEndpoint: Sized { &self, request: QueryIncentivizedPacketRequest, ) -> Result; + + fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result; } diff --git a/crates/relayer/src/chain/handle.rs b/crates/relayer/src/chain/handle.rs index be905173cb..5bbc5d79a6 100644 --- a/crates/relayer/src/chain/handle.rs +++ b/crates/relayer/src/chain/handle.rs @@ -7,6 +7,7 @@ use tracing::Span; use ibc_proto::ibc::apps::fee::v1::{ QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse, }; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, core::{ @@ -367,6 +368,11 @@ pub enum ChainRequest { request: QueryIncentivizedPacketRequest, reply_to: ReplyTo, }, + + QueryUpgrade { + request: QueryUpgradeRequest, + reply_to: ReplyTo, + }, } pub trait ChainHandle: Clone + Display + Send + Sync + Debug + 'static { @@ -678,4 +684,6 @@ pub trait ChainHandle: Clone + Display + Send + Sync + Debug + 'static { &self, request: QueryIncentivizedPacketRequest, ) -> Result; + + fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result; } diff --git a/crates/relayer/src/chain/handle/base.rs b/crates/relayer/src/chain/handle/base.rs index 2c2264f55c..291dbaddcb 100644 --- a/crates/relayer/src/chain/handle/base.rs +++ b/crates/relayer/src/chain/handle/base.rs @@ -3,8 +3,9 @@ use core::fmt::{Debug, Display, Error as FmtError, Formatter}; use crossbeam_channel as channel; use tracing::Span; -use ibc_proto::ibc::apps::fee::v1::{ - QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse, +use ibc_proto::ibc::{ + apps::fee::v1::{QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse}, + core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}, }; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, @@ -515,4 +516,8 @@ impl ChainHandle for BaseChainHandle { ) -> Result { self.send(|reply_to| ChainRequest::QueryIncentivizedPacket { request, reply_to }) } + + fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { + self.send(|reply_to| ChainRequest::QueryUpgrade { request, reply_to }) + } } diff --git a/crates/relayer/src/chain/handle/cache.rs b/crates/relayer/src/chain/handle/cache.rs index d09bc6927f..ded0cd9226 100644 --- a/crates/relayer/src/chain/handle/cache.rs +++ b/crates/relayer/src/chain/handle/cache.rs @@ -1,5 +1,7 @@ use core::fmt::{Display, Error as FmtError, Formatter}; use crossbeam_channel as channel; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeResponse; use tracing::Span; use ibc_proto::ibc::apps::fee::v1::QueryIncentivizedPacketRequest; @@ -510,4 +512,8 @@ impl ChainHandle for CachingChainHandle { ) -> Result { self.inner.query_incentivized_packet(request) } + + fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { + self.inner.query_upgrade(request) + } } diff --git a/crates/relayer/src/chain/handle/counting.rs b/crates/relayer/src/chain/handle/counting.rs index 66b83e5686..7a09cc5970 100644 --- a/crates/relayer/src/chain/handle/counting.rs +++ b/crates/relayer/src/chain/handle/counting.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use std::sync::{Arc, RwLock, RwLockReadGuard}; use crossbeam_channel as channel; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; use tracing::{debug, Span}; use ibc_proto::ibc::apps::fee::v1::{ @@ -503,4 +504,9 @@ impl ChainHandle for CountingChainHandle { self.inc_metric("query_incentivized_packet"); self.inner.query_incentivized_packet(request) } + + fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { + self.inc_metric("query_upgrade"); + self.inner.query_upgrade(request) + } } diff --git a/crates/relayer/src/chain/runtime.rs b/crates/relayer/src/chain/runtime.rs index 0426f6377d..e7d94a923e 100644 --- a/crates/relayer/src/chain/runtime.rs +++ b/crates/relayer/src/chain/runtime.rs @@ -5,8 +5,9 @@ use crossbeam_channel as channel; use tokio::runtime::Runtime as TokioRuntime; use tracing::{error, Span}; -use ibc_proto::ibc::apps::fee::v1::{ - QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse, +use ibc_proto::ibc::{ + apps::fee::v1::{QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse}, + core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}, }; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, @@ -349,6 +350,10 @@ where ChainRequest::QueryIncentivizedPacket { request, reply_to } => { self.query_incentivized_packet(request, reply_to)? }, + + ChainRequest::QueryUpgrade { request, reply_to } => { + self.query_upgrade(request, reply_to)? + }, } }, } @@ -850,4 +855,15 @@ where Ok(()) } + + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + reply_to: ReplyTo, + ) -> Result<(), Error> { + let result = self.chain.query_upgrade(request); + reply_to.send(result).map_err(Error::send)?; + + Ok(()) + } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 5ff7db5582..efeae7db0c 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,5 +1,5 @@ pub use error::ChannelError; -use ibc_proto::ibc::core::channel::v1::FlushStatus; +use ibc_proto::ibc::core::channel::v1::{FlushStatus, QueryUpgradeRequest}; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::upgrade_fields::UpgradeFields; @@ -20,7 +20,7 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_confirm::MsgChannelO use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; -// use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; use ibc_relayer_types::core::ics23_commitment::commitment::CommitmentProofBytes; use ibc_relayer_types::core::ics24_host::identifier::{ @@ -1593,13 +1593,18 @@ impl Channel { pub fn build_chan_upgrade_try( &self, - _timeout: UpgradeTimeout, + timeout: UpgradeTimeout, + upgrade_sequence: Sequence, ) -> Result, ChannelError> { // Source channel ID must exist let src_channel_id = self .src_channel_id() .ok_or_else(ChannelError::missing_local_channel_id)?; + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_local_channel_id)?; + let src_port_id = self.src_port_id(); // Fetch the src channel end that will be upgraded by the upgrade handshake @@ -1616,6 +1621,23 @@ impl Channel { ) .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; + let upgrade_response = self + .dst_chain() + .query_upgrade(QueryUpgradeRequest { + port_id: self.dst_port_id().to_string(), + channel_id: dst_channel_id.to_string(), + }) + .unwrap(); + + let proof_upgrade = CommitmentProofBytes::try_from(upgrade_response.proof) + .map_err(ChannelError::malformed_proof)?; + + let proof_height = upgrade_response + .proof_height + .ok_or(ChannelError::missing_channel_proof())? + .try_into() + .unwrap(); + // TODO: Is this check necessary? if channel_end.counterparty().port_id() != self.dst_port_id() { return Err(ChannelError::mismatch_port( @@ -1646,42 +1668,56 @@ impl Channel { return Err(ChannelError::missing_channel_proof()); }; - let _channel_proof_bytes = + let channel_proof_bytes = CommitmentProofBytes::try_from(channel_proof).map_err(ChannelError::malformed_proof)?; if channel_end.state != State::InitUpgrade { return Err(ChannelError::invalid_channel_upgrade_state()); } - let _signer = self + let signer = self .dst_chain() .get_signer() .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; // Build the domain type message - /*let new_msg = MsgChannelUpgradeTry { + let new_msg = MsgChannelUpgradeTry { port_id: src_port_id.clone(), channel_id: src_channel_id.clone(), - proposed_upgrade_channel, - signer, - counterparty_channel: channel_end, - counterparty_sequence, - timeout, + proposed_upgrade_connection_hops: vec![], // UPGRADE TODO + upgrade_timeout: timeout, + counterparty_proposed_upgrade: upgrade_response.upgrade.unwrap().try_into().unwrap(), + counterparty_upgrade_sequence: upgrade_sequence, proof_channel: channel_proof_bytes, - proof_upgrade_timeout, - proof_upgrade_sequence, + proof_upgrade, proof_height, + signer, }; - Ok(vec![new_msg.to_any()])*/ - Ok(vec![]) + Ok(vec![new_msg.to_any()]) } pub fn build_chan_upgrade_try_and_send( &self, timeout: UpgradeTimeout, ) -> Result { - let dst_msgs = self.build_chan_upgrade_try(timeout)?; + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_local_channel_id)?; + + let dst_port_id = self.dst_port_id(); + let (channel_end, _maybe_channel_proof) = self + .dst_chain() + .query_channel( + QueryChannelRequest { + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; + let dst_msgs = self.build_chan_upgrade_try(timeout, channel_end.upgraded_sequence)?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTry"); @@ -1725,6 +1761,59 @@ impl Channel { connection_delay: self.connection_delay, } } + + pub fn get_upgrade_fields( + &self, + new_version: Option, + new_ordering: Option, + new_connection_hops: Option>, + ) -> Result { + // Destination channel ID must exist + let channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let port_id = self.dst_port_id(); + + // Channel must exist on destination + let (mut channel_end, _proof) = self + .dst_chain() + .query_channel( + QueryChannelRequest { + port_id: port_id.clone(), + channel_id: channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; + + if channel_end.state != State::Open { + return Err(ChannelError::invalid_channel_upgrade_state()); + } + + if let Some(new_ordering) = new_ordering { + if new_ordering == Ordering::Uninitialized || new_ordering > channel_end.ordering { + return Err(ChannelError::invalid_channel_upgrade_ordering()); + } + + channel_end.ordering = new_ordering; + } + + if let Some(new_version) = new_version { + channel_end.version = new_version; + } + + if let Some(new_connection_hops) = new_connection_hops { + channel_end.connection_hops = new_connection_hops; + } + + Ok(UpgradeFields::new( + channel_end.ordering, + channel_end.connection_hops, + channel_end.version, + )) + } } pub fn extract_channel_id(event: &IbcEvent) -> Result<&ChannelId, ChannelError> { diff --git a/tools/test-framework/src/relayer/chain.rs b/tools/test-framework/src/relayer/chain.rs index f4913315ec..75c2318894 100644 --- a/tools/test-framework/src/relayer/chain.rs +++ b/tools/test-framework/src/relayer/chain.rs @@ -21,6 +21,7 @@ */ use crossbeam_channel as channel; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; use tracing::Span; use ibc_proto::ibc::apps::fee::v1::{ @@ -430,4 +431,8 @@ where ) -> Result { self.value().query_incentivized_packet(request) } + + fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { + self.value().query_upgrade(request) + } } From 9d36d2eed82046c58ce2bc3b91922bd74be5793a Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 23 Jun 2023 09:55:10 +0200 Subject: [PATCH 65/99] Fix channel upgrade TRY step --- .../src/core/ics04_channel/upgrade_fields.rs | 8 +- .../relayer-types/src/core/ics24_host/path.rs | 8 ++ crates/relayer/src/chain/cosmos.rs | 36 ++++-- crates/relayer/src/chain/cosmos/query.rs | 1 - .../relayer/src/chain/cosmos/query/upgrade.rs | 26 ---- crates/relayer/src/chain/endpoint.rs | 10 +- crates/relayer/src/chain/handle.rs | 12 +- crates/relayer/src/chain/handle/base.rs | 19 ++- crates/relayer/src/chain/handle/cache.rs | 10 +- crates/relayer/src/chain/handle/counting.rs | 11 +- crates/relayer/src/chain/runtime.rs | 12 +- crates/relayer/src/channel.rs | 115 ++++++++++-------- crates/relayer/src/channel/error.rs | 3 + crates/relayer/src/error.rs | 8 ++ tools/test-framework/src/relayer/chain.rs | 11 +- 15 files changed, 176 insertions(+), 114 deletions(-) delete mode 100644 crates/relayer/src/chain/cosmos/query/upgrade.rs diff --git a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs index f38e927333..fcad614d39 100644 --- a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs +++ b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs @@ -71,14 +71,18 @@ impl From for RawUpgradeFields { #[cfg(test)] pub mod test_util { + use std::string::ToString; + use std::vec; + use ibc_proto::ibc::core::channel::v1::UpgradeFields as RawUpgradeFields; - use std::{string::ToString, vec}; + + use crate::core::ics04_channel::version::Version; pub fn get_dummy_upgrade_fields() -> RawUpgradeFields { RawUpgradeFields { ordering: 1, connection_hops: vec![], - version: "ics20".to_string(), + version: Version::ics20_with_fee().to_string(), } } } diff --git a/crates/relayer-types/src/core/ics24_host/path.rs b/crates/relayer-types/src/core/ics24_host/path.rs index 300982d929..5efcc62536 100644 --- a/crates/relayer-types/src/core/ics24_host/path.rs +++ b/crates/relayer-types/src/core/ics24_host/path.rs @@ -42,6 +42,14 @@ pub enum Path { Acks(AcksPath), Receipts(ReceiptsPath), Upgrade(ClientUpgradePath), + ChannelUpgrade(ChannelUpgradePath), +} + +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)] +#[display(fmt = "channelUpgrades/upgrades/ports/{port_id}/channels/{channel_id}")] +pub struct ChannelUpgradePath { + pub port_id: PortId, + pub channel_id: ChannelId, } #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)] diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index eb9d7a7b16..45836c95c7 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -18,14 +18,13 @@ use tracing::{error, instrument, trace, warn}; use ibc_proto::cosmos::{ base::node::v1beta1::ConfigResponse, staking::v1beta1::Params as StakingParams, }; -use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; use ibc_proto::interchain_security::ccv::consumer::v1::Params as CcvConsumerParams; use ibc_proto::ibc::apps::fee::v1::{ QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse, }; use ibc_proto::protobuf::Protobuf; -use ibc_relayer_types::applications::ics31_icq::response::CrossChainQueryResponse; use ibc_relayer_types::clients::ics07_tendermint::client_state::{ AllowUpdate, ClientState as TmClientState, }; @@ -45,14 +44,18 @@ use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; use ibc_relayer_types::core::ics24_host::path::{ - AcksPath, ChannelEndsPath, ClientConsensusStatePath, ClientStatePath, CommitmentsPath, - ConnectionsPath, ReceiptsPath, SeqRecvsPath, + AcksPath, ChannelEndsPath, ChannelUpgradePath, ClientConsensusStatePath, ClientStatePath, + CommitmentsPath, ConnectionsPath, ReceiptsPath, SeqRecvsPath, }; use ibc_relayer_types::core::ics24_host::{ ClientUpgradePath, Path, IBC_QUERY_PATH, SDK_UPGRADE_QUERY_PATH, }; use ibc_relayer_types::signer::Signer; use ibc_relayer_types::Height as ICSHeight; +use ibc_relayer_types::{ + applications::ics31_icq::response::CrossChainQueryResponse, + core::{ics02_client::height::Height, ics04_channel::upgrade::Upgrade}, +}; use tendermint::block::Height as TmHeight; use tendermint::node::{self, info::TxIndexStatus}; @@ -82,7 +85,6 @@ use crate::chain::cosmos::query::status::query_status; use crate::chain::cosmos::query::tx::{ filter_matching_event, query_packets_from_block, query_packets_from_txs, query_txs, }; -use crate::chain::cosmos::query::upgrade::query_upgrade; use crate::chain::cosmos::query::{abci_query, fetch_version_specs, packet_query, QueryResponse}; use crate::chain::cosmos::types::account::Account; use crate::chain::cosmos::types::config::TxConfig; @@ -2211,9 +2213,27 @@ impl ChainEndpoint for CosmosSdkChain { Ok(incentivized_response) } - fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { - let upgrade_response = self.block_on(query_upgrade(&self.grpc_addr, request))?; - Ok(upgrade_response) + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + height: Height, + ) -> Result<(Upgrade, Option), Error> { + let port_id = PortId::from_str(&request.port_id) + .map_err(|_| Error::invalid_port_string(request.port_id))?; + let channel_id = ChannelId::from_str(&request.channel_id) + .map_err(|_| Error::invalid_channel_string(request.channel_id))?; + let res = self.query( + ChannelUpgradePath { + port_id, + channel_id, + }, + QueryHeight::Specific(height), + true, + )?; + let proof = res.proof.ok_or_else(Error::empty_response_proof)?; + let upgrade = Upgrade::decode_vec(&res.value).map_err(Error::decode)?; + + Ok((upgrade, Some(proof))) } } diff --git a/crates/relayer/src/chain/cosmos/query.rs b/crates/relayer/src/chain/cosmos/query.rs index 1a011d8e49..4869056b7b 100644 --- a/crates/relayer/src/chain/cosmos/query.rs +++ b/crates/relayer/src/chain/cosmos/query.rs @@ -22,7 +22,6 @@ pub mod denom_trace; pub mod fee; pub mod status; pub mod tx; -pub mod upgrade; /// Generic query response type #[derive(Clone, Debug, PartialEq)] diff --git a/crates/relayer/src/chain/cosmos/query/upgrade.rs b/crates/relayer/src/chain/cosmos/query/upgrade.rs deleted file mode 100644 index f7807ad39d..0000000000 --- a/crates/relayer/src/chain/cosmos/query/upgrade.rs +++ /dev/null @@ -1,26 +0,0 @@ -use http::uri::Uri; - -use crate::config::default::max_grpc_decoding_size; -use crate::error::Error; -use ibc_proto::ibc::core::channel::v1::{ - query_client::QueryClient, QueryUpgradeRequest, QueryUpgradeResponse, -}; - -/// Query the upgrade for a port and channel. -pub async fn query_upgrade( - grpc_address: &Uri, - request: QueryUpgradeRequest, -) -> Result { - let mut client = QueryClient::connect(grpc_address.clone()) - .await - .map_err(Error::grpc_transport)?; - - client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize); - - let response = client - .upgrade(tonic::Request::new(request)) - .await - .map_err(|e| Error::grpc_status(e, "query_incentivized_packet".to_owned()))?; - - Ok(response.into_inner()) -} diff --git a/crates/relayer/src/chain/endpoint.rs b/crates/relayer/src/chain/endpoint.rs index 4534af9ea3..a4ea1ba92a 100644 --- a/crates/relayer/src/chain/endpoint.rs +++ b/crates/relayer/src/chain/endpoint.rs @@ -1,6 +1,8 @@ use alloc::sync::Arc; use core::convert::TryFrom; -use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_relayer_types::core::ics02_client::height::Height; +use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; use tokio::runtime::Runtime as TokioRuntime; @@ -688,5 +690,9 @@ pub trait ChainEndpoint: Sized { request: QueryIncentivizedPacketRequest, ) -> Result; - fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result; + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + height: Height, + ) -> Result<(Upgrade, Option), Error>; } diff --git a/crates/relayer/src/chain/handle.rs b/crates/relayer/src/chain/handle.rs index 5bbc5d79a6..670c1a5c68 100644 --- a/crates/relayer/src/chain/handle.rs +++ b/crates/relayer/src/chain/handle.rs @@ -1,5 +1,6 @@ use alloc::sync::Arc; use core::fmt::{self, Debug, Display}; +use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; use crossbeam_channel as channel; use tracing::Span; @@ -7,7 +8,7 @@ use tracing::Span; use ibc_proto::ibc::apps::fee::v1::{ QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse, }; -use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, core::{ @@ -371,7 +372,8 @@ pub enum ChainRequest { QueryUpgrade { request: QueryUpgradeRequest, - reply_to: ReplyTo, + height: Height, + reply_to: ReplyTo<(Upgrade, Option)>, }, } @@ -685,5 +687,9 @@ pub trait ChainHandle: Clone + Display + Send + Sync + Debug + 'static { request: QueryIncentivizedPacketRequest, ) -> Result; - fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result; + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + height: Height, + ) -> Result<(Upgrade, Option), Error>; } diff --git a/crates/relayer/src/chain/handle/base.rs b/crates/relayer/src/chain/handle/base.rs index 291dbaddcb..76dea46f34 100644 --- a/crates/relayer/src/chain/handle/base.rs +++ b/crates/relayer/src/chain/handle/base.rs @@ -5,7 +5,7 @@ use tracing::Span; use ibc_proto::ibc::{ apps::fee::v1::{QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse}, - core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}, + core::channel::v1::QueryUpgradeRequest, }; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, @@ -14,7 +14,10 @@ use ibc_relayer_types::{ ics03_connection::connection::{ConnectionEnd, IdentifiedConnectionEnd}, ics03_connection::version::Version, ics04_channel::channel::{ChannelEnd, IdentifiedChannelEnd}, - ics04_channel::packet::{PacketMsgType, Sequence}, + ics04_channel::{ + packet::{PacketMsgType, Sequence}, + upgrade::Upgrade, + }, ics23_commitment::{commitment::CommitmentPrefix, merkle::MerkleProof}, ics24_host::identifier::ChainId, ics24_host::identifier::ChannelId, @@ -517,7 +520,15 @@ impl ChainHandle for BaseChainHandle { self.send(|reply_to| ChainRequest::QueryIncentivizedPacket { request, reply_to }) } - fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { - self.send(|reply_to| ChainRequest::QueryUpgrade { request, reply_to }) + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + height: Height, + ) -> Result<(Upgrade, Option), Error> { + self.send(|reply_to| ChainRequest::QueryUpgrade { + request, + height, + reply_to, + }) } } diff --git a/crates/relayer/src/chain/handle/cache.rs b/crates/relayer/src/chain/handle/cache.rs index ded0cd9226..f7d0b3492b 100644 --- a/crates/relayer/src/chain/handle/cache.rs +++ b/crates/relayer/src/chain/handle/cache.rs @@ -1,7 +1,7 @@ use core::fmt::{Display, Error as FmtError, Formatter}; use crossbeam_channel as channel; use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeResponse; +use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; use tracing::Span; use ibc_proto::ibc::apps::fee::v1::QueryIncentivizedPacketRequest; @@ -513,7 +513,11 @@ impl ChainHandle for CachingChainHandle { self.inner.query_incentivized_packet(request) } - fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { - self.inner.query_upgrade(request) + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + height: Height, + ) -> Result<(Upgrade, Option), Error> { + self.inner.query_upgrade(request, height) } } diff --git a/crates/relayer/src/chain/handle/counting.rs b/crates/relayer/src/chain/handle/counting.rs index 7a09cc5970..6966239a42 100644 --- a/crates/relayer/src/chain/handle/counting.rs +++ b/crates/relayer/src/chain/handle/counting.rs @@ -3,7 +3,8 @@ use std::collections::HashMap; use std::sync::{Arc, RwLock, RwLockReadGuard}; use crossbeam_channel as channel; -use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; use tracing::{debug, Span}; use ibc_proto::ibc::apps::fee::v1::{ @@ -505,8 +506,12 @@ impl ChainHandle for CountingChainHandle { self.inner.query_incentivized_packet(request) } - fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + height: Height, + ) -> Result<(Upgrade, Option), Error> { self.inc_metric("query_upgrade"); - self.inner.query_upgrade(request) + self.inner.query_upgrade(request, height) } } diff --git a/crates/relayer/src/chain/runtime.rs b/crates/relayer/src/chain/runtime.rs index e7d94a923e..a77d167299 100644 --- a/crates/relayer/src/chain/runtime.rs +++ b/crates/relayer/src/chain/runtime.rs @@ -7,7 +7,7 @@ use tracing::{error, Span}; use ibc_proto::ibc::{ apps::fee::v1::{QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse}, - core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}, + core::channel::v1::QueryUpgradeRequest, }; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, @@ -20,6 +20,7 @@ use ibc_relayer_types::{ ics04_channel::{ channel::{ChannelEnd, IdentifiedChannelEnd}, packet::{PacketMsgType, Sequence}, + upgrade::Upgrade, }, ics23_commitment::{commitment::CommitmentPrefix, merkle::MerkleProof}, ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId}, @@ -351,8 +352,8 @@ where self.query_incentivized_packet(request, reply_to)? }, - ChainRequest::QueryUpgrade { request, reply_to } => { - self.query_upgrade(request, reply_to)? + ChainRequest::QueryUpgrade { request, height, reply_to } => { + self.query_upgrade(request, height, reply_to)? }, } }, @@ -859,9 +860,10 @@ where fn query_upgrade( &self, request: QueryUpgradeRequest, - reply_to: ReplyTo, + height: Height, + reply_to: ReplyTo<(Upgrade, Option)>, ) -> Result<(), Error> { - let result = self.chain.query_upgrade(request); + let result = self.chain.query_upgrade(request, height); reply_to.send(result).map_err(Error::send)?; Ok(()) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index efeae7db0c..bc8ed978b7 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1494,7 +1494,7 @@ impl Channel { let port_id = self.dst_port_id(); // Channel must exist on destination - let (mut channel_end, _proof) = self + let (mut channel_end, _) = self .dst_chain() .query_channel( QueryChannelRequest { @@ -1594,49 +1594,72 @@ impl Channel { pub fn build_chan_upgrade_try( &self, timeout: UpgradeTimeout, - upgrade_sequence: Sequence, ) -> Result, ChannelError> { - // Source channel ID must exist let src_channel_id = self .src_channel_id() .ok_or_else(ChannelError::missing_local_channel_id)?; + let src_port_id = self.src_port_id(); + let src_latest_height = self + .src_chain() + .query_latest_height() + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; let dst_channel_id = self .dst_channel_id() .ok_or_else(ChannelError::missing_local_channel_id)?; - - let src_port_id = self.src_port_id(); + let dst_port_id = self.dst_port_id(); // Fetch the src channel end that will be upgraded by the upgrade handshake // Querying for the Channel End now includes the upgrade sequence number - let (channel_end, maybe_channel_proof) = self + let (channel_end, _) = self .src_chain() .query_channel( QueryChannelRequest { port_id: src_port_id.clone(), channel_id: src_channel_id.clone(), - height: QueryHeight::Latest, + height: QueryHeight::Specific(src_latest_height), }, IncludeProof::Yes, ) .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; - let upgrade_response = self + // Building the channel proof at the queried height + let src_proof = self + .src_chain() + .build_channel_proofs( + &src_port_id.clone(), + &src_channel_id.clone(), + src_latest_height, + ) + .map_err(ChannelError::channel_proof)?; + + let (dst_channel_end, _) = self .dst_chain() - .query_upgrade(QueryUpgradeRequest { - port_id: self.dst_port_id().to_string(), - channel_id: dst_channel_id.to_string(), - }) - .unwrap(); + .query_channel( + QueryChannelRequest { + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::Yes, + ) + .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; - let proof_upgrade = CommitmentProofBytes::try_from(upgrade_response.proof) - .map_err(ChannelError::malformed_proof)?; + let (upgrade, maybe_upgrade_proof) = self + .src_chain() + .query_upgrade( + QueryUpgradeRequest { + port_id: self.src_port_id().to_string(), + channel_id: src_channel_id.to_string(), + }, + src_latest_height, + ) + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; - let proof_height = upgrade_response - .proof_height - .ok_or(ChannelError::missing_channel_proof())? - .try_into() - .unwrap(); + let upgrade_proof = maybe_upgrade_proof.ok_or(ChannelError::missing_upgrade_proof())?; + + let proof_upgrade = + CommitmentProofBytes::try_from(upgrade_proof).map_err(ChannelError::malformed_proof)?; // TODO: Is this check necessary? if channel_end.counterparty().port_id() != self.dst_port_id() { @@ -1664,13 +1687,6 @@ impl Channel { )); } - let Some(channel_proof) = maybe_channel_proof else { - return Err(ChannelError::missing_channel_proof()); - }; - - let channel_proof_bytes = - CommitmentProofBytes::try_from(channel_proof).map_err(ChannelError::malformed_proof)?; - if channel_end.state != State::InitUpgrade { return Err(ChannelError::invalid_channel_upgrade_state()); } @@ -1682,42 +1698,30 @@ impl Channel { // Build the domain type message let new_msg = MsgChannelUpgradeTry { - port_id: src_port_id.clone(), - channel_id: src_channel_id.clone(), - proposed_upgrade_connection_hops: vec![], // UPGRADE TODO + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + proposed_upgrade_connection_hops: dst_channel_end.connection_hops, upgrade_timeout: timeout, - counterparty_proposed_upgrade: upgrade_response.upgrade.unwrap().try_into().unwrap(), - counterparty_upgrade_sequence: upgrade_sequence, - proof_channel: channel_proof_bytes, + counterparty_proposed_upgrade: upgrade, + counterparty_upgrade_sequence: channel_end.upgraded_sequence, + proof_channel: src_proof.object_proof().clone(), proof_upgrade, - proof_height, + proof_height: src_proof.height(), signer, }; - Ok(vec![new_msg.to_any()]) + let mut chain_a_msgs = self.build_update_client_on_dst(src_proof.height())?; + + chain_a_msgs.push(new_msg.to_any()); + + Ok(chain_a_msgs) } pub fn build_chan_upgrade_try_and_send( &self, timeout: UpgradeTimeout, ) -> Result { - let dst_channel_id = self - .dst_channel_id() - .ok_or_else(ChannelError::missing_local_channel_id)?; - - let dst_port_id = self.dst_port_id(); - let (channel_end, _maybe_channel_proof) = self - .dst_chain() - .query_channel( - QueryChannelRequest { - port_id: dst_port_id.clone(), - channel_id: dst_channel_id.clone(), - height: QueryHeight::Latest, - }, - IncludeProof::No, - ) - .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; - let dst_msgs = self.build_chan_upgrade_try(timeout, channel_end.upgraded_sequence)?; + let dst_msgs = self.build_chan_upgrade_try(timeout)?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTry"); @@ -1730,7 +1734,8 @@ impl Channel { let result = events .into_iter() .find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) + //matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) + matches!(event_with_height.event, IbcEvent::UpgradeInitChannel(_)) // Current implementation of simapp || matches!(event_with_height.event, IbcEvent::ChainError(_)) }) .ok_or_else(|| { @@ -1740,7 +1745,9 @@ impl Channel { })?; match &result.event { - IbcEvent::UpgradeTryChannel(_) => { + //IbcEvent::UpgradeTryChannel(_) => { + IbcEvent::UpgradeInitChannel(_) => { + // Current implementation of simapp info!("👋 {} => {}", self.dst_chain().id(), result); Ok(result.event) } diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index d1e4e1138c..ff8b0809b8 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -66,6 +66,9 @@ define_error! { MissingChannelProof |_| { "missing channel proof" }, + MissingUpgradeProof + |_| { "missing upgrade proof" }, + MalformedProof [ ProofError ] |_| { "malformed proof" }, diff --git a/crates/relayer/src/error.rs b/crates/relayer/src/error.rs index 28bd1fc1b9..c15b95c6d6 100644 --- a/crates/relayer/src/error.rs +++ b/crates/relayer/src/error.rs @@ -591,6 +591,14 @@ define_error! { { address: String } [ TendermintRpcError ] |e| { format!("invalid archive node address {}", e.address) }, + + InvalidPortString + { port: String } + |e| { format!("invalid port string {}", e.port) }, + + InvalidChannelString + { channel: String } + |e| { format!("invalid channel string {}", e.channel) }, } } diff --git a/tools/test-framework/src/relayer/chain.rs b/tools/test-framework/src/relayer/chain.rs index 75c2318894..6cd430eb58 100644 --- a/tools/test-framework/src/relayer/chain.rs +++ b/tools/test-framework/src/relayer/chain.rs @@ -21,7 +21,8 @@ */ use crossbeam_channel as channel; -use ibc_proto::ibc::core::channel::v1::{QueryUpgradeRequest, QueryUpgradeResponse}; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; use tracing::Span; use ibc_proto::ibc::apps::fee::v1::{ @@ -432,7 +433,11 @@ where self.value().query_incentivized_packet(request) } - fn query_upgrade(&self, request: QueryUpgradeRequest) -> Result { - self.value().query_upgrade(request) + fn query_upgrade( + &self, + request: QueryUpgradeRequest, + height: Height, + ) -> Result<(Upgrade, Option), Error> { + self.value().query_upgrade(request, height) } } From b153c0e458118117e1b4e8fcaa8a318cb246b775 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 23 Jun 2023 10:03:00 +0200 Subject: [PATCH 66/99] Update nix flake --- flake.lock | 116 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 22 deletions(-) diff --git a/flake.lock b/flake.lock index 3d2fefa7b0..73ce8fa840 100644 --- a/flake.lock +++ b/flake.lock @@ -63,6 +63,8 @@ "iris-src": "iris-src", "ixo-src": "ixo-src", "juno-src": "juno-src", + "migaloo-src": "migaloo-src", + "neutron-src": "neutron-src", "nix-std": "nix-std", "nixpkgs": "nixpkgs", "osmosis-src": "osmosis-src", @@ -84,17 +86,19 @@ "ts-relayer-src": "ts-relayer-src", "umee-src": "umee-src", "wasmd-src": "wasmd-src", + "wasmd_next-src": "wasmd_next-src", "wasmvm_0_16_3-src": "wasmvm_0_16_3-src", "wasmvm_1-src": "wasmvm_1-src", "wasmvm_1_1_1-src": "wasmvm_1_1_1-src", + "wasmvm_1_2_3-src": "wasmvm_1_2_3-src", "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1682153954, - "narHash": "sha256-nkkokaQz8vkpY92TAb4eAxM+UYcdZV4rNGdOb6+IKJ4=", + "lastModified": 1687506999, + "narHash": "sha256-eDw97IIlYB/wSYH2t+JZfRNJbehzshNvU38GGghzd2w=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "3d788d73a2d96b364a2845146bc25f8ed6b567fd", + "rev": "90fc6723def9a04189173df16817e24a9a3c7281", "type": "github" }, "original": { @@ -141,16 +145,16 @@ "evmos-src": { "flake": false, "locked": { - "lastModified": 1657722808, - "narHash": "sha256-WHo4DEaTwJXs3QGSGIRxqkaJFS6D96/zyXVmkaH867s=", + "lastModified": 1666728289, + "narHash": "sha256-hMry1q+31jqSe0krg880LIMcz0xgftB3mwfywWoLX3w=", "owner": "tharsis", "repo": "evmos", - "rev": "5f59c0f8393e15ff5894e6450567b534c498a428", + "rev": "80c38f659a65a983b221e2a568c6172b8ac3bffc", "type": "github" }, "original": { "owner": "tharsis", - "ref": "v6.0.2", + "ref": "v9.1.0", "repo": "evmos", "type": "github" } @@ -323,16 +327,16 @@ "gaia9-src": { "flake": false, "locked": { - "lastModified": 1678387146, - "narHash": "sha256-xE6jZKIgmZ+/bFUWrdoyOy73fsC1VdYfhxH9u4tD7HI=", + "lastModified": 1681924944, + "narHash": "sha256-UIM6yfqs1yZZ2BO/bBB43pPYSW1IzaYsk2f500tDYzA=", "owner": "cosmos", "repo": "gaia", - "rev": "4b14265197d9beeb6c8b0d407433c852a5af6422", + "rev": "05b6b87d3c9121e933eab437772ea56f33ae268f", "type": "github" }, "original": { "owner": "cosmos", - "ref": "v9.0.1", + "ref": "v9.0.3", "repo": "gaia", "type": "github" } @@ -464,16 +468,16 @@ "ibc-go-v7-src": { "flake": false, "locked": { - "lastModified": 1678970403, - "narHash": "sha256-vdsDqLHpP0Bp0j8gtDOdouzyQXKioZsxJA+znkQw6JY=", + "lastModified": 1686298823, + "narHash": "sha256-8ModVWpRWbwWQLj5BCCopn7vpOJjFp4ISESCCp4pqWQ=", "owner": "cosmos", "repo": "ibc-go", - "rev": "7fb65c76000f207ece1b83d8950e3aaff3dfc0e7", + "rev": "000e9d20b15b3c6939cefc0e26daa4b64c1be8fb", "type": "github" }, "original": { "owner": "cosmos", - "ref": "v7.0.0", + "ref": "v7.1.0", "repo": "ibc-go", "type": "github" } @@ -596,6 +600,40 @@ "type": "github" } }, + "migaloo-src": { + "flake": false, + "locked": { + "lastModified": 1681833529, + "narHash": "sha256-7sOAcUcc1HpZgLjjdiNuXeXCq9vB9EXCMY4YIT1MAgU=", + "owner": "White-Whale-Defi-Platform", + "repo": "migaloo-chain", + "rev": "129e6fecd377614123f2af33417f9e31accf195f", + "type": "github" + }, + "original": { + "owner": "White-Whale-Defi-Platform", + "ref": "v2.0.2", + "repo": "migaloo-chain", + "type": "github" + } + }, + "neutron-src": { + "flake": false, + "locked": { + "lastModified": 1685114240, + "narHash": "sha256-xHi4W4fOT3kTmkPEKdGp6JbzKQELdWy9PIn0qsZhprY=", + "owner": "neutron-org", + "repo": "neutron", + "rev": "3c8dde1ff524551e24295d393a3913c25199d265", + "type": "github" + }, + "original": { + "owner": "neutron-org", + "ref": "v1.0.2", + "repo": "neutron", + "type": "github" + } + }, "nix-std": { "locked": { "lastModified": 1658944356, @@ -661,11 +699,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1687245362, - "narHash": "sha256-+f9tH+k3u9lSS136M2LCsl5NJTNPvhmHEiVOcypiu1E=", + "lastModified": 1687488839, + "narHash": "sha256-7JDjuyHwUvGJJge9jxfRJkuYyL5G5yipspc4J3HwjGA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "205ee073b053fc4d87d5adf2ebd44ebbef7bca4d", + "rev": "f9e94676ce6c7531c44d38da61d2669ebec0f603", "type": "github" }, "original": { @@ -932,16 +970,16 @@ "stride-src": { "flake": false, "locked": { - "lastModified": 1678771112, - "narHash": "sha256-c971YXdUSVhpEQFDuBNsG1DooOus1ps0jw4x6haTSdU=", + "lastModified": 1679819302, + "narHash": "sha256-fdjnFHPBZNnhDyVoMuPfqNb6YUYRdcMO73FlZHjIuzA=", "owner": "Stride-Labs", "repo": "stride", - "rev": "ef4808d4095c3da3c4f35e1b37495b5813624d14", + "rev": "3c69e7644859981b1fd9313eb1f0c5e5886e4a0d", "type": "github" }, "original": { "owner": "Stride-Labs", - "ref": "v7.0.0", + "ref": "v8.0.0", "repo": "stride", "type": "github" } @@ -1029,6 +1067,23 @@ "type": "github" } }, + "wasmd_next-src": { + "flake": false, + "locked": { + "lastModified": 1682094944, + "narHash": "sha256-b+6XhBdKyQlrzsYxVRrDf4vHpv8GAJkGwHVfJ9sdf3U=", + "owner": "CosmWasm", + "repo": "wasmd", + "rev": "c2bb27d289f7f72f1471a4b33cb08fdfc8d66f63", + "type": "github" + }, + "original": { + "owner": "CosmWasm", + "ref": "v0.40.0-rc.1", + "repo": "wasmd", + "type": "github" + } + }, "wasmvm_0_16_3-src": { "flake": false, "locked": { @@ -1080,6 +1135,23 @@ "type": "github" } }, + "wasmvm_1_2_3-src": { + "flake": false, + "locked": { + "lastModified": 1681831436, + "narHash": "sha256-GscUMJ0Tkg77S9IYA9komyKKoa1AyVXSSaU8hw3ZNwk=", + "owner": "CosmWasm", + "repo": "wasmvm", + "rev": "61e41ae2a80081224f469614a267b0ba2a2d305f", + "type": "github" + }, + "original": { + "owner": "CosmWasm", + "ref": "v1.2.3", + "repo": "wasmvm", + "type": "github" + } + }, "wasmvm_1_beta7-src": { "flake": false, "locked": { From 246cf7c827b590bb6d9d4396b6f619b87dc844cd Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:59:38 +0200 Subject: [PATCH 67/99] Add integration test for `ChanUpgradeTry` step (#3259) * Add test for ChannelUpgradeInit step * Add conditional check 'channel-upgrade' to channel upgradability tests * Improve info message * Update event processing for UpgradeInit * Update UpgradeInit step test * Rename ChannelUpgradeInit test * Add ChanUpgradeTry test * Improve channel upgrade steps assertion * Add ChannelUpgradeAssertionAttributes struct for tests * Update naming for modifiable channel attributes in tests * Fix test doc string * Restore commented lines for channel upgrade TRY step * Improve channel upgrade tests * Disable TRY assert in test * Remove unnecessary test configuration for channel upgrade * Merge channel upgrade Init and Try tests into a single test * Improve channel upgrade test * Use 'CountingAndCachingChainHandle' in integration tests and 'IncludeProof::Yes' when querying channel ends in the integration tests * Updated channel upgrade TRY step tests * Fix and improve channel upgrade TRY step test * Updated nix flake * Fix test-stable * Update nix flake and TRY step test * Fix interchain-security CI. Add domain type FlushStatus * Fix FlushStatus display errors --- .github/workflows/integration.yaml | 1 + .../src/core/ics04_channel/channel.rs | 18 +- .../src/core/ics04_channel/error.rs | 4 + .../src/core/ics04_channel/flush_status.rs | 58 ++++++ .../src/core/ics04_channel/mod.rs | 1 + .../ics04_channel/msgs/chan_upgrade_try.rs | 12 +- crates/relayer/src/channel.rs | 3 +- flake.lock | 26 +-- .../channel_upgrade/manual_channel_upgrade.rs | 68 ++++--- .../src/bootstrap/binary/chain.rs | 10 +- tools/test-framework/src/relayer/channel.rs | 185 ++++++++++-------- tools/test-framework/src/relayer/driver.rs | 6 +- 12 files changed, 246 insertions(+), 146 deletions(-) create mode 100644 crates/relayer-types/src/core/ics04_channel/flush_status.rs diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index aed1f96a7d..c8a07e56d4 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -484,6 +484,7 @@ jobs: run: | nix shell .#gaia9 .#${{ matrix.chain.package }} -c cargo \ test -p ibc-integration-test --features interchain-security --no-fail-fast -- \ + --nocapture --test-threads=1 interchain_security:: model-based-test: runs-on: ubuntu-20.04 diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 0c2ad25081..23f06e8fa6 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -7,12 +7,12 @@ use ibc_proto::protobuf::Protobuf; use serde::{Deserialize, Serialize}; use ibc_proto::ibc::core::channel::v1::{ - Channel as RawChannel, Counterparty as RawCounterparty, FlushStatus, + Channel as RawChannel, Counterparty as RawCounterparty, FlushStatus as RawFlushStatus, IdentifiedChannel as RawIdentifiedChannel, }; use crate::core::ics04_channel::packet::Sequence; -use crate::core::ics04_channel::{error::Error, version::Version}; +use crate::core::ics04_channel::{error::Error, flush_status::FlushStatus, version::Version}; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] @@ -140,8 +140,7 @@ impl TryFrom for ChannelEnd { let version = value.version.into(); - let flush_status = FlushStatus::from_i32(value.flush_status) - .ok_or_else(|| Error::invalid_flush_status(value.flush_status))?; + let flush_status = FlushStatus::try_from(value.flush_status)?; Ok(ChannelEnd::new( chan_state, @@ -168,7 +167,7 @@ impl From for RawChannel { .collect(), version: value.version.to_string(), upgrade_sequence: value.upgraded_sequence.into(), - flush_status: value.flush_status.into(), + flush_status: RawFlushStatus::from(value.flush_status).into(), } } } @@ -217,6 +216,10 @@ impl ChannelEnd { &self.state } + pub fn flush_status(&self) -> &FlushStatus { + &self.flush_status + } + pub fn ordering(&self) -> &Ordering { &self.ordering } @@ -248,6 +251,11 @@ impl ChannelEnd { self.state.eq(other) } + /// Helper function to compare the flush status of this end with another flush status. + pub fn flush_status_matches(&self, other: &FlushStatus) -> bool { + self.flush_status.eq(other) + } + /// Helper function to compare the order of this end with another order. pub fn order_matches(&self, other: &Ordering) -> bool { self.ordering.eq(other) diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index 7d5dcfcb85..e8c137a3ed 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -26,6 +26,10 @@ define_error! { { state: i32 } | e | { format_args!("channel state unknown: {}", e.state) }, + UnknownFlushStatus + { state: i32 } + | e | { format_args!("flush status unknown: {}", e.state) }, + Identifier [ ValidationError ] | _ | { "identifier error" }, diff --git a/crates/relayer-types/src/core/ics04_channel/flush_status.rs b/crates/relayer-types/src/core/ics04_channel/flush_status.rs new file mode 100644 index 0000000000..a20376ee2f --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/flush_status.rs @@ -0,0 +1,58 @@ +use std::fmt::Display; +use std::fmt::Error as FmtError; +use std::fmt::Formatter; + +use serde::Deserialize; +use serde::Serialize; + +use ibc_proto::ibc::core::channel::v1::FlushStatus as RawFlushStatus; + +use crate::core::ics04_channel::error::Error; + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub enum FlushStatus { + NotinflushUnspecified = 0, + Flushing = 1, + Flushcomplete = 2, +} + +impl Display for FlushStatus { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + match self { + FlushStatus::NotinflushUnspecified => write!(f, "FLUSH_STATUS_NOTINFLUSH_UNSPECIFIED"), + FlushStatus::Flushing => write!(f, "FLUSH_STATUS_FLUSHING"), + FlushStatus::Flushcomplete => write!(f, "FLUSH_STATUS_FLUSHCOMPLETE"), + } + } +} + +impl TryFrom for FlushStatus { + type Error = Error; + + fn try_from(value: RawFlushStatus) -> Result { + value.try_into() + } +} + +impl From for RawFlushStatus { + fn from(value: FlushStatus) -> Self { + match value { + FlushStatus::NotinflushUnspecified => RawFlushStatus::NotinflushUnspecified, + FlushStatus::Flushing => RawFlushStatus::Flushing, + FlushStatus::Flushcomplete => RawFlushStatus::Flushcomplete, + } + } +} + +impl TryFrom for FlushStatus { + type Error = Error; + + fn try_from(value: i32) -> Result { + match value { + 0 => Ok(FlushStatus::NotinflushUnspecified), + 1 => Ok(FlushStatus::Flushing), + 2 => Ok(FlushStatus::Flushcomplete), + _ => Err(Error::unknown_flush_status(value)), + } + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/mod.rs b/crates/relayer-types/src/core/ics04_channel/mod.rs index 018a0608de..b3abac8a4b 100644 --- a/crates/relayer-types/src/core/ics04_channel/mod.rs +++ b/crates/relayer-types/src/core/ics04_channel/mod.rs @@ -5,6 +5,7 @@ pub mod channel; pub mod commitment; pub mod error; pub mod events; +pub mod flush_status; pub mod msgs; pub mod packet; pub mod packet_id; diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 8ed0fa43b1..70ccc508be 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -150,24 +150,30 @@ pub mod test_util { use ibc_proto::ibc::core::channel::v1::{ MsgChannelUpgradeTry as RawMsgChannelUpgradeTry, Timeout, }; - use ibc_proto::ibc::core::client::v1::Height; + use ibc_proto::ibc::core::client::v1::Height as RawHeight; + use crate::core::ics02_client::height::Height; use crate::core::ics04_channel::upgrade::test_util::get_dummy_upgrade; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; + use crate::timestamp::Timestamp; /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! pub fn get_dummy_raw_msg_chan_upgrade_try() -> RawMsgChannelUpgradeTry { + let dummy_timeout = Timeout { + height: Some(Height::new(0, 10).unwrap().into()), + timestamp: Timestamp::now().nanoseconds(), + }; RawMsgChannelUpgradeTry { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), proposed_upgrade_connection_hops: vec![], - upgrade_timeout: Some(Timeout::default()), + upgrade_timeout: Some(dummy_timeout), counterparty_proposed_upgrade: Some(get_dummy_upgrade()), counterparty_upgrade_sequence: 1, proof_upgrade: get_dummy_proof(), proof_channel: get_dummy_proof(), - proof_height: Some(Height { + proof_height: Some(RawHeight { revision_number: 1, revision_height: 1, }), diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index bc8ed978b7..6ee91d1607 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,5 +1,6 @@ pub use error::ChannelError; -use ibc_proto::ibc::core::channel::v1::{FlushStatus, QueryUpgradeRequest}; +use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_relayer_types::core::ics04_channel::flush_status::FlushStatus; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::upgrade_fields::UpgradeFields; diff --git a/flake.lock b/flake.lock index 73ce8fa840..100b3572c1 100644 --- a/flake.lock +++ b/flake.lock @@ -94,11 +94,11 @@ "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1687506999, - "narHash": "sha256-eDw97IIlYB/wSYH2t+JZfRNJbehzshNvU38GGghzd2w=", + "lastModified": 1688365359, + "narHash": "sha256-+wsphHIOmzXo9Xx9awSpU4LEWYyAQYCB2s998XRXeBQ=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "90fc6723def9a04189173df16817e24a9a3c7281", + "rev": "31d2178ff2db50f7d874fc6b5a206d75e346d74a", "type": "github" }, "original": { @@ -210,11 +210,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1687171271, - "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", "owner": "numtide", "repo": "flake-utils", - "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", "type": "github" }, "original": { @@ -451,17 +451,17 @@ "ibc-go-v7-channel-upgrade-src": { "flake": false, "locked": { - "lastModified": 1681914625, - "narHash": "sha256-MaUx988kvPc5AAlDiEPB0o0t+h+JyB3LsEFvPOvogQE=", + "lastModified": 1688114595, + "narHash": "sha256-jsEHc27nlK8wIBz1d7pgcSMDuDPt6zsXeYwrludF8dY=", "owner": "cosmos", "repo": "ibc-go", - "rev": "81a709b49a42504737d25be0e812d830f9a0897c", + "rev": "a7793bc10425d6f01e0b00a63520166837990221", "type": "github" }, "original": { "owner": "cosmos", "repo": "ibc-go", - "rev": "81a709b49a42504737d25be0e812d830f9a0897c", + "rev": "a7793bc10425d6f01e0b00a63520166837990221", "type": "github" } }, @@ -699,11 +699,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1687488839, - "narHash": "sha256-7JDjuyHwUvGJJge9jxfRJkuYyL5G5yipspc4J3HwjGA=", + "lastModified": 1688221086, + "narHash": "sha256-cdW6qUL71cNWhHCpMPOJjlw0wzSRP0pVlRn2vqX/VVg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f9e94676ce6c7531c44d38da61d2669ebec0f603", + "rev": "cd99c2b3c9f160cd004318e0697f90bbd5960825", "type": "github" }, "original": { diff --git a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs index b5c27ec583..20e2210d1a 100644 --- a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs +++ b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs @@ -1,30 +1,28 @@ +//! Tests the successful channel upgrade handshake: +//! +//! - `ChannelUpgradeManualHandshake` tests that after the channel can be upgraded +//! without relaying on the supervisor. This test manually calls the INIT, TRY, +//! ACK and CONFIRM steps. + use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; use ibc_relayer_types::core::{ics02_client::height::Height, ics04_channel::version::Version}; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ assert_eventually_channel_established, assert_eventually_channel_upgrade_init, - init_channel_upgrade, ChannelUpgradeAssertionAttributes, + assert_eventually_channel_upgrade_try, ChannelUpgradableAttributes, }; #[test] -fn test_channel_upgrade_init_handshake() -> Result<(), Error> { - run_binary_channel_test(&ChannelUpgradeInitHandshake) +fn test_channel_upgrade_manual_handshake() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeManualHandshake) } -pub struct ChannelUpgradeInitHandshake; +pub struct ChannelUpgradeManualHandshake; -impl TestOverrides for ChannelUpgradeInitHandshake { +impl TestOverrides for ChannelUpgradeManualHandshake { fn modify_test_config(&self, config: &mut TestConfig) { - config.bootstrap_with_random_ids = false; - } - - fn modify_relayer_config(&self, config: &mut Config) { - config.mode.connections.enabled = true; - - config.mode.channels.enabled = false; - config.mode.packets.enabled = false; - config.mode.clients.enabled = false; + config.bootstrap_with_random_ids = true; } fn should_spawn_supervisor(&self) -> bool { @@ -32,7 +30,7 @@ impl TestOverrides for ChannelUpgradeInitHandshake { } } -impl BinaryChannelTest for ChannelUpgradeInitHandshake { +impl BinaryChannelTest for ChannelUpgradeManualHandshake { fn run( &self, _config: &TestConfig, @@ -50,11 +48,11 @@ impl BinaryChannelTest for ChannelUpgradeInitHandshake { )?; let channel_end_a = chains - .handle_b + .handle_a .query_channel( QueryChannelRequest { - port_id: channels.port_b.0.clone(), - channel_id: channels.channel_id_b.0.clone(), + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), height: QueryHeight::Latest, }, IncludeProof::No, @@ -63,11 +61,11 @@ impl BinaryChannelTest for ChannelUpgradeInitHandshake { .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; let channel_end_b = chains - .handle_a + .handle_b .query_channel( QueryChannelRequest { - port_id: channels.port_a.0.clone(), - channel_id: channels.channel_id_a.0.clone(), + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), height: QueryHeight::Latest, }, IncludeProof::No, @@ -85,12 +83,7 @@ impl BinaryChannelTest for ChannelUpgradeInitHandshake { let new_ordering = None; let new_connection_hops = None; - // Only Version is changed in this test. - let upgrade_attrs = ChannelUpgradeAssertionAttributes::new( - old_version.clone(), - old_ordering, - old_connection_hops_a.clone(), - old_connection_hops_b.clone(), + let upgrade_attrs = ChannelUpgradableAttributes::new( old_version, old_ordering, old_connection_hops_a, @@ -104,24 +97,35 @@ impl BinaryChannelTest for ChannelUpgradeInitHandshake { .map_err(|e| eyre!("error creating height for timeout height: {e}"))?; let timeout = UpgradeTimeout::Height(timeout_height); - info!("Initialise channel upgrade process..."); + info!("Set channel in (INITUPGRADE, OPEN) state..."); - init_channel_upgrade( - channel, + channel.flipped().build_chan_upgrade_init_and_send( Some(new_version), new_ordering, new_connection_hops, - timeout, + timeout.clone(), )?; info!("Check that the step ChanUpgradeInit was correctly executed..."); assert_eventually_channel_upgrade_init( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgrade_attrs, + )?; + + info!("Set channel in (INITUPGRADE, TRYUPGRADE) state..."); + + channel.build_chan_upgrade_try_and_send(timeout)?; + + assert_eventually_channel_upgrade_try( &chains.handle_b, &chains.handle_a, &channels.channel_id_b.as_ref(), &channels.port_b.as_ref(), - &upgrade_attrs, + &upgrade_attrs.flipped(), )?; Ok(()) diff --git a/tools/test-framework/src/bootstrap/binary/chain.rs b/tools/test-framework/src/bootstrap/binary/chain.rs index 7787dbe47e..386e743b28 100644 --- a/tools/test-framework/src/bootstrap/binary/chain.rs +++ b/tools/test-framework/src/bootstrap/binary/chain.rs @@ -4,7 +4,7 @@ */ use eyre::Report as Error; -use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle, CountingChainHandle}; +use ibc_relayer::chain::handle::{ChainHandle, CountingAndCachingChainHandle}; use ibc_relayer::config::Config; use ibc_relayer::error::ErrorDetail as RelayerErrorDetail; use ibc_relayer::foreign_client::{ @@ -242,13 +242,11 @@ pub fn add_keys_to_chain_handle( } /** - Create a new [`SharedRegistry`] that uses [`ibc_relayer::chain::handle::CountingAndCachingChainHandle`] + Create a new [`SharedRegistry`] that uses [`CountingAndCachingChainHandle`] as the [`ChainHandle`] implementation. */ -// FIXME: Temporarily disable CachingChainHandle for Chain Upgrade tests as the -// caching causes the queried Channel End to not have the correct information. -pub fn new_registry(config: Config) -> SharedRegistry> { - >>::new(config) +pub fn new_registry(config: Config) -> SharedRegistry { + >::new(config) } /** diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index 532eea86a9..4c005b8bd2 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -6,7 +6,7 @@ use ibc_relayer::channel::{extract_channel_id, Channel, ChannelSide}; use ibc_relayer_types::core::ics04_channel::channel::{ ChannelEnd, IdentifiedChannelEnd, Ordering, State as ChannelState, }; -use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; +use ibc_relayer_types::core::ics04_channel::flush_status::FlushStatus; use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::ConnectionId; @@ -36,70 +36,52 @@ impl TaggedChannelEndExt } } -pub struct ChannelUpgradeAssertionAttributes { - old_version: Version, - old_ordering: Ordering, - old_connection_hops_a: Vec, - old_connection_hops_b: Vec, - new_version: Version, - new_ordering: Ordering, - new_connection_hops_a: Vec, - new_connection_hops_b: Vec, +/// This struct contains the attributes which can be modified with a channel upgrade +pub struct ChannelUpgradableAttributes { + version: Version, + ordering: Ordering, + connection_hops_a: Vec, + connection_hops_b: Vec, } -impl ChannelUpgradeAssertionAttributes { +impl ChannelUpgradableAttributes { pub fn new( - old_version: Version, - old_ordering: Ordering, - old_connection_hops_a: Vec, - old_connection_hops_b: Vec, - new_version: Version, - new_ordering: Ordering, - new_connection_hops_a: Vec, - new_connection_hops_b: Vec, + version: Version, + ordering: Ordering, + connection_hops_a: Vec, + connection_hops_b: Vec, ) -> Self { Self { - old_version, - old_ordering, - old_connection_hops_a, - old_connection_hops_b, - new_version, - new_ordering, - new_connection_hops_a, - new_connection_hops_b, + version, + ordering, + connection_hops_a, + connection_hops_b, } } - pub fn old_version(&self) -> &Version { - &self.old_version - } - - pub fn old_ordering(&self) -> &Ordering { - &self.old_ordering - } - - pub fn old_connection_hops_a(&self) -> &Vec { - &self.old_connection_hops_a - } - - pub fn old_connection_hops_b(&self) -> &Vec { - &self.old_connection_hops_b + pub fn flipped(&self) -> Self { + Self { + version: self.version.clone(), + ordering: self.ordering, + connection_hops_a: self.connection_hops_b.clone(), + connection_hops_b: self.connection_hops_a.clone(), + } } - pub fn new_version(&self) -> &Version { - &self.new_version + pub fn version(&self) -> &Version { + &self.version } - pub fn new_ordering(&self) -> &Ordering { - &self.new_ordering + pub fn ordering(&self) -> &Ordering { + &self.ordering } - pub fn new_connection_hops_a(&self) -> &Vec { - &self.new_connection_hops_a + pub fn connection_hops_a(&self) -> &Vec { + &self.connection_hops_a } - pub fn new_connection_hops_b(&self) -> &Vec { - &self.new_connection_hops_b + pub fn connection_hops_b(&self) -> &Vec { + &self.connection_hops_b } } @@ -211,7 +193,7 @@ pub fn query_channel_end( channel_id: channel_id.into_value().clone(), height: QueryHeight::Latest, }, - IncludeProof::No, + IncludeProof::Yes, )?; Ok(DualTagged::new(channel_end)) @@ -278,28 +260,12 @@ pub fn assert_eventually_channel_established( - channel: Channel, - new_version: Option, - new_ordering: Option, - new_connection_hops: Option>, - timeout: UpgradeTimeout, -) -> Result<(), Error> { - channel.build_chan_upgrade_init_and_send( - new_version, - new_ordering, - new_connection_hops, - timeout, - )?; - Ok(()) -} - pub fn assert_eventually_channel_upgrade_init( handle_a: &ChainA, handle_b: &ChainB, channel_id_a: &TaggedChannelIdRef, port_id_a: &TaggedPortIdRef, - upgrade_attrs: &ChannelUpgradeAssertionAttributes, + upgrade_attrs: &ChannelUpgradableAttributes, ) -> Result, Error> { assert_eventually_succeed( "channel upgrade should be initialised", @@ -314,6 +280,8 @@ pub fn assert_eventually_channel_upgrade_init( + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + upgrade_attrs: &ChannelUpgradableAttributes, +) -> Result, Error> { + assert_eventually_succeed( + "channel upgrade try step should be done", + 20, + Duration::from_secs(1), + || { + assert_channel_upgrade_state( + ChannelState::TryUpgrade, + ChannelState::InitUpgrade, + FlushStatus::Flushcomplete, + FlushStatus::NotinflushUnspecified, + handle_a, + handle_b, + channel_id_a, + port_id_a, + upgrade_attrs, + ) + }, + ) +} + fn assert_channel_upgrade_state( a_side_state: ChannelState, b_side_state: ChannelState, + a_side_flush_status: FlushStatus, + b_side_flush_status: FlushStatus, handle_a: &ChainA, handle_b: &ChainB, channel_id_a: &TaggedChannelIdRef, port_id_a: &TaggedPortIdRef, - upgrade_attrs: &ChannelUpgradeAssertionAttributes, + upgrade_attrs: &ChannelUpgradableAttributes, ) -> Result, Error> { let channel_end_a = query_channel_end(handle_a, channel_id_a, port_id_a)?; if !channel_end_a.value().state_matches(&a_side_state) { return Err(Error::generic(eyre!( - "expected channel end A to `{}`, but is instead `{}`", + "expected channel end A state to be `{}`, but is instead `{}`", a_side_state, channel_end_a.value().state() ))); @@ -347,33 +344,44 @@ fn assert_channel_upgrade_state( if !channel_end_a .value() - .version_matches(upgrade_attrs.new_version()) + .flush_status_matches(&a_side_flush_status) + { + return Err(Error::generic(eyre!( + "expected channel end A flush status to be `{}`, but is instead `{}`", + a_side_flush_status, + channel_end_a.value().flush_status() + ))); + } + + if !channel_end_a + .value() + .version_matches(upgrade_attrs.version()) { return Err(Error::generic(eyre!( "expected channel end A version to be `{}`, but it is instead `{}`", - upgrade_attrs.new_version(), + upgrade_attrs.version(), channel_end_a.value().version() ))); } if !channel_end_a .value() - .order_matches(upgrade_attrs.new_ordering()) + .order_matches(upgrade_attrs.ordering()) { return Err(Error::generic(eyre!( "expected channel end A ordering to be `{}`, but it is instead `{}`", - upgrade_attrs.new_ordering(), + upgrade_attrs.ordering(), channel_end_a.value().ordering() ))); } if !channel_end_a .value() - .connection_hops_matches(upgrade_attrs.new_connection_hops_a()) + .connection_hops_matches(upgrade_attrs.connection_hops_a()) { return Err(Error::generic(eyre!( "expected channel end A connection hops to be `{:?}`, but it is instead `{:?}`", - upgrade_attrs.new_connection_hops_a(), + upgrade_attrs.connection_hops_a(), channel_end_a.value().connection_hops() ))); } @@ -388,39 +396,52 @@ fn assert_channel_upgrade_state( if !channel_end_b.value().state_matches(&b_side_state) { return Err(Error::generic(eyre!( - "expected channel end B to be in open state" + "expected channel end B state to be `{}`, but is instead `{}`", + b_side_state, + channel_end_b.value().state() + ))); + } + + if !channel_end_b + .value() + .flush_status_matches(&b_side_flush_status) + { + return Err(Error::generic(eyre!( + "expected channel end B flush status to be `{}`, but is instead `{}`", + b_side_flush_status, + channel_end_b.value().flush_status() ))); } if !channel_end_b .value() - .version_matches(upgrade_attrs.old_version()) + .version_matches(upgrade_attrs.version()) { return Err(Error::generic(eyre!( "expected channel end B version to be `{}`, but it is instead `{}`", - upgrade_attrs.new_version(), + upgrade_attrs.version(), channel_end_b.value().version() ))); } if !channel_end_b .value() - .order_matches(upgrade_attrs.old_ordering()) + .order_matches(upgrade_attrs.ordering()) { return Err(Error::generic(eyre!( "expected channel end B ordering to be `{}`, but it is instead `{}`", - upgrade_attrs.new_ordering(), + upgrade_attrs.ordering(), channel_end_b.value().ordering() ))); } if !channel_end_b .value() - .connection_hops_matches(upgrade_attrs.old_connection_hops_b()) + .connection_hops_matches(upgrade_attrs.connection_hops_b()) { return Err(Error::generic(eyre!( "expected channel end B connection hops to be `{:?}`, but it is instead `{:?}`", - upgrade_attrs.new_connection_hops_b(), + upgrade_attrs.connection_hops_b(), channel_end_b.value().connection_hops() ))); } diff --git a/tools/test-framework/src/relayer/driver.rs b/tools/test-framework/src/relayer/driver.rs index 1b29af94f3..4e16c3483d 100644 --- a/tools/test-framework/src/relayer/driver.rs +++ b/tools/test-framework/src/relayer/driver.rs @@ -2,7 +2,7 @@ Driver for spawning the relayer. */ -use ibc_relayer::chain::handle::{BaseChainHandle, CountingChainHandle}; +use ibc_relayer::chain::handle::CountingAndCachingChainHandle; use ibc_relayer::config::Config; use ibc_relayer::registry::SharedRegistry; use ibc_relayer::supervisor::{spawn_supervisor, SupervisorHandle, SupervisorOptions}; @@ -41,9 +41,7 @@ pub struct RelayerDriver { Use this shared registry when spawning new supervisor using [`spawn_supervisor`](ibc_relayer::supervisor::spawn_supervisor). */ - // FIXME: Temporarily disable CachingChainHandle for Chain Upgrade tests as the - // caching causes the queried Channel End to not have the correct information. - pub registry: SharedRegistry>, + pub registry: SharedRegistry, /** Whether the driver should hang the test when the continuation From 128e48e255e25315226c20769c86a950d1cf7858 Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Mon, 24 Jul 2023 12:12:34 +0200 Subject: [PATCH 68/99] Add Channel Upgrade ACK and CONFIRM steps (#3462) * Add test for ChannelUpgradeInit step * Add conditional check 'channel-upgrade' to channel upgradability tests * Improve info message * Update event processing for UpgradeInit * Update UpgradeInit step test * Rename ChannelUpgradeInit test * Add ChanUpgradeTry test * Improve channel upgrade steps assertion * Add ChannelUpgradeAssertionAttributes struct for tests * Update naming for modifiable channel attributes in tests * Add test for 'ChanUpgradeAck' step * Fix test doc string * Restore commented lines for channel upgrade TRY step * Improve channel upgrade tests * Fix after merge * Disable TRY assert in test * Remove unnecessary test configuration for channel upgrade * Merge channel upgrade Init and Try tests into a single test * Improve channel upgrade test * Use 'CountingAndCachingChainHandle' in integration tests and 'IncludeProof::Yes' when querying channel ends in the integration tests * Updated channel upgrade TRY step tests * Fix and improve channel upgrade TRY step test * Updated nix flake * Fix test-stable * Update nix flake and TRY step test * Update ACK step assert function * Fix interchain-security CI. Add domain type FlushStatus * Fix FlushStatus display errors * Add build and send MsgChannelUpgradeAck * Add ACK step to Channel Upgrade test * Implement Channel Upgrade OPEN step * Update flake.lock to use latest simapp for channel upgrade * Fix channel upgrade test OPEN step * Fix assertion after channelupgradeopen * Update nix flake * Fix comments * Implement PartialEq for Version * Apply suggestions and improve documentation --- Cargo.lock | 3 +- .../src/core/ics04_channel/channel.rs | 24 +- .../src/core/ics04_channel/error.rs | 4 + .../src/core/ics04_channel/events.rs | 295 +++++++++++++++++- .../src/core/ics04_channel/flush_status.rs | 17 +- .../src/core/ics04_channel/msgs.rs | 2 + .../ics04_channel/msgs/chan_upgrade_ack.rs | 258 +++++++++++++++ .../ics04_channel/msgs/chan_upgrade_open.rs | 233 ++++++++++++++ .../ics04_channel/msgs/chan_upgrade_try.rs | 4 +- .../src/core/ics04_channel/version.rs | 24 +- crates/relayer-types/src/events.rs | 16 + crates/relayer/src/channel.rs | 218 ++++++++++++- crates/relayer/src/event.rs | 53 +++- flake.lock | 26 +- .../channel_upgrade/manual_channel_upgrade.rs | 58 +++- tools/test-framework/src/relayer/channel.rs | 56 ++++ 16 files changed, 1232 insertions(+), 59 deletions(-) create mode 100644 crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs create mode 100644 crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs diff --git a/Cargo.lock b/Cargo.lock index 6b35682726..a265d9089c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1442,8 +1442,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c888103095b45bee90cb9104513ade30abd69902153b0682b5ad81940ae1f865" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#9e0ecb6f3c4b736e3ff95e1518f19deeead1a675" dependencies = [ "base64 0.21.2", "bytes", diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 23f06e8fa6..cbf14e9e34 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -248,30 +248,30 @@ impl ChannelEnd { /// Helper function to compare the state of this end with another state. pub fn state_matches(&self, other: &State) -> bool { - self.state.eq(other) + self.state() == other } /// Helper function to compare the flush status of this end with another flush status. pub fn flush_status_matches(&self, other: &FlushStatus) -> bool { - self.flush_status.eq(other) + self.flush_status() == other } /// Helper function to compare the order of this end with another order. pub fn order_matches(&self, other: &Ordering) -> bool { - self.ordering.eq(other) + self.ordering() == other } #[allow(clippy::ptr_arg)] pub fn connection_hops_matches(&self, other: &Vec) -> bool { - self.connection_hops.eq(other) + self.connection_hops() == other } pub fn counterparty_matches(&self, other: &Counterparty) -> bool { - self.counterparty().eq(other) + self.counterparty() == other } pub fn version_matches(&self, other: &Version) -> bool { - self.version().eq(other) + self.version() == other } } @@ -424,7 +424,13 @@ pub enum State { /// A channel has acknowledged the upgrade handshake step on the counterparty chain. /// The counterparty chain that accepts the upgrade should set the channel state from /// OPEN to TRYUPGRADE. + /// The counterparty chain blocks new packets until the channel upgrade is done or cancelled. TryUpgrade = 6, + /// A channel has confirmed the upgrade handshake step on the counterparty chain. + /// The chain that confirmed the upgrade should set the channel state from + /// INITUPGRADE to ACKUPGRADE. + /// The chain blocks new packets until the channel upgrade is done or cancelled. + AckUpgrade = 7, } impl State { @@ -438,6 +444,7 @@ impl State { Self::Closed => "CLOSED", Self::InitUpgrade => "INITUPGRADE", Self::TryUpgrade => "TRYUPGRADE", + Self::AckUpgrade => "ACKUPGRADE", } } @@ -451,6 +458,7 @@ impl State { 4 => Ok(Self::Closed), 5 => Ok(Self::InitUpgrade), 6 => Ok(Self::TryUpgrade), + 7 => Ok(Self::AckUpgrade), _ => Err(Error::unknown_state(s)), } } @@ -486,6 +494,10 @@ impl State { InitUpgrade => !matches!(other, Uninitialized | Init | TryOpen | Open), TryUpgrade => !matches!(other, Uninitialized | Init | TryOpen | Open | InitUpgrade), + AckUpgrade => !matches!( + other, + Uninitialized | Init | TryOpen | Open | InitUpgrade | TryUpgrade + ), Closed => false, } diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index e8c137a3ed..07a7af32ff 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -30,6 +30,10 @@ define_error! { { state: i32 } | e | { format_args!("flush status unknown: {}", e.state) }, + UnknownFlushStatusType + { type_id: String } + | e | { format_args!("flush status unknown: {}", e.type_id) }, + Identifier [ ValidationError ] | _ | { "identifier error" }, diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index 5d115e276a..42eca22569 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -7,12 +7,12 @@ use tendermint::abci; use crate::core::ics04_channel::channel::Ordering; use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::flush_status::FlushStatus; use crate::core::ics04_channel::packet::Packet; use crate::core::ics04_channel::packet::Sequence; use crate::core::ics04_channel::version::Version; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; use crate::events::{Error as EventError, IbcEvent, IbcEventType}; - use crate::utils::pretty::PrettySlice; /// Channel event attribute keys @@ -38,6 +38,7 @@ pub const UPGRADE_CONNECTION_HOPS: &str = "upgrade_connection_hops"; pub const UPGRADE_VERSION: &str = "upgrade_version"; pub const UPGRADE_SEQUENCE: &str = "upgrade_sequence"; pub const UPGRADE_ORDERING: &str = "upgrade_ordering"; +pub const CHANNEL_FLUSH_STATUS: &str = "channel_flush_status"; #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] pub struct Attributes { @@ -145,6 +146,7 @@ pub struct UpgradeAttributes { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, + pub channel_flush_status: FlushStatus, } impl UpgradeAttributes {} @@ -571,6 +573,7 @@ pub struct UpgradeInit { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, + pub channel_flush_status: FlushStatus, } impl Display for UpgradeInit { @@ -585,8 +588,8 @@ impl Display for UpgradeInit { } write!( f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status ) } } @@ -602,6 +605,7 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, + channel_flush_status: ev.channel_flush_status, } } } @@ -647,6 +651,7 @@ impl TryFrom for UpgradeInit { upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, upgrade_ordering: attrs.upgrade_ordering, + channel_flush_status: attrs.channel_flush_status, }) } } @@ -666,43 +671,94 @@ impl EventType for UpgradeInit { #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct UpgradeTry { pub port_id: PortId, - pub channel_id: Option, - pub connection_id: ConnectionId, + pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, + pub channel_flush_status: FlushStatus, } impl Display for UpgradeTry { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { - match (&self.channel_id, &self.counterparty_channel_id) { - (Some(channel_id), Some(counterparty_channel_id)) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: {} }}", self.port_id, channel_id, self.connection_id, self.counterparty_port_id, counterparty_channel_id), - (Some(channel_id), None) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: {}, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: None }}", self.port_id, channel_id, self.connection_id, self.counterparty_port_id), - (None, Some(counterparty_channel_id)) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: None, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: {} }}", self.port_id, self.connection_id, self.counterparty_port_id, counterparty_channel_id), - (None, None) => write!(f, "UpgradeTry {{ port_id: {}, channel_id: None, connection_id: {}, counterparty_port_id: {}, counterparty_channel_id: None }}", self.port_id, self.connection_id, self.counterparty_port_id), + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + ) } } -impl From for Attributes { +impl From for UpgradeAttributes { fn from(ev: UpgradeTry) -> Self { Self { port_id: ev.port_id, channel_id: ev.channel_id, - connection_id: ev.connection_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, + upgrade_connection_hops: ev.upgrade_connection_hops, + upgrade_version: ev.upgrade_version, + upgrade_sequence: ev.upgrade_sequence, + upgrade_ordering: ev.upgrade_ordering, + channel_flush_status: ev.channel_flush_status, + } + } +} + +impl From for abci::Event { + fn from(value: UpgradeTry) -> Self { + let kind = UpgradeTry::event_type().as_str().to_owned(); + Self { + kind, + attributes: UpgradeAttributes::from(value).into(), } } } impl UpgradeTry { - pub fn channel_id(&self) -> Option<&ChannelId> { - self.channel_id.as_ref() + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id } pub fn port_id(&self) -> &PortId { &self.port_id } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeTry { + type Error = EventError; + + fn try_from(attrs: UpgradeAttributes) -> Result { + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_connection_hops: attrs.upgrade_connection_hops, + upgrade_version: attrs.upgrade_version, + upgrade_sequence: attrs.upgrade_sequence, + upgrade_ordering: attrs.upgrade_ordering, + channel_flush_status: attrs.channel_flush_status, + }) + } } impl From for IbcEvent { @@ -717,6 +773,216 @@ impl EventType for UpgradeTry { } } +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeAck { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, + pub channel_flush_status: FlushStatus, +} + +impl Display for UpgradeAck { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + ) + } +} + +impl From for UpgradeAttributes { + fn from(ev: UpgradeAck) -> Self { + Self { + port_id: ev.port_id, + channel_id: ev.channel_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: ev.counterparty_channel_id, + upgrade_connection_hops: ev.upgrade_connection_hops, + upgrade_version: ev.upgrade_version, + upgrade_sequence: ev.upgrade_sequence, + upgrade_ordering: ev.upgrade_ordering, + channel_flush_status: ev.channel_flush_status, + } + } +} + +impl From for abci::Event { + fn from(value: UpgradeAck) -> Self { + let kind = UpgradeAck::event_type().as_str().to_owned(); + Self { + kind, + attributes: UpgradeAttributes::from(value).into(), + } + } +} + +impl UpgradeAck { + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeAck { + type Error = EventError; + + fn try_from(attrs: UpgradeAttributes) -> Result { + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_connection_hops: attrs.upgrade_connection_hops, + upgrade_version: attrs.upgrade_version, + upgrade_sequence: attrs.upgrade_sequence, + upgrade_ordering: attrs.upgrade_ordering, + channel_flush_status: attrs.channel_flush_status, + }) + } +} + +impl From for IbcEvent { + fn from(v: UpgradeAck) -> Self { + IbcEvent::UpgradeAckChannel(v) + } +} + +impl EventType for UpgradeAck { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeAckChannel + } +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeOpen { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, + pub channel_flush_status: FlushStatus, +} + +impl Display for UpgradeOpen { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + ) + } +} + +impl From for UpgradeAttributes { + fn from(ev: UpgradeOpen) -> Self { + Self { + port_id: ev.port_id, + channel_id: ev.channel_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: ev.counterparty_channel_id, + upgrade_connection_hops: ev.upgrade_connection_hops, + upgrade_version: ev.upgrade_version, + upgrade_sequence: ev.upgrade_sequence, + upgrade_ordering: ev.upgrade_ordering, + channel_flush_status: ev.channel_flush_status, + } + } +} + +impl From for abci::Event { + fn from(value: UpgradeOpen) -> Self { + let kind = UpgradeOpen::event_type().as_str().to_owned(); + Self { + kind, + attributes: UpgradeAttributes::from(value).into(), + } + } +} + +impl UpgradeOpen { + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeOpen { + type Error = EventError; + + fn try_from(attrs: UpgradeAttributes) -> Result { + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_connection_hops: attrs.upgrade_connection_hops, + upgrade_version: attrs.upgrade_version, + upgrade_sequence: attrs.upgrade_sequence, + upgrade_ordering: attrs.upgrade_ordering, + channel_flush_status: attrs.channel_flush_status, + }) + } +} + +impl From for IbcEvent { + fn from(v: UpgradeOpen) -> Self { + IbcEvent::UpgradeOpenChannel(v) + } +} + +impl EventType for UpgradeOpen { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeOpenChannel + } +} + macro_rules! impl_try_from_attribute_for_event { ($($event:ty),+) => { $(impl TryFrom for $event { @@ -756,7 +1022,6 @@ impl_from_ibc_to_abci_event!( OpenTry, OpenAck, OpenConfirm, - UpgradeTry, CloseInit, CloseConfirm ); diff --git a/crates/relayer-types/src/core/ics04_channel/flush_status.rs b/crates/relayer-types/src/core/ics04_channel/flush_status.rs index a20376ee2f..80cfb172d3 100644 --- a/crates/relayer-types/src/core/ics04_channel/flush_status.rs +++ b/crates/relayer-types/src/core/ics04_channel/flush_status.rs @@ -1,6 +1,7 @@ use std::fmt::Display; use std::fmt::Error as FmtError; use std::fmt::Formatter; +use std::str::FromStr; use serde::Deserialize; use serde::Serialize; @@ -9,8 +10,9 @@ use ibc_proto::ibc::core::channel::v1::FlushStatus as RawFlushStatus; use crate::core::ics04_channel::error::Error; -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub enum FlushStatus { + #[default] NotinflushUnspecified = 0, Flushing = 1, Flushcomplete = 2, @@ -26,6 +28,19 @@ impl Display for FlushStatus { } } +impl FromStr for FlushStatus { + type Err = Error; + + fn from_str(s: &str) -> Result { + match s.to_lowercase().trim_start_matches("flush_status_") { + "notinflush_unspecified" => Ok(Self::NotinflushUnspecified), + "flushing" => Ok(Self::Flushing), + "flushcomplete" => Ok(Self::Flushcomplete), + _ => Err(Error::unknown_flush_status_type(s.to_string())), + } + } +} + impl TryFrom for FlushStatus { type Error = Error; diff --git a/crates/relayer-types/src/core/ics04_channel/msgs.rs b/crates/relayer-types/src/core/ics04_channel/msgs.rs index 830e1cfff1..f4bf9a77bb 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs.rs @@ -23,7 +23,9 @@ pub mod chan_close_confirm; pub mod chan_close_init; // Upgrade handshake messages. +pub mod chan_upgrade_ack; pub mod chan_upgrade_init; +pub mod chan_upgrade_open; pub mod chan_upgrade_try; // Packet specific messages. diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs new file mode 100644 index 0000000000..dd22baf7ee --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs @@ -0,0 +1,258 @@ +use ibc_proto::ibc::core::channel::v1::FlushStatus as RawFlushStatus; +use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeAck as RawMsgChannelUpgradeAck; +use ibc_proto::protobuf::Protobuf; + +use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::flush_status::FlushStatus; +use crate::core::ics04_channel::upgrade::Upgrade; +use crate::core::ics23_commitment::commitment::CommitmentProofBytes; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; +use crate::tx_msg::Msg; +use crate::Height; + +pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeAck"; + +/// Message definition for the third step of the channel upgrade +/// handshake (the `ChanUpgradeAck` datagram). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgChannelUpgradeAck { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_flush_status: FlushStatus, + pub counterparty_upgrade: Upgrade, + /// The proof of the counterparty channel + pub proof_channel: CommitmentProofBytes, + /// The proof of the counterparty upgrade + pub proof_upgrade: CommitmentProofBytes, + /// The height at which the proofs were queried. + pub proof_height: Height, + pub signer: Signer, +} + +impl MsgChannelUpgradeAck { + #[allow(clippy::too_many_arguments)] + pub fn new( + port_id: PortId, + channel_id: ChannelId, + counterparty_flush_status: FlushStatus, + counterparty_upgrade: Upgrade, + proof_channel: CommitmentProofBytes, + proof_upgrade: CommitmentProofBytes, + proof_height: Height, + signer: Signer, + ) -> Self { + Self { + port_id, + channel_id, + counterparty_flush_status, + counterparty_upgrade, + proof_channel, + proof_upgrade, + proof_height, + signer, + } + } +} + +impl Msg for MsgChannelUpgradeAck { + type ValidationError = Error; + type Raw = RawMsgChannelUpgradeAck; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + +impl Protobuf for MsgChannelUpgradeAck {} + +impl TryFrom for MsgChannelUpgradeAck { + type Error = Error; + + fn try_from(raw_msg: RawMsgChannelUpgradeAck) -> Result { + let counterparty_upgrade = raw_msg + .counterparty_upgrade + .ok_or(Error::missing_upgrade())? + .try_into()?; + + let proof_height = raw_msg + .proof_height + .ok_or_else(Error::missing_proof_height)? + .try_into() + .map_err(|_| Error::invalid_proof_height())?; + + Ok(MsgChannelUpgradeAck { + port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, + channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, + counterparty_flush_status: raw_msg.counterparty_flush_status.try_into()?, + counterparty_upgrade, + proof_channel: raw_msg + .proof_channel + .try_into() + .map_err(Error::invalid_proof)?, + proof_upgrade: raw_msg + .proof_upgrade + .try_into() + .map_err(Error::invalid_proof)?, + proof_height, + signer: raw_msg.signer.parse().map_err(Error::signer)?, + }) + } +} + +impl From for RawMsgChannelUpgradeAck { + fn from(domain_msg: MsgChannelUpgradeAck) -> Self { + RawMsgChannelUpgradeAck { + port_id: domain_msg.port_id.to_string(), + channel_id: domain_msg.channel_id.to_string(), + counterparty_flush_status: RawFlushStatus::from(domain_msg.counterparty_flush_status) + .into(), + counterparty_upgrade: Some(domain_msg.counterparty_upgrade.into()), + proof_upgrade: domain_msg.proof_upgrade.into(), + proof_channel: domain_msg.proof_channel.into(), + proof_height: Some(domain_msg.proof_height.into()), + signer: domain_msg.signer.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeAck as RawMsgChannelUpgradeAck; + use ibc_proto::ibc::core::client::v1::Height as RawHeight; + + use crate::core::ics04_channel::upgrade::test_util::get_dummy_upgrade; + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; + + /// Returns a dummy `RawMsgChannelUpgradeAck`, for testing only! + pub fn get_dummy_raw_msg_chan_upgrade_ack() -> RawMsgChannelUpgradeAck { + RawMsgChannelUpgradeAck { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + counterparty_flush_status: 2, // Flushcomplete + counterparty_upgrade: Some(get_dummy_upgrade()), + proof_upgrade: get_dummy_proof(), + proof_channel: get_dummy_proof(), + proof_height: Some(RawHeight { + revision_number: 1, + revision_height: 1, + }), + signer: get_dummy_bech32_account(), + } + } +} + +#[cfg(test)] +mod tests { + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeAck as RawMsgChannelUpgradeAck; + + use crate::core::ics04_channel::msgs::chan_upgrade_ack::test_util::get_dummy_raw_msg_chan_upgrade_ack; + use crate::core::ics04_channel::msgs::chan_upgrade_ack::MsgChannelUpgradeAck; + + #[test] + fn parse_channel_upgrade_try_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeAck, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_ack(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name: "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeAck { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeAck { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeAck { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeAck { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeAck { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeAck { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Empty proof channel".to_string(), + raw: RawMsgChannelUpgradeAck { + proof_channel: vec![], + ..default_raw_msg + }, + want_pass: false, + }, + ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeAck::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "MsgChannelUpgradeAck::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_ack(); + let msg = MsgChannelUpgradeAck::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeAck::from(msg.clone()); + let msg_back = MsgChannelUpgradeAck::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs new file mode 100644 index 0000000000..841a97ee45 --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs @@ -0,0 +1,233 @@ +use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeOpen as RawMsgChannelUpgradeOpen; +use ibc_proto::protobuf::Protobuf; + +use crate::core::ics04_channel::channel::State; +use crate::core::ics04_channel::error::Error; +use crate::core::ics23_commitment::commitment::CommitmentProofBytes; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; +use crate::tx_msg::Msg; +use crate::Height; + +pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeOpen"; + +/// Message definition for the last step of the channel upgrade +/// handshake (the `ChanUpgradeOpen` datagram). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgChannelUpgradeOpen { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_channel_state: State, + /// The proof of the counterparty channel + pub proof_channel: CommitmentProofBytes, + /// The height at which the proofs were queried. + pub proof_height: Height, + pub signer: Signer, +} + +impl MsgChannelUpgradeOpen { + #[allow(clippy::too_many_arguments)] + pub fn new( + port_id: PortId, + channel_id: ChannelId, + counterparty_channel_state: State, + proof_channel: CommitmentProofBytes, + proof_height: Height, + signer: Signer, + ) -> Self { + Self { + port_id, + channel_id, + counterparty_channel_state, + proof_channel, + proof_height, + signer, + } + } +} + +impl Msg for MsgChannelUpgradeOpen { + type ValidationError = Error; + type Raw = RawMsgChannelUpgradeOpen; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + +impl Protobuf for MsgChannelUpgradeOpen {} + +impl TryFrom for MsgChannelUpgradeOpen { + type Error = Error; + + fn try_from(raw_msg: RawMsgChannelUpgradeOpen) -> Result { + let proof_height = raw_msg + .proof_height + .ok_or_else(Error::missing_proof_height)? + .try_into() + .map_err(|_| Error::invalid_proof_height())?; + + Ok(MsgChannelUpgradeOpen { + port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, + channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, + counterparty_channel_state: State::from_i32(raw_msg.counterparty_channel_state)?, + proof_channel: raw_msg + .proof_channel + .try_into() + .map_err(Error::invalid_proof)?, + proof_height, + signer: raw_msg.signer.parse().map_err(Error::signer)?, + }) + } +} + +impl From for RawMsgChannelUpgradeOpen { + fn from(domain_msg: MsgChannelUpgradeOpen) -> Self { + RawMsgChannelUpgradeOpen { + port_id: domain_msg.port_id.to_string(), + channel_id: domain_msg.channel_id.to_string(), + counterparty_channel_state: domain_msg.counterparty_channel_state as i32, + proof_channel: domain_msg.proof_channel.into(), + proof_height: Some(domain_msg.proof_height.into()), + signer: domain_msg.signer.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeOpen as RawMsgChannelUpgradeOpen; + use ibc_proto::ibc::core::client::v1::Height as RawHeight; + + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; + + /// Returns a dummy `RawMsgChannelUpgradeOpen`, for testing only! + pub fn get_dummy_raw_msg_chan_upgrade_open() -> RawMsgChannelUpgradeOpen { + RawMsgChannelUpgradeOpen { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + counterparty_channel_state: 7, // AckUpgrade + proof_channel: get_dummy_proof(), + proof_height: Some(RawHeight { + revision_number: 1, + revision_height: 1, + }), + signer: get_dummy_bech32_account(), + } + } +} + +#[cfg(test)] +mod tests { + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeOpen as RawMsgChannelUpgradeOpen; + + use crate::core::ics04_channel::msgs::chan_upgrade_open::test_util::get_dummy_raw_msg_chan_upgrade_open; + use crate::core::ics04_channel::msgs::chan_upgrade_open::MsgChannelUpgradeOpen; + + #[test] + fn parse_channel_upgrade_try_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeOpen, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_open(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name: "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeOpen { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeOpen { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeOpen { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeOpen { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeOpen { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeOpen { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Empty proof channel".to_string(), + raw: RawMsgChannelUpgradeOpen { + proof_channel: vec![], + ..default_raw_msg + }, + want_pass: false, + }, + ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeOpen::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "MsgChannelUpgradeOpen::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_open(); + let msg = MsgChannelUpgradeOpen::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeOpen::from(msg.clone()); + let msg_back = MsgChannelUpgradeOpen::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 70ccc508be..23a3880bcb 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -19,16 +19,16 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeTry"; /// handshake (the `ChanUpgradeTry` datagram). #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelUpgradeTry { - /// The port identifier of the counterparty chain (the upgrade handshake originator). pub port_id: PortId, - /// The channel identifier of the counterparty chain (the upgrade handshake originator). pub channel_id: ChannelId, pub proposed_upgrade_connection_hops: Vec, /// The height and/or timestamp after which the upgrade will be timed out. pub upgrade_timeout: UpgradeTimeout, pub counterparty_proposed_upgrade: Upgrade, pub counterparty_upgrade_sequence: Sequence, + /// The proof of the counterparty channel pub proof_channel: CommitmentProofBytes, + /// The proof of the counterparty upgrade pub proof_upgrade: CommitmentProofBytes, /// The height at which the proofs were queried. pub proof_height: Height, diff --git a/crates/relayer-types/src/core/ics04_channel/version.rs b/crates/relayer-types/src/core/ics04_channel/version.rs index 4d15ae3d4b..493648e785 100644 --- a/crates/relayer-types/src/core/ics04_channel/version.rs +++ b/crates/relayer-types/src/core/ics04_channel/version.rs @@ -15,7 +15,7 @@ use crate::applications::transfer; /// This field is opaque to the core IBC protocol. /// No explicit validation is necessary, and the /// spec (v1) currently allows empty strings. -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Deserialize, Serialize)] pub struct Version(pub String); impl Version { @@ -54,6 +54,28 @@ impl Version { } } +impl PartialEq for Version { + fn eq(&self, other: &Self) -> bool { + if self.0 != other.0 { + // If the Version strings don't match, check that this isn't due to the json + // fields being in a different order + let parsed_version = match serde_json::from_str::(&self.0) { + Ok(value) => value, + Err(_) => return false, + }; + let parsed_other = match serde_json::from_str::(&other.to_string()) { + Ok(value) => value, + Err(_) => return false, + }; + + if parsed_version != parsed_other { + return false; + } + } + true + } +} + impl From for Version { fn from(s: String) -> Self { Self::new(s) diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index a52c01bef1..a5a30fce81 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -131,6 +131,8 @@ const CHANNEL_CLOSE_INIT_EVENT: &str = "channel_close_init"; const CHANNEL_CLOSE_CONFIRM_EVENT: &str = "channel_close_confirm"; const CHANNEL_UPGRADE_INIT_EVENT: &str = "channel_upgrade_init"; const CHANNEL_UPGRADE_TRY_EVENT: &str = "channel_upgrade_try"; +const CHANNEL_UPGRADE_ACK_EVENT: &str = "channel_upgrade_ack"; +const CHANNEL_UPGRADE_OPEN_EVENT: &str = "channel_upgrade_open"; /// Packet event types const SEND_PACKET_EVENT: &str = "send_packet"; const RECEIVE_PACKET_EVENT: &str = "receive_packet"; @@ -164,6 +166,8 @@ pub enum IbcEventType { CloseConfirmChannel, UpgradeInitChannel, UpgradeTryChannel, + UpgradeAckChannel, + UpgradeOpenChannel, SendPacket, ReceivePacket, WriteAck, @@ -198,6 +202,8 @@ impl IbcEventType { IbcEventType::CloseConfirmChannel => CHANNEL_CLOSE_CONFIRM_EVENT, IbcEventType::UpgradeInitChannel => CHANNEL_UPGRADE_INIT_EVENT, IbcEventType::UpgradeTryChannel => CHANNEL_UPGRADE_TRY_EVENT, + IbcEventType::UpgradeAckChannel => CHANNEL_UPGRADE_ACK_EVENT, + IbcEventType::UpgradeOpenChannel => CHANNEL_UPGRADE_OPEN_EVENT, IbcEventType::SendPacket => SEND_PACKET_EVENT, IbcEventType::ReceivePacket => RECEIVE_PACKET_EVENT, IbcEventType::WriteAck => WRITE_ACK_EVENT, @@ -236,6 +242,8 @@ impl FromStr for IbcEventType { CHANNEL_CLOSE_CONFIRM_EVENT => Ok(IbcEventType::CloseConfirmChannel), CHANNEL_UPGRADE_INIT_EVENT => Ok(IbcEventType::UpgradeInitChannel), CHANNEL_UPGRADE_TRY_EVENT => Ok(IbcEventType::UpgradeTryChannel), + CHANNEL_UPGRADE_ACK_EVENT => Ok(IbcEventType::UpgradeAckChannel), + CHANNEL_UPGRADE_OPEN_EVENT => Ok(IbcEventType::UpgradeOpenChannel), SEND_PACKET_EVENT => Ok(IbcEventType::SendPacket), RECEIVE_PACKET_EVENT => Ok(IbcEventType::ReceivePacket), WRITE_ACK_EVENT => Ok(IbcEventType::WriteAck), @@ -276,6 +284,8 @@ pub enum IbcEvent { CloseConfirmChannel(ChannelEvents::CloseConfirm), UpgradeInitChannel(ChannelEvents::UpgradeInit), UpgradeTryChannel(ChannelEvents::UpgradeTry), + UpgradeAckChannel(ChannelEvents::UpgradeAck), + UpgradeOpenChannel(ChannelEvents::UpgradeOpen), SendPacket(ChannelEvents::SendPacket), ReceivePacket(ChannelEvents::ReceivePacket), @@ -317,6 +327,8 @@ impl Display for IbcEvent { IbcEvent::CloseConfirmChannel(ev) => write!(f, "CloseConfirmChannel({ev})"), IbcEvent::UpgradeInitChannel(ev) => write!(f, "UpgradeInitChannel({ev})"), IbcEvent::UpgradeTryChannel(ev) => write!(f, "UpgradeTryChannel({ev})"), + IbcEvent::UpgradeAckChannel(ev) => write!(f, "UpgradeAckChannel({ev})"), + IbcEvent::UpgradeOpenChannel(ev) => write!(f, "UpgradeOpenChannel({ev})"), IbcEvent::SendPacket(ev) => write!(f, "SendPacket({ev})"), IbcEvent::ReceivePacket(ev) => write!(f, "ReceivePacket({ev})"), @@ -358,6 +370,8 @@ impl TryFrom for abci::Event { IbcEvent::CloseConfirmChannel(event) => event.into(), IbcEvent::UpgradeInitChannel(event) => event.into(), IbcEvent::UpgradeTryChannel(event) => event.into(), + IbcEvent::UpgradeAckChannel(event) => event.into(), + IbcEvent::UpgradeOpenChannel(event) => event.into(), IbcEvent::SendPacket(event) => event.try_into().map_err(Error::channel)?, IbcEvent::ReceivePacket(event) => event.try_into().map_err(Error::channel)?, IbcEvent::WriteAcknowledgement(event) => event.try_into().map_err(Error::channel)?, @@ -402,6 +416,8 @@ impl IbcEvent { IbcEvent::CloseConfirmChannel(_) => IbcEventType::CloseConfirmChannel, IbcEvent::UpgradeInitChannel(_) => IbcEventType::UpgradeInitChannel, IbcEvent::UpgradeTryChannel(_) => IbcEventType::UpgradeTryChannel, + IbcEvent::UpgradeAckChannel(_) => IbcEventType::UpgradeAckChannel, + IbcEvent::UpgradeOpenChannel(_) => IbcEventType::UpgradeOpenChannel, IbcEvent::SendPacket(_) => IbcEventType::SendPacket, IbcEvent::ReceivePacket(_) => IbcEventType::ReceivePacket, IbcEvent::WriteAcknowledgement(_) => IbcEventType::WriteAck, diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 6ee91d1607..5057feba24 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,6 +1,8 @@ pub use error::ChannelError; use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; use ibc_relayer_types::core::ics04_channel::flush_status::FlushStatus; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_ack::MsgChannelUpgradeAck; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_open::MsgChannelUpgradeOpen; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::upgrade_fields::UpgradeFields; @@ -1735,8 +1737,7 @@ impl Channel { let result = events .into_iter() .find(|event_with_height| { - //matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) - matches!(event_with_height.event, IbcEvent::UpgradeInitChannel(_)) // Current implementation of simapp + matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) || matches!(event_with_height.event, IbcEvent::ChainError(_)) }) .ok_or_else(|| { @@ -1746,9 +1747,216 @@ impl Channel { })?; match &result.event { - //IbcEvent::UpgradeTryChannel(_) => { - IbcEvent::UpgradeInitChannel(_) => { - // Current implementation of simapp + IbcEvent::UpgradeTryChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), + } + } + + pub fn build_chan_upgrade_ack(&self) -> Result, ChannelError> { + // Destination channel ID must exist + + let src_channel_id = self + .src_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let src_port_id = self.src_port_id(); + + let dst_port_id = self.dst_port_id(); + + let src_latest_height = self + .src_chain() + .query_latest_height() + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + let (src_channel_end, _) = self + .src_chain() + .query_channel( + QueryChannelRequest { + port_id: src_port_id.clone(), + channel_id: src_channel_id.clone(), + height: QueryHeight::Specific(src_latest_height), + }, + IncludeProof::Yes, + ) + .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; + + let (upgrade, maybe_upgrade_proof) = self + .src_chain() + .query_upgrade( + QueryUpgradeRequest { + port_id: self.src_port_id().to_string(), + channel_id: src_channel_id.to_string(), + }, + src_latest_height, + ) + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + let upgrade_proof = maybe_upgrade_proof.ok_or(ChannelError::missing_upgrade_proof())?; + + let proof_upgrade = + CommitmentProofBytes::try_from(upgrade_proof).map_err(ChannelError::malformed_proof)?; + + // Building the channel proof at the queried height + let proof = self + .src_chain() + .build_channel_proofs( + &src_port_id.clone(), + &src_channel_id.clone(), + src_latest_height, + ) + .map_err(ChannelError::channel_proof)?; + + let signer = self + .dst_chain() + .get_signer() + .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; + + // Build the domain type message + let new_msg = MsgChannelUpgradeAck { + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + counterparty_flush_status: src_channel_end.flush_status, + counterparty_upgrade: upgrade, + proof_channel: proof.object_proof().clone(), + proof_upgrade, + proof_height: proof.height(), + signer, + }; + + let mut chain_a_msgs = self.build_update_client_on_dst(proof.height())?; + + chain_a_msgs.push(new_msg.to_any()); + + Ok(chain_a_msgs) + } + + pub fn build_chan_upgrade_ack_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_ack()?; + + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeAck"); + + let events = self + .dst_chain() + .send_messages_and_wait_commit(tm) + .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; + + let result = events + .into_iter() + .find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeAckChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no channel upgrade ack event was in the response".to_string(), + ) + })?; + + match &result.event { + IbcEvent::UpgradeAckChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), + } + } + + pub fn build_chan_upgrade_open(&self) -> Result, ChannelError> { + // Destination channel ID must exist + let src_channel_id = self + .src_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let src_port_id = self.src_port_id(); + + let dst_port_id = self.dst_port_id(); + + let src_latest_height = self + .src_chain() + .query_latest_height() + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + let (src_channel_end, _) = self + .src_chain() + .query_channel( + QueryChannelRequest { + port_id: src_port_id.clone(), + channel_id: src_channel_id.clone(), + height: QueryHeight::Specific(src_latest_height), + }, + IncludeProof::Yes, + ) + .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; + + // Building the channel proof at the queried height + let proofs = self + .src_chain() + .build_channel_proofs( + &src_port_id.clone(), + &src_channel_id.clone(), + src_latest_height, + ) + .map_err(ChannelError::channel_proof)?; + + // Build message(s) to update client on destination + let mut msgs = self.build_update_client_on_dst(proofs.height())?; + + let signer = self + .dst_chain() + .get_signer() + .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; + + // Build the domain type message + let new_msg = MsgChannelUpgradeOpen { + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + counterparty_channel_state: src_channel_end.state, + proof_channel: proofs.object_proof().clone(), + proof_height: proofs.height(), + signer, + }; + + msgs.push(new_msg.to_any()); + Ok(msgs) + } + + pub fn build_chan_upgrade_open_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_open()?; + + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeOpen"); + + let events = self + .dst_chain() + .send_messages_and_wait_commit(tm) + .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; + + let result = events + .into_iter() + .find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeOpenChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no channel upgrade ack event was in the response".to_string(), + ) + })?; + + match &result.event { + IbcEvent::UpgradeOpenChannel(_) => { info!("👋 {} => {}", self.dst_chain().id(), result); Ok(result.event) } diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index 4a7101cc59..06a03c78fd 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -5,10 +5,6 @@ use tendermint::abci::Event as AbciEvent; use ibc_relayer_types::{ applications::ics29_fee::events::{DistributeFeePacket, IncentivizedPacket}, applications::ics31_icq::events::CrossChainQueryPacket, - core::ics03_connection::{ - error::Error as ConnectionError, - events::{self as connection_events, Attributes as ConnectionAttributes}, - }, core::ics04_channel::{ error::Error as ChannelError, events::{ @@ -28,6 +24,13 @@ use ibc_relayer_types::{ ics04_channel::{channel::Ordering, packet::Sequence, version::Version}, ics24_host::identifier::ConnectionId, }, + core::{ + ics03_connection::{ + error::Error as ConnectionError, + events::{self as connection_events, Attributes as ConnectionAttributes}, + }, + ics04_channel::flush_status::FlushStatus, + }, events::{Error as IbcEventError, IbcEvent, IbcEventType}, Height, }; @@ -121,6 +124,15 @@ pub fn ibc_event_try_from_abci_event(abci_event: &AbciEvent) -> Result Ok(IbcEvent::UpgradeInitChannel( channel_upgrade_init_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), + Ok(IbcEventType::UpgradeTryChannel) => Ok(IbcEvent::UpgradeTryChannel( + channel_upgrade_try_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, + )), + Ok(IbcEventType::UpgradeAckChannel) => Ok(IbcEvent::UpgradeAckChannel( + channel_upgrade_ack_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, + )), + Ok(IbcEventType::UpgradeOpenChannel) => Ok(IbcEvent::UpgradeOpenChannel( + channel_upgrade_open_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, + )), Ok(IbcEventType::SendPacket) => Ok(IbcEvent::SendPacket( send_packet_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), @@ -272,6 +284,36 @@ pub fn channel_upgrade_init_try_from_abci_event( } } +pub fn channel_upgrade_try_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_upgrade_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeTry::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + +pub fn channel_upgrade_ack_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_upgrade_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeAck::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + +pub fn channel_upgrade_open_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_upgrade_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeOpen::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + pub fn send_packet_try_from_abci_event( abci_event: &AbciEvent, ) -> Result { @@ -460,6 +502,9 @@ fn channel_upgrade_extract_attributes_from_tx( channel_events::UPGRADE_ORDERING => { attr.upgrade_ordering = Ordering::from_str(value)?; } + channel_events::CHANNEL_FLUSH_STATUS => { + attr.channel_flush_status = FlushStatus::from_str(value)?; + } _ => {} } } diff --git a/flake.lock b/flake.lock index 100b3572c1..5f2cce9dd6 100644 --- a/flake.lock +++ b/flake.lock @@ -94,11 +94,11 @@ "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1688365359, - "narHash": "sha256-+wsphHIOmzXo9Xx9awSpU4LEWYyAQYCB2s998XRXeBQ=", + "lastModified": 1689769850, + "narHash": "sha256-aqI4ApbiKuxrXqbXvM8tNS+L+LeoUlFABZqUmgpfDYc=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "31d2178ff2db50f7d874fc6b5a206d75e346d74a", + "rev": "f678276212ccc4b899a8c4c8fd3adebd557446b2", "type": "github" }, "original": { @@ -210,11 +210,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1687709756, - "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "owner": "numtide", "repo": "flake-utils", - "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { @@ -451,17 +451,17 @@ "ibc-go-v7-channel-upgrade-src": { "flake": false, "locked": { - "lastModified": 1688114595, - "narHash": "sha256-jsEHc27nlK8wIBz1d7pgcSMDuDPt6zsXeYwrludF8dY=", + "lastModified": 1689769107, + "narHash": "sha256-BadLMNoREpix9Bko7I9PhdkhIMjCoco8opO7HvWnbBs=", "owner": "cosmos", "repo": "ibc-go", - "rev": "a7793bc10425d6f01e0b00a63520166837990221", + "rev": "82ea9531e24855ef52e2dae629d579583a0e830f", "type": "github" }, "original": { "owner": "cosmos", "repo": "ibc-go", - "rev": "a7793bc10425d6f01e0b00a63520166837990221", + "rev": "82ea9531e24855ef52e2dae629d579583a0e830f", "type": "github" } }, @@ -699,11 +699,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1688221086, - "narHash": "sha256-cdW6qUL71cNWhHCpMPOJjlw0wzSRP0pVlRn2vqX/VVg=", + "lastModified": 1689631193, + "narHash": "sha256-AGSkBZaiTODQc8eT1rZDrQIjtb8JtFwJ0wVPzArlrnM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cd99c2b3c9f160cd004318e0697f90bbd5960825", + "rev": "57695599bdc4f7bfe5d28cfa23f14b3d8bdf8a5f", "type": "github" }, "original": { diff --git a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs index 20e2210d1a..46855c7620 100644 --- a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs +++ b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs @@ -9,7 +9,8 @@ use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; use ibc_relayer_types::core::{ics02_client::height::Height, ics04_channel::version::Version}; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ - assert_eventually_channel_established, assert_eventually_channel_upgrade_init, + assert_eventually_channel_established, assert_eventually_channel_upgrade_ack, + assert_eventually_channel_upgrade_init, assert_eventually_channel_upgrade_open, assert_eventually_channel_upgrade_try, ChannelUpgradableAttributes, }; @@ -21,10 +22,6 @@ fn test_channel_upgrade_manual_handshake() -> Result<(), Error> { pub struct ChannelUpgradeManualHandshake; impl TestOverrides for ChannelUpgradeManualHandshake { - fn modify_test_config(&self, config: &mut TestConfig) { - config.bootstrap_with_random_ids = true; - } - fn should_spawn_supervisor(&self) -> bool { false } @@ -83,9 +80,16 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { let new_ordering = None; let new_connection_hops = None; - let upgrade_attrs = ChannelUpgradableAttributes::new( + let old_attrs = ChannelUpgradableAttributes::new( old_version, old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + old_ordering, old_connection_hops_a, old_connection_hops_b, ); @@ -97,7 +101,7 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { .map_err(|e| eyre!("error creating height for timeout height: {e}"))?; let timeout = UpgradeTimeout::Height(timeout_height); - info!("Set channel in (INITUPGRADE, OPEN) state..."); + info!("Will run ChanUpgradeInit step..."); channel.flipped().build_chan_upgrade_init_and_send( Some(new_version), @@ -113,19 +117,53 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), - &upgrade_attrs, + &old_attrs, )?; - info!("Set channel in (INITUPGRADE, TRYUPGRADE) state..."); + info!("Will run ChanUpgradeTry step..."); channel.build_chan_upgrade_try_and_send(timeout)?; + info!("Check that the step ChanUpgradeTry was correctly executed..."); + assert_eventually_channel_upgrade_try( &chains.handle_b, &chains.handle_a, &channels.channel_id_b.as_ref(), &channels.port_b.as_ref(), - &upgrade_attrs.flipped(), + &old_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + info!("Will run first ChanUpgradeOpen step..."); + + channel.build_chan_upgrade_open_and_send()?; + + info!("Will run second ChanUpgradeOpen step..."); + + channel.flipped().build_chan_upgrade_open_and_send()?; + + info!("Check that the ChanUpgradeOpen steps were correctly executed..."); + + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, )?; Ok(()) diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index 4c005b8bd2..688cf1c0f0 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -321,6 +321,62 @@ pub fn assert_eventually_channel_upgrade_try( + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + upgrade_attrs: &ChannelUpgradableAttributes, +) -> Result, Error> { + assert_eventually_succeed( + "channel upgrade ack step should be done", + 20, + Duration::from_secs(1), + || { + assert_channel_upgrade_state( + ChannelState::AckUpgrade, + ChannelState::TryUpgrade, + FlushStatus::Flushcomplete, + FlushStatus::Flushcomplete, + handle_a, + handle_b, + channel_id_a, + port_id_a, + upgrade_attrs, + ) + }, + ) +} + +pub fn assert_eventually_channel_upgrade_open( + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + upgrade_attrs: &ChannelUpgradableAttributes, +) -> Result, Error> { + assert_eventually_succeed( + "channel upgrade open step should be done", + 20, + Duration::from_secs(1), + || { + assert_channel_upgrade_state( + ChannelState::Open, + ChannelState::Open, + FlushStatus::NotinflushUnspecified, + FlushStatus::NotinflushUnspecified, + handle_a, + handle_b, + channel_id_a, + port_id_a, + upgrade_attrs, + ) + }, + ) +} + +/// Note that the field modified by the channel upgrade are only updated when +/// the channel returns in the OPEN State fn assert_channel_upgrade_state( a_side_state: ChannelState, b_side_state: ChannelState, From 749d7db4354c4371e2c4e98bc23d8070a3c5ebab Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:55:55 +0200 Subject: [PATCH 69/99] Add missing CLIs for channel upgrade (#3495) * Add missing CLIs for channel upgrade * Update CLI template * Add cargo patch for check-guide test * Add documentation TODO to check-guide Cargo.toml * Set dst-channel flag to required for channel upgrade CLIs and updated templates * Clean channel upgrade CLIs * Update guide templates --- crates/relayer-cli/src/commands/tx.rs | 6 + crates/relayer-cli/src/commands/tx/channel.rs | 406 +++++++++++++++++- .../src/core/ics04_channel/timeout.rs | 20 +- .../commands/hermes/tx/chan-upgrade-ack_1.md | 1 + .../commands/hermes/tx/chan-upgrade-open_1.md | 1 + .../commands/hermes/tx/chan-upgrade-try_1.md | 2 +- guide/src/templates/help_templates/tx.md | 2 + .../help_templates/tx/chan-upgrade-ack.md | 30 ++ .../help_templates/tx/chan-upgrade-init.md | 7 +- .../help_templates/tx/chan-upgrade-open.md | 30 ++ .../help_templates/tx/chan-upgrade-try.md | 17 +- tools/check-guide/Cargo.lock | 4 +- tools/check-guide/Cargo.toml | 4 + 13 files changed, 492 insertions(+), 38 deletions(-) create mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md create mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md create mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-ack.md create mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-open.md diff --git a/crates/relayer-cli/src/commands/tx.rs b/crates/relayer-cli/src/commands/tx.rs index 6d65e6f976..814f1e4670 100644 --- a/crates/relayer-cli/src/commands/tx.rs +++ b/crates/relayer-cli/src/commands/tx.rs @@ -50,6 +50,12 @@ pub enum TxCmd { /// Relay the channel upgrade attempt (ChannelUpgradeTry) ChanUpgradeTry(channel::TxChanUpgradeTryCmd), + /// Relay the channel upgrade attempt (ChannelUpgradeAck) + ChanUpgradeAck(channel::TxChanUpgradeAckCmd), + + /// Relay the channel upgrade attempt (ChannelUpgradeOpen) + ChanUpgradeOpen(channel::TxChanUpgradeOpenCmd), + /// Send a fungible token transfer test transaction (ICS20 MsgTransfer) FtTransfer(transfer::TxIcs20MsgTransferCmd), diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index e54bc7ffd9..3133d03062 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -1,5 +1,7 @@ use abscissa_core::clap::Parser; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; +use abscissa_core::Runnable; +use humantime::Duration as HumanDuration; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryConnectionRequest, QueryHeight}; @@ -13,7 +15,6 @@ use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; use ibc_relayer_types::events::IbcEvent; -use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::Height; use crate::cli_utils::ChainHandlePair; @@ -739,31 +740,40 @@ pub struct TxChanUpgradeInitCmd { timeout_height: Option, #[clap( - long = "timeout-timestamp", + long = "timeout-time", required = false, - value_name = "TIMEOUT_TIMESTAMP", - help = "Timestamp that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout height is specified." + value_name = "TIMEOUT_TIME", + help = "Timeout in human readable format since current that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout height is specified." )] - timeout_timestamp: Option, + timeout_time: Option, } impl Runnable for TxChanUpgradeInitCmd { fn run(&self) { let config = app_config(); + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { + Ok(chains) => chains, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + let dst_chain_status = match chains.dst.query_application_status() { + Ok(application_status) => application_status, + Err(e) => Output::error(format!("query_application_status error {}", e)).exit(), + }; + + let timeout_timestamp = self + .timeout_time + .map(|timeout_time| (dst_chain_status.timestamp + *timeout_time).unwrap()); + // Check that at least one of timeout_height and timeout_timestamp has been provided - let Ok(timeout) = UpgradeTimeout::new(self.timeout_height, self.timeout_timestamp) else { + let Ok(timeout) = UpgradeTimeout::new(self.timeout_height, timeout_timestamp) else { Output::error( "At least one of --timeout-height or --timeout-timestamp must be specified.", ) .exit(); }; - let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { - Ok(chains) => chains, - Err(e) => Output::error(format!("{}", e)).exit(), - }; - // Fetch the Channel that will facilitate the communication between the channel ends // being upgraded. This channel is assumed to already exist on the destination chain. let channel = Channel { @@ -808,9 +818,9 @@ impl Runnable for TxChanUpgradeInitCmd { /// Relay the channel upgrade attempt (ChannelUpgradeTry) /// /// Build and send a `ChannelUpgradeTry` message in response to -/// a `ChannelUpgradeInnit` message, signaling the chain's intent to +/// a `ChannelUpgradeInit` message, signaling the chain's intent to /// cooperate with the source chain on upgrading the specified channel -/// and initiating the upgrade handshake. +/// and initiating the upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] pub struct TxChanUpgradeTryCmd { #[clap( @@ -872,31 +882,385 @@ pub struct TxChanUpgradeTryCmd { #[clap( long = "dst-channel", visible_alias = "dst-chan", + required = true, + help_heading = "REQUIRED", value_name = "DST_CHANNEL_ID", help = "Identifier of the destination channel (optional)" )] dst_chan_id: Option, + + #[clap( + long = "timeout-height", + required = false, + value_name = "TIMEOUT_HEIGHT", + help = "Height that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout timestamp is specified." + )] + timeout_height: Option, + + #[clap( + long = "timeout-time", + required = false, + value_name = "TIMEOUT_TIME", + help = "Timeout in human readable format since current that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout height is specified." + )] + timeout_time: Option, } impl Runnable for TxChanUpgradeTryCmd { - fn run(&self) {} + fn run(&self) { + let config = app_config(); + + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { + Ok(chains) => chains, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + let dst_chain_status = match chains.dst.query_application_status() { + Ok(application_status) => application_status, + Err(e) => Output::error(format!("query_application_status error {}", e)).exit(), + }; + + let timeout_timestamp = self + .timeout_time + .map(|timeout_time| (dst_chain_status.timestamp + *timeout_time).unwrap()); + + // Check that at least one of timeout_height and timeout_timestamp has been provided + let Ok(timeout) = UpgradeTimeout::new(self.timeout_height, timeout_timestamp) else { + Output::error( + "At least one of --timeout-height or --timeout-timestamp must be specified.", + ) + .exit(); + }; + + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { + Ok(chains) => chains, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Retrieve the connection + let dst_connection = match chains.dst.query_connection( + QueryConnectionRequest { + connection_id: self.dst_conn_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) { + Ok((connection, _)) => connection, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Fetch the Channel that will facilitate the communication between the channel ends + // being upgraded. This channel is assumed to already exist on the destination chain. + let channel = Channel { + connection_delay: Default::default(), + ordering: Ordering::default(), + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + Some(self.src_chan_id.clone()), + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + self.dst_chan_id.clone(), + None, + ), + }; + + info!("message ChanUpgradeTry: {}", channel); + + let res: Result = channel + .build_chan_upgrade_try_and_send(timeout) + .map_err(Error::channel); + + match res { + Ok(receipt) => Output::success(receipt).exit(), + Err(e) => Output::error(e).exit(), + } + } +} + +/// Relay the channel upgrade attempt (ChannelUpgradeAck) +/// +/// Build and send a `ChannelUpgradeAck` message in response to +/// a `ChannelUpgradeTry` message in order to continue the channel +/// upgrade handshake. +#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] +pub struct TxChanUpgradeAckCmd { + #[clap( + long = "dst-chain", + required = true, + value_name = "DST_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination chain" + )] + dst_chain_id: ChainId, + + #[clap( + long = "src-chain", + required = true, + value_name = "SRC_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the source chain" + )] + src_chain_id: ChainId, + + #[clap( + long = "dst-connection", + visible_alias = "dst-conn", + required = true, + value_name = "DST_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection" + )] + dst_conn_id: ConnectionId, + + #[clap( + long = "dst-port", + required = true, + value_name = "DST_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination port" + )] + dst_port_id: PortId, + + #[clap( + long = "src-port", + required = true, + value_name = "SRC_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the source port" + )] + src_port_id: PortId, + + #[clap( + long = "src-channel", + visible_alias = "src-chan", + required = true, + value_name = "SRC_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" + )] + src_chan_id: ChannelId, + + #[clap( + long = "dst-channel", + visible_alias = "dst-chan", + required = true, + help_heading = "REQUIRED", + value_name = "DST_CHANNEL_ID", + help = "Identifier of the destination channel (optional)" + )] + dst_chan_id: Option, +} + +impl Runnable for TxChanUpgradeAckCmd { + fn run(&self) { + let config = app_config(); + + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { + Ok(chains) => chains, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Retrieve the connection + let dst_connection = match chains.dst.query_connection( + QueryConnectionRequest { + connection_id: self.dst_conn_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) { + Ok((connection, _)) => connection, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Fetch the Channel that will facilitate the communication between the channel ends + // being upgraded. This channel is assumed to already exist on the destination chain. + let channel = Channel { + connection_delay: Default::default(), + ordering: Ordering::default(), + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + Some(self.src_chan_id.clone()), + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + self.dst_chan_id.clone(), + None, + ), + }; + + info!("message ChanUpgradeAck: {}", channel); + + let res: Result = channel + .build_chan_upgrade_ack_and_send() + .map_err(Error::channel); + + match res { + Ok(receipt) => Output::success(receipt).exit(), + Err(e) => Output::error(e).exit(), + } + } +} + +/// Relay the channel upgrade attempt (ChannelUpgradeOpen) +/// +/// Build and send a `ChannelUpgradeOpen` message to finalize +/// the channel upgrade handshake. +#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] +pub struct TxChanUpgradeOpenCmd { + #[clap( + long = "dst-chain", + required = true, + value_name = "DST_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination chain" + )] + dst_chain_id: ChainId, + + #[clap( + long = "src-chain", + required = true, + value_name = "SRC_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the source chain" + )] + src_chain_id: ChainId, + + #[clap( + long = "dst-connection", + visible_alias = "dst-conn", + required = true, + value_name = "DST_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection" + )] + dst_conn_id: ConnectionId, + + #[clap( + long = "dst-port", + required = true, + value_name = "DST_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination port" + )] + dst_port_id: PortId, + + #[clap( + long = "src-port", + required = true, + value_name = "SRC_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the source port" + )] + src_port_id: PortId, + + #[clap( + long = "src-channel", + visible_alias = "src-chan", + required = true, + value_name = "SRC_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" + )] + src_chan_id: ChannelId, + + #[clap( + long = "dst-channel", + visible_alias = "dst-chan", + required = true, + help_heading = "REQUIRED", + value_name = "DST_CHANNEL_ID", + help = "Identifier of the destination channel (optional)" + )] + dst_chan_id: Option, +} + +impl Runnable for TxChanUpgradeOpenCmd { + fn run(&self) { + let config = app_config(); + + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { + Ok(chains) => chains, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Retrieve the connection + let dst_connection = match chains.dst.query_connection( + QueryConnectionRequest { + connection_id: self.dst_conn_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) { + Ok((connection, _)) => connection, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Fetch the Channel that will facilitate the communication between the channel ends + // being upgraded. This channel is assumed to already exist on the destination chain. + let channel = Channel { + connection_delay: Default::default(), + ordering: Ordering::default(), + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + Some(self.src_chan_id.clone()), + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + self.dst_chan_id.clone(), + None, + ), + }; + + info!("message ChanUpgradeOpen: {}", channel); + + let res: Result = channel + .build_chan_upgrade_open_and_send() + .map_err(Error::channel); + + match res { + Ok(receipt) => Output::success(receipt).exit(), + Err(e) => Output::error(e).exit(), + } + } } #[cfg(test)] mod tests { - use super::{ - TxChanCloseConfirmCmd, TxChanCloseInitCmd, TxChanOpenAckCmd, TxChanOpenConfirmCmd, - TxChanOpenInitCmd, TxChanOpenTryCmd, - }; - + use abscissa_core::clap::Parser; use std::str::FromStr; - use abscissa_core::clap::Parser; use ibc_relayer_types::core::{ ics04_channel::channel::Ordering, ics24_host::identifier::{ChainId, ChannelId, ConnectionId, PortId}, }; + use crate::commands::tx::channel::{ + TxChanCloseConfirmCmd, TxChanCloseInitCmd, TxChanOpenAckCmd, TxChanOpenConfirmCmd, + TxChanOpenInitCmd, TxChanOpenTryCmd, + }; + #[test] fn test_chan_open_init_required_only() { assert_eq!( diff --git a/crates/relayer-types/src/core/ics04_channel/timeout.rs b/crates/relayer-types/src/core/ics04_channel/timeout.rs index 29d83551c8..2b95da0535 100644 --- a/crates/relayer-types/src/core/ics04_channel/timeout.rs +++ b/crates/relayer-types/src/core/ics04_channel/timeout.rs @@ -229,17 +229,25 @@ impl TryFrom for UpgradeTimeout { type Error = ChannelError; fn try_from(value: RawUpgradeTimeout) -> Result { - let timeout_height = value - .height - .map(Height::try_from) - .transpose() - .map_err(|_| Self::Error::invalid_timeout_height())?; + let raw_timeout_height = value.height.map(Height::try_from).transpose(); - let timeout_timestamp = Timestamp::from_nanoseconds(value.timestamp) + let raw_timeout_timestamp = Timestamp::from_nanoseconds(value.timestamp) .map_err(|_| Self::Error::invalid_timeout_timestamp) .ok() .filter(|ts| ts.nanoseconds() > 0); + let (timeout_height, timeout_timestamp) = match (raw_timeout_height, raw_timeout_timestamp) + { + (Ok(timeout_height), Some(timeout_timestamp)) => { + (timeout_height, Some(timeout_timestamp)) + } + (Ok(timeout_height), None) => (timeout_height, None), + (Err(_), Some(timeout_timestamp)) => (None, Some(timeout_timestamp)), + (Err(e), None) => { + return Err(e).map_err(|_| Self::Error::invalid_timeout_height()); + } + }; + Self::new(timeout_height, timeout_timestamp) } } diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md new file mode 100644 index 0000000000..3143b03d70 --- /dev/null +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md @@ -0,0 +1 @@ +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-ack --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md new file mode 100644 index 0000000000..e7c3a0c000 --- /dev/null +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md @@ -0,0 +1 @@ +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-open --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md index 6dd8adecaa..e33ec14407 100644 --- a/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md @@ -1 +1 @@ -[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-try[[#OPTIONS]] --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] \ No newline at end of file +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-try[[#OPTIONS]] --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/help_templates/tx.md b/guide/src/templates/help_templates/tx.md index f968b2655d..95e55b08aa 100644 --- a/guide/src/templates/help_templates/tx.md +++ b/guide/src/templates/help_templates/tx.md @@ -14,7 +14,9 @@ SUBCOMMANDS: chan-open-confirm Confirm opening of a channel (ChannelOpenConfirm) chan-open-init Initialize a channel (ChannelOpenInit) chan-open-try Relay the channel attempt (ChannelOpenTry) + chan-upgrade-ack Relay the channel upgrade attempt (ChannelUpgradeAck) chan-upgrade-init Initiate a channel upgrade (ChannelUpgradeInit) + chan-upgrade-open Relay the channel upgrade attempt (ChannelUpgradeOpen) chan-upgrade-try Relay the channel upgrade attempt (ChannelUpgradeTry) conn-ack Relay acknowledgment of a connection attempt (ConnectionOpenAck) conn-confirm Confirm opening of a connection (ConnectionOpenConfirm) diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-ack.md b/guide/src/templates/help_templates/tx/chan-upgrade-ack.md new file mode 100644 index 0000000000..6c30bfa913 --- /dev/null +++ b/guide/src/templates/help_templates/tx/chan-upgrade-ack.md @@ -0,0 +1,30 @@ +DESCRIPTION: +Relay the channel upgrade attempt (ChannelUpgradeAck) + +USAGE: + hermes tx chan-upgrade-ack --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel + +OPTIONS: + -h, --help Print help information + +REQUIRED: + --dst-chain + Identifier of the destination chain + + --dst-channel + Identifier of the destination channel (optional) [aliases: dst-chan] + + --dst-connection + Identifier of the destination connection [aliases: dst-conn] + + --dst-port + Identifier of the destination port + + --src-chain + Identifier of the source chain + + --src-channel + Identifier of the source channel (required) [aliases: src-chan] + + --src-port + Identifier of the source port diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-init.md b/guide/src/templates/help_templates/tx/chan-upgrade-init.md index bdeccaeb29..f0d217bb3b 100644 --- a/guide/src/templates/help_templates/tx/chan-upgrade-init.md +++ b/guide/src/templates/help_templates/tx/chan-upgrade-init.md @@ -21,9 +21,10 @@ OPTIONS: Height that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout timestamp is specified. - --timeout-timestamp - Timestamp that, once it has been surpassed on the originating chain, the upgrade will - time out. Required if no timeout height is specified. + --timeout-time + Timeout in human readable format since current that, once it has been surpassed on the + originating chain, the upgrade will time out. Required if no timeout height is + specified. --version Version of the channel that both chains will upgrade to. Defaults to the version of the diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-open.md b/guide/src/templates/help_templates/tx/chan-upgrade-open.md new file mode 100644 index 0000000000..fb878cd41d --- /dev/null +++ b/guide/src/templates/help_templates/tx/chan-upgrade-open.md @@ -0,0 +1,30 @@ +DESCRIPTION: +Relay the channel upgrade attempt (ChannelUpgradeOpen) + +USAGE: + hermes tx chan-upgrade-open --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel + +OPTIONS: + -h, --help Print help information + +REQUIRED: + --dst-chain + Identifier of the destination chain + + --dst-channel + Identifier of the destination channel (optional) [aliases: dst-chan] + + --dst-connection + Identifier of the destination connection [aliases: dst-conn] + + --dst-port + Identifier of the destination port + + --src-chain + Identifier of the source chain + + --src-channel + Identifier of the source channel (required) [aliases: src-chan] + + --src-port + Identifier of the source port diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-try.md b/guide/src/templates/help_templates/tx/chan-upgrade-try.md index 750d567599..c711c208de 100644 --- a/guide/src/templates/help_templates/tx/chan-upgrade-try.md +++ b/guide/src/templates/help_templates/tx/chan-upgrade-try.md @@ -2,19 +2,28 @@ DESCRIPTION: Relay the channel upgrade attempt (ChannelUpgradeTry) USAGE: - hermes tx chan-upgrade-try [OPTIONS] --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel + hermes tx chan-upgrade-try [OPTIONS] --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel OPTIONS: - --dst-channel - Identifier of the destination channel (optional) [aliases: dst-chan] - -h, --help Print help information + --timeout-height + Height that, once it has been surpassed on the originating chain, the upgrade will time + out. Required if no timeout timestamp is specified. + + --timeout-time + Timeout in human readable format since current that, once it has been surpassed on the + originating chain, the upgrade will time out. Required if no timeout height is + specified. + REQUIRED: --dst-chain Identifier of the destination chain + --dst-channel + Identifier of the destination channel (optional) [aliases: dst-chan] + --dst-connection Identifier of the destination connection [aliases: dst-conn] diff --git a/tools/check-guide/Cargo.lock b/tools/check-guide/Cargo.lock index 4dfc564388..e6128cb533 100644 --- a/tools/check-guide/Cargo.lock +++ b/tools/check-guide/Cargo.lock @@ -1735,8 +1735,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c888103095b45bee90cb9104513ade30abd69902153b0682b5ad81940ae1f865" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#9e0ecb6f3c4b736e3ff95e1518f19deeead1a675" dependencies = [ "base64 0.21.2", "bytes", @@ -1815,7 +1814,6 @@ name = "ibc-relayer-cli" version = "1.6.0" dependencies = [ "abscissa_core", - "atty", "clap 3.2.25", "clap_complete 3.2.5", "color-eyre", diff --git a/tools/check-guide/Cargo.toml b/tools/check-guide/Cargo.toml index 59b5956262..2281be90da 100644 --- a/tools/check-guide/Cargo.toml +++ b/tools/check-guide/Cargo.toml @@ -13,3 +13,7 @@ lazy_static = "1.4.0" mdbook-template = "1.1.0" regex = "1" walkdir = "2.3.3" + +# TODO remove once simapp v8 is released +[patch.crates-io] +ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "romac/channel-upgrade-only" } \ No newline at end of file From 7925add36e474d87d1fe52c69cd65ce9029e6b16 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 24 Aug 2023 13:49:46 +0200 Subject: [PATCH 70/99] Update channel upgrade after spec rework --- Cargo.lock | 12 +- crates/relayer-cli/src/commands/tx.rs | 3 + crates/relayer-cli/src/commands/tx/channel.rs | 206 +++++++++----- crates/relayer-types/Cargo.toml | 1 + .../src/core/ics04_channel/channel.rs | 41 ++- .../src/core/ics04_channel/events.rs | 105 +++++++ .../src/core/ics04_channel/msgs.rs | 1 + .../ics04_channel/msgs/chan_upgrade_ack.rs | 9 - .../msgs/chan_upgrade_confirm.rs | 256 ++++++++++++++++++ .../ics04_channel/msgs/chan_upgrade_init.rs | 26 -- .../ics04_channel/msgs/chan_upgrade_try.rs | 41 +-- .../src/core/ics04_channel/upgrade.rs | 10 +- crates/relayer-types/src/events.rs | 8 + crates/relayer/src/channel.rs | 208 ++++++++------ crates/relayer/src/channel/error.rs | 3 +- crates/relayer/src/event.rs | 14 + .../hermes/tx/chan-upgrade-confirm_1.md | 1 + .../commands/hermes/tx/chan-upgrade-try_1.md | 2 +- guide/src/templates/help_templates/tx.md | 39 +-- .../help_templates/tx/chan-upgrade-confirm.md | 30 ++ .../help_templates/tx/chan-upgrade-init.md | 9 - .../help_templates/tx/chan-upgrade-try.md | 14 +- scripts/auto_gen_templates.sh | 2 +- .../channel_upgrade/manual_channel_upgrade.rs | 44 +-- .../test-framework/src/chain/cli/bootstrap.rs | 4 +- tools/test-framework/src/relayer/channel.rs | 71 +++-- 26 files changed, 840 insertions(+), 320 deletions(-) create mode 100644 crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs create mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md create mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-confirm.md mode change 100644 => 100755 scripts/auto_gen_templates.sh diff --git a/Cargo.lock b/Cargo.lock index 2bbbb68610..33c6ffe5c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -865,9 +865,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if 1.0.0", ] @@ -1448,8 +1448,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59d0bc49ee5fc8e5d0e668765d470cb201fd0cdee4166f49c6cbcf3100466137" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#a3cad9102eeae2d356054b2a5c55298213f9405d" dependencies = [ "base64 0.21.2", "bytes", @@ -4332,8 +4331,3 @@ dependencies = [ "quote", "syn 2.0.29", ] - -[[patch.unused]] -name = "ibc-proto" -version = "0.32.0" -source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#b3d0320ead537ed528bb76b45fe49b8e4ca00c75" diff --git a/crates/relayer-cli/src/commands/tx.rs b/crates/relayer-cli/src/commands/tx.rs index 814f1e4670..ed10e3ff9c 100644 --- a/crates/relayer-cli/src/commands/tx.rs +++ b/crates/relayer-cli/src/commands/tx.rs @@ -53,6 +53,9 @@ pub enum TxCmd { /// Relay the channel upgrade attempt (ChannelUpgradeAck) ChanUpgradeAck(channel::TxChanUpgradeAckCmd), + /// Relay the channel upgrade attempt (ChannelUpgradeConfirm) + ChanUpgradeConfirm(channel::TxChanUpgradeConfirmCmd), + /// Relay the channel upgrade attempt (ChannelUpgradeOpen) ChanUpgradeOpen(channel::TxChanUpgradeOpenCmd), diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 3133d03062..2acabb5701 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -1,7 +1,6 @@ use abscissa_core::clap::Parser; use abscissa_core::Command; use abscissa_core::Runnable; -use humantime::Duration as HumanDuration; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryConnectionRequest, QueryHeight}; @@ -9,13 +8,11 @@ use ibc_relayer::channel::{Channel, ChannelSide}; use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd; use ibc_relayer_types::core::ics04_channel::channel::Ordering; -use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; use ibc_relayer_types::events::IbcEvent; -use ibc_relayer_types::Height; use crate::cli_utils::ChainHandlePair; use crate::conclude::Output; @@ -730,22 +727,6 @@ pub struct TxChanUpgradeInitCmd { help = "Set of connection hops for the channel that both chains will upgrade to. Defaults to the connection hops of the initiating chain if not specified." )] connection_hops: Option>, - - #[clap( - long = "timeout-height", - required = false, - value_name = "TIMEOUT_HEIGHT", - help = "Height that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout timestamp is specified." - )] - timeout_height: Option, - - #[clap( - long = "timeout-time", - required = false, - value_name = "TIMEOUT_TIME", - help = "Timeout in human readable format since current that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout height is specified." - )] - timeout_time: Option, } impl Runnable for TxChanUpgradeInitCmd { @@ -757,23 +738,6 @@ impl Runnable for TxChanUpgradeInitCmd { Err(e) => Output::error(format!("{}", e)).exit(), }; - let dst_chain_status = match chains.dst.query_application_status() { - Ok(application_status) => application_status, - Err(e) => Output::error(format!("query_application_status error {}", e)).exit(), - }; - - let timeout_timestamp = self - .timeout_time - .map(|timeout_time| (dst_chain_status.timestamp + *timeout_time).unwrap()); - - // Check that at least one of timeout_height and timeout_timestamp has been provided - let Ok(timeout) = UpgradeTimeout::new(self.timeout_height, timeout_timestamp) else { - Output::error( - "At least one of --timeout-height or --timeout-timestamp must be specified.", - ) - .exit(); - }; - // Fetch the Channel that will facilitate the communication between the channel ends // being upgraded. This channel is assumed to already exist on the destination chain. let channel = Channel { @@ -804,7 +768,6 @@ impl Runnable for TxChanUpgradeInitCmd { self.version.clone(), self.ordering, self.connection_hops.clone(), - timeout, ) .map_err(Error::channel); @@ -888,22 +851,6 @@ pub struct TxChanUpgradeTryCmd { help = "Identifier of the destination channel (optional)" )] dst_chan_id: Option, - - #[clap( - long = "timeout-height", - required = false, - value_name = "TIMEOUT_HEIGHT", - help = "Height that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout timestamp is specified." - )] - timeout_height: Option, - - #[clap( - long = "timeout-time", - required = false, - value_name = "TIMEOUT_TIME", - help = "Timeout in human readable format since current that, once it has been surpassed on the originating chain, the upgrade will time out. Required if no timeout height is specified." - )] - timeout_time: Option, } impl Runnable for TxChanUpgradeTryCmd { @@ -915,23 +862,132 @@ impl Runnable for TxChanUpgradeTryCmd { Err(e) => Output::error(format!("{}", e)).exit(), }; - let dst_chain_status = match chains.dst.query_application_status() { - Ok(application_status) => application_status, - Err(e) => Output::error(format!("query_application_status error {}", e)).exit(), + // Retrieve the connection + let dst_connection = match chains.dst.query_connection( + QueryConnectionRequest { + connection_id: self.dst_conn_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) { + Ok((connection, _)) => connection, + Err(e) => Output::error(format!("{}", e)).exit(), }; - let timeout_timestamp = self - .timeout_time - .map(|timeout_time| (dst_chain_status.timestamp + *timeout_time).unwrap()); - - // Check that at least one of timeout_height and timeout_timestamp has been provided - let Ok(timeout) = UpgradeTimeout::new(self.timeout_height, timeout_timestamp) else { - Output::error( - "At least one of --timeout-height or --timeout-timestamp must be specified.", - ) - .exit(); + // Fetch the Channel that will facilitate the communication between the channel ends + // being upgraded. This channel is assumed to already exist on the destination chain. + let channel = Channel { + connection_delay: Default::default(), + ordering: Ordering::default(), + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + Some(self.src_chan_id.clone()), + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + self.dst_chan_id.clone(), + None, + ), }; + info!("message ChanUpgradeTry: {}", channel); + + let res: Result = channel + .build_chan_upgrade_try_and_send() + .map_err(Error::channel); + + match res { + Ok(receipt) => Output::success(receipt).exit(), + Err(e) => Output::error(e).exit(), + } + } +} + +/// Relay the channel upgrade attempt (ChannelUpgradeAck) +/// +/// Build and send a `ChannelUpgradeAck` message in response to +/// a `ChannelUpgradeTry` message in order to continue the channel +/// upgrade handshake. +#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] +pub struct TxChanUpgradeAckCmd { + #[clap( + long = "dst-chain", + required = true, + value_name = "DST_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination chain" + )] + dst_chain_id: ChainId, + + #[clap( + long = "src-chain", + required = true, + value_name = "SRC_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the source chain" + )] + src_chain_id: ChainId, + + #[clap( + long = "dst-connection", + visible_alias = "dst-conn", + required = true, + value_name = "DST_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection" + )] + dst_conn_id: ConnectionId, + + #[clap( + long = "dst-port", + required = true, + value_name = "DST_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination port" + )] + dst_port_id: PortId, + + #[clap( + long = "src-port", + required = true, + value_name = "SRC_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the source port" + )] + src_port_id: PortId, + + #[clap( + long = "src-channel", + visible_alias = "src-chan", + required = true, + value_name = "SRC_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" + )] + src_chan_id: ChannelId, + + #[clap( + long = "dst-channel", + visible_alias = "dst-chan", + required = true, + help_heading = "REQUIRED", + value_name = "DST_CHANNEL_ID", + help = "Identifier of the destination channel (optional)" + )] + dst_chan_id: Option, +} + +impl Runnable for TxChanUpgradeAckCmd { + fn run(&self) { + let config = app_config(); + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { Ok(chains) => chains, Err(e) => Output::error(format!("{}", e)).exit(), @@ -972,10 +1028,10 @@ impl Runnable for TxChanUpgradeTryCmd { ), }; - info!("message ChanUpgradeTry: {}", channel); + info!("message ChanUpgradeAck: {}", channel); let res: Result = channel - .build_chan_upgrade_try_and_send(timeout) + .build_chan_upgrade_ack_and_send() .map_err(Error::channel); match res { @@ -985,13 +1041,13 @@ impl Runnable for TxChanUpgradeTryCmd { } } -/// Relay the channel upgrade attempt (ChannelUpgradeAck) +/// Relay the channel upgrade attempt (ChannelUpgradeConfirm) /// -/// Build and send a `ChannelUpgradeAck` message in response to -/// a `ChannelUpgradeTry` message in order to continue the channel +/// Build and send a `ChannelUpgradeConfirm` message in response to +/// a `ChannelUpgradeAck` message in order to continue the channel /// upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] -pub struct TxChanUpgradeAckCmd { +pub struct TxChanUpgradeConfirmCmd { #[clap( long = "dst-chain", required = true, @@ -1059,7 +1115,7 @@ pub struct TxChanUpgradeAckCmd { dst_chan_id: Option, } -impl Runnable for TxChanUpgradeAckCmd { +impl Runnable for TxChanUpgradeConfirmCmd { fn run(&self) { let config = app_config(); @@ -1103,10 +1159,10 @@ impl Runnable for TxChanUpgradeAckCmd { ), }; - info!("message ChanUpgradeAck: {}", channel); + info!("message ChanUpgradeConfirm: {}", channel); let res: Result = channel - .build_chan_upgrade_ack_and_send() + .build_chan_upgrade_confirm_and_send() .map_err(Error::channel); match res { diff --git a/crates/relayer-types/Cargo.toml b/crates/relayer-types/Cargo.toml index e890969979..f195bee54c 100644 --- a/crates/relayer-types/Cargo.toml +++ b/crates/relayer-types/Cargo.toml @@ -42,6 +42,7 @@ primitive-types = { version = "0.12.1", default-features = false, features = ["s dyn-clone = "1.0.12" num-rational = "0.4.1" regex = "1" +tracing = "0.1.36" [dependencies.tendermint] version = "0.33.0" diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index cbf14e9e34..2cc4705398 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -418,19 +418,23 @@ pub enum State { /// A channel has been closed and can no longer be used to send or receive /// packets. Closed = 4, + /// A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. + Flushing = 5, + /// A channel has just completed flushing any in-flight packets. + Flushcomplete = 6, /// A channel has just started the upgrade handshake. The chain that is /// proposing the upgrade should set the channel state from OPEN to INITUPGRADE. - InitUpgrade = 5, + InitUpgrade = 7, /// A channel has acknowledged the upgrade handshake step on the counterparty chain. /// The counterparty chain that accepts the upgrade should set the channel state from /// OPEN to TRYUPGRADE. /// The counterparty chain blocks new packets until the channel upgrade is done or cancelled. - TryUpgrade = 6, + TryUpgrade = 8, /// A channel has confirmed the upgrade handshake step on the counterparty chain. /// The chain that confirmed the upgrade should set the channel state from /// INITUPGRADE to ACKUPGRADE. /// The chain blocks new packets until the channel upgrade is done or cancelled. - AckUpgrade = 7, + AckUpgrade = 9, } impl State { @@ -442,6 +446,8 @@ impl State { Self::TryOpen => "TRYOPEN", Self::Open => "OPEN", Self::Closed => "CLOSED", + Self::Flushing => "FLUSHING", + Self::Flushcomplete => "FLUSHCOMPLETE", Self::InitUpgrade => "INITUPGRADE", Self::TryUpgrade => "TRYUPGRADE", Self::AckUpgrade => "ACKUPGRADE", @@ -456,9 +462,11 @@ impl State { 2 => Ok(Self::TryOpen), 3 => Ok(Self::Open), 4 => Ok(Self::Closed), - 5 => Ok(Self::InitUpgrade), - 6 => Ok(Self::TryUpgrade), - 7 => Ok(Self::AckUpgrade), + 5 => Ok(Self::Flushing), + 6 => Ok(Self::Flushcomplete), + 7 => Ok(Self::InitUpgrade), + 8 => Ok(Self::TryUpgrade), + 9 => Ok(Self::AckUpgrade), _ => Err(Error::unknown_state(s)), } } @@ -492,11 +500,26 @@ impl State { TryOpen => !matches!(other, Uninitialized | Init), Open => !matches!(other, Uninitialized | Init | TryOpen), - InitUpgrade => !matches!(other, Uninitialized | Init | TryOpen | Open), - TryUpgrade => !matches!(other, Uninitialized | Init | TryOpen | Open | InitUpgrade), + Flushing => !matches!(other, Uninitialized | Init | TryOpen | Open), + Flushcomplete => !matches!(other, Uninitialized | Init | TryOpen | Open | Flushing), + InitUpgrade => !matches!( + other, + Uninitialized | Init | TryOpen | Open | Flushing | Flushcomplete + ), + TryUpgrade => !matches!( + other, + Uninitialized | Init | TryOpen | Open | Flushing | Flushcomplete | InitUpgrade + ), AckUpgrade => !matches!( other, - Uninitialized | Init | TryOpen | Open | InitUpgrade | TryUpgrade + Uninitialized + | Init + | TryOpen + | Open + | Flushing + | Flushcomplete + | InitUpgrade + | TryUpgrade ), Closed => false, diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index 42eca22569..e231089d49 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -878,6 +878,111 @@ impl EventType for UpgradeAck { } } +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeConfirm { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, + pub channel_flush_status: FlushStatus, +} + +impl Display for UpgradeConfirm { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + ) + } +} + +impl From for UpgradeAttributes { + fn from(ev: UpgradeConfirm) -> Self { + Self { + port_id: ev.port_id, + channel_id: ev.channel_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: ev.counterparty_channel_id, + upgrade_connection_hops: ev.upgrade_connection_hops, + upgrade_version: ev.upgrade_version, + upgrade_sequence: ev.upgrade_sequence, + upgrade_ordering: ev.upgrade_ordering, + channel_flush_status: ev.channel_flush_status, + } + } +} + +impl From for abci::Event { + fn from(value: UpgradeConfirm) -> Self { + let kind = UpgradeConfirm::event_type().as_str().to_owned(); + Self { + kind, + attributes: UpgradeAttributes::from(value).into(), + } + } +} + +impl UpgradeConfirm { + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeConfirm { + type Error = EventError; + + fn try_from(attrs: UpgradeAttributes) -> Result { + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_connection_hops: attrs.upgrade_connection_hops, + upgrade_version: attrs.upgrade_version, + upgrade_sequence: attrs.upgrade_sequence, + upgrade_ordering: attrs.upgrade_ordering, + channel_flush_status: attrs.channel_flush_status, + }) + } +} + +impl From for IbcEvent { + fn from(v: UpgradeConfirm) -> Self { + IbcEvent::UpgradeConfirmChannel(v) + } +} + +impl EventType for UpgradeConfirm { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeConfirmChannel + } +} + #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct UpgradeOpen { pub port_id: PortId, diff --git a/crates/relayer-types/src/core/ics04_channel/msgs.rs b/crates/relayer-types/src/core/ics04_channel/msgs.rs index f4bf9a77bb..03f4b7eff8 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs.rs @@ -24,6 +24,7 @@ pub mod chan_close_init; // Upgrade handshake messages. pub mod chan_upgrade_ack; +pub mod chan_upgrade_confirm; pub mod chan_upgrade_init; pub mod chan_upgrade_open; pub mod chan_upgrade_try; diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs index dd22baf7ee..688efb82ca 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_ack.rs @@ -1,9 +1,7 @@ -use ibc_proto::ibc::core::channel::v1::FlushStatus as RawFlushStatus; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeAck as RawMsgChannelUpgradeAck; use ibc_proto::protobuf::Protobuf; use crate::core::ics04_channel::error::Error; -use crate::core::ics04_channel::flush_status::FlushStatus; use crate::core::ics04_channel::upgrade::Upgrade; use crate::core::ics23_commitment::commitment::CommitmentProofBytes; use crate::core::ics24_host::identifier::{ChannelId, PortId}; @@ -19,7 +17,6 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeAck"; pub struct MsgChannelUpgradeAck { pub port_id: PortId, pub channel_id: ChannelId, - pub counterparty_flush_status: FlushStatus, pub counterparty_upgrade: Upgrade, /// The proof of the counterparty channel pub proof_channel: CommitmentProofBytes, @@ -35,7 +32,6 @@ impl MsgChannelUpgradeAck { pub fn new( port_id: PortId, channel_id: ChannelId, - counterparty_flush_status: FlushStatus, counterparty_upgrade: Upgrade, proof_channel: CommitmentProofBytes, proof_upgrade: CommitmentProofBytes, @@ -45,7 +41,6 @@ impl MsgChannelUpgradeAck { Self { port_id, channel_id, - counterparty_flush_status, counterparty_upgrade, proof_channel, proof_upgrade, @@ -88,7 +83,6 @@ impl TryFrom for MsgChannelUpgradeAck { Ok(MsgChannelUpgradeAck { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, - counterparty_flush_status: raw_msg.counterparty_flush_status.try_into()?, counterparty_upgrade, proof_channel: raw_msg .proof_channel @@ -109,8 +103,6 @@ impl From for RawMsgChannelUpgradeAck { RawMsgChannelUpgradeAck { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), - counterparty_flush_status: RawFlushStatus::from(domain_msg.counterparty_flush_status) - .into(), counterparty_upgrade: Some(domain_msg.counterparty_upgrade.into()), proof_upgrade: domain_msg.proof_upgrade.into(), proof_channel: domain_msg.proof_channel.into(), @@ -134,7 +126,6 @@ pub mod test_util { RawMsgChannelUpgradeAck { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), - counterparty_flush_status: 2, // Flushcomplete counterparty_upgrade: Some(get_dummy_upgrade()), proof_upgrade: get_dummy_proof(), proof_channel: get_dummy_proof(), diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs new file mode 100644 index 0000000000..fb3c0ed1eb --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs @@ -0,0 +1,256 @@ +use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeConfirm as RawMsgChannelUpgradeConfirm; +use ibc_proto::protobuf::Protobuf; + +use crate::core::ics04_channel::channel::State; +use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::upgrade::Upgrade; +use crate::core::ics23_commitment::commitment::CommitmentProofBytes; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; +use crate::tx_msg::Msg; +use crate::Height; + +pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeConfirm"; + +/// Message definition for the third step of the channel upgrade +/// handshake (the `ChanUpgradeConfirm` datagram). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgChannelUpgradeConfirm { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_channel_state: State, + pub counterparty_upgrade: Upgrade, + /// The proof of the counterparty channel + pub proof_channel: CommitmentProofBytes, + /// The proof of the counterparty upgrade + pub proof_upgrade: CommitmentProofBytes, + /// The height at which the proofs were queried. + pub proof_height: Height, + pub signer: Signer, +} + +impl MsgChannelUpgradeConfirm { + #[allow(clippy::too_many_arguments)] + pub fn new( + port_id: PortId, + channel_id: ChannelId, + counterparty_channel_state: State, + counterparty_upgrade: Upgrade, + proof_channel: CommitmentProofBytes, + proof_upgrade: CommitmentProofBytes, + proof_height: Height, + signer: Signer, + ) -> Self { + Self { + port_id, + channel_id, + counterparty_channel_state, + counterparty_upgrade, + proof_channel, + proof_upgrade, + proof_height, + signer, + } + } +} + +impl Msg for MsgChannelUpgradeConfirm { + type ValidationError = Error; + type Raw = RawMsgChannelUpgradeConfirm; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + +impl Protobuf for MsgChannelUpgradeConfirm {} + +impl TryFrom for MsgChannelUpgradeConfirm { + type Error = Error; + + fn try_from(raw_msg: RawMsgChannelUpgradeConfirm) -> Result { + let counterparty_upgrade = raw_msg + .counterparty_upgrade + .ok_or(Error::missing_upgrade())? + .try_into()?; + + let proof_height = raw_msg + .proof_height + .ok_or_else(Error::missing_proof_height)? + .try_into() + .map_err(|_| Error::invalid_proof_height())?; + + Ok(MsgChannelUpgradeConfirm { + port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, + channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, + counterparty_channel_state: State::from_i32(raw_msg.counterparty_channel_state)?, + counterparty_upgrade, + proof_channel: raw_msg + .proof_channel + .try_into() + .map_err(Error::invalid_proof)?, + proof_upgrade: raw_msg + .proof_upgrade + .try_into() + .map_err(Error::invalid_proof)?, + proof_height, + signer: raw_msg.signer.parse().map_err(Error::signer)?, + }) + } +} + +impl From for RawMsgChannelUpgradeConfirm { + fn from(domain_msg: MsgChannelUpgradeConfirm) -> Self { + RawMsgChannelUpgradeConfirm { + port_id: domain_msg.port_id.to_string(), + channel_id: domain_msg.channel_id.to_string(), + counterparty_channel_state: domain_msg.counterparty_channel_state as i32, + counterparty_upgrade: Some(domain_msg.counterparty_upgrade.into()), + proof_upgrade: domain_msg.proof_upgrade.into(), + proof_channel: domain_msg.proof_channel.into(), + proof_height: Some(domain_msg.proof_height.into()), + signer: domain_msg.signer.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeConfirm as RawMsgChannelUpgradeConfirm; + use ibc_proto::ibc::core::client::v1::Height as RawHeight; + + use crate::core::ics04_channel::upgrade::test_util::get_dummy_upgrade; + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; + + /// Returns a dummy `RawMsgChannelUpgradeConfirm`, for testing only! + pub fn get_dummy_raw_msg_chan_upgrade_confirm() -> RawMsgChannelUpgradeConfirm { + RawMsgChannelUpgradeConfirm { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + counterparty_channel_state: 6, // Flushcomplete + counterparty_upgrade: Some(get_dummy_upgrade()), + proof_upgrade: get_dummy_proof(), + proof_channel: get_dummy_proof(), + proof_height: Some(RawHeight { + revision_number: 1, + revision_height: 1, + }), + signer: get_dummy_bech32_account(), + } + } +} + +#[cfg(test)] +mod tests { + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeConfirm as RawMsgChannelUpgradeConfirm; + + use crate::core::ics04_channel::msgs::chan_upgrade_confirm::test_util::get_dummy_raw_msg_chan_upgrade_confirm; + use crate::core::ics04_channel::msgs::chan_upgrade_confirm::MsgChannelUpgradeConfirm; + + #[test] + fn parse_channel_upgrade_try_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeConfirm, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_confirm(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name: "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeConfirm { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeConfirm { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeConfirm { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeConfirm { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeConfirm { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeConfirm { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Empty proof channel".to_string(), + raw: RawMsgChannelUpgradeConfirm { + proof_channel: vec![], + ..default_raw_msg + }, + want_pass: false, + }, + ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeConfirm::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "MsgChannelUpgradeConfirm::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_confirm(); + let msg = MsgChannelUpgradeConfirm::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeConfirm::from(msg.clone()); + let msg_back = MsgChannelUpgradeConfirm::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs index 3bf6c85b07..9a46f4f20d 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_init.rs @@ -4,7 +4,6 @@ use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpg use ibc_proto::protobuf::Protobuf; use crate::core::ics04_channel::error::Error; -use crate::core::ics04_channel::timeout::UpgradeTimeout; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::signer::Signer; use crate::tx_msg::Msg; @@ -18,7 +17,6 @@ pub struct MsgChannelUpgradeInit { pub port_id: PortId, pub channel_id: ChannelId, pub fields: UpgradeFields, - pub timeout: UpgradeTimeout, pub signer: Signer, } @@ -27,14 +25,12 @@ impl MsgChannelUpgradeInit { port_id: PortId, channel_id: ChannelId, fields: UpgradeFields, - timeout: UpgradeTimeout, signer: Signer, ) -> Self { Self { port_id, channel_id, fields, - timeout, signer, } } @@ -59,9 +55,6 @@ impl TryFrom for MsgChannelUpgradeInit { type Error = Error; fn try_from(raw_msg: RawMsgChannelUpgradeInit) -> Result { - let raw_timeout = raw_msg.timeout.ok_or(Error::missing_upgrade_timeout())?; - let timeout = UpgradeTimeout::try_from(raw_timeout)?; - let raw_fields = raw_msg.fields.ok_or(Error::missing_upgrade_fields())?; let fields = UpgradeFields::try_from(raw_fields)?; @@ -70,7 +63,6 @@ impl TryFrom for MsgChannelUpgradeInit { channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, signer: raw_msg.signer.parse().map_err(Error::signer)?, fields, - timeout, }) } } @@ -82,7 +74,6 @@ impl From for RawMsgChannelUpgradeInit { channel_id: domain_msg.channel_id.to_string(), signer: domain_msg.signer.to_string(), fields: Some(domain_msg.fields.into()), - timeout: Some(domain_msg.timeout.into()), } } } @@ -90,26 +81,18 @@ impl From for RawMsgChannelUpgradeInit { #[cfg(test)] pub mod test_util { use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; - use ibc_proto::ibc::core::channel::v1::Timeout as RawUpgradeTimeout; - use crate::core::ics02_client::height::Height; use crate::core::ics04_channel::upgrade_fields::test_util::get_dummy_upgrade_fields; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::test_utils::get_dummy_bech32_account; - use crate::timestamp::Timestamp; /// Returns a dummy `RawMsgChannelUpgadeInit`, for testing only! pub fn get_dummy_raw_msg_chan_upgrade_init() -> RawMsgChannelUpgradeInit { - let dummy_timeout = RawUpgradeTimeout { - height: Some(Height::new(0, 10).unwrap().into()), - timestamp: Timestamp::now().nanoseconds(), - }; RawMsgChannelUpgradeInit { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), signer: get_dummy_bech32_account(), fields: Some(get_dummy_upgrade_fields()), - timeout: Some(dummy_timeout), } } } @@ -119,7 +102,6 @@ mod tests { use test_log::test; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeInit as RawMsgChannelUpgradeInit; - use ibc_proto::ibc::core::channel::v1::Timeout as RawUpgradeTimeout; use crate::core::ics04_channel::msgs::chan_upgrade_init::test_util::get_dummy_raw_msg_chan_upgrade_init; use crate::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; @@ -188,14 +170,6 @@ mod tests { }, want_pass: false, }, - Test { - name: "Timeout timestamp is 0 and no timeout height provided".to_string(), - raw: RawMsgChannelUpgradeInit { - timeout: Some(RawUpgradeTimeout { height: None, timestamp: 0 }), - ..default_raw_msg - }, - want_pass: false, - }, ] .into_iter() .collect(); diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs index 23a3880bcb..1ff03e1c9f 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_try.rs @@ -1,5 +1,5 @@ use crate::core::ics04_channel::packet::Sequence; -use crate::core::ics04_channel::upgrade::Upgrade; +use crate::core::ics04_channel::upgrade_fields::UpgradeFields; use crate::Height; use ibc_proto::protobuf::Protobuf; @@ -7,7 +7,6 @@ use ibc_proto::protobuf::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; use crate::core::ics04_channel::error::Error; -use crate::core::ics04_channel::timeout::UpgradeTimeout; use crate::core::ics23_commitment::commitment::CommitmentProofBytes; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; use crate::signer::Signer; @@ -22,9 +21,7 @@ pub struct MsgChannelUpgradeTry { pub port_id: PortId, pub channel_id: ChannelId, pub proposed_upgrade_connection_hops: Vec, - /// The height and/or timestamp after which the upgrade will be timed out. - pub upgrade_timeout: UpgradeTimeout, - pub counterparty_proposed_upgrade: Upgrade, + pub counterparty_upgrade_fields: UpgradeFields, pub counterparty_upgrade_sequence: Sequence, /// The proof of the counterparty channel pub proof_channel: CommitmentProofBytes, @@ -41,8 +38,7 @@ impl MsgChannelUpgradeTry { port_id: PortId, channel_id: ChannelId, proposed_upgrade_connection_hops: Vec, - upgrade_timeout: UpgradeTimeout, - counterparty_proposed_upgrade: Upgrade, + counterparty_upgrade_fields: UpgradeFields, counterparty_upgrade_sequence: Sequence, proof_channel: CommitmentProofBytes, proof_upgrade: CommitmentProofBytes, @@ -53,8 +49,7 @@ impl MsgChannelUpgradeTry { port_id, channel_id, proposed_upgrade_connection_hops, - upgrade_timeout, - counterparty_proposed_upgrade, + counterparty_upgrade_fields, counterparty_upgrade_sequence, proof_channel, proof_upgrade, @@ -88,12 +83,11 @@ impl TryFrom for MsgChannelUpgradeTry { .iter() .map(|hop| hop.parse().map_err(Error::identifier)) .collect(); - let counterparty_proposed_upgrade = raw_msg - .counterparty_proposed_upgrade - .ok_or(Error::missing_upgrade())? + let counterparty_upgrade_fields = raw_msg + .counterparty_upgrade_fields + .ok_or(Error::missing_upgrade_fields())? .try_into()?; let counterparty_upgrade_sequence = raw_msg.counterparty_upgrade_sequence.into(); - let upgrade_timeout = raw_msg.upgrade_timeout.unwrap().try_into()?; let proof_height = raw_msg .proof_height @@ -105,9 +99,8 @@ impl TryFrom for MsgChannelUpgradeTry { port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, proposed_upgrade_connection_hops: proposed_upgrade_connection_hops?, - counterparty_proposed_upgrade, + counterparty_upgrade_fields, counterparty_upgrade_sequence, - upgrade_timeout, proof_channel: raw_msg .proof_channel .try_into() @@ -134,8 +127,7 @@ impl From for RawMsgChannelUpgradeTry { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), proposed_upgrade_connection_hops, - upgrade_timeout: Some(domain_msg.upgrade_timeout.into()), - counterparty_proposed_upgrade: Some(domain_msg.counterparty_proposed_upgrade.into()), + counterparty_upgrade_fields: Some(domain_msg.counterparty_upgrade_fields.into()), counterparty_upgrade_sequence: domain_msg.counterparty_upgrade_sequence.into(), proof_upgrade: domain_msg.proof_upgrade.into(), proof_channel: domain_msg.proof_channel.into(), @@ -147,29 +139,20 @@ impl From for RawMsgChannelUpgradeTry { #[cfg(test)] pub mod test_util { - use ibc_proto::ibc::core::channel::v1::{ - MsgChannelUpgradeTry as RawMsgChannelUpgradeTry, Timeout, - }; + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTry as RawMsgChannelUpgradeTry; use ibc_proto::ibc::core::client::v1::Height as RawHeight; - use crate::core::ics02_client::height::Height; - use crate::core::ics04_channel::upgrade::test_util::get_dummy_upgrade; + use crate::core::ics04_channel::upgrade_fields::test_util::get_dummy_upgrade_fields; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; - use crate::timestamp::Timestamp; /// Returns a dummy `RawMsgChannelUpgradeTry`, for testing only! pub fn get_dummy_raw_msg_chan_upgrade_try() -> RawMsgChannelUpgradeTry { - let dummy_timeout = Timeout { - height: Some(Height::new(0, 10).unwrap().into()), - timestamp: Timestamp::now().nanoseconds(), - }; RawMsgChannelUpgradeTry { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), proposed_upgrade_connection_hops: vec![], - upgrade_timeout: Some(dummy_timeout), - counterparty_proposed_upgrade: Some(get_dummy_upgrade()), + counterparty_upgrade_fields: Some(get_dummy_upgrade_fields()), counterparty_upgrade_sequence: 1, proof_upgrade: get_dummy_proof(), proof_channel: get_dummy_proof(), diff --git a/crates/relayer-types/src/core/ics04_channel/upgrade.rs b/crates/relayer-types/src/core/ics04_channel/upgrade.rs index 8af6dfa326..b543a6873c 100644 --- a/crates/relayer-types/src/core/ics04_channel/upgrade.rs +++ b/crates/relayer-types/src/core/ics04_channel/upgrade.rs @@ -9,7 +9,8 @@ use crate::core::ics04_channel::upgrade_fields::UpgradeFields; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Upgrade { pub fields: UpgradeFields, - pub timeout: UpgradeTimeout, + // timeout can be zero, see `TryFrom` implementation + pub timeout: Option, pub latest_sequence_send: Sequence, } @@ -25,8 +26,8 @@ impl TryFrom for Upgrade { .try_into()?; let timeout = value .timeout - .ok_or(ChannelError::missing_upgrade_timeout())? - .try_into()?; + .filter(|tm| UpgradeTimeout::try_from(tm.clone()).is_ok()) + .map(|tm| UpgradeTimeout::try_from(tm).unwrap()); let latest_sequence_send = value.latest_sequence_send.into(); Ok(Self { @@ -39,9 +40,10 @@ impl TryFrom for Upgrade { impl From for RawUpgrade { fn from(value: Upgrade) -> Self { + let timeout = value.timeout.map(|tm| tm.into()); Self { fields: Some(value.fields.into()), - timeout: Some(value.timeout.into()), + timeout, latest_sequence_send: value.latest_sequence_send.into(), } } diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index a5a30fce81..5a36c572a1 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -132,6 +132,7 @@ const CHANNEL_CLOSE_CONFIRM_EVENT: &str = "channel_close_confirm"; const CHANNEL_UPGRADE_INIT_EVENT: &str = "channel_upgrade_init"; const CHANNEL_UPGRADE_TRY_EVENT: &str = "channel_upgrade_try"; const CHANNEL_UPGRADE_ACK_EVENT: &str = "channel_upgrade_ack"; +const CHANNEL_UPGRADE_CONFIRM_EVENT: &str = "channel_upgrade_confirm"; const CHANNEL_UPGRADE_OPEN_EVENT: &str = "channel_upgrade_open"; /// Packet event types const SEND_PACKET_EVENT: &str = "send_packet"; @@ -167,6 +168,7 @@ pub enum IbcEventType { UpgradeInitChannel, UpgradeTryChannel, UpgradeAckChannel, + UpgradeConfirmChannel, UpgradeOpenChannel, SendPacket, ReceivePacket, @@ -203,6 +205,7 @@ impl IbcEventType { IbcEventType::UpgradeInitChannel => CHANNEL_UPGRADE_INIT_EVENT, IbcEventType::UpgradeTryChannel => CHANNEL_UPGRADE_TRY_EVENT, IbcEventType::UpgradeAckChannel => CHANNEL_UPGRADE_ACK_EVENT, + IbcEventType::UpgradeConfirmChannel => CHANNEL_UPGRADE_CONFIRM_EVENT, IbcEventType::UpgradeOpenChannel => CHANNEL_UPGRADE_OPEN_EVENT, IbcEventType::SendPacket => SEND_PACKET_EVENT, IbcEventType::ReceivePacket => RECEIVE_PACKET_EVENT, @@ -243,6 +246,7 @@ impl FromStr for IbcEventType { CHANNEL_UPGRADE_INIT_EVENT => Ok(IbcEventType::UpgradeInitChannel), CHANNEL_UPGRADE_TRY_EVENT => Ok(IbcEventType::UpgradeTryChannel), CHANNEL_UPGRADE_ACK_EVENT => Ok(IbcEventType::UpgradeAckChannel), + CHANNEL_UPGRADE_CONFIRM_EVENT => Ok(IbcEventType::UpgradeConfirmChannel), CHANNEL_UPGRADE_OPEN_EVENT => Ok(IbcEventType::UpgradeOpenChannel), SEND_PACKET_EVENT => Ok(IbcEventType::SendPacket), RECEIVE_PACKET_EVENT => Ok(IbcEventType::ReceivePacket), @@ -285,6 +289,7 @@ pub enum IbcEvent { UpgradeInitChannel(ChannelEvents::UpgradeInit), UpgradeTryChannel(ChannelEvents::UpgradeTry), UpgradeAckChannel(ChannelEvents::UpgradeAck), + UpgradeConfirmChannel(ChannelEvents::UpgradeConfirm), UpgradeOpenChannel(ChannelEvents::UpgradeOpen), SendPacket(ChannelEvents::SendPacket), @@ -328,6 +333,7 @@ impl Display for IbcEvent { IbcEvent::UpgradeInitChannel(ev) => write!(f, "UpgradeInitChannel({ev})"), IbcEvent::UpgradeTryChannel(ev) => write!(f, "UpgradeTryChannel({ev})"), IbcEvent::UpgradeAckChannel(ev) => write!(f, "UpgradeAckChannel({ev})"), + IbcEvent::UpgradeConfirmChannel(ev) => write!(f, "UpgradeConfirmChannel({ev})"), IbcEvent::UpgradeOpenChannel(ev) => write!(f, "UpgradeOpenChannel({ev})"), IbcEvent::SendPacket(ev) => write!(f, "SendPacket({ev})"), @@ -371,6 +377,7 @@ impl TryFrom for abci::Event { IbcEvent::UpgradeInitChannel(event) => event.into(), IbcEvent::UpgradeTryChannel(event) => event.into(), IbcEvent::UpgradeAckChannel(event) => event.into(), + IbcEvent::UpgradeConfirmChannel(event) => event.into(), IbcEvent::UpgradeOpenChannel(event) => event.into(), IbcEvent::SendPacket(event) => event.try_into().map_err(Error::channel)?, IbcEvent::ReceivePacket(event) => event.try_into().map_err(Error::channel)?, @@ -417,6 +424,7 @@ impl IbcEvent { IbcEvent::UpgradeInitChannel(_) => IbcEventType::UpgradeInitChannel, IbcEvent::UpgradeTryChannel(_) => IbcEventType::UpgradeTryChannel, IbcEvent::UpgradeAckChannel(_) => IbcEventType::UpgradeAckChannel, + IbcEvent::UpgradeConfirmChannel(_) => IbcEventType::UpgradeConfirmChannel, IbcEvent::UpgradeOpenChannel(_) => IbcEventType::UpgradeOpenChannel, IbcEvent::SendPacket(_) => IbcEventType::SendPacket, IbcEvent::ReceivePacket(_) => IbcEventType::ReceivePacket, diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 5057feba24..318fc593cb 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -2,6 +2,7 @@ pub use error::ChannelError; use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; use ibc_relayer_types::core::ics04_channel::flush_status::FlushStatus; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_ack::MsgChannelUpgradeAck; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_confirm::MsgChannelUpgradeConfirm; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_open::MsgChannelUpgradeOpen; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::upgrade_fields::UpgradeFields; @@ -24,7 +25,6 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpen use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; -use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; use ibc_relayer_types::core::ics23_commitment::commitment::CommitmentProofBytes; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, @@ -1487,7 +1487,6 @@ impl Channel { new_version: Option, new_ordering: Option, new_connection_hops: Option>, - timeout: UpgradeTimeout, ) -> Result, ChannelError> { // Destination channel ID must exist let channel_id = self @@ -1510,7 +1509,10 @@ impl Channel { .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; if channel_end.state != State::Open { - return Err(ChannelError::invalid_channel_upgrade_state()); + return Err(ChannelError::invalid_channel_upgrade_state( + State::Open.to_string(), + channel_end.state.to_string(), + )); } if let Some(new_ordering) = new_ordering { @@ -1546,7 +1548,6 @@ impl Channel { port_id: port_id.clone(), channel_id: channel_id.clone(), fields, - timeout, signer, } }; @@ -1559,10 +1560,9 @@ impl Channel { new_version: Option, new_ordering: Option, new_connection_hops: Option>, - timeout: UpgradeTimeout, ) -> Result { let dst_msgs = - self.build_chan_upgrade_init(new_version, new_ordering, new_connection_hops, timeout)?; + self.build_chan_upgrade_init(new_version, new_ordering, new_connection_hops)?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeInit"); @@ -1594,10 +1594,7 @@ impl Channel { } } - pub fn build_chan_upgrade_try( - &self, - timeout: UpgradeTimeout, - ) -> Result, ChannelError> { + pub fn build_chan_upgrade_try(&self) -> Result, ChannelError> { let src_channel_id = self .src_channel_id() .ok_or_else(ChannelError::missing_local_channel_id)?; @@ -1690,8 +1687,11 @@ impl Channel { )); } - if channel_end.state != State::InitUpgrade { - return Err(ChannelError::invalid_channel_upgrade_state()); + if channel_end.state != State::Open { + return Err(ChannelError::invalid_channel_upgrade_state( + State::Open.to_string(), + channel_end.state.to_string(), + )); } let signer = self @@ -1704,8 +1704,7 @@ impl Channel { port_id: dst_port_id.clone(), channel_id: dst_channel_id.clone(), proposed_upgrade_connection_hops: dst_channel_end.connection_hops, - upgrade_timeout: timeout, - counterparty_proposed_upgrade: upgrade, + counterparty_upgrade_fields: upgrade.fields, counterparty_upgrade_sequence: channel_end.upgraded_sequence, proof_channel: src_proof.object_proof().clone(), proof_upgrade, @@ -1720,11 +1719,8 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_try_and_send( - &self, - timeout: UpgradeTimeout, - ) -> Result { - let dst_msgs = self.build_chan_upgrade_try(timeout)?; + pub fn build_chan_upgrade_try_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_try()?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTry"); @@ -1776,7 +1772,110 @@ impl Channel { .query_latest_height() .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; - let (src_channel_end, _) = self + let (upgrade, maybe_upgrade_proof) = self + .src_chain() + .query_upgrade( + QueryUpgradeRequest { + port_id: self.src_port_id().to_string(), + channel_id: src_channel_id.to_string(), + }, + src_latest_height, + ) + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + let upgrade_proof = maybe_upgrade_proof.ok_or(ChannelError::missing_upgrade_proof())?; + + let proof_upgrade = + CommitmentProofBytes::try_from(upgrade_proof).map_err(ChannelError::malformed_proof)?; + + // Building the channel proof at the queried height + let proof = self + .src_chain() + .build_channel_proofs( + &src_port_id.clone(), + &src_channel_id.clone(), + src_latest_height, + ) + .map_err(ChannelError::channel_proof)?; + + let signer = self + .dst_chain() + .get_signer() + .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; + + // Build the domain type message + let new_msg = MsgChannelUpgradeAck { + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + counterparty_upgrade: upgrade, + proof_channel: proof.object_proof().clone(), + proof_upgrade, + proof_height: proof.height(), + signer, + }; + + let mut chain_a_msgs = self.build_update_client_on_dst(proof.height())?; + + chain_a_msgs.push(new_msg.to_any()); + + Ok(chain_a_msgs) + } + + pub fn build_chan_upgrade_ack_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_ack()?; + + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeAck"); + + let events = self + .dst_chain() + .send_messages_and_wait_commit(tm) + .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; + + let result = events + .into_iter() + .find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeAckChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no channel upgrade ack event was in the response".to_string(), + ) + })?; + + match &result.event { + IbcEvent::UpgradeAckChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), + } + } + + pub fn build_chan_upgrade_confirm(&self) -> Result, ChannelError> { + // Destination channel ID must exist + + let src_channel_id = self + .src_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let src_port_id = self.src_port_id(); + + let dst_port_id = self.dst_port_id(); + + let src_latest_height = self + .src_chain() + .query_latest_height() + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + // Fetch the src channel end that will be upgraded by the upgrade handshake + // Querying for the Channel End now includes the upgrade sequence number + let (channel_end, _) = self .src_chain() .query_channel( QueryChannelRequest { @@ -1820,10 +1919,10 @@ impl Channel { .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; // Build the domain type message - let new_msg = MsgChannelUpgradeAck { + let new_msg = MsgChannelUpgradeConfirm { port_id: dst_port_id.clone(), channel_id: dst_channel_id.clone(), - counterparty_flush_status: src_channel_end.flush_status, + counterparty_channel_state: channel_end.state, counterparty_upgrade: upgrade, proof_channel: proof.object_proof().clone(), proof_upgrade, @@ -1838,10 +1937,10 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_ack_and_send(&self) -> Result { - let dst_msgs = self.build_chan_upgrade_ack()?; + pub fn build_chan_upgrade_confirm_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_confirm()?; - let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeAck"); + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeConfirm"); let events = self .dst_chain() @@ -1851,17 +1950,17 @@ impl Channel { let result = events .into_iter() .find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeAckChannel(_)) + matches!(event_with_height.event, IbcEvent::UpgradeConfirmChannel(_)) || matches!(event_with_height.event, IbcEvent::ChainError(_)) }) .ok_or_else(|| { ChannelError::missing_event( - "no channel upgrade ack event was in the response".to_string(), + "no channel upgrade confirm event was in the response".to_string(), ) })?; match &result.event { - IbcEvent::UpgradeAckChannel(_) => { + IbcEvent::UpgradeConfirmChannel(_) => { info!("👋 {} => {}", self.dst_chain().id(), result); Ok(result.event) } @@ -1977,59 +2076,6 @@ impl Channel { connection_delay: self.connection_delay, } } - - pub fn get_upgrade_fields( - &self, - new_version: Option, - new_ordering: Option, - new_connection_hops: Option>, - ) -> Result { - // Destination channel ID must exist - let channel_id = self - .dst_channel_id() - .ok_or_else(ChannelError::missing_counterparty_channel_id)?; - - let port_id = self.dst_port_id(); - - // Channel must exist on destination - let (mut channel_end, _proof) = self - .dst_chain() - .query_channel( - QueryChannelRequest { - port_id: port_id.clone(), - channel_id: channel_id.clone(), - height: QueryHeight::Latest, - }, - IncludeProof::No, - ) - .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; - - if channel_end.state != State::Open { - return Err(ChannelError::invalid_channel_upgrade_state()); - } - - if let Some(new_ordering) = new_ordering { - if new_ordering == Ordering::Uninitialized || new_ordering > channel_end.ordering { - return Err(ChannelError::invalid_channel_upgrade_ordering()); - } - - channel_end.ordering = new_ordering; - } - - if let Some(new_version) = new_version { - channel_end.version = new_version; - } - - if let Some(new_connection_hops) = new_connection_hops { - channel_end.connection_hops = new_connection_hops; - } - - Ok(UpgradeFields::new( - channel_end.ordering, - channel_end.connection_hops, - channel_end.version, - )) - } } pub fn extract_channel_id(event: &IbcEvent) -> Result<&ChannelId, ChannelError> { diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index ff8b0809b8..950e0e2919 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -39,7 +39,8 @@ define_error! { |_| { "attempted to upgrade a channel to a more strict ordring, which is not allowed" }, InvalidChannelUpgradeState - |_| { "attempted to upgrade a channel that is not in the OPEN state" }, + { expected: String, actual: String } + |e| { format_args!("channel state should be {} but is {}", e.expected, e.actual) }, InvalidChannelUpgradeTimeout |_| { "attempted to upgrade a channel without supplying at least one of timeout height or timeout timestamp" }, diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index 06a03c78fd..181c452c7a 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -130,6 +130,10 @@ pub fn ibc_event_try_from_abci_event(abci_event: &AbciEvent) -> Result Ok(IbcEvent::UpgradeAckChannel( channel_upgrade_ack_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), + Ok(IbcEventType::UpgradeConfirmChannel) => Ok(IbcEvent::UpgradeConfirmChannel( + channel_upgrade_confirm_try_from_abci_event(abci_event) + .map_err(IbcEventError::channel)?, + )), Ok(IbcEventType::UpgradeOpenChannel) => Ok(IbcEvent::UpgradeOpenChannel( channel_upgrade_open_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), @@ -304,6 +308,16 @@ pub fn channel_upgrade_ack_try_from_abci_event( } } +pub fn channel_upgrade_confirm_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_upgrade_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeConfirm::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + pub fn channel_upgrade_open_try_from_abci_event( abci_event: &AbciEvent, ) -> Result { diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md new file mode 100644 index 0000000000..980a34b457 --- /dev/null +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md @@ -0,0 +1 @@ +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-confirm --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md index e33ec14407..57a55e65ea 100644 --- a/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md @@ -1 +1 @@ -[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-try[[#OPTIONS]] --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-try --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/help_templates/tx.md b/guide/src/templates/help_templates/tx.md index 95e55b08aa..d0ee9956db 100644 --- a/guide/src/templates/help_templates/tx.md +++ b/guide/src/templates/help_templates/tx.md @@ -8,22 +8,23 @@ OPTIONS: -h, --help Print help information SUBCOMMANDS: - chan-close-confirm Confirm the closing of a channel (ChannelCloseConfirm) - chan-close-init Initiate the closing of a channel (ChannelCloseInit) - chan-open-ack Relay acknowledgment of a channel attempt (ChannelOpenAck) - chan-open-confirm Confirm opening of a channel (ChannelOpenConfirm) - chan-open-init Initialize a channel (ChannelOpenInit) - chan-open-try Relay the channel attempt (ChannelOpenTry) - chan-upgrade-ack Relay the channel upgrade attempt (ChannelUpgradeAck) - chan-upgrade-init Initiate a channel upgrade (ChannelUpgradeInit) - chan-upgrade-open Relay the channel upgrade attempt (ChannelUpgradeOpen) - chan-upgrade-try Relay the channel upgrade attempt (ChannelUpgradeTry) - conn-ack Relay acknowledgment of a connection attempt (ConnectionOpenAck) - conn-confirm Confirm opening of a connection (ConnectionOpenConfirm) - conn-init Initialize a connection (ConnectionOpenInit) - conn-try Relay the connection attempt (ConnectionOpenTry) - ft-transfer Send a fungible token transfer test transaction (ICS20 MsgTransfer) - help Print this message or the help of the given subcommand(s) - packet-ack Relay acknowledgment packets - packet-recv Relay receive or timeout packets - upgrade-chain Send an IBC upgrade plan + chan-close-confirm Confirm the closing of a channel (ChannelCloseConfirm) + chan-close-init Initiate the closing of a channel (ChannelCloseInit) + chan-open-ack Relay acknowledgment of a channel attempt (ChannelOpenAck) + chan-open-confirm Confirm opening of a channel (ChannelOpenConfirm) + chan-open-init Initialize a channel (ChannelOpenInit) + chan-open-try Relay the channel attempt (ChannelOpenTry) + chan-upgrade-ack Relay the channel upgrade attempt (ChannelUpgradeAck) + chan-upgrade-confirm Relay the channel upgrade attempt (ChannelUpgradeConfirm) + chan-upgrade-init Initiate a channel upgrade (ChannelUpgradeInit) + chan-upgrade-open Relay the channel upgrade attempt (ChannelUpgradeOpen) + chan-upgrade-try Relay the channel upgrade attempt (ChannelUpgradeTry) + conn-ack Relay acknowledgment of a connection attempt (ConnectionOpenAck) + conn-confirm Confirm opening of a connection (ConnectionOpenConfirm) + conn-init Initialize a connection (ConnectionOpenInit) + conn-try Relay the connection attempt (ConnectionOpenTry) + ft-transfer Send a fungible token transfer test transaction (ICS20 MsgTransfer) + help Print this message or the help of the given subcommand(s) + packet-ack Relay acknowledgment packets + packet-recv Relay receive or timeout packets + upgrade-chain Send an IBC upgrade plan diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-confirm.md b/guide/src/templates/help_templates/tx/chan-upgrade-confirm.md new file mode 100644 index 0000000000..e13588c59d --- /dev/null +++ b/guide/src/templates/help_templates/tx/chan-upgrade-confirm.md @@ -0,0 +1,30 @@ +DESCRIPTION: +Relay the channel upgrade attempt (ChannelUpgradeConfirm) + +USAGE: + hermes tx chan-upgrade-confirm --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel + +OPTIONS: + -h, --help Print help information + +REQUIRED: + --dst-chain + Identifier of the destination chain + + --dst-channel + Identifier of the destination channel (optional) [aliases: dst-chan] + + --dst-connection + Identifier of the destination connection [aliases: dst-conn] + + --dst-port + Identifier of the destination port + + --src-chain + Identifier of the source chain + + --src-channel + Identifier of the source channel (required) [aliases: src-chan] + + --src-port + Identifier of the source port diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-init.md b/guide/src/templates/help_templates/tx/chan-upgrade-init.md index f0d217bb3b..8df60dac43 100644 --- a/guide/src/templates/help_templates/tx/chan-upgrade-init.md +++ b/guide/src/templates/help_templates/tx/chan-upgrade-init.md @@ -17,15 +17,6 @@ OPTIONS: only be upgraded from a stricter ordering to a less strict ordering, i.e., from ORDERED to UNORDERED. Defaults to the ordering of the initiating chain if not specified. - --timeout-height - Height that, once it has been surpassed on the originating chain, the upgrade will time - out. Required if no timeout timestamp is specified. - - --timeout-time - Timeout in human readable format since current that, once it has been surpassed on the - originating chain, the upgrade will time out. Required if no timeout height is - specified. - --version Version of the channel that both chains will upgrade to. Defaults to the version of the initiating chain if not specified. diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-try.md b/guide/src/templates/help_templates/tx/chan-upgrade-try.md index c711c208de..6a00fbc211 100644 --- a/guide/src/templates/help_templates/tx/chan-upgrade-try.md +++ b/guide/src/templates/help_templates/tx/chan-upgrade-try.md @@ -2,20 +2,10 @@ DESCRIPTION: Relay the channel upgrade attempt (ChannelUpgradeTry) USAGE: - hermes tx chan-upgrade-try [OPTIONS] --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel + hermes tx chan-upgrade-try --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel OPTIONS: - -h, --help - Print help information - - --timeout-height - Height that, once it has been surpassed on the originating chain, the upgrade will time - out. Required if no timeout timestamp is specified. - - --timeout-time - Timeout in human readable format since current that, once it has been surpassed on the - originating chain, the upgrade will time out. Required if no timeout height is - specified. + -h, --help Print help information REQUIRED: --dst-chain diff --git a/scripts/auto_gen_templates.sh b/scripts/auto_gen_templates.sh old mode 100644 new mode 100755 index d7eb557357..12f7e105ed --- a/scripts/auto_gen_templates.sh +++ b/scripts/auto_gen_templates.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This script is used to generate the templates for the guide SCRIPT_NAME="$0" diff --git a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs index 46855c7620..db7d60c4f0 100644 --- a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs +++ b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs @@ -5,13 +5,13 @@ //! ACK and CONFIRM steps. use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; -use ibc_relayer_types::core::ics04_channel::timeout::UpgradeTimeout; -use ibc_relayer_types::core::{ics02_client::height::Height, ics04_channel::version::Version}; +use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ assert_eventually_channel_established, assert_eventually_channel_upgrade_ack, - assert_eventually_channel_upgrade_init, assert_eventually_channel_upgrade_open, - assert_eventually_channel_upgrade_try, ChannelUpgradableAttributes, + assert_eventually_channel_upgrade_confirm, assert_eventually_channel_upgrade_init, + assert_eventually_channel_upgrade_open, assert_eventually_channel_upgrade_try, + ChannelUpgradableAttributes, }; #[test] @@ -81,33 +81,35 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { let new_connection_hops = None; let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let interm_attrs = ChannelUpgradableAttributes::new( old_version, + new_version.clone(), old_ordering, old_connection_hops_a.clone(), old_connection_hops_b.clone(), ); let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), new_version.clone(), old_ordering, old_connection_hops_a, old_connection_hops_b, ); - let timeout_height = Height::new( - ChainId::chain_version(chains.chain_id_b().0.to_string().as_str()), - 120, - ) - .map_err(|e| eyre!("error creating height for timeout height: {e}"))?; - let timeout = UpgradeTimeout::Height(timeout_height); - info!("Will run ChanUpgradeInit step..."); channel.flipped().build_chan_upgrade_init_and_send( Some(new_version), new_ordering, new_connection_hops, - timeout.clone(), )?; info!("Check that the step ChanUpgradeInit was correctly executed..."); @@ -122,7 +124,7 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { info!("Will run ChanUpgradeTry step..."); - channel.build_chan_upgrade_try_and_send(timeout)?; + channel.build_chan_upgrade_try_and_send()?; info!("Check that the step ChanUpgradeTry was correctly executed..."); @@ -148,11 +150,21 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { &old_attrs, )?; - info!("Will run first ChanUpgradeOpen step..."); + info!("Will run ChanUpgradeConfirm step..."); - channel.build_chan_upgrade_open_and_send()?; + channel.build_chan_upgrade_confirm_and_send()?; + + info!("Check that the step ChanUpgradeConfirm was correctly executed..."); + + assert_eventually_channel_upgrade_confirm( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &interm_attrs.flipped(), + )?; - info!("Will run second ChanUpgradeOpen step..."); + info!("Will run ChanUpgradeOpen step..."); channel.flipped().build_chan_upgrade_open_and_send()?; diff --git a/tools/test-framework/src/chain/cli/bootstrap.rs b/tools/test-framework/src/chain/cli/bootstrap.rs index 15d7f9f71d..63e31a2ee6 100644 --- a/tools/test-framework/src/chain/cli/bootstrap.rs +++ b/tools/test-framework/src/chain/cli/bootstrap.rs @@ -71,6 +71,7 @@ pub fn add_genesis_account( &[ "--home", home_path, + "genesis", "add-genesis-account", wallet_address, &amounts_str, @@ -93,6 +94,7 @@ pub fn add_genesis_validator( &[ "--home", home_path, + "genesis", "gentx", wallet_id, "--keyring-backend", @@ -110,7 +112,7 @@ pub fn collect_gen_txs(chain_id: &str, command_path: &str, home_path: &str) -> R simple_exec( chain_id, command_path, - &["--home", home_path, "collect-gentxs"], + &["--home", home_path, "genesis", "collect-gentxs"], )?; Ok(()) diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index 688cf1c0f0..42ed7f9670 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -38,7 +38,8 @@ impl TaggedChannelEndExt /// This struct contains the attributes which can be modified with a channel upgrade pub struct ChannelUpgradableAttributes { - version: Version, + version_a: Version, + version_b: Version, ordering: Ordering, connection_hops_a: Vec, connection_hops_b: Vec, @@ -46,13 +47,15 @@ pub struct ChannelUpgradableAttributes { impl ChannelUpgradableAttributes { pub fn new( - version: Version, + version_a: Version, + version_b: Version, ordering: Ordering, connection_hops_a: Vec, connection_hops_b: Vec, ) -> Self { Self { - version, + version_a, + version_b, ordering, connection_hops_a, connection_hops_b, @@ -61,15 +64,20 @@ impl ChannelUpgradableAttributes { pub fn flipped(&self) -> Self { Self { - version: self.version.clone(), + version_a: self.version_b.clone(), + version_b: self.version_a.clone(), ordering: self.ordering, connection_hops_a: self.connection_hops_b.clone(), connection_hops_b: self.connection_hops_a.clone(), } } - pub fn version(&self) -> &Version { - &self.version + pub fn version_a(&self) -> &Version { + &self.version_a + } + + pub fn version_b(&self) -> &Version { + &self.version_b } pub fn ordering(&self) -> &Ordering { @@ -278,7 +286,7 @@ pub fn assert_eventually_channel_upgrade_init( + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + upgrade_attrs: &ChannelUpgradableAttributes, +) -> Result, Error> { + assert_eventually_succeed( + "channel upgrade confirm step should be done", + 20, + Duration::from_secs(1), + || { + assert_channel_upgrade_state( + ChannelState::Open, + ChannelState::Flushcomplete, + FlushStatus::NotinflushUnspecified, + FlushStatus::NotinflushUnspecified, handle_a, handle_b, channel_id_a, @@ -411,11 +446,11 @@ fn assert_channel_upgrade_state( if !channel_end_a .value() - .version_matches(upgrade_attrs.version()) + .version_matches(upgrade_attrs.version_a()) { return Err(Error::generic(eyre!( "expected channel end A version to be `{}`, but it is instead `{}`", - upgrade_attrs.version(), + upgrade_attrs.version_a(), channel_end_a.value().version() ))); } @@ -471,11 +506,11 @@ fn assert_channel_upgrade_state( if !channel_end_b .value() - .version_matches(upgrade_attrs.version()) + .version_matches(upgrade_attrs.version_b()) { return Err(Error::generic(eyre!( "expected channel end B version to be `{}`, but it is instead `{}`", - upgrade_attrs.version(), + upgrade_attrs.version_b(), channel_end_b.value().version() ))); } From 7a0531d2aea4dc8e7e2a0205dda76ee47383f8e5 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 24 Aug 2023 13:53:52 +0200 Subject: [PATCH 71/99] Update nix flake --- flake.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 782fc3bf12..2cfd6a4352 100644 --- a/flake.lock +++ b/flake.lock @@ -118,11 +118,11 @@ "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1690194431, - "narHash": "sha256-9ojIz20Wi54zjHaWjXUiTKZw3N3YhqGgpznbh+K/+D4=", + "lastModified": 1692877927, + "narHash": "sha256-wZZMQqUuWImKk9U+SgAtBCxjSoQmTs5A4AL5vN8wiL0=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "b8297d709f92a6b6cff5c9cd84d5d30e538f2224", + "rev": "b41a5541fa9e6460f25365c3f2a54cb66da3b69e", "type": "github" }, "original": { @@ -254,11 +254,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { @@ -529,17 +529,17 @@ "ibc-go-v7-channel-upgrade-src": { "flake": false, "locked": { - "lastModified": 1689769107, - "narHash": "sha256-BadLMNoREpix9Bko7I9PhdkhIMjCoco8opO7HvWnbBs=", + "lastModified": 1692787150, + "narHash": "sha256-2EicMXlcBneBR5NwpAyVZ/uSvLaWrJEKLmb5/H+o/Ls=", "owner": "cosmos", "repo": "ibc-go", - "rev": "82ea9531e24855ef52e2dae629d579583a0e830f", + "rev": "f1e8ae805a3633d47928cfc02315a1a19ca80a0e", "type": "github" }, "original": { "owner": "cosmos", "repo": "ibc-go", - "rev": "82ea9531e24855ef52e2dae629d579583a0e830f", + "rev": "f1e8ae805a3633d47928cfc02315a1a19ca80a0e", "type": "github" } }, @@ -777,11 +777,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1691403902, - "narHash": "sha256-J74y4xWtKPDPyVtF4arzrwuSOGznlFlJ+uB9RwNNnbo=", + "lastModified": 1692808169, + "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c91024273f020df2dcb209cc133461ca17848026", + "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", "type": "github" }, "original": { From 9dd685d5a58f386ce507430cfdef6a3114237ec0 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 24 Aug 2023 14:14:37 +0200 Subject: [PATCH 72/99] Update nix flake --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 2cfd6a4352..23fba98bc2 100644 --- a/flake.lock +++ b/flake.lock @@ -118,11 +118,11 @@ "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1692877927, - "narHash": "sha256-wZZMQqUuWImKk9U+SgAtBCxjSoQmTs5A4AL5vN8wiL0=", + "lastModified": 1692879240, + "narHash": "sha256-oVxjLGuWIaWeyI9KufDgQKtGyfKYMxDzvGk5UNuRjnk=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "b41a5541fa9e6460f25365c3f2a54cb66da3b69e", + "rev": "8cdc17fbefdafce7ff659838372a6ab740798b6e", "type": "github" }, "original": { From eb29842f38c85679b6b3bf49a067bad3c1a87f6f Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 24 Aug 2023 14:50:59 +0200 Subject: [PATCH 73/99] Add test bootstrap compatibility for pre and post SDK v0.47.0 --- .../test-framework/src/chain/cli/bootstrap.rs | 71 +++++++++++++++---- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/tools/test-framework/src/chain/cli/bootstrap.rs b/tools/test-framework/src/chain/cli/bootstrap.rs index 63e31a2ee6..65dc1e9ed4 100644 --- a/tools/test-framework/src/chain/cli/bootstrap.rs +++ b/tools/test-framework/src/chain/cli/bootstrap.rs @@ -64,8 +64,9 @@ pub fn add_genesis_account( amounts: &[String], ) -> Result<(), Error> { let amounts_str = itertools::join(amounts, ","); - - simple_exec( + // Cosmos SDK v0.47.0 introduced the `genesis` subcommand, this match is required to + // support pre and post SDK v0.47.0. https://github.com/cosmos/cosmos-sdk/pull/14149 + match simple_exec( chain_id, command_path, &[ @@ -76,9 +77,23 @@ pub fn add_genesis_account( wallet_address, &amounts_str, ], - )?; - - Ok(()) + ) { + Ok(_) => Ok(()), + Err(_) => { + simple_exec( + chain_id, + command_path, + &[ + "--home", + home_path, + "add-genesis-account", + wallet_address, + &amounts_str, + ], + )?; + Ok(()) + } + } } pub fn add_genesis_validator( @@ -88,7 +103,9 @@ pub fn add_genesis_validator( wallet_id: &str, amount: &str, ) -> Result<(), Error> { - simple_exec( + // Cosmos SDK v0.47.0 introduced the `genesis` subcommand, this match is required to + // support pre and post SDK v0.47.0. https://github.com/cosmos/cosmos-sdk/pull/14149 + match simple_exec( chain_id, command_path, &[ @@ -103,19 +120,47 @@ pub fn add_genesis_validator( chain_id, amount, ], - )?; - - Ok(()) + ) { + Ok(_) => Ok(()), + Err(_) => { + simple_exec( + chain_id, + command_path, + &[ + "--home", + home_path, + "gentx", + wallet_id, + "--keyring-backend", + "test", + "--chain-id", + chain_id, + amount, + ], + )?; + Ok(()) + } + } } pub fn collect_gen_txs(chain_id: &str, command_path: &str, home_path: &str) -> Result<(), Error> { - simple_exec( + // Cosmos SDK v0.47.0 introduced the `genesis` subcommand, this match is required to + // support pre and post SDK v0.47.0. https://github.com/cosmos/cosmos-sdk/pull/14149 + match simple_exec( chain_id, command_path, &["--home", home_path, "genesis", "collect-gentxs"], - )?; - - Ok(()) + ) { + Ok(_) => Ok(()), + Err(_) => { + simple_exec( + chain_id, + command_path, + &["--home", home_path, "collect-gentxs"], + )?; + Ok(()) + } + } } pub fn start_chain( From f368a1428c03ad409b6a7dd9e4f51b010329e841 Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:57:56 +0200 Subject: [PATCH 74/99] Channel upgrade worker handshake (#3569) * Add missing CLIs for channel upgrade * Update CLI template * Add cargo patch for check-guide test * Add documentation TODO to check-guide Cargo.toml * Set dst-channel flag to required for channel upgrade CLIs and updated templates * Clean channel upgrade CLIs * Update guide templates * Update channel upgrade test to match ibc-go changes * WIP: waiting for new channel states during upgrade to be implemented * Implement channel upgrade handshake * Add channel upgrade handshake test * Removed unnecessary logs * Update channel upgrade test doc * Add test to transfer ics29 packet after channel upgrade * Update tools/integration-test/src/tests/channel_upgrade/ics29.rs Co-authored-by: Sean Chen Signed-off-by: Luca Joss <43531661+ljoss17@users.noreply.github.com> * Add comments * Fix 'query bank balances' CLI to handle SDK v0.50 changes * Remove flush status from channel end * Update Nix flake and use alpha release of channel upgrade simapp for CI * Fix test-stable and change 'into_i32' to 'as_i32' for Channel State * Fix python tests * Use state comparison method 'less_or_equal_progress' where applicable * Add tests for channel upgrade completion * Improve less_or_equal method for channel states and add unit tests * Use automatic link for URL in channel State documentation * Add comment on channel upgrade open assertion --------- Signed-off-by: Luca Joss <43531661+ljoss17@users.noreply.github.com> Co-authored-by: Sean Chen --- .github/workflows/integration.yaml | 2 +- Cargo.lock | 8 +- .../src/core/ics04_channel/channel.rs | 250 ++++--- .../src/core/ics04_channel/events.rs | 46 +- .../src/core/ics04_channel/flush_status.rs | 73 -- .../src/core/ics04_channel/mod.rs | 1 - .../msgs/chan_upgrade_confirm.rs | 2 +- .../ics04_channel/msgs/chan_upgrade_open.rs | 4 +- crates/relayer-types/src/events.rs | 13 +- crates/relayer/src/chain/counterparty.rs | 6 +- crates/relayer/src/channel.rs | 67 +- crates/relayer/src/connection.rs | 4 +- crates/relayer/src/event.rs | 14 +- .../src/event/source/websocket/extract.rs | 5 + crates/relayer/src/link.rs | 4 +- crates/relayer/src/object.rs | 33 + crates/relayer/src/supervisor.rs | 24 + crates/relayer/src/supervisor/spawn.rs | 4 +- crates/relayer/src/worker/channel.rs | 47 +- e2e/e2e/channel.py | 10 +- flake.lock | 6 +- flake.nix | 76 +-- .../commands/hermes/tx/chan-upgrade-try_1.md | 2 +- .../src/tests/channel_upgrade/ics29.rs | 220 ++++++ .../channel_upgrade/manual_channel_upgrade.rs | 183 ----- .../src/tests/channel_upgrade/mod.rs | 4 +- .../channel_upgrade/upgrade_handshake.rs | 116 ++++ .../upgrade_handshake_steps.rs | 644 ++++++++++++++++++ tools/test-framework/src/chain/cli/query.rs | 70 +- tools/test-framework/src/relayer/channel.rs | 59 +- 30 files changed, 1472 insertions(+), 525 deletions(-) delete mode 100644 crates/relayer-types/src/core/ics04_channel/flush_status.rs create mode 100644 tools/integration-test/src/tests/channel_upgrade/ics29.rs delete mode 100644 tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs create mode 100644 tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs create mode 100644 tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 85659b5eae..89912a5d17 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -425,7 +425,7 @@ jobs: fail-fast: false matrix: chain: - - package: ibc-go-v7-channel-upgrade + - package: ibc-go-v8-channel-upgrade-simapp command: simd account_prefix: cosmos steps: diff --git a/Cargo.lock b/Cargo.lock index d9378af793..9b6e5ded21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1372,8 +1372,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725fd83c94e9859fd967cd706996679799171eba940740f071f0046fb6f6e031" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#f2745837ae445d431e8e48e5fd0bef14b2cf4585" dependencies = [ "base64 0.21.4", "bytes", @@ -4185,8 +4184,3 @@ dependencies = [ "quote", "syn 2.0.38", ] - -[[patch.unused]] -name = "ibc-proto" -version = "0.33.0" -source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#a3cad9102eeae2d356054b2a5c55298213f9405d" diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 2cc4705398..f30f6714c0 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -7,12 +7,12 @@ use ibc_proto::protobuf::Protobuf; use serde::{Deserialize, Serialize}; use ibc_proto::ibc::core::channel::v1::{ - Channel as RawChannel, Counterparty as RawCounterparty, FlushStatus as RawFlushStatus, + Channel as RawChannel, Counterparty as RawCounterparty, IdentifiedChannel as RawIdentifiedChannel, }; use crate::core::ics04_channel::packet::Sequence; -use crate::core::ics04_channel::{error::Error, flush_status::FlushStatus, version::Version}; +use crate::core::ics04_channel::{error::Error, version::Version}; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] @@ -45,7 +45,6 @@ impl TryFrom for IdentifiedChannelEnd { connection_hops: value.connection_hops, version: value.version, upgrade_sequence: 0, // FIXME: proto IdentifiedChannel does not have this field, should we default to 0 ? - flush_status: 0, }; Ok(IdentifiedChannelEnd { @@ -59,7 +58,7 @@ impl TryFrom for IdentifiedChannelEnd { impl From for RawIdentifiedChannel { fn from(value: IdentifiedChannelEnd) -> Self { RawIdentifiedChannel { - state: value.channel_end.state as i32, + state: value.channel_end.state.as_i32(), ordering: value.channel_end.ordering as i32, counterparty: Some(value.channel_end.counterparty().clone().into()), connection_hops: value @@ -83,7 +82,6 @@ pub struct ChannelEnd { pub connection_hops: Vec, pub version: Version, pub upgraded_sequence: Sequence, - pub flush_status: FlushStatus, } impl Display for ChannelEnd { @@ -105,7 +103,6 @@ impl Default for ChannelEnd { connection_hops: Vec::new(), version: Version::default(), upgraded_sequence: Sequence::from(0), // The value of 0 indicates the channel has never been upgraded - flush_status: FlushStatus::NotinflushUnspecified, } } } @@ -140,8 +137,6 @@ impl TryFrom for ChannelEnd { let version = value.version.into(); - let flush_status = FlushStatus::try_from(value.flush_status)?; - Ok(ChannelEnd::new( chan_state, chan_ordering, @@ -149,7 +144,6 @@ impl TryFrom for ChannelEnd { connection_hops, version, Sequence::from(value.upgrade_sequence), - flush_status, )) } } @@ -157,7 +151,7 @@ impl TryFrom for ChannelEnd { impl From for RawChannel { fn from(value: ChannelEnd) -> Self { RawChannel { - state: value.state as i32, + state: value.state.as_i32(), ordering: value.ordering as i32, counterparty: Some(value.counterparty().clone().into()), connection_hops: value @@ -167,7 +161,6 @@ impl From for RawChannel { .collect(), version: value.version.to_string(), upgrade_sequence: value.upgraded_sequence.into(), - flush_status: RawFlushStatus::from(value.flush_status).into(), } } } @@ -181,7 +174,6 @@ impl ChannelEnd { connection_hops: Vec, version: Version, upgraded_sequence: Sequence, - flush_status: FlushStatus, ) -> Self { Self { state, @@ -190,7 +182,6 @@ impl ChannelEnd { connection_hops, version, upgraded_sequence, - flush_status, } } @@ -207,19 +198,17 @@ impl ChannelEnd { self.remote.channel_id = Some(c); } - /// Returns `true` if this `ChannelEnd` is in state [`State::Open`]. + /// Returns `true` if this `ChannelEnd` is in state [`State::Open`] + /// [`State::Open(UpgradeState::Upgrading)`] is only used in the channel upgrade + /// handshake so this method matches with [`State::Open(UpgradeState::NotUpgrading)`]. pub fn is_open(&self) -> bool { - self.state_matches(&State::Open) + self.state_matches(&State::Open(UpgradeState::NotUpgrading)) } pub fn state(&self) -> &State { &self.state } - pub fn flush_status(&self) -> &FlushStatus { - &self.flush_status - } - pub fn ordering(&self) -> &Ordering { &self.ordering } @@ -251,11 +240,6 @@ impl ChannelEnd { self.state() == other } - /// Helper function to compare the flush status of this end with another flush status. - pub fn flush_status_matches(&self, other: &FlushStatus) -> bool { - self.flush_status() == other - } - /// Helper function to compare the order of this end with another order. pub fn order_matches(&self, other: &Ordering) -> bool { self.ordering() == other @@ -397,6 +381,15 @@ impl FromStr for Ordering { } } +/// This enum is used to differentiate if a channel is being upgraded when +/// a `UpgradeInitChannel` or a `UpgradeOpenChannel` is received. +/// See `handshake_step` method in `crates/relayer/src/channel.rs`. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub enum UpgradeState { + Upgrading, + NotUpgrading, +} + /// The possible state variants that a channel can exhibit. /// /// These are encoded with integer discriminants so that there is @@ -407,34 +400,25 @@ impl FromStr for Ordering { #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum State { /// Default state - Uninitialized = 0, + Uninitialized, /// A channel has just started the opening handshake. - Init = 1, + Init, /// A channel has acknowledged the handshake step on the counterparty chain. - TryOpen = 2, + TryOpen, /// A channel has completed the handshake step. Open channels are ready to /// send and receive packets. - Open = 3, + /// During some steps of channel upgrades, the state is still in Open. The + /// `UpgradeState` is used to differentiate these states during the upgrade + /// handshake. + /// + Open(UpgradeState), /// A channel has been closed and can no longer be used to send or receive /// packets. - Closed = 4, + Closed, /// A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. - Flushing = 5, + Flushing, /// A channel has just completed flushing any in-flight packets. - Flushcomplete = 6, - /// A channel has just started the upgrade handshake. The chain that is - /// proposing the upgrade should set the channel state from OPEN to INITUPGRADE. - InitUpgrade = 7, - /// A channel has acknowledged the upgrade handshake step on the counterparty chain. - /// The counterparty chain that accepts the upgrade should set the channel state from - /// OPEN to TRYUPGRADE. - /// The counterparty chain blocks new packets until the channel upgrade is done or cancelled. - TryUpgrade = 8, - /// A channel has confirmed the upgrade handshake step on the counterparty chain. - /// The chain that confirmed the upgrade should set the channel state from - /// INITUPGRADE to ACKUPGRADE. - /// The chain blocks new packets until the channel upgrade is done or cancelled. - AckUpgrade = 9, + Flushcomplete, } impl State { @@ -444,13 +428,10 @@ impl State { Self::Uninitialized => "UNINITIALIZED", Self::Init => "INIT", Self::TryOpen => "TRYOPEN", - Self::Open => "OPEN", + Self::Open(_) => "OPEN", Self::Closed => "CLOSED", Self::Flushing => "FLUSHING", Self::Flushcomplete => "FLUSHCOMPLETE", - Self::InitUpgrade => "INITUPGRADE", - Self::TryUpgrade => "TRYUPGRADE", - Self::AckUpgrade => "ACKUPGRADE", } } @@ -460,20 +441,30 @@ impl State { 0 => Ok(Self::Uninitialized), 1 => Ok(Self::Init), 2 => Ok(Self::TryOpen), - 3 => Ok(Self::Open), + 3 => Ok(Self::Open(UpgradeState::NotUpgrading)), 4 => Ok(Self::Closed), 5 => Ok(Self::Flushing), 6 => Ok(Self::Flushcomplete), - 7 => Ok(Self::InitUpgrade), - 8 => Ok(Self::TryUpgrade), - 9 => Ok(Self::AckUpgrade), _ => Err(Error::unknown_state(s)), } } + // Parses the State out from a i32. + pub fn as_i32(&self) -> i32 { + match self { + State::Uninitialized => 0, + State::Init => 1, + State::TryOpen => 2, + State::Open(_) => 3, + State::Closed => 4, + State::Flushing => 5, + State::Flushcomplete => 6, + } + } + /// Returns whether or not this channel state is `Open`. pub fn is_open(self) -> bool { - self == State::Open + self == State::Open(UpgradeState::NotUpgrading) } /// Returns whether or not this channel state is `Closed`. @@ -483,6 +474,7 @@ impl State { /// Returns whether or not the channel with this state /// has progressed less or the same than the argument. + /// This only takes into account the open channel handshake. /// /// # Example /// ```rust,ignore @@ -498,31 +490,23 @@ impl State { Init => !matches!(other, Uninitialized), TryOpen => !matches!(other, Uninitialized | Init), - Open => !matches!(other, Uninitialized | Init | TryOpen), + Open(UpgradeState::NotUpgrading) => !matches!(other, Uninitialized | Init | TryOpen), + _ => false, + } + } - Flushing => !matches!(other, Uninitialized | Init | TryOpen | Open), - Flushcomplete => !matches!(other, Uninitialized | Init | TryOpen | Open | Flushing), - InitUpgrade => !matches!( - other, - Uninitialized | Init | TryOpen | Open | Flushing | Flushcomplete - ), - TryUpgrade => !matches!( - other, - Uninitialized | Init | TryOpen | Open | Flushing | Flushcomplete | InitUpgrade - ), - AckUpgrade => !matches!( + /// Returns whether or not the channel with this state is + /// being upgraded. + pub fn is_upgrading(self, other: Self) -> bool { + use State::*; + + match self { + Open(UpgradeState::NotUpgrading) => matches!( other, - Uninitialized - | Init - | TryOpen - | Open - | Flushing - | Flushcomplete - | InitUpgrade - | TryUpgrade + Open(UpgradeState::Upgrading) | Flushing | Flushcomplete ), - - Closed => false, + Open(UpgradeState::Upgrading) | Flushing | Flushcomplete => true, + _ => false, } } } @@ -559,7 +543,6 @@ pub mod test_util { connection_hops: vec![ConnectionId::default().to_string()], version: "ics20".to_string(), // The version is not validated. upgrade_sequence: 0, // The value of 0 indicates the channel has never been upgraded - flush_status: 0, } } } @@ -700,4 +683,119 @@ mod tests { } } } + + #[test] + fn less_or_equal_progress_uninitialized() { + use crate::core::ics04_channel::channel::State; + use crate::core::ics04_channel::channel::UpgradeState; + + let higher_or_equal_states = vec![ + State::Uninitialized, + State::Init, + State::TryOpen, + State::Open(UpgradeState::NotUpgrading), + State::Open(UpgradeState::Upgrading), + State::Closed, + State::Flushing, + State::Flushcomplete, + ]; + for state in higher_or_equal_states { + assert!(State::Uninitialized.less_or_equal_progress(state)) + } + } + + #[test] + fn less_or_equal_progress_init() { + use crate::core::ics04_channel::channel::State; + use crate::core::ics04_channel::channel::UpgradeState; + + let lower_states = vec![State::Uninitialized]; + let higher_or_equal_states = vec![ + State::Init, + State::TryOpen, + State::Open(UpgradeState::NotUpgrading), + State::Open(UpgradeState::Upgrading), + State::Closed, + State::Flushing, + State::Flushcomplete, + ]; + for state in lower_states { + assert!(!State::Init.less_or_equal_progress(state)); + } + for state in higher_or_equal_states { + assert!(State::Init.less_or_equal_progress(state)) + } + } + + #[test] + fn less_or_equal_progress_tryopen() { + use crate::core::ics04_channel::channel::State; + use crate::core::ics04_channel::channel::UpgradeState; + + let lower_states = vec![State::Uninitialized, State::Init]; + let higher_or_equal_states = vec![ + State::TryOpen, + State::Open(UpgradeState::NotUpgrading), + State::Open(UpgradeState::Upgrading), + State::Closed, + State::Flushing, + State::Flushcomplete, + ]; + for state in lower_states { + assert!(!State::TryOpen.less_or_equal_progress(state)); + } + for state in higher_or_equal_states { + assert!(State::TryOpen.less_or_equal_progress(state)) + } + } + + #[test] + fn less_or_equal_progress_open_not_upgrading() { + use crate::core::ics04_channel::channel::State; + use crate::core::ics04_channel::channel::UpgradeState; + + let lower_states = vec![State::Uninitialized, State::Init, State::TryOpen]; + let higher_or_equal_states = vec![ + State::Open(UpgradeState::NotUpgrading), + State::Open(UpgradeState::Upgrading), + State::Closed, + State::Flushing, + State::Flushcomplete, + ]; + for state in lower_states { + assert!(!State::Open(UpgradeState::NotUpgrading).less_or_equal_progress(state)); + } + for state in higher_or_equal_states { + assert!(State::Open(UpgradeState::NotUpgrading).less_or_equal_progress(state)) + } + } + + #[test] + fn less_or_equal_progress_upgrading_states() { + use crate::core::ics04_channel::channel::State; + use crate::core::ics04_channel::channel::UpgradeState; + + let states = [ + State::Uninitialized, + State::Init, + State::TryOpen, + State::Open(UpgradeState::NotUpgrading), + State::Open(UpgradeState::Upgrading), + State::Closed, + State::Flushing, + State::Flushcomplete, + ]; + + let upgrading_states = vec![ + State::Open(UpgradeState::Upgrading), + State::Closed, + State::Flushing, + State::Flushcomplete, + ]; + for upgrade_state in upgrading_states { + for state in states.iter() { + assert!(!upgrade_state.less_or_equal_progress(*state)); + } + } + } } diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index e231089d49..0e466e17d2 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -7,7 +7,6 @@ use tendermint::abci; use crate::core::ics04_channel::channel::Ordering; use crate::core::ics04_channel::error::Error; -use crate::core::ics04_channel::flush_status::FlushStatus; use crate::core::ics04_channel::packet::Packet; use crate::core::ics04_channel::packet::Sequence; use crate::core::ics04_channel::version::Version; @@ -146,10 +145,16 @@ pub struct UpgradeAttributes { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, - pub channel_flush_status: FlushStatus, } -impl UpgradeAttributes {} +impl UpgradeAttributes { + pub fn port_id(&self) -> &PortId { + &self.port_id + } + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } +} impl Display for UpgradeAttributes { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { @@ -573,7 +578,6 @@ pub struct UpgradeInit { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, - pub channel_flush_status: FlushStatus, } impl Display for UpgradeInit { @@ -588,8 +592,8 @@ impl Display for UpgradeInit { } write!( f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering ) } } @@ -605,7 +609,6 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - channel_flush_status: ev.channel_flush_status, } } } @@ -651,7 +654,6 @@ impl TryFrom for UpgradeInit { upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, upgrade_ordering: attrs.upgrade_ordering, - channel_flush_status: attrs.channel_flush_status, }) } } @@ -678,7 +680,6 @@ pub struct UpgradeTry { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, - pub channel_flush_status: FlushStatus, } impl Display for UpgradeTry { @@ -693,8 +694,8 @@ impl Display for UpgradeTry { } write!( f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering ) } } @@ -710,7 +711,6 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - channel_flush_status: ev.channel_flush_status, } } } @@ -756,7 +756,6 @@ impl TryFrom for UpgradeTry { upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, upgrade_ordering: attrs.upgrade_ordering, - channel_flush_status: attrs.channel_flush_status, }) } } @@ -783,7 +782,6 @@ pub struct UpgradeAck { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, - pub channel_flush_status: FlushStatus, } impl Display for UpgradeAck { @@ -798,8 +796,8 @@ impl Display for UpgradeAck { } write!( f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering ) } } @@ -815,7 +813,6 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - channel_flush_status: ev.channel_flush_status, } } } @@ -861,7 +858,6 @@ impl TryFrom for UpgradeAck { upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, upgrade_ordering: attrs.upgrade_ordering, - channel_flush_status: attrs.channel_flush_status, }) } } @@ -888,7 +884,6 @@ pub struct UpgradeConfirm { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, - pub channel_flush_status: FlushStatus, } impl Display for UpgradeConfirm { @@ -903,8 +898,8 @@ impl Display for UpgradeConfirm { } write!( f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering ) } } @@ -920,7 +915,6 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - channel_flush_status: ev.channel_flush_status, } } } @@ -966,7 +960,6 @@ impl TryFrom for UpgradeConfirm { upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, upgrade_ordering: attrs.upgrade_ordering, - channel_flush_status: attrs.channel_flush_status, }) } } @@ -993,7 +986,6 @@ pub struct UpgradeOpen { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, - pub channel_flush_status: FlushStatus, } impl Display for UpgradeOpen { @@ -1008,8 +1000,8 @@ impl Display for UpgradeOpen { } write!( f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, channel_flush_status: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.channel_flush_status + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering ) } } @@ -1025,7 +1017,6 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - channel_flush_status: ev.channel_flush_status, } } } @@ -1071,7 +1062,6 @@ impl TryFrom for UpgradeOpen { upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, upgrade_ordering: attrs.upgrade_ordering, - channel_flush_status: attrs.channel_flush_status, }) } } diff --git a/crates/relayer-types/src/core/ics04_channel/flush_status.rs b/crates/relayer-types/src/core/ics04_channel/flush_status.rs deleted file mode 100644 index 80cfb172d3..0000000000 --- a/crates/relayer-types/src/core/ics04_channel/flush_status.rs +++ /dev/null @@ -1,73 +0,0 @@ -use std::fmt::Display; -use std::fmt::Error as FmtError; -use std::fmt::Formatter; -use std::str::FromStr; - -use serde::Deserialize; -use serde::Serialize; - -use ibc_proto::ibc::core::channel::v1::FlushStatus as RawFlushStatus; - -use crate::core::ics04_channel::error::Error; - -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub enum FlushStatus { - #[default] - NotinflushUnspecified = 0, - Flushing = 1, - Flushcomplete = 2, -} - -impl Display for FlushStatus { - fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { - match self { - FlushStatus::NotinflushUnspecified => write!(f, "FLUSH_STATUS_NOTINFLUSH_UNSPECIFIED"), - FlushStatus::Flushing => write!(f, "FLUSH_STATUS_FLUSHING"), - FlushStatus::Flushcomplete => write!(f, "FLUSH_STATUS_FLUSHCOMPLETE"), - } - } -} - -impl FromStr for FlushStatus { - type Err = Error; - - fn from_str(s: &str) -> Result { - match s.to_lowercase().trim_start_matches("flush_status_") { - "notinflush_unspecified" => Ok(Self::NotinflushUnspecified), - "flushing" => Ok(Self::Flushing), - "flushcomplete" => Ok(Self::Flushcomplete), - _ => Err(Error::unknown_flush_status_type(s.to_string())), - } - } -} - -impl TryFrom for FlushStatus { - type Error = Error; - - fn try_from(value: RawFlushStatus) -> Result { - value.try_into() - } -} - -impl From for RawFlushStatus { - fn from(value: FlushStatus) -> Self { - match value { - FlushStatus::NotinflushUnspecified => RawFlushStatus::NotinflushUnspecified, - FlushStatus::Flushing => RawFlushStatus::Flushing, - FlushStatus::Flushcomplete => RawFlushStatus::Flushcomplete, - } - } -} - -impl TryFrom for FlushStatus { - type Error = Error; - - fn try_from(value: i32) -> Result { - match value { - 0 => Ok(FlushStatus::NotinflushUnspecified), - 1 => Ok(FlushStatus::Flushing), - 2 => Ok(FlushStatus::Flushcomplete), - _ => Err(Error::unknown_flush_status(value)), - } - } -} diff --git a/crates/relayer-types/src/core/ics04_channel/mod.rs b/crates/relayer-types/src/core/ics04_channel/mod.rs index b3abac8a4b..018a0608de 100644 --- a/crates/relayer-types/src/core/ics04_channel/mod.rs +++ b/crates/relayer-types/src/core/ics04_channel/mod.rs @@ -5,7 +5,6 @@ pub mod channel; pub mod commitment; pub mod error; pub mod events; -pub mod flush_status; pub mod msgs; pub mod packet; pub mod packet_id; diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs index fb3c0ed1eb..3ae7856a13 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs @@ -108,7 +108,7 @@ impl From for RawMsgChannelUpgradeConfirm { RawMsgChannelUpgradeConfirm { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), - counterparty_channel_state: domain_msg.counterparty_channel_state as i32, + counterparty_channel_state: domain_msg.counterparty_channel_state.as_i32(), counterparty_upgrade: Some(domain_msg.counterparty_upgrade.into()), proof_upgrade: domain_msg.proof_upgrade.into(), proof_channel: domain_msg.proof_channel.into(), diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs index 841a97ee45..a33ba54851 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs @@ -90,7 +90,7 @@ impl From for RawMsgChannelUpgradeOpen { RawMsgChannelUpgradeOpen { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), - counterparty_channel_state: domain_msg.counterparty_channel_state as i32, + counterparty_channel_state: domain_msg.counterparty_channel_state.as_i32(), proof_channel: domain_msg.proof_channel.into(), proof_height: Some(domain_msg.proof_height.into()), signer: domain_msg.signer.to_string(), @@ -111,7 +111,7 @@ pub mod test_util { RawMsgChannelUpgradeOpen { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), - counterparty_channel_state: 7, // AckUpgrade + counterparty_channel_state: 6, // Flushcomplete proof_channel: get_dummy_proof(), proof_height: Some(RawHeight { revision_number: 1, diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index 5a36c572a1..caff7a421a 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -19,8 +19,8 @@ use crate::core::ics03_connection::error as connection_error; use crate::core::ics03_connection::events as ConnectionEvents; use crate::core::ics03_connection::events::Attributes as ConnectionAttributes; use crate::core::ics04_channel::error as channel_error; -use crate::core::ics04_channel::events as ChannelEvents; use crate::core::ics04_channel::events::Attributes as ChannelAttributes; +use crate::core::ics04_channel::events::{self as ChannelEvents, UpgradeAttributes}; use crate::core::ics04_channel::packet::Packet; use crate::core::ics24_host::error::ValidationError; use crate::timestamp::ParseTimestampError; @@ -450,6 +450,17 @@ impl IbcEvent { } } + pub fn channel_upgrade_attributes(self) -> Option { + match self { + IbcEvent::UpgradeInitChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeTryChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeAckChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeConfirmChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeOpenChannel(ev) => Some(ev.into()), + _ => None, + } + } + pub fn connection_attributes(&self) -> Option<&ConnectionAttributes> { match self { IbcEvent::OpenInitConnection(ev) => Some(ev.attributes()), diff --git a/crates/relayer/src/chain/counterparty.rs b/crates/relayer/src/chain/counterparty.rs index ac34d84f40..f1fcc7cd14 100644 --- a/crates/relayer/src/chain/counterparty.rs +++ b/crates/relayer/src/chain/counterparty.rs @@ -295,7 +295,11 @@ pub fn channel_on_destination( channel_id: remote_channel_id.clone(), height: QueryHeight::Latest, }, - IncludeProof::No, + // IncludeProof::Yes forces a new query when the CachingChainHandle + // is used. + // TODO: Pass the BaseChainHandle instead of the CachingChainHandle + // to the channel worker to avoid querying for a Proof . + IncludeProof::Yes, ) .map(|(c, _)| IdentifiedChannelEnd { port_id: channel.channel_end.counterparty().port_id().clone(), diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 318fc593cb..8c46816278 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,6 +1,5 @@ pub use error::ChannelError; use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; -use ibc_relayer_types::core::ics04_channel::flush_status::FlushStatus; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_ack::MsgChannelUpgradeAck; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_confirm::MsgChannelUpgradeConfirm; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_open::MsgChannelUpgradeOpen; @@ -15,7 +14,7 @@ use serde::Serialize; use tracing::{debug, error, info, warn}; use ibc_relayer_types::core::ics04_channel::channel::{ - ChannelEnd, Counterparty, IdentifiedChannelEnd, Ordering, State, + ChannelEnd, Counterparty, IdentifiedChannelEnd, Ordering, State, UpgradeState, }; use ibc_relayer_types::core::ics04_channel::msgs::chan_close_confirm::MsgChannelCloseConfirm; use ibc_relayer_types::core::ics04_channel::msgs::chan_close_init::MsgChannelCloseInit; @@ -309,7 +308,11 @@ impl Channel { channel_id: channel.src_channel_id.clone(), height: QueryHeight::Specific(height), }, - IncludeProof::No, + // IncludeProof::Yes forces a new query when the CachingChainHandle + // is used. + // TODO: Pass the BaseChainHandle instead of the CachingChainHandle + // to the channel worker to avoid querying for a Proof . + IncludeProof::Yes, ) .map_err(ChannelError::relayer)?; @@ -673,7 +676,7 @@ impl Channel { } // send the Confirm message to chain B (destination) - (State::Open, State::TryOpen) => { + (State::Open(UpgradeState::NotUpgrading), State::TryOpen) => { self.build_chan_open_confirm_and_send().map_err(|e| { error!("failed ChanOpenConfirm {}: {}", self.b_side, e); e @@ -681,7 +684,7 @@ impl Channel { } // send the Confirm message to chain A (source) - (State::TryOpen, State::Open) => { + (State::TryOpen, State::Open(UpgradeState::NotUpgrading)) => { self.flipped() .build_chan_open_confirm_and_send() .map_err(|e| { @@ -690,7 +693,7 @@ impl Channel { })?; } - (State::Open, State::Open) => { + (State::Open(UpgradeState::NotUpgrading), State::Open(UpgradeState::NotUpgrading)) => { info!("channel handshake already finished for {}", self); return Ok(()); } @@ -767,17 +770,33 @@ impl Channel { (State::Init, State::Init) => Some(self.build_chan_open_try_and_send()?), (State::TryOpen, State::Init) => Some(self.build_chan_open_ack_and_send()?), (State::TryOpen, State::TryOpen) => Some(self.build_chan_open_ack_and_send()?), - (State::Open, State::TryOpen) => Some(self.build_chan_open_confirm_and_send()?), - (State::Open, State::Open) => return Ok((None, Next::Abort)), + (State::Open(UpgradeState::NotUpgrading), State::TryOpen) => { + Some(self.build_chan_open_confirm_and_send()?) + } + (State::Open(UpgradeState::NotUpgrading), State::Open(_)) => { + return Ok((None, Next::Abort)) + } // If the counterparty state is already Open but current state is TryOpen, // return anyway as the final step is to be done by the counterparty worker. - (State::TryOpen, State::Open) => return Ok((None, Next::Abort)), + (State::TryOpen, State::Open(_)) => return Ok((None, Next::Abort)), // Close handshake steps (State::Closed, State::Closed) => return Ok((None, Next::Abort)), (State::Closed, _) => Some(self.build_chan_close_confirm_and_send()?), + // Channel Upgrade handshake steps + (State::Open(UpgradeState::Upgrading), State::Open(_)) => { + Some(self.build_chan_upgrade_try_and_send()?) + } + (State::Flushing, State::Open(_)) => Some(self.build_chan_upgrade_ack_and_send()?), + (State::Flushcomplete, State::Flushing) => { + Some(self.build_chan_upgrade_confirm_and_send()?) + } + (State::Open(_), State::Flushcomplete) => { + Some(self.build_chan_upgrade_open_and_send()?) + } + _ => None, }; @@ -786,7 +805,9 @@ impl Channel { match event { Some(IbcEvent::OpenConfirmChannel(_)) | Some(IbcEvent::OpenAckChannel(_)) - | Some(IbcEvent::CloseConfirmChannel(_)) => Ok((event, Next::Abort)), + | Some(IbcEvent::CloseConfirmChannel(_)) + | Some(IbcEvent::UpgradeConfirmChannel(_)) + | Some(IbcEvent::UpgradeOpenChannel(_)) => Ok((event, Next::Abort)), _ => Ok((event, Next::Continue)), } } @@ -817,9 +838,14 @@ impl Channel { let state = match event { IbcEvent::OpenInitChannel(_) => State::Init, IbcEvent::OpenTryChannel(_) => State::TryOpen, - IbcEvent::OpenAckChannel(_) => State::Open, - IbcEvent::OpenConfirmChannel(_) => State::Open, + IbcEvent::OpenAckChannel(_) => State::Open(UpgradeState::NotUpgrading), + IbcEvent::OpenConfirmChannel(_) => State::Open(UpgradeState::NotUpgrading), IbcEvent::CloseInitChannel(_) => State::Closed, + IbcEvent::UpgradeInitChannel(_) => State::Open(UpgradeState::Upgrading), + IbcEvent::UpgradeTryChannel(_) => State::Flushing, + IbcEvent::UpgradeAckChannel(_) => State::Flushcomplete, + IbcEvent::UpgradeConfirmChannel(_) => State::Flushcomplete, + IbcEvent::UpgradeOpenChannel(_) => State::Open(UpgradeState::Upgrading), _ => State::Uninitialized, }; @@ -871,7 +897,6 @@ impl Channel { vec![self.dst_connection_id().clone()], version, Sequence::from(0), - FlushStatus::NotinflushUnspecified, ); // Build the domain type message @@ -941,7 +966,7 @@ impl Channel { let highest_state = match msg_type { ChannelMsgType::OpenAck => State::TryOpen, ChannelMsgType::OpenConfirm => State::TryOpen, - ChannelMsgType::CloseConfirm => State::Open, + ChannelMsgType::CloseConfirm => State::Open(UpgradeState::NotUpgrading), _ => State::Uninitialized, }; @@ -952,7 +977,6 @@ impl Channel { vec![self.dst_connection_id().clone()], Version::empty(), Sequence::from(0), - FlushStatus::NotinflushUnspecified, // UPGRADE TODO check ); // Retrieve existing channel @@ -1045,7 +1069,6 @@ impl Channel { vec![self.dst_connection_id().clone()], version, Sequence::from(0), - FlushStatus::NotinflushUnspecified, // UPGRADE TODO check ); // Get signer @@ -1508,9 +1531,9 @@ impl Channel { ) .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; - if channel_end.state != State::Open { + if channel_end.state != State::Open(UpgradeState::NotUpgrading) { return Err(ChannelError::invalid_channel_upgrade_state( - State::Open.to_string(), + State::Open(UpgradeState::NotUpgrading).to_string(), channel_end.state.to_string(), )); } @@ -1687,9 +1710,9 @@ impl Channel { )); } - if channel_end.state != State::Open { + if channel_end.state != State::Open(UpgradeState::NotUpgrading) { return Err(ChannelError::invalid_channel_upgrade_state( - State::Open.to_string(), + State::Open(UpgradeState::NotUpgrading).to_string(), channel_end.state.to_string(), )); } @@ -2108,7 +2131,9 @@ fn check_destination_channel_state( existing_channel.connection_hops() == expected_channel.connection_hops(); // TODO: Refactor into a method - let good_state = *existing_channel.state() as u32 <= *expected_channel.state() as u32; + let good_state = existing_channel + .state() + .less_or_equal_progress(*expected_channel.state()); let good_channel_port_ids = existing_channel.counterparty().channel_id().is_none() || existing_channel.counterparty().channel_id() == expected_channel.counterparty().channel_id() diff --git a/crates/relayer/src/connection.rs b/crates/relayer/src/connection.rs index 341049446b..52326ad937 100644 --- a/crates/relayer/src/connection.rs +++ b/crates/relayer/src/connection.rs @@ -1365,7 +1365,9 @@ fn check_destination_connection_state( && existing_connection.counterparty().client_id() == expected_connection.counterparty().client_id(); - let good_state = *existing_connection.state() as u32 <= *expected_connection.state() as u32; + let good_state = existing_connection + .state() + .less_or_equal_progress(*expected_connection.state()); let good_connection_ids = existing_connection.counterparty().connection_id().is_none() || existing_connection.counterparty().connection_id() diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index 181c452c7a..a1771e56ff 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -5,6 +5,10 @@ use tendermint::abci::Event as AbciEvent; use ibc_relayer_types::{ applications::ics29_fee::events::{DistributeFeePacket, IncentivizedPacket}, applications::ics31_icq::events::CrossChainQueryPacket, + core::ics03_connection::{ + error::Error as ConnectionError, + events::{self as connection_events, Attributes as ConnectionAttributes}, + }, core::ics04_channel::{ error::Error as ChannelError, events::{ @@ -24,13 +28,6 @@ use ibc_relayer_types::{ ics04_channel::{channel::Ordering, packet::Sequence, version::Version}, ics24_host::identifier::ConnectionId, }, - core::{ - ics03_connection::{ - error::Error as ConnectionError, - events::{self as connection_events, Attributes as ConnectionAttributes}, - }, - ics04_channel::flush_status::FlushStatus, - }, events::{Error as IbcEventError, IbcEvent, IbcEventType}, Height, }; @@ -516,9 +513,6 @@ fn channel_upgrade_extract_attributes_from_tx( channel_events::UPGRADE_ORDERING => { attr.upgrade_ordering = Ordering::from_str(value)?; } - channel_events::CHANNEL_FLUSH_STATUS => { - attr.channel_flush_status = FlushStatus::from_str(value)?; - } _ => {} } } diff --git a/crates/relayer/src/event/source/websocket/extract.rs b/crates/relayer/src/event/source/websocket/extract.rs index ad8db55b6a..9530cd8122 100644 --- a/crates/relayer/src/event/source/websocket/extract.rs +++ b/crates/relayer/src/event/source/websocket/extract.rs @@ -235,6 +235,11 @@ fn event_is_type_channel(ev: &IbcEvent) -> bool { | IbcEvent::OpenConfirmChannel(_) | IbcEvent::CloseInitChannel(_) | IbcEvent::CloseConfirmChannel(_) + | IbcEvent::UpgradeInitChannel(_) + | IbcEvent::UpgradeTryChannel(_) + | IbcEvent::UpgradeAckChannel(_) + | IbcEvent::UpgradeConfirmChannel(_) + | IbcEvent::UpgradeOpenChannel(_) | IbcEvent::SendPacket(_) | IbcEvent::ReceivePacket(_) | IbcEvent::WriteAcknowledgement(_) diff --git a/crates/relayer/src/link.rs b/crates/relayer/src/link.rs index 5e9716aee4..1ed7dc7df3 100644 --- a/crates/relayer/src/link.rs +++ b/crates/relayer/src/link.rs @@ -1,6 +1,6 @@ use ibc_relayer_types::core::{ ics03_connection::connection::State as ConnectionState, - ics04_channel::channel::State as ChannelState, + ics04_channel::channel::{State as ChannelState, UpgradeState}, ics24_host::identifier::{ChannelId, PortChannelId, PortId}, }; use tracing::info; @@ -77,7 +77,7 @@ impl Link { ) })?; - if !a_channel.state_matches(&ChannelState::Open) + if !a_channel.state_matches(&ChannelState::Open(UpgradeState::NotUpgrading)) && !a_channel.state_matches(&ChannelState::Closed) { return Err(LinkError::invalid_channel_state( diff --git a/crates/relayer/src/object.rs b/crates/relayer/src/object.rs index 9f7349734d..eea5e2f60c 100644 --- a/crates/relayer/src/object.rs +++ b/crates/relayer/src/object.rs @@ -1,6 +1,7 @@ use std::fmt::Display; use flex_error::define_error; +use ibc_relayer_types::core::ics04_channel::events::UpgradeAttributes; use serde::{Deserialize, Serialize}; use ibc_relayer_types::applications::ics29_fee::events::IncentivizedPacket; @@ -460,6 +461,38 @@ impl Object { .into()) } + pub fn channel_from_chan_upgrade_events( + attributes: &UpgradeAttributes, + src_chain: &impl ChainHandle, + allow_non_open_connection: bool, + ) -> Result { + let channel_id = attributes.channel_id(); + + let port_id = attributes.port_id(); + + let dst_chain_id = if allow_non_open_connection { + // Get the destination chain allowing for the possibility that the connection is not yet open. + // This is to support the optimistic channel handshake by allowing the channel worker to get + // the channel events while the connection is being established. + // The channel worker will eventually finish the channel handshake via the retry mechanism. + channel_connection_client_no_checks(src_chain, port_id, channel_id) + .map(|c| c.client.client_state.chain_id()) + .map_err(ObjectError::supervisor)? + } else { + channel_connection_client(src_chain, port_id, channel_id) + .map(|c| c.client.client_state.chain_id()) + .map_err(ObjectError::supervisor)? + }; + + Ok(Channel { + dst_chain_id, + src_chain_id: src_chain.id(), + src_channel_id: channel_id.clone(), + src_port_id: port_id.clone(), + } + .into()) + } + /// Build the object associated with the given [`SendPacket`] event. pub fn for_send_packet( e: &SendPacket, diff --git a/crates/relayer/src/supervisor.rs b/crates/relayer/src/supervisor.rs index 8a28d07605..37c42acbfb 100644 --- a/crates/relayer/src/supervisor.rs +++ b/crates/relayer/src/supervisor.rs @@ -539,6 +539,30 @@ pub fn collect_events( || Object::client_from_chan_open_events(&attributes, src_chain).ok(), ); } + IbcEvent::UpgradeInitChannel(..) + | IbcEvent::UpgradeTryChannel(..) + | IbcEvent::UpgradeAckChannel(..) + | IbcEvent::UpgradeOpenChannel(..) => { + collect_event( + &mut collected, + event_with_height.clone(), + mode.channels.enabled, + || { + event_with_height + .event + .clone() + .channel_upgrade_attributes() + .and_then(|attr| { + Object::channel_from_chan_upgrade_events( + &attr, + src_chain, + mode.connections.enabled, + ) + .ok() + }) + }, + ); + } IbcEvent::SendPacket(ref packet) => { collect_event( &mut collected, diff --git a/crates/relayer/src/supervisor/spawn.rs b/crates/relayer/src/supervisor/spawn.rs index c7ffd2a240..eb5499b272 100644 --- a/crates/relayer/src/supervisor/spawn.rs +++ b/crates/relayer/src/supervisor/spawn.rs @@ -315,6 +315,8 @@ impl<'a, Chain: ChainHandle> SpawnContext<'a, Chain> { let open_handshake = chan_state_dst.less_or_equal_progress(ChannelState::TryOpen) && chan_state_dst.less_or_equal_progress(chan_state_src); + let upgrade_handshake = chan_state_dst.is_upgrading(chan_state_src); + // Determine if close handshake is required, i.e. if channel state on source is `Closed`, // and on destination channel state is not `Closed, and there are no pending packets. // If there are pending packets on destination then we let the packet worker clear the @@ -322,7 +324,7 @@ impl<'a, Chain: ChainHandle> SpawnContext<'a, Chain> { let close_handshake = chan_state_src.is_closed() && !chan_state_dst.is_closed() && !has_packets(); - if open_handshake || close_handshake { + if open_handshake || upgrade_handshake || close_handshake { // create worker for channel handshake that will advance the counterparty state let channel_object = Object::Channel(Channel { dst_chain_id: counterparty_chain.id(), diff --git a/crates/relayer/src/worker/channel.rs b/crates/relayer/src/worker/channel.rs index a6204a3df4..84a84e233b 100644 --- a/crates/relayer/src/worker/channel.rs +++ b/crates/relayer/src/worker/channel.rs @@ -1,5 +1,6 @@ use core::time::Duration; use crossbeam_channel::Receiver; +use ibc_relayer_types::events::IbcEventType; use tracing::{debug, error_span}; use crate::channel::{channel_handshake_retry, Channel as RelayChannel}; @@ -49,19 +50,39 @@ pub fn spawn_channel_worker( complete_handshake_on_new_block = false; if let Some(event_with_height) = last_event { - retry_with_index( - channel_handshake_retry::default_strategy(max_block_times), - |index| match RelayChannel::restore_from_event( - chains.a.clone(), - chains.b.clone(), - event_with_height.event.clone(), - ) { - Ok(mut handshake_channel) => handshake_channel - .step_event(&event_with_height.event, index), - Err(_) => RetryResult::Retry(index), - }, - ) - .map_err(|e| TaskError::Fatal(RunError::retry(e))) + match event_with_height.event.event_type() { + IbcEventType::UpgradeInitChannel + | IbcEventType::UpgradeTryChannel + | IbcEventType::UpgradeAckChannel + | IbcEventType::UpgradeConfirmChannel + | IbcEventType::UpgradeOpenChannel => retry_with_index( + channel_handshake_retry::default_strategy(max_block_times), + |index| match RelayChannel::restore_from_state( + chains.a.clone(), + chains.b.clone(), + channel.clone(), + event_with_height.height, + ) { + Ok((mut handshake_channel, _)) => handshake_channel + .step_event(&event_with_height.event, index), + Err(_) => RetryResult::Retry(index), + }, + ) + .map_err(|e| TaskError::Fatal(RunError::retry(e))), + _ => retry_with_index( + channel_handshake_retry::default_strategy(max_block_times), + |index| match RelayChannel::restore_from_event( + chains.a.clone(), + chains.b.clone(), + event_with_height.event.clone(), + ) { + Ok(mut handshake_channel) => handshake_channel + .step_event(&event_with_height.event, index), + Err(_) => RetryResult::Retry(index), + }, + ) + .map_err(|e| TaskError::Fatal(RunError::retry(e))), + } } else { Ok(Next::Continue) } diff --git a/e2e/e2e/channel.py b/e2e/e2e/channel.py index 0036ae7fa3..37f3871aee 100644 --- a/e2e/e2e/channel.py +++ b/e2e/e2e/channel.py @@ -472,15 +472,17 @@ def handshake( split() a_chan_end = query_channel_end(c, side_a, port_id, a_chan_id) - if a_chan_end.state != 'Open': + expected_state = str({'Open': 'NotUpgrading'}) + if str(a_chan_end.state) != str({'Open': 'NotUpgrading'}): l.error( - f'Channel end with id {a_chan_id} on chain {side_a} is not in Open state, got: {a_chan_end.state}') + f"Channel end with id {a_chan_id} on chain {side_a} is not in {expected_state} state, got: {a_chan_end.state}") exit(1) b_chan_end = query_channel_end(c, side_b, port_id, b_chan_id) - if b_chan_end.state != 'Open': + print(b_chan_end.state) + if str(b_chan_end.state) != str({'Open': 'NotUpgrading'}): l.error( - f'Channel end with id {b_chan_id} on chain {side_b} is not in Open state, got: {b_chan_end.state}') + f'Channel end with id {b_chan_id} on chain {side_b} is not in {expected_state} state, got: {b_chan_end.state}') exit(1) a_chan_ends = query_channel_ends(c, side_a, port_id, a_chan_id) diff --git a/flake.lock b/flake.lock index 6c1750e11d..48b6fb9850 100644 --- a/flake.lock +++ b/flake.lock @@ -896,11 +896,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1696757521, - "narHash": "sha256-cfgtLNCBLFx2qOzRLI6DHfqTdfWI+UbvsKYa3b3fvaA=", + "lastModified": 1697009197, + "narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2646b294a146df2781b1ca49092450e8a32814e1", + "rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index bba0185745..1fa649d7d7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,54 +4,54 @@ inputs = { nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable; flake-utils.url = github:numtide/flake-utils; - cosmos-nix.url = github:informalsystems/cosmos.nix/ibc-go-channel-upgrade; + cosmos-nix.url = github:informalsystems/cosmos.nix; }; outputs = inputs: let - utils = inputs.flake-utils.lib; - in + utils = inputs.flake-utils.lib; + in utils.eachSystem - [ - "aarch64-linux" - "aarch64-darwin" - "x86_64-darwin" - "x86_64-linux" - ] + [ + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + "x86_64-linux" + ] (system: let - nixpkgs = import inputs.nixpkgs { - inherit system; - }; + nixpkgs = import inputs.nixpkgs { + inherit system; + }; - cosmos-nix = inputs.cosmos-nix.packages.${system}; + cosmos-nix = inputs.cosmos-nix.packages.${system}; in { - packages = { + packages = { inherit (cosmos-nix) gaia6-ordered gaia12 - osmosis - wasmd - ibc-go-v2-simapp - ibc-go-v3-simapp - ibc-go-v4-simapp - ibc-go-v5-simapp - ibc-go-v6-simapp - ibc-go-v7-simapp - ibc-go-v7-channel-upgrade - apalache - evmos - juno - stride - stride-no-admin - stride-consumer-no-admin - stride-consumer - migaloo - neutron - ; + osmosis + wasmd + ibc-go-v2-simapp + ibc-go-v3-simapp + ibc-go-v4-simapp + ibc-go-v5-simapp + ibc-go-v6-simapp + ibc-go-v7-simapp + ibc-go-v8-channel-upgrade-simapp + apalache + evmos + juno + stride + stride-no-admin + stride-consumer-no-admin + stride-consumer + migaloo + neutron + ; - python = nixpkgs.python3.withPackages (p: [ - p.toml - ]); - }; - }); + python = nixpkgs.python3.withPackages (p: [ + p.toml + ]); + }; + }); } diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md index 57a55e65ea..a2f0e74436 100644 --- a/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-try_1.md @@ -1 +1 @@ -[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-try --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-try --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] diff --git a/tools/integration-test/src/tests/channel_upgrade/ics29.rs b/tools/integration-test/src/tests/channel_upgrade/ics29.rs new file mode 100644 index 0000000000..cdcae198fa --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/ics29.rs @@ -0,0 +1,220 @@ +//! Tests channel upgrade fetures: +//! +//! - `ChannelUpgradeICS29` tests that only after the upgrade handshake is completed +//! and the channel version has been updated to ICS29 can Incentivized packets be +//! relayed. + +use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_test_framework::prelude::*; +use ibc_test_framework::relayer::channel::{ + assert_eventually_channel_established, assert_eventually_channel_upgrade_open, + ChannelUpgradableAttributes, +}; +use ibc_test_framework::util::random::random_u128_range; + +#[test] +fn test_channel_upgrade_ics29() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeICS29) +} + +pub struct ChannelUpgradeICS29; + +impl TestOverrides for ChannelUpgradeICS29 { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + config.mode.packets.auto_register_counterparty_payee = true; + config.mode.packets.clear_interval = 0; + config.mode.packets.clear_on_start = false; + + config.mode.clients.misbehaviour = false; + } +} + +impl BinaryChannelTest for ChannelUpgradeICS29 { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let chain_driver_a = chains.node_a.chain_driver(); + let chain_driver_b = chains.node_b.chain_driver(); + + let denom_a = chains.node_a.denom(); + + let port_a = channels.port_a.as_ref(); + let channel_id_a = channels.channel_id_a.as_ref(); + + let wallets_a = chains.node_a.wallets(); + let wallets_b = chains.node_b.wallets(); + + let relayer_a = wallets_a.relayer(); + + let user_a = wallets_a.user1(); + let user_b = wallets_b.user1(); + + let balance_a1 = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; + + let relayer_balance_a = chain_driver_a.query_balance(&relayer_a.address(), &denom_a)?; + + let send_amount = random_u128_range(1000, 2000); + let receive_fee = random_u128_range(300, 400); + let ack_fee = random_u128_range(200, 300); + let timeout_fee = random_u128_range(100, 200); + + let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; + + let balance_a2 = balance_a1 - total_sent; + + let ics29_transfer = chain_driver_a.ibc_token_transfer_with_fee( + &port_a, + &channel_id_a, + &user_a, + &user_b.address(), + &denom_a.with_amount(send_amount).as_ref(), + &denom_a.with_amount(receive_fee).as_ref(), + &denom_a.with_amount(ack_fee).as_ref(), + &denom_a.with_amount(timeout_fee).as_ref(), + Duration::from_secs(60), + ); + + assert!(ics29_transfer.is_err(), "{ics29_transfer:?}"); + + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + let new_ordering = None; + let new_connection_hops = None; + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + ); + + info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); + + // Note: Initialising a channel upgrade this way, without requiring a + // signature or proof of authority to perform the channel upgrade, will + // eventually be removed. + // Only authority (gov module or other) will be able to trigger a channel upgrade. + // See: https://github.com/cosmos/ibc-go/issues/4186 + channel.flipped().build_chan_upgrade_init_and_send( + Some(new_version), + new_ordering, + new_connection_hops, + )?; + + info!("Check that the channel upgrade successfully upgraded the version..."); + + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + // Since the channel has been updated to ICS29 version after the Hermes instance + // was started, the `auto_register_counterparty_payee` has not registered the + // counterparty payee. It is required to register it manually. + chain_driver_b.register_counterparty_payee( + &wallets_b.relayer(), + &relayer_a.address(), + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + { + let counterparty_payee = chain_driver_b.query_counterparty_payee( + &channels.channel_id_b.as_ref(), + &wallets_b.relayer().address(), + )?; + + assert_eq( + "counterparty address should match registered address", + &counterparty_payee, + &Some(relayer_a.address().cloned()), + )?; + } + + chain_driver_a.ibc_token_transfer_with_fee( + &port_a, + &channel_id_a, + &user_a, + &user_b.address(), + &denom_a.with_amount(send_amount).as_ref(), + &denom_a.with_amount(receive_fee).as_ref(), + &denom_a.with_amount(ack_fee).as_ref(), + &denom_a.with_amount(timeout_fee).as_ref(), + Duration::from_secs(60), + )?; + + let denom_b = derive_ibc_denom( + &channels.port_b.as_ref(), + &channels.channel_id_b.as_ref(), + &denom_a, + )?; + + chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; + + chain_driver_b.assert_eventual_wallet_amount( + &user_b.address(), + &denom_b.with_amount(send_amount).as_ref(), + )?; + + chain_driver_a.assert_eventual_wallet_amount( + &user_a.address(), + &(balance_a2 + timeout_fee).as_ref(), + )?; + + chain_driver_a.assert_eventual_wallet_amount( + &relayer_a.address(), + &(relayer_balance_a + ack_fee + receive_fee).as_ref(), + )?; + + Ok(()) + } +} diff --git a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs b/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs deleted file mode 100644 index db7d60c4f0..0000000000 --- a/tools/integration-test/src/tests/channel_upgrade/manual_channel_upgrade.rs +++ /dev/null @@ -1,183 +0,0 @@ -//! Tests the successful channel upgrade handshake: -//! -//! - `ChannelUpgradeManualHandshake` tests that after the channel can be upgraded -//! without relaying on the supervisor. This test manually calls the INIT, TRY, -//! ACK and CONFIRM steps. - -use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; -use ibc_relayer_types::core::ics04_channel::version::Version; -use ibc_test_framework::prelude::*; -use ibc_test_framework::relayer::channel::{ - assert_eventually_channel_established, assert_eventually_channel_upgrade_ack, - assert_eventually_channel_upgrade_confirm, assert_eventually_channel_upgrade_init, - assert_eventually_channel_upgrade_open, assert_eventually_channel_upgrade_try, - ChannelUpgradableAttributes, -}; - -#[test] -fn test_channel_upgrade_manual_handshake() -> Result<(), Error> { - run_binary_channel_test(&ChannelUpgradeManualHandshake) -} - -pub struct ChannelUpgradeManualHandshake; - -impl TestOverrides for ChannelUpgradeManualHandshake { - fn should_spawn_supervisor(&self) -> bool { - false - } -} - -impl BinaryChannelTest for ChannelUpgradeManualHandshake { - fn run( - &self, - _config: &TestConfig, - _relayer: RelayerDriver, - chains: ConnectedChains, - channels: ConnectedChannel, - ) -> Result<(), Error> { - info!("Check that channels are both in OPEN State"); - - assert_eventually_channel_established( - &chains.handle_b, - &chains.handle_a, - &channels.channel_id_b.as_ref(), - &channels.port_b.as_ref(), - )?; - - let channel_end_a = chains - .handle_a - .query_channel( - QueryChannelRequest { - port_id: channels.port_a.0.clone(), - channel_id: channels.channel_id_a.0.clone(), - height: QueryHeight::Latest, - }, - IncludeProof::No, - ) - .map(|(channel_end, _)| channel_end) - .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; - - let channel_end_b = chains - .handle_b - .query_channel( - QueryChannelRequest { - port_id: channels.port_b.0.clone(), - channel_id: channels.channel_id_b.0.clone(), - height: QueryHeight::Latest, - }, - IncludeProof::No, - ) - .map(|(channel_end, _)| channel_end) - .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; - - let old_version = channel_end_a.version; - let old_ordering = channel_end_a.ordering; - let old_connection_hops_a = channel_end_a.connection_hops; - let old_connection_hops_b = channel_end_b.connection_hops; - - let channel = channels.channel; - let new_version = Version::ics20_with_fee(); - let new_ordering = None; - let new_connection_hops = None; - - let old_attrs = ChannelUpgradableAttributes::new( - old_version.clone(), - old_version.clone(), - old_ordering, - old_connection_hops_a.clone(), - old_connection_hops_b.clone(), - ); - - let interm_attrs = ChannelUpgradableAttributes::new( - old_version, - new_version.clone(), - old_ordering, - old_connection_hops_a.clone(), - old_connection_hops_b.clone(), - ); - - let upgraded_attrs = ChannelUpgradableAttributes::new( - new_version.clone(), - new_version.clone(), - old_ordering, - old_connection_hops_a, - old_connection_hops_b, - ); - - info!("Will run ChanUpgradeInit step..."); - - channel.flipped().build_chan_upgrade_init_and_send( - Some(new_version), - new_ordering, - new_connection_hops, - )?; - - info!("Check that the step ChanUpgradeInit was correctly executed..."); - - assert_eventually_channel_upgrade_init( - &chains.handle_a, - &chains.handle_b, - &channels.channel_id_a.as_ref(), - &channels.port_a.as_ref(), - &old_attrs, - )?; - - info!("Will run ChanUpgradeTry step..."); - - channel.build_chan_upgrade_try_and_send()?; - - info!("Check that the step ChanUpgradeTry was correctly executed..."); - - assert_eventually_channel_upgrade_try( - &chains.handle_b, - &chains.handle_a, - &channels.channel_id_b.as_ref(), - &channels.port_b.as_ref(), - &old_attrs.flipped(), - )?; - - info!("Will run ChanUpgradeAck step..."); - - channel.flipped().build_chan_upgrade_ack_and_send()?; - - info!("Check that the step ChanUpgradeAck was correctly executed..."); - - assert_eventually_channel_upgrade_ack( - &chains.handle_a, - &chains.handle_b, - &channels.channel_id_a.as_ref(), - &channels.port_a.as_ref(), - &old_attrs, - )?; - - info!("Will run ChanUpgradeConfirm step..."); - - channel.build_chan_upgrade_confirm_and_send()?; - - info!("Check that the step ChanUpgradeConfirm was correctly executed..."); - - assert_eventually_channel_upgrade_confirm( - &chains.handle_b, - &chains.handle_a, - &channels.channel_id_b.as_ref(), - &channels.port_b.as_ref(), - &interm_attrs.flipped(), - )?; - - info!("Will run ChanUpgradeOpen step..."); - - channel.flipped().build_chan_upgrade_open_and_send()?; - - info!("Check that the ChanUpgradeOpen steps were correctly executed..."); - - assert_eventually_channel_upgrade_open( - &chains.handle_a, - &chains.handle_b, - &channels.channel_id_a.as_ref(), - &channels.port_a.as_ref(), - &upgraded_attrs, - )?; - - Ok(()) - } -} diff --git a/tools/integration-test/src/tests/channel_upgrade/mod.rs b/tools/integration-test/src/tests/channel_upgrade/mod.rs index f5fee49272..158224819b 100644 --- a/tools/integration-test/src/tests/channel_upgrade/mod.rs +++ b/tools/integration-test/src/tests/channel_upgrade/mod.rs @@ -1 +1,3 @@ -pub mod manual_channel_upgrade; +pub mod ics29; +pub mod upgrade_handshake; +pub mod upgrade_handshake_steps; diff --git a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs new file mode 100644 index 0000000000..b0e100b422 --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs @@ -0,0 +1,116 @@ +//! Tests channel upgrade: +//! +//! - `ChannelUpgradeHandshake` tests that after the upgrade handshake is completed +//! after initialising the upgrade with `build_chan_upgrade_init_and_send` without +//! any in-flight packets. + +use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_test_framework::prelude::*; +use ibc_test_framework::relayer::channel::{ + assert_eventually_channel_established, assert_eventually_channel_upgrade_open, + ChannelUpgradableAttributes, +}; + +#[test] +fn test_channel_upgrade_handshake() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshake) +} + +pub struct ChannelUpgradeHandshake; + +impl TestOverrides for ChannelUpgradeHandshake { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + } +} + +impl BinaryChannelTest for ChannelUpgradeHandshake { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + let new_ordering = None; + let new_connection_hops = None; + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + ); + + info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); + + // Note: Initialising a channel upgrade this way, without requiring a + // signature or proof of authority to perform the channel upgrade, will + // eventually be removed. + // Only authority (gov module or other) will be able to trigger a channel upgrade. + // See: https://github.com/cosmos/ibc-go/issues/4186 + channel.flipped().build_chan_upgrade_init_and_send( + Some(new_version), + new_ordering, + new_connection_hops, + )?; + + info!("Check that the channel upgrade successfully upgraded the version..."); + + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have been correctly updated. + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + } +} diff --git a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs new file mode 100644 index 0000000000..6c76d57638 --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs @@ -0,0 +1,644 @@ +//! Tests channel upgrade: +//! +//! - `ChannelUpgradeManualHandshake` tests each step of the channel upgrade manually, +//! without relaying on the supervisor. +//! +//! - `ChannelUpgradeHandshakeFromTry` tests that the channel worker will finish the +//! upgrade handshake if the channel is being upgraded and is at the Try step. +//! +//! - `ChannelUpgradeHandshakeFromAck` tests that the channel worker will finish the +//! upgrade handshake if the channel is being upgraded and is at the Ack step. +//! +//! - `ChannelUpgradeHandshakeFromConfirm` tests that the channel worker will finish the +//! upgrade handshake if the channel is being upgraded and is at the Confirm step. + +use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_test_framework::prelude::*; +use ibc_test_framework::relayer::channel::{ + assert_eventually_channel_established, assert_eventually_channel_upgrade_ack, + assert_eventually_channel_upgrade_confirm, assert_eventually_channel_upgrade_init, + assert_eventually_channel_upgrade_open, assert_eventually_channel_upgrade_try, + ChannelUpgradableAttributes, +}; + +#[test] +fn test_channel_upgrade_manual_handshake() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeManualHandshake) +} + +#[test] +fn test_channel_upgrade_handshake_from_try() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeFromTry) +} + +#[test] +fn test_channel_upgrade_handshake_from_ack() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeFromAck) +} + +#[test] +fn test_channel_upgrade_handshake_from_confirm() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeFromConfirm) +} + +pub struct ChannelUpgradeManualHandshake; + +impl TestOverrides for ChannelUpgradeManualHandshake { + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeManualHandshake { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + let new_ordering = None; + let new_connection_hops = None; + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let interm_attrs = ChannelUpgradableAttributes::new( + old_version, + new_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + ); + + info!("Will run ChanUpgradeInit step..."); + + // Note: Initialising a channel upgrade this way, without requiring a + // signature or proof of authority to perform the channel upgrade, will + // eventually be removed. + // Only authority (gov module or other) will be able to trigger a channel upgrade. + // See: https://github.com/cosmos/ibc-go/issues/4186 + channel.flipped().build_chan_upgrade_init_and_send( + Some(new_version), + new_ordering, + new_connection_hops, + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + assert_eventually_channel_upgrade_init( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + info!("Will run ChanUpgradeConfirm step..."); + + channel.build_chan_upgrade_confirm_and_send()?; + + info!("Check that the step ChanUpgradeConfirm was correctly executed..."); + + assert_eventually_channel_upgrade_confirm( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &interm_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeOpen step..."); + + channel.flipped().build_chan_upgrade_open_and_send()?; + + info!("Check that the ChanUpgradeOpen steps were correctly executed..."); + + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have been correctly updated. + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + } +} + +pub struct ChannelUpgradeHandshakeFromTry; + +impl TestOverrides for ChannelUpgradeHandshakeFromTry { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeHandshakeFromTry { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + let new_ordering = None; + let new_connection_hops = None; + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + ); + + info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); + + // Note: Initialising a channel upgrade this way, without requiring a + // signature or proof of authority to perform the channel upgrade, will + // eventually be removed. + // Only authority (gov module or other) will be able to trigger a channel upgrade. + // See: https://github.com/cosmos/ibc-go/issues/4186 + channel.flipped().build_chan_upgrade_init_and_send( + Some(new_version), + new_ordering, + new_connection_hops, + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + info!("Check that the channel upgrade successfully upgraded the version..."); + + relayer.with_supervisor(|| { + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have been correctly updated. + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + }) + } +} + +pub struct ChannelUpgradeHandshakeFromAck; + +impl TestOverrides for ChannelUpgradeHandshakeFromAck { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeHandshakeFromAck { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + let new_ordering = None; + let new_connection_hops = None; + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + ); + + info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); + + // Note: Initialising a channel upgrade this way, without requiring a + // signature or proof of authority to perform the channel upgrade, will + // eventually be removed. + // Only authority (gov module or other) will be able to trigger a channel upgrade. + // See: https://github.com/cosmos/ibc-go/issues/4186 + channel.flipped().build_chan_upgrade_init_and_send( + Some(new_version), + new_ordering, + new_connection_hops, + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + info!("Check that the channel upgrade successfully upgraded the version..."); + + relayer.with_supervisor(|| { + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have been correctly updated. + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + }) + } +} +pub struct ChannelUpgradeHandshakeFromConfirm; + +impl TestOverrides for ChannelUpgradeHandshakeFromConfirm { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + let new_ordering = None; + let new_connection_hops = None; + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let interm_attrs = ChannelUpgradableAttributes::new( + old_version, + new_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + ); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a, + old_connection_hops_b, + ); + + info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); + + // Note: Initialising a channel upgrade this way, without requiring a + // signature or proof of authority to perform the channel upgrade, will + // eventually be removed. + // Only authority (gov module or other) will be able to trigger a channel upgrade. + // See: https://github.com/cosmos/ibc-go/issues/4186 + channel.flipped().build_chan_upgrade_init_and_send( + Some(new_version), + new_ordering, + new_connection_hops, + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + info!("Will run ChanUpgradeConfirm step..."); + + channel.build_chan_upgrade_confirm_and_send()?; + + info!("Check that the step ChanUpgradeConfirm was correctly executed..."); + + assert_eventually_channel_upgrade_confirm( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &interm_attrs.flipped(), + )?; + + info!("Check that the channel upgrade successfully upgraded the version..."); + + relayer.with_supervisor(|| { + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have been correctly updated. + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + }) + } +} diff --git a/tools/test-framework/src/chain/cli/query.rs b/tools/test-framework/src/chain/cli/query.rs index 8029d23929..9bf90f81bf 100644 --- a/tools/test-framework/src/chain/cli/query.rs +++ b/tools/test-framework/src/chain/cli/query.rs @@ -14,7 +14,9 @@ pub fn query_balance( wallet_id: &str, denom: &str, ) -> Result { - let res = simple_exec( + // SDK v0.50 has removed the `--denom` flag from the `query bank balances` CLI. + // It also changed the JSON output. + match simple_exec( chain_id, command_path, &[ @@ -29,20 +31,64 @@ pub fn query_balance( "--output", "json", ], - )? - .stdout; + ) { + Ok(output) => { + let amount_str = json::from_str::(&output.stdout) + .map_err(handle_generic_error)? + .get("amount") + .ok_or_else(|| eyre!("expected amount field"))? + .as_str() + .ok_or_else(|| eyre!("expected string field"))? + .to_string(); - let amount_str = json::from_str::(&res) - .map_err(handle_generic_error)? - .get("amount") - .ok_or_else(|| eyre!("expected amount field"))? - .as_str() - .ok_or_else(|| eyre!("expected string field"))? - .to_string(); + let amount = Amount::from_str(&amount_str).map_err(handle_generic_error)?; + + Ok(amount) + } + Err(_) => { + let res = simple_exec( + chain_id, + command_path, + &[ + "--node", + rpc_listen_address, + "query", + "bank", + "balances", + wallet_id, + "--output", + "json", + ], + )? + .stdout; + let amounts_array = + json::from_str::(&res).map_err(handle_generic_error)?; - let amount = Amount::from_str(&amount_str).map_err(handle_generic_error)?; + let balances = amounts_array + .get("balances") + .ok_or_else(|| eyre!("expected balances field"))? + .as_array() + .ok_or_else(|| eyre!("expected array field"))?; - Ok(amount) + let amount_str = balances + .iter() + .find(|a| { + a.get("denom") + .ok_or_else(|| eyre!("expected denom field")) + .unwrap() + == denom + }) + .ok_or_else(|| eyre!("no entry with denom `{denom}` found"))? + .get("amount") + .ok_or_else(|| eyre!("expected amount field"))? + .as_str() + .ok_or_else(|| eyre!("expected amount to be in string format"))?; + + let amount = Amount::from_str(amount_str).map_err(handle_generic_error)?; + + Ok(amount) + } + } } /** diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index 42ed7f9670..637ec1f195 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -4,9 +4,8 @@ use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; use ibc_relayer::channel::{extract_channel_id, Channel, ChannelSide}; use ibc_relayer_types::core::ics04_channel::channel::{ - ChannelEnd, IdentifiedChannelEnd, Ordering, State as ChannelState, + ChannelEnd, IdentifiedChannelEnd, Ordering, State as ChannelState, UpgradeState, }; -use ibc_relayer_types::core::ics04_channel::flush_status::FlushStatus; use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::ConnectionId; @@ -240,7 +239,10 @@ pub fn assert_eventually_channel_established( a_side_state: ChannelState, b_side_state: ChannelState, - a_side_flush_status: FlushStatus, - b_side_flush_status: FlushStatus, handle_a: &ChainA, handle_b: &ChainB, channel_id_a: &TaggedChannelIdRef, @@ -433,17 +426,6 @@ fn assert_channel_upgrade_state( ))); } - if !channel_end_a - .value() - .flush_status_matches(&a_side_flush_status) - { - return Err(Error::generic(eyre!( - "expected channel end A flush status to be `{}`, but is instead `{}`", - a_side_flush_status, - channel_end_a.value().flush_status() - ))); - } - if !channel_end_a .value() .version_matches(upgrade_attrs.version_a()) @@ -493,17 +475,6 @@ fn assert_channel_upgrade_state( ))); } - if !channel_end_b - .value() - .flush_status_matches(&b_side_flush_status) - { - return Err(Error::generic(eyre!( - "expected channel end B flush status to be `{}`, but is instead `{}`", - b_side_flush_status, - channel_end_b.value().flush_status() - ))); - } - if !channel_end_b .value() .version_matches(upgrade_attrs.version_b()) From 3f9d346abc30d7ac1eb5c0744f9506e34e474e14 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 6 Dec 2023 10:39:12 +0100 Subject: [PATCH 75/99] Update nix flake and remove log file --- flake.lock | 6 +- upgrade.log | 1722 --------------------------------------------------- 2 files changed, 3 insertions(+), 1725 deletions(-) delete mode 100644 upgrade.log diff --git a/flake.lock b/flake.lock index d138405994..874e699bf9 100644 --- a/flake.lock +++ b/flake.lock @@ -950,11 +950,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1701626906, - "narHash": "sha256-ugr1QyzzwNk505ICE4VMQzonHQ9QS5W33xF2FXzFQ00=", + "lastModified": 1701693815, + "narHash": "sha256-7BkrXykVWfkn6+c1EhFA3ko4MLi3gVG0p9G96PNnKTM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0c6d8c783336a59f4c59d4a6daed6ab269c4b361", + "rev": "09ec6a0881e1a36c29d67497693a67a16f4da573", "type": "github" }, "original": { diff --git a/upgrade.log b/upgrade.log deleted file mode 100644 index 17885dfc6b..0000000000 --- a/upgrade.log +++ /dev/null @@ -1,1722 +0,0 @@ - -running 6 tests -test tests::channel_upgrade::ics29::test_channel_upgrade_ics29 ... 2023-12-01T11:30:22.432542Z  INFO ibc_test_framework::framework::base: starting test with test config: TestConfig { chain_command_paths: ["simd"], account_prefixes: ["cosmos"], native_tokens: ["stake"], compat_modes: None, chain_store_dir: "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171", hang_on_fail: false, bootstrap_with_random_ids: false } -2023-12-01T11:30:25.674112Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos1443n98gd4yxeqfm696m640lwnvkxd25dsz0al5 amount 1624635601299340236samoleans succeed after 0 tries -2023-12-01T11:30:25.674165Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc1 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/ibc1 and RPC address http://localhost:61915. -2023-12-01T11:30:25.674187Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc1 - id: user1, address: cosmos1xs95ndvdqpndpu8wva30zlu7qm4k9k9qwsafmw -2023-12-01T11:30:25.674207Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/ibc1' --node http://localhost:61915 -2023-12-01T11:30:28.775735Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos1tuvpmz9qae5qk04vwzyve7qjr6tj9m236hvng2 amount 1649896583226704015samoleans succeed after 0 tries -2023-12-01T11:30:28.775799Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc2 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/ibc2 and RPC address http://localhost:55423. -2023-12-01T11:30:28.775808Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc2 - id: user1, address: cosmos10rfs4sg0vux0whgchfsu88x5zwm8d3sz2p25p4 -2023-12-01T11:30:28.775840Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/ibc2' --node http://localhost:55423 -2023-12-01T11:30:28.777477Z  INFO ibc_test_framework::bootstrap::binary::chain: written hermes config.toml to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/relayer-config.toml: -[global] -log_level = "info" - -[mode.clients] -enabled = true -refresh = true -misbehaviour = false - -[mode.connections] -enabled = false - -[mode.channels] -enabled = true - -[mode.packets] -enabled = true -clear_interval = 0 -clear_on_start = false -tx_confirmation = false -auto_register_counterparty_payee = true - -[rest] -enabled = false -host = "127.0.0.1" -port = 3000 - -[telemetry] -enabled = false -host = "127.0.0.1" -port = 3001 - -[telemetry.buckets.latency_submitted] -start = 500 -end = 20000 -buckets = 10 - -[telemetry.buckets.latency_confirmed] -start = 1000 -end = 30000 -buckets = 10 - -[[chains]] -type = "CosmosSdk" -id = "ibc1" -rpc_addr = "http://localhost:61915/" -grpc_addr = "http://localhost:21061/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:61915/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[[chains]] -type = "CosmosSdk" -id = "ibc2" -rpc_addr = "http://localhost:55423/" -grpc_addr = "http://localhost:63633/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:55423/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[tracing_server] -enabled = false -port = 5555 - -2023-12-01T11:30:39.482470Z  WARN ibc_telemetry: global telemetry state not set, will initialize it using default histogram ranges -2023-12-01T11:30:41.337125Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc1 to chain ibc2 with client id 07-tendermint-1 on chain ibc2 -2023-12-01T11:30:42.562673Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc2 to chain ibc1 with client id 07-tendermint-0 on chain ibc1 -2023-12-01T11:30:42.563217Z  INFO ibc_test_framework::framework::binary::chain: written chains environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/binary-chains.env -2023-12-01T11:30:43.478780Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-1, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-0 } }) at height 0-16 -2023-12-01T11:30:44.692542Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-1 } }) at height 0-20 -2023-12-01T11:30:50.877564Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenTryConnection(OpenTry { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-23 -2023-12-01T11:30:56.060850Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenAckConnection(OpenAck { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: connection-1, counterparty_client_id: 07-tendermint-1 } }) at height 0-31 -2023-12-01T11:31:01.023465Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenConfirmConnection(OpenConfirm { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-33 -2023-12-01T11:31:04.026205Z  INFO ibc_relayer::connection: connection handshake already finished for Connection { delay_period: 0ns, a_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0 }, b_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1 } } -2023-12-01T11:31:04.029261Z  INFO ibc_test_framework::bootstrap::binary::connection: created new chain/client/connection from ibc1/07-tendermint-0/connection-0 to ibc2/07-tendermint-1/connection-1 -2023-12-01T11:31:04.029603Z  INFO ibc_test_framework::framework::binary::connection: written connection environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/binary-connections.env -2023-12-01T11:31:05.243388Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-37 -2023-12-01T11:31:06.153563Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-41 -2023-12-01T11:31:10.291723Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-42 -2023-12-01T11:31:15.646214Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) at height 0-50 -2023-12-01T11:31:20.792506Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-52 -2023-12-01T11:31:23.795822Z  INFO ibc_relayer::channel: channel handshake already finished for Channel { ordering: ORDER_UNORDERED, a_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0, port_id: transfer, channel_id: channel-0, version: ics20-1 }, b_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1, port_id: transfer, channel_id: channel-1, version: ics20-1 }, connection_delay: 0ns } -2023-12-01T11:31:23.795887Z  INFO ibc_test_framework::bootstrap::binary::channel: created new chain/client/connection/channel from ibc1/07-tendermint-0/connection-0/channel-0 to ibc2/07-tendermint-1/connection-1/channel-1 -2023-12-01T11:31:23.796214Z  INFO ibc_test_framework::framework::binary::channel: written channel environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1122610171/binary-channels.env -2023-12-01T11:31:23.796364Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:31:23.796519Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:31:23.796531Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:31:23.799098Z  WARN scan.chain{chain=ibc1}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:31:23.799184Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:31:23.800583Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:31:23.804253Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:31:23.804390Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:31:23.804404Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:31:23.806735Z  WARN scan.chain{chain=ibc2}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:31:23.806818Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:31:23.808056Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:31:23.810378Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:31:23.815862Z  WARN scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: connection is not open, skipping scan of channels over this connection -2023-12-01T11:31:23.818895Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-1}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:31:23.822347Z  INFO ibc_relayer::supervisor: scanned chains: -2023-12-01T11:31:23.822943Z  INFO ibc_relayer::supervisor: # Chain: ibc1 - - Client: 07-tendermint-0 - * Connection: connection-0 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: OPEN - | Counterparty: channel-1 -# Chain: ibc2 - - Client: 07-tendermint-0 - - Client: 07-tendermint-1 - * Connection: connection-0 - | State: INIT - | Counterparty state: - * Connection: connection-1 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: INIT - | Counterparty: - + Channel: channel-1 - | Port: transfer - | State: OPEN - | Counterparty: channel-0 - -2023-12-01T11:31:23.823115Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc1 connection=connection-0 counterparty_chain=ibc2 -2023-12-01T11:31:23.823486Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc1 connection=connection-0 -2023-12-01T11:31:23.823531Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc1 connection=connection-0 -2023-12-01T11:31:23.823561Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is OPEN, state on destination chain is OPEN chain=ibc1 counterparty_chain=ibc2 channel=channel-0 -2023-12-01T11:31:23.825458Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned client worker: client::ibc2->ibc1:07-tendermint-0 -2023-12-01T11:31:23.830715Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc1 channel=channel-0 -2023-12-01T11:31:23.831395Z  INFO spawn:chain{chain=ibc1}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc1 -2023-12-01T11:31:23.833063Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is INIT, state on destination chain is UNINITIALIZED chain=ibc2 connection=connection-0 counterparty_chain=ibc1 -2023-12-01T11:31:23.834891Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-0 -2023-12-01T11:31:23.834967Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc2 connection=connection-1 counterparty_chain=ibc1 -2023-12-01T11:31:23.834996Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc2 connection=connection-1 -2023-12-01T11:31:23.835017Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-1 -2023-12-01T11:31:23.835046Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is INIT, state on destination chain is UNINITIALIZED chain=ibc2 counterparty_chain=ibc1 channel=channel-0 -2023-12-01T11:31:23.835149Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-0/transfer:ibc2->ibc1 -2023-12-01T11:31:23.835192Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-0 -2023-12-01T11:31:23.835218Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: channel is OPEN, state on destination chain is OPEN chain=ibc2 counterparty_chain=ibc1 channel=channel-1 -2023-12-01T11:31:23.838710Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: spawned client worker: client::ibc1->ibc2:07-tendermint-1 -2023-12-01T11:31:23.843093Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-1 -2023-12-01T11:31:23.843246Z  INFO spawn:chain{chain=ibc2}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc2 -2023-12-01T11:31:23.849417Z  INFO ibc_integration_test::tests::channel_upgrade::ics29: Check that channels are both in OPEN State -2023-12-01T11:31:24.855523Z  INFO ibc_test_framework::util::retry: task channel should eventually established succeed after 0 tries -2023-12-01T11:31:25.334928Z ERROR estimate_gas: ibc_relayer::chain::cosmos::estimate: failed to simulate tx. propagating error to caller: gRPC call `send_tx_simulate` failed with status: status: Unknown, message: "failed to execute message; message index: 0: fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled [cosmos/cosmos-sdk@v0.50.0-rc.0.0.20230915171831-2196edacb99d/baseapp/baseapp.go:970] With gas wanted: '18446744073709551615' and gas used: '66708' ", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "59"} } -2023-12-01T11:31:25.335122Z  INFO ibc_integration_test::tests::channel_upgrade::ics29: Will initialise upgrade handshake by sending the ChanUpgradeInit step... -2023-12-01T11:31:25.942338Z  INFO ibc_relayer::channel: 👋 ibc1 => UpgradeInitChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-60 -2023-12-01T11:31:25.942388Z  INFO ibc_integration_test::tests::channel_upgrade::ics29: Check that the channel upgrade successfully upgraded the version... -2023-12-01T11:31:26.878064Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: 🎊 ibc1 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-61 -2023-12-01T11:31:26.878145Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:31:26.878936Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeInitChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:26.883259Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:31:27.222066Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: event: OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:31:28.971055Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: 🎊 ibc2 => OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) at height 0-60 -2023-12-01T11:31:28.971105Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) -2023-12-01T11:31:29.897210Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: 👋 ibc2 => UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-61 -2023-12-01T11:31:29.897266Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:30.255887Z  WARN worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: event: UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:30.258026Z  WARN worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: build_chan_upgrade_ack for channel channel-1 and port transfer -2023-12-01T11:31:30.302681Z  WARN spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: event: OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) -2023-12-01T11:31:32.110516Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: 👋 ibc1 => UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-66 -2023-12-01T11:31:32.110564Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:33.037425Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: 🎊 ibc1 => OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-67 -2023-12-01T11:31:33.037497Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:31:33.440351Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:33.442785Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_confirm for channel channel-0 and port transfer -2023-12-01T11:31:35.100184Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: 👋 ibc2 => UpgradeConfirmChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [], upgrade_version: , upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-66 -2023-12-01T11:31:35.100267Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: UpgradeConfirmChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [], upgrade_version: , upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:35.711605Z  WARN worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:37.157674Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: 👋 ibc1 => UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-71 -2023-12-01T11:31:37.157730Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:31:37.158796Z  INFO ibc_test_framework::util::retry: task channel upgrade open step should be done succeed after 9 tries -2023-12-01T11:31:40.152117Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.packet.cmd{src_chain=ibc1 src_port=transfer src_channel=channel-0 dst_chain=ibc2}:relay{odata=ac2f9267 ->Destination @0-73; len=1}: ibc_relayer::link::operational_data: assembled batch of 2 message(s) -2023-12-01T11:31:40.159237Z ERROR worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.packet.cmd{src_chain=ibc1 src_port=transfer src_channel=channel-0 dst_chain=ibc2}:relay{odata=ac2f9267 ->Destination @0-73; len=1}:send_messages_and_wait_check_tx{chain=ibc2 tracking_id=ac2f9267}:send_tx_with_account_sequence_retry{chain=ibc2 account.sequence=12}:estimate_gas: ibc_relayer::chain::cosmos::estimate: failed to simulate tx. propagating error to caller: gRPC call `send_tx_simulate` failed with status: status: Unknown, message: "account sequence mismatch, expected 13, got 12: incorrect account sequence [cosmos/cosmos-sdk@v0.50.0-rc.0.0.20230915171831-2196edacb99d/x/auth/ante/sigverify.go:290] With gas wanted: '18446744073709551615' and gas used: '51930' ", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "71"} } -2023-12-01T11:31:40.159318Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.packet.cmd{src_chain=ibc1 src_port=transfer src_channel=channel-0 dst_chain=ibc2}:relay{odata=ac2f9267 ->Destination @0-73; len=1}:send_messages_and_wait_check_tx{chain=ibc2 tracking_id=ac2f9267}:send_tx_with_account_sequence_retry{chain=ibc2 account.sequence=12}: ibc_relayer::chain::cosmos::retry: failed to estimate gas because of a mismatched account sequence number, refreshing account sequence number and retrying once error=gRPC call `send_tx_simulate` failed with status: status: Unknown, message: "account sequence mismatch, expected 13, got 12: incorrect account sequence [cosmos/cosmos-sdk@v0.50.0-rc.0.0.20230915171831-2196edacb99d/x/auth/ante/sigverify.go:290] With gas wanted: '18446744073709551615' and gas used: '51930' ", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "71"} } - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:31:40.160529Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.packet.cmd{src_chain=ibc1 src_port=transfer src_channel=channel-0 dst_chain=ibc2}:relay{odata=ac2f9267 ->Destination @0-73; len=1}:send_messages_and_wait_check_tx{chain=ibc2 tracking_id=ac2f9267}:send_tx_with_account_sequence_retry{chain=ibc2 account.sequence=12}: ibc_relayer::chain::cosmos::query::account: refreshed account sequence number old=12 new=13 -2023-12-01T11:31:40.460765Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos1xs95ndvdqpndpu8wva30zlu7qm4k9k9qwsafmw amount 1624635601299338005samoleans succeed after 0 tries -2023-12-01T11:31:40.467059Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.packet.cmd{src_chain=ibc1 src_port=transfer src_channel=channel-0 dst_chain=ibc2}:relay{odata=ac2f9267 ->Destination @0-73; len=1}: ibc_relayer::link::relay_sender: response(s): 1; Ok:AC87C1763554D61BB9E49C2A2861C778AF9F36E08F1935C256A9451902011569 target_chain=ibc2 -2023-12-01T11:31:40.467101Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.packet.cmd{src_chain=ibc1 src_port=transfer src_channel=channel-0 dst_chain=ibc2}:relay{odata=ac2f9267 ->Destination @0-73; len=1}: ibc_relayer::link::relay_path: submitted -2023-12-01T11:31:41.605623Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos10rfs4sg0vux0whgchfsu88x5zwm8d3sz2p25p4 amount 1427ibc/C1840BD16FCFA8F421DAA0DAAB08B9C323FC7685D0D7951DC37B3F9ECB08A199 succeed after 0 tries -2023-12-01T11:31:42.147913Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.packet.cmd{src_chain=ibc2 src_port=transfer src_channel=channel-1 dst_chain=ibc1}:relay{odata=1cc1f1a9 ->Destination @0-72; len=1}: ibc_relayer::link::operational_data: assembled batch of 2 message(s) -2023-12-01T11:31:42.156410Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.packet.cmd{src_chain=ibc2 src_port=transfer src_channel=channel-1 dst_chain=ibc1}:relay{odata=1cc1f1a9 ->Destination @0-72; len=1}: ibc_relayer::link::relay_sender: response(s): 1; Ok:D984D230C9DDDE2ED47561BCDA700E09BBA128737510DDA5DB07754CB5AD580C target_chain=ibc1 -2023-12-01T11:31:42.159166Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.packet.cmd{src_chain=ibc2 src_port=transfer src_channel=channel-1 dst_chain=ibc1}:relay{odata=1cc1f1a9 ->Destination @0-72; len=1}: ibc_relayer::link::relay_path: submitted -2023-12-01T11:31:43.892193Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos1xs95ndvdqpndpu8wva30zlu7qm4k9k9qwsafmw amount 1624635601299338190samoleans succeed after 1 tries -2023-12-01T11:31:45.043457Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos1443n98gd4yxeqfm696m640lwnvkxd25dsz0al5 amount 1624635601299340855samoleans succeed after 0 tries -2023-12-01T11:31:54.642065Z  INFO ibc_test_framework::types::binary::chains: stopping chain handle ibc2 -2023-12-01T11:31:54.642473Z  INFO ibc_test_framework::types::binary::chains: stopping chain handle ibc1 -ok -test tests::channel_upgrade::upgrade_handshake::test_channel_upgrade_handshake ... 2023-12-01T11:31:54.648084Z  INFO ibc_test_framework::framework::base: starting test with test config: TestConfig { chain_command_paths: ["simd"], account_prefixes: ["cosmos"], native_tokens: ["stake"], compat_modes: None, chain_store_dir: "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102", hang_on_fail: false, bootstrap_with_random_ids: false } -2023-12-01T11:31:57.735907Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos10jrg7ukqfhdqxzevys8xcugsrzhyvzd5vxw9zw amount 1110697913817813958samoleans succeed after 0 tries -2023-12-01T11:31:57.735961Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc1 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/ibc1 and RPC address http://localhost:7622. -2023-12-01T11:31:57.735984Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc1 - id: user1, address: cosmos1d40px3wq2vyuae8qfxk26gu6fju9wak5vpqz0a -2023-12-01T11:31:57.735991Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/ibc1' --node http://localhost:7622 -2023-12-01T11:32:00.878649Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos14hwlf3tl3xel7n0svn0cfextq0p6vv6hfm6l36 amount 1100623247595779558samoleans succeed after 0 tries -2023-12-01T11:32:00.878708Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc2 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/ibc2 and RPC address http://localhost:25334. -2023-12-01T11:32:00.878717Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc2 - id: user1, address: cosmos1yk9u37zh5vrj8fvr6nw4enls2faxy2xk6lgw75 -2023-12-01T11:32:00.878728Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/ibc2' --node http://localhost:25334 -2023-12-01T11:32:00.879651Z  INFO ibc_test_framework::bootstrap::binary::chain: written hermes config.toml to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/relayer-config.toml: -[global] -log_level = "info" - -[mode.clients] -enabled = true -refresh = true -misbehaviour = true - -[mode.connections] -enabled = false - -[mode.channels] -enabled = true - -[mode.packets] -enabled = true -clear_interval = 100 -clear_on_start = true -tx_confirmation = false -auto_register_counterparty_payee = false - -[rest] -enabled = false -host = "127.0.0.1" -port = 3000 - -[telemetry] -enabled = false -host = "127.0.0.1" -port = 3001 - -[telemetry.buckets.latency_submitted] -start = 500 -end = 20000 -buckets = 10 - -[telemetry.buckets.latency_confirmed] -start = 1000 -end = 30000 -buckets = 10 - -[[chains]] -type = "CosmosSdk" -id = "ibc1" -rpc_addr = "http://localhost:7622/" -grpc_addr = "http://localhost:54852/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:7622/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[[chains]] -type = "CosmosSdk" -id = "ibc2" -rpc_addr = "http://localhost:25334/" -grpc_addr = "http://localhost:38974/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:25334/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[tracing_server] -enabled = false -port = 5555 - -2023-12-01T11:32:13.768681Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc1 to chain ibc2 with client id 07-tendermint-1 on chain ibc2 -2023-12-01T11:32:14.686616Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc2 to chain ibc1 with client id 07-tendermint-0 on chain ibc1 -2023-12-01T11:32:14.686998Z  INFO ibc_test_framework::framework::binary::chain: written chains environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/binary-chains.env -2023-12-01T11:32:15.597270Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-1, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-0 } }) at height 0-16 -2023-12-01T11:32:16.814677Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-1 } }) at height 0-20 -2023-12-01T11:32:23.027382Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenTryConnection(OpenTry { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-23 -2023-12-01T11:32:28.938614Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenAckConnection(OpenAck { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: connection-1, counterparty_client_id: 07-tendermint-1 } }) at height 0-32 -2023-12-01T11:32:33.388540Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenConfirmConnection(OpenConfirm { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-33 -2023-12-01T11:32:36.394376Z  INFO ibc_relayer::connection: connection handshake already finished for Connection { delay_period: 0ns, a_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0 }, b_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1 } } -2023-12-01T11:32:36.394429Z  INFO ibc_test_framework::bootstrap::binary::connection: created new chain/client/connection from ibc1/07-tendermint-0/connection-0 to ibc2/07-tendermint-1/connection-1 -2023-12-01T11:32:36.394958Z  INFO ibc_test_framework::framework::binary::connection: written connection environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/binary-connections.env -2023-12-01T11:32:37.303004Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-37 -2023-12-01T11:32:38.213369Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-41 -2023-12-01T11:32:42.455806Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-42 -2023-12-01T11:32:46.595937Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) at height 0-49 -2023-12-01T11:32:51.951405Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-51 -2023-12-01T11:32:54.952773Z  INFO ibc_relayer::channel: channel handshake already finished for Channel { ordering: ORDER_UNORDERED, a_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0, port_id: transfer, channel_id: channel-0, version: ics20-1 }, b_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1, port_id: transfer, channel_id: channel-1, version: ics20-1 }, connection_delay: 0ns } -2023-12-01T11:32:54.952817Z  INFO ibc_test_framework::bootstrap::binary::channel: created new chain/client/connection/channel from ibc1/07-tendermint-0/connection-0/channel-0 to ibc2/07-tendermint-1/connection-1/channel-1 -2023-12-01T11:32:54.953121Z  INFO ibc_test_framework::framework::binary::channel: written channel environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1221353102/binary-channels.env -2023-12-01T11:32:54.953178Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:32:54.953248Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:32:54.953258Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:32:54.956150Z  WARN scan.chain{chain=ibc1}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:32:54.956231Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:32:54.957750Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:32:54.960994Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:32:54.961085Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:32:54.961098Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:32:54.963548Z  WARN scan.chain{chain=ibc2}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:32:54.963621Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:32:54.965144Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:32:54.968063Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:32:54.969237Z  WARN scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: connection is not open, skipping scan of channels over this connection -2023-12-01T11:32:54.969272Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-1}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:32:54.972504Z  INFO ibc_relayer::supervisor: scanned chains: -2023-12-01T11:32:54.972523Z  INFO ibc_relayer::supervisor: # Chain: ibc1 - - Client: 07-tendermint-0 - * Connection: connection-0 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: OPEN - | Counterparty: channel-1 -# Chain: ibc2 - - Client: 07-tendermint-0 - - Client: 07-tendermint-1 - * Connection: connection-0 - | State: INIT - | Counterparty state: - * Connection: connection-1 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: INIT - | Counterparty: - + Channel: channel-1 - | Port: transfer - | State: OPEN - | Counterparty: channel-0 - -2023-12-01T11:32:54.972599Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc1 connection=connection-0 counterparty_chain=ibc2 -2023-12-01T11:32:54.972619Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc1 connection=connection-0 -2023-12-01T11:32:54.972638Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc1 connection=connection-0 -2023-12-01T11:32:54.972677Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is OPEN, state on destination chain is OPEN chain=ibc1 counterparty_chain=ibc2 channel=channel-0 -2023-12-01T11:32:54.976068Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned client worker: client::ibc2->ibc1:07-tendermint-0 -2023-12-01T11:32:54.978486Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc1 channel=channel-0 -2023-12-01T11:32:54.978572Z  INFO spawn:chain{chain=ibc1}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc1 -2023-12-01T11:32:54.980264Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is INIT, state on destination chain is UNINITIALIZED chain=ibc2 connection=connection-0 counterparty_chain=ibc1 -2023-12-01T11:32:54.980297Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-0 -2023-12-01T11:32:54.980340Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc2 connection=connection-1 counterparty_chain=ibc1 -2023-12-01T11:32:54.980359Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc2 connection=connection-1 -2023-12-01T11:32:54.980378Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-1 -2023-12-01T11:32:54.980403Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is INIT, state on destination chain is UNINITIALIZED chain=ibc2 counterparty_chain=ibc1 channel=channel-0 -2023-12-01T11:32:54.980468Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-0/transfer:ibc2->ibc1 -2023-12-01T11:32:54.980490Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-0 -2023-12-01T11:32:54.980512Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: channel is OPEN, state on destination chain is OPEN chain=ibc2 counterparty_chain=ibc1 channel=channel-1 -2023-12-01T11:32:54.984730Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: spawned client worker: client::ibc1->ibc2:07-tendermint-1 -2023-12-01T11:32:54.987018Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-1 -2023-12-01T11:32:54.987113Z  INFO spawn:chain{chain=ibc2}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc2 -2023-12-01T11:32:54.991028Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake: Check that channels are both in OPEN State -2023-12-01T11:32:55.390082Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}:foreign_client.detect_misbehaviour{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc2 -2023-12-01T11:32:55.398311Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:32:55.705783Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}:foreign_client.detect_misbehaviour{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc2 -2023-12-01T11:32:55.716735Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:32:55.992640Z  INFO ibc_test_framework::util::retry: task channel should eventually established succeed after 0 tries -2023-12-01T11:32:55.992765Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake: Will initialise upgrade handshake by sending the ChanUpgradeInit step... -2023-12-01T11:32:56.906161Z  INFO ibc_relayer::channel: 👋 ibc1 => UpgradeInitChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-59 -2023-12-01T11:32:56.906221Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake: Check that the channel upgrade successfully upgraded the version... -2023-12-01T11:32:56.917306Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:32:56.917306Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}:foreign_client.detect_misbehaviour{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc2 -2023-12-01T11:32:57.220458Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:32:57.230151Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:32:57.249068Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeInitChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:32:57.252387Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:32:57.544360Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:32:59.005729Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: 👋 ibc2 => UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-58 -2023-12-01T11:32:59.005776Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:32:59.006184Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:32:59.941639Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: 🎊 ibc1 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-62 -2023-12-01T11:32:59.941696Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:32:59.942531Z  WARN worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: event: UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:32:59.949865Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:32:59.952448Z  WARN worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: build_chan_upgrade_ack for channel channel-1 and port transfer -2023-12-01T11:33:00.052681Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:33:00.338116Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: event: OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:33:02.198793Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: 🎊 ibc2 => OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) at height 0-61 -2023-12-01T11:33:02.198856Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) -2023-12-01T11:33:02.209934Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}:foreign_client.detect_misbehaviour{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc2 -2023-12-01T11:33:02.310111Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:33:03.138678Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: 👋 ibc1 => UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-65 -2023-12-01T11:33:03.138745Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:33:03.271459Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:33:03.342411Z  WARN spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: event: OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) -2023-12-01T11:33:03.371615Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:33:03.719893Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}:foreign_client.detect_misbehaviour{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc2 -2023-12-01T11:33:03.749708Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:33:03.751989Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_confirm for channel channel-0 and port transfer -2023-12-01T11:33:03.820939Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:33:05.193636Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: 👋 ibc2 => UpgradeConfirmChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [], upgrade_version: , upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-64 -2023-12-01T11:33:05.193716Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: UpgradeConfirmChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [], upgrade_version: , upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:33:06.129728Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: 🎊 ibc1 => OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-68 -2023-12-01T11:33:06.129797Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:33:06.138970Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:33:06.241445Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:33:06.333194Z  WARN worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:33:07.047844Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}:foreign_client.detect_misbehaviour{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc2 -2023-12-01T11:33:07.150871Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.client.misbehaviour{client=07-tendermint-0 src_chain=ibc2 dst_chain=ibc1}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc2->ibc1:07-tendermint-0}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:33:08.094854Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: 👋 ibc1 => UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-70 -2023-12-01T11:33:08.096520Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:33:08.153655Z  INFO ibc_test_framework::util::retry: task channel upgrade open step should be done succeed after 10 tries -2023-12-01T11:33:25.477157Z  INFO ibc_test_framework::types::binary::chains: stopping chain handle ibc2 -2023-12-01T11:33:25.477540Z  INFO ibc_test_framework::types::binary::chains: stopping chain handle ibc1 -ok -test tests::channel_upgrade::upgrade_handshake_steps::test_channel_upgrade_handshake_from_ack ... 2023-12-01T11:33:25.483221Z  INFO ibc_test_framework::framework::base: starting test with test config: TestConfig { chain_command_paths: ["simd"], account_prefixes: ["cosmos"], native_tokens: ["stake"], compat_modes: None, chain_store_dir: "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375", hang_on_fail: false, bootstrap_with_random_ids: false } -2023-12-01T11:33:28.562857Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos19xypxgq9q6ujkkt6k4fl4aaucptwjpvjzfg3lf amount 1466585791601217111samoleans succeed after 0 tries -2023-12-01T11:33:28.562902Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc1 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/ibc1 and RPC address http://localhost:39309. -2023-12-01T11:33:28.562929Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc1 - id: user1, address: cosmos1w2t6ttt5et0jcfzwzqz8xn3tulr0unaz6xvtqm -2023-12-01T11:33:28.562937Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/ibc1' --node http://localhost:39309 -2023-12-01T11:33:31.651250Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos185mr64fqxux4uc9848rq7j5dsmrmepa6976m8x amount 1662369447401891858samoleans succeed after 0 tries -2023-12-01T11:33:31.651295Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc2 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/ibc2 and RPC address http://localhost:40649. -2023-12-01T11:33:31.651307Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc2 - id: user1, address: cosmos1a0j0epgee8s5dqlff9j6u9rukpmspcg2xd2kax -2023-12-01T11:33:31.651332Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/ibc2' --node http://localhost:40649 -2023-12-01T11:33:31.652174Z  INFO ibc_test_framework::bootstrap::binary::chain: written hermes config.toml to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/relayer-config.toml: -[global] -log_level = "info" - -[mode.clients] -enabled = true -refresh = true -misbehaviour = true - -[mode.connections] -enabled = false - -[mode.channels] -enabled = true - -[mode.packets] -enabled = true -clear_interval = 100 -clear_on_start = true -tx_confirmation = false -auto_register_counterparty_payee = false - -[rest] -enabled = false -host = "127.0.0.1" -port = 3000 - -[telemetry] -enabled = false -host = "127.0.0.1" -port = 3001 - -[telemetry.buckets.latency_submitted] -start = 500 -end = 20000 -buckets = 10 - -[telemetry.buckets.latency_confirmed] -start = 1000 -end = 30000 -buckets = 10 - -[[chains]] -type = "CosmosSdk" -id = "ibc1" -rpc_addr = "http://localhost:39309/" -grpc_addr = "http://localhost:47431/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:39309/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[[chains]] -type = "CosmosSdk" -id = "ibc2" -rpc_addr = "http://localhost:40649/" -grpc_addr = "http://localhost:30013/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:40649/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[tracing_server] -enabled = false -port = 5555 - -2023-12-01T11:33:44.455547Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc1 to chain ibc2 with client id 07-tendermint-1 on chain ibc2 -2023-12-01T11:33:45.376869Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc2 to chain ibc1 with client id 07-tendermint-0 on chain ibc1 -2023-12-01T11:33:45.377110Z  INFO ibc_test_framework::framework::binary::chain: written chains environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/binary-chains.env -2023-12-01T11:33:46.586396Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-1, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-0 } }) at height 0-16 -2023-12-01T11:33:47.498370Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-1 } }) at height 0-20 -2023-12-01T11:33:53.797146Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenTryConnection(OpenTry { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-23 -2023-12-01T11:33:59.888902Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenAckConnection(OpenAck { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: connection-1, counterparty_client_id: 07-tendermint-1 } }) at height 0-32 -2023-12-01T11:34:05.076813Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenConfirmConnection(OpenConfirm { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-34 -2023-12-01T11:34:08.079230Z  INFO ibc_relayer::connection: connection handshake already finished for Connection { delay_period: 0ns, a_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0 }, b_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1 } } -2023-12-01T11:34:08.079283Z  INFO ibc_test_framework::bootstrap::binary::connection: created new chain/client/connection from ibc1/07-tendermint-0/connection-0 to ibc2/07-tendermint-1/connection-1 -2023-12-01T11:34:08.079593Z  INFO ibc_test_framework::framework::binary::connection: written connection environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/binary-connections.env -2023-12-01T11:34:09.289722Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-38 -2023-12-01T11:34:10.200338Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-42 -2023-12-01T11:34:15.463525Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-44 -2023-12-01T11:34:20.434550Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) at height 0-52 -2023-12-01T11:34:25.603113Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-54 -2023-12-01T11:34:28.604186Z  INFO ibc_relayer::channel: channel handshake already finished for Channel { ordering: ORDER_UNORDERED, a_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0, port_id: transfer, channel_id: channel-0, version: ics20-1 }, b_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1, port_id: transfer, channel_id: channel-1, version: ics20-1 }, connection_delay: 0ns } -2023-12-01T11:34:28.605086Z  INFO ibc_test_framework::bootstrap::binary::channel: created new chain/client/connection/channel from ibc1/07-tendermint-0/connection-0/channel-0 to ibc2/07-tendermint-1/connection-1/channel-1 -2023-12-01T11:34:28.605412Z  INFO ibc_test_framework::framework::binary::channel: written channel environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-3027044375/binary-channels.env -2023-12-01T11:34:28.605491Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that channels are both in OPEN State -2023-12-01T11:34:29.609866Z  INFO ibc_test_framework::util::retry: task channel should eventually established succeed after 0 tries -2023-12-01T11:34:29.610193Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Will initialise upgrade handshake by sending the ChanUpgradeInit step... -2023-12-01T11:34:30.825984Z  INFO ibc_relayer::channel: 👋 ibc1 => UpgradeInitChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-62 -2023-12-01T11:34:30.826042Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Will run ChanUpgradeTry step... -2023-12-01T11:34:30.828922Z  WARN ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:34:32.798666Z  INFO ibc_relayer::channel: 👋 ibc2 => UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-61 -2023-12-01T11:34:32.798705Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that the step ChanUpgradeTry was correctly executed... -2023-12-01T11:34:33.808910Z  INFO ibc_test_framework::util::retry: task channel upgrade try step should be done succeed after 0 tries -2023-12-01T11:34:33.812725Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Will run ChanUpgradeAck step... -2023-12-01T11:34:33.814228Z  WARN ibc_relayer::channel: build_chan_upgrade_ack for channel channel-1 and port transfer -2023-12-01T11:34:35.882392Z  INFO ibc_relayer::channel: 👋 ibc1 => UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-67 -2023-12-01T11:34:35.882477Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that the step ChanUpgradeAck was correctly executed... -2023-12-01T11:34:36.890024Z  INFO ibc_test_framework::util::retry: task channel upgrade ack step should be done succeed after 0 tries -2023-12-01T11:34:36.893023Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that the channel upgrade successfully upgraded the version... -2023-12-01T11:34:36.893170Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:34:36.893358Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:34:36.893620Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:34:36.896713Z  WARN scan.chain{chain=ibc1}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:34:36.900220Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:34:36.902086Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:34:36.909114Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:34:36.909315Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:34:36.909339Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:34:36.912741Z  WARN scan.chain{chain=ibc2}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:34:36.912882Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:34:36.914751Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:34:36.918049Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:34:36.920043Z  WARN scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: connection is not open, skipping scan of channels over this connection -2023-12-01T11:34:36.920101Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-1}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:34:36.925199Z  INFO ibc_relayer::supervisor: scanned chains: -2023-12-01T11:34:36.925236Z  INFO ibc_relayer::supervisor: # Chain: ibc1 - - Client: 07-tendermint-0 - * Connection: connection-0 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: FLUSHCOMPLETE - | Counterparty: channel-1 -# Chain: ibc2 - - Client: 07-tendermint-0 - - Client: 07-tendermint-1 - * Connection: connection-0 - | State: INIT - | Counterparty state: - * Connection: connection-1 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: INIT - | Counterparty: - + Channel: channel-1 - | Port: transfer - | State: FLUSHING - | Counterparty: channel-0 - -2023-12-01T11:34:36.925375Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc1 connection=connection-0 counterparty_chain=ibc2 -2023-12-01T11:34:36.925416Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc1 connection=connection-0 -2023-12-01T11:34:36.925449Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc1 connection=connection-0 -2023-12-01T11:34:36.925477Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is FLUSHCOMPLETE, state on destination chain is FLUSHING chain=ibc1 counterparty_chain=ibc2 channel=channel-0 -2023-12-01T11:34:36.925585Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-0/transfer:ibc1->ibc2 -2023-12-01T11:34:36.925609Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc1 channel=channel-0 -2023-12-01T11:34:36.925669Z  INFO spawn:chain{chain=ibc1}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc1 -2023-12-01T11:34:36.928008Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is INIT, state on destination chain is UNINITIALIZED chain=ibc2 connection=connection-0 counterparty_chain=ibc1 -2023-12-01T11:34:36.928056Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-0 -2023-12-01T11:34:36.928111Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc2 connection=connection-1 counterparty_chain=ibc1 -2023-12-01T11:34:36.928134Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc2 connection=connection-1 -2023-12-01T11:34:36.928155Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-1 -2023-12-01T11:34:36.928184Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is INIT, state on destination chain is UNINITIALIZED chain=ibc2 counterparty_chain=ibc1 channel=channel-0 -2023-12-01T11:34:36.928262Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-0/transfer:ibc2->ibc1 -2023-12-01T11:34:36.928283Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-0 -2023-12-01T11:34:36.928306Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: channel is FLUSHING, state on destination chain is FLUSHCOMPLETE chain=ibc2 counterparty_chain=ibc1 channel=channel-1 -2023-12-01T11:34:36.928355Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-1/transfer:ibc2->ibc1 -2023-12-01T11:34:36.928380Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-1 -2023-12-01T11:34:36.928428Z  INFO spawn:chain{chain=ibc2}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc2 -2023-12-01T11:34:38.555405Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_confirm for channel channel-0 and port transfer -2023-12-01T11:34:40.193326Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: 👋 ibc2 => UpgradeConfirmChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [], upgrade_version: , upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-68 -2023-12-01T11:34:40.193381Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: UpgradeConfirmChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [], upgrade_version: , upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:34:41.126182Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: 🎊 ibc1 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-72 -2023-12-01T11:34:41.126239Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:34:41.329689Z  WARN spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:34:41.473773Z  WARN worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: event: OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:34:43.323006Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: 🎊 ibc2 => OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) at height 0-71 -2023-12-01T11:34:43.323066Z  INFO worker.batch{chain=ibc1}:supervisor.handle_batch{chain=ibc1}:supervisor.process_batch{chain=ibc1}:worker.channel{channel=channel::channel-1/transfer:ibc1->ibc2}: ibc_relayer::channel: channel handshake step completed with events: OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) -2023-12-01T11:34:44.251708Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: 👋 ibc1 => UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-75 -2023-12-01T11:34:44.251776Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:34:44.254690Z  INFO ibc_test_framework::util::retry: task channel upgrade open step should be done succeed after 6 tries -2023-12-01T11:34:44.454048Z  WARN spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: event: OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) -2023-12-01T11:34:44.672226Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:44.985683Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:46.197993Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: 🎊 ibc1 => OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-77 -2023-12-01T11:34:46.198047Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:34:46.206489Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:46.519294Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:46.835803Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:47.147861Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:47.460513Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:47.771456Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}:foreign_client.detect_misbehaviour{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::light_client::tendermint::detector: No evidence of misbehavior detected for chain ibc1 -2023-12-01T11:34:48.076140Z  INFO worker.batch{chain=ibc2}:supervisor.handle_batch{chain=ibc2}:supervisor.process_batch{chain=ibc2}:worker.client.misbehaviour{client=07-tendermint-1 src_chain=ibc1 dst_chain=ibc2}:foreign_client.detect_misbehaviour_and_submit_evidence{client=ibc1->ibc2:07-tendermint-1}: ibc_relayer::foreign_client: client is valid -2023-12-01T11:35:07.332454Z  INFO ibc_test_framework::types::binary::chains: stopping chain handle ibc2 -2023-12-01T11:35:07.332837Z  INFO ibc_test_framework::types::binary::chains: stopping chain handle ibc1 -ok -test tests::channel_upgrade::upgrade_handshake_steps::test_channel_upgrade_handshake_from_confirm ... 2023-12-01T11:35:07.338517Z  INFO ibc_test_framework::framework::base: starting test with test config: TestConfig { chain_command_paths: ["simd"], account_prefixes: ["cosmos"], native_tokens: ["stake"], compat_modes: None, chain_store_dir: "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828", hang_on_fail: false, bootstrap_with_random_ids: false } -2023-12-01T11:35:10.434522Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos15yqyv49htwcyu6vdf4xt5a9gnszypeayjfmgd3 amount 1612141894685084784samoleans succeed after 0 tries -2023-12-01T11:35:10.435944Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc1 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/ibc1 and RPC address http://localhost:61451. -2023-12-01T11:35:10.436004Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc1 - id: user1, address: cosmos1kt8kqw3te7hp7r06wprc5y5uccvq90r6ddjxf5 -2023-12-01T11:35:10.436039Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/ibc1' --node http://localhost:61451 -2023-12-01T11:35:13.531998Z  INFO ibc_test_framework::util::retry: task wallet reach cosmos1gv9hkkh3pyrwl83y9dlttfkweaq658swahghlj amount 1759713385587921069samoleans succeed after 0 tries -2023-12-01T11:35:13.532045Z  INFO ibc_test_framework::bootstrap::single: started new chain ibc2 at with home path /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/ibc2 and RPC address http://localhost:10471. -2023-12-01T11:35:13.532055Z  INFO ibc_test_framework::bootstrap::single: user wallet for chain ibc2 - id: user1, address: cosmos1a02amd3wakrh9u9wyyv0u4p5kjauc5csmj3fv5 -2023-12-01T11:35:13.532063Z  INFO ibc_test_framework::bootstrap::single: you can manually interact with the chain using commands starting with: -simd --home '/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/ibc2' --node http://localhost:10471 -2023-12-01T11:35:13.532959Z  INFO ibc_test_framework::bootstrap::binary::chain: written hermes config.toml to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/relayer-config.toml: -[global] -log_level = "info" - -[mode.clients] -enabled = true -refresh = true -misbehaviour = true - -[mode.connections] -enabled = false - -[mode.channels] -enabled = true - -[mode.packets] -enabled = true -clear_interval = 100 -clear_on_start = true -tx_confirmation = false -auto_register_counterparty_payee = false - -[rest] -enabled = false -host = "127.0.0.1" -port = 3000 - -[telemetry] -enabled = false -host = "127.0.0.1" -port = 3001 - -[telemetry.buckets.latency_submitted] -start = 500 -end = 20000 -buckets = 10 - -[telemetry.buckets.latency_confirmed] -start = 1000 -end = 30000 -buckets = 10 - -[[chains]] -type = "CosmosSdk" -id = "ibc1" -rpc_addr = "http://localhost:61451/" -grpc_addr = "http://localhost:7634/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:61451/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[[chains]] -type = "CosmosSdk" -id = "ibc2" -rpc_addr = "http://localhost:10471/" -grpc_addr = "http://localhost:48077/" -rpc_timeout = "10s" -trusted_node = false -account_prefix = "cosmos" -key_name = "relayer" -key_store_type = "Test" -key_store_folder = "/Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/hermes_keyring" -store_prefix = "ibc" -max_gas = 3000000 -gas_multiplier = 1.2 -max_msg_num = 30 -max_tx_size = 180000 -max_grpc_decoding_size = 33554432 -clock_drift = "5s" -max_block_time = "30s" -trusting_period = "14days" -ccv_consumer_chain = false -memo_prefix = "" -sequential_batch_tx = false - -[chains.event_source] -mode = "push" -url = "ws://localhost:10471/websocket" -batch_delay = "500ms" - -[chains.trust_threshold] -numerator = "1" -denominator = "3" - -[chains.gas_price] -price = 0.003 -denom = "stake" - -[chains.packet_filter] -policy = "allowall" - -[chains.packet_filter.min_fees] - -[chains.address_type] -derivation = "cosmos" - -[tracing_server] -enabled = false -port = 5555 - -2023-12-01T11:35:26.365886Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc1 to chain ibc2 with client id 07-tendermint-1 on chain ibc2 -2023-12-01T11:35:27.287220Z  INFO ibc_test_framework::bootstrap::binary::chain: created foreign client from chain ibc2 to chain ibc1 with client id 07-tendermint-0 on chain ibc1 -2023-12-01T11:35:27.287603Z  INFO ibc_test_framework::framework::binary::chain: written chains environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/binary-chains.env -2023-12-01T11:35:28.205244Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-1, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-0 } }) at height 0-16 -2023-12-01T11:35:29.422566Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenInitConnection(OpenInit { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: None, counterparty_client_id: 07-tendermint-1 } }) at height 0-20 -2023-12-01T11:35:35.409578Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenTryConnection(OpenTry { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-23 -2023-12-01T11:35:41.897606Z  INFO ibc_relayer::connection: 🥂 ibc1 => OpenAckConnection(OpenAck { Attributes { connection_id: connection-0, client_id: 07-tendermint-0, counterparty_connection_id: connection-1, counterparty_client_id: 07-tendermint-1 } }) at height 0-32 -2023-12-01T11:35:46.866123Z  INFO ibc_relayer::connection: 🥂 ibc2 => OpenConfirmConnection(OpenConfirm { Attributes { connection_id: connection-1, client_id: 07-tendermint-1, counterparty_connection_id: connection-0, counterparty_client_id: 07-tendermint-0 } }) at height 0-34 -2023-12-01T11:35:49.872462Z  INFO ibc_relayer::connection: connection handshake already finished for Connection { delay_period: 0ns, a_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0 }, b_side: ConnectionSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1 } } -2023-12-01T11:35:49.872989Z  INFO ibc_test_framework::bootstrap::binary::connection: created new chain/client/connection from ibc1/07-tendermint-0/connection-0 to ibc2/07-tendermint-1/connection-1 -2023-12-01T11:35:49.873360Z  INFO ibc_test_framework::framework::binary::connection: written connection environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/binary-connections.env -2023-12-01T11:35:51.086170Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-38 -2023-12-01T11:35:51.997211Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenInitChannel(OpenInit { port_id: transfer, channel_id: channel-0, connection_id: None, counterparty_port_id: transfer, counterparty_channel_id: None }) at height 0-42 -2023-12-01T11:35:56.139445Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-43 -2023-12-01T11:36:01.490681Z  INFO ibc_relayer::channel: 🎊 ibc1 => OpenAckChannel(OpenAck { port_id: transfer, channel_id: channel-0, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1 }) at height 0-51 -2023-12-01T11:36:06.345918Z  INFO ibc_relayer::channel: 🎊 ibc2 => OpenConfirmChannel(OpenConfirm { port_id: transfer, channel_id: channel-1, connection_id: connection-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-53 -2023-12-01T11:36:09.348960Z  INFO ibc_relayer::channel: channel handshake already finished for Channel { ordering: ORDER_UNORDERED, a_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc1 }, client_id: 07-tendermint-0, connection_id: connection-0, port_id: transfer, channel_id: channel-0, version: ics20-1 }, b_side: ChannelSide { chain: CachingChainHandle { chain_id: ibc2 }, client_id: 07-tendermint-1, connection_id: connection-1, port_id: transfer, channel_id: channel-1, version: ics20-1 }, connection_delay: 0ns } -2023-12-01T11:36:09.349003Z  INFO ibc_test_framework::bootstrap::binary::channel: created new chain/client/connection/channel from ibc1/07-tendermint-0/connection-0/channel-0 to ibc2/07-tendermint-1/connection-1/channel-1 -2023-12-01T11:36:09.349325Z  INFO ibc_test_framework::framework::binary::channel: written channel environment to /Users/luca/Documents/InformalSystems/hermes/tools/integration-test/data/test-1453610828/binary-channels.env -2023-12-01T11:36:09.349371Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that channels are both in OPEN State -2023-12-01T11:36:10.351424Z  INFO ibc_test_framework::util::retry: task channel should eventually established succeed after 0 tries -2023-12-01T11:36:10.351566Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Will initialise upgrade handshake by sending the ChanUpgradeInit step... -2023-12-01T11:36:10.659881Z  INFO ibc_relayer::channel: 👋 ibc1 => UpgradeInitChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-60 -2023-12-01T11:36:10.659947Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Will run ChanUpgradeTry step... -2023-12-01T11:36:10.662981Z  WARN ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:12.615362Z  INFO ibc_relayer::channel: 👋 ibc2 => UpgradeTryChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [ connection-1 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-59 -2023-12-01T11:36:12.615409Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that the step ChanUpgradeTry was correctly executed... -2023-12-01T11:36:13.620687Z  INFO ibc_test_framework::util::retry: task channel upgrade try step should be done succeed after 0 tries -2023-12-01T11:36:13.620723Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Will run ChanUpgradeAck step... -2023-12-01T11:36:13.622156Z  WARN ibc_relayer::channel: build_chan_upgrade_ack for channel channel-1 and port transfer -2023-12-01T11:36:15.786137Z  INFO ibc_relayer::channel: 👋 ibc1 => UpgradeAckChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-65 -2023-12-01T11:36:15.788239Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that the step ChanUpgradeAck was correctly executed... -2023-12-01T11:36:16.792010Z  INFO ibc_test_framework::util::retry: task channel upgrade ack step should be done succeed after 0 tries -2023-12-01T11:36:16.792049Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Will run ChanUpgradeConfirm step... -2023-12-01T11:36:16.793923Z  WARN ibc_relayer::channel: build_chan_upgrade_confirm for channel channel-0 and port transfer -2023-12-01T11:36:18.841064Z  INFO ibc_relayer::channel: 👋 ibc2 => UpgradeConfirmChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-1, counterparty_port_id: transfer, counterparty_channel_id: channel-0, upgrade_connection_hops: [], upgrade_version: , upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-65 -2023-12-01T11:36:18.841107Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that the step ChanUpgradeConfirm was correctly executed... -2023-12-01T11:36:19.844925Z  INFO ibc_test_framework::util::retry: task channel upgrade confirm step should be done succeed after 0 tries -2023-12-01T11:36:19.844985Z  INFO ibc_integration_test::tests::channel_upgrade::upgrade_handshake_steps: Check that the channel upgrade successfully upgraded the version... -2023-12-01T11:36:19.845040Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:36:19.845116Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:36:19.845127Z  INFO scan.chain{chain=ibc1}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:36:19.847565Z  WARN scan.chain{chain=ibc1}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:36:19.847638Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:36:19.849251Z  INFO scan.chain{chain=ibc1}:scan.client{client=07-tendermint-0}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:36:19.852507Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain... -2023-12-01T11:36:19.852597Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning chain for all clients, connections and channels -2023-12-01T11:36:19.852609Z  INFO scan.chain{chain=ibc2}: ibc_relayer::supervisor::scan: scanning all clients... -2023-12-01T11:36:19.855090Z  WARN scan.chain{chain=ibc2}: ibc_relayer::chain::cosmos: encountered unsupported client type `/ibc.lightclients.localhost.v2.ClientState` while scanning client `09-localhost`, skipping the client -2023-12-01T11:36:19.855162Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-0}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:36:19.856524Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}: ibc_relayer::supervisor::scan: scanning client... -2023-12-01T11:36:19.859732Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:36:19.860888Z  WARN scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-0}: ibc_relayer::supervisor::scan: connection is not open, skipping scan of channels over this connection -2023-12-01T11:36:19.860918Z  INFO scan.chain{chain=ibc2}:scan.client{client=07-tendermint-1}:scan.connection{connection=connection-1}: ibc_relayer::supervisor::scan: scanning connection... -2023-12-01T11:36:19.863979Z  INFO ibc_relayer::supervisor: scanned chains: -2023-12-01T11:36:19.864002Z  INFO ibc_relayer::supervisor: # Chain: ibc1 - - Client: 07-tendermint-0 - * Connection: connection-0 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: FLUSHCOMPLETE - | Counterparty: channel-1 -# Chain: ibc2 - - Client: 07-tendermint-0 - - Client: 07-tendermint-1 - * Connection: connection-0 - | State: INIT - | Counterparty state: - * Connection: connection-1 - | State: OPEN - | Counterparty state: OPEN - + Channel: channel-0 - | Port: transfer - | State: INIT - | Counterparty: - + Channel: channel-1 - | Port: transfer - | State: OPEN - | Counterparty: channel-0 - -2023-12-01T11:36:19.864090Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc1 connection=connection-0 counterparty_chain=ibc2 -2023-12-01T11:36:19.864112Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc1 connection=connection-0 -2023-12-01T11:36:19.864132Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc1 connection=connection-0 -2023-12-01T11:36:19.864159Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is FLUSHCOMPLETE, state on destination chain is OPEN chain=ibc1 counterparty_chain=ibc2 channel=channel-0 -2023-12-01T11:36:19.864265Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-0/transfer:ibc1->ibc2 -2023-12-01T11:36:19.864287Z  INFO spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc1 channel=channel-0 -2023-12-01T11:36:19.864342Z  INFO spawn:chain{chain=ibc1}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc1 -2023-12-01T11:36:19.865994Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: connection is INIT, state on destination chain is UNINITIALIZED chain=ibc2 connection=connection-0 counterparty_chain=ibc1 -2023-12-01T11:36:19.866032Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-0}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-0 -2023-12-01T11:36:19.866083Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is OPEN, state on destination chain is OPEN chain=ibc2 connection=connection-1 counterparty_chain=ibc1 -2023-12-01T11:36:19.866103Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: connection is already open, not spawning Connection worker chain=ibc2 connection=connection-1 -2023-12-01T11:36:19.866122Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: no connection workers were spawn chain=ibc2 connection=connection-1 -2023-12-01T11:36:19.866152Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: channel is INIT, state on destination chain is UNINITIALIZED chain=ibc2 counterparty_chain=ibc1 channel=channel-0 -2023-12-01T11:36:19.866222Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-0/transfer:ibc2->ibc1 -2023-12-01T11:36:19.866242Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-0 -2023-12-01T11:36:19.866265Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: channel is OPEN, state on destination chain is FLUSHCOMPLETE chain=ibc2 counterparty_chain=ibc1 channel=channel-1 -2023-12-01T11:36:19.866312Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}: ibc_relayer::supervisor::spawn: spawned channel worker: channel::channel-1/transfer:ibc2->ibc1 -2023-12-01T11:36:19.866333Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}: ibc_relayer::supervisor::spawn: done spawning channel workers chain=ibc2 channel=channel-1 -2023-12-01T11:36:19.866380Z  INFO spawn:chain{chain=ibc2}: ibc_relayer::supervisor::spawn: spawning Wallet worker: wallet::ibc2 -2023-12-01T11:36:22.955915Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: 👋 ibc1 => UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) at height 0-72 -2023-12-01T11:36:22.955995Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-1}:worker.channel{channel=channel::channel-1/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:22.957604Z  INFO ibc_test_framework::util::retry: task channel upgrade open step should be done succeed after 2 tries -2023-12-01T11:36:24.174664Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: 🎊 ibc1 => OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) at height 0-73 -2023-12-01T11:36:24.174728Z  INFO spawn:chain{chain=ibc2}:client{client=07-tendermint-1}:connection{connection=connection-1}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc2->ibc1}: ibc_relayer::channel: channel handshake step completed with events: OpenTryChannel(OpenTry { port_id: transfer, channel_id: channel-1, connection_id: connection-0, counterparty_port_id: transfer, counterparty_channel_id: channel-0 }) -2023-12-01T11:36:24.581128Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:24.584909Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:24.587641Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:27.591514Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:27.596106Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:27.596649Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:30.598892Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:30.603459Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:30.604009Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:33.606776Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:33.611277Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:33.611806Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:36.612985Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:36.617369Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:36.617889Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:39.621737Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:39.626342Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:39.626881Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:42.628046Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:42.632609Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:42.633147Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:45.634355Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:45.638873Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:45.639382Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:48.640648Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:48.648313Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:48.648827Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:51.655044Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:51.666729Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:51.667744Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:54.675473Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:54.679851Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:54.680379Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:36:57.682829Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:36:57.687175Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:36:57.687691Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:00.690854Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:00.695296Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:00.695836Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:03.699115Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:03.703846Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:03.704431Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:06.707730Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:06.712653Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:06.713277Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:09.716372Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:09.721650Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:09.722242Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:12.723528Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:12.728015Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:12.728534Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:15.732290Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:15.736958Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:15.737466Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:18.739010Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:18.743522Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:18.744053Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:21.746128Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:21.750688Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:21.751212Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:24.752537Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:24.757018Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:24.757565Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:27.762788Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:27.770427Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:27.770948Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:30.775930Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:30.783532Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:30.786517Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:33.789206Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:33.793763Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:33.794287Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:36.797656Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:36.802106Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:36.802601Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:39.804006Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:39.808669Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:39.809199Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:42.811851Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:42.816271Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:42.816813Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:45.818013Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:45.822414Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:45.822945Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:48.824892Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:48.829304Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:48.829817Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:51.832872Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:51.837341Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:51.837876Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:54.839064Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:54.843395Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:54.843906Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:37:57.845030Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:37:57.849415Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:37:57.849948Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:00.854154Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:00.858647Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:00.859184Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:03.862507Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:03.873542Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:03.874627Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:06.880004Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:06.886894Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:06.888103Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:09.891208Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:09.896037Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:09.896562Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:12.899329Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:12.903859Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:12.904437Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:15.907400Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:15.911807Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:15.912313Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:18.913990Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:18.918600Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:18.919128Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:21.920488Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:21.924927Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:21.925434Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:24.926878Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:24.931458Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:24.931980Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:27.933542Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:27.938301Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:27.942209Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:30.945911Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:30.950496Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:30.951016Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:33.952970Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:33.958391Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:33.959017Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:36.965189Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:36.969765Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:36.970421Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:39.973150Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:39.978046Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:39.978643Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:42.979878Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:42.984224Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:42.984724Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:45.986782Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:45.991431Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:45.991975Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 -2023-12-01T11:38:48.995453Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: event: UpgradeOpenChannel(UpgradeAttributes { port_id: transfer, channel_id: channel-0, counterparty_port_id: transfer, counterparty_channel_id: channel-1, upgrade_connection_hops: [ connection-0 ], upgrade_version: {"fee_version":"ics29-1","app_version":"ics20-1"}, upgrade_sequence: 1, upgrade_ordering: ORDER_UNORDERED }) -2023-12-01T11:38:49.001860Z  WARN spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: build_chan_upgrade_try for channel channel-0 and port transfer -2023-12-01T11:38:49.002621Z ERROR spawn:chain{chain=ibc1}:client{client=07-tendermint-0}:connection{connection=connection-0}:channel{channel=channel-0}:worker.channel{channel=channel::channel-0/transfer:ibc1->ibc2}: ibc_relayer::channel: failed ChanOPEN with error: failed during a query to chain id ibc1 - -Caused by: - 0: error decoding protobuf - 1: error converting message type into domain type: missing upgrade fields - - Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 - -Location: - /Users/luca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9 From b4e1d2993eeef5fab65f16c10accd0c6c4aa7688 Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:42:53 +0100 Subject: [PATCH 76/99] Use governance proposal to initialise channel upgrade tests (#3680) * Use governance proposal to initialise channel upgrade tests * Fix issue with chains which don't have 'expedited_voting_period' * Fix issues post merge * Correctly determine if the channel is upgrading or not * Remove CLI to init channel upgrade * Display channel state as 'Open' regardless if it is upgrading or not * Change serialize for channel state * Fix python e2e channel handshake test * feat: implement chan upgrade cancel and add timeout ack integration test (#3736) * feat: implement chan-upgrade-cancel and add integration test for timeout on upgrade ack * uncomment code * formatting * Fix channel upgrade timeout and cancel handling * Fix clippy warnings * Add channel upgrade cancel tests with supervisor * Fix typo * Fix upgrade cancel on confirm test and update guide * Clean channel upgrade tests * Additional clean-up in channel upgrade test assertions * Temporarily disable one chan upgrade timeout test * Remove incorrect timeout channel upgrade test --------- Co-authored-by: Luca Joss <43531661+ljoss17@users.noreply.github.com> Co-authored-by: Luca Joss * Fix Docker workflow after update to upload-artifact@v4 * Fix Artifact name for Docker job * feat: updates to upgrade fields and logic for `MsgTimeoutOnClose` and `MsgChannelCloseConfirm` (#3764) * wip: update naming of fields * add logic to add counterparty upgrade sequence to timeout on close and channel close confirm messages * add integration test for: when ICA channel upgrades and afterwards packet times out, then channel is closed * argo fmt --all * remove empty comment * Fix channel end parsing and test for ICA timeout after channel upgrade * Update nix flake * Improve documentation for upgraded ICA channel close test * Improve build channel close methods --------- Co-authored-by: Luca Joss * feat: add support for `MsgChannelUpgradeTimeout` and integration test (#3773) * feat: add support for msgchannelupgradetimeout and integration test * fix build errors * Update nix flake * Update CLI templates * cargo fmt * Fix clippy warnings/errors * Fix extracting upgrade_timeout attribute * WIP * Fix channel upgrade logic * Change Height to QueryHeight for restore_from_state method --------- Co-authored-by: Luca Joss * fetch counterparty upgrade sequence from src chain (#3801) * test(channel upgradability): add integration test that relays packets during flushing (#3786) * test: add integration test that flushes packets during channel upgrade * wip: add counterparty upgrade sequence to chan upgrade open * update integration test * cargo fmt * Fix UpgradeInit parsing and Registering ICA account following simd changes * handle new fields in messages: order in msg register interchain account and counterparty upgrade sequence in msg channel upgrade open * fix warnings * Update Nix flake * address review comments * cargo fmt * some clippy warnings * fix assert_eq! * fix test * cargo fmt * chore: rename order to ordering in msg register interchain account * Use ibc-go v8.1.0-rc.0 for channel upgrade tests * Add and use legacy 'MsgRegisterInterchainAccount' * Use different signer to initialise channel upgrade for 'test_channel_upgrade_handshake' test * add test where ICA channel is upgraded to unordered * cargo fmt + add debug log * increase packet timeout * Add case where Channel upgrade Try event is received by source chain while dst chain is open not upgrading * Use user2 to signe channel upgrade init proposal in ICA unordered test --------- Co-authored-by: Luca Joss * Fix ICS29 timeout fee test compatibility for ibc-go v8.1+ * Add compatibility to ICS29 tests for ibc-go v8.1+ * Fix typos * Update method used to verify if there is an ongoing channel upgrade * Update channel query to correctly reflect if it is upgrading or not if the state is open * Add upgrade handshake step if both channel ends are in open upgrading * Fix channel state assertion for channel Init and Try steps * Fix assertions in channel upgrade tests * Fix verification if channel needs to be flushed * Add test for packet flushing during channel upgrade * Fix link creation when channel is upgrading * test(channel-upgrades): add test where upgrade timeouts on acknowledge packet (#3828) * add test where upgrade times out during packet ack * cargo fmt * Fix packet worker spawning if channel is flushing or flushcomplete --------- Co-authored-by: Luca Joss * Clean-up channel upgrade tests * Improve channel upgrade workers * Remove unused code * Use ibc-proto-rs v0.42.0 * Remove unnecessary code * Clean up code and remove guide entries for tx channel upgrade init CLI --------- Co-authored-by: Carlos Rodriguez Co-authored-by: Romain Ruetschi <106849+romac@users.noreply.github.com> --- .github/workflows/integration.yaml | 42 +- Cargo.lock | 5 - Cargo.toml | 1 - crates/relayer-cli/src/commands/tx.rs | 9 +- crates/relayer-cli/src/commands/tx/channel.rs | 288 +++-- .../src/applications/ics27_ica/error.rs | 5 + .../src/applications/ics27_ica/mod.rs | 3 + .../core/ics02_client/msgs/upgrade_client.rs | 6 +- .../src/core/ics04_channel/channel.rs | 70 +- .../src/core/ics04_channel/error.rs | 3 + .../src/core/ics04_channel/events.rs | 249 +++- .../src/core/ics04_channel/msgs.rs | 2 + .../ics04_channel/msgs/chan_close_confirm.rs | 9 +- .../ics04_channel/msgs/chan_upgrade_cancel.rs | 241 ++++ .../ics04_channel/msgs/chan_upgrade_open.rs | 2 +- .../msgs/chan_upgrade_timeout.rs | 258 ++++ .../ics04_channel/msgs/timeout_on_close.rs | 8 +- .../src/core/ics04_channel/timeout.rs | 88 +- .../src/core/ics04_channel/upgrade.rs | 45 +- .../src/core/ics04_channel/version.rs | 9 + .../relayer-types/src/core/ics24_host/path.rs | 8 + crates/relayer-types/src/events.rs | 16 + crates/relayer-types/src/mock/client_state.rs | 18 +- crates/relayer/src/chain/cosmos.rs | 131 +- .../src/chain/cosmos/types/events/channel.rs | 57 +- crates/relayer/src/chain/endpoint.rs | 10 +- crates/relayer/src/chain/handle.rs | 16 +- crates/relayer/src/chain/handle/base.rs | 16 +- crates/relayer/src/chain/handle/cache.rs | 11 +- crates/relayer/src/chain/handle/counting.rs | 13 +- crates/relayer/src/chain/runtime.rs | 20 +- crates/relayer/src/channel.rs | 483 +++++--- crates/relayer/src/channel/error.rs | 3 + crates/relayer/src/event.rs | 28 + .../src/event/source/websocket/extract.rs | 5 + crates/relayer/src/link.rs | 3 + crates/relayer/src/link/relay_path.rs | 7 +- crates/relayer/src/supervisor/spawn.rs | 38 +- crates/relayer/src/worker/channel.rs | 14 +- e2e/e2e/channel.py | 9 +- flake.lock | 44 +- flake.nix | 1 - .../commands/hermes/tx/chan-upgrade-ack_1.md | 2 +- .../hermes/tx/chan-upgrade-cancel_1.md | 1 + .../hermes/tx/chan-upgrade-confirm_1.md | 2 +- .../commands/hermes/tx/chan-upgrade-init_1.md | 1 - .../commands/hermes/tx/chan-upgrade-open_1.md | 2 +- .../hermes/tx/chan-upgrade-timeout_1.md | 1 + guide/src/templates/help_templates/tx.md | 3 +- .../help_templates/tx/chan-upgrade-cancel.md | 30 + .../help_templates/tx/chan-upgrade-init.md | 28 - .../help_templates/tx/chan-upgrade-timeout.md | 30 + .../src/tests/async_icq/simple_query.rs | 2 +- .../src/tests/channel_upgrade/flushing.rs | 422 +++++++ .../src/tests/channel_upgrade/ica.rs | 529 ++++++++ .../src/tests/channel_upgrade/ics29.rs | 41 +- .../src/tests/channel_upgrade/mod.rs | 3 + .../src/tests/channel_upgrade/timeout.rs | 1070 +++++++++++++++++ .../channel_upgrade/upgrade_handshake.rs | 158 ++- .../upgrade_handshake_steps.rs | 454 +++++-- .../src/tests/client_upgrade.rs | 6 +- .../src/tests/fee/auto_forward_relayer.rs | 14 +- .../src/tests/fee/filter_fees.rs | 62 +- .../src/tests/fee/forward_relayer.rs | 10 +- .../src/tests/fee/no_forward_relayer.rs | 22 +- .../src/tests/fee/pay_fee_async.rs | 41 +- .../src/tests/fee/register_payee.rs | 10 +- .../src/tests/fee/timeout_fee.rs | 4 - tools/test-framework/src/chain/cli/upgrade.rs | 87 +- .../test-framework/src/chain/ext/bootstrap.rs | 2 +- .../test-framework/src/chain/ext/proposal.rs | 212 +++- .../src/framework/binary/ics.rs | 1 + tools/test-framework/src/relayer/chain.rs | 12 +- tools/test-framework/src/relayer/channel.rs | 110 +- 74 files changed, 4912 insertions(+), 754 deletions(-) create mode 100644 crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_cancel.rs create mode 100644 crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_timeout.rs create mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-cancel_1.md delete mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md create mode 100644 guide/src/templates/commands/hermes/tx/chan-upgrade-timeout_1.md create mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-cancel.md delete mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-init.md create mode 100644 guide/src/templates/help_templates/tx/chan-upgrade-timeout.md create mode 100644 tools/integration-test/src/tests/channel_upgrade/flushing.rs create mode 100644 tools/integration-test/src/tests/channel_upgrade/ica.rs create mode 100644 tools/integration-test/src/tests/channel_upgrade/timeout.rs diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index b520bdd4b1..7f2c3a60fc 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -69,7 +69,7 @@ jobs: command: simd account_prefix: cosmos native_token: stake - features: ica,ics29-fee + features: ica,ics29-fee,channel-upgrade - package: wasmd command: wasmd account_prefix: wasm @@ -161,46 +161,6 @@ jobs: cargo nextest run -p ibc-integration-test --no-fail-fast --failure-output final --test-threads=2 \ --features ordered test_ordered_channel - channel-upgrade: - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - chain: - - package: ibc-go-v8-channel-upgrade-simapp - command: simd - account_prefix: cosmos - steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v24 - with: - install_url: https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install - install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' - extra_nix_config: | - experimental-features = nix-command flakes - - uses: cachix/cachix-action@v13 - with: - name: cosmos - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v2 - - uses: actions-rs/cargo@v1 - with: - command: test - args: -p ibc-integration-test --features channel-upgrade --no-fail-fast --no-run - - env: - RUST_LOG: debug - RUST_BACKTRACE: 1 - NO_COLOR_LOG: 1 - CHAIN_COMMAND_PATHS: ${{ matrix.chain.command }} - ACCOUNT_PREFIXES: ${{ matrix.chain.account_prefix }} - run: | - nix shell .#${{ matrix.chain.package }} -c cargo \ - test -p ibc-integration-test --features channel-upgrade --no-fail-fast -- \ - --nocapture --test-threads=1 channel_upgrade:: - interchain-security-no-ica: runs-on: ubuntu-20.04 strategy: diff --git a/Cargo.lock b/Cargo.lock index d2ce93d898..5c1142f9b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4278,8 +4278,3 @@ dependencies = [ "quote", "syn 2.0.48", ] - -[[patch.unused]] -name = "ibc-proto" -version = "0.41.0" -source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=romac/channel-upgrade-only#0d28c0068634ef3c863e7a56a34c2c2fce222164" diff --git a/Cargo.toml b/Cargo.toml index a2a07946d3..751221bc3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ exclude = [ overflow-checks = true [patch.crates-io] -ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "romac/channel-upgrade-only" } # ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "main" } # tendermint = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" } # tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" } diff --git a/crates/relayer-cli/src/commands/tx.rs b/crates/relayer-cli/src/commands/tx.rs index ed10e3ff9c..dc5099250c 100644 --- a/crates/relayer-cli/src/commands/tx.rs +++ b/crates/relayer-cli/src/commands/tx.rs @@ -44,9 +44,6 @@ pub enum TxCmd { /// Confirm the closing of a channel (ChannelCloseConfirm) ChanCloseConfirm(channel::TxChanCloseConfirmCmd), - /// Initiate a channel upgrade (ChannelUpgradeInit) - ChanUpgradeInit(channel::TxChanUpgradeInitCmd), - /// Relay the channel upgrade attempt (ChannelUpgradeTry) ChanUpgradeTry(channel::TxChanUpgradeTryCmd), @@ -59,6 +56,12 @@ pub enum TxCmd { /// Relay the channel upgrade attempt (ChannelUpgradeOpen) ChanUpgradeOpen(channel::TxChanUpgradeOpenCmd), + /// Relay the channel upgrade cancellation (ChannelUpgradeCancel) + ChanUpgradeCancel(channel::TxChanUpgradeCancelCmd), + + /// Relay the channel upgrade timeout (ChannelUpgradeTimeout) + ChanUpgradeTimeout(channel::TxChanUpgradeTimeoutCmd), + /// Send a fungible token transfer test transaction (ICS20 MsgTransfer) FtTransfer(transfer::TxIcs20MsgTransferCmd), diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 0bb9b4c3f9..c43d78f54e 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -10,7 +10,6 @@ use ibc_relayer::channel::{Channel, ChannelSide}; use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd; use ibc_relayer_types::core::ics04_channel::channel::Ordering; -use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; @@ -662,14 +661,23 @@ impl Runnable for TxChanCloseConfirmCmd { } } -/// Initiate a channel upgrade (ChannelUpgradeInit) +/// Relay the channel upgrade attempt (ChannelUpgradeTry) /// -/// Build and send a `ChannelUpgradeInit` message to a destination -/// chain that the source chain has an already-existing channel open -/// with, signaling the intent by the source chain to perform -/// the channel upgrade handshake. +/// Build and send a `ChannelUpgradeTry` message in response to +/// a `ChannelUpgradeInit` message, signaling the chain's intent to +/// cooperate with the source chain on upgrading the specified channel +/// and initiating the upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] -pub struct TxChanUpgradeInitCmd { +pub struct TxChanUpgradeTryCmd { + #[clap( + long = "dst-chain", + required = true, + value_name = "DST_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination chain" + )] + dst_chain_id: ChainId, + #[clap( long = "src-chain", required = true, @@ -680,13 +688,14 @@ pub struct TxChanUpgradeInitCmd { src_chain_id: ChainId, #[clap( - long = "dst-chain", + long = "dst-connection", + visible_alias = "dst-conn", required = true, - value_name = "DST_CHAIN_ID", + value_name = "DST_CONNECTION_ID", help_heading = "REQUIRED", - help = "Identifier of the destination chain" + help = "Identifier of the destination connection" )] - dst_chain_id: ChainId, + dst_conn_id: ConnectionId, #[clap( long = "dst-port", @@ -697,42 +706,168 @@ pub struct TxChanUpgradeInitCmd { )] dst_port_id: PortId, + #[clap( + long = "src-port", + required = true, + value_name = "SRC_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the source port" + )] + src_port_id: PortId, + + #[clap( + long = "src-channel", + visible_alias = "src-chan", + required = true, + value_name = "SRC_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" + )] + src_chan_id: ChannelId, + #[clap( long = "dst-channel", visible_alias = "dst-chan", required = true, + help_heading = "REQUIRED", value_name = "DST_CHANNEL_ID", + help = "Identifier of the destination channel (optional)" + )] + dst_chan_id: Option, +} + +impl Runnable for TxChanUpgradeTryCmd { + fn run(&self) { + let config = app_config(); + + let chains = match ChainHandlePair::spawn(&config, &self.src_chain_id, &self.dst_chain_id) { + Ok(chains) => chains, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Retrieve the connection + let dst_connection = match chains.dst.query_connection( + QueryConnectionRequest { + connection_id: self.dst_conn_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) { + Ok((connection, _)) => connection, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + + // Fetch the Channel that will facilitate the communication between the channel ends + // being upgraded. This channel is assumed to already exist on the destination chain. + let channel = Channel { + connection_delay: Default::default(), + ordering: Ordering::default(), + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + Some(self.src_chan_id.clone()), + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + self.dst_chan_id.clone(), + None, + ), + }; + + info!("message ChanUpgradeTry: {}", channel); + + let res: Result, Error> = channel + .build_chan_upgrade_try_and_send() + .map_err(Error::channel); + + match res { + Ok(receipt) => Output::success(receipt).exit(), + Err(e) => Output::error(e).exit(), + } + } +} + +/// Relay the channel upgrade attempt (ChannelUpgradeAck) +/// +/// Build and send a `ChannelUpgradeAck` message in response to +/// a `ChannelUpgradeTry` message in order to continue the channel +/// upgrade handshake. +#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] +pub struct TxChanUpgradeAckCmd { + #[clap( + long = "dst-chain", + required = true, + value_name = "DST_CHAIN_ID", help_heading = "REQUIRED", - help = "Identifier of the destination channel" + help = "Identifier of the destination chain" )] - dst_chan_id: ChannelId, + dst_chain_id: ChainId, #[clap( - long = "version", - required = false, - value_name = "VERSION", - help = "Version of the channel that both chains will upgrade to. Defaults to the version of the initiating chain if not specified." + long = "src-chain", + required = true, + value_name = "SRC_CHAIN_ID", + help_heading = "REQUIRED", + help = "Identifier of the source chain" + )] + src_chain_id: ChainId, + + #[clap( + long = "dst-connection", + visible_alias = "dst-conn", + required = true, + value_name = "DST_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection" + )] + dst_conn_id: ConnectionId, + + #[clap( + long = "dst-port", + required = true, + value_name = "DST_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination port" + )] + dst_port_id: PortId, + + #[clap( + long = "src-port", + required = true, + value_name = "SRC_PORT_ID", + help_heading = "REQUIRED", + help = "Identifier of the source port" )] - version: Option, + src_port_id: PortId, #[clap( - long = "ordering", - required = false, - value_name = "ORDERING", - help = "Ordering of the channel that both chains will upgrade to. Note that the a channel may only be upgraded from a stricter ordering to a less strict ordering, i.e., from ORDERED to UNORDERED. Defaults to the ordering of the initiating chain if not specified." + long = "src-channel", + visible_alias = "src-chan", + required = true, + value_name = "SRC_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" )] - ordering: Option, + src_chan_id: ChannelId, #[clap( - long = "connection-hops", - required = false, - value_name = "CONNECTION_HOPS", - help = "Set of connection hops for the channel that both chains will upgrade to. Defaults to the connection hops of the initiating chain if not specified." + long = "dst-channel", + visible_alias = "dst-chan", + required = true, + help_heading = "REQUIRED", + value_name = "DST_CHANNEL_ID", + help = "Identifier of the destination channel (optional)" )] - connection_hops: Option>, + dst_chan_id: Option, } -impl Runnable for TxChanUpgradeInitCmd { +impl Runnable for TxChanUpgradeAckCmd { fn run(&self) { let config = app_config(); @@ -741,6 +876,18 @@ impl Runnable for TxChanUpgradeInitCmd { Err(e) => Output::error(format!("{}", e)).exit(), }; + // Retrieve the connection + let dst_connection = match chains.dst.query_connection( + QueryConnectionRequest { + connection_id: self.dst_conn_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) { + Ok((connection, _)) => connection, + Err(e) => Output::error(format!("{}", e)).exit(), + }; + // Fetch the Channel that will facilitate the communication between the channel ends // being upgraded. This channel is assumed to already exist on the destination chain. let channel = Channel { @@ -750,28 +897,24 @@ impl Runnable for TxChanUpgradeInitCmd { chains.src, ClientId::default(), ConnectionId::default(), - PortId::default(), - None, + self.src_port_id.clone(), + Some(self.src_chan_id.clone()), None, ), b_side: ChannelSide::new( chains.dst, - ClientId::default(), - ConnectionId::default(), + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), self.dst_port_id.clone(), - Some(self.dst_chan_id.clone()), + self.dst_chan_id.clone(), None, ), }; - info!("message ChanUpgradeInit: {}", channel); + info!("message ChanUpgradeAck: {}", channel); - let res: Result = channel - .build_chan_upgrade_init_and_send( - self.version.clone(), - self.ordering, - self.connection_hops.clone(), - ) + let res: Result, Error> = channel + .build_chan_upgrade_ack_and_send() .map_err(Error::channel); match res { @@ -781,14 +924,13 @@ impl Runnable for TxChanUpgradeInitCmd { } } -/// Relay the channel upgrade attempt (ChannelUpgradeTry) +/// Relay the channel upgrade attempt (ChannelUpgradeConfirm) /// -/// Build and send a `ChannelUpgradeTry` message in response to -/// a `ChannelUpgradeInit` message, signaling the chain's intent to -/// cooperate with the source chain on upgrading the specified channel -/// and initiating the upgrade handshake. +/// Build and send a `ChannelUpgradeConfirm` message in response to +/// a `ChannelUpgradeAck` message in order to continue the channel +/// upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] -pub struct TxChanUpgradeTryCmd { +pub struct TxChanUpgradeConfirmCmd { #[clap( long = "dst-chain", required = true, @@ -856,7 +998,7 @@ pub struct TxChanUpgradeTryCmd { dst_chan_id: Option, } -impl Runnable for TxChanUpgradeTryCmd { +impl Runnable for TxChanUpgradeConfirmCmd { fn run(&self) { let config = app_config(); @@ -900,10 +1042,10 @@ impl Runnable for TxChanUpgradeTryCmd { ), }; - info!("message ChanUpgradeTry: {}", channel); + info!("message ChanUpgradeConfirm: {}", channel); - let res: Result = channel - .build_chan_upgrade_try_and_send() + let res: Result, Error> = channel + .build_chan_upgrade_confirm_and_send() .map_err(Error::channel); match res { @@ -913,13 +1055,12 @@ impl Runnable for TxChanUpgradeTryCmd { } } -/// Relay the channel upgrade attempt (ChannelUpgradeAck) +/// Relay the channel upgrade attempt (ChannelUpgradeOpen) /// -/// Build and send a `ChannelUpgradeAck` message in response to -/// a `ChannelUpgradeTry` message in order to continue the channel -/// upgrade handshake. +/// Build and send a `ChannelUpgradeOpen` message to finalize +/// the channel upgrade handshake. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] -pub struct TxChanUpgradeAckCmd { +pub struct TxChanUpgradeOpenCmd { #[clap( long = "dst-chain", required = true, @@ -987,7 +1128,7 @@ pub struct TxChanUpgradeAckCmd { dst_chan_id: Option, } -impl Runnable for TxChanUpgradeAckCmd { +impl Runnable for TxChanUpgradeOpenCmd { fn run(&self) { let config = app_config(); @@ -1031,10 +1172,10 @@ impl Runnable for TxChanUpgradeAckCmd { ), }; - info!("message ChanUpgradeAck: {}", channel); + info!("message ChanUpgradeOpen: {}", channel); let res: Result = channel - .build_chan_upgrade_ack_and_send() + .build_chan_upgrade_open_and_send() .map_err(Error::channel); match res { @@ -1044,13 +1185,12 @@ impl Runnable for TxChanUpgradeAckCmd { } } -/// Relay the channel upgrade attempt (ChannelUpgradeConfirm) +/// Relay channel upgrade cancel when counterparty has aborted the upgrade (ChannelUpgradeCancel) /// -/// Build and send a `ChannelUpgradeConfirm` message in response to -/// a `ChannelUpgradeAck` message in order to continue the channel -/// upgrade handshake. +/// Build and send a `ChannelUpgradeCancel` message to cancel +/// the channel upgrade handshake given that the counterparty has aborted. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] -pub struct TxChanUpgradeConfirmCmd { +pub struct TxChanUpgradeCancelCmd { #[clap( long = "dst-chain", required = true, @@ -1118,7 +1258,7 @@ pub struct TxChanUpgradeConfirmCmd { dst_chan_id: Option, } -impl Runnable for TxChanUpgradeConfirmCmd { +impl Runnable for TxChanUpgradeCancelCmd { fn run(&self) { let config = app_config(); @@ -1162,10 +1302,10 @@ impl Runnable for TxChanUpgradeConfirmCmd { ), }; - info!("message ChanUpgradeConfirm: {}", channel); + info!("message ChanUpgradeCancel: {}", channel); let res: Result = channel - .build_chan_upgrade_confirm_and_send() + .build_chan_upgrade_cancel_and_send() .map_err(Error::channel); match res { @@ -1175,12 +1315,12 @@ impl Runnable for TxChanUpgradeConfirmCmd { } } -/// Relay the channel upgrade attempt (ChannelUpgradeOpen) +/// Relay channel upgrade timeout when counterparty has not flushed packets before upgrade timeout (ChannelUpgradeTimeout) /// -/// Build and send a `ChannelUpgradeOpen` message to finalize -/// the channel upgrade handshake. +/// Build and send a `ChannelUpgradeTimeout` message to timeout +/// the channel upgrade handshake given that the counterparty has not flushed packets before upgrade timeout. #[derive(Clone, Command, Debug, Parser, PartialEq, Eq)] -pub struct TxChanUpgradeOpenCmd { +pub struct TxChanUpgradeTimeoutCmd { #[clap( long = "dst-chain", required = true, @@ -1248,7 +1388,7 @@ pub struct TxChanUpgradeOpenCmd { dst_chan_id: Option, } -impl Runnable for TxChanUpgradeOpenCmd { +impl Runnable for TxChanUpgradeTimeoutCmd { fn run(&self) { let config = app_config(); @@ -1292,10 +1432,10 @@ impl Runnable for TxChanUpgradeOpenCmd { ), }; - info!("message ChanUpgradeOpen: {}", channel); + info!("message ChanUpgradeTimeout: {}", channel); let res: Result = channel - .build_chan_upgrade_open_and_send() + .build_chan_upgrade_timeout_and_send() .map_err(Error::channel); match res { diff --git a/crates/relayer-types/src/applications/ics27_ica/error.rs b/crates/relayer-types/src/applications/ics27_ica/error.rs index 4143b2467f..878b1ab1f0 100644 --- a/crates/relayer-types/src/applications/ics27_ica/error.rs +++ b/crates/relayer-types/src/applications/ics27_ica/error.rs @@ -1,3 +1,4 @@ +use crate::core::ics04_channel::error as channel_error; use crate::core::ics24_host::error::ValidationError; use crate::signer::SignerError; @@ -6,6 +7,10 @@ use flex_error::define_error; define_error! { #[derive(Debug, PartialEq, Eq)] Error { + Ics04Channel + [ channel_error::Error ] + | _ | { "ics04 channel error" }, + Owner [ SignerError ] | _ | { "failed to parse owner" }, diff --git a/crates/relayer-types/src/applications/ics27_ica/mod.rs b/crates/relayer-types/src/applications/ics27_ica/mod.rs index c42612c711..74c81280b4 100644 --- a/crates/relayer-types/src/applications/ics27_ica/mod.rs +++ b/crates/relayer-types/src/applications/ics27_ica/mod.rs @@ -2,3 +2,6 @@ pub mod cosmos_tx; pub mod error; pub mod msgs; pub mod packet_data; + +/// ICS27 application current version. +pub const VERSION: &str = "ics27-1"; diff --git a/crates/relayer-types/src/core/ics02_client/msgs/upgrade_client.rs b/crates/relayer-types/src/core/ics02_client/msgs/upgrade_client.rs index 20fcf6ccc3..f6b5e4c5cc 100644 --- a/crates/relayer-types/src/core/ics02_client/msgs/upgrade_client.rs +++ b/crates/relayer-types/src/core/ics02_client/msgs/upgrade_client.rs @@ -139,7 +139,7 @@ pub mod test_util { pub fn get_dummy_raw_msg_upgrade_client(height: Height) -> RawMsgUpgradeClient { RawMsgUpgradeClient { client_id: "tendermint".parse().unwrap(), - client_state: Some(MockClientState::new(MockHeader::new(height)).into()), + client_state: Some(MockClientState::new(MockHeader::new(height), 1209600u64).into()), consensus_state: Some(MockConsensusState::new(MockHeader::new(height)).into()), proof_upgrade_client: get_dummy_proof(), proof_upgrade_consensus_state: get_dummy_proof(), @@ -172,7 +172,9 @@ mod tests { let height = Height::new(1, 1).unwrap(); - let client_state = MockClientState::new(MockHeader::new(height)); + // 14 days in seconds + let trusting_period = 1209600u64; + let client_state = MockClientState::new(MockHeader::new(height), trusting_period); let consensus_state = MockConsensusState::new(MockHeader::new(height)); let proof = get_dummy_merkle_proof(); diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index 90b8ba8d4c..c3de396df6 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -11,6 +11,7 @@ use ibc_proto::ibc::core::channel::v1::{ IdentifiedChannel as RawIdentifiedChannel, }; +use crate::core::ics04_channel::packet::Sequence; use crate::core::ics04_channel::{error::Error, version::Version}; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; @@ -69,7 +70,7 @@ impl From for RawIdentifiedChannel { version: value.channel_end.version.to_string(), port_id: value.port_id.to_string(), channel_id: value.channel_id.to_string(), - upgrade_sequence: value.channel_end.upgrade_sequence, + upgrade_sequence: value.channel_end.upgrade_sequence.into(), } } } @@ -81,7 +82,7 @@ pub struct ChannelEnd { pub remote: Counterparty, pub connection_hops: Vec, pub version: Version, - pub upgrade_sequence: u64, + pub upgrade_sequence: Sequence, } impl Display for ChannelEnd { @@ -102,7 +103,7 @@ impl Default for ChannelEnd { remote: Counterparty::default(), connection_hops: Vec::new(), version: Version::default(), - upgrade_sequence: 0, + upgrade_sequence: Sequence::from(0), // The value of 0 indicates the channel has never been upgraded } } } @@ -143,7 +144,7 @@ impl TryFrom for ChannelEnd { remote, connection_hops, version, - value.upgrade_sequence, + value.upgrade_sequence.into(), )) } } @@ -160,7 +161,7 @@ impl From for RawChannel { .map(|v| v.as_str().to_string()) .collect(), version: value.version.to_string(), - upgrade_sequence: value.upgrade_sequence, + upgrade_sequence: value.upgrade_sequence.into(), } } } @@ -173,7 +174,7 @@ impl ChannelEnd { remote: Counterparty, connection_hops: Vec, version: Version, - upgrade_sequence: u64, + upgrade_sequence: Sequence, ) -> Self { Self { state, @@ -237,25 +238,36 @@ impl ChannelEnd { /// Helper function to compare the state of this end with another state. pub fn state_matches(&self, other: &State) -> bool { - self.state.eq(other) + self.state() == other } /// Helper function to compare the order of this end with another order. pub fn order_matches(&self, other: &Ordering) -> bool { - self.ordering.eq(other) + self.ordering() == other } #[allow(clippy::ptr_arg)] pub fn connection_hops_matches(&self, other: &Vec) -> bool { - self.connection_hops.eq(other) + self.connection_hops() == other } pub fn counterparty_matches(&self, other: &Counterparty) -> bool { - self.counterparty().eq(other) + self.counterparty() == other } pub fn version_matches(&self, other: &Version) -> bool { - self.version().eq(other) + self.version() == other + } + + /// Returns whether or not the channel with this state is + /// being upgraded. + pub fn is_upgrading(&self) -> bool { + use State::*; + + matches!( + self.state, + Open(UpgradeState::Upgrading) | Flushing | Flushcomplete + ) } } @@ -397,7 +409,7 @@ pub enum UpgradeState { /// explicitly, this is an attempt to capture the lifecycle of a /// channel, beginning from the `Uninitialized` state, through the /// `Open` state, before finally being `Closed`. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)] pub enum State { /// Default state Uninitialized, @@ -421,6 +433,23 @@ pub enum State { Flushcomplete, } +impl Serialize for State { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + match self { + Self::Uninitialized => serializer.serialize_str("Uninitialized"), + Self::Init => serializer.serialize_str("Init"), + Self::TryOpen => serializer.serialize_str("TryOpen"), + Self::Open(_) => serializer.serialize_str("Open"), + Self::Closed => serializer.serialize_str("Closed"), + Self::Flushing => serializer.serialize_str("Flushing"), + Self::Flushcomplete => serializer.serialize_str("Flushcomplete"), + } + } +} + impl State { /// Yields the state as a string pub fn as_string(&self) -> &'static str { @@ -494,21 +523,6 @@ impl State { _ => false, } } - - /// Returns whether or not the channel with this state is - /// being upgraded. - pub fn is_upgrading(self, other: Self) -> bool { - use State::*; - - match self { - Open(UpgradeState::NotUpgrading) => matches!( - other, - Open(UpgradeState::Upgrading) | Flushing | Flushcomplete - ), - Open(UpgradeState::Upgrading) | Flushing | Flushcomplete => true, - _ => false, - } - } } /// Provides a `to_string` method. @@ -542,7 +556,7 @@ pub mod test_util { counterparty: Some(get_dummy_raw_counterparty()), connection_hops: vec![ConnectionId::default().to_string()], version: "ics20".to_string(), // The version is not validated. - upgrade_sequence: 0, + upgrade_sequence: 0, // The value of 0 indicates the channel has never been upgraded } } } diff --git a/crates/relayer-types/src/core/ics04_channel/error.rs b/crates/relayer-types/src/core/ics04_channel/error.rs index 8fef18e1c2..d6228fca41 100644 --- a/crates/relayer-types/src/core/ics04_channel/error.rs +++ b/crates/relayer-types/src/core/ics04_channel/error.rs @@ -126,6 +126,9 @@ define_error! { MissingUpgradeFields | _ | { "missing upgrade fields" }, + MissingUpgradeErrorReceipt + | _ | { "missing upgrade error receipt" }, + MissingProposedUpgradeChannel | _ | { "missing proposed upgrade channel" }, diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index 5fcf32f1b6..d3bdee764b 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -10,9 +10,11 @@ use crate::core::ics04_channel::channel::Ordering; use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::packet::Packet; use crate::core::ics04_channel::packet::Sequence; +use crate::core::ics04_channel::timeout::Timeout; use crate::core::ics04_channel::version::Version; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; use crate::events::{Error as EventError, IbcEvent, IbcEventType}; +use crate::timestamp::Timestamp; use crate::utils::pretty::PrettySlice; /// Channel event attribute keys @@ -106,6 +108,7 @@ pub struct UpgradeAttributes { pub upgrade_version: Version, pub upgrade_sequence: Sequence, pub upgrade_ordering: Ordering, + pub upgrade_timeout: Option, } impl UpgradeAttributes { @@ -570,16 +573,7 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - } - } -} - -impl From for abci::Event { - fn from(value: UpgradeInit) -> Self { - let kind = UpgradeInit::event_type().as_str().to_owned(); - Self { - kind, - attributes: UpgradeAttributes::from(value).into(), + upgrade_timeout: None, } } } @@ -672,16 +666,7 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - } - } -} - -impl From for abci::Event { - fn from(value: UpgradeTry) -> Self { - let kind = UpgradeTry::event_type().as_str().to_owned(); - Self { - kind, - attributes: UpgradeAttributes::from(value).into(), + upgrade_timeout: None, } } } @@ -774,16 +759,7 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - } - } -} - -impl From for abci::Event { - fn from(value: UpgradeAck) -> Self { - let kind = UpgradeAck::event_type().as_str().to_owned(); - Self { - kind, - attributes: UpgradeAttributes::from(value).into(), + upgrade_timeout: None, } } } @@ -876,16 +852,7 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - } - } -} - -impl From for abci::Event { - fn from(value: UpgradeConfirm) -> Self { - let kind = UpgradeConfirm::event_type().as_str().to_owned(); - Self { - kind, - attributes: UpgradeAttributes::from(value).into(), + upgrade_timeout: None, } } } @@ -978,16 +945,7 @@ impl From for UpgradeAttributes { upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, upgrade_ordering: ev.upgrade_ordering, - } - } -} - -impl From for abci::Event { - fn from(value: UpgradeOpen) -> Self { - let kind = UpgradeOpen::event_type().as_str().to_owned(); - Self { - kind, - attributes: UpgradeAttributes::from(value).into(), + upgrade_timeout: None, } } } @@ -1039,6 +997,197 @@ impl EventType for UpgradeOpen { } } +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeCancel { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, +} + +impl Display for UpgradeCancel { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering + ) + } +} + +impl From for UpgradeAttributes { + fn from(ev: UpgradeCancel) -> Self { + Self { + port_id: ev.port_id, + channel_id: ev.channel_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: ev.counterparty_channel_id, + upgrade_connection_hops: ev.upgrade_connection_hops, + upgrade_version: ev.upgrade_version, + upgrade_sequence: ev.upgrade_sequence, + upgrade_ordering: ev.upgrade_ordering, + upgrade_timeout: None, + } + } +} + +impl UpgradeCancel { + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeCancel { + type Error = EventError; + + fn try_from(attrs: UpgradeAttributes) -> Result { + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_connection_hops: attrs.upgrade_connection_hops, + upgrade_version: attrs.upgrade_version, + upgrade_sequence: attrs.upgrade_sequence, + upgrade_ordering: attrs.upgrade_ordering, + }) + } +} + +impl From for IbcEvent { + fn from(v: UpgradeCancel) -> Self { + IbcEvent::UpgradeCancelChannel(v) + } +} + +impl EventType for UpgradeCancel { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeCancelChannel + } +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeTimeout { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, + pub upgrade_connection_hops: Vec, + pub upgrade_version: Version, + pub upgrade_sequence: Sequence, + pub upgrade_ordering: Ordering, + pub upgrade_timeout: Timeout, +} + +impl Display for UpgradeTimeout { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } + for hop in self.upgrade_connection_hops.iter() { + write!(f, " {} ", hop)?; + } + write!( + f, + "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, upgrade_timeout: {} }}", + self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.upgrade_timeout, + ) + } +} + +impl From for UpgradeAttributes { + fn from(ev: UpgradeTimeout) -> Self { + Self { + port_id: ev.port_id, + channel_id: ev.channel_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: ev.counterparty_channel_id, + upgrade_connection_hops: ev.upgrade_connection_hops, + upgrade_version: ev.upgrade_version, + upgrade_sequence: ev.upgrade_sequence, + upgrade_ordering: ev.upgrade_ordering, + upgrade_timeout: Some(ev.upgrade_timeout), + } + } +} + +impl UpgradeTimeout { + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeTimeout { + type Error = EventError; + + fn try_from(attrs: UpgradeAttributes) -> Result { + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_connection_hops: attrs.upgrade_connection_hops, + upgrade_version: attrs.upgrade_version, + upgrade_sequence: attrs.upgrade_sequence, + upgrade_ordering: attrs.upgrade_ordering, + upgrade_timeout: attrs.upgrade_timeout.map_or_else( + || Timeout::Timestamp(Timestamp::default()), + |timeout| timeout, + ), + }) + } +} + +impl From for IbcEvent { + fn from(v: UpgradeTimeout) -> Self { + IbcEvent::UpgradeTimeoutChannel(v) + } +} + +impl EventType for UpgradeTimeout { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeTimeoutChannel + } +} + macro_rules! impl_try_from_attribute_for_event { ($($event:ty),+) => { $(impl TryFrom for $event { diff --git a/crates/relayer-types/src/core/ics04_channel/msgs.rs b/crates/relayer-types/src/core/ics04_channel/msgs.rs index 03f4b7eff8..c856d76866 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs.rs @@ -24,9 +24,11 @@ pub mod chan_close_init; // Upgrade handshake messages. pub mod chan_upgrade_ack; +pub mod chan_upgrade_cancel; pub mod chan_upgrade_confirm; pub mod chan_upgrade_init; pub mod chan_upgrade_open; +pub mod chan_upgrade_timeout; pub mod chan_upgrade_try; // Packet specific messages. diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs index 33b4873899..50736ece9e 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_close_confirm.rs @@ -3,6 +3,7 @@ use ibc_proto::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelCloseConfirm as RawMsgChannelCloseConfirm; use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::packet::Sequence; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::proofs::Proofs; use crate::signer::Signer; @@ -20,7 +21,7 @@ pub struct MsgChannelCloseConfirm { pub channel_id: ChannelId, pub proofs: Proofs, pub signer: Signer, - pub counterparty_upgrade_sequence: u64, + pub counterparty_upgrade_sequence: Sequence, } impl MsgChannelCloseConfirm { @@ -30,7 +31,7 @@ impl MsgChannelCloseConfirm { channel_id, proofs, signer, - counterparty_upgrade_sequence: 0, + counterparty_upgrade_sequence: Sequence::from(0), } } } @@ -75,7 +76,7 @@ impl TryFrom for MsgChannelCloseConfirm { channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, proofs, signer: raw_msg.signer.parse().map_err(Error::signer)?, - counterparty_upgrade_sequence: raw_msg.counterparty_upgrade_sequence, + counterparty_upgrade_sequence: raw_msg.counterparty_upgrade_sequence.into(), }) } } @@ -88,7 +89,7 @@ impl From for RawMsgChannelCloseConfirm { proof_init: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), signer: domain_msg.signer.to_string(), - counterparty_upgrade_sequence: domain_msg.counterparty_upgrade_sequence, + counterparty_upgrade_sequence: domain_msg.counterparty_upgrade_sequence.into(), } } } diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_cancel.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_cancel.rs new file mode 100644 index 0000000000..f2e33039b1 --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_cancel.rs @@ -0,0 +1,241 @@ +use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeCancel as RawMsgChannelUpgradeCancel; +use ibc_proto::Protobuf; + +use crate::core::ics04_channel::error::Error; +use crate::core::ics04_channel::upgrade::ErrorReceipt; +use crate::core::ics23_commitment::commitment::CommitmentProofBytes; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; +use crate::tx_msg::Msg; +use crate::Height; + +pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeCancel"; + +/// Message definition the `ChanUpgradeCancel` datagram. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgChannelUpgradeCancel { + pub port_id: PortId, + pub channel_id: ChannelId, + pub error_receipt: ErrorReceipt, + /// The proof of the counterparty error receipt + pub proof_error_receipt: CommitmentProofBytes, + /// The height at which the proofs were queried. + pub proof_height: Height, + pub signer: Signer, +} + +impl MsgChannelUpgradeCancel { + #[allow(clippy::too_many_arguments)] + pub fn new( + port_id: PortId, + channel_id: ChannelId, + error_receipt: ErrorReceipt, + proof_error_receipt: CommitmentProofBytes, + proof_height: Height, + signer: Signer, + ) -> Self { + Self { + port_id, + channel_id, + error_receipt, + proof_error_receipt, + proof_height, + signer, + } + } +} + +impl Msg for MsgChannelUpgradeCancel { + type ValidationError = Error; + type Raw = RawMsgChannelUpgradeCancel; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + +impl Protobuf for MsgChannelUpgradeCancel {} + +impl TryFrom for MsgChannelUpgradeCancel { + type Error = Error; + + fn try_from(raw_msg: RawMsgChannelUpgradeCancel) -> Result { + let raw_error_receipt = raw_msg + .error_receipt + .ok_or(Error::missing_upgrade_error_receipt())?; + let error_receipt = ErrorReceipt::try_from(raw_error_receipt)?; + + let proof_height = raw_msg + .proof_height + .ok_or_else(Error::missing_proof_height)? + .try_into() + .map_err(|_| Error::invalid_proof_height())?; + + Ok(MsgChannelUpgradeCancel { + port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, + channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, + error_receipt, + proof_error_receipt: raw_msg + .proof_error_receipt + .try_into() + .map_err(Error::invalid_proof)?, + proof_height, + signer: raw_msg.signer.parse().map_err(Error::signer)?, + }) + } +} + +impl From for RawMsgChannelUpgradeCancel { + fn from(domain_msg: MsgChannelUpgradeCancel) -> Self { + RawMsgChannelUpgradeCancel { + port_id: domain_msg.port_id.to_string(), + channel_id: domain_msg.channel_id.to_string(), + error_receipt: Some(domain_msg.error_receipt.into()), + proof_error_receipt: domain_msg.proof_error_receipt.into(), + proof_height: Some(domain_msg.proof_height.into()), + signer: domain_msg.signer.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use ibc_proto::ibc::core::channel::v1::ErrorReceipt as RawErrorReceipt; + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeCancel as RawMsgChannelUpgradeCancel; + use ibc_proto::ibc::core::client::v1::Height as RawHeight; + + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; + + /// Returns a dummy `RawMsgChannelUpgradeCnacel`, for testing only! + pub fn get_dummy_raw_msg_chan_upgrade_cancel() -> RawMsgChannelUpgradeCancel { + RawMsgChannelUpgradeCancel { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + error_receipt: Some(RawErrorReceipt { + sequence: 1, + message: "error message".to_string(), + }), + proof_error_receipt: get_dummy_proof(), + proof_height: Some(RawHeight { + revision_number: 1, + revision_height: 1, + }), + signer: get_dummy_bech32_account(), + } + } +} + +#[cfg(test)] +mod tests { + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeCancel as RawMsgChannelUpgradeCancel; + + use crate::core::ics04_channel::msgs::chan_upgrade_cancel::test_util::get_dummy_raw_msg_chan_upgrade_cancel; + use crate::core::ics04_channel::msgs::chan_upgrade_cancel::MsgChannelUpgradeCancel; + + #[test] + fn parse_channel_upgrade_try_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeCancel, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_cancel(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name: "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeCancel { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeCancel { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeCancel { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeCancel { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeCancel { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeCancel { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Empty proof channel".to_string(), + raw: RawMsgChannelUpgradeCancel { + proof_error_receipt: vec![], + ..default_raw_msg + }, + want_pass: false, + }, + ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeCancel::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "RawMsgChannelUpgradeCancel::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_cancel(); + let msg = MsgChannelUpgradeCancel::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeCancel::from(msg.clone()); + let msg_back = MsgChannelUpgradeCancel::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs index c928d9dea9..a91e65de2e 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs @@ -42,10 +42,10 @@ impl MsgChannelUpgradeOpen { port_id, channel_id, counterparty_channel_state, + counterparty_upgrade_sequence, proof_channel, proof_height, signer, - counterparty_upgrade_sequence, } } } diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_timeout.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_timeout.rs new file mode 100644 index 0000000000..e6bbe74fd9 --- /dev/null +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_timeout.rs @@ -0,0 +1,258 @@ +use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTimeout as RawMsgChannelUpgradeTimeout; +use ibc_proto::Protobuf; + +use crate::core::ics04_channel::channel::ChannelEnd; +use crate::core::ics04_channel::error::Error; +use crate::core::ics23_commitment::commitment::CommitmentProofBytes; +use crate::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; +use crate::tx_msg::Msg; +use crate::Height; + +pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelUpgradeTimeout"; + +/// Message definition the `ChanUpgradeTimeout` datagram. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgChannelUpgradeTimeout { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_channel: ChannelEnd, + /// The proof of the counterparty channel + pub proof_channel: CommitmentProofBytes, + /// The height at which the proofs were queried. + pub proof_height: Height, + pub signer: Signer, +} + +impl MsgChannelUpgradeTimeout { + #[allow(clippy::too_many_arguments)] + pub fn new( + port_id: PortId, + channel_id: ChannelId, + counterparty_channel: ChannelEnd, + proof_channel: CommitmentProofBytes, + proof_height: Height, + signer: Signer, + ) -> Self { + Self { + port_id, + channel_id, + counterparty_channel, + proof_channel, + proof_height, + signer, + } + } +} + +impl Msg for MsgChannelUpgradeTimeout { + type ValidationError = Error; + type Raw = RawMsgChannelUpgradeTimeout; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + +impl Protobuf for MsgChannelUpgradeTimeout {} + +impl TryFrom for MsgChannelUpgradeTimeout { + type Error = Error; + + fn try_from(raw_msg: RawMsgChannelUpgradeTimeout) -> Result { + let raw_counterparty_channel = raw_msg + .counterparty_channel + .ok_or(Error::missing_channel())?; + let counterparty_channel = ChannelEnd::try_from(raw_counterparty_channel)?; + + let proof_height = raw_msg + .proof_height + .ok_or_else(Error::missing_proof_height)? + .try_into() + .map_err(|_| Error::invalid_proof_height())?; + + Ok(MsgChannelUpgradeTimeout { + port_id: raw_msg.port_id.parse().map_err(Error::identifier)?, + channel_id: raw_msg.channel_id.parse().map_err(Error::identifier)?, + counterparty_channel, + proof_channel: raw_msg + .proof_channel + .try_into() + .map_err(Error::invalid_proof)?, + proof_height, + signer: raw_msg.signer.parse().map_err(Error::signer)?, + }) + } +} + +impl From for RawMsgChannelUpgradeTimeout { + fn from(domain_msg: MsgChannelUpgradeTimeout) -> Self { + RawMsgChannelUpgradeTimeout { + port_id: domain_msg.port_id.to_string(), + channel_id: domain_msg.channel_id.to_string(), + counterparty_channel: Some(domain_msg.counterparty_channel.into()), + proof_channel: domain_msg.proof_channel.into(), + proof_height: Some(domain_msg.proof_height.into()), + signer: domain_msg.signer.to_string(), + } + } +} + +#[cfg(test)] +pub mod test_util { + use crate::core::ics04_channel::channel::test_util::get_dummy_raw_channel_end; + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTimeout as RawMsgChannelUpgradeTimeout; + use ibc_proto::ibc::core::client::v1::Height as RawHeight; + + use crate::core::ics24_host::identifier::{ChannelId, PortId}; + use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof}; + + /// Returns a dummy `RawMsgChannelUpgradeCnacel`, for testing only! + pub fn get_dummy_raw_msg_chan_upgrade_timeout() -> RawMsgChannelUpgradeTimeout { + RawMsgChannelUpgradeTimeout { + port_id: PortId::default().to_string(), + channel_id: ChannelId::default().to_string(), + counterparty_channel: Some(get_dummy_raw_channel_end()), + proof_channel: get_dummy_proof(), + proof_height: Some(RawHeight { + revision_number: 1, + revision_height: 1, + }), + signer: get_dummy_bech32_account(), + } + } +} + +#[cfg(test)] +mod tests { + use test_log::test; + + use ibc_proto::ibc::core::channel::v1::MsgChannelUpgradeTimeout as RawMsgChannelUpgradeTimeout; + use ibc_proto::ibc::core::client::v1::Height; + + use crate::core::ics04_channel::msgs::chan_upgrade_timeout::test_util::get_dummy_raw_msg_chan_upgrade_timeout; + use crate::core::ics04_channel::msgs::chan_upgrade_timeout::MsgChannelUpgradeTimeout; + + #[test] + fn parse_channel_upgrade_try_msg() { + struct Test { + name: String, + raw: RawMsgChannelUpgradeTimeout, + want_pass: bool, + } + + let default_raw_msg = get_dummy_raw_msg_chan_upgrade_timeout(); + + let tests: Vec = vec![ + Test { + name: "Good parameters".to_string(), + raw: default_raw_msg.clone(), + want_pass: true, + }, + Test { + name: "Correct port ID".to_string(), + raw: RawMsgChannelUpgradeTimeout { + port_id: "p36".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Port too short".to_string(), + raw: RawMsgChannelUpgradeTimeout { + port_id: "p".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Port too long".to_string(), + raw: RawMsgChannelUpgradeTimeout { + port_id: "abcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstuabcdefsdfasdfasdfasdfasdfasdfadsfasdgafsgadfasdfasdfasdfsdfasdfaghijklmnopqrstu".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Correct channel ID".to_string(), + raw: RawMsgChannelUpgradeTimeout { + channel_id: "channel-2".to_string(), + ..default_raw_msg.clone() + }, + want_pass: true, + }, + Test { + name: "Channel name too short".to_string(), + raw: RawMsgChannelUpgradeTimeout { + channel_id: "c".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Channel name too long".to_string(), + raw: RawMsgChannelUpgradeTimeout { + channel_id: "channel-128391283791827398127398791283912837918273981273987912839".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Empty proof channel".to_string(), + raw: RawMsgChannelUpgradeTimeout { + proof_channel: vec![], + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Bad proof height, height = 0".to_string(), + raw: RawMsgChannelUpgradeTimeout { + proof_height: Some(Height { + revision_number: 0, + revision_height: 0, + }), + ..default_raw_msg.clone() + }, + want_pass: false, + }, + Test { + name: "Missing proof height".to_string(), + raw: RawMsgChannelUpgradeTimeout { + proof_height: None, + ..default_raw_msg.clone() + }, + want_pass: false, + }, + ] + .into_iter() + .collect(); + + for test in tests { + let res = MsgChannelUpgradeTimeout::try_from(test.raw.clone()); + + assert_eq!( + test.want_pass, + res.is_ok(), + "RawMsgChannelUpgradeTimeout::try_from failed for test {}, \nraw msg {:?} with err {:?}", + test.name, + test.raw, + res.err() + ); + } + } + + #[test] + fn to_and_from() { + let raw = get_dummy_raw_msg_chan_upgrade_timeout(); + let msg = MsgChannelUpgradeTimeout::try_from(raw.clone()).unwrap(); + let raw_back = RawMsgChannelUpgradeTimeout::from(msg.clone()); + let msg_back = MsgChannelUpgradeTimeout::try_from(raw_back.clone()).unwrap(); + assert_eq!(raw, raw_back); + assert_eq!(msg, msg_back); + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/timeout_on_close.rs b/crates/relayer-types/src/core/ics04_channel/msgs/timeout_on_close.rs index c83ee0417e..17a47fe2a0 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/timeout_on_close.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/timeout_on_close.rs @@ -18,7 +18,7 @@ pub struct MsgTimeoutOnClose { pub next_sequence_recv: Sequence, pub proofs: Proofs, pub signer: Signer, - pub counterparty_upgrade_sequence: u64, + pub counterparty_upgrade_sequence: Sequence, } impl MsgTimeoutOnClose { @@ -27,7 +27,7 @@ impl MsgTimeoutOnClose { next_sequence_recv: Sequence, proofs: Proofs, signer: Signer, - counterparty_upgrade_sequence: u64, + counterparty_upgrade_sequence: Sequence, ) -> MsgTimeoutOnClose { Self { packet, @@ -89,7 +89,7 @@ impl TryFrom for MsgTimeoutOnClose { next_sequence_recv: Sequence::from(raw_msg.next_sequence_recv), signer: raw_msg.signer.parse().map_err(Error::signer)?, proofs, - counterparty_upgrade_sequence: raw_msg.counterparty_upgrade_sequence, + counterparty_upgrade_sequence: raw_msg.counterparty_upgrade_sequence.into(), }) } } @@ -106,7 +106,7 @@ impl From for RawMsgTimeoutOnClose { proof_height: Some(domain_msg.proofs.height().into()), next_sequence_recv: domain_msg.next_sequence_recv.into(), signer: domain_msg.signer.to_string(), - counterparty_upgrade_sequence: domain_msg.counterparty_upgrade_sequence, + counterparty_upgrade_sequence: domain_msg.counterparty_upgrade_sequence.into(), } } } diff --git a/crates/relayer-types/src/core/ics04_channel/timeout.rs b/crates/relayer-types/src/core/ics04_channel/timeout.rs index 2d53a7c2e3..cee5f40601 100644 --- a/crates/relayer-types/src/core/ics04_channel/timeout.rs +++ b/crates/relayer-types/src/core/ics04_channel/timeout.rs @@ -1,14 +1,16 @@ use core::fmt::{Display, Error as FmtError, Formatter}; +use std::str::FromStr; +use flex_error::{define_error, TraceError}; use serde::{Deserialize, Serialize}; -use ibc_proto::ibc::core::channel::v1::Timeout as RawUpgradeTimeout; +use ibc_proto::ibc::core::channel::v1::Timeout as RawTimeout; use ibc_proto::ibc::core::client::v1::Height as RawHeight; use ibc_proto::Protobuf; use crate::core::ics02_client::{error::Error as ICS2Error, height::Height}; use crate::core::ics04_channel::error::Error as ChannelError; -use crate::timestamp::Timestamp; +use crate::timestamp::{ParseTimestampError, Timestamp}; /// Indicates a consensus height on the destination chain after which the packet /// will no longer be processed, and will instead count as having timed-out. @@ -188,8 +190,8 @@ impl<'de> Deserialize<'de> for TimeoutHeight { /// A composite of timeout height and timeout timestamp types, useful for when /// performing a channel upgrade handshake, as there are cases when only timeout /// height is set, only timeout timestamp is set, or both are set. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum UpgradeTimeout { +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub enum Timeout { /// Timeout height indicates the height at which the counterparty /// must no longer proceed with the upgrade handshake. /// The chains will then preserve their original channel and the upgrade handshake is aborted @@ -204,31 +206,73 @@ pub enum UpgradeTimeout { Both(Height, Timestamp), } -impl UpgradeTimeout { +impl Display for Timeout { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + match self { + Self::Height(height) => write!(f, "{height}"), + Self::Timestamp(timestamp) => write!(f, "{timestamp}"), + Self::Both(height, timestamp) => write!(f, "{height}, {timestamp}"), + } + } +} + +impl Timeout { pub fn new(height: Option, timestamp: Option) -> Result { match (height, timestamp) { - (Some(height), None) => Ok(UpgradeTimeout::Height(height)), - (None, Some(timestamp)) => Ok(UpgradeTimeout::Timestamp(timestamp)), - (Some(height), Some(timestamp)) => Ok(UpgradeTimeout::Both(height, timestamp)), + (Some(height), None) => Ok(Timeout::Height(height)), + (None, Some(timestamp)) => Ok(Timeout::Timestamp(timestamp)), + (Some(height), Some(timestamp)) => Ok(Timeout::Both(height, timestamp)), (None, None) => Err(ChannelError::missing_upgrade_timeout()), } } pub fn into_tuple(self) -> (Option, Option) { match self { - UpgradeTimeout::Height(height) => (Some(height), None), - UpgradeTimeout::Timestamp(timestamp) => (None, Some(timestamp)), - UpgradeTimeout::Both(height, timestamp) => (Some(height), Some(timestamp)), + Timeout::Height(height) => (Some(height), None), + Timeout::Timestamp(timestamp) => (None, Some(timestamp)), + Timeout::Both(height, timestamp) => (Some(height), Some(timestamp)), + } + } +} + +define_error! { + #[derive(Debug, PartialEq, Eq)] + TimeoutError { + InvalidTimestamp + { timestamp: String } + [ TraceError ] + |e| { format_args!("cannot convert into a `Timestamp` type from string {0}", e.timestamp) }, + + InvalidTimeout + { timeout: String } + |e| { format_args!("invalid timeout {0}", e.timeout) }, + } +} + +impl FromStr for Timeout { + type Err = TimeoutError; + + fn from_str(value: &str) -> Result { + let split: Vec<&str> = value.split(' ').collect(); + + if split.len() != 2 { + return Err(TimeoutError::invalid_timeout(value.to_owned())); } + + // only timeout timestamp are supported at the moment + split[1] + .parse::() + .map(Timeout::Timestamp) + .map_err(|e| TimeoutError::invalid_timestamp(value.to_owned(), e)) } } -impl Protobuf for UpgradeTimeout {} +impl Protobuf for Timeout {} -impl TryFrom for UpgradeTimeout { +impl TryFrom for Timeout { type Error = ChannelError; - fn try_from(value: RawUpgradeTimeout) -> Result { + fn try_from(value: RawTimeout) -> Result { let raw_timeout_height = value.height.map(Height::try_from).transpose(); let raw_timeout_timestamp = Timestamp::from_nanoseconds(value.timestamp) @@ -252,18 +296,18 @@ impl TryFrom for UpgradeTimeout { } } -impl From for RawUpgradeTimeout { - fn from(value: UpgradeTimeout) -> Self { +impl From for RawTimeout { + fn from(value: Timeout) -> Self { match value { - UpgradeTimeout::Height(height) => Self { + Timeout::Height(height) => Self { height: Some(RawHeight::from(height)), timestamp: 0, }, - UpgradeTimeout::Timestamp(timestamp) => Self { + Timeout::Timestamp(timestamp) => Self { height: None, timestamp: timestamp.nanoseconds(), }, - UpgradeTimeout::Both(height, timestamp) => Self { + Timeout::Both(height, timestamp) => Self { height: Some(RawHeight::from(height)), timestamp: timestamp.nanoseconds(), }, @@ -273,13 +317,13 @@ impl From for RawUpgradeTimeout { #[cfg(test)] pub mod test_util { - use ibc_proto::ibc::core::channel::v1::Timeout as RawUpgradeTimeout; + use ibc_proto::ibc::core::channel::v1::Timeout as RawTimeout; use ibc_proto::ibc::core::client::v1::Height as RawHeight; use crate::core::ics02_client::height::Height; - pub fn get_dummy_upgrade_timeout() -> RawUpgradeTimeout { - RawUpgradeTimeout { + pub fn get_dummy_upgrade_timeout() -> RawTimeout { + RawTimeout { height: Some(RawHeight::from(Height::new(1, 50).unwrap())), timestamp: 0, } diff --git a/crates/relayer-types/src/core/ics04_channel/upgrade.rs b/crates/relayer-types/src/core/ics04_channel/upgrade.rs index ce0f0ec24d..a909859cf5 100644 --- a/crates/relayer-types/src/core/ics04_channel/upgrade.rs +++ b/crates/relayer-types/src/core/ics04_channel/upgrade.rs @@ -1,17 +1,18 @@ +use ibc_proto::ibc::core::channel::v1::ErrorReceipt as RawErrorReceipt; use ibc_proto::ibc::core::channel::v1::Upgrade as RawUpgrade; use ibc_proto::Protobuf; use crate::core::ics04_channel::error::Error as ChannelError; use crate::core::ics04_channel::packet::Sequence; -use crate::core::ics04_channel::timeout::UpgradeTimeout; +use crate::core::ics04_channel::timeout::Timeout; use crate::core::ics04_channel::upgrade_fields::UpgradeFields; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Upgrade { pub fields: UpgradeFields, // timeout can be zero, see `TryFrom` implementation - pub timeout: Option, - pub latest_sequence_send: Sequence, + pub timeout: Option, + pub next_sequence_send: Sequence, } impl Protobuf for Upgrade {} @@ -26,14 +27,14 @@ impl TryFrom for Upgrade { .try_into()?; let timeout = value .timeout - .filter(|tm| UpgradeTimeout::try_from(tm.clone()).is_ok()) - .map(|tm| UpgradeTimeout::try_from(tm).unwrap()); - let latest_sequence_send = value.next_sequence_send.into(); + .filter(|tm| Timeout::try_from(tm.clone()).is_ok()) + .map(|tm| Timeout::try_from(tm).unwrap()); + let next_sequence_send = value.next_sequence_send.into(); Ok(Self { fields, timeout, - latest_sequence_send, + next_sequence_send, }) } } @@ -44,7 +45,35 @@ impl From for RawUpgrade { Self { fields: Some(value.fields.into()), timeout, - next_sequence_send: value.latest_sequence_send.into(), + next_sequence_send: value.next_sequence_send.into(), + } + } +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ErrorReceipt { + pub sequence: Sequence, + pub message: String, +} + +impl Protobuf for ErrorReceipt {} + +impl TryFrom for ErrorReceipt { + type Error = ChannelError; + + fn try_from(value: RawErrorReceipt) -> Result { + Ok(Self { + sequence: value.sequence.into(), + message: value.message, + }) + } +} + +impl From for RawErrorReceipt { + fn from(value: ErrorReceipt) -> Self { + Self { + sequence: value.sequence.into(), + message: value.message, } } } diff --git a/crates/relayer-types/src/core/ics04_channel/version.rs b/crates/relayer-types/src/core/ics04_channel/version.rs index 493648e785..151b97f746 100644 --- a/crates/relayer-types/src/core/ics04_channel/version.rs +++ b/crates/relayer-types/src/core/ics04_channel/version.rs @@ -36,6 +36,15 @@ impl Version { Self::new(val.to_string()) } + pub fn app_version_with_fee(app_version: &str) -> Self { + let val = json::json!({ + "fee_version": "ics29-1", + "app_version": app_version, + }); + + Self::new(val.to_string()) + } + pub fn empty() -> Self { Self::new("".to_string()) } diff --git a/crates/relayer-types/src/core/ics24_host/path.rs b/crates/relayer-types/src/core/ics24_host/path.rs index 5efcc62536..41d76d4012 100644 --- a/crates/relayer-types/src/core/ics24_host/path.rs +++ b/crates/relayer-types/src/core/ics24_host/path.rs @@ -43,6 +43,14 @@ pub enum Path { Receipts(ReceiptsPath), Upgrade(ClientUpgradePath), ChannelUpgrade(ChannelUpgradePath), + ChannelUpgradeError(ChannelUpgradeErrorPath), +} + +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)] +#[display(fmt = "channelUpgrades/upgradeError/ports/{port_id}/channels/{channel_id}")] +pub struct ChannelUpgradeErrorPath { + pub port_id: PortId, + pub channel_id: ChannelId, } #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Display)] diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index ea4156b7f6..bd454e0da3 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -134,6 +134,8 @@ const CHANNEL_UPGRADE_TRY_EVENT: &str = "channel_upgrade_try"; const CHANNEL_UPGRADE_ACK_EVENT: &str = "channel_upgrade_ack"; const CHANNEL_UPGRADE_CONFIRM_EVENT: &str = "channel_upgrade_confirm"; const CHANNEL_UPGRADE_OPEN_EVENT: &str = "channel_upgrade_open"; +const CHANNEL_UPGRADE_CANCEL_EVENT: &str = "channel_upgrade_cancelled"; +const CHANNEL_UPGRADE_TIMEOUT_EVENT: &str = "channel_upgrade_timeout"; /// Packet event types const SEND_PACKET_EVENT: &str = "send_packet"; const RECEIVE_PACKET_EVENT: &str = "receive_packet"; @@ -170,6 +172,8 @@ pub enum IbcEventType { UpgradeAckChannel, UpgradeConfirmChannel, UpgradeOpenChannel, + UpgradeCancelChannel, + UpgradeTimeoutChannel, SendPacket, ReceivePacket, WriteAck, @@ -207,6 +211,8 @@ impl IbcEventType { IbcEventType::UpgradeAckChannel => CHANNEL_UPGRADE_ACK_EVENT, IbcEventType::UpgradeConfirmChannel => CHANNEL_UPGRADE_CONFIRM_EVENT, IbcEventType::UpgradeOpenChannel => CHANNEL_UPGRADE_OPEN_EVENT, + IbcEventType::UpgradeCancelChannel => CHANNEL_UPGRADE_CANCEL_EVENT, + IbcEventType::UpgradeTimeoutChannel => CHANNEL_UPGRADE_TIMEOUT_EVENT, IbcEventType::SendPacket => SEND_PACKET_EVENT, IbcEventType::ReceivePacket => RECEIVE_PACKET_EVENT, IbcEventType::WriteAck => WRITE_ACK_EVENT, @@ -248,6 +254,8 @@ impl FromStr for IbcEventType { CHANNEL_UPGRADE_ACK_EVENT => Ok(IbcEventType::UpgradeAckChannel), CHANNEL_UPGRADE_CONFIRM_EVENT => Ok(IbcEventType::UpgradeConfirmChannel), CHANNEL_UPGRADE_OPEN_EVENT => Ok(IbcEventType::UpgradeOpenChannel), + CHANNEL_UPGRADE_CANCEL_EVENT => Ok(IbcEventType::UpgradeCancelChannel), + CHANNEL_UPGRADE_TIMEOUT_EVENT => Ok(IbcEventType::UpgradeTimeoutChannel), SEND_PACKET_EVENT => Ok(IbcEventType::SendPacket), RECEIVE_PACKET_EVENT => Ok(IbcEventType::ReceivePacket), WRITE_ACK_EVENT => Ok(IbcEventType::WriteAck), @@ -291,6 +299,8 @@ pub enum IbcEvent { UpgradeAckChannel(ChannelEvents::UpgradeAck), UpgradeConfirmChannel(ChannelEvents::UpgradeConfirm), UpgradeOpenChannel(ChannelEvents::UpgradeOpen), + UpgradeCancelChannel(ChannelEvents::UpgradeCancel), + UpgradeTimeoutChannel(ChannelEvents::UpgradeTimeout), SendPacket(ChannelEvents::SendPacket), ReceivePacket(ChannelEvents::ReceivePacket), @@ -335,6 +345,8 @@ impl Display for IbcEvent { IbcEvent::UpgradeAckChannel(ev) => write!(f, "UpgradeAckChannel({ev})"), IbcEvent::UpgradeConfirmChannel(ev) => write!(f, "UpgradeConfirmChannel({ev})"), IbcEvent::UpgradeOpenChannel(ev) => write!(f, "UpgradeOpenChannel({ev})"), + IbcEvent::UpgradeCancelChannel(ev) => write!(f, "UpgradeCancelChannel({ev})"), + IbcEvent::UpgradeTimeoutChannel(ev) => write!(f, "UpgradeTimeoutChannel({ev})"), IbcEvent::SendPacket(ev) => write!(f, "SendPacket({ev})"), IbcEvent::ReceivePacket(ev) => write!(f, "ReceivePacket({ev})"), @@ -385,6 +397,8 @@ impl IbcEvent { IbcEvent::UpgradeAckChannel(_) => IbcEventType::UpgradeAckChannel, IbcEvent::UpgradeConfirmChannel(_) => IbcEventType::UpgradeConfirmChannel, IbcEvent::UpgradeOpenChannel(_) => IbcEventType::UpgradeOpenChannel, + IbcEvent::UpgradeCancelChannel(_) => IbcEventType::UpgradeCancelChannel, + IbcEvent::UpgradeTimeoutChannel(_) => IbcEventType::UpgradeTimeoutChannel, IbcEvent::SendPacket(_) => IbcEventType::SendPacket, IbcEvent::ReceivePacket(_) => IbcEventType::ReceivePacket, IbcEvent::WriteAcknowledgement(_) => IbcEventType::WriteAck, @@ -416,6 +430,8 @@ impl IbcEvent { IbcEvent::UpgradeAckChannel(ev) => Some(ev.into()), IbcEvent::UpgradeConfirmChannel(ev) => Some(ev.into()), IbcEvent::UpgradeOpenChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeCancelChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeTimeoutChannel(ev) => Some(ev.into()), _ => None, } } diff --git a/crates/relayer-types/src/mock/client_state.rs b/crates/relayer-types/src/mock/client_state.rs index 98917b0ef0..3a92852767 100644 --- a/crates/relayer-types/src/mock/client_state.rs +++ b/crates/relayer-types/src/mock/client_state.rs @@ -25,13 +25,15 @@ pub const MOCK_CLIENT_STATE_TYPE_URL: &str = "/ibc.mock.ClientState"; pub struct MockClientState { pub header: MockHeader, pub frozen_height: Option, + pub trusting_period: u64, } impl MockClientState { - pub fn new(header: MockHeader) -> Self { + pub fn new(header: MockHeader, trusting_period: u64) -> Self { Self { header, frozen_height: None, + trusting_period, } } @@ -46,19 +48,23 @@ impl TryFrom for MockClientState { type Error = Error; fn try_from(raw: RawMockClientState) -> Result { - Ok(Self::new(raw.header.unwrap().try_into()?)) + Ok(Self::new( + raw.header.unwrap().try_into()?, + raw.trusting_period, + )) } } impl From for RawMockClientState { fn from(value: MockClientState) -> Self { + let frozen = value.frozen_height.is_some(); RawMockClientState { header: Some(ibc_proto::ibc::mock::Header { height: Some(value.header.height().into()), timestamp: value.header.timestamp.nanoseconds(), }), - frozen: false, - trusting_period: 14 * 24 * 60 * 60, + frozen, + trusting_period: value.trusting_period, } } } @@ -130,6 +136,8 @@ impl ClientState for MockClientState { impl From for MockClientState { fn from(cs: MockConsensusState) -> Self { - Self::new(cs.header) + // 14 days in seconds + let trusting_period = 1209600u64; + Self::new(cs.header, trusting_period) } } diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index 031fc81778..8330fb3b5a 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -22,10 +22,9 @@ use ibc_proto::cosmos::staking::v1beta1::Params as StakingParams; use ibc_proto::ibc::apps::fee::v1::{ QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse, }; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; use ibc_proto::interchain_security::ccv::v1::ConsumerParams as CcvConsumerParams; use ibc_proto::Protobuf; -use ibc_relayer_types::applications::ics31_icq::response::CrossChainQueryResponse; use ibc_relayer_types::clients::ics07_tendermint::client_state::{ AllowUpdate, ClientState as TmClientState, }; @@ -45,15 +44,23 @@ use ibc_relayer_types::core::ics24_host::identifier::{ ChainId, ChannelId, ClientId, ConnectionId, PortId, }; use ibc_relayer_types::core::ics24_host::path::{ - AcksPath, ChannelEndsPath, ChannelUpgradePath, ClientConsensusStatePath, ClientStatePath, - CommitmentsPath, ConnectionsPath, ReceiptsPath, SeqRecvsPath, + AcksPath, ChannelEndsPath, ChannelUpgradeErrorPath, ChannelUpgradePath, + ClientConsensusStatePath, ClientStatePath, CommitmentsPath, ConnectionsPath, ReceiptsPath, + SeqRecvsPath, }; use ibc_relayer_types::core::ics24_host::{ ClientUpgradePath, Path, IBC_QUERY_PATH, SDK_UPGRADE_QUERY_PATH, }; -use ibc_relayer_types::core::{ics02_client::height::Height, ics04_channel::upgrade::Upgrade}; +use ibc_relayer_types::core::{ + ics02_client::height::Height, ics04_channel::upgrade::ErrorReceipt, + ics04_channel::upgrade::Upgrade, +}; use ibc_relayer_types::signer::Signer; use ibc_relayer_types::Height as ICSHeight; +use ibc_relayer_types::{ + applications::ics31_icq::response::CrossChainQueryResponse, + core::ics04_channel::channel::{State, UpgradeState}, +}; use tendermint::block::Height as TmHeight; use tendermint::node::{self, info::TxIndexStatus}; @@ -1661,7 +1668,9 @@ impl ChainEndpoint for CosmosSdkChain { .map_err(|e| Error::grpc_status(e, "query_connection_channels".to_owned()))? .into_inner(); - let channels = response + let height = self.query_chain_latest_height()?; + + let channels: Vec = response .channels .into_iter() .filter_map(|ch| { @@ -1675,7 +1684,26 @@ impl ChainEndpoint for CosmosSdkChain { }) .ok() }) + .map(|mut channel| { + // If the channel is open, look for an upgrade in order to correctly set the + // state to Open(Upgrading) or Open(NotUpgrading) + if channel.channel_end.is_open() + && self + .query_upgrade( + QueryUpgradeRequest { + port_id: channel.port_id.to_string(), + channel_id: channel.channel_id.to_string(), + }, + height, + ) + .is_ok() + { + channel.channel_end.state = State::Open(UpgradeState::Upgrading); + } + channel + }) .collect(); + Ok(channels) } @@ -1711,6 +1739,8 @@ impl ChainEndpoint for CosmosSdkChain { .map_err(|e| Error::grpc_status(e, "query_channels".to_owned()))? .into_inner(); + let height = self.query_chain_latest_height()?; + let channels = response .channels .into_iter() @@ -1725,6 +1755,24 @@ impl ChainEndpoint for CosmosSdkChain { }) .ok() }) + .map(|mut channel| { + // If the channel is open, look for an upgrade in order to correctly set the + // state to Open(Upgrading) or Open(NotUpgrading) + if channel.channel_end.is_open() + && self + .query_upgrade( + QueryUpgradeRequest { + port_id: channel.port_id.to_string(), + channel_id: channel.channel_id.to_string(), + }, + height, + ) + .is_ok() + { + channel.channel_end.state = State::Open(UpgradeState::Upgrading); + } + channel + }) .collect(); Ok(channels) @@ -1744,12 +1792,33 @@ impl ChainEndpoint for CosmosSdkChain { crate::telemetry!(query, self.id(), "query_channel"); let res = self.query( - ChannelEndsPath(request.port_id, request.channel_id), + ChannelEndsPath(request.port_id.clone(), request.channel_id.clone()), request.height, matches!(include_proof, IncludeProof::Yes), )?; - let channel_end = ChannelEnd::decode_vec(&res.value).map_err(Error::decode)?; + let mut channel_end = ChannelEnd::decode_vec(&res.value).map_err(Error::decode)?; + + if channel_end.is_open() { + let height = match request.height { + QueryHeight::Latest => self.query_chain_latest_height()?, + QueryHeight::Specific(height) => height, + }; + // In order to determine if the channel is Open upgrading or not the Upgrade is queried. + // If an upgrade is ongoing then the query will succeed in finding an Upgrade. + if self + .query_upgrade( + QueryUpgradeRequest { + port_id: request.port_id.to_string(), + channel_id: request.channel_id.to_string(), + }, + height, + ) + .is_ok() + { + channel_end.state = State::Open(UpgradeState::Upgrading); + } + } match include_proof { IncludeProof::Yes => { @@ -2399,6 +2468,29 @@ impl ChainEndpoint for CosmosSdkChain { Ok((upgrade, Some(proof))) } + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + ) -> Result<(ErrorReceipt, Option), Error> { + let port_id = PortId::from_str(&request.port_id) + .map_err(|_| Error::invalid_port_string(request.port_id))?; + let channel_id = ChannelId::from_str(&request.channel_id) + .map_err(|_| Error::invalid_channel_string(request.channel_id))?; + let res = self.query( + ChannelUpgradeErrorPath { + port_id, + channel_id, + }, + QueryHeight::Specific(height), + true, + )?; + let proof = res.proof.ok_or_else(Error::empty_response_proof)?; + let error_receipt = ErrorReceipt::decode_vec(&res.value).map_err(Error::decode)?; + + Ok((error_receipt, Some(proof))) + } } fn sort_events_by_sequence(events: &mut [IbcEventWithHeight]) { @@ -2584,24 +2676,29 @@ mod tests { #[test] fn sort_clients_id_suffix() { + // 14 days in seconds + let trusting_period = 1209600u64; let mut clients: Vec = vec![ IdentifiedAnyClientState::new( ClientId::new(ClientType::Tendermint, 4).unwrap(), - AnyClientState::Mock(MockClientState::new(MockHeader::new( - Height::new(0, 1).unwrap(), - ))), + AnyClientState::Mock(MockClientState::new( + MockHeader::new(Height::new(0, 1).unwrap()), + trusting_period, + )), ), IdentifiedAnyClientState::new( ClientId::new(ClientType::Tendermint, 1).unwrap(), - AnyClientState::Mock(MockClientState::new(MockHeader::new( - Height::new(0, 1).unwrap(), - ))), + AnyClientState::Mock(MockClientState::new( + MockHeader::new(Height::new(0, 1).unwrap()), + trusting_period, + )), ), IdentifiedAnyClientState::new( ClientId::new(ClientType::Tendermint, 7).unwrap(), - AnyClientState::Mock(MockClientState::new(MockHeader::new( - Height::new(0, 1).unwrap(), - ))), + AnyClientState::Mock(MockClientState::new( + MockHeader::new(Height::new(0, 1).unwrap()), + trusting_period, + )), ), ]; clients.sort_by_cached_key(|c| client_id_suffix(&c.client_id).unwrap_or(0)); diff --git a/crates/relayer/src/chain/cosmos/types/events/channel.rs b/crates/relayer/src/chain/cosmos/types/events/channel.rs index 442d73a21d..85c627d95b 100644 --- a/crates/relayer/src/chain/cosmos/types/events/channel.rs +++ b/crates/relayer/src/chain/cosmos/types/events/channel.rs @@ -4,14 +4,16 @@ use ibc_relayer_types::core::ics02_client::height::HeightErrorDetail; use ibc_relayer_types::core::ics04_channel::error::Error; use ibc_relayer_types::core::ics04_channel::events::{ AcknowledgePacket, Attributes, CloseConfirm, CloseInit, EventType, OpenAck, OpenConfirm, - OpenInit, OpenTry, SendPacket, TimeoutPacket, WriteAcknowledgement, PKT_ACK_ATTRIBUTE_KEY, - PKT_DATA_ATTRIBUTE_KEY, PKT_DST_CHANNEL_ATTRIBUTE_KEY, PKT_DST_PORT_ATTRIBUTE_KEY, - PKT_SEQ_ATTRIBUTE_KEY, PKT_SRC_CHANNEL_ATTRIBUTE_KEY, PKT_SRC_PORT_ATTRIBUTE_KEY, - PKT_TIMEOUT_HEIGHT_ATTRIBUTE_KEY, PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY, + OpenInit, OpenTry, SendPacket, TimeoutPacket, UpgradeAttributes, UpgradeInit, + WriteAcknowledgement, PKT_ACK_ATTRIBUTE_KEY, PKT_DATA_ATTRIBUTE_KEY, + PKT_DST_CHANNEL_ATTRIBUTE_KEY, PKT_DST_PORT_ATTRIBUTE_KEY, PKT_SEQ_ATTRIBUTE_KEY, + PKT_SRC_CHANNEL_ATTRIBUTE_KEY, PKT_SRC_PORT_ATTRIBUTE_KEY, PKT_TIMEOUT_HEIGHT_ATTRIBUTE_KEY, + PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY, }; use ibc_relayer_types::core::ics04_channel::events::{ReceivePacket, TimeoutOnClosePacket}; use ibc_relayer_types::core::ics04_channel::packet::Packet; use ibc_relayer_types::core::ics04_channel::timeout::TimeoutHeight; +use ibc_relayer_types::core::ics24_host::identifier::ConnectionId; use ibc_relayer_types::events::Error as EventError; use ibc_relayer_types::Height; @@ -39,6 +41,45 @@ fn extract_attributes(object: &RawObject<'_>, namespace: &str) -> Result, + namespace: &str, +) -> Result { + let connection_hops: ConnectionId = + extract_attribute(object, &format!("{namespace}.connection_hops"))? + .parse() + .map_err(EventError::parse)?; + Ok(UpgradeAttributes { + port_id: extract_attribute(object, &format!("{namespace}.port_id"))? + .parse() + .map_err(EventError::parse)?, + channel_id: extract_attribute(object, &format!("{namespace}.channel_id"))? + .parse() + .map_err(EventError::parse)?, + counterparty_port_id: extract_attribute( + object, + &format!("{namespace}.counterparty_port_id"), + )? + .parse() + .map_err(EventError::parse)?, + counterparty_channel_id: maybe_extract_attribute( + object, + &format!("{namespace}.counterparty_channel_id"), + ) + .and_then(|v| v.parse().ok()), + upgrade_connection_hops: vec![connection_hops], + upgrade_version: extract_attribute(object, &format!("{namespace}.version"))?.into(), + upgrade_sequence: extract_attribute(object, &format!("{namespace}.upgrade_sequence"))? + .parse() + .map_err(|_| EventError::missing_action_string())?, + upgrade_ordering: extract_attribute(object, &format!("{namespace}.ordering"))? + .parse() + .map_err(|_| EventError::missing_action_string())?, + upgrade_timeout: maybe_extract_attribute(object, &format!("{namespace}.timeout")) + .and_then(|v| v.parse().ok()), + }) +} + macro_rules! impl_try_from_raw_obj_for_event { ($($event:ty),+) => { $(impl TryFrom> for $event { @@ -94,6 +135,14 @@ impl TryFrom> for WriteAcknowledgement { } } +impl TryFrom> for UpgradeInit { + type Error = EventError; + + fn try_from(obj: RawObject<'_>) -> Result { + extract_upgrade_attributes(&obj, Self::event_type().as_str())?.try_into() + } +} + /// Parse a string into a timeout height expected to be stored in /// `Packet.timeout_height`. We need to parse the timeout height differently /// because of a quirk introduced in ibc-go. See comment in diff --git a/crates/relayer/src/chain/endpoint.rs b/crates/relayer/src/chain/endpoint.rs index 300fa6df0e..acbf6406ec 100644 --- a/crates/relayer/src/chain/endpoint.rs +++ b/crates/relayer/src/chain/endpoint.rs @@ -1,8 +1,8 @@ use alloc::sync::Arc; use core::convert::TryFrom; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; use ibc_relayer_types::core::ics02_client::height::Height; -use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; +use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade}; use tokio::runtime::Runtime as TokioRuntime; @@ -696,4 +696,10 @@ pub trait ChainEndpoint: Sized { request: QueryUpgradeRequest, height: Height, ) -> Result<(Upgrade, Option), Error>; + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + ) -> Result<(ErrorReceipt, Option), Error>; } diff --git a/crates/relayer/src/chain/handle.rs b/crates/relayer/src/chain/handle.rs index 0d08c112ec..750a083e73 100644 --- a/crates/relayer/src/chain/handle.rs +++ b/crates/relayer/src/chain/handle.rs @@ -1,6 +1,6 @@ use alloc::sync::Arc; use core::fmt::{self, Debug, Display}; -use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; +use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade}; use crossbeam_channel as channel; use tracing::Span; @@ -8,7 +8,7 @@ use tracing::Span; use ibc_proto::ibc::apps::fee::v1::{ QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse, }; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, core::{ @@ -379,6 +379,12 @@ pub enum ChainRequest { height: Height, reply_to: ReplyTo<(Upgrade, Option)>, }, + + QueryUpgradeError { + request: QueryUpgradeErrorRequest, + height: Height, + reply_to: ReplyTo<(ErrorReceipt, Option)>, + }, } pub trait ChainHandle: Clone + Display + Send + Sync + Debug + 'static { @@ -698,4 +704,10 @@ pub trait ChainHandle: Clone + Display + Send + Sync + Debug + 'static { request: QueryUpgradeRequest, height: Height, ) -> Result<(Upgrade, Option), Error>; + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + ) -> Result<(ErrorReceipt, Option), Error>; } diff --git a/crates/relayer/src/chain/handle/base.rs b/crates/relayer/src/chain/handle/base.rs index e202f7170a..4c612212f4 100644 --- a/crates/relayer/src/chain/handle/base.rs +++ b/crates/relayer/src/chain/handle/base.rs @@ -5,7 +5,7 @@ use tracing::Span; use ibc_proto::ibc::{ apps::fee::v1::{QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse}, - core::channel::v1::QueryUpgradeRequest, + core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}, }; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, @@ -16,7 +16,7 @@ use ibc_relayer_types::{ ics04_channel::channel::{ChannelEnd, IdentifiedChannelEnd}, ics04_channel::{ packet::{PacketMsgType, Sequence}, - upgrade::Upgrade, + upgrade::{ErrorReceipt, Upgrade}, }, ics23_commitment::{commitment::CommitmentPrefix, merkle::MerkleProof}, ics24_host::identifier::ChainId, @@ -537,4 +537,16 @@ impl ChainHandle for BaseChainHandle { reply_to, }) } + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + ) -> Result<(ErrorReceipt, Option), Error> { + self.send(|reply_to| ChainRequest::QueryUpgradeError { + request, + height, + reply_to, + }) + } } diff --git a/crates/relayer/src/chain/handle/cache.rs b/crates/relayer/src/chain/handle/cache.rs index 92029fc53f..26fa5636fa 100644 --- a/crates/relayer/src/chain/handle/cache.rs +++ b/crates/relayer/src/chain/handle/cache.rs @@ -1,11 +1,12 @@ use core::fmt::{Display, Error as FmtError, Formatter}; use crossbeam_channel as channel; use ibc_relayer_types::core::ics02_client::header::AnyHeader; +use ibc_relayer_types::core::ics04_channel::upgrade::ErrorReceipt; use tracing::Span; use ibc_proto::ibc::apps::fee::v1::QueryIncentivizedPacketRequest; use ibc_proto::ibc::apps::fee::v1::QueryIncentivizedPacketResponse; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; use ibc_relayer_types::applications::ics31_icq::response::CrossChainQueryResponse; use ibc_relayer_types::core::ics02_client::events::UpdateClient; use ibc_relayer_types::core::ics03_connection::connection::ConnectionEnd; @@ -525,4 +526,12 @@ impl ChainHandle for CachingChainHandle { ) -> Result<(Upgrade, Option), Error> { self.inner.query_upgrade(request, height) } + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + ) -> Result<(ErrorReceipt, Option), Error> { + self.inner.query_upgrade_error(request, height) + } } diff --git a/crates/relayer/src/chain/handle/counting.rs b/crates/relayer/src/chain/handle/counting.rs index ebc0a9c88f..053d289ef8 100644 --- a/crates/relayer/src/chain/handle/counting.rs +++ b/crates/relayer/src/chain/handle/counting.rs @@ -3,8 +3,8 @@ use std::collections::HashMap; use std::sync::{Arc, RwLock, RwLockReadGuard}; use crossbeam_channel as channel; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; -use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; +use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade}; use tracing::{debug, Span}; use ibc_proto::ibc::apps::fee::v1::{ @@ -520,4 +520,13 @@ impl ChainHandle for CountingChainHandle { self.inc_metric("query_upgrade"); self.inner.query_upgrade(request, height) } + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + ) -> Result<(ErrorReceipt, Option), Error> { + self.inc_metric("query_upgrade_error"); + self.inner.query_upgrade_error(request, height) + } } diff --git a/crates/relayer/src/chain/runtime.rs b/crates/relayer/src/chain/runtime.rs index a084bf5967..6732c01368 100644 --- a/crates/relayer/src/chain/runtime.rs +++ b/crates/relayer/src/chain/runtime.rs @@ -7,7 +7,7 @@ use tracing::{error, Span}; use ibc_proto::ibc::{ apps::fee::v1::{QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse}, - core::channel::v1::QueryUpgradeRequest, + core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}, }; use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, @@ -21,7 +21,7 @@ use ibc_relayer_types::{ ics04_channel::{ channel::{ChannelEnd, IdentifiedChannelEnd}, packet::{PacketMsgType, Sequence}, - upgrade::Upgrade, + upgrade::{ErrorReceipt, Upgrade}, }, ics23_commitment::{commitment::CommitmentPrefix, merkle::MerkleProof}, ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}, @@ -360,6 +360,10 @@ where ChainRequest::QueryUpgrade { request, height, reply_to } => { self.query_upgrade(request, height, reply_to)? }, + + ChainRequest::QueryUpgradeError { request, height, reply_to } => { + self.query_upgrade_error(request, height, reply_to)? + }, } }, } @@ -883,4 +887,16 @@ where Ok(()) } + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + reply_to: ReplyTo<(ErrorReceipt, Option)>, + ) -> Result<(), Error> { + let result = self.chain.query_upgrade_error(request, height); + reply_to.send(result).map_err(Error::send)?; + + Ok(()) + } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 3f24009692..2938f1b061 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,9 +1,11 @@ pub use error::ChannelError; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_ack::MsgChannelUpgradeAck; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_cancel::MsgChannelUpgradeCancel; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_confirm::MsgChannelUpgradeConfirm; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_open::MsgChannelUpgradeOpen; -use ibc_relayer_types::core::ics04_channel::upgrade_fields::UpgradeFields; +use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_timeout::MsgChannelUpgradeTimeout; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; use core::fmt::{Display, Error as FmtError, Formatter}; use core::time::Duration; @@ -21,7 +23,6 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenA use ibc_relayer_types::core::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; -use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_init::MsgChannelUpgradeInit; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_try::MsgChannelUpgradeTry; use ibc_relayer_types::core::ics23_commitment::commitment::CommitmentProofBytes; use ibc_relayer_types::core::ics24_host::identifier::{ @@ -298,14 +299,14 @@ impl Channel { chain: ChainA, counterparty_chain: ChainB, channel: WorkerChannelObject, - height: Height, + height: QueryHeight, ) -> Result<(Channel, State), ChannelError> { let (a_channel, _) = chain .query_channel( QueryChannelRequest { port_id: channel.src_port_id.clone(), channel_id: channel.src_channel_id.clone(), - height: QueryHeight::Specific(height), + height, }, // IncludeProof::Yes forces a new query when the CachingChainHandle // is used. @@ -772,30 +773,66 @@ impl Channel { (State::Open(UpgradeState::NotUpgrading), State::TryOpen) => { Some(self.build_chan_open_confirm_and_send()?) } - (State::Open(UpgradeState::NotUpgrading), State::Open(_)) => { + (State::Open(UpgradeState::NotUpgrading), State::Open(UpgradeState::NotUpgrading)) => { return Ok((None, Next::Abort)) } // If the counterparty state is already Open but current state is TryOpen, // return anyway as the final step is to be done by the counterparty worker. - (State::TryOpen, State::Open(_)) => return Ok((None, Next::Abort)), + (State::TryOpen, State::Open(UpgradeState::NotUpgrading)) => { + return Ok((None, Next::Abort)) + } // Close handshake steps (State::Closed, State::Closed) => return Ok((None, Next::Abort)), (State::Closed, _) => Some(self.build_chan_close_confirm_and_send()?), // Channel Upgrade handshake steps - (State::Open(UpgradeState::Upgrading), State::Open(_)) => { - Some(self.build_chan_upgrade_try_and_send()?) + (State::Open(UpgradeState::Upgrading), State::Open(UpgradeState::NotUpgrading)) => { + match self.build_chan_upgrade_try_and_send()? { + Some(event) => Some(event), + None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), + } } - (State::Flushing, State::Open(_)) => Some(self.build_chan_upgrade_ack_and_send()?), + (State::Open(UpgradeState::Upgrading), State::Open(UpgradeState::Upgrading)) => { + match self.build_chan_upgrade_try_and_send()? { + Some(event) => Some(event), + None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), + } + } + (State::Open(UpgradeState::NotUpgrading), State::Open(UpgradeState::Upgrading)) => { + match self.flipped().build_chan_upgrade_try_and_send()? { + Some(event) => Some(event), + None => Some(self.build_chan_upgrade_cancel_and_send()?), + } + } + (State::Flushing, State::Open(UpgradeState::Upgrading)) => { + match self.build_chan_upgrade_ack_and_send()? { + Some(event) => Some(event), + None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), + } + } + (State::Flushing, State::Flushing) => match self.build_chan_upgrade_ack_and_send()? { + Some(event) => Some(event), + None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), + }, (State::Flushcomplete, State::Flushing) => { - Some(self.build_chan_upgrade_confirm_and_send()?) + match self.build_chan_upgrade_confirm_and_send()? { + Some(event) => Some(event), + None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), + } } - (State::Flushcomplete, State::Open(_)) => { + (State::Flushing, State::Open(UpgradeState::NotUpgrading)) => { + Some(self.flipped().build_chan_upgrade_cancel_and_send()?) + } + + (State::Flushcomplete, State::Flushcomplete) => { + Some(self.build_chan_upgrade_open_and_send()?) + } + (State::Flushcomplete, State::Open(UpgradeState::NotUpgrading)) => { Some(self.flipped().build_chan_upgrade_open_and_send()?) } - (State::Open(UpgradeState::Upgrading), State::Flushcomplete) => { + (State::Open(UpgradeState::NotUpgrading), State::Flushcomplete) => { Some(self.build_chan_upgrade_open_and_send()?) } @@ -847,7 +884,7 @@ impl Channel { IbcEvent::UpgradeTryChannel(_) => State::Flushing, IbcEvent::UpgradeAckChannel(_) => State::Flushcomplete, IbcEvent::UpgradeConfirmChannel(_) => State::Flushcomplete, - IbcEvent::UpgradeOpenChannel(_) => State::Open(UpgradeState::Upgrading), + IbcEvent::UpgradeOpenChannel(_) => State::Open(UpgradeState::NotUpgrading), _ => State::Uninitialized, }; @@ -898,7 +935,7 @@ impl Channel { counterparty, vec![self.dst_connection_id().clone()], version, - 0, + Sequence::from(0), ); // Build the domain type message @@ -978,7 +1015,7 @@ impl Channel { counterparty, vec![self.dst_connection_id().clone()], Version::empty(), - 0, + Sequence::from(0), ); // Retrieve existing channel @@ -1070,7 +1107,7 @@ impl Channel { counterparty, vec![self.dst_connection_id().clone()], version, - 0, + Sequence::from(0), ); // Get signer @@ -1511,114 +1548,6 @@ impl Channel { } } - pub fn build_chan_upgrade_init( - &self, - new_version: Option, - new_ordering: Option, - new_connection_hops: Option>, - ) -> Result, ChannelError> { - // Destination channel ID must exist - let channel_id = self - .dst_channel_id() - .ok_or_else(ChannelError::missing_counterparty_channel_id)?; - - let port_id = self.dst_port_id(); - - // Channel must exist on destination - let (mut channel_end, _) = self - .dst_chain() - .query_channel( - QueryChannelRequest { - port_id: port_id.clone(), - channel_id: channel_id.clone(), - height: QueryHeight::Latest, - }, - IncludeProof::No, - ) - .map_err(|e| ChannelError::query(self.dst_chain().id(), e))?; - - if channel_end.state != State::Open(UpgradeState::NotUpgrading) { - return Err(ChannelError::invalid_channel_upgrade_state( - State::Open(UpgradeState::NotUpgrading).to_string(), - channel_end.state.to_string(), - )); - } - - if let Some(new_ordering) = new_ordering { - channel_end.ordering = new_ordering; - } - - if let Some(new_version) = new_version { - channel_end.version = new_version; - } - - if let Some(new_connection_hops) = new_connection_hops { - channel_end.connection_hops = new_connection_hops; - } - - let fields = UpgradeFields::new( - channel_end.ordering, - channel_end.connection_hops, - channel_end.version, - ); - - let signer = self - .dst_chain() - .get_signer() - .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; - - // Build the domain type message - let new_msg = { - MsgChannelUpgradeInit { - port_id: port_id.clone(), - channel_id: channel_id.clone(), - fields, - signer, - } - }; - - Ok(vec![new_msg.to_any()]) - } - - pub fn build_chan_upgrade_init_and_send( - &self, - new_version: Option, - new_ordering: Option, - new_connection_hops: Option>, - ) -> Result { - let dst_msgs = - self.build_chan_upgrade_init(new_version, new_ordering, new_connection_hops)?; - - let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeInit"); - - let events = self - .dst_chain() - .send_messages_and_wait_commit(tm) - .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; - - // Find the relevant event for channel upgrade init - let result = events - .into_iter() - .find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeInitChannel(_)) - || matches!(event_with_height.event, IbcEvent::ChainError(_)) - }) - .ok_or_else(|| { - ChannelError::missing_event( - "no channel upgrade init event was in the response".to_string(), - ) - })?; - - match &result.event { - IbcEvent::UpgradeInitChannel(_) => { - info!("👋 {} => {}", self.dst_chain().id(), result); - Ok(result.event) - } - IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), - _ => Err(ChannelError::invalid_event(result.event)), - } - } - pub fn build_chan_upgrade_try(&self) -> Result, ChannelError> { let src_channel_id = self .src_channel_id() @@ -1712,7 +1641,9 @@ impl Channel { )); } - if channel_end.state != State::Open(UpgradeState::NotUpgrading) { + if channel_end.state != State::Open(UpgradeState::NotUpgrading) + && channel_end.state != State::Open(UpgradeState::Upgrading) + { return Err(ChannelError::invalid_channel_upgrade_state( State::Open(UpgradeState::NotUpgrading).to_string(), channel_end.state.to_string(), @@ -1730,7 +1661,7 @@ impl Channel { channel_id: dst_channel_id.clone(), proposed_upgrade_connection_hops: dst_channel_end.connection_hops, counterparty_upgrade_fields: upgrade.fields, - counterparty_upgrade_sequence: channel_end.upgrade_sequence.into(), + counterparty_upgrade_sequence: channel_end.upgrade_sequence, proof_channel: src_proof.object_proof().clone(), proof_upgrade, proof_height: src_proof.height(), @@ -1744,7 +1675,7 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_try_and_send(&self) -> Result { + pub fn build_chan_upgrade_try_and_send(&self) -> Result, ChannelError> { let dst_msgs = self.build_chan_upgrade_try()?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTry"); @@ -1754,26 +1685,22 @@ impl Channel { .send_messages_and_wait_commit(tm) .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; - // Find the relevant event for channel upgrade try - let result = events - .into_iter() - .find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) - || matches!(event_with_height.event, IbcEvent::ChainError(_)) - }) - .ok_or_else(|| { - ChannelError::missing_event( - "no channel upgrade try event was in the response".to_string(), - ) - })?; - - match &result.event { - IbcEvent::UpgradeTryChannel(_) => { - info!("👋 {} => {}", self.dst_chain().id(), result); - Ok(result.event) + // If the Channel Upgrade Try times out, there will be no events in the response + if let Some(event_with_height) = events.into_iter().find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) { + match &event_with_height.event { + IbcEvent::UpgradeTryChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), event_with_height); + Ok(Some(event_with_height.event.clone())) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(event_with_height.event.clone())), } - IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), - _ => Err(ChannelError::invalid_event(result.event)), + } else { + warn!("no channel upgrade try event found, this might be due to the channel upgrade having timed out"); + Ok(None) } } @@ -1846,7 +1773,7 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_ack_and_send(&self) -> Result { + pub fn build_chan_upgrade_ack_and_send(&self) -> Result, ChannelError> { let dst_msgs = self.build_chan_upgrade_ack()?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeAck"); @@ -1856,25 +1783,22 @@ impl Channel { .send_messages_and_wait_commit(tm) .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; - let result = events - .into_iter() - .find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeAckChannel(_)) - || matches!(event_with_height.event, IbcEvent::ChainError(_)) - }) - .ok_or_else(|| { - ChannelError::missing_event( - "no channel upgrade ack event was in the response".to_string(), - ) - })?; - - match &result.event { - IbcEvent::UpgradeAckChannel(_) => { - info!("👋 {} => {}", self.dst_chain().id(), result); - Ok(result.event) + // If the Channel Upgrade Ack times out, there will be no events in the response + if let Some(event_with_height) = events.into_iter().find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeAckChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) { + match &event_with_height.event { + IbcEvent::UpgradeAckChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), event_with_height); + Ok(Some(event_with_height.event.clone())) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(event_with_height.event.clone())), } - IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), - _ => Err(ChannelError::invalid_event(result.event)), + } else { + warn!("no channel upgrade ack event found, this might be due to the channel upgrade having timed out"); + Ok(None) } } @@ -1962,11 +1886,106 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_confirm_and_send(&self) -> Result { + pub fn build_chan_upgrade_confirm_and_send(&self) -> Result, ChannelError> { let dst_msgs = self.build_chan_upgrade_confirm()?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeConfirm"); + let events = self + .dst_chain() + .send_messages_and_wait_commit(tm) + .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; + + // If the Channel Upgrade Confirm times out, there will be no events in the response + if let Some(event_with_height) = events.into_iter().find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeConfirmChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) { + match &event_with_height.event { + IbcEvent::UpgradeConfirmChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), event_with_height); + Ok(Some(event_with_height.event.clone())) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(event_with_height.event.clone())), + } + } else { + warn!("no channel upgrade confirm event found, this might be due to the channel upgrade having timed out"); + Ok(None) + } + } + + pub fn build_chan_upgrade_open(&self) -> Result, ChannelError> { + // Destination channel ID must exist + let src_channel_id = self + .src_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let src_port_id = self.src_port_id(); + + let dst_port_id = self.dst_port_id(); + + let src_latest_height = self + .src_chain() + .query_latest_height() + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + let (src_channel_end, _) = self + .src_chain() + .query_channel( + QueryChannelRequest { + port_id: src_port_id.clone(), + channel_id: src_channel_id.clone(), + height: QueryHeight::Specific(src_latest_height), + }, + IncludeProof::Yes, + ) + .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; + + let counterparty_upgrade_sequence = src_channel_end.upgrade_sequence; + + // Building the channel proof at the queried height + let proofs = self + .src_chain() + .build_channel_proofs( + &src_port_id.clone(), + &src_channel_id.clone(), + src_latest_height, + ) + .map_err(ChannelError::channel_proof)?; + + // Build message(s) to update client on destination + let mut msgs = self.build_update_client_on_dst(proofs.height())?; + + let signer = self + .dst_chain() + .get_signer() + .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; + + // Build the domain type message + let new_msg = MsgChannelUpgradeOpen { + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + counterparty_channel_state: src_channel_end.state, + counterparty_upgrade_sequence, + proof_channel: proofs.object_proof().clone(), + proof_height: proofs.height(), + signer, + }; + + msgs.push(new_msg.to_any()); + Ok(msgs) + } + + pub fn build_chan_upgrade_open_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_open()?; + + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeOpen"); + let events = self .dst_chain() .send_messages_and_wait_commit(tm) @@ -1975,17 +1994,17 @@ impl Channel { let result = events .into_iter() .find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeConfirmChannel(_)) + matches!(event_with_height.event, IbcEvent::UpgradeOpenChannel(_)) || matches!(event_with_height.event, IbcEvent::ChainError(_)) }) .ok_or_else(|| { ChannelError::missing_event( - "no channel upgrade confirm event was in the response".to_string(), + "no channel upgrade open event was in the response".to_string(), ) })?; match &result.event { - IbcEvent::UpgradeConfirmChannel(_) => { + IbcEvent::UpgradeOpenChannel(_) => { info!("👋 {} => {}", self.dst_chain().id(), result); Ok(result.event) } @@ -1994,7 +2013,7 @@ impl Channel { } } - pub fn build_chan_upgrade_open(&self) -> Result, ChannelError> { + pub fn build_chan_upgrade_cancel(&self) -> Result, ChannelError> { // Destination channel ID must exist let src_channel_id = self .src_channel_id() @@ -2013,7 +2032,108 @@ impl Channel { .query_latest_height() .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; - let (src_channel_end, _) = self + let (error_receipt, maybe_error_receipt_proof) = self + .src_chain() + .query_upgrade_error( + QueryUpgradeErrorRequest { + port_id: src_port_id.to_string(), + channel_id: src_channel_id.to_string(), + }, + src_latest_height, + ) + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + let error_receipt_proof = + maybe_error_receipt_proof.ok_or(ChannelError::missing_upgrade_error_receipt_proof())?; + + let proof_error_receipt = CommitmentProofBytes::try_from(error_receipt_proof) + .map_err(ChannelError::malformed_proof)?; + + // Building the channel proof at the queried height + let proofs = self + .src_chain() + .build_channel_proofs( + &src_port_id.clone(), + &src_channel_id.clone(), + src_latest_height, + ) + .map_err(ChannelError::channel_proof)?; + + // Build message(s) to update client on destination + let mut msgs = self.build_update_client_on_dst(proofs.height())?; + + let signer = self + .dst_chain() + .get_signer() + .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; + + // Build the domain type message + let new_msg = MsgChannelUpgradeCancel { + port_id: dst_port_id.clone(), + channel_id: dst_channel_id.clone(), + error_receipt, + proof_error_receipt, + proof_height: proofs.height(), + signer, + }; + + msgs.push(new_msg.to_any()); + Ok(msgs) + } + + pub fn build_chan_upgrade_cancel_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_cancel()?; + + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeCancel"); + + let events = self + .dst_chain() + .send_messages_and_wait_commit(tm) + .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; + + let result = events + .into_iter() + .find(|event_with_height| { + matches!(event_with_height.event, IbcEvent::UpgradeCancelChannel(_)) + || matches!(event_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no channel upgrade cancel event was in the response".to_string(), + ) + })?; + + match &result.event { + IbcEvent::UpgradeCancelChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), + } + } + + pub fn build_chan_upgrade_timeout(&self) -> Result, ChannelError> { + // Destination channel ID must exist + let src_channel_id = self + .src_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let dst_channel_id = self + .dst_channel_id() + .ok_or_else(ChannelError::missing_counterparty_channel_id)?; + + let src_port_id = self.src_port_id(); + + let dst_port_id = self.dst_port_id(); + + let src_latest_height = self + .src_chain() + .query_latest_height() + .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; + + // Retrieve counterparty channel + let (counterparty_channel, _) = self .src_chain() .query_channel( QueryChannelRequest { @@ -2025,8 +2145,6 @@ impl Channel { ) .map_err(|e| ChannelError::query(self.src_chain().id(), e))?; - let counterparty_upgrade_sequence = src_channel_end.upgrade_sequence; - // Building the channel proof at the queried height let proofs = self .src_chain() @@ -2046,11 +2164,10 @@ impl Channel { .map_err(|e| ChannelError::fetch_signer(self.dst_chain().id(), e))?; // Build the domain type message - let new_msg = MsgChannelUpgradeOpen { + let new_msg = MsgChannelUpgradeTimeout { port_id: dst_port_id.clone(), channel_id: dst_channel_id.clone(), - counterparty_channel_state: src_channel_end.state, - counterparty_upgrade_sequence: counterparty_upgrade_sequence.into(), + counterparty_channel, proof_channel: proofs.object_proof().clone(), proof_height: proofs.height(), signer, @@ -2060,10 +2177,10 @@ impl Channel { Ok(msgs) } - pub fn build_chan_upgrade_open_and_send(&self) -> Result { - let dst_msgs = self.build_chan_upgrade_open()?; + pub fn build_chan_upgrade_timeout_and_send(&self) -> Result { + let dst_msgs = self.build_chan_upgrade_timeout()?; - let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeOpen"); + let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTimeout"); let events = self .dst_chain() @@ -2073,17 +2190,17 @@ impl Channel { let result = events .into_iter() .find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeOpenChannel(_)) + matches!(event_with_height.event, IbcEvent::UpgradeTimeoutChannel(_)) || matches!(event_with_height.event, IbcEvent::ChainError(_)) }) .ok_or_else(|| { ChannelError::missing_event( - "no channel upgrade ack event was in the response".to_string(), + "no channel upgrade timeout event was in the response".to_string(), ) })?; match &result.event { - IbcEvent::UpgradeOpenChannel(_) => { + IbcEvent::UpgradeTimeoutChannel(_) => { info!("👋 {} => {}", self.dst_chain().id(), result); Ok(result.event) } diff --git a/crates/relayer/src/channel/error.rs b/crates/relayer/src/channel/error.rs index 895065db0e..e25b1898bf 100644 --- a/crates/relayer/src/channel/error.rs +++ b/crates/relayer/src/channel/error.rs @@ -70,6 +70,9 @@ define_error! { MissingUpgradeProof |_| { "missing upgrade proof" }, + MissingUpgradeErrorReceiptProof + |_| { "missing upgrade error receipt proof" }, + MalformedProof [ ProofError ] |_| { "malformed proof" }, diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index adad3596d5..794d776a06 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -133,6 +133,14 @@ pub fn ibc_event_try_from_abci_event(abci_event: &AbciEvent) -> Result Ok(IbcEvent::UpgradeOpenChannel( channel_upgrade_open_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), + Ok(IbcEventType::UpgradeCancelChannel) => Ok(IbcEvent::UpgradeCancelChannel( + channel_upgrade_cancelled_try_from_abci_event(abci_event) + .map_err(IbcEventError::channel)?, + )), + Ok(IbcEventType::UpgradeTimeoutChannel) => Ok(IbcEvent::UpgradeTimeoutChannel( + channel_upgrade_timeout_try_from_abci_event(abci_event) + .map_err(IbcEventError::channel)?, + )), Ok(IbcEventType::SendPacket) => Ok(IbcEvent::SendPacket( send_packet_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), @@ -324,6 +332,26 @@ pub fn channel_upgrade_open_try_from_abci_event( } } +pub fn channel_upgrade_cancelled_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_upgrade_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeCancel::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + +pub fn channel_upgrade_timeout_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_upgrade_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeTimeout::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + pub fn send_packet_try_from_abci_event( abci_event: &AbciEvent, ) -> Result { diff --git a/crates/relayer/src/event/source/websocket/extract.rs b/crates/relayer/src/event/source/websocket/extract.rs index 30addd9653..7a411beabb 100644 --- a/crates/relayer/src/event/source/websocket/extract.rs +++ b/crates/relayer/src/event/source/websocket/extract.rs @@ -319,6 +319,11 @@ fn extract_block_events( extract_events(height, block_events, "channel_open_confirm", "channel_id"), height, ); + append_events::( + &mut events, + extract_events(height, block_events, "channel_upgrade_init", "channel_id"), + height, + ); append_events::( &mut events, extract_events(height, block_events, "send_packet", "packet_data_hex"), diff --git a/crates/relayer/src/link.rs b/crates/relayer/src/link.rs index 842d793d99..9e0aaa84c9 100644 --- a/crates/relayer/src/link.rs +++ b/crates/relayer/src/link.rs @@ -84,6 +84,9 @@ impl Link { })?; if !a_channel.state_matches(&ChannelState::Open(UpgradeState::NotUpgrading)) + && !a_channel.state_matches(&ChannelState::Open(UpgradeState::Upgrading)) + && !a_channel.state_matches(&ChannelState::Flushing) + && !a_channel.state_matches(&ChannelState::Flushcomplete) && !a_channel.state_matches(&ChannelState::Closed) { return Err(LinkError::invalid_channel_state( diff --git a/crates/relayer/src/link/relay_path.rs b/crates/relayer/src/link/relay_path.rs index 2cbc3b85e7..eeb2a8a931 100644 --- a/crates/relayer/src/link/relay_path.rs +++ b/crates/relayer/src/link/relay_path.rs @@ -350,10 +350,9 @@ impl RelayPath { } // Nothing to do if channel on destination is already closed - if self - .dst_channel(QueryHeight::Latest)? - .state_matches(&ChannelState::Closed) - { + let dst_channel = self.dst_channel(QueryHeight::Latest)?; + + if dst_channel.state_matches(&ChannelState::Closed) { return Ok(None); } diff --git a/crates/relayer/src/supervisor/spawn.rs b/crates/relayer/src/supervisor/spawn.rs index 07a6c8e8fd..769ac2b9d3 100644 --- a/crates/relayer/src/supervisor/spawn.rs +++ b/crates/relayer/src/supervisor/spawn.rs @@ -244,9 +244,12 @@ impl<'a, Chain: ChainHandle> SpawnContext<'a, Chain> { chan_state_dst ); + let is_channel_upgrading = channel_scan.channel.channel_end.is_upgrading(); + if (mode.clients.enabled || mode.packets.enabled) && chan_state_src.is_open() && (chan_state_dst.is_open() || chan_state_dst.is_closed()) + && !is_channel_upgrading { if mode.clients.enabled { // Spawn the client worker @@ -303,7 +306,7 @@ impl<'a, Chain: ChainHandle> SpawnContext<'a, Chain> { } Ok(mode.clients.enabled) - } else if mode.channels.enabled { + } else if mode.channels.enabled && !is_channel_upgrading { let has_packets = || { !channel_scan .unreceived_packets_on_counterparty(&counterparty_chain, &chain) @@ -315,8 +318,6 @@ impl<'a, Chain: ChainHandle> SpawnContext<'a, Chain> { let open_handshake = chan_state_dst.less_or_equal_progress(ChannelState::TryOpen) && chan_state_dst.less_or_equal_progress(chan_state_src); - let upgrade_handshake = chan_state_dst.is_upgrading(chan_state_src); - // Determine if close handshake is required, i.e. if channel state on source is `Closed`, // and on destination channel state is not `Closed, and there are no pending packets. // If there are pending packets on destination then we let the packet worker clear the @@ -324,7 +325,7 @@ impl<'a, Chain: ChainHandle> SpawnContext<'a, Chain> { let close_handshake = chan_state_src.is_closed() && !chan_state_dst.is_closed() && !has_packets(); - if open_handshake || upgrade_handshake || close_handshake { + if open_handshake || close_handshake { // create worker for channel handshake that will advance the counterparty state let channel_object = Object::Channel(Channel { dst_chain_id: counterparty_chain.id(), @@ -341,6 +342,35 @@ impl<'a, Chain: ChainHandle> SpawnContext<'a, Chain> { } else { Ok(false) } + } else if is_channel_upgrading { + let path_object = Object::Packet(Packet { + dst_chain_id: counterparty_chain.id(), + src_chain_id: chain.id(), + src_channel_id: channel_scan.channel.channel_id.clone(), + src_port_id: channel_scan.channel.port_id.clone(), + }); + + self.workers + .spawn( + chain.clone(), + counterparty_chain.clone(), + &path_object, + self.config, + ) + .then(|| info!("spawned packet worker: {}", path_object.short_name())); + + let channel_object = Object::Channel(Channel { + dst_chain_id: counterparty_chain.id(), + src_chain_id: chain.id(), + src_channel_id: channel_scan.channel.channel_id, + src_port_id: channel_scan.channel.port_id, + }); + + self.workers + .spawn(chain, counterparty_chain, &channel_object, self.config) + .then(|| info!("spawned channel worker: {}", channel_object.short_name())); + + Ok(true) } else { Ok(false) } diff --git a/crates/relayer/src/worker/channel.rs b/crates/relayer/src/worker/channel.rs index a3018360b9..2a741ddf34 100644 --- a/crates/relayer/src/worker/channel.rs +++ b/crates/relayer/src/worker/channel.rs @@ -3,6 +3,7 @@ use crossbeam_channel::Receiver; use ibc_relayer_types::events::IbcEventType; use tracing::{debug, error_span}; +use crate::chain::requests::QueryHeight; use crate::channel::{channel_handshake_retry, Channel as RelayChannel}; use crate::util::retry::RetryResult; use crate::util::task::{spawn_background_task, Next, TaskError, TaskHandle}; @@ -61,10 +62,11 @@ pub fn spawn_channel_worker( chains.a.clone(), chains.b.clone(), channel.clone(), - event_with_height.height, + QueryHeight::Latest, ) { - Ok((mut handshake_channel, _)) => handshake_channel - .step_event(&event_with_height.event, index), + Ok((mut handshake_channel, state)) => { + handshake_channel.step_state(state, index) + } Err(_) => RetryResult::Retry(index), }, ) @@ -94,10 +96,6 @@ pub fn spawn_channel_worker( } if complete_handshake_on_new_block => { debug!("starts processing block event at {:#?}", current_height); - let height = current_height - .decrement() - .map_err(|e| TaskError::Fatal(RunError::ics02(e)))?; - complete_handshake_on_new_block = false; retry_with_index( channel_handshake_retry::default_strategy(max_block_times), @@ -105,7 +103,7 @@ pub fn spawn_channel_worker( chains.a.clone(), chains.b.clone(), channel.clone(), - height, + QueryHeight::Latest, ) { Ok((mut handshake_channel, state)) => { handshake_channel.step_state(state, index) diff --git a/e2e/e2e/channel.py b/e2e/e2e/channel.py index 37f3871aee..75b5d23dd8 100644 --- a/e2e/e2e/channel.py +++ b/e2e/e2e/channel.py @@ -472,17 +472,16 @@ def handshake( split() a_chan_end = query_channel_end(c, side_a, port_id, a_chan_id) - expected_state = str({'Open': 'NotUpgrading'}) - if str(a_chan_end.state) != str({'Open': 'NotUpgrading'}): + if str(a_chan_end.state) != 'Open': l.error( - f"Channel end with id {a_chan_id} on chain {side_a} is not in {expected_state} state, got: {a_chan_end.state}") + f"Channel end with id {a_chan_id} on chain {side_a} is not in `Open` state, got: {a_chan_end.state}") exit(1) b_chan_end = query_channel_end(c, side_b, port_id, b_chan_id) print(b_chan_end.state) - if str(b_chan_end.state) != str({'Open': 'NotUpgrading'}): + if str(b_chan_end.state) != 'Open': l.error( - f'Channel end with id {b_chan_id} on chain {side_b} is not in {expected_state} state, got: {b_chan_end.state}') + f'Channel end with id {b_chan_id} on chain {side_b} is not in `Open` state, got: {b_chan_end.state}') exit(1) a_chan_ends = query_channel_ends(c, side_a, port_id, a_chan_id) diff --git a/flake.lock b/flake.lock index a0dbfb5653..0ea4a08db3 100644 --- a/flake.lock +++ b/flake.lock @@ -138,7 +138,6 @@ "ibc-go-v5-src": "ibc-go-v5-src", "ibc-go-v6-src": "ibc-go-v6-src", "ibc-go-v7-src": "ibc-go-v7-src", - "ibc-go-v8-channel-upgrade-src": "ibc-go-v8-channel-upgrade-src", "ibc-go-v8-src": "ibc-go-v8-src", "ibc-rs-src": "ibc-rs-src", "ica-src": "ica-src", @@ -178,11 +177,11 @@ "wasmvm_1_beta7-src": "wasmvm_1_beta7-src" }, "locked": { - "lastModified": 1705315275, - "narHash": "sha256-XnjvjdTdXkwWFWx1nRflbsDyazSBV09QOmr/aiAuZ1M=", + "lastModified": 1707228682, + "narHash": "sha256-USzPme0JWq2frYdOd6oJGHqveP/jaGiCMZVozcMiNd8=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "04ef5159b4262b7dd445544838468a84a1d987cf", + "rev": "0be6eb961b3ca6583689dabefa0ff108d1cefd55", "type": "github" }, "original": { @@ -739,36 +738,19 @@ "type": "github" } }, - "ibc-go-v8-channel-upgrade-src": { - "flake": false, - "locked": { - "lastModified": 1703189903, - "narHash": "sha256-vxzv+b40TKqCIN4FAkeIu+jmlPP5XRLR+P0uEIjr7AE=", - "owner": "cosmos", - "repo": "ibc-go", - "rev": "7a89e5d5b5ebb7643ce3992c34008c35373ecf34", - "type": "github" - }, - "original": { - "owner": "cosmos", - "ref": "04-channel-upgrades-rc.0", - "repo": "ibc-go", - "type": "github" - } - }, "ibc-go-v8-src": { "flake": false, "locked": { - "lastModified": 1699602904, - "narHash": "sha256-BcP3y874QviVsV+04p9CioolyvmWH82ORbb5EB2GyRI=", + "lastModified": 1706691043, + "narHash": "sha256-eS+X4bT7vp1+LyIPd0mOnAJahAONr+Syton3v3rSkGI=", "owner": "cosmos", "repo": "ibc-go", - "rev": "2551dea41cd3c512845007ca895c8402afa9b79f", + "rev": "7e01c9149149b9d4b1d871e58eb88a22f15bdb3c", "type": "github" }, "original": { "owner": "cosmos", - "ref": "v8.0.0", + "ref": "v8.1.0", "repo": "ibc-go", "type": "github" } @@ -993,11 +975,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1701040486, - "narHash": "sha256-vawYwoHA5CwvjfqaT3A5CT9V36Eq43gxdwpux32Qkjw=", + "lastModified": 1706683685, + "narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "45827faa2132b8eade424f6bdd48d8828754341a", + "rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d", "type": "github" }, "original": { @@ -1041,11 +1023,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1705505490, - "narHash": "sha256-HS+Zg50Zm1Ehfat/OgGS2YJqU7/4ohsQhK+ClwcKmVA=", + "lastModified": 1707171055, + "narHash": "sha256-7ZiKRdhrScsDfhDkGy8yJWAT6BfHqa8PYMX04roU03k=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f36047a5a4b5631f75210859abac7f97ba1ba7a7", + "rev": "4b1aab22192b787355733c9495d47f4c66af084c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index f954295f61..7e2f5756e3 100644 --- a/flake.nix +++ b/flake.nix @@ -41,7 +41,6 @@ ibc-go-v6-simapp ibc-go-v7-simapp ibc-go-v8-simapp - ibc-go-v8-channel-upgrade-simapp interchain-security migaloo neutron diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md index 3143b03d70..c39115bdf9 100644 --- a/guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-ack_1.md @@ -1 +1 @@ -[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-ack --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-ack --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-cancel_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-cancel_1.md new file mode 100644 index 0000000000..5f7fc7e0e1 --- /dev/null +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-cancel_1.md @@ -0,0 +1 @@ +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-cancel --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md index 980a34b457..4b9434eb3b 100644 --- a/guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-confirm_1.md @@ -1 +1 @@ -[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-confirm --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-confirm --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md deleted file mode 100644 index cfe87a3bcd..0000000000 --- a/guide/src/templates/commands/hermes/tx/chan-upgrade-init_1.md +++ /dev/null @@ -1 +0,0 @@ -[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-init[[#OPTIONS]] --src-chain [[#SRC_CHAIN_ID]] --dst-chain [[#DST_CHAIN_ID]] --dst-port [[#DST_PORT_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md index e7c3a0c000..43fe8ee75a 100644 --- a/guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-open_1.md @@ -1 +1 @@ -[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-open --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] \ No newline at end of file +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-open --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] diff --git a/guide/src/templates/commands/hermes/tx/chan-upgrade-timeout_1.md b/guide/src/templates/commands/hermes/tx/chan-upgrade-timeout_1.md new file mode 100644 index 0000000000..2ccf8b5d99 --- /dev/null +++ b/guide/src/templates/commands/hermes/tx/chan-upgrade-timeout_1.md @@ -0,0 +1 @@ +[[#BINARY hermes]][[#GLOBALOPTIONS]] tx chan-upgrade-timeout --dst-chain [[#DST_CHAIN_ID]] --src-chain [[#SRC_CHAIN_ID]] --dst-connection [[#DST_CONNECTION_ID]] --dst-port [[#DST_PORT_ID]] --src-port [[#SRC_PORT_ID]] --src-channel [[#SRC_CHANNEL_ID]] --dst-channel [[#DST_CHANNEL_ID]] diff --git a/guide/src/templates/help_templates/tx.md b/guide/src/templates/help_templates/tx.md index d0ee9956db..9d83c50de5 100644 --- a/guide/src/templates/help_templates/tx.md +++ b/guide/src/templates/help_templates/tx.md @@ -15,9 +15,10 @@ SUBCOMMANDS: chan-open-init Initialize a channel (ChannelOpenInit) chan-open-try Relay the channel attempt (ChannelOpenTry) chan-upgrade-ack Relay the channel upgrade attempt (ChannelUpgradeAck) + chan-upgrade-cancel Relay the channel upgrade cancellation (ChannelUpgradeCancel) chan-upgrade-confirm Relay the channel upgrade attempt (ChannelUpgradeConfirm) - chan-upgrade-init Initiate a channel upgrade (ChannelUpgradeInit) chan-upgrade-open Relay the channel upgrade attempt (ChannelUpgradeOpen) + chan-upgrade-timeout Relay the channel upgrade timeout (ChannelUpgradeTimeout) chan-upgrade-try Relay the channel upgrade attempt (ChannelUpgradeTry) conn-ack Relay acknowledgment of a connection attempt (ConnectionOpenAck) conn-confirm Confirm opening of a connection (ConnectionOpenConfirm) diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-cancel.md b/guide/src/templates/help_templates/tx/chan-upgrade-cancel.md new file mode 100644 index 0000000000..ceb38a5f12 --- /dev/null +++ b/guide/src/templates/help_templates/tx/chan-upgrade-cancel.md @@ -0,0 +1,30 @@ +DESCRIPTION: +Relay the channel upgrade cancellation (ChannelUpgradeCancel) + +USAGE: + hermes tx chan-upgrade-cancel --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel + +OPTIONS: + -h, --help Print help information + +REQUIRED: + --dst-chain + Identifier of the destination chain + + --dst-channel + Identifier of the destination channel (optional) [aliases: dst-chan] + + --dst-connection + Identifier of the destination connection [aliases: dst-conn] + + --dst-port + Identifier of the destination port + + --src-chain + Identifier of the source chain + + --src-channel + Identifier of the source channel (required) [aliases: src-chan] + + --src-port + Identifier of the source port diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-init.md b/guide/src/templates/help_templates/tx/chan-upgrade-init.md deleted file mode 100644 index 8df60dac43..0000000000 --- a/guide/src/templates/help_templates/tx/chan-upgrade-init.md +++ /dev/null @@ -1,28 +0,0 @@ -DESCRIPTION: -Initiate a channel upgrade (ChannelUpgradeInit) - -USAGE: - hermes tx chan-upgrade-init [OPTIONS] --src-chain --dst-chain --dst-port --dst-channel - -OPTIONS: - --connection-hops - Set of connection hops for the channel that both chains will upgrade to. Defaults to the - connection hops of the initiating chain if not specified. - - -h, --help - Print help information - - --ordering - Ordering of the channel that both chains will upgrade to. Note that the a channel may - only be upgraded from a stricter ordering to a less strict ordering, i.e., from ORDERED - to UNORDERED. Defaults to the ordering of the initiating chain if not specified. - - --version - Version of the channel that both chains will upgrade to. Defaults to the version of the - initiating chain if not specified. - -REQUIRED: - --dst-chain Identifier of the destination chain - --dst-channel Identifier of the destination channel [aliases: dst-chan] - --dst-port Identifier of the destination port - --src-chain Identifier of the source chain diff --git a/guide/src/templates/help_templates/tx/chan-upgrade-timeout.md b/guide/src/templates/help_templates/tx/chan-upgrade-timeout.md new file mode 100644 index 0000000000..3d783f1a3a --- /dev/null +++ b/guide/src/templates/help_templates/tx/chan-upgrade-timeout.md @@ -0,0 +1,30 @@ +DESCRIPTION: +Relay the channel upgrade timeout (ChannelUpgradeTimeout) + +USAGE: + hermes tx chan-upgrade-timeout --dst-chain --src-chain --dst-connection --dst-port --src-port --src-channel --dst-channel + +OPTIONS: + -h, --help Print help information + +REQUIRED: + --dst-chain + Identifier of the destination chain + + --dst-channel + Identifier of the destination channel (optional) [aliases: dst-chan] + + --dst-connection + Identifier of the destination connection [aliases: dst-conn] + + --dst-port + Identifier of the destination port + + --src-chain + Identifier of the source chain + + --src-channel + Identifier of the source channel (required) [aliases: src-chan] + + --src-port + Identifier of the source port diff --git a/tools/integration-test/src/tests/async_icq/simple_query.rs b/tools/integration-test/src/tests/async_icq/simple_query.rs index 4d2824d344..f11877f53a 100644 --- a/tools/integration-test/src/tests/async_icq/simple_query.rs +++ b/tools/integration-test/src/tests/async_icq/simple_query.rs @@ -109,7 +109,7 @@ impl BinaryConnectionTest for AsyncIcqTest { "1", )?; - driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string())?; + driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string(), "1")?; info!("Assert that the update oracle proposal is eventually passed"); diff --git a/tools/integration-test/src/tests/channel_upgrade/flushing.rs b/tools/integration-test/src/tests/channel_upgrade/flushing.rs new file mode 100644 index 0000000000..0e4bdf7143 --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/flushing.rs @@ -0,0 +1,422 @@ +//! Tests that the relayer correctly flushes in-flight packets during channel upgrade. +//! +//! - `ChannelUpgradeFlushing` tests that the channel worker will complete the +//! upgrade handshake when there are pending packets before starting the channel upgrade. +//! +//! - `ChannelUpgradeHandshakeFlushPackets` tests that the channel worker will complete the +//! upgrade handshake when packets need to be flushed during the handshake. + +use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::channel::State as ChannelState; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; +use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; +use ibc_test_framework::prelude::*; +use ibc_test_framework::relayer::channel::{ + assert_eventually_channel_established, assert_eventually_channel_upgrade_ack, + assert_eventually_channel_upgrade_init, assert_eventually_channel_upgrade_open, + assert_eventually_channel_upgrade_try, ChannelUpgradableAttributes, +}; +use ibc_test_framework::util::random::random_u128_range; + +#[test] +fn test_channel_upgrade_simple_flushing() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeFlushing) +} + +#[test] +fn test_channel_upgrade_handshake_flush_packets() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeFlushPackets) +} + +const MAX_DEPOSIT_PERIOD: &str = "10s"; +const VOTING_PERIOD: u64 = 10; + +pub struct ChannelUpgradeFlushing; + +impl TestOverrides for ChannelUpgradeFlushing { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + config.mode.packets.auto_register_counterparty_payee = true; + config.mode.packets.clear_interval = 0; + config.mode.packets.clear_on_start = true; + + config.mode.clients.misbehaviour = false; + } + + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + Ok(()) + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeFlushing { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let chain_driver_a = chains.node_a.chain_driver(); + let chain_driver_b = chains.node_b.chain_driver(); + + let denom_a = chains.node_a.denom(); + + let port_a = channels.port_a.as_ref(); + let channel_id_a = channels.channel_id_a.as_ref(); + + let wallets_a = chains.node_a.wallets(); + let wallets_b = chains.node_b.wallets(); + + let user_a = wallets_a.user1(); + let user_b = wallets_b.user1(); + + let send_amount = random_u128_range(1000, 2000); + + chain_driver_a.ibc_transfer_token( + &port_a, + &channel_id_a, + &user_a, + &user_b.address(), + &denom_a.with_amount(send_amount).as_ref(), + )?; + + sleep(Duration::from_secs(3)); + + chain_driver_a.ibc_transfer_token( + &port_a, + &channel_id_a, + &user_a, + &user_b.address(), + &denom_a.with_amount(send_amount).as_ref(), + )?; + + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b, + Sequence::from(1), + ); + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + sleep(Duration::from_secs(5)); + + info!("Check that the channel upgrade successfully upgraded the version..."); + + relayer.with_supervisor(|| { + let denom_b = derive_ibc_denom( + &channels.port_b.as_ref(), + &channels.channel_id_b.as_ref(), + &denom_a, + )?; + + chain_driver_b.assert_eventual_wallet_amount( + &user_b.address(), + &denom_b.with_amount(send_amount + send_amount).as_ref(), + )?; + + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + }) + } +} + +struct ChannelUpgradeHandshakeFlushPackets; + +impl TestOverrides for ChannelUpgradeHandshakeFlushPackets { + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + Ok(()) + } + + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + + config.mode.clients.misbehaviour = false; + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b, + Sequence::from(1), + ); + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + assert_eventually_channel_upgrade_init( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + // send a IBC transfer message from chain a to chain b + // so that we have an in-flight packet and chain a + // will move to `FLUSHING` during Ack + let denom_a = chains.node_a.denom(); + let wallet_a = chains.node_a.wallets().user1().cloned(); + let wallet_b = chains.node_b.wallets().user1().cloned(); + let a_to_b_amount = random_u128_range(1000, 5000); + + info!( + "Sending IBC transfer from chain {} to chain {} with amount of {} {}", + chains.chain_id_a(), + chains.chain_id_b(), + a_to_b_amount, + denom_a + ); + + chains.node_a.chain_driver().ibc_transfer_token( + &channels.port_a.as_ref(), + &channels.channel_id_a.as_ref(), + &wallet_a.as_ref(), + &wallet_b.address(), + &denom_a.with_amount(a_to_b_amount).as_ref(), + )?; + + // send a IBC transfer message from chain b to chain a + // so that we have an in-flight packet and chain a + // will move to `FLUSHING` during Try + let denom_b = chains.node_b.denom(); + let b_to_a_amount = random_u128_range(1000, 5000); + + info!( + "Sending IBC transfer from chain {} to chain {} with amount of {} {}", + chains.chain_id_b(), + chains.chain_id_a(), + b_to_a_amount, + denom_b + ); + + chains.node_b.chain_driver().ibc_transfer_token( + &channels.port_b.as_ref(), + &channels.channel_id_b.as_ref(), + &wallet_b.as_ref(), + &wallet_a.address(), + &denom_b.with_amount(b_to_a_amount).as_ref(), + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + // channel a is `FLUSHING` because the packet + // from a to b has not been cleared yet + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + ChannelState::Flushing, + ChannelState::Flushing, + &old_attrs, + )?; + + info!("Check that the channel upgrade successfully upgraded the version..."); + + // start supervisor to clear in-flight packets + // and move channel ends to `FLUSH_COMPLETE` + relayer.with_supervisor(|| { + let ibc_denom_a = derive_ibc_denom( + &channels.port_a.as_ref(), + &channels.channel_id_a.as_ref(), + &denom_b, + )?; + + chains.node_a.chain_driver().assert_eventual_wallet_amount( + &wallet_a.address(), + &ibc_denom_a.with_amount(b_to_a_amount).as_ref(), + )?; + + let ibc_denom_b = derive_ibc_denom( + &channels.port_b.as_ref(), + &channels.channel_id_b.as_ref(), + &denom_a, + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &wallet_b.address(), + &ibc_denom_b.with_amount(a_to_b_amount).as_ref(), + )?; + + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have been correctly updated. + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + }) + } +} diff --git a/tools/integration-test/src/tests/channel_upgrade/ica.rs b/tools/integration-test/src/tests/channel_upgrade/ica.rs new file mode 100644 index 0000000000..4991a71c00 --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/ica.rs @@ -0,0 +1,529 @@ +//! Tests channel upgrade features: +//! +//! - `ChannelUpgradeICACloseChannel` tests that after the upgrade handshake is completed +//! and the channel version has been updated to ICS29 a packet timeout closes the channel. +//! +//! - `ChannelUpgradeICAUnordered` tests that after the after sending a packet on an ordered +//! ICA channel, the upgrade handshake is completed when the channel is upgraded to unordered. + +use serde_json as json; +use std::collections::HashMap; +use std::str::FromStr; + +use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer::chain::tracking::TrackedMsgs; +use ibc_relayer::config::{ + filter::{ChannelFilters, ChannelPolicy, FilterPattern}, + ChainConfig, PacketFilter, +}; +use ibc_relayer::event::IbcEventWithHeight; + +use ibc_relayer_types::applications::{ + ics27_ica, + ics27_ica::{ + cosmos_tx::CosmosTx, msgs::send_tx::MsgSendTx, packet_data::InterchainAccountPacketData, + }, + transfer::{msgs::send::MsgSend, Amount, Coin}, +}; +use ibc_relayer_types::bigint::U256; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; +use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_relayer_types::signer::Signer; +use ibc_relayer_types::timestamp::Timestamp; +use ibc_relayer_types::tx_msg::Msg; + +use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; +use ibc_test_framework::chain::ext::ica::register_interchain_account; +use ibc_test_framework::prelude::*; +use ibc_test_framework::relayer::channel::{ + assert_eventually_channel_closed, assert_eventually_channel_established, + assert_eventually_channel_upgrade_open, ChannelUpgradableAttributes, +}; + +#[test] +fn test_channel_upgrade_ica_close_channel() -> Result<(), Error> { + run_binary_connection_test(&ChannelUpgradeICACloseChannel) +} + +#[test] +fn test_channel_upgrade_ica_unordered() -> Result<(), Error> { + run_binary_connection_test(&ChannelUpgradeICAUnordered::new(PacketFilter::new( + ChannelPolicy::Allow(ChannelFilters::new(vec![( + FilterPattern::Wildcard("ica*".parse().unwrap()), + FilterPattern::Wildcard("*".parse().unwrap()), + )])), + HashMap::new(), + ))) +} + +const MAX_DEPOSIT_PERIOD: &str = "10s"; +const VOTING_PERIOD: u64 = 10; + +pub struct ChannelUpgradeICACloseChannel; + +impl TestOverrides for ChannelUpgradeICACloseChannel { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + + config.mode.clients.misbehaviour = false; + } + + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + + Ok(()) + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryConnectionTest for ChannelUpgradeICACloseChannel { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + connection: ConnectedConnection, + ) -> Result<(), Error> { + let stake_denom: MonoTagged = MonoTagged::new(Denom::base("stake")); + + // Run the block with supervisor in order to open and then upgrade the ICA channel + let (wallet, ica_address, controller_channel_id, controller_port_id) = relayer + .with_supervisor(|| { + // Register an interchain account on behalf of + // controller wallet `user1` where the counterparty chain is the interchain accounts host. + let (wallet, controller_channel_id, controller_port_id) = + register_interchain_account(&chains.node_a, chains.handle_a(), &connection)?; + + // Check that the corresponding ICA channel is eventually established. + let _counterparty_channel_id = assert_eventually_channel_established( + chains.handle_a(), + chains.handle_b(), + &controller_channel_id.as_ref(), + &controller_port_id.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: controller_port_id.value().clone(), + channel_id: controller_channel_id.value().clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let host_port_id = channel_end_a.remote.port_id; + let host_channel_id = channel_end_a + .remote + .channel_id + .ok_or_else(|| eyre!("expect to find counterparty channel id"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: host_port_id.clone(), + channel_id: host_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + // Query the controller chain for the address of the ICA wallet on the host chain. + let ica_address = chains.node_a.chain_driver().query_interchain_account( + &wallet.address(), + &connection.connection_id_a.as_ref(), + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &ica_address.as_ref(), + &stake_denom.with_amount(0u64).as_ref(), + )?; + + let app_version = json::json!({ + "version": ics27_ica::VERSION, + "encoding": "proto3", + "tx_type": "sdk_multi_msg", + "address": ica_address.to_string(), + "controller_connection_id": connection.connection_id_a.0, + "host_connection_id": connection.connection_id_b.0, + }); + let new_version = Version::app_version_with_fee(&app_version.to_string()); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + controller_port_id.to_string().as_str(), + controller_channel_id.to_string().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Check that the channel upgrade successfully upgraded the version..."); + + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &controller_channel_id.as_ref(), + &controller_port_id.as_ref(), + &upgraded_attrs, + )?; + sleep(Duration::from_secs(5)); + + Ok(( + wallet, + ica_address, + controller_channel_id, + controller_port_id, + )) + })?; + + // Create a pending ICA transfer without supervisor in order to created a timed out + // packet + + // Send funds to the interchain account. + let ica_fund = 42000u64; + + chains.node_b.chain_driver().local_transfer_token( + &chains.node_b.wallets().user1(), + &ica_address.as_ref(), + &stake_denom.with_amount(ica_fund).as_ref(), + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &ica_address.as_ref(), + &stake_denom.with_amount(ica_fund).as_ref(), + )?; + + let amount = 12345u64; + + let msg = MsgSend { + from_address: ica_address.to_string(), + to_address: chains.node_b.wallets().user2().address().to_string(), + amount: vec![Coin { + denom: stake_denom.to_string(), + amount: Amount(U256::from(amount)), + }], + }; + + let raw_msg = msg.to_any(); + + let cosmos_tx = CosmosTx { + messages: vec![raw_msg], + }; + + let raw_cosmos_tx = cosmos_tx.to_any(); + + let interchain_account_packet_data = InterchainAccountPacketData::new(raw_cosmos_tx.value); + + let signer = Signer::from_str(&wallet.address().to_string()).unwrap(); + + let balance_user2 = chains.node_b.chain_driver().query_balance( + &chains.node_b.wallets().user2().address(), + &stake_denom.as_ref(), + )?; + sleep(Duration::from_secs(5)); + + interchain_send_tx( + chains.handle_a(), + &signer, + &connection.connection_id_a.0, + interchain_account_packet_data.clone(), + Timestamp::from_nanoseconds(1000000000).unwrap(), + )?; + + sleep(Duration::from_nanos(3000000000)); + + // Start the supervisor which will relay the timed out packet and close the channel + relayer.with_supervisor(|| { + // Check that user2 has not received the sent amount. + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &chains.node_b.wallets().user2().address(), + &(balance_user2).as_ref(), + )?; + sleep(Duration::from_secs(5)); + + // Check that the ICA account's balance has not been debited the sent amount. + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &ica_address.as_ref(), + &stake_denom.with_amount(ica_fund).as_ref(), + )?; + + info!("Check that the channel closed after packet timeout..."); + + assert_eventually_channel_closed( + &chains.handle_a, + &chains.handle_b, + &controller_channel_id.as_ref(), + &controller_port_id.as_ref(), + )?; + + Ok(()) + }) + } +} + +pub struct ChannelUpgradeICAUnordered { + packet_filter: PacketFilter, +} + +impl ChannelUpgradeICAUnordered { + pub fn new(packet_filter: PacketFilter) -> Self { + Self { packet_filter } + } +} + +impl TestOverrides for ChannelUpgradeICAUnordered { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + + config.mode.clients.misbehaviour = false; + + for chain in &mut config.chains { + match chain { + ChainConfig::CosmosSdk(chain_config) => { + chain_config.packet_filter = self.packet_filter.clone(); + } + } + } + } + + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + use serde_json::Value; + + let allow_messages = genesis + .get_mut("app_state") + .and_then(|app_state| app_state.get_mut("interchainaccounts")) + .and_then(|ica| ica.get_mut("host_genesis_state")) + .and_then(|state| state.get_mut("params")) + .and_then(|params| params.get_mut("allow_messages")) + .and_then(|allow_messages| allow_messages.as_array_mut()); + + if let Some(allow_messages) = allow_messages { + allow_messages.push(Value::String("/cosmos.bank.v1beta1.MsgSend".to_string())); + } else { + return Err(Error::generic(eyre!("failed to update genesis file"))); + } + + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + + Ok(()) + } + + fn should_spawn_supervisor(&self) -> bool { + true + } +} + +impl BinaryConnectionTest for ChannelUpgradeICAUnordered { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + connection: ConnectedConnection, + ) -> Result<(), Error> { + let stake_denom: MonoTagged = MonoTagged::new(Denom::base("stake")); + + info!("Will register interchain account..."); + + // Register an interchain account on behalf of + // controller wallet `user1` where the counterparty chain is the interchain accounts host. + let (wallet, controller_channel_id, controller_port_id) = + register_interchain_account(&chains.node_a, chains.handle_a(), &connection)?; + + // Check that the corresponding ICA channel is eventually established. + let _counterparty_channel_id = assert_eventually_channel_established( + chains.handle_a(), + chains.handle_b(), + &controller_channel_id.as_ref(), + &controller_port_id.as_ref(), + )?; + + // Query the controller chain for the address of the ICA wallet on the host chain. + let ica_address = chains + .node_a + .chain_driver() + .query_interchain_account(&wallet.address(), &connection.connection_id_a.as_ref())?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &ica_address.as_ref(), + &stake_denom.with_amount(0u64).as_ref(), + )?; + + info!("Will send a message to the interchain account..."); + + // Send funds to the interchain account. + let ica_fund = 42000u64; + + chains.node_b.chain_driver().local_transfer_token( + &chains.node_b.wallets().user1(), + &ica_address.as_ref(), + &stake_denom.with_amount(ica_fund).as_ref(), + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &ica_address.as_ref(), + &stake_denom.with_amount(ica_fund).as_ref(), + )?; + + let amount = 12345u64; + + let msg = MsgSend { + from_address: ica_address.to_string(), + to_address: chains.node_b.wallets().user2().address().to_string(), + amount: vec![Coin { + denom: stake_denom.to_string(), + amount: Amount(U256::from(amount)), + }], + }; + + let raw_msg = msg.to_any(); + + let cosmos_tx = CosmosTx { + messages: vec![raw_msg], + }; + + let raw_cosmos_tx = cosmos_tx.to_any(); + + let interchain_account_packet_data = InterchainAccountPacketData::new(raw_cosmos_tx.value); + + let signer = Signer::from_str(&wallet.address().to_string()).unwrap(); + + interchain_send_tx( + chains.handle_a(), + &signer, + &connection.connection_id_a.0, + interchain_account_packet_data.clone(), + Timestamp::from_nanoseconds(10000000000).unwrap(), + )?; + + // Check that the ICA account's balance has been debited the sent amount. + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &ica_address.as_ref(), + &stake_denom.with_amount(ica_fund - amount).as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: controller_port_id.value().clone(), + channel_id: controller_channel_id.value().clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let host_port_id = channel_end_a.remote.port_id; + let host_channel_id = channel_end_a + .remote + .channel_id + .ok_or_else(|| eyre!("expect to find counterparty channel id"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: host_port_id.clone(), + channel_id: host_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version_a = channel_end_a.version; + let old_version_b = channel_end_b.version; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let new_ordering = Ordering::Unordered; + + let upgraded_attrs = ChannelUpgradableAttributes::new( + old_version_a.clone(), + old_version_b.clone(), + new_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + controller_port_id.to_string().as_str(), + controller_channel_id.to_string().as_str(), + new_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&old_version_a.0).unwrap(), + &chains.node_a.wallets().user2().address().to_string(), + "1", + )?; + + info!("Check that the channel upgrade successfully upgraded the ordering..."); + + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &controller_channel_id.as_ref(), + &controller_port_id.as_ref(), + &upgraded_attrs, + )?; + sleep(Duration::from_secs(5)); + + Ok(()) + } +} + +fn interchain_send_tx( + chain: &ChainA, + from: &Signer, + connection: &ConnectionId, + msg: InterchainAccountPacketData, + relative_timeout: Timestamp, +) -> Result, Error> { + let msg = MsgSendTx { + owner: from.clone(), + connection_id: connection.clone(), + packet_data: msg, + relative_timeout, + }; + + let msg_any = msg.to_any(); + + let tm = TrackedMsgs::new_static(vec![msg_any], "SendTx"); + + chain + .send_messages_and_wait_commit(tm) + .map_err(Error::relayer) +} diff --git a/tools/integration-test/src/tests/channel_upgrade/ics29.rs b/tools/integration-test/src/tests/channel_upgrade/ics29.rs index cdcae198fa..02f90b2745 100644 --- a/tools/integration-test/src/tests/channel_upgrade/ics29.rs +++ b/tools/integration-test/src/tests/channel_upgrade/ics29.rs @@ -1,11 +1,13 @@ -//! Tests channel upgrade fetures: +//! Tests channel upgrade features: //! //! - `ChannelUpgradeICS29` tests that only after the upgrade handshake is completed //! and the channel version has been updated to ICS29 can Incentivized packets be //! relayed. use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ assert_eventually_channel_established, assert_eventually_channel_upgrade_open, @@ -18,6 +20,9 @@ fn test_channel_upgrade_ics29() -> Result<(), Error> { run_binary_channel_test(&ChannelUpgradeICS29) } +const MAX_DEPOSIT_PERIOD: &str = "10s"; +const VOTING_PERIOD: u64 = 10; + pub struct ChannelUpgradeICS29; impl TestOverrides for ChannelUpgradeICS29 { @@ -29,6 +34,12 @@ impl TestOverrides for ChannelUpgradeICS29 { config.mode.clients.misbehaviour = false; } + + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + Ok(()) + } } impl BinaryChannelTest for ChannelUpgradeICS29 { @@ -123,28 +134,26 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { let channel = channels.channel; let new_version = Version::ics20_with_fee(); - let new_ordering = None; - let new_connection_hops = None; let upgraded_attrs = ChannelUpgradableAttributes::new( new_version.clone(), new_version.clone(), old_ordering, - old_connection_hops_a, + old_connection_hops_a.clone(), old_connection_hops_b, + Sequence::from(1), ); - info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); - - // Note: Initialising a channel upgrade this way, without requiring a - // signature or proof of authority to perform the channel upgrade, will - // eventually be removed. - // Only authority (gov module or other) will be able to trigger a channel upgrade. - // See: https://github.com/cosmos/ibc-go/issues/4186 - channel.flipped().build_chan_upgrade_init_and_send( - Some(new_version), - new_ordering, - new_connection_hops, + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", )?; info!("Check that the channel upgrade successfully upgraded the version..."); @@ -198,8 +207,6 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { &denom_a, )?; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; - chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(send_amount).as_ref(), diff --git a/tools/integration-test/src/tests/channel_upgrade/mod.rs b/tools/integration-test/src/tests/channel_upgrade/mod.rs index 158224819b..2e40d3bd5e 100644 --- a/tools/integration-test/src/tests/channel_upgrade/mod.rs +++ b/tools/integration-test/src/tests/channel_upgrade/mod.rs @@ -1,3 +1,6 @@ +pub mod flushing; +pub mod ica; pub mod ics29; +pub mod timeout; pub mod upgrade_handshake; pub mod upgrade_handshake_steps; diff --git a/tools/integration-test/src/tests/channel_upgrade/timeout.rs b/tools/integration-test/src/tests/channel_upgrade/timeout.rs new file mode 100644 index 0000000000..b6087e470e --- /dev/null +++ b/tools/integration-test/src/tests/channel_upgrade/timeout.rs @@ -0,0 +1,1070 @@ +//! Tests channel upgrade: +//! +//! - `ChannelUpgradeTimeoutAckHandshake` tests that the channel worker will timeout the +//! upgrade handshake if too much time passes before relaying the Upgrade Ack. +//! +//! - `ChannelUpgradeTimeoutConfirmHandshake` tests that the channel worker will timeout the +//! upgrade handshake if too much time passes before relaying the Upgrade Confirm. +//! +//! - `ChannelUpgradeManualTimeoutWhenFlushingHandshake` tests that the channel upgrade can be timed out +//! and cancelled if the packets take too much time to be flushed. +//! +//! - `ChannelUpgradeHandshakeTimeoutWhenFlushing` tests that the channel worker will timeout the +//! upgrade handshake if the counterparty does not finish flushing the packets before the upgrade timeout. +//! +//! - `ChannelUpgradeHandshakeTimeoutOnAck` tests that the channel worker will cancel the +//! upgrade handshake if the Ack step fails due to an upgrade timeout. +//! +//! - `ChannelUpgradeHandshakeTimeoutOnPacketAck` tests that the channel worker will cancel the +//! upgrade handshake if the chain acknowledges a packet after the upgrade timeout expired. +//! +//! +//! +use std::thread::sleep; + +use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::channel::State as ChannelState; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; +use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_relayer_types::events::IbcEventType; +use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; +use ibc_test_framework::prelude::*; +use ibc_test_framework::relayer::channel::{ + assert_eventually_channel_established, assert_eventually_channel_upgrade_ack, + assert_eventually_channel_upgrade_cancel, assert_eventually_channel_upgrade_flushing, + assert_eventually_channel_upgrade_init, assert_eventually_channel_upgrade_try, + ChannelUpgradableAttributes, +}; + +#[test] +fn test_channel_upgrade_timeout_ack_handshake() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeTimeoutAckHandshake) +} + +#[test] +fn test_channel_upgrade_timeout_confirm_handshake() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeTimeoutConfirmHandshake) +} + +#[test] +fn test_channel_upgrade_manual_timeout_when_flushing() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeManualTimeoutWhenFlushing) +} + +#[test] +fn test_channel_upgrade_handshake_timeout_when_flushing() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeTimeoutWhenFlushing) +} + +#[test] +fn test_channel_upgrade_handshake_timeout_on_ack() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeTimeoutOnAck) +} + +#[test] +fn test_channel_upgrade_handshake_timeout_on_packet_ack() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeTimeoutOnPacketAck) +} + +const MAX_DEPOSIT_PERIOD: &str = "10s"; +const VOTING_PERIOD: u64 = 10; + +struct ChannelUpgradeTestOverrides; + +impl TestOverrides for ChannelUpgradeTestOverrides { + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + Ok(()) + } + + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + + config.mode.clients.misbehaviour = false; + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +struct ChannelUpgradeTimeoutAckHandshake; + +impl BinaryChannelTest for ChannelUpgradeTimeoutAckHandshake { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will update channel params to set a short upgrade timeout..."); + + chains.node_b.chain_driver().update_channel_params( + 5000000000, + chains.handle_b().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + std::thread::sleep(Duration::from_secs(10)); + + info!("Check that the channel upgrade was successfully cancelled..."); + + // This will assert that both channel ends are eventually + // in Open state, and that the fields have not changed. + relayer.with_supervisor(|| { + assert_eventually_channel_upgrade_cancel( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + Ok(()) + }) + } +} + +struct ChannelUpgradeTimeoutConfirmHandshake; + +impl BinaryChannelTest for ChannelUpgradeTimeoutConfirmHandshake { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will update channel params to set a short upgrade timeout..."); + + chains.node_a.chain_driver().update_channel_params( + 5000000000, + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "2", + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + ChannelState::Flushcomplete, + ChannelState::Flushing, + &old_attrs, + )?; + + std::thread::sleep(Duration::from_secs(10)); + + info!("Check that the channel upgrade was successfully cancelled..."); + + // This will assert that both channel ends are eventually + // in Open state, and that the fields have not changed. + relayer.with_supervisor(|| { + assert_eventually_channel_upgrade_cancel( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + Ok(()) + }) + } +} + +struct ChannelUpgradeHandshakeTimeoutWhenFlushing; + +impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will update channel params to set a shorter upgrade timeout..."); + + // the upgrade timeout should be long enough for chain a + // to complete Ack successfully so that it goes into `FLUSHING` + chains.node_b.chain_driver().update_channel_params( + 25000000000, + chains.handle_b().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + // send a IBC transfer message from chain a to chain b + // so that we have an in-flight packet and chain a + // will move to `FLUSHING` during Ack + let denom_a = chains.node_a.denom(); + let wallet_a = chains.node_a.wallets().user1().cloned(); + let wallet_b = chains.node_b.wallets().user1().cloned(); + let a_to_b_amount = 12345u64; + + info!( + "Sending IBC transfer from chain {} to chain {} with amount of {} {}", + chains.chain_id_a(), + chains.chain_id_b(), + a_to_b_amount, + denom_a + ); + + chains.node_a.chain_driver().ibc_transfer_token( + &channels.port_a.as_ref(), + &channels.channel_id_a.as_ref(), + &wallet_a.as_ref(), + &wallet_b.address(), + &denom_a.with_amount(a_to_b_amount).as_ref(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_flushing( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + // wait enough time so that timeout expires while chain a is in FLUSHING + sleep(Duration::from_nanos(35000000000)); + + info!("Will run ChanUpgradeTimeout step..."); + + // Since the chain a has not moved to `FLUSH_COMPLETE` before the upgrade timeout + // expired, then we can submit `MsgChannelUpgradeTimeout` on chain b + // to cancel the upgrade and move the channel back to `OPEN` + let timeout_event = channel.build_chan_upgrade_timeout_and_send()?; + assert_eq!( + timeout_event.event_type(), + IbcEventType::UpgradeTimeoutChannel + ); + + relayer.with_supervisor(|| { + info!("Check that the step ChanUpgradeTimeout was correctly executed..."); + + assert_eventually_channel_upgrade_cancel( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + Ok(()) + }) + } +} + +struct ChannelUpgradeManualTimeoutWhenFlushing; + +impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will update channel params to set a shorter upgrade timeout..."); + + // the upgrade timeout should be long enough for chain a + // to complete Ack successfully so that it goes into `FLUSHING` + chains.node_b.chain_driver().update_channel_params( + 25000000000, + chains.handle_b().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + assert_eventually_channel_upgrade_init( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + // send a IBC transfer message from chain a to chain b + // so that we have an in-flight packet and chain a + // will move to `FLUSHING` during Ack + let denom_a = chains.node_a.denom(); + let wallet_a = chains.node_a.wallets().user1().cloned(); + let wallet_b = chains.node_b.wallets().user1().cloned(); + let a_to_b_amount = 12345u128; + + info!( + "Sending IBC transfer from chain {} to chain {} with amount of {} {}", + chains.chain_id_a(), + chains.chain_id_b(), + a_to_b_amount, + denom_a + ); + + chains.node_a.chain_driver().ibc_transfer_token( + &channels.port_a.as_ref(), + &channels.channel_id_a.as_ref(), + &wallet_a.as_ref(), + &wallet_b.address(), + &denom_a.with_amount(a_to_b_amount).as_ref(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_flushing( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + // wait enough time so that timeout expires while chain a is in FLUSHING + sleep(Duration::from_nanos(35000000000)); + + info!("Will run ChanUpgradeTimeout step..."); + + // Since the chain a has not moved to `FLUSH_COMPLETE` before the upgrade timeout + // expired, then we can submit `MsgChannelUpgradeTimeout` on chain b + // to cancel the upgrade and move the channel back to `OPEN` + let timeout_event = channel.build_chan_upgrade_timeout_and_send()?; + assert_eq!( + timeout_event.event_type(), + IbcEventType::UpgradeTimeoutChannel + ); + + let cancel_event = channel.flipped().build_chan_upgrade_cancel_and_send()?; + assert_eq!( + cancel_event.event_type(), + IbcEventType::UpgradeCancelChannel + ); + + info!("Check that the step ChanUpgradeTimeout was correctly executed..."); + + assert_eventually_channel_upgrade_cancel( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + Ok(()) + } +} + +struct ChannelUpgradeHandshakeTimeoutOnAck; + +impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnAck { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will update channel params to set a short upgrade timeout..."); + + chains.node_b.chain_driver().update_channel_params( + 5000000000, + chains.handle_b().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + assert_eventually_channel_upgrade_init( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + // wait enough time so that ACK fails due to upgrade timeout + sleep(Duration::from_secs(10)); + + info!("Will run ChanUpgradeAck step..."); + + let ack_event = channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck timed out..."); + + // ACK should fail because the upgrade has timed out + assert!( + ack_event.is_none(), + "channel upgrade ack should have failed due to timeout" + ); + + info!("Will run ChanUpgradeCancel step..."); + + // Since the following assertion checks that the fields of channel ends + // have not been updated, asserting there is a `UpgradeCancelChannel` event + // avoids having a passing test due to the Upgrade Init step failing + let cancel_event = channel.build_chan_upgrade_cancel_and_send()?; + assert_eq!( + cancel_event.event_type(), + IbcEventType::UpgradeCancelChannel + ); + + info!("Check that the step ChanUpgradeCancel was correctly executed..."); + + assert_eventually_channel_upgrade_cancel( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + Ok(()) + } +} + +struct ChannelUpgradeHandshakeTimeoutOnPacketAck; + +impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_version = channel_end_a.version; + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let old_attrs = ChannelUpgradableAttributes::new( + old_version.clone(), + old_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will update channel params to set a short upgrade timeout..."); + + // the upgrade timeout should be long enough for chain a + // to complete Ack successfully so that it goes into `FLUSHING` + chains.node_b.chain_driver().update_channel_params( + 80000000000, + chains.handle_b().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + assert_eventually_channel_upgrade_init( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + // send a IBC transfer message from chain a to chain b + // so that we have an in-flight packet and chain a + // will move to `FLUSHING` during Ack + let denom_a = chains.node_a.denom(); + let wallet_a = chains.node_a.wallets().user1().cloned(); + let wallet_b = chains.node_b.wallets().user1().cloned(); + let a_to_b_amount = 12345u128; + + info!( + "Sending IBC transfer from chain {} to chain {} with amount of {} {}", + chains.chain_id_a(), + chains.chain_id_b(), + a_to_b_amount, + denom_a + ); + + chains + .node_a + .chain_driver() + .ibc_transfer_token_with_memo_and_timeout( + &channels.port_a.as_ref(), + &channels.channel_id_a.as_ref(), + &wallet_a.as_ref(), + &wallet_b.address(), + &denom_a.with_amount(a_to_b_amount).as_ref(), + None, + Some(Duration::from_secs(600)), + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &old_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + // channel a is `FLUSHING` because the packet + // from a to b has not been cleared yet + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + ChannelState::Flushing, + ChannelState::Flushing, + &old_attrs, + )?; + + // wait enough time so that timeout expires while chain a is in FLUSHING + // and when packet lifecycle completes with acknowledge packet on chain a + // it will abort the upgrade + sleep(Duration::from_nanos(80000000000)); + + info!("Check that the channel upgrade aborted..."); + + // start supervisor to clear in-flight packets + // and move channel ends to `FLUSH_COMPLETE` + relayer.with_supervisor(|| { + let ibc_denom_b = derive_ibc_denom( + &channels.port_b.as_ref(), + &channels.channel_id_b.as_ref(), + &denom_a, + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &wallet_b.address(), + &ibc_denom_b.with_amount(a_to_b_amount).as_ref(), + )?; + + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have NOT been correctly updated, because chain a aborted the upgrade + assert_eventually_channel_upgrade_cancel( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &old_attrs, + )?; + + Ok(()) + }) + } +} + +impl HasOverrides for ChannelUpgradeTimeoutAckHandshake { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeTimeoutConfirmHandshake { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeManualTimeoutWhenFlushing { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeHandshakeTimeoutWhenFlushing { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeHandshakeTimeoutOnAck { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeHandshakeTimeoutOnPacketAck { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} diff --git a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs index b0e100b422..891c5c295d 100644 --- a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs +++ b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs @@ -3,9 +3,15 @@ //! - `ChannelUpgradeHandshake` tests that after the upgrade handshake is completed //! after initialising the upgrade with `build_chan_upgrade_init_and_send` without //! any in-flight packets. +//! +//! - `ChannelUpgradeClearHandshake` tests that if the upgrade handshake is initialised +//! before the relayer, the upgrade will complete upon starting the relayer. +use std::thread::sleep; use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ assert_eventually_channel_established, assert_eventually_channel_upgrade_open, @@ -17,12 +23,26 @@ fn test_channel_upgrade_handshake() -> Result<(), Error> { run_binary_channel_test(&ChannelUpgradeHandshake) } +#[test] +fn test_channel_upgrade_clear_handshake() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeClearHandshake) +} + +const MAX_DEPOSIT_PERIOD: &str = "10s"; +const VOTING_PERIOD: u64 = 10; + pub struct ChannelUpgradeHandshake; impl TestOverrides for ChannelUpgradeHandshake { fn modify_relayer_config(&self, config: &mut Config) { config.mode.channels.enabled = true; } + + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + Ok(()) + } } impl BinaryChannelTest for ChannelUpgradeHandshake { @@ -74,28 +94,26 @@ impl BinaryChannelTest for ChannelUpgradeHandshake { let channel = channels.channel; let new_version = Version::ics20_with_fee(); - let new_ordering = None; - let new_connection_hops = None; let upgraded_attrs = ChannelUpgradableAttributes::new( new_version.clone(), new_version.clone(), old_ordering, - old_connection_hops_a, + old_connection_hops_a.clone(), old_connection_hops_b, + Sequence::from(1), ); - info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); - - // Note: Initialising a channel upgrade this way, without requiring a - // signature or proof of authority to perform the channel upgrade, will - // eventually be removed. - // Only authority (gov module or other) will be able to trigger a channel upgrade. - // See: https://github.com/cosmos/ibc-go/issues/4186 - channel.flipped().build_chan_upgrade_init_and_send( - Some(new_version), - new_ordering, - new_connection_hops, + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + &chains.node_a.wallets().user2().address().to_string(), + "1", )?; info!("Check that the channel upgrade successfully upgraded the version..."); @@ -114,3 +132,115 @@ impl BinaryChannelTest for ChannelUpgradeHandshake { Ok(()) } } + +pub struct ChannelUpgradeClearHandshake; + +impl TestOverrides for ChannelUpgradeClearHandshake { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + config.mode.clients.misbehaviour = false; + } + + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + Ok(()) + } + + fn should_spawn_supervisor(&self) -> bool { + false + } +} + +impl BinaryChannelTest for ChannelUpgradeClearHandshake { + fn run( + &self, + _config: &TestConfig, + relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let old_ordering = channel_end_a.ordering; + let old_connection_hops_a = channel_end_a.connection_hops; + let old_connection_hops_b = channel_end_b.connection_hops; + + let channel = channels.channel; + let new_version = Version::ics20_with_fee(); + + let upgraded_attrs = ChannelUpgradableAttributes::new( + new_version.clone(), + new_version.clone(), + old_ordering, + old_connection_hops_a.clone(), + old_connection_hops_b, + Sequence::from(1), + ); + + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + // After the governance proposal, wait a few blocks before starting the Hermes instance + sleep(Duration::from_secs(5)); + + info!("Check that the channel upgrade successfully upgraded the version..."); + + relayer.with_supervisor(|| { + // This will assert that both channel ends are eventually + // in Open state, and that the fields targeted by the upgrade + // have been correctly updated. + assert_eventually_channel_upgrade_open( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &upgraded_attrs, + )?; + + Ok(()) + }) + } +} diff --git a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs index 55c070fa44..d1f17a2d22 100644 --- a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs +++ b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs @@ -11,9 +11,25 @@ //! //! - `ChannelUpgradeHandshakeFromConfirm` tests that the channel worker will finish the //! upgrade handshake if the channel is being upgraded and is at the Confirm step. +//! +//! - `ChannelUpgradeHandshakeTimeoutOnAck` tests that the channel worker will cancel the +//! upgrade handshake if the Ack step fails due to an upgrade timeout. +//! +//! - `ChannelUpgradeHandshakeTimeoutWhenFlushing` tests that the channel worker will timeout the +//! upgrade handshake if the counterparty does not finish flushing the packets before the upgrade timeout. +//! +//! - `ChannelUpgradeHandshakeInitiateNewUpgrade` tests that the channel worker will +//! finish the upgrade handshake if the side that moved to `OPEN` initiates a +//! new upgrade before the counterparty moved to `OPEN`. +//! +//! - `ChannelUpgradeHandshakeTimeoutOnPacketAck` tests that the channel worker will cancel the +//! upgrade handshake if the chain acknowledges a packet after the upgrade timeout expired. use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; +use ibc_relayer_types::core::ics04_channel::channel::{State as ChannelState, UpgradeState}; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::version::Version; +use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ assert_eventually_channel_established, assert_eventually_channel_upgrade_ack, @@ -42,14 +58,36 @@ fn test_channel_upgrade_handshake_from_confirm() -> Result<(), Error> { run_binary_channel_test(&ChannelUpgradeHandshakeFromConfirm) } -pub struct ChannelUpgradeManualHandshake; +#[test] +fn test_channel_upgrade_handshake_initiate_new_upgrade() -> Result<(), Error> { + run_binary_channel_test(&ChannelUpgradeHandshakeInitiateNewUpgrade) +} + +const MAX_DEPOSIT_PERIOD: &str = "10s"; +const VOTING_PERIOD: u64 = 10; + +struct ChannelUpgradeTestOverrides; + +impl TestOverrides for ChannelUpgradeTestOverrides { + fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { + set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; + set_voting_period(genesis, VOTING_PERIOD)?; + Ok(()) + } + + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.channels.enabled = true; + + config.mode.clients.misbehaviour = false; + } -impl TestOverrides for ChannelUpgradeManualHandshake { fn should_spawn_supervisor(&self) -> bool { false } } +struct ChannelUpgradeManualHandshake; + impl BinaryChannelTest for ChannelUpgradeManualHandshake { fn run( &self, @@ -100,8 +138,6 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { let channel = channels.channel; let new_version = Version::ics20_with_fee(); - let new_ordering = None; - let new_connection_hops = None; let old_attrs = ChannelUpgradableAttributes::new( old_version.clone(), @@ -109,6 +145,7 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { old_ordering, old_connection_hops_a.clone(), old_connection_hops_b.clone(), + Sequence::from(1), ); let interm_attrs = ChannelUpgradableAttributes::new( @@ -117,27 +154,28 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { old_ordering, old_connection_hops_a.clone(), old_connection_hops_b.clone(), + Sequence::from(1), ); let upgraded_attrs = ChannelUpgradableAttributes::new( new_version.clone(), new_version.clone(), old_ordering, - old_connection_hops_a, + old_connection_hops_a.clone(), old_connection_hops_b, + Sequence::from(1), ); - info!("Will run ChanUpgradeInit step..."); - - // Note: Initialising a channel upgrade this way, without requiring a - // signature or proof of authority to perform the channel upgrade, will - // eventually be removed. - // Only authority (gov module or other) will be able to trigger a channel upgrade. - // See: https://github.com/cosmos/ibc-go/issues/4186 - channel.flipped().build_chan_upgrade_init_and_send( - Some(new_version), - new_ordering, - new_connection_hops, + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", )?; info!("Check that the step ChanUpgradeInit was correctly executed..."); @@ -175,6 +213,8 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), + ChannelState::Flushcomplete, + ChannelState::Flushing, &old_attrs, )?; @@ -213,17 +253,7 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { } } -pub struct ChannelUpgradeHandshakeFromTry; - -impl TestOverrides for ChannelUpgradeHandshakeFromTry { - fn modify_relayer_config(&self, config: &mut Config) { - config.mode.channels.enabled = true; - } - - fn should_spawn_supervisor(&self) -> bool { - false - } -} +struct ChannelUpgradeHandshakeFromTry; impl BinaryChannelTest for ChannelUpgradeHandshakeFromTry { fn run( @@ -275,8 +305,6 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromTry { let channel = channels.channel; let new_version = Version::ics20_with_fee(); - let new_ordering = None; - let new_connection_hops = None; let old_attrs = ChannelUpgradableAttributes::new( old_version.clone(), @@ -284,27 +312,28 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromTry { old_ordering, old_connection_hops_a.clone(), old_connection_hops_b.clone(), + Sequence::from(1), ); let upgraded_attrs = ChannelUpgradableAttributes::new( new_version.clone(), new_version.clone(), old_ordering, - old_connection_hops_a, + old_connection_hops_a.clone(), old_connection_hops_b, + Sequence::from(1), ); - info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); - - // Note: Initialising a channel upgrade this way, without requiring a - // signature or proof of authority to perform the channel upgrade, will - // eventually be removed. - // Only authority (gov module or other) will be able to trigger a channel upgrade. - // See: https://github.com/cosmos/ibc-go/issues/4186 - channel.flipped().build_chan_upgrade_init_and_send( - Some(new_version), - new_ordering, - new_connection_hops, + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", )?; info!("Will run ChanUpgradeTry step..."); @@ -340,17 +369,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromTry { } } -pub struct ChannelUpgradeHandshakeFromAck; - -impl TestOverrides for ChannelUpgradeHandshakeFromAck { - fn modify_relayer_config(&self, config: &mut Config) { - config.mode.channels.enabled = true; - } - - fn should_spawn_supervisor(&self) -> bool { - false - } -} +struct ChannelUpgradeHandshakeFromAck; impl BinaryChannelTest for ChannelUpgradeHandshakeFromAck { fn run( @@ -402,8 +421,6 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromAck { let channel = channels.channel; let new_version = Version::ics20_with_fee(); - let new_ordering = None; - let new_connection_hops = None; let old_attrs = ChannelUpgradableAttributes::new( old_version.clone(), @@ -411,27 +428,28 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromAck { old_ordering, old_connection_hops_a.clone(), old_connection_hops_b.clone(), + Sequence::from(1), ); let upgraded_attrs = ChannelUpgradableAttributes::new( new_version.clone(), new_version.clone(), old_ordering, - old_connection_hops_a, + old_connection_hops_a.clone(), old_connection_hops_b, + Sequence::from(1), ); - info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); - - // Note: Initialising a channel upgrade this way, without requiring a - // signature or proof of authority to perform the channel upgrade, will - // eventually be removed. - // Only authority (gov module or other) will be able to trigger a channel upgrade. - // See: https://github.com/cosmos/ibc-go/issues/4186 - channel.flipped().build_chan_upgrade_init_and_send( - Some(new_version), - new_ordering, - new_connection_hops, + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", )?; info!("Will run ChanUpgradeTry step..."); @@ -459,6 +477,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromAck { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), + ChannelState::Flushcomplete, + ChannelState::Flushing, &old_attrs, )?; @@ -480,18 +500,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromAck { }) } } -pub struct ChannelUpgradeHandshakeFromConfirm; - -impl TestOverrides for ChannelUpgradeHandshakeFromConfirm { - fn modify_relayer_config(&self, config: &mut Config) { - config.mode.channels.enabled = true; - config.mode.clients.misbehaviour = false; - } - - fn should_spawn_supervisor(&self) -> bool { - false - } -} +struct ChannelUpgradeHandshakeFromConfirm; impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { fn run( @@ -543,8 +552,6 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { let channel = channels.channel; let new_version = Version::ics20_with_fee(); - let new_ordering = None; - let new_connection_hops = None; let old_attrs = ChannelUpgradableAttributes::new( old_version.clone(), @@ -552,6 +559,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { old_ordering, old_connection_hops_a.clone(), old_connection_hops_b.clone(), + Sequence::from(1), ); let interm_attrs = ChannelUpgradableAttributes::new( @@ -560,27 +568,28 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { old_ordering, old_connection_hops_a.clone(), old_connection_hops_b.clone(), + Sequence::from(1), ); let upgraded_attrs = ChannelUpgradableAttributes::new( new_version.clone(), new_version.clone(), old_ordering, - old_connection_hops_a, + old_connection_hops_a.clone(), old_connection_hops_b, + Sequence::from(1), ); - info!("Will initialise upgrade handshake by sending the ChanUpgradeInit step..."); - - // Note: Initialising a channel upgrade this way, without requiring a - // signature or proof of authority to perform the channel upgrade, will - // eventually be removed. - // Only authority (gov module or other) will be able to trigger a channel upgrade. - // See: https://github.com/cosmos/ibc-go/issues/4186 - channel.flipped().build_chan_upgrade_init_and_send( - Some(new_version), - new_ordering, - new_connection_hops, + info!("Will initialise upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + old_ordering.as_str(), + old_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&new_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", )?; info!("Will run ChanUpgradeTry step..."); @@ -608,6 +617,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), + ChannelState::Flushcomplete, + ChannelState::Flushing, &old_attrs, )?; @@ -643,3 +654,262 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { }) } } + +struct ChannelUpgradeHandshakeInitiateNewUpgrade; + +impl BinaryChannelTest for ChannelUpgradeHandshakeInitiateNewUpgrade { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channels: ConnectedChannel, + ) -> Result<(), Error> { + info!("Check that channels are both in OPEN State"); + + assert_eventually_channel_established( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + )?; + + let mut channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + let mut channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + let pre_upgrade_1_version = channel_end_a.version; + let pre_upgrade_1_ordering = channel_end_a.ordering; + let pre_upgrade_1_connection_hops_a = channel_end_a.connection_hops.clone(); + let pre_upgrade_1_connection_hops_b = channel_end_b.connection_hops.clone(); + + let channel = channels.channel; + let post_upgrade_1_version = Version::ics20_with_fee(); + + let pre_upgrade_1_attrs = ChannelUpgradableAttributes::new( + pre_upgrade_1_version.clone(), + pre_upgrade_1_version.clone(), + pre_upgrade_1_ordering, + pre_upgrade_1_connection_hops_a.clone(), + pre_upgrade_1_connection_hops_b.clone(), + Sequence::from(1), + ); + + let interm_upgrade_1_attrs = ChannelUpgradableAttributes::new( + pre_upgrade_1_version, + post_upgrade_1_version.clone(), + pre_upgrade_1_ordering, + pre_upgrade_1_connection_hops_a.clone(), + pre_upgrade_1_connection_hops_b.clone(), + Sequence::from(1), + ); + + info!("Will initialise on chain A upgrade handshake with governance proposal..."); + + chains.node_a.chain_driver().initialise_channel_upgrade( + channel.src_port_id().as_str(), + channel.src_channel_id().unwrap().as_str(), + pre_upgrade_1_ordering.as_str(), + pre_upgrade_1_connection_hops_a.first().unwrap().as_str(), + &serde_json::to_string(&post_upgrade_1_version.0).unwrap(), + chains.handle_a().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + assert_eventually_channel_upgrade_init( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + &pre_upgrade_1_attrs, + )?; + + info!("Will run ChanUpgradeTry step..."); + + channel.build_chan_upgrade_try_and_send()?; + + info!("Check that the step ChanUpgradeTry was correctly executed..."); + + assert_eventually_channel_upgrade_try( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &pre_upgrade_1_attrs.flipped(), + )?; + + info!("Will run ChanUpgradeAck step..."); + + channel.flipped().build_chan_upgrade_ack_and_send()?; + + info!("Check that the step ChanUpgradeAck was correctly executed..."); + + assert_eventually_channel_upgrade_ack( + &chains.handle_a, + &chains.handle_b, + &channels.channel_id_a.as_ref(), + &channels.port_a.as_ref(), + ChannelState::Flushcomplete, + ChannelState::Flushing, + &pre_upgrade_1_attrs, + )?; + + info!("Will run ChanUpgradeConfirm step..."); + + channel.build_chan_upgrade_confirm_and_send()?; + + info!("Check that the step ChanUpgradeConfirm was correctly executed..."); + + assert_eventually_channel_upgrade_confirm( + &chains.handle_b, + &chains.handle_a, + &channels.channel_id_b.as_ref(), + &channels.port_b.as_ref(), + &interm_upgrade_1_attrs.flipped(), + )?; + + // ChannelEnd B is now `OPEN` (because both ends did not have in-flight packets) + // Initialise a new upgrade handshake on chain B before ChannelEnd A moves to `OPEN` + + let pre_upgrade_2_ordering = channel_end_a.ordering; + let pre_upgrade_2_connection_hops_b = channel_end_b.connection_hops.clone(); + + let post_upgrade_2_version = Version::ics20(); + + info!("Will initialise on chain B upgrade handshake with governance proposal..."); + + chains.node_b.chain_driver().initialise_channel_upgrade( + channel.dst_port_id().as_str(), + channel.dst_channel_id().unwrap().as_str(), + pre_upgrade_2_ordering.as_str(), + pre_upgrade_2_connection_hops_b.first().unwrap().as_str(), + &serde_json::to_string(&post_upgrade_2_version.0).unwrap(), + chains.handle_b().get_signer().unwrap().as_ref(), + "1", + )?; + + info!("Check that the step ChanUpgradeInit was correctly executed..."); + + channel_end_b = chains + .handle_b + .query_channel( + QueryChannelRequest { + port_id: channels.port_b.0.clone(), + channel_id: channels.channel_id_b.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::Yes, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd B: {e}"))?; + + // upgrade sequence should have been incremented + let upgrade_sequence_b = Sequence::from(2); + assert_eq!( + channel_end_b.upgrade_sequence, upgrade_sequence_b, + "expected channel end B upgrade sequence to be `{}`, but it is instead `{}`", + upgrade_sequence_b, channel_end_b.upgrade_sequence + ); + + // Finish upgrade 1 on ChannelEnd A + + info!("Will run ChanUpgradeOpen step..."); + + channel.flipped().build_chan_upgrade_open_and_send()?; + + info!("Check that the step ChanUpgradeOpen was correctly executed..."); + + channel_end_a = chains + .handle_a + .query_channel( + QueryChannelRequest { + port_id: channels.port_a.0.clone(), + channel_id: channels.channel_id_a.0.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::Yes, + ) + .map(|(channel_end, _)| channel_end) + .map_err(|e| eyre!("Error querying ChannelEnd A: {e}"))?; + + if !channel_end_a.is_open() { + return Err(Error::generic(eyre!( + "expected channel end A state to be `{}`, but is instead `{}`", + ChannelState::Open(UpgradeState::NotUpgrading), + channel_end_a.state() + ))); + } + + assert_eq!( + channel_end_a.version, post_upgrade_1_version, + "expected channel end A version to be `{}`, but is instead `{}`", + post_upgrade_1_version, channel_end_a.version + ); + + Ok(()) + } +} + +impl HasOverrides for ChannelUpgradeManualHandshake { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeHandshakeFromTry { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeHandshakeFromAck { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeHandshakeFromConfirm { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} + +impl HasOverrides for ChannelUpgradeHandshakeInitiateNewUpgrade { + type Overrides = ChannelUpgradeTestOverrides; + + fn get_overrides(&self) -> &ChannelUpgradeTestOverrides { + &ChannelUpgradeTestOverrides + } +} diff --git a/tools/integration-test/src/tests/client_upgrade.rs b/tools/integration-test/src/tests/client_upgrade.rs index 01731e6d8b..9387321cc6 100644 --- a/tools/integration-test/src/tests/client_upgrade.rs +++ b/tools/integration-test/src/tests/client_upgrade.rs @@ -121,7 +121,7 @@ impl BinaryChainTest for ClientUpgradeTest { .map_err(handle_generic_error)?; // Vote on the proposal so the chain will upgrade - driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string())?; + driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string(), "1")?; info!("Assert that the chain upgrade proposal is eventually passed"); @@ -267,7 +267,7 @@ impl BinaryChainTest for HeightTooHighClientUpgradeTest { .map_err(handle_generic_error)?; // Vote on the proposal so the chain will upgrade - driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string())?; + driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string(), "1")?; // The application height reports a height of 1 less than the height according to Tendermint client_upgrade_height.increment(); @@ -364,7 +364,7 @@ impl BinaryChainTest for HeightTooLowClientUpgradeTest { .map_err(handle_generic_error)?; // Vote on the proposal so the chain will upgrade - driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string())?; + driver.vote_proposal(&fee_denom_a.with_amount(381000000u64).to_string(), "1")?; // The application height reports a height of 1 less than the height according to Tendermint client_upgrade_height diff --git a/tools/integration-test/src/tests/fee/auto_forward_relayer.rs b/tools/integration-test/src/tests/fee/auto_forward_relayer.rs index 7d0b6bdcc3..ca120394a5 100644 --- a/tools/integration-test/src/tests/fee/auto_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/auto_forward_relayer.rs @@ -54,7 +54,7 @@ impl BinaryChannelTest for AutoForwardRelayerTest { let user_a = wallets_a.user1(); let user_b = wallets_b.user1(); - let balance_a1 = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; + let balance_a = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; let relayer_balance_a = chain_driver_a.query_balance(&relayer_a.address(), &denom_a)?; @@ -63,10 +63,6 @@ impl BinaryChannelTest for AutoForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; - - let balance_a2 = balance_a1 - total_sent; - chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, @@ -85,18 +81,22 @@ impl BinaryChannelTest for AutoForwardRelayerTest { &denom_a, )?; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; + info!("Will assert user b received the transferred token"); chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(send_amount).as_ref(), )?; + info!("Will assert user a transferred the sent amount, the recv fee and ack fee"); + chain_driver_a.assert_eventual_wallet_amount( &user_a.address(), - &(balance_a2 + timeout_fee).as_ref(), + &(balance_a - send_amount - receive_fee - ack_fee).as_ref(), )?; + info!("Will assert the relayer received the recv fee and ack fee"); + chain_driver_a.assert_eventual_wallet_amount( &relayer_a.address(), &(relayer_balance_a + ack_fee + receive_fee).as_ref(), diff --git a/tools/integration-test/src/tests/fee/filter_fees.rs b/tools/integration-test/src/tests/fee/filter_fees.rs index a6cd76b37d..6113d98c1f 100644 --- a/tools/integration-test/src/tests/fee/filter_fees.rs +++ b/tools/integration-test/src/tests/fee/filter_fees.rs @@ -1,3 +1,4 @@ +use std::cmp::max; use std::collections::HashMap; use ibc_relayer::config::filter::{ChannelPolicy, FeePolicy, FilterPattern, MinFee}; @@ -77,7 +78,12 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { let total_sent_fail = send_amount + receive_fee_fail + ack_fee + timeout_fee; - let balance_a2_fail = balance_a1 - total_sent_fail; + // Before ibc-go v8.1.0 the amount escrowed for ICS29 fees is the sum of recv, ack and timeout fees + let balance_a2_fail = balance_a1.clone() - total_sent_fail; + + // From ibc-go v8.1+ the amount escrowed for ICS29 fees is the highest value between recv + ack fees or timeout fee + let balance_a2_fail2 = + balance_a1 - send_amount - max(receive_fee_fail + ack_fee, timeout_fee); chain_driver_a.ibc_token_transfer_with_fee( &port_a, @@ -99,16 +105,30 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { std::thread::sleep(Duration::from_secs(10)); - chain_driver_a - .assert_eventual_wallet_amount(&user_a.address(), &balance_a2_fail.as_ref())?; + // This double check is required because ibc-go versions previous to v8.1.0 escrow recv, ack and timeout + // fees for ICS29. From ibc-go v8.1+ only the highest value between recv+ack and timeout is escrowed. + match chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a2_fail.as_ref()) + { + Ok(()) => {} + Err(_) => chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a2_fail2.as_ref())?, + } chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(0u128).as_ref(), )?; - chain_driver_a - .assert_eventual_wallet_amount(&user_a.address(), &(balance_a2_fail).as_ref())?; + // This double check is required because ibc-go versions previous to v8.1.0 escrow recv, ack and timeout + // fees for ICS29. From ibc-go v8.1+ only the highest value between recv+ack and timeout is escrowed. + match chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &(balance_a2_fail).as_ref()) + { + Ok(()) => {} + Err(_) => chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a2_fail2.as_ref())?, + } chain_driver_a.assert_eventual_wallet_amount( &relayer_a.address(), @@ -118,7 +138,7 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { { info!("Verify that packet with enough fees is relayed"); - let balance_a1 = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; + let balance_a = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; let relayer_balance_a = chain_driver_a.query_balance(&relayer_a.address(), &denom_a)?; let send_amount = random_u128_range(1000, 2000); @@ -126,10 +146,6 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let total_sent_success = send_amount + receive_fee_success + ack_fee + timeout_fee; - - let balance_a2_success = balance_a1 - total_sent_success; - chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, @@ -148,9 +164,6 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { &denom_a, )?; - chain_driver_a - .assert_eventual_wallet_amount(&user_a.address(), &balance_a2_success.as_ref())?; - chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(send_amount).as_ref(), @@ -160,6 +173,11 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { &relayer_a.address(), &(relayer_balance_a + receive_fee_success + ack_fee).as_ref(), )?; + + chain_driver_a.assert_eventual_wallet_amount( + &user_a.address(), + &(balance_a - send_amount - receive_fee_success - ack_fee).as_ref(), + )?; } Ok(()) @@ -226,7 +244,11 @@ impl BinaryChannelTest for FilterByChannelIncentivizedFeesRelayerTest { let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; - let balance_a2 = balance_a1 - total_sent; + // Before ibc-go v8.1.0 the amount escrowed for ICS29 fees is the sum of recv, ack and timeout fees + let balance_a2_legacy = balance_a1.clone() - total_sent; + + // From ibc-go v8.1+ the amount escrowed for ICS29 fees is the highest value between recv + ack fees or timeout fee + let balance_a2 = balance_a1.clone() - send_amount - max(receive_fee + ack_fee, timeout_fee); let denom_b = derive_ibc_denom( &channel.port_b.as_ref(), @@ -248,7 +270,15 @@ impl BinaryChannelTest for FilterByChannelIncentivizedFeesRelayerTest { Duration::from_secs(60), )?; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; + // This double check is required because ibc-go versions previous to v8.1.0 escrow recv, ack and timeout + // fees for ICS29. From ibc-go v8.1+ only the highest value between recv+ack and timeout is escrowed. + match chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a2_legacy.as_ref()) + { + Ok(()) => {} + Err(_) => chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?, + } chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), @@ -257,7 +287,7 @@ impl BinaryChannelTest for FilterByChannelIncentivizedFeesRelayerTest { chain_driver_a.assert_eventual_wallet_amount( &user_a.address(), - &(balance_a2 + timeout_fee).as_ref(), + &(balance_a1 - send_amount - receive_fee - ack_fee).as_ref(), )?; chain_driver_a.assert_eventual_wallet_amount( diff --git a/tools/integration-test/src/tests/fee/forward_relayer.rs b/tools/integration-test/src/tests/fee/forward_relayer.rs index f5dc0695fc..daa5bcf317 100644 --- a/tools/integration-test/src/tests/fee/forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/forward_relayer.rs @@ -93,7 +93,7 @@ impl BinaryChannelTest for ForwardRelayerTest { let user_a = wallets_a.user1(); let user_b = wallets_b.user1(); - let balance_a1 = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; + let balance_a = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; let relayer_balance_a = chain_driver_a.query_balance(&relayer_a.address(), &denom_a)?; @@ -102,10 +102,6 @@ impl BinaryChannelTest for ForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; - - let balance_a2 = balance_a1 - total_sent; - chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, @@ -124,8 +120,6 @@ impl BinaryChannelTest for ForwardRelayerTest { &denom_a, )?; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; - chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(send_amount).as_ref(), @@ -133,7 +127,7 @@ impl BinaryChannelTest for ForwardRelayerTest { chain_driver_a.assert_eventual_wallet_amount( &user_a.address(), - &(balance_a2 + timeout_fee).as_ref(), + &(balance_a - send_amount - receive_fee - ack_fee).as_ref(), )?; chain_driver_a.assert_eventual_wallet_amount( diff --git a/tools/integration-test/src/tests/fee/no_forward_relayer.rs b/tools/integration-test/src/tests/fee/no_forward_relayer.rs index f623126b55..8b840640e8 100644 --- a/tools/integration-test/src/tests/fee/no_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/no_forward_relayer.rs @@ -71,7 +71,7 @@ impl BinaryChannelTest for NoForwardRelayerTest { let user_a = wallets_a.user1(); let user_b = wallets_b.user1(); - let balance_a1 = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; + let balance_a = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; let relayer_balance_a = chain_driver_a.query_balance(&relayer_a.address(), &denom_a)?; @@ -80,10 +80,6 @@ impl BinaryChannelTest for NoForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; - - let balance_a2 = balance_a1 - total_sent; - chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, @@ -102,8 +98,6 @@ impl BinaryChannelTest for NoForwardRelayerTest { &denom_a, )?; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; - chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(send_amount).as_ref(), @@ -113,7 +107,7 @@ impl BinaryChannelTest for NoForwardRelayerTest { // as there is no counterparty address registered. chain_driver_a.assert_eventual_wallet_amount( &user_a.address(), - &(balance_a2 + receive_fee + timeout_fee).as_ref(), + &(balance_a - send_amount - ack_fee).as_ref(), )?; chain_driver_a.assert_eventual_wallet_amount( @@ -153,7 +147,7 @@ impl BinaryChannelTest for InvalidForwardRelayerTest { let user_a = wallets_a.user1(); let user_b = wallets_b.user1(); - let balance_a1 = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; + let balance_a = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; let relayer_balance_a = chain_driver_a.query_balance(&relayer_a.address(), &denom_a)?; @@ -162,10 +156,6 @@ impl BinaryChannelTest for InvalidForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; - - let balance_a2 = balance_a1 - total_sent; - let invalid_address = MonoTagged::new(WalletAddress("a very long and invalid address".to_string())); @@ -194,18 +184,16 @@ impl BinaryChannelTest for InvalidForwardRelayerTest { &denom_a, )?; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; - chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(send_amount).as_ref(), )?; // receive fee and timeout fee should be refunded, - // as thecounterparty address registered is invalid. + // as the counterparty address registered is invalid. chain_driver_a.assert_eventual_wallet_amount( &user_a.address(), - &(balance_a2 + receive_fee + timeout_fee).as_ref(), + &(balance_a - send_amount - ack_fee).as_ref(), )?; chain_driver_a.assert_eventual_wallet_amount( diff --git a/tools/integration-test/src/tests/fee/pay_fee_async.rs b/tools/integration-test/src/tests/fee/pay_fee_async.rs index f62d089ff1..37c486c07d 100644 --- a/tools/integration-test/src/tests/fee/pay_fee_async.rs +++ b/tools/integration-test/src/tests/fee/pay_fee_async.rs @@ -18,6 +18,8 @@ //! Finally, the test initializes the supervisor in order to relay the pending packets so that the //! balances on the two chains can be asserted. +use std::cmp::max; + use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::events::IbcEvent; use ibc_test_framework::prelude::*; @@ -105,13 +107,26 @@ impl BinaryChannelTest for PayPacketFeeAsyncTest { &denom_a.with_amount(receive_fee).as_ref(), &denom_a.with_amount(ack_fee).as_ref(), &denom_a.with_amount(timeout_fee).as_ref(), - Duration::from_secs(60), + Duration::from_secs(300), )?; let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; - let balance_a2 = balance_a1 - total_sent; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; + // Before ibc-go v8.1.0 the amount escrowed for ICS29 fees is the sum of recv, ack and timeout fees + let balance_a2_legacy = balance_a1.clone() - total_sent; + + // From ibc-go v8.1+ the amount escrowed for ICS29 fees is the highest value between recv + ack fees or timeout fee + let balance_a2 = balance_a1.clone() - send_amount - max(receive_fee + ack_fee, timeout_fee); + + // This double check is required because ibc-go versions previous to v8.1.0 escrow recv, ack and timeout + // fees for ICS29. From ibc-go v8.1+ only the highest value between recv+ack and timeout is escrowed. + match chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a2_legacy.as_ref()) + { + Ok(()) => {} + Err(_) => chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?, + } let sequence = { let send_packet_event = events @@ -208,9 +223,22 @@ impl BinaryChannelTest for PayPacketFeeAsyncTest { )?; let total_sent_2 = receive_fee_2 + ack_fee_2 + timeout_fee_2; - let balance_a3 = balance_a2 - total_sent_2; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a3.as_ref())?; + // Before ibc-go v8.1.0 the amount escrowed for ICS29 fees is the sum of recv, ack and timeout fees + let balance_a3_legacy = balance_a2_legacy - total_sent_2; + + // From ibc-go v8.1+ the amount escrowed for ICS29 fees is the highest value between recv + ack fees or timeout fee + let balance_a3 = balance_a2 - max(receive_fee_2 + ack_fee_2, timeout_fee_2); + + // This double check is required because ibc-go versions previous to v8.1.0 escrow recv, ack and timeout + // fees for ICS29. From ibc-go v8.1+ only the highest value between recv+ack and timeout is escrowed. + match chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a3_legacy.as_ref()) + { + Ok(()) => {} + Err(_) => chain_driver_a + .assert_eventual_wallet_amount(&user_a.address(), &balance_a3.as_ref())?, + } { let event = events2 @@ -259,7 +287,8 @@ impl BinaryChannelTest for PayPacketFeeAsyncTest { chain_driver_a.assert_eventual_wallet_amount( &user_a.address(), - &(balance_a3 + timeout_fee + timeout_fee_2).as_ref(), + &(balance_a1 - send_amount - receive_fee - receive_fee_2 - ack_fee - ack_fee_2) + .as_ref(), )?; chain_driver_a.assert_eventual_wallet_amount( diff --git a/tools/integration-test/src/tests/fee/register_payee.rs b/tools/integration-test/src/tests/fee/register_payee.rs index 0e92dfe4b3..638800c846 100644 --- a/tools/integration-test/src/tests/fee/register_payee.rs +++ b/tools/integration-test/src/tests/fee/register_payee.rs @@ -107,7 +107,7 @@ impl BinaryChannelTest for ForwardRelayerTest { let user_a = wallets_a.user1(); let user_b = wallets_b.user1(); - let balance_a1 = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; + let balance_a = chain_driver_a.query_balance(&user_a.address(), &denom_a)?; let relayer_balance_a = chain_driver_a.query_balance(&relayer_a.address(), &denom_a)?; let payee_balance_a = chain_driver_a.query_balance(&payee_a.address(), &denom_a)?; @@ -117,10 +117,6 @@ impl BinaryChannelTest for ForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let total_sent = send_amount + receive_fee + ack_fee + timeout_fee; - - let balance_a2 = balance_a1 - total_sent; - chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, @@ -139,8 +135,6 @@ impl BinaryChannelTest for ForwardRelayerTest { &denom_a, )?; - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; - chain_driver_b.assert_eventual_wallet_amount( &user_b.address(), &denom_b.with_amount(send_amount).as_ref(), @@ -148,7 +142,7 @@ impl BinaryChannelTest for ForwardRelayerTest { chain_driver_a.assert_eventual_wallet_amount( &user_a.address(), - &(balance_a2 + timeout_fee).as_ref(), + &(balance_a - send_amount - receive_fee - ack_fee).as_ref(), )?; chain_driver_a.assert_eventual_wallet_amount( diff --git a/tools/integration-test/src/tests/fee/timeout_fee.rs b/tools/integration-test/src/tests/fee/timeout_fee.rs index 1d6131ed89..1d3068db01 100644 --- a/tools/integration-test/src/tests/fee/timeout_fee.rs +++ b/tools/integration-test/src/tests/fee/timeout_fee.rs @@ -72,10 +72,6 @@ impl BinaryChannelTest for TimeoutFeeTest { Duration::from_secs(5), )?; - info!("Expect user A's balance after transfer: {}", balance_a2); - - chain_driver_a.assert_eventual_wallet_amount(&user_a.address(), &balance_a2.as_ref())?; - // Sleep to wait for IBC packet to timeout before start relaying thread::sleep(Duration::from_secs(6)); diff --git a/tools/test-framework/src/chain/cli/upgrade.rs b/tools/test-framework/src/chain/cli/upgrade.rs index ffb66f50b0..172391bf05 100644 --- a/tools/test-framework/src/chain/cli/upgrade.rs +++ b/tools/test-framework/src/chain/cli/upgrade.rs @@ -1,8 +1,11 @@ /*! Methods for voting on a proposal. */ +use eyre::eyre; + use crate::chain::exec::simple_exec; use crate::error::Error; +use crate::prelude::*; pub fn vote_proposal( chain_id: &str, @@ -10,6 +13,7 @@ pub fn vote_proposal( home_path: &str, rpc_listen_address: &str, fees: &str, + proposal_id: &str, ) -> Result<(), Error> { simple_exec( chain_id, @@ -20,7 +24,7 @@ pub fn vote_proposal( "tx", "gov", "vote", - "1", + proposal_id, "yes", "--chain-id", chain_id, @@ -38,3 +42,84 @@ pub fn vote_proposal( Ok(()) } + +pub fn submit_gov_proposal( + chain_id: &str, + command_path: &str, + home_path: &str, + rpc_listen_address: &str, + signer: &str, + proposal_file: &str, +) -> Result<(), Error> { + let proposal_file = format!("{}/{}", home_path, proposal_file); + let output = simple_exec( + chain_id, + command_path, + &[ + "--node", + rpc_listen_address, + "tx", + "gov", + "submit-proposal", + &proposal_file, + "--chain-id", + chain_id, + "--home", + home_path, + "--keyring-backend", + "test", + "--gas", + "20000000", + "--from", + signer, + "--output", + "json", + "--yes", + ], + )?; + + let json_output: serde_json::Value = + serde_json::from_str(&output.stdout).map_err(handle_generic_error)?; + + if json_output + .get("code") + .ok_or_else(|| eyre!("expected `code` field in output"))? + .as_u64() + .ok_or_else(|| eyre!("expected `code` to be a u64"))? + != 0 + { + let raw_log = json_output + .get("raw_log") + .ok_or_else(|| eyre!("expected `code` field in output"))? + .as_str() + .ok_or_else(|| eyre!("expected `raw_log` to be a str"))?; + warn!("failed to submit governance proposal due to `{raw_log}`. Will retry..."); + simple_exec( + chain_id, + command_path, + &[ + "--node", + rpc_listen_address, + "tx", + "gov", + "submit-proposal", + &proposal_file, + "--chain-id", + chain_id, + "--home", + home_path, + "--keyring-backend", + "test", + "--gas", + "20000000", + "--from", + signer, + "--output", + "json", + "--yes", + ], + )?; + } + + Ok(()) +} diff --git a/tools/test-framework/src/chain/ext/bootstrap.rs b/tools/test-framework/src/chain/ext/bootstrap.rs index 37f7818d75..3fb6e00ecd 100644 --- a/tools/test-framework/src/chain/ext/bootstrap.rs +++ b/tools/test-framework/src/chain/ext/bootstrap.rs @@ -334,7 +334,7 @@ impl ChainBootstrapMethodsExt for ChainDriver { assert_eventually_succeed( &format!("proposal `{}` status: {}", proposal_id, status.as_str()), 10, - Duration::from_secs(2), + Duration::from_secs(3), || match query_gov_proposal( chain_id, command_path, diff --git a/tools/test-framework/src/chain/ext/proposal.rs b/tools/test-framework/src/chain/ext/proposal.rs index e15e9a93ce..c42531462c 100644 --- a/tools/test-framework/src/chain/ext/proposal.rs +++ b/tools/test-framework/src/chain/ext/proposal.rs @@ -7,11 +7,14 @@ use ibc_proto::cosmos::gov::v1beta1::{query_client::QueryClient, QueryProposalRe use ibc_proto::ibc::core::client::v1::{MsgIbcSoftwareUpgrade, UpgradeProposal}; use ibc_relayer::error::Error as RelayerError; -use crate::chain::cli::upgrade::vote_proposal; +use crate::chain::cli::upgrade::{submit_gov_proposal, vote_proposal}; use crate::chain::driver::ChainDriver; use crate::error::Error; -use crate::prelude::handle_generic_error; +use crate::prelude::{handle_generic_error, TaggedChainDriverExt}; use crate::types::tagged::*; +use crate::util::proposal_status::ProposalStatus; + +use super::bootstrap::ChainBootstrapMethodsExt; pub trait ChainProposalMethodsExt { fn query_upgrade_proposal_height( @@ -20,7 +23,25 @@ pub trait ChainProposalMethodsExt { proposal_id: u64, ) -> Result; - fn vote_proposal(&self, fees: &str) -> Result<(), Error>; + fn vote_proposal(&self, fees: &str, proposal_id: &str) -> Result<(), Error>; + + fn initialise_channel_upgrade( + &self, + port_id: &str, + channel_id: &str, + ordering: &str, + connection_hops: &str, + version: &str, + signer: &str, + proposal_id: &str, + ) -> Result<(), Error>; + + fn update_channel_params( + &self, + timestamp: u64, + signer: &str, + proposal_id: &str, + ) -> Result<(), Error>; } impl<'a, Chain: Send> ChainProposalMethodsExt for MonoTagged { @@ -34,16 +55,125 @@ impl<'a, Chain: Send> ChainProposalMethodsExt for MonoTagged Result<(), Error> { + fn vote_proposal(&self, fees: &str, proposal_id: &str) -> Result<(), Error> { vote_proposal( self.value().chain_id.as_str(), &self.value().command_path, &self.value().home_path, &self.value().rpc_listen_address(), fees, + proposal_id, )?; Ok(()) } + + fn initialise_channel_upgrade( + &self, + port_id: &str, + channel_id: &str, + ordering: &str, + connection_hops: &str, + version: &str, + signer: &str, + proposal_id: &str, + ) -> Result<(), Error> { + let gov_address = self.query_auth_module("gov")?; + let channel_upgrade_proposal = create_channel_upgrade_proposal( + self.value(), + port_id, + channel_id, + ordering, + connection_hops, + version, + &gov_address, + )?; + submit_gov_proposal( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + signer, + &channel_upgrade_proposal, + )?; + + self.value().assert_proposal_status( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + ProposalStatus::VotingPeriod, + proposal_id, + )?; + + vote_proposal( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + "1200stake", + proposal_id, + )?; + + self.value().assert_proposal_status( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + ProposalStatus::Passed, + proposal_id, + )?; + + Ok(()) + } + + // The timestamp is in nanoseconds + fn update_channel_params( + &self, + timestamp: u64, + signer: &str, + proposal_id: &str, + ) -> Result<(), Error> { + let gov_address = self.query_auth_module("gov")?; + let channel_update_params_proposal = + create_channel_update_params_proposal(self.value(), timestamp, &gov_address)?; + submit_gov_proposal( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + signer, + &channel_update_params_proposal, + )?; + + self.value().assert_proposal_status( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + ProposalStatus::VotingPeriod, + proposal_id, + )?; + + vote_proposal( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + "1200stake", + proposal_id, + )?; + + self.value().assert_proposal_status( + self.value().chain_id.as_str(), + &self.value().command_path, + &self.value().home_path, + &self.value().rpc_listen_address(), + ProposalStatus::Passed, + proposal_id, + )?; + + Ok(()) + } } /// Query the proposal with the given proposal_id, which is supposed to be an UpgradeProposal. @@ -109,3 +239,77 @@ pub async fn query_upgrade_proposal_height( Ok(height) } + +fn create_channel_upgrade_proposal( + chain_driver: &ChainDriver, + port_id: &str, + channel_id: &str, + ordering: &str, + connection_hops: &str, + version: &str, + gov_address: &str, +) -> Result { + let raw_proposal = r#" + { + "messages": [ + { + "@type": "/ibc.core.channel.v1.MsgChannelUpgradeInit", + "port_id": "{port_id}", + "channel_id": "{channel_id}", + "fields": { + "ordering": "{ordering}", + "connection_hops": ["{connection_hops}"], + "version": {version} + }, + "signer":"{signer}" + } + ], + "deposit": "10000001stake", + "title": "Channel upgrade", + "summary": "Upgrade channel version", + "expedited": false + }"#; + + let proposal = raw_proposal.replace("{port_id}", port_id); + let proposal = proposal.replace("{channel_id}", channel_id); + let proposal = proposal.replace("{ordering}", ordering); + let proposal = proposal.replace("{connection_hops}", connection_hops); + let proposal = proposal.replace("{version}", version); + let proposal = proposal.replace("{signer}", gov_address); + + chain_driver.write_file("channel_upgrade_proposal.json", &proposal)?; + Ok("channel_upgrade_proposal.json".to_owned()) +} + +fn create_channel_update_params_proposal( + chain_driver: &ChainDriver, + timestamp: u64, + gov_address: &str, +) -> Result { + let raw_proposal = r#" + { + "messages": [ + { + "@type": "/ibc.core.channel.v1.MsgUpdateParams", + "params": { + "upgrade_timeout": { + "timestamp": {timestamp} + } + }, + "authority":"{signer}" + } + ], + "deposit": "10000001stake", + "title": "Channel update params", + "summary": "Update channel params", + "expedited": false + }"#; + + let proposal = raw_proposal.replace("{timestamp}", ×tamp.to_string()); + let proposal = proposal.replace("{signer}", gov_address); + + let output_file = "channel_update_params_proposal.json"; + + chain_driver.write_file(output_file, &proposal)?; + Ok(output_file.to_owned()) +} diff --git a/tools/test-framework/src/framework/binary/ics.rs b/tools/test-framework/src/framework/binary/ics.rs index 8125a541f9..d11c8ff3e8 100644 --- a/tools/test-framework/src/framework/binary/ics.rs +++ b/tools/test-framework/src/framework/binary/ics.rs @@ -90,6 +90,7 @@ where &node_a.chain_driver.home_path, &node_a.chain_driver.rpc_listen_address(), &provider_fee, + "1", )?; node_a.chain_driver.assert_proposal_status( diff --git a/tools/test-framework/src/relayer/chain.rs b/tools/test-framework/src/relayer/chain.rs index e64bdf9938..9178fce0a1 100644 --- a/tools/test-framework/src/relayer/chain.rs +++ b/tools/test-framework/src/relayer/chain.rs @@ -21,9 +21,9 @@ */ use crossbeam_channel as channel; -use ibc_proto::ibc::core::channel::v1::QueryUpgradeRequest; +use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; use ibc_relayer::chain::cosmos::version::Specs; -use ibc_relayer_types::core::ics04_channel::upgrade::Upgrade; +use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade}; use tracing::Span; use ibc_proto::ibc::apps::fee::v1::{ @@ -445,4 +445,12 @@ where ) -> Result<(Upgrade, Option), Error> { self.value().query_upgrade(request, height) } + + fn query_upgrade_error( + &self, + request: QueryUpgradeErrorRequest, + height: Height, + ) -> Result<(ErrorReceipt, Option), Error> { + self.value().query_upgrade_error(request, height) + } } diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index 93b5e5bc75..e1baa50f1f 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -7,6 +7,7 @@ use ibc_relayer::channel::{extract_channel_id, Channel, ChannelSide}; use ibc_relayer_types::core::ics04_channel::channel::{ ChannelEnd, IdentifiedChannelEnd, Ordering, State as ChannelState, UpgradeState, }; +use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::core::ics24_host::identifier::ConnectionId; @@ -43,6 +44,7 @@ pub struct ChannelUpgradableAttributes { ordering: Ordering, connection_hops_a: Vec, connection_hops_b: Vec, + upgrade_sequence: Sequence, } impl ChannelUpgradableAttributes { @@ -52,6 +54,7 @@ impl ChannelUpgradableAttributes { ordering: Ordering, connection_hops_a: Vec, connection_hops_b: Vec, + upgrade_sequence: Sequence, ) -> Self { Self { version_a, @@ -59,6 +62,7 @@ impl ChannelUpgradableAttributes { ordering, connection_hops_a, connection_hops_b, + upgrade_sequence, } } @@ -69,6 +73,7 @@ impl ChannelUpgradableAttributes { ordering: self.ordering, connection_hops_a: self.connection_hops_b.clone(), connection_hops_b: self.connection_hops_a.clone(), + upgrade_sequence: self.upgrade_sequence, } } @@ -91,6 +96,10 @@ impl ChannelUpgradableAttributes { pub fn connection_hops_b(&self) -> &Vec { &self.connection_hops_b } + + pub fn upgrade_sequence(&self) -> &Sequence { + &self.upgrade_sequence + } } pub fn init_channel( @@ -346,7 +355,8 @@ pub fn assert_eventually_channel_closed( + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + channel_state_a: ChannelState, + channel_state_b: ChannelState, + upgrade_attrs: &ChannelUpgradableAttributes, +) -> Result, Error> { + assert_eventually_succeed( + "channel upgrade ack step should be done", + 20, + Duration::from_secs(1), + || { + assert_channel_upgrade_state( + channel_state_a, + channel_state_b, + handle_a, + handle_b, + channel_id_a, + port_id_a, + upgrade_attrs, + &Sequence::from(1), + &Sequence::from(1), + ) + }, + ) +} + +pub fn assert_eventually_channel_upgrade_flushing( handle_a: &ChainA, handle_b: &ChainB, channel_id_a: &TaggedChannelIdRef, @@ -425,13 +468,15 @@ pub fn assert_eventually_channel_upgrade_ack( + handle_a: &ChainA, + handle_b: &ChainB, + channel_id_a: &TaggedChannelIdRef, + port_id_a: &TaggedPortIdRef, + upgrade_attrs: &ChannelUpgradableAttributes, +) -> Result, Error> { + assert_eventually_succeed( + "channel upgrade cancel step should be done", + 20, + Duration::from_secs(1), + || { + assert_channel_upgrade_state( + ChannelState::Open(UpgradeState::NotUpgrading), + ChannelState::Open(UpgradeState::NotUpgrading), + handle_a, + handle_b, + channel_id_a, + port_id_a, + upgrade_attrs, + &Sequence::from(1), + &Sequence::from(1), ) }, ) @@ -497,6 +573,8 @@ fn assert_channel_upgrade_state( channel_id_a: &TaggedChannelIdRef, port_id_a: &TaggedPortIdRef, upgrade_attrs: &ChannelUpgradableAttributes, + upgrade_sequence_a: &Sequence, + upgrade_sequence_b: &Sequence, ) -> Result, Error> { let channel_end_a = query_channel_end(handle_a, channel_id_a, port_id_a)?; @@ -541,6 +619,18 @@ fn assert_channel_upgrade_state( ))); } + if !channel_end_a + .value() + .upgrade_sequence + .eq(upgrade_sequence_a) + { + return Err(Error::generic(eyre!( + "expected channel end A upgrade sequence to be `{}`, but it is instead `{}`", + upgrade_sequence_a, + channel_end_a.value().upgrade_sequence + ))); + } + let channel_id_b = channel_end_a .tagged_counterparty_channel_id() .ok_or_else(|| eyre!("expected counterparty channel id to present on open channel"))?; @@ -590,5 +680,17 @@ fn assert_channel_upgrade_state( ))); } + if !channel_end_b + .value() + .upgrade_sequence + .eq(upgrade_sequence_b) + { + return Err(Error::generic(eyre!( + "expected channel end B upgrade sequence to be `{}`, but it is instead `{}`", + upgrade_sequence_b, + channel_end_b.value().upgrade_sequence + ))); + } + Ok(channel_id_b) } From d2e9452c9f6e844e048c8c76795e877d3bba8dca Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Tue, 2 Apr 2024 18:07:56 +0200 Subject: [PATCH 77/99] Remove unnecessary fields from IBC channel upgrade events --- .../src/core/ics04_channel/events.rs | 211 ++++-------------- .../src/chain/cosmos/types/events/channel.rs | 22 +- crates/relayer/src/event.rs | 65 +++--- .../src/tests/async_icq/simple_query.rs | 23 +- .../src/tests/channel_upgrade/ica.rs | 21 +- .../channel_upgrade/upgrade_handshake.rs | 1 + tools/integration-test/src/tests/ica.rs | 20 +- .../ica_ordered_channel.rs | 19 +- .../tests/interchain_security/ica_transfer.rs | 19 +- tools/test-framework/src/chain/config.rs | 20 ++ 10 files changed, 120 insertions(+), 301 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index d3bdee764b..c5f8b92736 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -6,12 +6,10 @@ use std::str; use serde_derive::{Deserialize, Serialize}; use tendermint::abci; -use crate::core::ics04_channel::channel::Ordering; +use crate::core::ics02_client::height::Height; use crate::core::ics04_channel::error::Error; use crate::core::ics04_channel::packet::Packet; use crate::core::ics04_channel::packet::Sequence; -use crate::core::ics04_channel::timeout::Timeout; -use crate::core::ics04_channel::version::Version; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; use crate::events::{Error as EventError, IbcEvent, IbcEventType}; use crate::timestamp::Timestamp; @@ -36,11 +34,9 @@ pub const PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY: &str = "packet_timeout_timestamp" pub const PKT_ACK_ATTRIBUTE_KEY: &str = "packet_ack"; /// Channel upgrade attribute keys -pub const UPGRADE_CONNECTION_HOPS: &str = "upgrade_connection_hops"; -pub const UPGRADE_VERSION: &str = "upgrade_version"; pub const UPGRADE_SEQUENCE: &str = "upgrade_sequence"; -pub const UPGRADE_ORDERING: &str = "upgrade_ordering"; -pub const CHANNEL_FLUSH_STATUS: &str = "channel_flush_status"; +pub const UPGRADE_TIMEOUT_HEIGHT: &str = "timeout_height"; +pub const UPGRADE_TIMEOUT_TIMESTAMP: &str = "timeout_timestamp"; #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] pub struct Attributes { @@ -104,11 +100,9 @@ pub struct UpgradeAttributes { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, - pub upgrade_timeout: Option, + pub upgrade_timeout_height: Option, + pub upgrade_timeout_timestamp: Option, } impl UpgradeAttributes { @@ -127,14 +121,7 @@ impl Display for UpgradeAttributes { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; - } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering - ) + write!(f, "], upgrade_sequence: {} }}", self.upgrade_sequence) } } pub trait EventType { @@ -163,29 +150,9 @@ impl From for Vec { let channel_id = (COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY, a.channel_id.as_str()).into(); attributes.push(channel_id); - let mut hops = "".to_owned(); - let mut hops_iterator = a.upgrade_connection_hops.iter().peekable(); - - while let Some(hop) = hops_iterator.next() { - hops = format!("{hops}{hop}"); - // If it is not the last element, add separator. - if hops_iterator.peek().is_some() { - hops = format!("{hops}, "); - } - } - - let upgrade_connection_hops = (UPGRADE_CONNECTION_HOPS, hops.as_str()).into(); - attributes.push(upgrade_connection_hops); - - let upgrade_version = (UPGRADE_VERSION, a.upgrade_version.0.as_str()).into(); - attributes.push(upgrade_version); - let upgrade_sequence = (UPGRADE_SEQUENCE, a.upgrade_sequence.to_string().as_str()).into(); attributes.push(upgrade_sequence); - let upgrade_ordering = (UPGRADE_ORDERING, a.upgrade_ordering.as_str()).into(); - attributes.push(upgrade_ordering); - attributes } } @@ -538,10 +505,7 @@ pub struct UpgradeInit { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, } impl Display for UpgradeInit { @@ -551,14 +515,7 @@ impl Display for UpgradeInit { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; - } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering - ) + write!(f, "], upgrade_sequence: {} }}", self.upgrade_sequence) } } @@ -569,11 +526,9 @@ impl From for UpgradeAttributes { channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, - upgrade_connection_hops: ev.upgrade_connection_hops, - upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, - upgrade_ordering: ev.upgrade_ordering, - upgrade_timeout: None, + upgrade_timeout_height: None, + upgrade_timeout_timestamp: None, } } } @@ -605,10 +560,7 @@ impl TryFrom for UpgradeInit { channel_id: attrs.channel_id, counterparty_port_id: attrs.counterparty_port_id, counterparty_channel_id: attrs.counterparty_channel_id, - upgrade_connection_hops: attrs.upgrade_connection_hops, - upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, - upgrade_ordering: attrs.upgrade_ordering, }) } } @@ -631,10 +583,7 @@ pub struct UpgradeTry { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, } impl Display for UpgradeTry { @@ -644,14 +593,7 @@ impl Display for UpgradeTry { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; - } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering - ) + write!(f, "], upgrade_sequence: {} }}", self.upgrade_sequence) } } @@ -662,11 +604,9 @@ impl From for UpgradeAttributes { channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, - upgrade_connection_hops: ev.upgrade_connection_hops, - upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, - upgrade_ordering: ev.upgrade_ordering, - upgrade_timeout: None, + upgrade_timeout_height: None, + upgrade_timeout_timestamp: None, } } } @@ -698,10 +638,7 @@ impl TryFrom for UpgradeTry { channel_id: attrs.channel_id, counterparty_port_id: attrs.counterparty_port_id, counterparty_channel_id: attrs.counterparty_channel_id, - upgrade_connection_hops: attrs.upgrade_connection_hops, - upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, - upgrade_ordering: attrs.upgrade_ordering, }) } } @@ -724,10 +661,7 @@ pub struct UpgradeAck { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, } impl Display for UpgradeAck { @@ -737,14 +671,7 @@ impl Display for UpgradeAck { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; - } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering - ) + write!(f, "], upgrade_sequence: {} }}", self.upgrade_sequence) } } @@ -755,11 +682,9 @@ impl From for UpgradeAttributes { channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, - upgrade_connection_hops: ev.upgrade_connection_hops, - upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, - upgrade_ordering: ev.upgrade_ordering, - upgrade_timeout: None, + upgrade_timeout_height: None, + upgrade_timeout_timestamp: None, } } } @@ -791,10 +716,7 @@ impl TryFrom for UpgradeAck { channel_id: attrs.channel_id, counterparty_port_id: attrs.counterparty_port_id, counterparty_channel_id: attrs.counterparty_channel_id, - upgrade_connection_hops: attrs.upgrade_connection_hops, - upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, - upgrade_ordering: attrs.upgrade_ordering, }) } } @@ -817,10 +739,7 @@ pub struct UpgradeConfirm { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, } impl Display for UpgradeConfirm { @@ -830,14 +749,7 @@ impl Display for UpgradeConfirm { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; - } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering - ) + write!(f, "], upgrade_sequence: {} }}", self.upgrade_sequence) } } @@ -848,11 +760,9 @@ impl From for UpgradeAttributes { channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, - upgrade_connection_hops: ev.upgrade_connection_hops, - upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, - upgrade_ordering: ev.upgrade_ordering, - upgrade_timeout: None, + upgrade_timeout_height: None, + upgrade_timeout_timestamp: None, } } } @@ -884,10 +794,7 @@ impl TryFrom for UpgradeConfirm { channel_id: attrs.channel_id, counterparty_port_id: attrs.counterparty_port_id, counterparty_channel_id: attrs.counterparty_channel_id, - upgrade_connection_hops: attrs.upgrade_connection_hops, - upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, - upgrade_ordering: attrs.upgrade_ordering, }) } } @@ -910,10 +817,7 @@ pub struct UpgradeOpen { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, } impl Display for UpgradeOpen { @@ -923,14 +827,7 @@ impl Display for UpgradeOpen { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; - } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering - ) + write!(f, "], upgrade_sequence: {} }}", self.upgrade_sequence) } } @@ -941,11 +838,9 @@ impl From for UpgradeAttributes { channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, - upgrade_connection_hops: ev.upgrade_connection_hops, - upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, - upgrade_ordering: ev.upgrade_ordering, - upgrade_timeout: None, + upgrade_timeout_height: None, + upgrade_timeout_timestamp: None, } } } @@ -977,10 +872,7 @@ impl TryFrom for UpgradeOpen { channel_id: attrs.channel_id, counterparty_port_id: attrs.counterparty_port_id, counterparty_channel_id: attrs.counterparty_channel_id, - upgrade_connection_hops: attrs.upgrade_connection_hops, - upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, - upgrade_ordering: attrs.upgrade_ordering, }) } } @@ -1003,10 +895,7 @@ pub struct UpgradeCancel { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, } impl Display for UpgradeCancel { @@ -1016,14 +905,7 @@ impl Display for UpgradeCancel { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; - } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering - ) + write!(f, "], upgrade_sequence: {} }}", self.upgrade_sequence) } } @@ -1034,11 +916,9 @@ impl From for UpgradeAttributes { channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, - upgrade_connection_hops: ev.upgrade_connection_hops, - upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, - upgrade_ordering: ev.upgrade_ordering, - upgrade_timeout: None, + upgrade_timeout_height: None, + upgrade_timeout_timestamp: None, } } } @@ -1070,10 +950,7 @@ impl TryFrom for UpgradeCancel { channel_id: attrs.channel_id, counterparty_port_id: attrs.counterparty_port_id, counterparty_channel_id: attrs.counterparty_channel_id, - upgrade_connection_hops: attrs.upgrade_connection_hops, - upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, - upgrade_ordering: attrs.upgrade_ordering, }) } } @@ -1096,11 +973,9 @@ pub struct UpgradeTimeout { pub channel_id: ChannelId, pub counterparty_port_id: PortId, pub counterparty_channel_id: Option, - pub upgrade_connection_hops: Vec, - pub upgrade_version: Version, pub upgrade_sequence: Sequence, - pub upgrade_ordering: Ordering, - pub upgrade_timeout: Timeout, + pub upgrade_timeout_height: Option, + pub upgrade_timeout_timestamp: Option, } impl Display for UpgradeTimeout { @@ -1110,14 +985,19 @@ impl Display for UpgradeTimeout { } else { write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; } - for hop in self.upgrade_connection_hops.iter() { - write!(f, " {} ", hop)?; + + write!(f, "], upgrade_sequence: {}", self.upgrade_sequence)?; + + match (self.upgrade_timeout_height, self.upgrade_timeout_timestamp) { + (Some(height), Some(timestamp)) => write!( + f, + " timeout_height: {}, timeout_timestamp: {} }}", + height, timestamp + ), + (Some(height), None) => write!(f, " timeout_height: {} }}", height), + (None, Some(timestamp)) => write!(f, " timeout_timestamp: {} }}", timestamp), + (None, None) => write!(f, " }}"), } - write!( - f, - "], upgrade_version: {}, upgrade_sequence: {}, upgrade_ordering: {}, upgrade_timeout: {} }}", - self.upgrade_version, self.upgrade_sequence, self.upgrade_ordering, self.upgrade_timeout, - ) } } @@ -1128,11 +1008,9 @@ impl From for UpgradeAttributes { channel_id: ev.channel_id, counterparty_port_id: ev.counterparty_port_id, counterparty_channel_id: ev.counterparty_channel_id, - upgrade_connection_hops: ev.upgrade_connection_hops, - upgrade_version: ev.upgrade_version, upgrade_sequence: ev.upgrade_sequence, - upgrade_ordering: ev.upgrade_ordering, - upgrade_timeout: Some(ev.upgrade_timeout), + upgrade_timeout_height: ev.upgrade_timeout_height, + upgrade_timeout_timestamp: ev.upgrade_timeout_timestamp, } } } @@ -1164,14 +1042,9 @@ impl TryFrom for UpgradeTimeout { channel_id: attrs.channel_id, counterparty_port_id: attrs.counterparty_port_id, counterparty_channel_id: attrs.counterparty_channel_id, - upgrade_connection_hops: attrs.upgrade_connection_hops, - upgrade_version: attrs.upgrade_version, upgrade_sequence: attrs.upgrade_sequence, - upgrade_ordering: attrs.upgrade_ordering, - upgrade_timeout: attrs.upgrade_timeout.map_or_else( - || Timeout::Timestamp(Timestamp::default()), - |timeout| timeout, - ), + upgrade_timeout_height: attrs.upgrade_timeout_height, + upgrade_timeout_timestamp: attrs.upgrade_timeout_timestamp, }) } } diff --git a/crates/relayer/src/chain/cosmos/types/events/channel.rs b/crates/relayer/src/chain/cosmos/types/events/channel.rs index 85c627d95b..80cf6ac0e8 100644 --- a/crates/relayer/src/chain/cosmos/types/events/channel.rs +++ b/crates/relayer/src/chain/cosmos/types/events/channel.rs @@ -13,7 +13,6 @@ use ibc_relayer_types::core::ics04_channel::events::{ use ibc_relayer_types::core::ics04_channel::events::{ReceivePacket, TimeoutOnClosePacket}; use ibc_relayer_types::core::ics04_channel::packet::Packet; use ibc_relayer_types::core::ics04_channel::timeout::TimeoutHeight; -use ibc_relayer_types::core::ics24_host::identifier::ConnectionId; use ibc_relayer_types::events::Error as EventError; use ibc_relayer_types::Height; @@ -45,10 +44,6 @@ fn extract_upgrade_attributes( object: &RawObject<'_>, namespace: &str, ) -> Result { - let connection_hops: ConnectionId = - extract_attribute(object, &format!("{namespace}.connection_hops"))? - .parse() - .map_err(EventError::parse)?; Ok(UpgradeAttributes { port_id: extract_attribute(object, &format!("{namespace}.port_id"))? .parse() @@ -67,16 +62,19 @@ fn extract_upgrade_attributes( &format!("{namespace}.counterparty_channel_id"), ) .and_then(|v| v.parse().ok()), - upgrade_connection_hops: vec![connection_hops], - upgrade_version: extract_attribute(object, &format!("{namespace}.version"))?.into(), upgrade_sequence: extract_attribute(object, &format!("{namespace}.upgrade_sequence"))? .parse() .map_err(|_| EventError::missing_action_string())?, - upgrade_ordering: extract_attribute(object, &format!("{namespace}.ordering"))? - .parse() - .map_err(|_| EventError::missing_action_string())?, - upgrade_timeout: maybe_extract_attribute(object, &format!("{namespace}.timeout")) - .and_then(|v| v.parse().ok()), + upgrade_timeout_height: maybe_extract_attribute( + object, + &format!("{namespace}.timeout_height"), + ) + .and_then(|v| v.parse().ok()), + upgrade_timeout_timestamp: maybe_extract_attribute( + object, + &format!("{namespace}.timeout_timestamp"), + ) + .and_then(|v| v.parse().ok()), }) } diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index 794d776a06..82f976a384 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -5,32 +5,33 @@ use subtle_encoding::hex; use tendermint::abci::Event as AbciEvent; use ibc_relayer_types::{ - applications::ics29_fee::events::{DistributeFeePacket, IncentivizedPacket}, - applications::ics31_icq::events::CrossChainQueryPacket, - core::ics02_client::{ - error::Error as ClientError, - events::{self as client_events, Attributes as ClientAttributes, HEADER_ATTRIBUTE_KEY}, - header::{decode_header, AnyHeader}, - height::HeightErrorDetail, - }, - core::ics03_connection::{ - error::Error as ConnectionError, - events::{self as connection_events, Attributes as ConnectionAttributes}, - }, - core::ics04_channel::{ - error::Error as ChannelError, - events::{ - self as channel_events, Attributes as ChannelAttributes, - UpgradeAttributes as ChannelUpgradeAttributes, - }, - packet::Packet, - timeout::TimeoutHeight, + applications::{ + ics29_fee::events::{DistributeFeePacket, IncentivizedPacket}, + ics31_icq::events::CrossChainQueryPacket, }, core::{ - ics04_channel::{channel::Ordering, packet::Sequence, version::Version}, - ics24_host::identifier::ConnectionId, + ics02_client::{ + error::Error as ClientError, + events::{self as client_events, Attributes as ClientAttributes, HEADER_ATTRIBUTE_KEY}, + header::{decode_header, AnyHeader}, + height::HeightErrorDetail, + }, + ics03_connection::{ + error::Error as ConnectionError, + events::{self as connection_events, Attributes as ConnectionAttributes}, + }, + ics04_channel::{ + error::Error as ChannelError, + events::{ + self as channel_events, Attributes as ChannelAttributes, + UpgradeAttributes as ChannelUpgradeAttributes, + }, + packet::{Packet, Sequence}, + timeout::TimeoutHeight, + }, }, events::{Error as IbcEventError, IbcEvent, IbcEventType}, + timestamp::Timestamp, Height, }; @@ -521,25 +522,19 @@ fn channel_upgrade_extract_attributes_from_tx( channel_events::COUNTERPARTY_CHANNEL_ID_ATTRIBUTE_KEY => { attr.counterparty_channel_id = value.parse().ok(); } - channel_events::UPGRADE_CONNECTION_HOPS => { - let mut hops = vec![]; - for hop_str in value.trim().split(',') { - let hop = ConnectionId::from_str(hop_str).map_err(ChannelError::identifier)?; - hops.push(hop); - } - attr.upgrade_connection_hops = hops; - } - channel_events::UPGRADE_VERSION => { - attr.upgrade_version = Version(value.to_string()); - } channel_events::UPGRADE_SEQUENCE => { attr.upgrade_sequence = Sequence::from(value.parse::().map_err(|e| { ChannelError::invalid_string_as_sequence(value.to_string(), e) })?); } - channel_events::UPGRADE_ORDERING => { - attr.upgrade_ordering = Ordering::from_str(value)?; + channel_events::UPGRADE_TIMEOUT_HEIGHT => { + let maybe_height = Height::from_str(value).ok(); + attr.upgrade_timeout_height = maybe_height; + } + channel_events::UPGRADE_TIMEOUT_TIMESTAMP => { + let maybe_timestamp = Timestamp::from_str(value).ok(); + attr.upgrade_timeout_timestamp = maybe_timestamp; } _ => {} } diff --git a/tools/integration-test/src/tests/async_icq/simple_query.rs b/tools/integration-test/src/tests/async_icq/simple_query.rs index f11877f53a..73b8f7362a 100644 --- a/tools/integration-test/src/tests/async_icq/simple_query.rs +++ b/tools/integration-test/src/tests/async_icq/simple_query.rs @@ -1,6 +1,8 @@ use ibc_relayer::channel::version::Version; use ibc_relayer::config::ChainConfig; -use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; +use ibc_test_framework::chain::config::{ + add_allow_message, set_max_deposit_period, set_voting_period, +}; use ibc_test_framework::chain::ext::async_icq::AsyncIcqMethodsExt; use ibc_test_framework::chain::ext::bootstrap::ChainBootstrapMethodsExt; use ibc_test_framework::prelude::*; @@ -30,26 +32,11 @@ impl TestOverrides for AsyncIcqTest { // Allow Oracle message on host side fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - use serde_json::Value; - set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; set_voting_period(genesis, VOTING_PERIOD)?; + add_allow_message(genesis, "/provenance.oracle.v1.Query/Oracle")?; - let allow_messages = genesis - .get_mut("app_state") - .and_then(|app_state| app_state.get_mut("interchainquery")) - .and_then(|ica| ica.get_mut("params")) - .and_then(|params| params.get_mut("allow_queries")) - .and_then(|allow_messages| allow_messages.as_array_mut()); - - if let Some(allow_messages) = allow_messages { - allow_messages.push(Value::String( - "/provenance.oracle.v1.Query/Oracle".to_string(), - )); - Ok(()) - } else { - Err(Error::generic(eyre!("failed to update genesis file"))) - } + Ok(()) } fn channel_version(&self) -> Version { diff --git a/tools/integration-test/src/tests/channel_upgrade/ica.rs b/tools/integration-test/src/tests/channel_upgrade/ica.rs index 4991a71c00..75d068bba1 100644 --- a/tools/integration-test/src/tests/channel_upgrade/ica.rs +++ b/tools/integration-test/src/tests/channel_upgrade/ica.rs @@ -32,7 +32,9 @@ use ibc_relayer_types::signer::Signer; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; -use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period}; +use ibc_test_framework::chain::config::{ + add_allow_message, set_max_deposit_period, set_voting_period, +}; use ibc_test_framework::chain::ext::ica::register_interchain_account; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ @@ -314,22 +316,7 @@ impl TestOverrides for ChannelUpgradeICAUnordered { } fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - use serde_json::Value; - - let allow_messages = genesis - .get_mut("app_state") - .and_then(|app_state| app_state.get_mut("interchainaccounts")) - .and_then(|ica| ica.get_mut("host_genesis_state")) - .and_then(|state| state.get_mut("params")) - .and_then(|params| params.get_mut("allow_messages")) - .and_then(|allow_messages| allow_messages.as_array_mut()); - - if let Some(allow_messages) = allow_messages { - allow_messages.push(Value::String("/cosmos.bank.v1beta1.MsgSend".to_string())); - } else { - return Err(Error::generic(eyre!("failed to update genesis file"))); - } - + add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; set_voting_period(genesis, VOTING_PERIOD)?; diff --git a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs index 891c5c295d..1a8dbe27ed 100644 --- a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs +++ b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake.rs @@ -36,6 +36,7 @@ pub struct ChannelUpgradeHandshake; impl TestOverrides for ChannelUpgradeHandshake { fn modify_relayer_config(&self, config: &mut Config) { config.mode.channels.enabled = true; + config.mode.clients.misbehaviour = false; } fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { diff --git a/tools/integration-test/src/tests/ica.rs b/tools/integration-test/src/tests/ica.rs index 024e82a4d9..1e987c7ca3 100644 --- a/tools/integration-test/src/tests/ica.rs +++ b/tools/integration-test/src/tests/ica.rs @@ -17,6 +17,7 @@ use ibc_relayer_types::signer::Signer; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; +use ibc_test_framework::chain::config::add_allow_message; use ibc_test_framework::chain::ext::ica::register_interchain_account; use ibc_test_framework::ibc::denom::Denom; use ibc_test_framework::prelude::*; @@ -77,22 +78,9 @@ impl TestOverrides for IcaFilterTestAllow { // Allow MsgSend messages over ICA fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - use serde_json::Value; - - let allow_messages = genesis - .get_mut("app_state") - .and_then(|app_state| app_state.get_mut("interchainaccounts")) - .and_then(|ica| ica.get_mut("host_genesis_state")) - .and_then(|state| state.get_mut("params")) - .and_then(|params| params.get_mut("allow_messages")) - .and_then(|allow_messages| allow_messages.as_array_mut()); - - if let Some(allow_messages) = allow_messages { - allow_messages.push(Value::String("/cosmos.bank.v1beta1.MsgSend".to_string())); - Ok(()) - } else { - Err(Error::generic(eyre!("failed to update genesis file"))) - } + add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; + + Ok(()) } } diff --git a/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs b/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs index 56a0075ff3..06ff3cdd00 100644 --- a/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs +++ b/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs @@ -17,6 +17,7 @@ use ibc_relayer_types::bigint::U256; use ibc_relayer_types::signer::Signer; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; +use ibc_test_framework::chain::config::add_allow_message; use ibc_test_framework::chain::ext::ica::register_interchain_account; use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test; use ibc_test_framework::prelude::*; @@ -35,23 +36,7 @@ struct IcaOrderedChannelTest; impl TestOverrides for IcaOrderedChannelTest { fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - use serde_json::Value; - - // Allow MsgSend messages over ICA - let allow_messages = genesis - .get_mut("app_state") - .and_then(|app_state| app_state.get_mut("interchainaccounts")) - .and_then(|ica| ica.get_mut("host_genesis_state")) - .and_then(|state| state.get_mut("params")) - .and_then(|params| params.get_mut("allow_messages")) - .and_then(|allow_messages| allow_messages.as_array_mut()); - - if let Some(allow_messages) = allow_messages { - allow_messages.push(Value::String("/cosmos.bank.v1beta1.MsgSend".to_string())); - } else { - return Err(Error::generic(eyre!("failed to update genesis file"))); - } - + add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; update_genesis_for_consumer_chain(genesis)?; Ok(()) diff --git a/tools/integration-test/src/tests/interchain_security/ica_transfer.rs b/tools/integration-test/src/tests/interchain_security/ica_transfer.rs index 5377f206da..2814489513 100644 --- a/tools/integration-test/src/tests/interchain_security/ica_transfer.rs +++ b/tools/integration-test/src/tests/interchain_security/ica_transfer.rs @@ -11,6 +11,7 @@ use ibc_relayer_types::bigint::U256; use ibc_relayer_types::signer::Signer; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; +use ibc_test_framework::chain::config::add_allow_message; use ibc_test_framework::chain::ext::ica::register_interchain_account; use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test; use ibc_test_framework::prelude::*; @@ -28,23 +29,7 @@ struct InterchainSecurityIcaTransferTest; impl TestOverrides for InterchainSecurityIcaTransferTest { fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - use serde_json::Value; - - // Allow MsgSend messages over ICA - let allow_messages = genesis - .get_mut("app_state") - .and_then(|app_state| app_state.get_mut("interchainaccounts")) - .and_then(|ica| ica.get_mut("host_genesis_state")) - .and_then(|state| state.get_mut("params")) - .and_then(|params| params.get_mut("allow_messages")) - .and_then(|allow_messages| allow_messages.as_array_mut()); - - if let Some(allow_messages) = allow_messages { - allow_messages.push(Value::String("/cosmos.bank.v1beta1.MsgSend".to_string())); - } else { - return Err(Error::generic(eyre!("failed to update genesis file"))); - } - + add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; update_genesis_for_consumer_chain(genesis)?; Ok(()) diff --git a/tools/test-framework/src/chain/config.rs b/tools/test-framework/src/chain/config.rs index 66f4f3a02d..63290e55ca 100644 --- a/tools/test-framework/src/chain/config.rs +++ b/tools/test-framework/src/chain/config.rs @@ -190,6 +190,26 @@ pub fn set_max_deposit_period(genesis: &mut serde_json::Value, period: &str) -> Ok(()) } +pub fn add_allow_message(genesis: &mut serde_json::Value, message: &str) -> Result<(), Error> { + let allow_messages = genesis + .get_mut("app_state") + .and_then(|app_state| app_state.get_mut("interchainaccounts")) + .and_then(|ica| ica.get_mut("host_genesis_state")) + .and_then(|state| state.get_mut("params")) + .and_then(|params| params.get_mut("allow_messages")) + .and_then(|allow_messages| allow_messages.as_array_mut()) + .ok_or_else(|| { + eyre!("failed to retrieve allow_messages as a vector, in the genesis file") + })?; + + // Only add `MsgSend` if the wildcard '*' is not specified + if allow_messages.iter().all(|v| v.as_str() != Some("*")) { + allow_messages.push(serde_json::Value::String(message.to_string())); + } + + Ok(()) +} + pub fn set_min_deposit_amount( genesis: &mut serde_json::Value, min_deposit_amount: u64, From 21014746b915bd263f308163402d64f3ae71c811 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 3 Apr 2024 08:41:03 +0200 Subject: [PATCH 78/99] cargo fmt --- crates/relayer-cli/src/commands/tx/channel.rs | 40 +++++++++---------- crates/relayer/src/chain/endpoint.rs | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 8feadfb2a7..4e55c07cc0 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -133,26 +133,26 @@ impl Runnable for TxChanOpenInitCmd { self, |chains: ChainHandlePair, dst_connection: ConnectionEnd| { Channel { - connection_delay: Default::default(), - ordering: self.order, - a_side: ChannelSide::new( - chains.src, - ClientId::default(), - ConnectionId::default(), - self.src_port_id.clone(), - None, - None, - ), - b_side: ChannelSide::new( - chains.dst, - dst_connection.client_id().clone(), - self.dst_conn_id.clone(), - self.dst_port_id.clone(), - None, - None, - ), - } - } + connection_delay: Default::default(), + ordering: self.order, + a_side: ChannelSide::new( + chains.src, + ClientId::default(), + ConnectionId::default(), + self.src_port_id.clone(), + None, + None, + ), + b_side: ChannelSide::new( + chains.dst, + dst_connection.client_id().clone(), + self.dst_conn_id.clone(), + self.dst_port_id.clone(), + None, + None, + ), + } + } ); } } diff --git a/crates/relayer/src/chain/endpoint.rs b/crates/relayer/src/chain/endpoint.rs index c1597348fa..a871bbdb4b 100644 --- a/crates/relayer/src/chain/endpoint.rs +++ b/crates/relayer/src/chain/endpoint.rs @@ -15,10 +15,10 @@ use ibc_relayer_types::core::ics02_client::header::{AnyHeader, Header}; use ibc_relayer_types::core::ics03_connection::connection::{ ConnectionEnd, IdentifiedConnectionEnd, State, }; -use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade}; use ibc_relayer_types::core::ics03_connection::version::{get_compatible_versions, Version}; use ibc_relayer_types::core::ics04_channel::channel::{ChannelEnd, IdentifiedChannelEnd}; use ibc_relayer_types::core::ics04_channel::packet::{PacketMsgType, Sequence}; +use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade}; use ibc_relayer_types::core::ics23_commitment::commitment::{ CommitmentPrefix, CommitmentProofBytes, }; From ff43a8db572f1997132f37163e39db3b03b1a107 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 3 Apr 2024 14:01:00 +0200 Subject: [PATCH 79/99] Fix async ICQ test --- .../src/tests/async_icq/simple_query.rs | 4 +-- .../src/tests/channel_upgrade/ica.rs | 4 +-- tools/integration-test/src/tests/ica.rs | 7 ++--- .../ica_ordered_channel.rs | 4 +-- .../tests/interchain_security/ica_transfer.rs | 4 +-- tools/test-framework/src/chain/config.rs | 27 ++++++++++++++++++- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/tools/integration-test/src/tests/async_icq/simple_query.rs b/tools/integration-test/src/tests/async_icq/simple_query.rs index 73b8f7362a..f8343d1811 100644 --- a/tools/integration-test/src/tests/async_icq/simple_query.rs +++ b/tools/integration-test/src/tests/async_icq/simple_query.rs @@ -1,7 +1,7 @@ use ibc_relayer::channel::version::Version; use ibc_relayer::config::ChainConfig; use ibc_test_framework::chain::config::{ - add_allow_message, set_max_deposit_period, set_voting_period, + add_allow_message_interchainquery, set_max_deposit_period, set_voting_period, }; use ibc_test_framework::chain::ext::async_icq::AsyncIcqMethodsExt; use ibc_test_framework::chain::ext::bootstrap::ChainBootstrapMethodsExt; @@ -34,7 +34,7 @@ impl TestOverrides for AsyncIcqTest { fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; set_voting_period(genesis, VOTING_PERIOD)?; - add_allow_message(genesis, "/provenance.oracle.v1.Query/Oracle")?; + add_allow_message_interchainquery(genesis, "/provenance.oracle.v1.Query/Oracle")?; Ok(()) } diff --git a/tools/integration-test/src/tests/channel_upgrade/ica.rs b/tools/integration-test/src/tests/channel_upgrade/ica.rs index 75d068bba1..8b738b6855 100644 --- a/tools/integration-test/src/tests/channel_upgrade/ica.rs +++ b/tools/integration-test/src/tests/channel_upgrade/ica.rs @@ -33,7 +33,7 @@ use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; use ibc_test_framework::chain::config::{ - add_allow_message, set_max_deposit_period, set_voting_period, + add_allow_message_interchainaccounts, set_max_deposit_period, set_voting_period, }; use ibc_test_framework::chain::ext::ica::register_interchain_account; use ibc_test_framework::prelude::*; @@ -316,7 +316,7 @@ impl TestOverrides for ChannelUpgradeICAUnordered { } fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; + add_allow_message_interchainaccounts(genesis, "/cosmos.bank.v1beta1.MsgSend")?; set_max_deposit_period(genesis, MAX_DEPOSIT_PERIOD)?; set_voting_period(genesis, VOTING_PERIOD)?; diff --git a/tools/integration-test/src/tests/ica.rs b/tools/integration-test/src/tests/ica.rs index 6822b3b1f9..7ed2ef38f0 100644 --- a/tools/integration-test/src/tests/ica.rs +++ b/tools/integration-test/src/tests/ica.rs @@ -16,8 +16,9 @@ use ibc_relayer_types::signer::Signer; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; -use ibc_test_framework::chain::config::add_allow_message; -use ibc_test_framework::chain::ext::ica::register_interchain_account; +use ibc_test_framework::chain::{ + config::add_allow_message_interchainaccounts, ext::ica::register_interchain_account, +}; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{ assert_eventually_channel_closed, assert_eventually_channel_established, query_channel_end, @@ -76,7 +77,7 @@ impl TestOverrides for IcaFilterTestAllow { // Allow MsgSend messages over ICA fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; + add_allow_message_interchainaccounts(genesis, "/cosmos.bank.v1beta1.MsgSend")?; Ok(()) } diff --git a/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs b/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs index 06ff3cdd00..ade71f8132 100644 --- a/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs +++ b/tools/integration-test/src/tests/interchain_security/ica_ordered_channel.rs @@ -17,7 +17,7 @@ use ibc_relayer_types::bigint::U256; use ibc_relayer_types::signer::Signer; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; -use ibc_test_framework::chain::config::add_allow_message; +use ibc_test_framework::chain::config::add_allow_message_interchainaccounts; use ibc_test_framework::chain::ext::ica::register_interchain_account; use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test; use ibc_test_framework::prelude::*; @@ -36,7 +36,7 @@ struct IcaOrderedChannelTest; impl TestOverrides for IcaOrderedChannelTest { fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; + add_allow_message_interchainaccounts(genesis, "/cosmos.bank.v1beta1.MsgSend")?; update_genesis_for_consumer_chain(genesis)?; Ok(()) diff --git a/tools/integration-test/src/tests/interchain_security/ica_transfer.rs b/tools/integration-test/src/tests/interchain_security/ica_transfer.rs index 2814489513..28d05cad91 100644 --- a/tools/integration-test/src/tests/interchain_security/ica_transfer.rs +++ b/tools/integration-test/src/tests/interchain_security/ica_transfer.rs @@ -11,7 +11,7 @@ use ibc_relayer_types::bigint::U256; use ibc_relayer_types::signer::Signer; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::tx_msg::Msg; -use ibc_test_framework::chain::config::add_allow_message; +use ibc_test_framework::chain::config::add_allow_message_interchainaccounts; use ibc_test_framework::chain::ext::ica::register_interchain_account; use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test; use ibc_test_framework::prelude::*; @@ -29,7 +29,7 @@ struct InterchainSecurityIcaTransferTest; impl TestOverrides for InterchainSecurityIcaTransferTest { fn modify_genesis_file(&self, genesis: &mut serde_json::Value) -> Result<(), Error> { - add_allow_message(genesis, "/cosmos.bank.v1beta1.MsgSend")?; + add_allow_message_interchainaccounts(genesis, "/cosmos.bank.v1beta1.MsgSend")?; update_genesis_for_consumer_chain(genesis)?; Ok(()) diff --git a/tools/test-framework/src/chain/config.rs b/tools/test-framework/src/chain/config.rs index 63290e55ca..ad84749548 100644 --- a/tools/test-framework/src/chain/config.rs +++ b/tools/test-framework/src/chain/config.rs @@ -190,7 +190,10 @@ pub fn set_max_deposit_period(genesis: &mut serde_json::Value, period: &str) -> Ok(()) } -pub fn add_allow_message(genesis: &mut serde_json::Value, message: &str) -> Result<(), Error> { +pub fn add_allow_message_interchainaccounts( + genesis: &mut serde_json::Value, + message: &str, +) -> Result<(), Error> { let allow_messages = genesis .get_mut("app_state") .and_then(|app_state| app_state.get_mut("interchainaccounts")) @@ -210,6 +213,28 @@ pub fn add_allow_message(genesis: &mut serde_json::Value, message: &str) -> Resu Ok(()) } +pub fn add_allow_message_interchainquery( + genesis: &mut serde_json::Value, + message: &str, +) -> Result<(), Error> { + let allow_messages = genesis + .get_mut("app_state") + .and_then(|app_state| app_state.get_mut("interchainquery")) + .and_then(|ica| ica.get_mut("params")) + .and_then(|params| params.get_mut("allow_queries")) + .and_then(|allow_messages| allow_messages.as_array_mut()) + .ok_or_else(|| { + eyre!("failed to retrieve allow_messages as a vector, in the genesis file") + })?; + + // Only add `MsgSend` if the wildcard '*' is not specified + if allow_messages.iter().all(|v| v.as_str() != Some("*")) { + allow_messages.push(serde_json::Value::String(message.to_string())); + } + + Ok(()) +} + pub fn set_min_deposit_amount( genesis: &mut serde_json::Value, min_deposit_amount: u64, From 678f3dad2af05a0ab6bf4313ac6e681d885fd97c Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 3 Apr 2024 14:05:38 +0200 Subject: [PATCH 80/99] Fix cargo doc --- crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs index 00224fdb6b..4d11cbbd91 100644 --- a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs +++ b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs @@ -3,8 +3,6 @@ use core::str::FromStr; use ibc_proto::ibc::core::channel::v1::UpgradeFields as RawUpgradeFields; use ibc_proto::Protobuf; use itertools::Itertools; -use std::string::ToString; -use std::vec::Vec; use crate::core::ics04_channel::channel::Ordering; use crate::core::ics04_channel::error::Error as ChannelError; From d76b7c49696494e3323d2f0e9ba88bddcd14d362 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 3 Apr 2024 14:23:42 +0200 Subject: [PATCH 81/99] Remove redundant import --- crates/relayer-cli/src/commands/tx/channel.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 4e55c07cc0..5b8ea71067 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -2,7 +2,6 @@ use abscissa_core::clap::Parser; use abscissa_core::Command; -use abscissa_core::Runnable; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryConnectionRequest, QueryHeight}; From 3481a541b8ae11e200f74669076b89184b6cf2b3 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 3 Apr 2024 14:29:08 +0200 Subject: [PATCH 82/99] Remove redundant import --- tools/test-framework/src/chain/cli/upgrade.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/test-framework/src/chain/cli/upgrade.rs b/tools/test-framework/src/chain/cli/upgrade.rs index 172391bf05..cef7e8df0a 100644 --- a/tools/test-framework/src/chain/cli/upgrade.rs +++ b/tools/test-framework/src/chain/cli/upgrade.rs @@ -4,7 +4,6 @@ use eyre::eyre; use crate::chain::exec::simple_exec; -use crate::error::Error; use crate::prelude::*; pub fn vote_proposal( From e1039e506e7e562349fdd0c00063f5ccfdf9219a Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 5 Apr 2024 12:09:11 +0200 Subject: [PATCH 83/99] Correctly handle channel upgrade error --- crates/relayer-cli/src/commands/tx/channel.rs | 6 +- .../src/core/ics04_channel/events.rs | 97 ++++++++ crates/relayer-types/src/events.rs | 9 + .../src/chain/cosmos/types/events/channel.rs | 2 + crates/relayer/src/channel.rs | 208 +++++++++++------- crates/relayer/src/event.rs | 18 ++ .../src/event/source/websocket/extract.rs | 1 + crates/relayer/src/supervisor.rs | 3 +- crates/relayer/src/worker/channel.rs | 25 ++- .../src/tests/channel_upgrade/timeout.rs | 5 +- 10 files changed, 290 insertions(+), 84 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index 5b8ea71067..de75a48aaf 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -780,7 +780,7 @@ impl Runnable for TxChanUpgradeTryCmd { info!("message ChanUpgradeTry: {}", channel); - let res: Result, Error> = channel + let res: Result = channel .build_chan_upgrade_try_and_send() .map_err(Error::channel); @@ -911,7 +911,7 @@ impl Runnable for TxChanUpgradeAckCmd { info!("message ChanUpgradeAck: {}", channel); - let res: Result, Error> = channel + let res: Result = channel .build_chan_upgrade_ack_and_send() .map_err(Error::channel); @@ -1042,7 +1042,7 @@ impl Runnable for TxChanUpgradeConfirmCmd { info!("message ChanUpgradeConfirm: {}", channel); - let res: Result, Error> = channel + let res: Result = channel .build_chan_upgrade_confirm_and_send() .map_err(Error::channel); diff --git a/crates/relayer-types/src/core/ics04_channel/events.rs b/crates/relayer-types/src/core/ics04_channel/events.rs index 957b41f4a1..85e2493fe5 100644 --- a/crates/relayer-types/src/core/ics04_channel/events.rs +++ b/crates/relayer-types/src/core/ics04_channel/events.rs @@ -37,6 +37,7 @@ pub const PKT_ACK_ATTRIBUTE_KEY: &str = "packet_ack_hex"; pub const UPGRADE_SEQUENCE: &str = "upgrade_sequence"; pub const UPGRADE_TIMEOUT_HEIGHT: &str = "timeout_height"; pub const UPGRADE_TIMEOUT_TIMESTAMP: &str = "timeout_timestamp"; +pub const UPGRADE_ERROR_RECEIPT: &str = "error_receipt"; #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] pub struct Attributes { @@ -103,6 +104,7 @@ pub struct UpgradeAttributes { pub upgrade_sequence: Sequence, pub upgrade_timeout_height: Option, pub upgrade_timeout_timestamp: Option, + pub error_receipt: Option, } impl UpgradeAttributes { @@ -529,6 +531,7 @@ impl From for UpgradeAttributes { upgrade_sequence: ev.upgrade_sequence, upgrade_timeout_height: None, upgrade_timeout_timestamp: None, + error_receipt: None, } } } @@ -607,6 +610,7 @@ impl From for UpgradeAttributes { upgrade_sequence: ev.upgrade_sequence, upgrade_timeout_height: None, upgrade_timeout_timestamp: None, + error_receipt: None, } } } @@ -685,6 +689,7 @@ impl From for UpgradeAttributes { upgrade_sequence: ev.upgrade_sequence, upgrade_timeout_height: None, upgrade_timeout_timestamp: None, + error_receipt: None, } } } @@ -763,6 +768,7 @@ impl From for UpgradeAttributes { upgrade_sequence: ev.upgrade_sequence, upgrade_timeout_height: None, upgrade_timeout_timestamp: None, + error_receipt: None, } } } @@ -841,6 +847,7 @@ impl From for UpgradeAttributes { upgrade_sequence: ev.upgrade_sequence, upgrade_timeout_height: None, upgrade_timeout_timestamp: None, + error_receipt: None, } } } @@ -919,6 +926,7 @@ impl From for UpgradeAttributes { upgrade_sequence: ev.upgrade_sequence, upgrade_timeout_height: None, upgrade_timeout_timestamp: None, + error_receipt: None, } } } @@ -1011,6 +1019,7 @@ impl From for UpgradeAttributes { upgrade_sequence: ev.upgrade_sequence, upgrade_timeout_height: ev.upgrade_timeout_height, upgrade_timeout_timestamp: ev.upgrade_timeout_timestamp, + error_receipt: None, } } } @@ -1060,6 +1069,94 @@ impl EventType for UpgradeTimeout { IbcEventType::UpgradeTimeoutChannel } } +// + +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct UpgradeError { + pub port_id: PortId, + pub channel_id: ChannelId, + pub counterparty_port_id: PortId, + pub counterparty_channel_id: Option, + pub upgrade_sequence: Sequence, + pub error_receipt: String, +} + +impl Display for UpgradeError { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + if let Some(counterparty_channel_id) = &self.counterparty_channel_id { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: {counterparty_channel_id}, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } else { + write!(f, "UpgradeAttributes {{ port_id: {}, channel_id: {}, counterparty_port_id: {}, counterparty_channel_id: None, upgrade_connection_hops: [", self.port_id, self.channel_id, self.counterparty_port_id)?; + } + + write!( + f, + "], upgrade_sequence: {}, error_receipt: {} }}", + self.upgrade_sequence, self.error_receipt + ) + } +} + +impl From for UpgradeAttributes { + fn from(ev: UpgradeError) -> Self { + Self { + port_id: ev.port_id, + channel_id: ev.channel_id, + counterparty_port_id: ev.counterparty_port_id, + counterparty_channel_id: ev.counterparty_channel_id, + upgrade_sequence: ev.upgrade_sequence, + upgrade_timeout_height: None, + upgrade_timeout_timestamp: None, + error_receipt: Some(ev.error_receipt), + } + } +} + +impl UpgradeError { + pub fn channel_id(&self) -> &ChannelId { + &self.channel_id + } + + pub fn port_id(&self) -> &PortId { + &self.port_id + } + + pub fn counterparty_port_id(&self) -> &PortId { + &self.counterparty_port_id + } + + pub fn counterparty_channel_id(&self) -> Option<&ChannelId> { + self.counterparty_channel_id.as_ref() + } +} + +impl TryFrom for UpgradeError { + type Error = EventError; + + fn try_from(attrs: UpgradeAttributes) -> Result { + let error_receipt = attrs.error_receipt.unwrap_or_default(); + Ok(Self { + port_id: attrs.port_id, + channel_id: attrs.channel_id, + counterparty_port_id: attrs.counterparty_port_id, + counterparty_channel_id: attrs.counterparty_channel_id, + upgrade_sequence: attrs.upgrade_sequence, + error_receipt, + }) + } +} + +impl From for IbcEvent { + fn from(v: UpgradeError) -> Self { + IbcEvent::UpgradeErrorChannel(v) + } +} + +impl EventType for UpgradeError { + fn event_type() -> IbcEventType { + IbcEventType::UpgradeErrorChannel + } +} macro_rules! impl_try_from_attribute_for_event { ($($event:ty),+) => { diff --git a/crates/relayer-types/src/events.rs b/crates/relayer-types/src/events.rs index efc1b4dc62..7ceb45d5c2 100644 --- a/crates/relayer-types/src/events.rs +++ b/crates/relayer-types/src/events.rs @@ -132,6 +132,7 @@ const CHANNEL_OPEN_ACK_EVENT: &str = "channel_open_ack"; const CHANNEL_OPEN_CONFIRM_EVENT: &str = "channel_open_confirm"; const CHANNEL_CLOSE_INIT_EVENT: &str = "channel_close_init"; const CHANNEL_CLOSE_CONFIRM_EVENT: &str = "channel_close_confirm"; +/// Channel upgrade event types const CHANNEL_UPGRADE_INIT_EVENT: &str = "channel_upgrade_init"; const CHANNEL_UPGRADE_TRY_EVENT: &str = "channel_upgrade_try"; const CHANNEL_UPGRADE_ACK_EVENT: &str = "channel_upgrade_ack"; @@ -139,6 +140,7 @@ const CHANNEL_UPGRADE_CONFIRM_EVENT: &str = "channel_upgrade_confirm"; const CHANNEL_UPGRADE_OPEN_EVENT: &str = "channel_upgrade_open"; const CHANNEL_UPGRADE_CANCEL_EVENT: &str = "channel_upgrade_cancelled"; const CHANNEL_UPGRADE_TIMEOUT_EVENT: &str = "channel_upgrade_timeout"; +const CHANNEL_UPGRADE_ERROR_EVENT: &str = "channel_upgrade_error"; /// Packet event types const SEND_PACKET_EVENT: &str = "send_packet"; const RECEIVE_PACKET_EVENT: &str = "receive_packet"; @@ -177,6 +179,7 @@ pub enum IbcEventType { UpgradeOpenChannel, UpgradeCancelChannel, UpgradeTimeoutChannel, + UpgradeErrorChannel, SendPacket, ReceivePacket, WriteAck, @@ -216,6 +219,7 @@ impl IbcEventType { IbcEventType::UpgradeOpenChannel => CHANNEL_UPGRADE_OPEN_EVENT, IbcEventType::UpgradeCancelChannel => CHANNEL_UPGRADE_CANCEL_EVENT, IbcEventType::UpgradeTimeoutChannel => CHANNEL_UPGRADE_TIMEOUT_EVENT, + IbcEventType::UpgradeErrorChannel => CHANNEL_UPGRADE_ERROR_EVENT, IbcEventType::SendPacket => SEND_PACKET_EVENT, IbcEventType::ReceivePacket => RECEIVE_PACKET_EVENT, IbcEventType::WriteAck => WRITE_ACK_EVENT, @@ -259,6 +263,7 @@ impl FromStr for IbcEventType { CHANNEL_UPGRADE_OPEN_EVENT => Ok(IbcEventType::UpgradeOpenChannel), CHANNEL_UPGRADE_CANCEL_EVENT => Ok(IbcEventType::UpgradeCancelChannel), CHANNEL_UPGRADE_TIMEOUT_EVENT => Ok(IbcEventType::UpgradeTimeoutChannel), + CHANNEL_UPGRADE_ERROR_EVENT => Ok(IbcEventType::UpgradeErrorChannel), SEND_PACKET_EVENT => Ok(IbcEventType::SendPacket), RECEIVE_PACKET_EVENT => Ok(IbcEventType::ReceivePacket), WRITE_ACK_EVENT => Ok(IbcEventType::WriteAck), @@ -304,6 +309,7 @@ pub enum IbcEvent { UpgradeOpenChannel(ChannelEvents::UpgradeOpen), UpgradeCancelChannel(ChannelEvents::UpgradeCancel), UpgradeTimeoutChannel(ChannelEvents::UpgradeTimeout), + UpgradeErrorChannel(ChannelEvents::UpgradeError), SendPacket(ChannelEvents::SendPacket), ReceivePacket(ChannelEvents::ReceivePacket), @@ -350,6 +356,7 @@ impl Display for IbcEvent { IbcEvent::UpgradeOpenChannel(ev) => write!(f, "UpgradeOpenChannel({ev})"), IbcEvent::UpgradeCancelChannel(ev) => write!(f, "UpgradeCancelChannel({ev})"), IbcEvent::UpgradeTimeoutChannel(ev) => write!(f, "UpgradeTimeoutChannel({ev})"), + IbcEvent::UpgradeErrorChannel(ev) => write!(f, "UpgradeErrorChannel({ev})"), IbcEvent::SendPacket(ev) => write!(f, "SendPacket({ev})"), IbcEvent::ReceivePacket(ev) => write!(f, "ReceivePacket({ev})"), @@ -402,6 +409,7 @@ impl IbcEvent { IbcEvent::UpgradeOpenChannel(_) => IbcEventType::UpgradeOpenChannel, IbcEvent::UpgradeCancelChannel(_) => IbcEventType::UpgradeCancelChannel, IbcEvent::UpgradeTimeoutChannel(_) => IbcEventType::UpgradeTimeoutChannel, + IbcEvent::UpgradeErrorChannel(_) => IbcEventType::UpgradeErrorChannel, IbcEvent::SendPacket(_) => IbcEventType::SendPacket, IbcEvent::ReceivePacket(_) => IbcEventType::ReceivePacket, IbcEvent::WriteAcknowledgement(_) => IbcEventType::WriteAck, @@ -435,6 +443,7 @@ impl IbcEvent { IbcEvent::UpgradeOpenChannel(ev) => Some(ev.into()), IbcEvent::UpgradeCancelChannel(ev) => Some(ev.into()), IbcEvent::UpgradeTimeoutChannel(ev) => Some(ev.into()), + IbcEvent::UpgradeErrorChannel(ev) => Some(ev.into()), _ => None, } } diff --git a/crates/relayer/src/chain/cosmos/types/events/channel.rs b/crates/relayer/src/chain/cosmos/types/events/channel.rs index 64bcd27541..dfe30eacc0 100644 --- a/crates/relayer/src/chain/cosmos/types/events/channel.rs +++ b/crates/relayer/src/chain/cosmos/types/events/channel.rs @@ -75,6 +75,8 @@ fn extract_upgrade_attributes( &format!("{namespace}.timeout_timestamp"), ) .and_then(|v| v.parse().ok()), + error_receipt: maybe_extract_attribute(object, &format!("{namespace}.error_receipt")) + .and_then(|v| v.parse().ok()), }) } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index a6d01120bb..01a79376ab 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -764,6 +764,7 @@ impl Channel { &mut self, state: State, ) -> Result<(Option, Next), ChannelError> { + //tracing::warn!("state: {:#?}, counterparty: {:#?}", state, self.counterparty_state()?); let event = match (state, self.counterparty_state()?) { // Open handshake steps (State::Init, State::Uninitialized) => Some(self.build_chan_open_try_and_send()?), @@ -789,51 +790,71 @@ impl Channel { // Channel Upgrade handshake steps (State::Open(UpgradeState::Upgrading), State::Open(UpgradeState::NotUpgrading)) => { - match self.build_chan_upgrade_try_and_send()? { - Some(event) => Some(event), - None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), - } + Some(self.build_chan_upgrade_try_and_send()?) } (State::Open(UpgradeState::Upgrading), State::Open(UpgradeState::Upgrading)) => { - match self.build_chan_upgrade_try_and_send()? { - Some(event) => Some(event), - None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), - } + Some(self.build_chan_upgrade_try_and_send()?) } (State::Open(UpgradeState::NotUpgrading), State::Open(UpgradeState::Upgrading)) => { - match self.flipped().build_chan_upgrade_try_and_send()? { - Some(event) => Some(event), - None => Some(self.build_chan_upgrade_cancel_and_send()?), - } + Some(self.build_chan_upgrade_try_and_send()?) } (State::Flushing, State::Open(UpgradeState::Upgrading)) => { - match self.build_chan_upgrade_ack_and_send()? { - Some(event) => Some(event), - None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), - } + Some(self.build_chan_upgrade_ack_and_send()?) } - (State::Flushing, State::Flushing) => match self.build_chan_upgrade_ack_and_send()? { - Some(event) => Some(event), - None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), - }, + (State::Flushing, State::Flushing) => Some(self.build_chan_upgrade_ack_and_send()?), (State::Flushcomplete, State::Flushing) => { - match self.build_chan_upgrade_confirm_and_send()? { - Some(event) => Some(event), - None => Some(self.flipped().build_chan_upgrade_cancel_and_send()?), - } + Some(self.build_chan_upgrade_confirm_and_send()?) } + (State::Flushing, State::Open(UpgradeState::NotUpgrading)) => { Some(self.flipped().build_chan_upgrade_cancel_and_send()?) } + (State::Open(UpgradeState::NotUpgrading), State::Flushing) => { + Some(self.build_chan_upgrade_cancel_and_send()?) + } (State::Flushcomplete, State::Flushcomplete) => { Some(self.build_chan_upgrade_open_and_send()?) } (State::Flushcomplete, State::Open(UpgradeState::NotUpgrading)) => { - Some(self.flipped().build_chan_upgrade_open_and_send()?) + // Check if error + let height = self.b_chain().query_latest_height().unwrap(); + let (upgrade_error, _) = self + .b_chain() + .query_upgrade_error( + QueryUpgradeErrorRequest { + port_id: self.b_side.port_id.clone().to_string(), + channel_id: self.b_side.channel_id.clone().unwrap().clone().to_string(), + }, + height, + ) + .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof())?; + + if upgrade_error.sequence > 0.into() { + Some(self.flipped().build_chan_upgrade_cancel_and_send()?) + } else { + Some(self.flipped().build_chan_upgrade_open_and_send()?) + } } (State::Open(UpgradeState::NotUpgrading), State::Flushcomplete) => { - Some(self.build_chan_upgrade_open_and_send()?) + // Check if error query_upgrade_error + let height = self.a_chain().query_latest_height().unwrap(); + let (upgrade_error, _) = self + .a_chain() + .query_upgrade_error( + QueryUpgradeErrorRequest { + port_id: self.a_side.port_id.clone().to_string(), + channel_id: self.a_side.channel_id.clone().unwrap().clone().to_string(), + }, + height, + ) + .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof())?; + + if upgrade_error.sequence > 0.into() { + Some(self.build_chan_upgrade_cancel_and_send()?) + } else { + Some(self.build_chan_upgrade_open_and_send()?) + } } _ => None, @@ -846,7 +867,8 @@ impl Channel { | Some(IbcEvent::OpenAckChannel(_)) | Some(IbcEvent::CloseConfirmChannel(_)) | Some(IbcEvent::UpgradeConfirmChannel(_)) - | Some(IbcEvent::UpgradeOpenChannel(_)) => Ok((event, Next::Abort)), + | Some(IbcEvent::UpgradeOpenChannel(_)) + | Some(IbcEvent::UpgradeCancelChannel(_)) => Ok((event, Next::Abort)), _ => Ok((event, Next::Continue)), } } @@ -1675,7 +1697,7 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_try_and_send(&self) -> Result, ChannelError> { + pub fn build_chan_upgrade_try_and_send(&self) -> Result { let dst_msgs = self.build_chan_upgrade_try()?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeTry"); @@ -1685,22 +1707,34 @@ impl Channel { .send_messages_and_wait_commit(tm) .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; - // If the Channel Upgrade Try times out, there will be no events in the response - if let Some(event_with_height) = events.into_iter().find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeTryChannel(_)) - || matches!(event_with_height.event, IbcEvent::ChainError(_)) - }) { - match &event_with_height.event { - IbcEvent::UpgradeTryChannel(_) => { - info!("👋 {} => {}", self.dst_chain().id(), event_with_height); - Ok(Some(event_with_height.event.clone())) - } - IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), - _ => Err(ChannelError::invalid_event(event_with_height.event.clone())), + // Find the relevant event for channel upgrade try + let result = events + .into_iter() + .find(|events_with_height| { + matches!(events_with_height.event, IbcEvent::UpgradeTryChannel(_)) + || matches!(events_with_height.event, IbcEvent::UpgradeErrorChannel(_)) + || matches!(events_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no chan upgrade try or upgrade error event was in the response".to_string(), + ) + })?; + + match result.event { + IbcEvent::UpgradeTryChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) } - } else { - warn!("no channel upgrade try event found, this might be due to the channel upgrade having timed out"); - Ok(None) + IbcEvent::UpgradeErrorChannel(ref ev) => { + warn!( + "Channel Upgrade Try failed with error: {}", + ev.error_receipt + ); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), } } @@ -1773,7 +1807,7 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_ack_and_send(&self) -> Result, ChannelError> { + pub fn build_chan_upgrade_ack_and_send(&self) -> Result { let dst_msgs = self.build_chan_upgrade_ack()?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeAck"); @@ -1783,22 +1817,34 @@ impl Channel { .send_messages_and_wait_commit(tm) .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; - // If the Channel Upgrade Ack times out, there will be no events in the response - if let Some(event_with_height) = events.into_iter().find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeAckChannel(_)) - || matches!(event_with_height.event, IbcEvent::ChainError(_)) - }) { - match &event_with_height.event { - IbcEvent::UpgradeAckChannel(_) => { - info!("👋 {} => {}", self.dst_chain().id(), event_with_height); - Ok(Some(event_with_height.event.clone())) - } - IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), - _ => Err(ChannelError::invalid_event(event_with_height.event.clone())), + // Find the relevant event for channel upgrade ack + let result = events + .into_iter() + .find(|events_with_height| { + matches!(events_with_height.event, IbcEvent::UpgradeAckChannel(_)) + || matches!(events_with_height.event, IbcEvent::UpgradeErrorChannel(_)) + || matches!(events_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no chan upgrade ack or upgrade error event was in the response".to_string(), + ) + })?; + + match result.event { + IbcEvent::UpgradeAckChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) } - } else { - warn!("no channel upgrade ack event found, this might be due to the channel upgrade having timed out"); - Ok(None) + IbcEvent::UpgradeErrorChannel(ref ev) => { + warn!( + "Channel Upgrade Ack failed with error: {}", + ev.error_receipt + ); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), } } @@ -1886,7 +1932,7 @@ impl Channel { Ok(chain_a_msgs) } - pub fn build_chan_upgrade_confirm_and_send(&self) -> Result, ChannelError> { + pub fn build_chan_upgrade_confirm_and_send(&self) -> Result { let dst_msgs = self.build_chan_upgrade_confirm()?; let tm = TrackedMsgs::new_static(dst_msgs, "ChannelUpgradeConfirm"); @@ -1896,22 +1942,34 @@ impl Channel { .send_messages_and_wait_commit(tm) .map_err(|e| ChannelError::submit(self.dst_chain().id(), e))?; - // If the Channel Upgrade Confirm times out, there will be no events in the response - if let Some(event_with_height) = events.into_iter().find(|event_with_height| { - matches!(event_with_height.event, IbcEvent::UpgradeConfirmChannel(_)) - || matches!(event_with_height.event, IbcEvent::ChainError(_)) - }) { - match &event_with_height.event { - IbcEvent::UpgradeConfirmChannel(_) => { - info!("👋 {} => {}", self.dst_chain().id(), event_with_height); - Ok(Some(event_with_height.event.clone())) - } - IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), - _ => Err(ChannelError::invalid_event(event_with_height.event.clone())), + // Find the relevant event for channel upgrade confirm + let result = events + .into_iter() + .find(|events_with_height| { + matches!(events_with_height.event, IbcEvent::UpgradeConfirmChannel(_)) + || matches!(events_with_height.event, IbcEvent::UpgradeErrorChannel(_)) + || matches!(events_with_height.event, IbcEvent::ChainError(_)) + }) + .ok_or_else(|| { + ChannelError::missing_event( + "no chan upgrade ack or upgrade error event was in the response".to_string(), + ) + })?; + + match result.event { + IbcEvent::UpgradeConfirmChannel(_) => { + info!("👋 {} => {}", self.dst_chain().id(), result); + Ok(result.event) } - } else { - warn!("no channel upgrade confirm event found, this might be due to the channel upgrade having timed out"); - Ok(None) + IbcEvent::UpgradeErrorChannel(ref ev) => { + warn!( + "Channel Upgrade Confirm failed with error: {}", + ev.error_receipt + ); + Ok(result.event) + } + IbcEvent::ChainError(e) => Err(ChannelError::tx_response(e.clone())), + _ => Err(ChannelError::invalid_event(result.event)), } } diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index 628e99129d..1a6cacdbca 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -142,6 +142,10 @@ pub fn ibc_event_try_from_abci_event(abci_event: &AbciEvent) -> Result Ok(IbcEvent::UpgradeErrorChannel( + channel_upgrade_error_try_from_abci_event(abci_event) + .map_err(IbcEventError::channel)?, + )), Ok(IbcEventType::SendPacket) => Ok(IbcEvent::SendPacket( send_packet_try_from_abci_event(abci_event).map_err(IbcEventError::channel)?, )), @@ -353,6 +357,16 @@ pub fn channel_upgrade_timeout_try_from_abci_event( } } +pub fn channel_upgrade_error_try_from_abci_event( + abci_event: &AbciEvent, +) -> Result { + match channel_upgrade_extract_attributes_from_tx(abci_event) { + Ok(attrs) => channel_events::UpgradeError::try_from(attrs) + .map_err(|_| ChannelError::implementation_specific()), + Err(e) => Err(e), + } +} + pub fn send_packet_try_from_abci_event( abci_event: &AbciEvent, ) -> Result { @@ -536,6 +550,10 @@ fn channel_upgrade_extract_attributes_from_tx( let maybe_timestamp = Timestamp::from_str(value).ok(); attr.upgrade_timeout_timestamp = maybe_timestamp; } + channel_events::UPGRADE_ERROR_RECEIPT => { + let maybe_error_receipt = value.to_string(); + attr.error_receipt = Some(maybe_error_receipt); + } _ => {} } } diff --git a/crates/relayer/src/event/source/websocket/extract.rs b/crates/relayer/src/event/source/websocket/extract.rs index 9c5bcb0dfd..284c4e9af1 100644 --- a/crates/relayer/src/event/source/websocket/extract.rs +++ b/crates/relayer/src/event/source/websocket/extract.rs @@ -239,6 +239,7 @@ fn event_is_type_channel(ev: &IbcEvent) -> bool { | IbcEvent::UpgradeAckChannel(_) | IbcEvent::UpgradeConfirmChannel(_) | IbcEvent::UpgradeOpenChannel(_) + | IbcEvent::UpgradeErrorChannel(_) | IbcEvent::SendPacket(_) | IbcEvent::ReceivePacket(_) | IbcEvent::WriteAcknowledgement(_) diff --git a/crates/relayer/src/supervisor.rs b/crates/relayer/src/supervisor.rs index 2cf8706e4b..16ca340703 100644 --- a/crates/relayer/src/supervisor.rs +++ b/crates/relayer/src/supervisor.rs @@ -542,7 +542,8 @@ pub fn collect_events( IbcEvent::UpgradeInitChannel(..) | IbcEvent::UpgradeTryChannel(..) | IbcEvent::UpgradeAckChannel(..) - | IbcEvent::UpgradeOpenChannel(..) => { + | IbcEvent::UpgradeOpenChannel(..) + | IbcEvent::UpgradeErrorChannel(..) => { collect_event( &mut collected, event_with_height.clone(), diff --git a/crates/relayer/src/worker/channel.rs b/crates/relayer/src/worker/channel.rs index 2a741ddf34..5847a6198f 100644 --- a/crates/relayer/src/worker/channel.rs +++ b/crates/relayer/src/worker/channel.rs @@ -1,7 +1,7 @@ use core::time::Duration; use crossbeam_channel::Receiver; use ibc_relayer_types::events::IbcEventType; -use tracing::{debug, error_span}; +use tracing::{debug, error_span, warn}; use crate::chain::requests::QueryHeight; use crate::channel::{channel_handshake_retry, Channel as RelayChannel}; @@ -71,6 +71,29 @@ pub fn spawn_channel_worker( }, ) .map_err(|e| TaskError::Fatal(RunError::retry(e))), + IbcEventType::UpgradeErrorChannel => retry_with_index( + channel_handshake_retry::default_strategy(max_block_times), + |index| match RelayChannel::restore_from_state( + chains.a.clone(), + chains.b.clone(), + channel.clone(), + QueryHeight::Latest, + ) { + Ok((handshake_channel, _)) => { + match handshake_channel + .build_chan_upgrade_cancel_and_send() + { + Ok(_) => RetryResult::Ok(Next::Abort), + Err(e) => { + warn!("Channel upgrade cancel failed: {e}"); + RetryResult::Retry(index) + } + } + } + Err(_) => RetryResult::Retry(index), + }, + ) + .map_err(|e| TaskError::Fatal(RunError::retry(e))), _ => retry_with_index( channel_handshake_retry::default_strategy(max_block_times), |index| match RelayChannel::restore_from_event( diff --git a/tools/integration-test/src/tests/channel_upgrade/timeout.rs b/tools/integration-test/src/tests/channel_upgrade/timeout.rs index b6087e470e..39984fbd53 100644 --- a/tools/integration-test/src/tests/channel_upgrade/timeout.rs +++ b/tools/integration-test/src/tests/channel_upgrade/timeout.rs @@ -799,10 +799,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnAck { info!("Check that the step ChanUpgradeAck timed out..."); // ACK should fail because the upgrade has timed out - assert!( - ack_event.is_none(), - "channel upgrade ack should have failed due to timeout" - ); + assert_eq!(ack_event.event_type(), IbcEventType::UpgradeErrorChannel); info!("Will run ChanUpgradeCancel step..."); From 364adf432b1e1f51cae3f372519f2bc664817100 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 8 Apr 2024 13:36:46 +0200 Subject: [PATCH 84/99] Remove validate basic from channel open try --- Cargo.toml | 1 - .../core/ics04_channel/msgs/chan_open_try.rs | 29 +++++++------------ crates/relayer/src/channel.rs | 1 - 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fb41b66941..06928aa369 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,7 +121,6 @@ uuid = "1.7.0" overflow-checks = true [patch.crates-io] -# ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "main" } # tendermint = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" } # tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" } # tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" } diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs index 2b94286f36..e802433cc4 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_open_try.rs @@ -1,7 +1,6 @@ use crate::core::ics04_channel::channel::ChannelEnd; use crate::core::ics04_channel::error::Error as ChannelError; use crate::core::ics04_channel::version::Version; -use crate::core::ics24_host::error::ValidationError; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::proofs::Proofs; @@ -57,16 +56,6 @@ impl Msg for MsgChannelOpenTry { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn validate_basic(&self) -> Result<(), ValidationError> { - // TODO: adapt error - // match self.channel.counterparty().channel_id() { - // None => Err(ValidationError::invalid_counterparty_channel_id()), - // Some(_c) => Ok(()), - // } - - Ok(()) - } } impl Protobuf for MsgChannelOpenTry {} @@ -98,21 +87,25 @@ impl TryFrom for MsgChannelOpenTry { .transpose() .map_err(ChannelError::identifier)?; + let channel: ChannelEnd = raw_msg + .channel + .ok_or_else(ChannelError::missing_channel)? + .try_into()?; + + assert!( + channel.counterparty().channel_id().is_some(), + "Expected counterparty channel to have a channel ID" + ); + let msg = MsgChannelOpenTry { port_id: raw_msg.port_id.parse().map_err(ChannelError::identifier)?, previous_channel_id, - channel: raw_msg - .channel - .ok_or_else(ChannelError::missing_channel)? - .try_into()?, + channel, counterparty_version: raw_msg.counterparty_version.into(), proofs, signer: raw_msg.signer.parse().map_err(ChannelError::signer)?, }; - msg.validate_basic() - .map_err(ChannelError::invalid_counterparty_channel_id)?; - Ok(msg) } } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 01a79376ab..8fc9bdb7e1 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -764,7 +764,6 @@ impl Channel { &mut self, state: State, ) -> Result<(Option, Next), ChannelError> { - //tracing::warn!("state: {:#?}, counterparty: {:#?}", state, self.counterparty_state()?); let event = match (state, self.counterparty_state()?) { // Open handshake steps (State::Init, State::Uninitialized) => Some(self.build_chan_open_try_and_send()?), From e258615e78b354e9e9d3741510ae12097c4a37d3 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 19 Apr 2024 13:33:32 +0200 Subject: [PATCH 85/99] Improve detection of channel upgrade cancel when one end is in Flushcomplete --- crates/relayer/src/chain/counterparty.rs | 2 +- crates/relayer/src/channel.rs | 32 +++++++++++++++------ tools/test-framework/src/relayer/channel.rs | 2 +- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/crates/relayer/src/chain/counterparty.rs b/crates/relayer/src/chain/counterparty.rs index 80f06f83a3..0710f25a6e 100644 --- a/crates/relayer/src/chain/counterparty.rs +++ b/crates/relayer/src/chain/counterparty.rs @@ -167,7 +167,7 @@ pub fn channel_connection_client_no_checks( channel_id: channel_id.clone(), height: QueryHeight::Latest, }, - IncludeProof::No, + IncludeProof::Yes, ) .map_err(Error::relayer)?; diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 8fc9bdb7e1..32e080865c 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -460,7 +460,7 @@ impl Channel { channel_id: id.clone(), height: QueryHeight::Latest, }, - IncludeProof::No, + IncludeProof::Yes, ) .map(|(channel_end, _)| channel_end) .map_err(|e| ChannelError::chain_query(self.a_chain().id(), e)) @@ -818,7 +818,7 @@ impl Channel { (State::Flushcomplete, State::Open(UpgradeState::NotUpgrading)) => { // Check if error let height = self.b_chain().query_latest_height().unwrap(); - let (upgrade_error, _) = self + let upgrade_error = self .b_chain() .query_upgrade_error( QueryUpgradeErrorRequest { @@ -827,10 +827,16 @@ impl Channel { }, height, ) - .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof())?; + .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof()); + + let channel_end = self.a_channel(self.a_channel_id())?; - if upgrade_error.sequence > 0.into() { - Some(self.flipped().build_chan_upgrade_cancel_and_send()?) + if let Ok((upgrade_error, _)) = upgrade_error { + if upgrade_error.sequence == channel_end.upgrade_sequence { + Some(self.flipped().build_chan_upgrade_cancel_and_send()?) + } else { + Some(self.flipped().build_chan_upgrade_open_and_send()?) + } } else { Some(self.flipped().build_chan_upgrade_open_and_send()?) } @@ -838,7 +844,7 @@ impl Channel { (State::Open(UpgradeState::NotUpgrading), State::Flushcomplete) => { // Check if error query_upgrade_error let height = self.a_chain().query_latest_height().unwrap(); - let (upgrade_error, _) = self + let upgrade_error = self .a_chain() .query_upgrade_error( QueryUpgradeErrorRequest { @@ -847,10 +853,18 @@ impl Channel { }, height, ) - .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof())?; + .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof()); - if upgrade_error.sequence > 0.into() { - Some(self.build_chan_upgrade_cancel_and_send()?) + let channel_end = self.b_channel(self.b_channel_id())?; + + if let Ok((upgrade_error, _)) = upgrade_error { + if upgrade_error.sequence > 0.into() + && upgrade_error.sequence == channel_end.upgrade_sequence + { + Some(self.build_chan_upgrade_cancel_and_send()?) + } else { + Some(self.build_chan_upgrade_open_and_send()?) + } } else { Some(self.build_chan_upgrade_open_and_send()?) } diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index e1baa50f1f..a9c4b32b03 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -409,7 +409,7 @@ pub fn assert_eventually_channel_upgrade_try Date: Tue, 23 Apr 2024 11:09:03 +0200 Subject: [PATCH 86/99] Add changelog entry --- .../unreleased/features/ibc-relayer/2547-channel-upgrades.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/features/ibc-relayer/2547-channel-upgrades.md diff --git a/.changelog/unreleased/features/ibc-relayer/2547-channel-upgrades.md b/.changelog/unreleased/features/ibc-relayer/2547-channel-upgrades.md new file mode 100644 index 0000000000..869b7096d4 --- /dev/null +++ b/.changelog/unreleased/features/ibc-relayer/2547-channel-upgrades.md @@ -0,0 +1,2 @@ + - Add support for upgrading channels, as per the [ICS 004 specification](https://github.com/cosmos/ibc/blob/main/spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md) ([#3228](https://github.com/informalsystems/hermes/issues/2547)) + This feature allows chains to upgrade an existing channel to take advantage of new features without having to create a new channel, thus preserving all existing packet state processed on the channel. For example, a channel could now be upgraded to enable the [ICS 029 fee middleware](https://ibc.cosmos.network/main/middleware/ics29-fee/overview), allowing relayer operators on that channel to receive fees each time they relay an incentivized packet. From bea686752a586747ec7a94f624f29ef80ec2b6ee Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 14 May 2024 10:46:30 +0200 Subject: [PATCH 87/99] Fix post-merge compilation issues --- crates/relayer/src/event.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/relayer/src/event.rs b/crates/relayer/src/event.rs index a579f214ee..f5219f4750 100644 --- a/crates/relayer/src/event.rs +++ b/crates/relayer/src/event.rs @@ -543,8 +543,14 @@ fn channel_upgrade_extract_attributes_from_tx( let mut attr = ChannelUpgradeAttributes::default(); for tag in &event.attributes { - let key = tag.key.as_str(); - let value = tag.value.as_str(); + let key = tag + .key_str() + .map_err(|_| ChannelError::malformed_event_attribute_key())?; + + let value = tag + .value_str() + .map_err(|_| ChannelError::malformed_event_attribute_value(key.to_owned()))?; + match key { channel_events::PORT_ID_ATTRIBUTE_KEY => { attr.port_id = value.parse().map_err(ChannelError::identifier)? From a185fa1da4ab2796f8df3d6f57de4538a5f8dfdd Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 14 May 2024 13:42:02 +0200 Subject: [PATCH 88/99] Rename `State::Flushcomplete` to `State::FlushComplete` --- .../src/core/ics04_channel/channel.rs | 24 +++++++++---------- .../msgs/chan_upgrade_confirm.rs | 2 +- .../ics04_channel/msgs/chan_upgrade_open.rs | 2 +- crates/relayer/src/channel.rs | 12 +++++----- crates/relayer/src/link.rs | 2 +- .../src/tests/channel_upgrade/timeout.rs | 2 +- .../upgrade_handshake_steps.rs | 8 +++---- tools/test-framework/src/relayer/channel.rs | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index c3de396df6..c61037b31f 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -266,7 +266,7 @@ impl ChannelEnd { matches!( self.state, - Open(UpgradeState::Upgrading) | Flushing | Flushcomplete + Open(UpgradeState::Upgrading) | Flushing | FlushComplete ) } } @@ -430,7 +430,7 @@ pub enum State { /// A channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. Flushing, /// A channel has just completed flushing any in-flight packets. - Flushcomplete, + FlushComplete, } impl Serialize for State { @@ -445,7 +445,7 @@ impl Serialize for State { Self::Open(_) => serializer.serialize_str("Open"), Self::Closed => serializer.serialize_str("Closed"), Self::Flushing => serializer.serialize_str("Flushing"), - Self::Flushcomplete => serializer.serialize_str("Flushcomplete"), + Self::FlushComplete => serializer.serialize_str("FlushComplete"), } } } @@ -460,7 +460,7 @@ impl State { Self::Open(_) => "OPEN", Self::Closed => "CLOSED", Self::Flushing => "FLUSHING", - Self::Flushcomplete => "FLUSHCOMPLETE", + Self::FlushComplete => "FLUSHCOMPLETE", } } @@ -473,7 +473,7 @@ impl State { 3 => Ok(Self::Open(UpgradeState::NotUpgrading)), 4 => Ok(Self::Closed), 5 => Ok(Self::Flushing), - 6 => Ok(Self::Flushcomplete), + 6 => Ok(Self::FlushComplete), _ => Err(Error::unknown_state(s)), } } @@ -487,7 +487,7 @@ impl State { State::Open(_) => 3, State::Closed => 4, State::Flushing => 5, - State::Flushcomplete => 6, + State::FlushComplete => 6, } } @@ -711,7 +711,7 @@ mod tests { State::Open(UpgradeState::Upgrading), State::Closed, State::Flushing, - State::Flushcomplete, + State::FlushComplete, ]; for state in higher_or_equal_states { assert!(State::Uninitialized.less_or_equal_progress(state)) @@ -731,7 +731,7 @@ mod tests { State::Open(UpgradeState::Upgrading), State::Closed, State::Flushing, - State::Flushcomplete, + State::FlushComplete, ]; for state in lower_states { assert!(!State::Init.less_or_equal_progress(state)); @@ -753,7 +753,7 @@ mod tests { State::Open(UpgradeState::Upgrading), State::Closed, State::Flushing, - State::Flushcomplete, + State::FlushComplete, ]; for state in lower_states { assert!(!State::TryOpen.less_or_equal_progress(state)); @@ -774,7 +774,7 @@ mod tests { State::Open(UpgradeState::Upgrading), State::Closed, State::Flushing, - State::Flushcomplete, + State::FlushComplete, ]; for state in lower_states { assert!(!State::Open(UpgradeState::NotUpgrading).less_or_equal_progress(state)); @@ -797,14 +797,14 @@ mod tests { State::Open(UpgradeState::Upgrading), State::Closed, State::Flushing, - State::Flushcomplete, + State::FlushComplete, ]; let upgrading_states = vec![ State::Open(UpgradeState::Upgrading), State::Closed, State::Flushing, - State::Flushcomplete, + State::FlushComplete, ]; for upgrade_state in upgrading_states { for state in states.iter() { diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs index e10d21953e..d2a2c96b22 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_confirm.rs @@ -132,7 +132,7 @@ pub mod test_util { RawMsgChannelUpgradeConfirm { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), - counterparty_channel_state: 6, // Flushcomplete + counterparty_channel_state: 6, // FlushComplete counterparty_upgrade: Some(get_dummy_upgrade()), proof_upgrade: get_dummy_proof(), proof_channel: get_dummy_proof(), diff --git a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs index a91e65de2e..36bac21367 100644 --- a/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs +++ b/crates/relayer-types/src/core/ics04_channel/msgs/chan_upgrade_open.rs @@ -117,7 +117,7 @@ pub mod test_util { RawMsgChannelUpgradeOpen { port_id: PortId::default().to_string(), channel_id: ChannelId::default().to_string(), - counterparty_channel_state: 6, // Flushcomplete + counterparty_channel_state: 6, // FlushComplete counterparty_upgrade_sequence: 1, proof_channel: get_dummy_proof(), proof_height: Some(RawHeight { diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 32e080865c..9cb8d887a3 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -801,7 +801,7 @@ impl Channel { Some(self.build_chan_upgrade_ack_and_send()?) } (State::Flushing, State::Flushing) => Some(self.build_chan_upgrade_ack_and_send()?), - (State::Flushcomplete, State::Flushing) => { + (State::FlushComplete, State::Flushing) => { Some(self.build_chan_upgrade_confirm_and_send()?) } @@ -812,10 +812,10 @@ impl Channel { Some(self.build_chan_upgrade_cancel_and_send()?) } - (State::Flushcomplete, State::Flushcomplete) => { + (State::FlushComplete, State::FlushComplete) => { Some(self.build_chan_upgrade_open_and_send()?) } - (State::Flushcomplete, State::Open(UpgradeState::NotUpgrading)) => { + (State::FlushComplete, State::Open(UpgradeState::NotUpgrading)) => { // Check if error let height = self.b_chain().query_latest_height().unwrap(); let upgrade_error = self @@ -841,7 +841,7 @@ impl Channel { Some(self.flipped().build_chan_upgrade_open_and_send()?) } } - (State::Open(UpgradeState::NotUpgrading), State::Flushcomplete) => { + (State::Open(UpgradeState::NotUpgrading), State::FlushComplete) => { // Check if error query_upgrade_error let height = self.a_chain().query_latest_height().unwrap(); let upgrade_error = self @@ -917,8 +917,8 @@ impl Channel { IbcEvent::CloseInitChannel(_) => State::Closed, IbcEvent::UpgradeInitChannel(_) => State::Open(UpgradeState::Upgrading), IbcEvent::UpgradeTryChannel(_) => State::Flushing, - IbcEvent::UpgradeAckChannel(_) => State::Flushcomplete, - IbcEvent::UpgradeConfirmChannel(_) => State::Flushcomplete, + IbcEvent::UpgradeAckChannel(_) => State::FlushComplete, + IbcEvent::UpgradeConfirmChannel(_) => State::FlushComplete, IbcEvent::UpgradeOpenChannel(_) => State::Open(UpgradeState::NotUpgrading), _ => State::Uninitialized, }; diff --git a/crates/relayer/src/link.rs b/crates/relayer/src/link.rs index 174f4641ab..3d87499480 100644 --- a/crates/relayer/src/link.rs +++ b/crates/relayer/src/link.rs @@ -89,7 +89,7 @@ impl Link { if !a_channel.state_matches(&ChannelState::Open(UpgradeState::NotUpgrading)) && !a_channel.state_matches(&ChannelState::Open(UpgradeState::Upgrading)) && !a_channel.state_matches(&ChannelState::Flushing) - && !a_channel.state_matches(&ChannelState::Flushcomplete) + && !a_channel.state_matches(&ChannelState::FlushComplete) && !a_channel.state_matches(&ChannelState::Closed) { return Err(LinkError::invalid_channel_state( diff --git a/tools/integration-test/src/tests/channel_upgrade/timeout.rs b/tools/integration-test/src/tests/channel_upgrade/timeout.rs index 39984fbd53..42bdd288ed 100644 --- a/tools/integration-test/src/tests/channel_upgrade/timeout.rs +++ b/tools/integration-test/src/tests/channel_upgrade/timeout.rs @@ -312,7 +312,7 @@ impl BinaryChannelTest for ChannelUpgradeTimeoutConfirmHandshake { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), - ChannelState::Flushcomplete, + ChannelState::FlushComplete, ChannelState::Flushing, &old_attrs, )?; diff --git a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs index d1f17a2d22..31b665bc9a 100644 --- a/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs +++ b/tools/integration-test/src/tests/channel_upgrade/upgrade_handshake_steps.rs @@ -213,7 +213,7 @@ impl BinaryChannelTest for ChannelUpgradeManualHandshake { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), - ChannelState::Flushcomplete, + ChannelState::FlushComplete, ChannelState::Flushing, &old_attrs, )?; @@ -477,7 +477,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromAck { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), - ChannelState::Flushcomplete, + ChannelState::FlushComplete, ChannelState::Flushing, &old_attrs, )?; @@ -617,7 +617,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFromConfirm { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), - ChannelState::Flushcomplete, + ChannelState::FlushComplete, ChannelState::Flushing, &old_attrs, )?; @@ -773,7 +773,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeInitiateNewUpgrade { &chains.handle_b, &channels.channel_id_a.as_ref(), &channels.port_a.as_ref(), - ChannelState::Flushcomplete, + ChannelState::FlushComplete, ChannelState::Flushing, &pre_upgrade_1_attrs, )?; diff --git a/tools/test-framework/src/relayer/channel.rs b/tools/test-framework/src/relayer/channel.rs index 99abb8d547..2ea35886c9 100644 --- a/tools/test-framework/src/relayer/channel.rs +++ b/tools/test-framework/src/relayer/channel.rs @@ -515,7 +515,7 @@ pub fn assert_eventually_channel_upgrade_confirm Date: Tue, 14 May 2024 13:47:36 +0200 Subject: [PATCH 89/99] Small cleanup --- .../relayer-types/src/core/ics04_channel/upgrade_fields.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs index 4d11cbbd91..9d90ed41c1 100644 --- a/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs +++ b/crates/relayer-types/src/core/ics04_channel/upgrade_fields.rs @@ -32,14 +32,16 @@ impl TryFrom for UpgradeFields { type Error = ChannelError; fn try_from(value: RawUpgradeFields) -> Result { + use itertools::Either; + let ordering = Ordering::from_i32(value.ordering)?; let (connection_hops, failures): (Vec<_>, Vec<_>) = value .connection_hops .iter() .partition_map(|id| match ConnectionId::from_str(id) { - Ok(connection_id) => itertools::Either::Left(connection_id), - Err(e) => itertools::Either::Right((id.clone(), e)), + Ok(connection_id) => Either::Left(connection_id), + Err(e) => Either::Right((id.clone(), e)), }); if !failures.is_empty() { From fb18998e5e30326f50acba93b5d8bca953060a6e Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 15 May 2024 09:51:31 +0200 Subject: [PATCH 90/99] Sort imports --- crates/relayer/src/chain/handle.rs | 2 +- crates/relayer/src/channel.rs | 19 ++++++++++--------- crates/relayer/src/object.rs | 3 +-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/relayer/src/chain/handle.rs b/crates/relayer/src/chain/handle.rs index 750a083e73..2f3ec0170e 100644 --- a/crates/relayer/src/chain/handle.rs +++ b/crates/relayer/src/chain/handle.rs @@ -1,6 +1,5 @@ use alloc::sync::Arc; use core::fmt::{self, Debug, Display}; -use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade}; use crossbeam_channel as channel; use tracing::Span; @@ -20,6 +19,7 @@ use ibc_relayer_types::{ ics04_channel::{ channel::{ChannelEnd, IdentifiedChannelEnd}, packet::{PacketMsgType, Sequence}, + upgrade::{ErrorReceipt, Upgrade}, }, ics23_commitment::{commitment::CommitmentPrefix, merkle::MerkleProof}, ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}, diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 9cb8d887a3..578ff4ddde 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1,4 +1,10 @@ -pub use error::ChannelError; +use core::fmt::{Display, Error as FmtError, Formatter}; +use core::time::Duration; + +use ibc_proto::google::protobuf::Any; +use serde::Serialize; +use tracing::{debug, error, info, warn}; + use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest}; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_ack::MsgChannelUpgradeAck; use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_cancel::MsgChannelUpgradeCancel; @@ -7,13 +13,6 @@ use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_open::MsgChannelU use ibc_relayer_types::core::ics04_channel::msgs::chan_upgrade_timeout::MsgChannelUpgradeTimeout; use ibc_relayer_types::core::ics04_channel::packet::Sequence; -use core::fmt::{Display, Error as FmtError, Formatter}; -use core::time::Duration; - -use ibc_proto::google::protobuf::Any; -use serde::Serialize; -use tracing::{debug, error, info, warn}; - use ibc_relayer_types::core::ics04_channel::channel::{ ChannelEnd, Counterparty, IdentifiedChannelEnd, Ordering, State, UpgradeState, }; @@ -48,10 +47,12 @@ use crate::util::retry::retry_with_index; use crate::util::retry::RetryResult; use crate::util::task::Next; -pub mod error; pub mod version; use version::Version; +pub mod error; +pub use error::ChannelError; + pub mod channel_handshake_retry { //! Provides utility methods and constants to configure the retry behavior //! for the channel handshake algorithm. diff --git a/crates/relayer/src/object.rs b/crates/relayer/src/object.rs index 8027554747..aac3efb257 100644 --- a/crates/relayer/src/object.rs +++ b/crates/relayer/src/object.rs @@ -1,7 +1,6 @@ use std::fmt::Display; use flex_error::define_error; -use ibc_relayer_types::core::ics04_channel::events::UpgradeAttributes; use serde::{Deserialize, Serialize}; use ibc_relayer_types::applications::ics29_fee::events::IncentivizedPacket; @@ -9,7 +8,7 @@ use ibc_relayer_types::core::{ ics02_client::events::UpdateClient, ics03_connection::events::Attributes as ConnectionAttributes, ics04_channel::events::{ - Attributes, CloseInit, SendPacket, TimeoutPacket, WriteAcknowledgement, + Attributes, CloseInit, SendPacket, TimeoutPacket, UpgradeAttributes, WriteAcknowledgement, }, ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}, }; From 29e3e09d637b768c6ed108331953b7d26572edd3 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 22 May 2024 16:33:35 +0200 Subject: [PATCH 91/99] Whitespace --- crates/relayer/src/worker/channel.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/relayer/src/worker/channel.rs b/crates/relayer/src/worker/channel.rs index 5847a6198f..76c5eb361e 100644 --- a/crates/relayer/src/worker/channel.rs +++ b/crates/relayer/src/worker/channel.rs @@ -36,6 +36,7 @@ pub fn spawn_channel_worker( cmd_rx: Receiver, ) -> TaskHandle { let mut complete_handshake_on_new_block = true; + spawn_background_task( error_span!("worker.channel", channel = %channel.short_name()), Some(Duration::from_millis(200)), @@ -50,6 +51,7 @@ pub fn spawn_channel_worker( debug!("starts processing {:?}", last_event); complete_handshake_on_new_block = false; + if let Some(event_with_height) = last_event { match event_with_height.event.event_type() { IbcEventType::UpgradeInitChannel @@ -71,6 +73,7 @@ pub fn spawn_channel_worker( }, ) .map_err(|e| TaskError::Fatal(RunError::retry(e))), + IbcEventType::UpgradeErrorChannel => retry_with_index( channel_handshake_retry::default_strategy(max_block_times), |index| match RelayChannel::restore_from_state( @@ -94,6 +97,7 @@ pub fn spawn_channel_worker( }, ) .map_err(|e| TaskError::Fatal(RunError::retry(e))), + _ => retry_with_index( channel_handshake_retry::default_strategy(max_block_times), |index| match RelayChannel::restore_from_event( @@ -120,6 +124,7 @@ pub fn spawn_channel_worker( debug!("starts processing block event at {:#?}", current_height); complete_handshake_on_new_block = false; + retry_with_index( channel_handshake_retry::default_strategy(max_block_times), |index| match RelayChannel::restore_from_state( From 08400d048b081038f3227af85f7cf2645aab36a9 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 22 May 2024 16:38:15 +0200 Subject: [PATCH 92/99] Remove patch override --- tools/check-guide/Cargo.lock | 1710 +++++++++++++++++----------------- tools/check-guide/Cargo.toml | 4 - 2 files changed, 878 insertions(+), 836 deletions(-) diff --git a/tools/check-guide/Cargo.lock b/tools/check-guide/Cargo.lock index df79b8288f..645b211df2 100644 --- a/tools/check-guide/Cargo.lock +++ b/tools/check-guide/Cargo.lock @@ -23,7 +23,7 @@ dependencies = [ "termcolor", "toml 0.5.11", "tracing", - "tracing-log", + "tracing-log 0.1.4", "tracing-subscriber", "wait-timeout", ] @@ -58,18 +58,18 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "ammonia" -version = "3.3.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e6d1c7838db705c9b756557ee27c384ce695a1c51a6fe528784cb1c6840170" +checksum = "1ab99eae5ee58501ab236beb6f20f6ca39be615267b014899c89b2f0bc18a459" dependencies = [ "html5ever", "maplit", @@ -95,63 +95,64 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arc-swap" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "arrayref" @@ -184,33 +185,34 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "async-tungstenite" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e9efbe14612da0a19fb983059a0b621e9cf6225d7018ecab4f9988215540dc" +checksum = "3609af4bbf701ddaf1f6bb4e6257dff4ff8932327d0e685d3f653724c258b1ac" dependencies = [ "futures-io", "futures-util", "log", "pin-project-lite", - "rustls-native-certs", + "rustls-native-certs 0.7.0", + "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "tungstenite", ] @@ -227,9 +229,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" @@ -242,7 +244,7 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", + "http 0.2.12", "http-body", "hyper", "itoa", @@ -272,7 +274,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", + "http 0.2.12", "http-body", "mime", "rustversion", @@ -282,13 +284,13 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object", @@ -303,9 +305,15 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -342,9 +350,9 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitcoin" -version = "0.31.1" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd00f3c09b5f21fb357abe32d29946eb8bb7a0862bae62c0b5e4a692acbbe73c" +checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" dependencies = [ "bech32 0.10.0-beta", "bitcoin-internals", @@ -383,9 +391,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "blake2" @@ -405,7 +413,7 @@ dependencies = [ "arrayref", "arrayvec", "cc", - "cfg-if 1.0.0", + "cfg-if", "constant_time_eq", ] @@ -429,29 +437,29 @@ dependencies = [ [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "tinyvec", ] [[package]] name = "bstr" -version = "1.6.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", - "regex-automata 0.3.9", + "regex-automata 0.4.6", "serde", ] [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byte-unit" @@ -463,32 +471,17 @@ dependencies = [ "utf8-width", ] -[[package]] -name = "bytecount" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7" - [[package]] name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" -dependencies = [ - "serde", -] +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] -name = "camino" -version = "1.1.6" +name = "bytes" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -499,42 +492,11 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e9e01327e6c86e92ec72b1c798d4a94810f147209bbe3ffab6a86954937a6f" -[[package]] -name = "cargo-platform" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", -] - [[package]] name = "cc" -version = "1.0.83" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -556,14 +518,14 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -578,30 +540,30 @@ dependencies = [ "clap_lex 0.2.4", "indexmap 1.9.3", "once_cell", - "strsim", + "strsim 0.10.0", "termcolor", "textwrap", ] [[package]] name = "clap" -version = "4.4.6" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", - "clap_lex 0.5.1", - "strsim", + "clap_lex 0.7.0", + "strsim 0.11.1", "terminal_size", ] @@ -616,11 +578,11 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.3" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" +checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e" dependencies = [ - "clap 4.4.6", + "clap 4.5.4", ] [[package]] @@ -647,15 +609,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "color-eyre" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" dependencies = [ "backtrace", "color-spantrace", @@ -668,9 +630,9 @@ dependencies = [ [[package]] name = "color-spantrace" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" dependencies = [ "once_cell", "owo-colors", @@ -680,28 +642,28 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] name = "const-oid" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "constant_time_eq" @@ -722,9 +684,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -732,67 +694,52 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crossbeam-channel" -version = "0.4.4" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ - "crossbeam-utils 0.7.2", - "maybe-uninit", + "crossbeam-utils", ] [[package]] -name = "crossbeam-channel" -version = "0.5.11" +name = "crossbeam-deque" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "crossbeam-utils 0.8.19", + "crossbeam-epoch", + "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "crossbeam-utils 0.8.19", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", + "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" @@ -802,9 +749,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core", @@ -824,11 +771,11 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest 0.10.7", @@ -841,13 +788,13 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] @@ -869,8 +816,8 @@ version = "5.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ - "cfg-if 1.0.0", - "hashbrown 0.14.1", + "cfg-if", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -878,15 +825,26 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + +[[package]] +name = "dbus" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" +dependencies = [ + "libc", + "libdbus-sys", + "winapi", +] [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", @@ -894,9 +852,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] [[package]] name = "derivation-path" @@ -955,7 +916,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] @@ -972,9 +933,9 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest 0.10.7", @@ -986,9 +947,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8", "serde", @@ -1010,15 +971,16 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", "rand_core", "serde", "sha2 0.10.8", + "subtle", "zeroize", ] @@ -1036,9 +998,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elasticlunr-rs" @@ -1054,9 +1016,9 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -1079,11 +1041,21 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", +] + +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", ] [[package]] @@ -1101,15 +1073,15 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ + "anstream", + "anstyle", + "env_filter", "humantime", - "is-terminal", "log", - "regex", - "termcolor", ] [[package]] @@ -1120,32 +1092,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ - "cc", "libc", -] - -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "version_check", + "windows-sys 0.52.0", ] [[package]] @@ -1170,9 +1122,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "ff" @@ -1186,20 +1138,20 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "filetime" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", ] [[package]] @@ -1229,18 +1181,21 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "fs-err" -version = "2.9.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] [[package]] name = "fsevent-sys" @@ -1263,9 +1218,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -1278,9 +1233,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -1288,15 +1243,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -1305,38 +1260,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -1363,11 +1318,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "libc", "wasi", @@ -1376,27 +1331,21 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" - -[[package]] -name = "glob" -version = "0.3.1" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", ] [[package]] @@ -1412,17 +1361,17 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http", - "indexmap 1.9.3", + "http 0.2.12", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -1431,15 +1380,15 @@ dependencies = [ [[package]] name = "half" -version = "1.8.2" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" [[package]] name = "handlebars" -version = "4.4.0" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" dependencies = [ "log", "pest", @@ -1457,9 +1406,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hdpath" @@ -1476,10 +1425,10 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "headers-core", - "http", + "http 0.2.12", "httpdate", "mime", "sha1", @@ -1491,7 +1440,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.12", ] [[package]] @@ -1511,9 +1460,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -1523,9 +1472,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-conservative" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" [[package]] name = "hex_lit" @@ -1544,23 +1493,34 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" +checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4" dependencies = [ "log", "mac", "markup5ever", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.65", ] [[package]] name = "http" -version = "0.2.9" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -1569,12 +1529,12 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] @@ -1608,22 +1568,22 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2", "tokio", "tower-service", "tracing", @@ -1632,16 +1592,16 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", + "http 0.2.12", "hyper", - "rustls", + "rustls 0.21.12", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", ] [[package]] @@ -1658,16 +1618,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1686,10 +1646,10 @@ dependencies = [ "async-trait", "flex-error", "futures", - "http", + "http 0.2.12", "ibc-proto", "ibc-relayer-types", - "itertools 0.10.5", + "itertools", "reqwest", "serde", "serde_json", @@ -1700,11 +1660,11 @@ dependencies = [ [[package]] name = "ibc-proto" -version = "0.42.2" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a6f2bbf7e1d12f98d8d54d9114231b865418d0f8b619c0873180eafdee07fd" +checksum = "66080040d5a4800d52966d55b055400f86b79c34b854b935bef03c87aacda62a" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "flex-error", "ics23", @@ -1727,7 +1687,7 @@ dependencies = [ "bs58", "byte-unit", "bytes", - "crossbeam-channel 0.5.11", + "crossbeam-channel", "digest 0.10.7", "dirs-next", "ed25519", @@ -1738,13 +1698,13 @@ dependencies = [ "generic-array", "hdpath", "hex", - "http", + "http 0.2.12", "humantime", "humantime-serde", "ibc-proto", "ibc-relayer-types", "ibc-telemetry", - "itertools 0.10.5", + "itertools", "moka", "num-bigint", "num-rational", @@ -1774,11 +1734,11 @@ dependencies = [ "tiny-keccak", "tokio", "tokio-stream", - "toml 0.8.8", + "toml 0.8.13", "tonic", "tracing", "tracing-subscriber", - "uuid 1.7.0", + "uuid", ] [[package]] @@ -1790,21 +1750,21 @@ dependencies = [ "clap_complete 3.2.5", "color-eyre", "console", - "crossbeam-channel 0.5.11", + "crossbeam-channel", "dialoguer", "dirs-next", "eyre", "flex-error", "futures", "hdpath", - "http", + "http 0.2.12", "humantime", "ibc-chain-registry", "ibc-relayer", "ibc-relayer-rest", "ibc-relayer-types", "ibc-telemetry", - "itertools 0.10.5", + "itertools", "oneline-eyre", "regex", "serde", @@ -1825,7 +1785,7 @@ name = "ibc-relayer-rest" version = "0.27.2" dependencies = [ "axum", - "crossbeam-channel 0.5.11", + "crossbeam-channel", "ibc-relayer", "ibc-relayer-types", "serde", @@ -1842,7 +1802,7 @@ dependencies = [ "flex-error", "ibc-proto", "ics23", - "itertools 0.10.5", + "itertools", "num-rational", "primitive-types", "prost", @@ -1855,6 +1815,7 @@ dependencies = [ "tendermint-light-client-verifier", "tendermint-proto", "time", + "tracing", "uint", ] @@ -1904,9 +1865,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1914,17 +1875,16 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata 0.4.6", "same-file", - "thread_local", "walkdir", "winapi-util", ] @@ -1956,12 +1916,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.5", ] [[package]] @@ -1970,7 +1930,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aa4a0980c8379295100d70854354e78df2ee1c6ca0f96ffe89afeb3140e3a3d" dependencies = [ - "base64", + "base64 0.21.7", "serde", ] @@ -1996,61 +1956,47 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" - -[[package]] -name = "is-terminal" -version = "0.4.9" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.3", - "rustix", - "windows-sys 0.48.0", -] +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] -name = "itertools" -version = "0.10.5" +name = "is_terminal_polyfill" +version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "ecdsa", "elliptic-curve", "sha2 0.10.8", @@ -2058,9 +2004,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] @@ -2093,21 +2039,41 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libdbus-sys" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" +dependencies = [ + "cc", + "pkg-config", +] + +[[package]] +name = "libredox" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -2115,9 +2081,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "mac" @@ -2133,9 +2099,9 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "markup5ever" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" +checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45" dependencies = [ "log", "phf", @@ -2160,25 +2126,19 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "mdbook" -version = "0.4.35" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c3f88addd34930bc5f01b9dc19f780447e51c92bf2536e3ded058018271775d" +checksum = "b45a38e19bd200220ef07c892b0157ad3d2365e5b5a267ca01ad12182491eea5" dependencies = [ "ammonia", "anyhow", "chrono", - "clap 4.4.6", - "clap_complete 4.4.3", + "clap 4.5.4", + "clap_complete 4.5.2", "elasticlunr-rs", - "env_logger 0.10.0", + "env_logger 0.11.3", "futures-util", "handlebars", "ignore", @@ -2188,6 +2148,7 @@ dependencies = [ "notify-debouncer-mini", "once_cell", "opener", + "pathdiff", "pulldown-cmark", "regex", "serde", @@ -2197,14 +2158,15 @@ dependencies = [ "tokio", "toml 0.5.11", "topological-sort", + "walkdir", "warp", ] [[package]] name = "mdbook-template" -version = "1.1.0" +version = "1.1.1+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "920f69694a682c1100d64ca342278fc289d7d89b905a60c39ca39e0ea04ce0f1" +checksum = "24ababe45effcc8453d4dc68de0d699d6858399b6f20ecfaf616a1ca2e0c6aa3" dependencies = [ "anyhow", "clap 3.2.25", @@ -2219,18 +2181,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mime" @@ -2250,18 +2203,18 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -2271,38 +2224,37 @@ dependencies = [ [[package]] name = "moka" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1911e88d5831f748a4097a43862d129e3c6fca831eecac9b8db6d01d93c9de2" +checksum = "9e0d88686dc561d743b40de8269b26eaf0dc58781bde087b0984646602021d08" dependencies = [ - "crossbeam-channel 0.5.11", + "crossbeam-channel", "crossbeam-epoch", - "crossbeam-utils 0.8.19", + "crossbeam-utils", "once_cell", "parking_lot", "quanta", "rustc_version", - "skeptic", "smallvec", "tagptr", "thiserror", "triomphe", - "uuid 1.7.0", + "uuid", ] [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "normpath" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec60c60a693226186f5d6edf073232bfb6464ed97eb22cf3b01c1e8198fd97f5" +checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2311,8 +2263,8 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.4.0", - "crossbeam-channel 0.5.11", + "bitflags 2.5.0", + "crossbeam-channel", "filetime", "fsevent-sys", "inotify", @@ -2326,11 +2278,12 @@ dependencies = [ [[package]] name = "notify-debouncer-mini" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55ee272914f4563a2f8b8553eb6811f3c0caea81c756346bad15b7e3ef969f0" +checksum = "5d40b221972a1fc5ef4d858a2f671fb34c75983eb385463dff3780eeff6a9d43" dependencies = [ - "crossbeam-channel 0.5.11", + "crossbeam-channel", + "log", "notify", ] @@ -2346,44 +2299,36 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", "serde", ] [[package]] -name = "num-derive" -version = "0.3.3" +name = "num-conv" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -2392,9 +2337,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -2405,15 +2350,15 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.9", "libc", ] [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -2435,19 +2380,20 @@ dependencies = [ [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "opener" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c62dcb6174f9cb326eac248f07e955d5d559c272730b6c03e396b443b562788" +checksum = "f8df34be653210fbe9ffaff41d3b92721c56ce82dfee58ee684f9afb5e3a90c0" dependencies = [ "bstr", + "dbus", "normpath", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -2500,7 +2446,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b3a2a91fdbfdd4d212c0dcc2ab540de2c2bcbbd90be17de7a7daf8822d010c1" dependencies = [ "async-trait", - "crossbeam-channel 0.5.11", + "crossbeam-channel", "dashmap", "fnv", "futures-channel", @@ -2515,9 +2461,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.5.1" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "overload" @@ -2533,9 +2479,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -2543,22 +2489,28 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pathdiff" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "pbkdf2" @@ -2571,9 +2523,9 @@ dependencies = [ [[package]] name = "peg" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166a" +checksum = "8a625d12ad770914cbf7eff6f9314c3ef803bfe364a1b20bc36ddf56673e71e5" dependencies = [ "peg-macros", "peg-runtime", @@ -2581,9 +2533,9 @@ dependencies = [ [[package]] name = "peg-macros" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c" +checksum = "f241d42067ed3ab6a4fece1db720838e1418f36d868585a27931f95d6bc03582" dependencies = [ "peg-runtime", "proc-macro2", @@ -2592,21 +2544,21 @@ dependencies = [ [[package]] name = "peg-runtime" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" +checksum = "e3aeb8f54c078314c2065ee649a7241f46b9d8e418e1a9581ba0546657d7aa3a" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.4" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -2615,9 +2567,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -2625,22 +2577,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -2649,21 +2601,21 @@ dependencies = [ [[package]] name = "phf" -version = "0.10.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ - "phf_shared", + "phf_shared 0.11.2", ] [[package]] name = "phf_codegen" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.11.2", + "phf_shared 0.11.2", ] [[package]] @@ -2672,7 +2624,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ - "phf_shared", + "phf_shared 0.10.0", + "rand", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", "rand", ] @@ -2685,31 +2647,40 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -2727,11 +2698,23 @@ dependencies = [ "spki", ] +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "platforms" -version = "3.1.2" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" + +[[package]] +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" @@ -2747,9 +2730,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-serde", @@ -2782,20 +2765,20 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" dependencies = [ "unicode-ident", ] [[package]] name = "prometheus" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" +checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fnv", "lazy_static", "memchr", @@ -2806,9 +2789,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -2816,22 +2799,22 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "prost-types" -version = "0.12.1" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ "prost", ] @@ -2844,22 +2827,29 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "pulldown-cmark" -version = "0.9.3" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "memchr", + "pulldown-cmark-escape", "unicase", ] +[[package]] +name = "pulldown-cmark-escape" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3" + [[package]] name = "quanta" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca0b7bac0b97248c40bb77288fc52029cf1459c0461ea1b05ee32ccf011de2c" +checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" dependencies = [ - "crossbeam-utils 0.8.19", + "crossbeam-utils", "libc", "once_cell", "raw-cpuid", @@ -2870,9 +2860,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2909,52 +2899,52 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.0.1" +version = "11.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" +checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.5.0", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", - "redox_syscall 0.2.16", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.9.6" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.9", - "regex-syntax 0.7.5", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", ] [[package]] @@ -2968,13 +2958,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.3", ] [[package]] @@ -2985,23 +2975,23 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-rustls", @@ -3012,15 +3002,16 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", - "rustls-native-certs", - "rustls-pemfile", + "rustls 0.21.12", + "rustls-native-certs 0.6.3", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tower-service", "url", "wasm-bindgen", @@ -3047,17 +3038,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.20" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", + "getrandom", "libc", - "once_cell", "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -3071,9 +3062,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -3092,29 +3083,43 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.17" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.4", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3122,41 +3127,81 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.2", + "rustls-pki-types", "schannel", "security-framework", ] [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64", + "base64 0.22.1", + "rustls-pki-types", ] +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ "ring", "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -3169,11 +3214,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3190,9 +3235,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -3245,11 +3290,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -3258,9 +3303,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -3268,27 +3313,27 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.197" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.12" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" dependencies = [ "serde", ] @@ -3305,20 +3350,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -3327,9 +3372,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ "itoa", "serde", @@ -3337,20 +3382,20 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -3373,7 +3418,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.10.7", ] @@ -3385,7 +3430,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.9.0", "opaque-debug", @@ -3397,7 +3442,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.10.7", ] @@ -3429,9 +3474,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shlex" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook" @@ -3445,18 +3490,18 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", "rand_core", @@ -3468,21 +3513,6 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" -[[package]] -name = "skeptic" -version = "0.13.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8" -dependencies = [ - "bytecount", - "cargo_metadata", - "error-chain", - "glob", - "pulldown-cmark", - "tempfile", - "walkdir", -] - [[package]] name = "slab" version = "0.4.9" @@ -3494,41 +3524,31 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" - -[[package]] -name = "socket2" -version = "0.4.9" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "spin" -version = "0.5.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", @@ -3549,7 +3569,7 @@ dependencies = [ "new_debug_unreachable", "once_cell", "parking_lot", - "phf_shared", + "phf_shared 0.10.0", "precomputed-hash", "serde", ] @@ -3560,8 +3580,8 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.10.0", + "phf_shared 0.10.0", "proc-macro2", "quote", ] @@ -3572,6 +3592,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "strum" version = "0.25.0" @@ -3583,15 +3609,15 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] @@ -3628,9 +3654,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" dependencies = [ "proc-macro2", "quote", @@ -3684,22 +3710,21 @@ checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fastrand", - "redox_syscall 0.3.5", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tendermint" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc2294fa667c8b548ee27a9ba59115472d0a09c2ba255771092a7f1dcf03a789" +checksum = "8b50aae6ec24c3429149ad59b5b8d3374d7804d4c7d6125ceb97cb53907fb68d" dependencies = [ "bytes", "digest 0.10.7", @@ -3728,26 +3753,26 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a25dbe8b953e80f3d61789fbdb83bf9ad6c0ef16df5ca6546f49912542cc137" +checksum = "e07b383dc8780ebbec04cfb603f3fdaba6ea6663d8dd861425b1ffa7761fe90d" dependencies = [ "flex-error", "serde", "serde_json", "tendermint", - "toml 0.5.11", + "toml 0.8.13", "url", ] [[package]] name = "tendermint-light-client" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94aecbdccbc4b557649b2d1b1a4bfc27ec85205e00fb8020fce044245a4c9e3f" +checksum = "331544139bbcf353acb5f56e733093d8e4bf2522cda0491b4bba7039ef0b944e" dependencies = [ "contracts", - "crossbeam-channel 0.4.4", + "crossbeam-channel", "derive_more", "flex-error", "futures", @@ -3767,12 +3792,11 @@ dependencies = [ [[package]] name = "tendermint-light-client-detector" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea83654b03e3ddc6782c9704a3fefd4d0671bd6c5e3f09d29e31fcb45e75636c" +checksum = "73d0ffaf614bd2db605c4762e3a31a536b73cd45488fa5bace050135ca348f28" dependencies = [ - "contracts", - "crossbeam-channel 0.4.4", + "crossbeam-channel", "derive_more", "flex-error", "futures", @@ -3791,9 +3815,9 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74994da9de4b1144837a367ca2c60c650f5526a7c1a54760a3020959b522e474" +checksum = "4216e487165e5dbd7af79952eaa0d5f06c5bde861eb76c690acd7f2d2a19395c" dependencies = [ "derive_more", "flex-error", @@ -3804,14 +3828,12 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.34.1" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b797dd3d2beaaee91d2f065e7bdf239dc8d80bba4a183a288bc1279dd5a69a1e" +checksum = "46f193d04afde6592c20fd70788a10b8cb3823091c07456db70d8a93f5fb99c1" dependencies = [ "bytes", "flex-error", - "num-derive", - "num-traits", "prost", "prost-types", "serde", @@ -3822,9 +3844,9 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbf0a4753b46a190f367337e0163d0b552a2674a6bac54e74f9f2cdcde2969b" +checksum = "21e3c231a3632cab53f92ad4161c730c468c08cfe4f0aa5a6735b53b390aecbd" dependencies = [ "async-trait", "async-tungstenite", @@ -3834,6 +3856,7 @@ dependencies = [ "getrandom", "peg", "pin-project", + "rand", "reqwest", "semver", "serde", @@ -3849,7 +3872,7 @@ dependencies = [ "tokio", "tracing", "url", - "uuid 0.8.2", + "uuid", "walkdir", ] @@ -3866,9 +3889,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -3885,47 +3908,49 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", ] [[package]] name = "time" -version = "0.3.29" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -3939,10 +3964,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -3991,9 +4017,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -4003,7 +4029,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.4", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -4020,13 +4046,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] @@ -4035,15 +4061,26 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.12", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.4", + "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -4052,9 +4089,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", @@ -4064,16 +4101,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -4087,9 +4123,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.8" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" dependencies = [ "serde", "serde_spanned", @@ -4099,20 +4135,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -4121,28 +4157,28 @@ dependencies = [ [[package]] name = "tonic" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ "async-stream", "async-trait", "axum", - "base64", + "base64 0.21.7", "bytes", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-timeout", "percent-encoding", "pin-project", "prost", - "rustls", - "rustls-native-certs", - "rustls-pemfile", + "rustls-native-certs 0.7.0", + "rustls-pemfile 2.1.2", + "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "tokio-stream", "tower", "tower-layer", @@ -4190,11 +4226,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if 1.0.0", "log", "pin-project-lite", "tracing-attributes", @@ -4203,20 +4238,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -4234,12 +4269,23 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -4255,9 +4301,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -4270,36 +4316,37 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.2.0", "tracing-serde", ] [[package]] name = "triomphe" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 1.1.0", "httparse", "log", "rand", - "rustls", + "rustls 0.22.4", + "rustls-pki-types", "sha1", "thiserror", "url", @@ -4341,9 +4388,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -4353,18 +4400,18 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -4374,15 +4421,15 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -4403,9 +4450,9 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "utf8-width" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" [[package]] name = "utf8parse" @@ -4415,15 +4462,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" - -[[package]] -name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom", ] @@ -4451,9 +4492,9 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -4470,28 +4511,26 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" +checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c" dependencies = [ "bytes", "futures-channel", "futures-util", "headers", - "http", + "http 0.2.12", "hyper", "log", "mime", "mime_guess", "percent-encoding", "pin-project", - "rustls-pemfile", "scoped-tls", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-stream", "tokio-tungstenite", "tokio-util", "tower-service", @@ -4506,36 +4545,36 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "wasm-bindgen", "web-sys", @@ -4543,9 +4582,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4553,28 +4592,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -4598,11 +4637,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -4612,21 +4651,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.52.5", ] [[package]] @@ -4639,18 +4669,12 @@ dependencies = [ ] [[package]] -name = "windows-targets" -version = "0.42.2" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.52.5", ] [[package]] @@ -4669,10 +4693,20 @@ dependencies = [ ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" +name = "windows-targets" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] [[package]] name = "windows_aarch64_gnullvm" @@ -4681,10 +4715,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" +name = "windows_aarch64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -4693,10 +4727,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] -name = "windows_i686_gnu" -version = "0.42.2" +name = "windows_aarch64_msvc" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -4705,10 +4739,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] -name = "windows_i686_msvc" -version = "0.42.2" +name = "windows_i686_gnu" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -4717,10 +4757,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" +name = "windows_i686_msvc" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -4729,10 +4769,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" +name = "windows_x86_64_gnu" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -4741,10 +4781,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" +name = "windows_x86_64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -4752,11 +4792,17 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + [[package]] name = "winnow" -version = "0.5.15" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr", ] @@ -4767,15 +4813,15 @@ version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "windows-sys 0.48.0", ] [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -4788,5 +4834,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.65", ] diff --git a/tools/check-guide/Cargo.toml b/tools/check-guide/Cargo.toml index 6bc6b19ee1..e5a77be25f 100644 --- a/tools/check-guide/Cargo.toml +++ b/tools/check-guide/Cargo.toml @@ -11,7 +11,3 @@ lazy_static = "1.4.0" mdbook-template = "1.1.0" regex = "1" walkdir = "2.3.3" - -# TODO remove once simapp v8 is released -[patch.crates-io] -ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "romac/channel-upgrade-only" } \ No newline at end of file From 8ff6cb31f37fbcc5e0f071ef24e97ea2715421af Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Mon, 27 May 2024 12:28:21 +0200 Subject: [PATCH 93/99] Apply suggestions from code review Co-authored-by: Romain Ruetschi Signed-off-by: Luca Joss <43531661+ljoss17@users.noreply.github.com> --- crates/relayer-types/src/applications/ics27_ica/error.rs | 2 +- crates/relayer-types/src/core/ics04_channel/channel.rs | 1 - crates/relayer/src/channel.rs | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/relayer-types/src/applications/ics27_ica/error.rs b/crates/relayer-types/src/applications/ics27_ica/error.rs index 878b1ab1f0..263f090fe1 100644 --- a/crates/relayer-types/src/applications/ics27_ica/error.rs +++ b/crates/relayer-types/src/applications/ics27_ica/error.rs @@ -9,7 +9,7 @@ define_error! { Error { Ics04Channel [ channel_error::Error ] - | _ | { "ics04 channel error" }, + | _ | { "ICS 04 channel error" }, Owner [ SignerError ] diff --git a/crates/relayer-types/src/core/ics04_channel/channel.rs b/crates/relayer-types/src/core/ics04_channel/channel.rs index c61037b31f..722ed1f8cd 100644 --- a/crates/relayer-types/src/core/ics04_channel/channel.rs +++ b/crates/relayer-types/src/core/ics04_channel/channel.rs @@ -246,7 +246,6 @@ impl ChannelEnd { self.ordering() == other } - #[allow(clippy::ptr_arg)] pub fn connection_hops_matches(&self, other: &Vec) -> bool { self.connection_hops() == other } diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 578ff4ddde..65e674ea23 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1677,8 +1677,7 @@ impl Channel { )); } - if channel_end.state != State::Open(UpgradeState::NotUpgrading) - && channel_end.state != State::Open(UpgradeState::Upgrading) + if !matches!(channel_end.state, State::Open(_)) { return Err(ChannelError::invalid_channel_upgrade_state( State::Open(UpgradeState::NotUpgrading).to_string(), From 918cf47be002961bbfbfc462d067c81141bfa36b Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 27 May 2024 12:59:01 +0200 Subject: [PATCH 94/99] cargo fmt --- crates/relayer/src/channel.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 65e674ea23..ac7660653a 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1677,8 +1677,7 @@ impl Channel { )); } - if !matches!(channel_end.state, State::Open(_)) - { + if !matches!(channel_end.state, State::Open(_)) { return Err(ChannelError::invalid_channel_upgrade_state( State::Open(UpgradeState::NotUpgrading).to_string(), channel_end.state.to_string(), From a97766fd44742da1b13124d853cb4d019b551b5a Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 27 May 2024 13:04:48 +0200 Subject: [PATCH 95/99] Fix codespell errors --- Cargo.lock | 8 ++++---- crates/relayer/src/chain/cosmos/config.rs | 2 +- docs/architecture/adr-005-relayer-v0-implementation.md | 2 +- docs/spec/relayer/Definitions.md | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b36b1e200..a84b9b0fed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2762,9 +2762,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.201" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -2790,9 +2790,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", diff --git a/crates/relayer/src/chain/cosmos/config.rs b/crates/relayer/src/chain/cosmos/config.rs index dab51398e6..5e85f2a11d 100644 --- a/crates/relayer/src/chain/cosmos/config.rs +++ b/crates/relayer/src/chain/cosmos/config.rs @@ -56,7 +56,7 @@ pub struct CosmosSdkConfig { pub max_gas: Option, // This field is only meant to be set via the `update client` command, - // for when we need to ugprade a client across a genesis restart and + // for when we need to upgrade a client across a genesis restart and // therefore need and archive node to fetch blocks from. pub genesis_restart: Option, diff --git a/docs/architecture/adr-005-relayer-v0-implementation.md b/docs/architecture/adr-005-relayer-v0-implementation.md index bc35c3e1f0..78d381ba7b 100644 --- a/docs/architecture/adr-005-relayer-v0-implementation.md +++ b/docs/architecture/adr-005-relayer-v0-implementation.md @@ -221,7 +221,7 @@ Accepted [comment](https://github.com/informalsystems/hermes/pull/449#issuecomment-750248113) provides additional insights into development-time relayer `v0.1` environment. -- __Mock__: Has been removed after splittin the ibc-rs repository +- __Mock__: Has been removed after splitting the ibc-rs repository diff --git a/docs/spec/relayer/Definitions.md b/docs/spec/relayer/Definitions.md index 5d8830a717..ce3ad90b2f 100644 --- a/docs/spec/relayer/Definitions.md +++ b/docs/spec/relayer/Definitions.md @@ -224,7 +224,7 @@ CreateUpdateClientDatagrams(shs []SignedHeader) IBCDatagram[] // Submit given datagram to a given chain Submit(chain Chain, datagram IBCDatagram) Error -// Return the correspondin chain for a given chainID +// Return the corresponding chain for a given chainID // We assume that the relayer maintains a map of known chainIDs and the corresponding chains. GetChain(chainID String) Chain ``` From f26c2756e46b1494e7f975b8b1b6fc89e81f8540 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 29 May 2024 08:30:47 +0200 Subject: [PATCH 96/99] Use IncludeProof for query_upgrade and query_upgrade_error --- crates/relayer/src/chain/cosmos.rs | 23 +++++++++++++++++---- crates/relayer/src/chain/endpoint.rs | 2 ++ crates/relayer/src/chain/handle.rs | 4 ++++ crates/relayer/src/chain/handle/base.rs | 4 ++++ crates/relayer/src/chain/handle/cache.rs | 7 +++++-- crates/relayer/src/chain/handle/counting.rs | 7 +++++-- crates/relayer/src/chain/runtime.rs | 16 ++++++++------ crates/relayer/src/channel.rs | 6 ++++++ tools/test-framework/src/relayer/chain.rs | 7 +++++-- 9 files changed, 60 insertions(+), 16 deletions(-) diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index e8f07d15e2..09cd731b77 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -1697,6 +1697,7 @@ impl ChainEndpoint for CosmosSdkChain { channel_id: channel.channel_id.to_string(), }, height, + IncludeProof::No, ) .is_ok() { @@ -1768,6 +1769,7 @@ impl ChainEndpoint for CosmosSdkChain { channel_id: channel.channel_id.to_string(), }, height, + IncludeProof::No, ) .is_ok() { @@ -1815,6 +1817,7 @@ impl ChainEndpoint for CosmosSdkChain { channel_id: request.channel_id.to_string(), }, height, + IncludeProof::No, ) .is_ok() { @@ -2452,6 +2455,7 @@ impl ChainEndpoint for CosmosSdkChain { &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(Upgrade, Option), Error> { let port_id = PortId::from_str(&request.port_id) .map_err(|_| Error::invalid_port_string(request.port_id))?; @@ -2465,16 +2469,22 @@ impl ChainEndpoint for CosmosSdkChain { QueryHeight::Specific(height), true, )?; - let proof = res.proof.ok_or_else(Error::empty_response_proof)?; let upgrade = Upgrade::decode_vec(&res.value).map_err(Error::decode)?; - Ok((upgrade, Some(proof))) + match include_proof { + IncludeProof::Yes => { + let proof = res.proof.ok_or_else(Error::empty_response_proof)?; + Ok((upgrade, Some(proof))) + } + IncludeProof::No => Ok((upgrade, None)), + } } fn query_upgrade_error( &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(ErrorReceipt, Option), Error> { let port_id = PortId::from_str(&request.port_id) .map_err(|_| Error::invalid_port_string(request.port_id))?; @@ -2488,10 +2498,15 @@ impl ChainEndpoint for CosmosSdkChain { QueryHeight::Specific(height), true, )?; - let proof = res.proof.ok_or_else(Error::empty_response_proof)?; let error_receipt = ErrorReceipt::decode_vec(&res.value).map_err(Error::decode)?; - Ok((error_receipt, Some(proof))) + match include_proof { + IncludeProof::Yes => { + let proof = res.proof.ok_or_else(Error::empty_response_proof)?; + Ok((error_receipt, Some(proof))) + } + IncludeProof::No => Ok((error_receipt, None)), + } } } diff --git a/crates/relayer/src/chain/endpoint.rs b/crates/relayer/src/chain/endpoint.rs index a871bbdb4b..0a12e73341 100644 --- a/crates/relayer/src/chain/endpoint.rs +++ b/crates/relayer/src/chain/endpoint.rs @@ -694,11 +694,13 @@ pub trait ChainEndpoint: Sized { &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(Upgrade, Option), Error>; fn query_upgrade_error( &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(ErrorReceipt, Option), Error>; } diff --git a/crates/relayer/src/chain/handle.rs b/crates/relayer/src/chain/handle.rs index 2f3ec0170e..2137821e61 100644 --- a/crates/relayer/src/chain/handle.rs +++ b/crates/relayer/src/chain/handle.rs @@ -377,12 +377,14 @@ pub enum ChainRequest { QueryUpgrade { request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, reply_to: ReplyTo<(Upgrade, Option)>, }, QueryUpgradeError { request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, reply_to: ReplyTo<(ErrorReceipt, Option)>, }, } @@ -703,11 +705,13 @@ pub trait ChainHandle: Clone + Display + Send + Sync + Debug + 'static { &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(Upgrade, Option), Error>; fn query_upgrade_error( &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(ErrorReceipt, Option), Error>; } diff --git a/crates/relayer/src/chain/handle/base.rs b/crates/relayer/src/chain/handle/base.rs index 4c612212f4..0898269281 100644 --- a/crates/relayer/src/chain/handle/base.rs +++ b/crates/relayer/src/chain/handle/base.rs @@ -530,10 +530,12 @@ impl ChainHandle for BaseChainHandle { &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(Upgrade, Option), Error> { self.send(|reply_to| ChainRequest::QueryUpgrade { request, height, + include_proof, reply_to, }) } @@ -542,10 +544,12 @@ impl ChainHandle for BaseChainHandle { &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(ErrorReceipt, Option), Error> { self.send(|reply_to| ChainRequest::QueryUpgradeError { request, height, + include_proof, reply_to, }) } diff --git a/crates/relayer/src/chain/handle/cache.rs b/crates/relayer/src/chain/handle/cache.rs index 26fa5636fa..6a1731f903 100644 --- a/crates/relayer/src/chain/handle/cache.rs +++ b/crates/relayer/src/chain/handle/cache.rs @@ -523,15 +523,18 @@ impl ChainHandle for CachingChainHandle { &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(Upgrade, Option), Error> { - self.inner.query_upgrade(request, height) + self.inner.query_upgrade(request, height, include_proof) } fn query_upgrade_error( &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(ErrorReceipt, Option), Error> { - self.inner.query_upgrade_error(request, height) + self.inner + .query_upgrade_error(request, height, include_proof) } } diff --git a/crates/relayer/src/chain/handle/counting.rs b/crates/relayer/src/chain/handle/counting.rs index 053d289ef8..1096e1b0bf 100644 --- a/crates/relayer/src/chain/handle/counting.rs +++ b/crates/relayer/src/chain/handle/counting.rs @@ -516,17 +516,20 @@ impl ChainHandle for CountingChainHandle { &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(Upgrade, Option), Error> { self.inc_metric("query_upgrade"); - self.inner.query_upgrade(request, height) + self.inner.query_upgrade(request, height, include_proof) } fn query_upgrade_error( &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(ErrorReceipt, Option), Error> { self.inc_metric("query_upgrade_error"); - self.inner.query_upgrade_error(request, height) + self.inner + .query_upgrade_error(request, height, include_proof) } } diff --git a/crates/relayer/src/chain/runtime.rs b/crates/relayer/src/chain/runtime.rs index 83817f7f5c..1422f386b3 100644 --- a/crates/relayer/src/chain/runtime.rs +++ b/crates/relayer/src/chain/runtime.rs @@ -356,12 +356,12 @@ where self.query_consumer_chains(reply_to)? }, - ChainRequest::QueryUpgrade { request, height, reply_to } => { - self.query_upgrade(request, height, reply_to)? + ChainRequest::QueryUpgrade { request, height, include_proof, reply_to } => { + self.query_upgrade(request, height, include_proof, reply_to)? }, - ChainRequest::QueryUpgradeError { request, height, reply_to } => { - self.query_upgrade_error(request, height, reply_to)? + ChainRequest::QueryUpgradeError { request, height, include_proof, reply_to } => { + self.query_upgrade_error(request, height, include_proof, reply_to)? }, } }, @@ -879,9 +879,10 @@ where &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, reply_to: ReplyTo<(Upgrade, Option)>, ) -> Result<(), Error> { - let result = self.chain.query_upgrade(request, height); + let result = self.chain.query_upgrade(request, height, include_proof); reply_to.send(result).map_err(Error::send)?; Ok(()) @@ -891,9 +892,12 @@ where &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, reply_to: ReplyTo<(ErrorReceipt, Option)>, ) -> Result<(), Error> { - let result = self.chain.query_upgrade_error(request, height); + let result = self + .chain + .query_upgrade_error(request, height, include_proof); reply_to.send(result).map_err(Error::send)?; Ok(()) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index ac7660653a..b68781b75b 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -827,6 +827,7 @@ impl Channel { channel_id: self.b_side.channel_id.clone().unwrap().clone().to_string(), }, height, + IncludeProof::No, ) .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof()); @@ -853,6 +854,7 @@ impl Channel { channel_id: self.a_side.channel_id.clone().unwrap().clone().to_string(), }, height, + IncludeProof::No, ) .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof()); @@ -1643,6 +1645,7 @@ impl Channel { channel_id: src_channel_id.to_string(), }, src_latest_height, + IncludeProof::Yes, ) .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; @@ -1778,6 +1781,7 @@ impl Channel { channel_id: src_channel_id.to_string(), }, src_latest_height, + IncludeProof::Yes, ) .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; @@ -1902,6 +1906,7 @@ impl Channel { channel_id: src_channel_id.to_string(), }, src_latest_height, + IncludeProof::Yes, ) .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; @@ -2110,6 +2115,7 @@ impl Channel { channel_id: src_channel_id.to_string(), }, src_latest_height, + IncludeProof::Yes, ) .map_err(|e| ChannelError::chain_query(self.src_chain().id(), e))?; diff --git a/tools/test-framework/src/relayer/chain.rs b/tools/test-framework/src/relayer/chain.rs index 9178fce0a1..7c68839d30 100644 --- a/tools/test-framework/src/relayer/chain.rs +++ b/tools/test-framework/src/relayer/chain.rs @@ -442,15 +442,18 @@ where &self, request: QueryUpgradeRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(Upgrade, Option), Error> { - self.value().query_upgrade(request, height) + self.value().query_upgrade(request, height, include_proof) } fn query_upgrade_error( &self, request: QueryUpgradeErrorRequest, height: Height, + include_proof: IncludeProof, ) -> Result<(ErrorReceipt, Option), Error> { - self.value().query_upgrade_error(request, height) + self.value() + .query_upgrade_error(request, height, include_proof) } } From f4e8310052b7e7a7ac8d67b09660586e6e328932 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 29 May 2024 09:35:24 +0200 Subject: [PATCH 97/99] Add a method to build and send channel upgrade open or cancel --- crates/relayer/src/channel.rs | 90 ++++++++++++++--------------------- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index b68781b75b..9fd5da8cd3 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -816,61 +816,11 @@ impl Channel { (State::FlushComplete, State::FlushComplete) => { Some(self.build_chan_upgrade_open_and_send()?) } - (State::FlushComplete, State::Open(UpgradeState::NotUpgrading)) => { - // Check if error - let height = self.b_chain().query_latest_height().unwrap(); - let upgrade_error = self - .b_chain() - .query_upgrade_error( - QueryUpgradeErrorRequest { - port_id: self.b_side.port_id.clone().to_string(), - channel_id: self.b_side.channel_id.clone().unwrap().clone().to_string(), - }, - height, - IncludeProof::No, - ) - .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof()); - - let channel_end = self.a_channel(self.a_channel_id())?; - - if let Ok((upgrade_error, _)) = upgrade_error { - if upgrade_error.sequence == channel_end.upgrade_sequence { - Some(self.flipped().build_chan_upgrade_cancel_and_send()?) - } else { - Some(self.flipped().build_chan_upgrade_open_and_send()?) - } - } else { - Some(self.flipped().build_chan_upgrade_open_and_send()?) - } - } + (State::FlushComplete, State::Open(UpgradeState::NotUpgrading)) => self + .flipped() + .build_chan_upgrade_open_or_cancel_and_send()?, (State::Open(UpgradeState::NotUpgrading), State::FlushComplete) => { - // Check if error query_upgrade_error - let height = self.a_chain().query_latest_height().unwrap(); - let upgrade_error = self - .a_chain() - .query_upgrade_error( - QueryUpgradeErrorRequest { - port_id: self.a_side.port_id.clone().to_string(), - channel_id: self.a_side.channel_id.clone().unwrap().clone().to_string(), - }, - height, - IncludeProof::No, - ) - .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof()); - - let channel_end = self.b_channel(self.b_channel_id())?; - - if let Ok((upgrade_error, _)) = upgrade_error { - if upgrade_error.sequence > 0.into() - && upgrade_error.sequence == channel_end.upgrade_sequence - { - Some(self.build_chan_upgrade_cancel_and_send()?) - } else { - Some(self.build_chan_upgrade_open_and_send()?) - } - } else { - Some(self.build_chan_upgrade_open_and_send()?) - } + self.build_chan_upgrade_open_or_cancel_and_send()? } _ => None, @@ -2297,6 +2247,38 @@ impl Channel { connection_delay: self.connection_delay, } } + + pub fn build_chan_upgrade_open_or_cancel_and_send( + &self, + ) -> Result, ChannelError> { + // Check if error query_upgrade_error + let height = self.a_chain().query_latest_height().unwrap(); + let upgrade_error = self + .a_chain() + .query_upgrade_error( + QueryUpgradeErrorRequest { + port_id: self.a_side.port_id.clone().to_string(), + channel_id: self.a_side.channel_id.clone().unwrap().clone().to_string(), + }, + height, + IncludeProof::No, + ) + .map_err(|_| ChannelError::missing_upgrade_error_receipt_proof()); + + let channel_end = self.b_channel(self.b_channel_id())?; + + if let Ok((upgrade_error, _)) = upgrade_error { + if upgrade_error.sequence > 0.into() + && upgrade_error.sequence == channel_end.upgrade_sequence + { + Ok(Some(self.build_chan_upgrade_cancel_and_send()?)) + } else { + Ok(Some(self.build_chan_upgrade_open_and_send()?)) + } + } else { + Ok(Some(self.build_chan_upgrade_open_and_send()?)) + } + } } pub fn extract_channel_id(event: &IbcEvent) -> Result<&ChannelId, ChannelError> { From 7c56bc2b58f46b77979c9b96707a498a6218aa8f Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 29 May 2024 15:06:23 +0200 Subject: [PATCH 98/99] Remove unnecessary assertions --- crates/relayer/src/channel.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index 9fd5da8cd3..eb9a5a70a6 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -1604,32 +1604,6 @@ impl Channel { let proof_upgrade = CommitmentProofBytes::try_from(upgrade_proof).map_err(ChannelError::malformed_proof)?; - // TODO: Is this check necessary? - if channel_end.counterparty().port_id() != self.dst_port_id() { - return Err(ChannelError::mismatch_port( - self.dst_chain().id(), - self.dst_port_id().clone(), - self.src_chain().id(), - self.src_port_id().clone(), - src_channel_id.clone(), - )); - } - - let counterparty_ordering = channel_end.ordering(); - - // We're assuming here that so long as the orderings match between the - // two channel ends, that the ordering on this channel end is valid - // as far as going from a stricter order to a less strict ordering - // So we aren't explicitly checking for that here like we did in the - // build_chan_upgrade_init function - // TODO: Make sure this assumption is correct - if *counterparty_ordering != self.ordering { - return Err(ChannelError::invalid_ordering( - self.ordering, - *counterparty_ordering, - )); - } - if !matches!(channel_end.state, State::Open(_)) { return Err(ChannelError::invalid_channel_upgrade_state( State::Open(UpgradeState::NotUpgrading).to_string(), From c74f9e57e7650a6d65d044bd155e76bea1a76668 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 29 May 2024 15:07:29 +0200 Subject: [PATCH 99/99] Add handling of channel upgrade timeout event in channel worker --- crates/relayer/src/worker/channel.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/relayer/src/worker/channel.rs b/crates/relayer/src/worker/channel.rs index 76c5eb361e..5c722cb262 100644 --- a/crates/relayer/src/worker/channel.rs +++ b/crates/relayer/src/worker/channel.rs @@ -58,7 +58,8 @@ pub fn spawn_channel_worker( | IbcEventType::UpgradeTryChannel | IbcEventType::UpgradeAckChannel | IbcEventType::UpgradeConfirmChannel - | IbcEventType::UpgradeOpenChannel => retry_with_index( + | IbcEventType::UpgradeOpenChannel + | IbcEventType::UpgradeTimeoutChannel => retry_with_index( channel_handshake_retry::default_strategy(max_block_times), |index| match RelayChannel::restore_from_state( chains.a.clone(),