From 8c179d3d48addc6d1d805dd71c0aa0bf30230ef0 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 May 2024 11:12:32 +0200 Subject: [PATCH 01/21] Use patched ibc-proto-rs for ICS20 v2 protos --- Cargo.lock | 3 +-- Cargo.toml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c0b3b5613..8447bd9e51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1410,8 +1410,7 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66080040d5a4800d52966d55b055400f86b79c34b854b935bef03c87aacda62a" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=luca_joss/update-ibc-go-commit#4c4e09551fccc9b5121fad5aec8b1cc6416cf0c7" dependencies = [ "base64 0.22.0", "bytes", diff --git a/Cargo.toml b/Cargo.toml index f2dd104e12..48d17541fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,6 +121,7 @@ uuid = "1.8.0" overflow-checks = true [patch.crates-io] +ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "luca_joss/update-ibc-go-commit" } # 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" } From 15b75ed5a34297e98e5cfaf7b2b02603a0543366 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 May 2024 11:12:53 +0200 Subject: [PATCH 02/21] Update channel version handling and add ICS20 v2 compatibility --- .../src/applications/transfer/error.rs | 9 --- .../src/applications/transfer/mod.rs | 2 +- .../applications/transfer/msgs/transfer.rs | 81 ++----------------- .../src/applications/transfer/packet.rs | 59 ++++++++++++++ .../src/core/ics04_channel/version.rs | 16 ++-- crates/relayer/src/channel/version.rs | 2 +- crates/relayer/src/link/relay_path.rs | 34 +++++++- crates/relayer/src/transfer.rs | 37 ++++++++- 8 files changed, 142 insertions(+), 98 deletions(-) diff --git a/crates/relayer-types/src/applications/transfer/error.rs b/crates/relayer-types/src/applications/transfer/error.rs index f0e52d946d..3bf31bb0e0 100644 --- a/crates/relayer-types/src/applications/transfer/error.rs +++ b/crates/relayer-types/src/applications/transfer/error.rs @@ -9,7 +9,6 @@ use uint::FromDecStrErr; use crate::core::ics04_channel::channel::Ordering; use crate::core::ics04_channel::error as channel_error; -use crate::core::ics04_channel::version::Version; use crate::core::ics24_host::error::ValidationError; use crate::core::ics24_host::identifier::{ChannelId, PortId}; use crate::signer::SignerError; @@ -93,14 +92,6 @@ define_error! { { order: Ordering } | e | { format_args!("expected '{0}' channel, got '{1}'", Ordering::Unordered, e.order) }, - InvalidVersion - { version: Version } - | e | { format_args!("expected version '{0}', got '{1}'", Version::ics20(), e.version) }, - - InvalidCounterpartyVersion - { version: Version } - | e | { format_args!("expected counterparty version '{0}', got '{1}'", Version::ics20(), e.version) }, - CantCloseChannel | _ | { "channel cannot be closed" }, diff --git a/crates/relayer-types/src/applications/transfer/mod.rs b/crates/relayer-types/src/applications/transfer/mod.rs index fd405000eb..617d9fd63c 100644 --- a/crates/relayer-types/src/applications/transfer/mod.rs +++ b/crates/relayer-types/src/applications/transfer/mod.rs @@ -23,4 +23,4 @@ pub const MODULE_ID_STR: &str = "transfer"; pub const PORT_ID_STR: &str = "transfer"; /// ICS20 application current version. -pub const VERSION: &str = "ics20-1"; +pub const VERSION: &str = "ics20"; diff --git a/crates/relayer-types/src/applications/transfer/msgs/transfer.rs b/crates/relayer-types/src/applications/transfer/msgs/transfer.rs index 8bfc198b44..3695b90a3f 100644 --- a/crates/relayer-types/src/applications/transfer/msgs/transfer.rs +++ b/crates/relayer-types/src/applications/transfer/msgs/transfer.rs @@ -28,7 +28,7 @@ pub struct MsgTransfer { /// the channel by which the packet will be sent pub source_channel: ChannelId, /// the tokens to be transferred - pub token: C, + pub token: Option, /// the sender address pub sender: Signer, /// the recipient address on the destination chain @@ -41,6 +41,7 @@ pub struct MsgTransfer { pub timeout_timestamp: Timestamp, /// optional memo pub memo: Option, + pub tokens: Vec, } impl Msg for MsgTransfer { @@ -78,12 +79,13 @@ impl TryFrom for MsgTransfer { .source_channel .parse() .map_err(|e| Error::invalid_channel_id(raw_msg.source_channel.clone(), e))?, - token: raw_msg.token.ok_or_else(Error::invalid_token)?, + token: raw_msg.token, sender: raw_msg.sender.parse().map_err(Error::signer)?, receiver: raw_msg.receiver.parse().map_err(Error::signer)?, timeout_height, timeout_timestamp, memo, + tokens: raw_msg.tokens, }) } } @@ -95,12 +97,13 @@ impl From for RawMsgTransfer { RawMsgTransfer { source_port: domain_msg.source_port.to_string(), source_channel: domain_msg.source_channel.to_string(), - token: Some(domain_msg.token), + token: domain_msg.token, sender: domain_msg.sender.to_string(), receiver: domain_msg.receiver.to_string(), timeout_height: domain_msg.timeout_height.into(), timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(), memo, + tokens: domain_msg.tokens, } } } @@ -126,75 +129,3 @@ impl From for Any { } } } - -#[cfg(test)] -pub mod test_util { - use core::ops::Add; - use core::time::Duration; - - use super::MsgTransfer; - use crate::applications::transfer::packet::PacketData; - use crate::applications::transfer::Coin; - use crate::bigint::U256; - use crate::core::ics04_channel::packet::{Packet, Sequence}; - use crate::core::ics04_channel::timeout::TimeoutHeight; - use crate::signer::Signer; - use crate::{ - applications::transfer::{BaseCoin, PrefixedCoin}, - core::ics24_host::identifier::{ChannelId, PortId}, - test_utils::get_dummy_bech32_account, - timestamp::Timestamp, - }; - - // Returns a dummy ICS20 `MsgTransfer`. If no `timeout_timestamp` is - // specified, a timestamp of 10 seconds in the future is used. - pub fn get_dummy_msg_transfer( - timeout_height: TimeoutHeight, - timeout_timestamp: Option, - ) -> MsgTransfer { - let address: Signer = get_dummy_bech32_account().as_str().parse().unwrap(); - MsgTransfer { - source_port: PortId::default(), - source_channel: ChannelId::default(), - token: BaseCoin { - denom: "uatom".parse().unwrap(), - amount: U256::from(10).into(), - } - .into(), - sender: address.clone(), - receiver: address, - timeout_timestamp: timeout_timestamp - .unwrap_or_else(|| Timestamp::now().add(Duration::from_secs(10)).unwrap()), - timeout_height, - memo: None, - } - } - - pub fn get_dummy_transfer_packet(msg: MsgTransfer, sequence: Sequence) -> Packet { - let coin = Coin { - denom: msg.token.denom.clone(), - amount: msg.token.amount, - }; - - let data = { - let data = PacketData { - token: coin, - sender: msg.sender.clone(), - receiver: msg.receiver.clone(), - memo: None, - }; - serde_json::to_vec(&data).expect("PacketData's infallible Serialize impl failed") - }; - - Packet { - sequence, - source_port: msg.source_port, - source_channel: msg.source_channel, - destination_port: PortId::default(), - destination_channel: ChannelId::default(), - data, - timeout_height: msg.timeout_height, - timeout_timestamp: msg.timeout_timestamp, - } - } -} diff --git a/crates/relayer-types/src/applications/transfer/packet.rs b/crates/relayer-types/src/applications/transfer/packet.rs index 7b13d49b1e..207314513b 100644 --- a/crates/relayer-types/src/applications/transfer/packet.rs +++ b/crates/relayer-types/src/applications/transfer/packet.rs @@ -1,6 +1,8 @@ use std::str::FromStr; use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketData as RawPacketData; +use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketDataV2 as RawPacketDataV2; +use ibc_proto::ibc::applications::transfer::v2::Token as RawToken; use serde::{Deserialize, Serialize}; use super::error::Error; @@ -45,3 +47,60 @@ impl From for RawPacketData { } } } + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(try_from = "RawPacketDataV2", into = "RawPacketDataV2")] +pub struct PacketDataV2 { + pub token: Vec, + pub sender: Signer, + pub receiver: Signer, + pub memo: Option, +} + +impl TryFrom for PacketDataV2 { + type Error = Error; + + fn try_from(raw_pkt_data: RawPacketDataV2) -> Result { + // This denom may be prefixed or unprefixed. + let tokens = raw_pkt_data + .tokens + .iter() + .map(|token| { + let denom = PrefixedDenom::from_str(&token.denom).unwrap(); + let amount = Amount::from_str(&token.amount).unwrap(); + PrefixedCoin { denom, amount } + }) + .collect(); + //let denom = PrefixedDenom::from_str(&raw_pkt_data.denom)?; + //let amount = Amount::from_str(&raw_pkt_data.amount)?; + let memo = Some(raw_pkt_data.memo).filter(|m| !m.is_empty()); + Ok(Self { + //token: PrefixedCoin { denom, amount }, + token: tokens, + sender: raw_pkt_data.sender.parse().map_err(Error::signer)?, + receiver: raw_pkt_data.receiver.parse().map_err(Error::signer)?, + memo, + }) + } +} + +impl From for RawPacketDataV2 { + fn from(pkt_data: PacketDataV2) -> Self { + let memo = pkt_data.memo.unwrap_or_default(); + let tokens = pkt_data + .token + .iter() + .map(|token| RawToken { + denom: token.denom.to_string(), + amount: token.denom.to_string(), + trace: vec![], + }) + .collect(); + Self { + tokens, + sender: pkt_data.sender.to_string(), + receiver: pkt_data.receiver.to_string(), + memo, + } + } +} diff --git a/crates/relayer-types/src/core/ics04_channel/version.rs b/crates/relayer-types/src/core/ics04_channel/version.rs index 4d15ae3d4b..a3f38bd242 100644 --- a/crates/relayer-types/src/core/ics04_channel/version.rs +++ b/crates/relayer-types/src/core/ics04_channel/version.rs @@ -23,14 +23,14 @@ impl Version { Self(v) } - pub fn ics20() -> Self { - Self::new(transfer::VERSION.to_string()) + pub fn ics20(version: u64) -> Self { + Self::new(format!("{}-{version}", transfer::VERSION)) } - pub fn ics20_with_fee() -> Self { + pub fn ics20_with_fee(version: u64) -> Self { let val = json::json!({ "fee_version": "ics29-1", - "app_version": transfer::VERSION, + "app_version": format!("{}-{version}", transfer::VERSION), }); Self::new(val.to_string()) @@ -52,6 +52,10 @@ impl Version { }) .unwrap_or(false) } + + pub fn is_ics20_v2(&self) -> bool { + self.0.contains("ics20-2") + } } impl From for Version { @@ -88,12 +92,12 @@ mod test { #[test] fn test_ics29_version() { { - let version = Version::ics20(); + let version = Version::ics20(1); assert!(!version.supports_fee()); } { - let version = Version::ics20_with_fee(); + let version = Version::ics20_with_fee(1); assert!(version.supports_fee()); } } diff --git a/crates/relayer/src/channel/version.rs b/crates/relayer/src/channel/version.rs index 2aaf0b36ea..59d6899ae0 100644 --- a/crates/relayer/src/channel/version.rs +++ b/crates/relayer/src/channel/version.rs @@ -12,7 +12,7 @@ pub use ibc_relayer_types::core::ics04_channel::version::Version; pub fn default_by_port(port_id: &PortId) -> Option { if port_id.as_str() == transfer::PORT_ID_STR { // https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#forwards-compatibility - Some(Version::ics20()) + Some(Version::ics20(1)) } else { None } diff --git a/crates/relayer/src/link/relay_path.rs b/crates/relayer/src/link/relay_path.rs index 511ecc383b..ca5a4e1d72 100644 --- a/crates/relayer/src/link/relay_path.rs +++ b/crates/relayer/src/link/relay_path.rs @@ -1,11 +1,14 @@ use alloc::collections::BTreeMap as HashMap; use alloc::collections::VecDeque; use ibc_relayer_types::core::ics04_channel::packet::Sequence; +use ibc_relayer_types::core::ics04_channel::version::Version; +use serde_json::Error; use std::ops::Sub; use std::time::{Duration, Instant}; use ibc_proto::google::protobuf::Any; use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketData as RawPacketData; +use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketDataV2 as RawPacketDataV2; use itertools::Itertools; use tracing::{debug, error, info, span, trace, warn, Level}; @@ -566,12 +569,14 @@ impl RelayPath { trace!(event = %event_with_height, "processing event"); if let Some(packet) = event_with_height.event.packet() { + let channel_version = self.channel().dst_version(); // If the event is a ICS-04 packet event, and the packet contains ICS-20 // packet data, check that the ICS-20 fields are within the configured limits. if !check_ics20_fields_size( &packet.data, self.max_memo_size, self.max_receiver_size, + channel_version, ) { telemetry!( filtered_packets, @@ -1948,12 +1953,16 @@ fn check_ics20_fields_size( data: &[u8], memo_limit: Ics20FieldSizeLimit, receiver_limit: Ics20FieldSizeLimit, + maybe_channel_version: Option<&Version>, ) -> bool { - match serde_json::from_slice::(data) { - Ok(packet_data) => { + let channel_version = maybe_channel_version + .cloned() + .unwrap_or_else(|| Version::ics20(1)); + match extract_memo_and_receiver(&channel_version, data) { + Ok((memo, receiver)) => { match ( - memo_limit.check_field_size(&packet_data.memo), - receiver_limit.check_field_size(&packet_data.receiver), + memo_limit.check_field_size(&memo), + receiver_limit.check_field_size(&receiver), ) { (ValidationResult::Valid, ValidationResult::Valid) => true, @@ -1973,3 +1982,20 @@ fn check_ics20_fields_size( } } } + +fn extract_memo_and_receiver( + channel_version: &Version, + data: &[u8], +) -> Result<(String, String), Error> { + if channel_version.is_ics20_v2() { + match serde_json::from_slice::(data) { + Ok(packet_data) => Ok((packet_data.memo, packet_data.receiver)), + Err(e) => Err(e), + } + } else { + match serde_json::from_slice::(data) { + Ok(packet_data) => Ok((packet_data.memo, packet_data.receiver)), + Err(e) => Err(e), + } + } +} diff --git a/crates/relayer/src/transfer.rs b/crates/relayer/src/transfer.rs index d9f199ba38..fca69d2b1e 100644 --- a/crates/relayer/src/transfer.rs +++ b/crates/relayer/src/transfer.rs @@ -143,15 +143,48 @@ pub fn build_transfer_message( let msg = MsgTransfer { source_port: src_port_id, source_channel: src_channel_id, - token: Coin { + token: Some(Coin { denom, amount: amount.to_string(), - }, + }), sender, receiver, timeout_height, timeout_timestamp, memo, + tokens: vec![], + }; + + msg.to_any() +} + +pub fn build_transfer_message_v2( + src_port_id: PortId, + src_channel_id: ChannelId, + tokens: Vec<(Amount, String)>, + sender: Signer, + receiver: Signer, + timeout_height: TimeoutHeight, + timeout_timestamp: Timestamp, + memo: Option, +) -> Any { + let tokens = tokens + .iter() + .map(|(amount, denom)| Coin { + denom: denom.clone(), + amount: amount.to_string(), + }) + .collect(); + let msg = MsgTransfer { + source_port: src_port_id, + source_channel: src_channel_id, + token: None, + sender, + receiver, + timeout_height, + timeout_timestamp, + memo, + tokens, }; msg.to_any() From f233ec0eb08ec9513b4b8e9fb35feb5ea354d75e Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 May 2024 11:13:16 +0200 Subject: [PATCH 03/21] Update tests with new channel version handling and add ICS20 v2 test --- tools/integration-test/Cargo.toml | 1 + ...t_setup_with_fee_enabled_binary_channel.rs | 2 +- .../src/tests/fee/auto_forward_relayer.rs | 2 +- .../src/tests/fee/filter_fees.rs | 4 +- .../src/tests/fee/forward_relayer.rs | 2 +- .../src/tests/fee/no_forward_relayer.rs | 4 +- .../src/tests/fee/pay_fee_async.rs | 2 +- .../src/tests/fee/register_payee.rs | 2 +- .../src/tests/fee/timeout_fee.rs | 2 +- tools/integration-test/src/tests/transfer.rs | 187 +++++++++++++++++- .../src/bootstrap/binary/channel.rs | 2 +- .../test-framework/src/bootstrap/consumer.rs | 21 +- tools/test-framework/src/bootstrap/single.rs | 25 ++- .../test-framework/src/chain/ext/transfer.rs | 35 +++- .../test-framework/src/framework/overrides.rs | 2 +- tools/test-framework/src/relayer/transfer.rs | 84 ++++++++ tools/test-framework/src/types/single/node.rs | 18 ++ 17 files changed, 375 insertions(+), 20 deletions(-) diff --git a/tools/integration-test/Cargo.toml b/tools/integration-test/Cargo.toml index af3977fb9e..783590c381 100644 --- a/tools/integration-test/Cargo.toml +++ b/tools/integration-test/Cargo.toml @@ -46,6 +46,7 @@ celestia = [] async-icq = [] juno = [] dynamic-gas-fee = [] +ics20-v2 = [] [[bin]] name = "test_setup_with_binary_channel" diff --git a/tools/integration-test/src/bin/test_setup_with_fee_enabled_binary_channel.rs b/tools/integration-test/src/bin/test_setup_with_fee_enabled_binary_channel.rs index ac938158d2..cf36b6c4a5 100644 --- a/tools/integration-test/src/bin/test_setup_with_fee_enabled_binary_channel.rs +++ b/tools/integration-test/src/bin/test_setup_with_fee_enabled_binary_channel.rs @@ -59,7 +59,7 @@ impl TestOverrides for Test { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } 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 ca120394a5..55c9e36373 100644 --- a/tools/integration-test/src/tests/fee/auto_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/auto_forward_relayer.rs @@ -26,7 +26,7 @@ impl TestOverrides for AutoForwardRelayerTest { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } diff --git a/tools/integration-test/src/tests/fee/filter_fees.rs b/tools/integration-test/src/tests/fee/filter_fees.rs index 6113d98c1f..e67c794afd 100644 --- a/tools/integration-test/src/tests/fee/filter_fees.rs +++ b/tools/integration-test/src/tests/fee/filter_fees.rs @@ -37,7 +37,7 @@ impl TestOverrides for FilterIncentivizedFeesRelayerTest { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } @@ -206,7 +206,7 @@ impl TestOverrides for FilterByChannelIncentivizedFeesRelayerTest { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } diff --git a/tools/integration-test/src/tests/fee/forward_relayer.rs b/tools/integration-test/src/tests/fee/forward_relayer.rs index daa5bcf317..ee6addfa68 100644 --- a/tools/integration-test/src/tests/fee/forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/forward_relayer.rs @@ -21,7 +21,7 @@ struct ForwardRelayerTest; impl TestOverrides for ForwardRelayerTest { fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } 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 8b840640e8..f09ac98d64 100644 --- a/tools/integration-test/src/tests/fee/no_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/no_forward_relayer.rs @@ -33,7 +33,7 @@ impl TestOverrides for NoForwardRelayerTest { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } @@ -43,7 +43,7 @@ impl TestOverrides for InvalidForwardRelayerTest { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } 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 37c486c07d..2fbc36491d 100644 --- a/tools/integration-test/src/tests/fee/pay_fee_async.rs +++ b/tools/integration-test/src/tests/fee/pay_fee_async.rs @@ -38,7 +38,7 @@ impl TestOverrides for PayPacketFeeAsyncTest { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } diff --git a/tools/integration-test/src/tests/fee/register_payee.rs b/tools/integration-test/src/tests/fee/register_payee.rs index 638800c846..45da6e16de 100644 --- a/tools/integration-test/src/tests/fee/register_payee.rs +++ b/tools/integration-test/src/tests/fee/register_payee.rs @@ -24,7 +24,7 @@ struct ForwardRelayerTest; impl TestOverrides for ForwardRelayerTest { fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } diff --git a/tools/integration-test/src/tests/fee/timeout_fee.rs b/tools/integration-test/src/tests/fee/timeout_fee.rs index 1d3068db01..b960ab4d88 100644 --- a/tools/integration-test/src/tests/fee/timeout_fee.rs +++ b/tools/integration-test/src/tests/fee/timeout_fee.rs @@ -20,7 +20,7 @@ impl TestOverrides for TimeoutFeeTest { } fn channel_version(&self) -> Version { - Version::ics20_with_fee() + Version::ics20_with_fee(1) } } diff --git a/tools/integration-test/src/tests/transfer.rs b/tools/integration-test/src/tests/transfer.rs index f117dc742f..e477b72c91 100644 --- a/tools/integration-test/src/tests/transfer.rs +++ b/tools/integration-test/src/tests/transfer.rs @@ -1,3 +1,4 @@ +use ibc_relayer::channel::version::Version; use ibc_test_framework::prelude::*; use ibc_test_framework::util::random::random_u128_range; @@ -6,6 +7,12 @@ fn test_ibc_transfer() -> Result<(), Error> { run_binary_channel_test(&IbcTransferTest) } +#[cfg(any(doc, feature = "ics20-v2"))] +#[test] +fn test_ibc_transfer_ics20_v2() -> Result<(), Error> { + run_binary_channel_test(&IbcTransferICS20V2Test) +} + /** Test that IBC token transfer can still work with a single chain that is connected to itself. @@ -41,7 +48,11 @@ fn test_self_connected_nary_ibc_transfer() -> Result<(), Error> { pub struct IbcTransferTest; -impl TestOverrides for IbcTransferTest {} +impl TestOverrides for IbcTransferTest { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.clients.misbehaviour = false; + } +} impl BinaryChannelTest for IbcTransferTest { fn run( @@ -148,3 +159,177 @@ impl BinaryChannelTest for IbcTransferTest { Ok(()) } } + +pub struct IbcTransferICS20V2Test; + +impl TestOverrides for IbcTransferICS20V2Test { + fn modify_relayer_config(&self, config: &mut Config) { + config.mode.clients.misbehaviour = false; + } + + fn channel_version(&self) -> Version { + Version::ics20(2) + } +} + +impl BinaryChannelTest for IbcTransferICS20V2Test { + fn run( + &self, + _config: &TestConfig, + _relayer: RelayerDriver, + chains: ConnectedChains, + channel: ConnectedChannel, + ) -> Result<(), Error> { + let denom_a = chains.node_a.denom(); + let other_denom = chains.node_a.second_denom(); + + let wallet_a = chains.node_a.wallets().user1().cloned(); + let wallet_b = chains.node_b.wallets().user1().cloned(); + let wallet_c = chains.node_a.wallets().user2().cloned(); + + let balance_a = chains + .node_a + .chain_driver() + .query_balance(&wallet_a.address(), &denom_a)?; + + let other_balance_a = chains + .node_a + .chain_driver() + .query_balance(&wallet_a.address(), &other_denom)?; + + let a_to_b_amount_denom_a = random_u128_range(1000, 5000); + let a_to_b_amount_other_denom = random_u128_range(1000, 5000); + + info!( + "Sending IBC transfer from chain {} to chain {} with amount of {} {} and {} {}", + chains.chain_id_a(), + chains.chain_id_b(), + a_to_b_amount_denom_a, + denom_a, + a_to_b_amount_other_denom, + other_denom, + ); + + let token_denom_a = denom_a.with_amount(a_to_b_amount_denom_a); + let token_other_denom = other_denom.with_amount(a_to_b_amount_other_denom); + + chains.node_a.chain_driver().ibc_transfer_token_v2( + &channel.port_a.as_ref(), + &channel.channel_id_a.as_ref(), + &wallet_a.as_ref(), + &wallet_b.address(), + &vec![token_denom_a.as_ref(), token_other_denom.as_ref()], + )?; + + let denom_b = derive_ibc_denom( + &channel.port_b.as_ref(), + &channel.channel_id_b.as_ref(), + &denom_a, + )?; + + let other_denom_b = derive_ibc_denom( + &channel.port_b.as_ref(), + &channel.channel_id_b.as_ref(), + &other_denom, + )?; + + info!( + "Waiting for user on chain B to receive IBC transferred amount of {} and {}", + a_to_b_amount_denom_a, a_to_b_amount_other_denom + ); + + chains.node_a.chain_driver().assert_eventual_wallet_amount( + &wallet_a.address(), + &(balance_a - a_to_b_amount_denom_a).as_ref(), + )?; + + chains.node_a.chain_driver().assert_eventual_wallet_amount( + &wallet_a.address(), + &(other_balance_a - a_to_b_amount_other_denom).as_ref(), + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &wallet_b.address(), + &denom_b.with_amount(a_to_b_amount_denom_a).as_ref(), + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &wallet_b.address(), + &other_denom_b + .with_amount(a_to_b_amount_other_denom) + .as_ref(), + )?; + + info!( + "successfully performed IBC transfer from chain {} to chain {}", + chains.chain_id_a(), + chains.chain_id_b(), + ); + + let balance_c = chains + .node_a + .chain_driver() + .query_balance(&wallet_c.address(), &denom_a)?; + + let other_balance_c = chains + .node_a + .chain_driver() + .query_balance(&wallet_c.address(), &other_denom)?; + + let b_to_a_amount_denom_b = random_u128_range(500, a_to_b_amount_denom_a); + let b_to_a_amount_other_denom_b = random_u128_range(500, a_to_b_amount_other_denom); + + info!( + "Sending IBC transfer from chain {} to chain {} with amount of {} {} and {} {}", + chains.chain_id_b(), + chains.chain_id_a(), + b_to_a_amount_denom_b, + denom_b, + b_to_a_amount_other_denom_b, + other_denom_b, + ); + + let token_denom_b = denom_b.with_amount(b_to_a_amount_denom_b); + let token_other_denom_b = other_denom_b.with_amount(b_to_a_amount_other_denom_b); + + chains.node_b.chain_driver().ibc_transfer_token_v2( + &channel.port_b.as_ref(), + &channel.channel_id_b.as_ref(), + &wallet_b.as_ref(), + &wallet_c.address(), + &vec![token_denom_b.as_ref(), token_other_denom_b.as_ref()], + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &wallet_b.address(), + &denom_b + .with_amount(a_to_b_amount_denom_a - b_to_a_amount_denom_b) + .as_ref(), + )?; + + chains.node_b.chain_driver().assert_eventual_wallet_amount( + &wallet_b.address(), + &other_denom_b + .with_amount(a_to_b_amount_other_denom - b_to_a_amount_other_denom_b) + .as_ref(), + )?; + + chains.node_a.chain_driver().assert_eventual_wallet_amount( + &wallet_c.address(), + &(balance_c + b_to_a_amount_denom_b).as_ref(), + )?; + + chains.node_a.chain_driver().assert_eventual_wallet_amount( + &wallet_c.address(), + &(other_balance_c + b_to_a_amount_other_denom_b).as_ref(), + )?; + + info!( + "successfully performed reverse IBC transfer from chain {} back to chain {}", + chains.chain_id_b(), + chains.chain_id_a(), + ); + + Ok(()) + } +} diff --git a/tools/test-framework/src/bootstrap/binary/channel.rs b/tools/test-framework/src/bootstrap/binary/channel.rs index 4b1439568a..7ddae387dd 100644 --- a/tools/test-framework/src/bootstrap/binary/channel.rs +++ b/tools/test-framework/src/bootstrap/binary/channel.rs @@ -201,7 +201,7 @@ impl Default for BootstrapChannelOptions { fn default() -> Self { Self { order: Ordering::Unordered, - version: Version::ics20(), + version: Version::ics20(1), pad_channel_id_a: 0, pad_channel_id_b: 1, } diff --git a/tools/test-framework/src/bootstrap/consumer.rs b/tools/test-framework/src/bootstrap/consumer.rs index 6c85595331..741f543c73 100644 --- a/tools/test-framework/src/bootstrap/consumer.rs +++ b/tools/test-framework/src/bootstrap/consumer.rs @@ -27,7 +27,11 @@ pub fn bootstrap_consumer_node( let denom = Denom::base("samoleans"); + let second_denom = Denom::base("samoleansv2"); + let initial_amount = random_u128_range(1_000_000_000_000_000_000, 2_000_000_000_000_000_000); + let second_initial_amount = + random_u128_range(1_000_000_000_000_000_000, 2_000_000_000_000_000_000); let initial_stake = Token::new(stake_denom, initial_amount); let additional_initial_stake = initial_stake @@ -38,6 +42,7 @@ pub fn bootstrap_consumer_node( )))?; let initial_coin = Token::new(denom.clone(), initial_amount); + let second_initial_coin = Token::new(second_denom.clone(), second_initial_amount); let chain_driver = builder.new_chain(prefix, false, chain_number)?; chain_driver.initialize()?; @@ -48,9 +53,18 @@ pub fn bootstrap_consumer_node( let user2 = chain_driver.add_wallet("user2")?; chain_driver.add_genesis_account(&validator.address, &[&additional_initial_stake])?; - chain_driver.add_genesis_account(&relayer.address, &[&initial_stake, &initial_coin])?; - chain_driver.add_genesis_account(&user1.address, &[&initial_stake, &initial_coin])?; - chain_driver.add_genesis_account(&user2.address, &[&initial_stake, &initial_coin])?; + chain_driver.add_genesis_account( + &relayer.address, + &[&initial_stake, &initial_coin, &second_initial_coin], + )?; + chain_driver.add_genesis_account( + &user1.address, + &[&initial_stake, &initial_coin, &second_initial_coin], + )?; + chain_driver.add_genesis_account( + &user2.address, + &[&initial_stake, &initial_coin, &second_initial_coin], + )?; // Wait for the consumer chain to be initialized before querying the genesis thread::sleep(Duration::from_secs(30)); @@ -136,6 +150,7 @@ pub fn bootstrap_consumer_node( let node = FullNode { chain_driver, denom, + second_denom, wallets, process: Arc::new(RwLock::new(process)), }; diff --git a/tools/test-framework/src/bootstrap/single.rs b/tools/test-framework/src/bootstrap/single.rs index 508d0b28ba..b0a220856b 100644 --- a/tools/test-framework/src/bootstrap/single.rs +++ b/tools/test-framework/src/bootstrap/single.rs @@ -54,10 +54,18 @@ pub fn bootstrap_single_node( Denom::base("samoleans") }; + let second_denom = if use_random_id { + Denom::base(&format!("coinv2{:x}", random_u32())) + } else { + Denom::base("samoleansv2") + }; + // Evmos requires of at least 1_000_000_000_000_000_000 or else there will be the // error `error during handshake: error on replay: validator set is nil in genesis and still empty after InitChain` // when running `evmosd start`. let initial_amount = random_u128_range(1_000_000_000_000_000_000, 2_000_000_000_000_000_000); + let second_initial_amount = + random_u128_range(1_000_000_000_000_000_000, 2_000_000_000_000_000_000); let initial_native_token = Token::new(native_denom, initial_amount); let additional_native_token = initial_native_token @@ -68,6 +76,7 @@ pub fn bootstrap_single_node( native_token )))?; let initial_coin = Token::new(denom.clone(), initial_amount); + let second_initial_coin = Token::new(second_denom.clone(), second_initial_amount); let chain_driver = builder.new_chain(prefix, use_random_id, chain_number)?; @@ -85,11 +94,20 @@ pub fn bootstrap_single_node( chain_driver.add_genesis_validator(&validator.id, &initial_native_token)?; - chain_driver.add_genesis_account(&user1.address, &[&initial_native_token, &initial_coin])?; + chain_driver.add_genesis_account( + &user1.address, + &[&initial_native_token, &initial_coin, &second_initial_coin], + )?; - chain_driver.add_genesis_account(&user2.address, &[&initial_native_token, &initial_coin])?; + chain_driver.add_genesis_account( + &user2.address, + &[&initial_native_token, &initial_coin, &second_initial_coin], + )?; - chain_driver.add_genesis_account(&relayer.address, &[&initial_native_token, &initial_coin])?; + chain_driver.add_genesis_account( + &relayer.address, + &[&initial_native_token, &initial_coin, &second_initial_coin], + )?; chain_driver.collect_gen_txs()?; @@ -154,6 +172,7 @@ pub fn bootstrap_single_node( let node = FullNode { chain_driver, denom, + second_denom, wallets, process: Arc::new(RwLock::new(process)), }; diff --git a/tools/test-framework/src/chain/ext/transfer.rs b/tools/test-framework/src/chain/ext/transfer.rs index 94707ff8da..47e98f05f8 100644 --- a/tools/test-framework/src/chain/ext/transfer.rs +++ b/tools/test-framework/src/chain/ext/transfer.rs @@ -9,7 +9,9 @@ use crate::chain::driver::ChainDriver; use crate::chain::tagged::TaggedChainDriverExt; use crate::error::Error; use crate::ibc::token::TaggedTokenRef; -use crate::relayer::transfer::{batched_ibc_token_transfer, ibc_token_transfer}; +use crate::relayer::transfer::{ + batched_ibc_token_transfer, ibc_token_transfer, ibc_token_transfer_v2, +}; use crate::types::id::{TaggedChannelIdRef, TaggedPortIdRef}; use crate::types::tagged::*; use crate::types::wallet::{Wallet, WalletAddress}; @@ -44,6 +46,15 @@ pub trait ChainTransferMethodsExt { token: &TaggedTokenRef, ) -> Result; + fn ibc_transfer_token_v2( + &self, + port_id: &TaggedPortIdRef, + channel_id: &TaggedChannelIdRef, + sender: &MonoTagged, + recipient: &MonoTagged, + token: &Vec>, + ) -> Result; + fn ibc_transfer_token_with_memo_and_timeout( &self, port_id: &TaggedPortIdRef, @@ -108,6 +119,28 @@ impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged( + &self, + port_id: &TaggedPortIdRef, + channel_id: &TaggedChannelIdRef, + sender: &MonoTagged, + recipient: &MonoTagged, + tokens: &Vec>, + ) -> Result { + let rpc_client = self.rpc_client()?; + self.value().runtime.block_on(ibc_token_transfer_v2( + rpc_client.as_ref(), + &self.tx_config(), + port_id, + channel_id, + sender, + recipient, + tokens, + None, + None, + )) + } + fn ibc_transfer_token_with_memo_and_timeout( &self, port_id: &TaggedPortIdRef, diff --git a/tools/test-framework/src/framework/overrides.rs b/tools/test-framework/src/framework/overrides.rs index 0338224469..4a39dc5f50 100644 --- a/tools/test-framework/src/framework/overrides.rs +++ b/tools/test-framework/src/framework/overrides.rs @@ -143,7 +143,7 @@ pub trait TestOverrides { Implemented for [`ChannelVersionOverride`]. */ fn channel_version(&self) -> Version { - Version::ics20() + Version::ics20(1) } } diff --git a/tools/test-framework/src/relayer/transfer.rs b/tools/test-framework/src/relayer/transfer.rs index 26595051a5..78bd3589a9 100644 --- a/tools/test-framework/src/relayer/transfer.rs +++ b/tools/test-framework/src/relayer/transfer.rs @@ -14,6 +14,7 @@ use ibc_relayer::chain::cosmos::tx::batched_send_tx; use ibc_relayer::chain::cosmos::tx::simple_send_tx; use ibc_relayer::chain::cosmos::types::config::TxConfig; use ibc_relayer::transfer::build_transfer_message as raw_build_transfer_message; +use ibc_relayer::transfer::build_transfer_message_v2 as raw_build_transfer_message_v2; use ibc_relayer::transfer::TransferError; use ibc_relayer_types::applications::transfer::error::Error as Ics20Error; use ibc_relayer_types::core::ics04_channel::timeout::TimeoutHeight; @@ -65,6 +66,49 @@ pub fn build_transfer_message( )) } +pub fn build_transfer_message_v2( + port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, + channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, + sender: &MonoTagged, + recipient: &MonoTagged, + tokens: &Vec>, + timeout: Duration, + memo: Option, +) -> Result { + let timeout_timestamp = Timestamp::now() + .add(timeout) + .map_err(handle_generic_error)?; + + let sender = sender + .value() + .address + .0 + .parse() + .map_err(|e| TransferError::token_transfer(Ics20Error::signer(e)))?; + + let receiver = recipient + .value() + .0 + .parse() + .map_err(|e| TransferError::token_transfer(Ics20Error::signer(e)))?; + + let tokens = tokens + .iter() + .map(|token| (token.value().amount, token.value().denom.to_string())) + .collect(); + + Ok(raw_build_transfer_message_v2( + (*port_id.value()).clone(), + (*channel_id.value()).clone(), + tokens, + sender, + receiver, + TimeoutHeight::no_timeout(), + timeout_timestamp, + memo, + )) +} + /** Perform a simplified version of IBC token transfer for testing purpose. @@ -122,6 +166,46 @@ pub async fn ibc_token_transfer( Ok(packet) } +pub async fn ibc_token_transfer_v2( + rpc_client: MonoTagged, + tx_config: &MonoTagged, + port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, + channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, + sender: &MonoTagged, + recipient: &MonoTagged, + tokens: &Vec>, + memo: Option, + timeout: Option, +) -> Result { + let message = build_transfer_message_v2( + port_id, + channel_id, + sender, + recipient, + tokens, + timeout.unwrap_or(Duration::from_secs(60)), + memo.clone(), + )?; + + let events = simple_send_tx( + rpc_client.into_value(), + tx_config.value(), + &sender.value().key, + vec![message], + ) + .await?; + + let packet = events + .into_iter() + .find_map(|event| match event.event { + IbcEvent::SendPacket(ev) => Some(ev.packet), + _ => None, + }) + .ok_or_else(|| eyre!("failed to find send packet event"))?; + + Ok(packet) +} + pub async fn batched_ibc_token_transfer( rpc_client: MonoTagged, tx_config: &MonoTagged, diff --git a/tools/test-framework/src/types/single/node.rs b/tools/test-framework/src/types/single/node.rs index b6241c0ade..d7a6b182aa 100644 --- a/tools/test-framework/src/types/single/node.rs +++ b/tools/test-framework/src/types/single/node.rs @@ -47,6 +47,13 @@ pub struct FullNode { */ pub denom: Denom, + /** + The second currency denomination which the wallets have been loaded + with initial balance during the chain setup. + This is used for ICS20 v2 test transfering multiple denoms in one message. + */ + pub second_denom: Denom, + /** The test wallets with more than sufficient account balance that can be used for testing. @@ -82,6 +89,9 @@ pub trait TaggedFullNodeExt { /// Get the [`Denom`] tagged with the given `Chain`. fn denom(&self) -> MonoTagged; + + /// Get the [`Denom`] tagged with the given `Chain` of the secondary token. + fn second_denom(&self) -> MonoTagged; } impl TaggedFullNodeExt for MonoTagged { @@ -100,6 +110,10 @@ impl TaggedFullNodeExt for MonoTagged { fn denom(&self) -> MonoTagged { self.map_ref(|c| &c.denom) } + + fn second_denom(&self) -> MonoTagged { + self.map_ref(|c| &c.second_denom) + } } impl<'a, Chain> TaggedFullNodeExt for MonoTagged { @@ -118,6 +132,10 @@ impl<'a, Chain> TaggedFullNodeExt for MonoTagged { fn denom(&self) -> MonoTagged { self.map_ref(|c| &c.denom) } + + fn second_denom(&self) -> MonoTagged { + self.map_ref(|c| &c.second_denom) + } } impl FullNode { From d05bc5a468904816b669fcc52fe3db64a4315a24 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 May 2024 11:21:29 +0200 Subject: [PATCH 04/21] Codespell fix --- tools/test-framework/src/types/single/node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-framework/src/types/single/node.rs b/tools/test-framework/src/types/single/node.rs index d7a6b182aa..c67c2a105d 100644 --- a/tools/test-framework/src/types/single/node.rs +++ b/tools/test-framework/src/types/single/node.rs @@ -50,7 +50,7 @@ pub struct FullNode { /** The second currency denomination which the wallets have been loaded with initial balance during the chain setup. - This is used for ICS20 v2 test transfering multiple denoms in one message. + This is used for ICS20 v2 test transferring multiple denoms in one message. */ pub second_denom: Denom, From fc41cdceb1b3993243cbf406faf415bc098f2599 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 May 2024 13:05:55 +0200 Subject: [PATCH 05/21] Apply github suggestions --- crates/relayer-types/src/applications/transfer/mod.rs | 2 +- crates/relayer-types/src/applications/transfer/packet.rs | 6 +++--- crates/relayer-types/src/core/ics04_channel/version.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/relayer-types/src/applications/transfer/mod.rs b/crates/relayer-types/src/applications/transfer/mod.rs index 617d9fd63c..0c51c0e9d9 100644 --- a/crates/relayer-types/src/applications/transfer/mod.rs +++ b/crates/relayer-types/src/applications/transfer/mod.rs @@ -23,4 +23,4 @@ pub const MODULE_ID_STR: &str = "transfer"; pub const PORT_ID_STR: &str = "transfer"; /// ICS20 application current version. -pub const VERSION: &str = "ics20"; +pub const VERSION_PREFIX: &str = "ics20"; diff --git a/crates/relayer-types/src/applications/transfer/packet.rs b/crates/relayer-types/src/applications/transfer/packet.rs index 207314513b..a7e16de937 100644 --- a/crates/relayer-types/src/applications/transfer/packet.rs +++ b/crates/relayer-types/src/applications/transfer/packet.rs @@ -51,7 +51,7 @@ impl From for RawPacketData { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(try_from = "RawPacketDataV2", into = "RawPacketDataV2")] pub struct PacketDataV2 { - pub token: Vec, + pub tokens: Vec, pub sender: Signer, pub receiver: Signer, pub memo: Option, @@ -76,7 +76,7 @@ impl TryFrom for PacketDataV2 { let memo = Some(raw_pkt_data.memo).filter(|m| !m.is_empty()); Ok(Self { //token: PrefixedCoin { denom, amount }, - token: tokens, + tokens, sender: raw_pkt_data.sender.parse().map_err(Error::signer)?, receiver: raw_pkt_data.receiver.parse().map_err(Error::signer)?, memo, @@ -88,7 +88,7 @@ impl From for RawPacketDataV2 { fn from(pkt_data: PacketDataV2) -> Self { let memo = pkt_data.memo.unwrap_or_default(); let tokens = pkt_data - .token + .tokens .iter() .map(|token| RawToken { denom: token.denom.to_string(), diff --git a/crates/relayer-types/src/core/ics04_channel/version.rs b/crates/relayer-types/src/core/ics04_channel/version.rs index a3f38bd242..30e6a39747 100644 --- a/crates/relayer-types/src/core/ics04_channel/version.rs +++ b/crates/relayer-types/src/core/ics04_channel/version.rs @@ -24,13 +24,13 @@ impl Version { } pub fn ics20(version: u64) -> Self { - Self::new(format!("{}-{version}", transfer::VERSION)) + Self::new(format!("{}-{version}", transfer::VERSION_PREFIX)) } pub fn ics20_with_fee(version: u64) -> Self { let val = json::json!({ "fee_version": "ics29-1", - "app_version": format!("{}-{version}", transfer::VERSION), + "app_version": format!("{}-{version}", transfer::VERSION_PREFIX), }); Self::new(val.to_string()) From b465f9f6ae5290bd6c623c8f31a28346e4cc6cc0 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 6 Jun 2024 12:53:11 +0200 Subject: [PATCH 06/21] Use UID and GID 2000 when creating Docker image --- ci/release/hermes.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/release/hermes.Dockerfile b/ci/release/hermes.Dockerfile index 5da3f2c6e1..8540b2446b 100644 --- a/ci/release/hermes.Dockerfile +++ b/ci/release/hermes.Dockerfile @@ -14,8 +14,8 @@ RUN cargo build --release FROM ubuntu:latest LABEL maintainer="hello@informal.systems" -ARG UID=1000 -ARG GID=1000 +ARG UID=2000 +ARG GID=2000 RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates RUN update-ca-certificates From 0a90e5d5edade0d3aef73a75ed79f394aac7541d Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 21 Aug 2024 12:54:45 +0200 Subject: [PATCH 07/21] Add ICS20 v2 feature to ibc-go v9 tests --- .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 bfd1e1b1c8..511f8648f5 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,new-register-interchain-account,channel-upgrade,authz,no-denom-trace + features: ica,ics29-fee,new-register-interchain-account,channel-upgrade,authz,no-denom-trace,ics20-v2 - package: wasmd command: wasmd account_prefix: wasm From f68c5e8cadf0d9c4f884b19006ce2d167e95565e Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 21 Aug 2024 13:06:02 +0200 Subject: [PATCH 08/21] Improve method 'is_ics20_v2' --- .../src/core/ics04_channel/version.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/relayer-types/src/core/ics04_channel/version.rs b/crates/relayer-types/src/core/ics04_channel/version.rs index 00378b685f..3a2322b916 100644 --- a/crates/relayer-types/src/core/ics04_channel/version.rs +++ b/crates/relayer-types/src/core/ics04_channel/version.rs @@ -7,6 +7,7 @@ use serde_json as json; use std::convert::Infallible; use std::fmt::{Display, Error as FmtError, Formatter}; use std::str::FromStr; +use tracing::debug; use crate::applications::transfer; @@ -63,7 +64,19 @@ impl Version { } pub fn is_ics20_v2(&self) -> bool { - self.0.contains("ics20-2") + match serde_json::from_str::(&self.0) { + Ok(json_value) => { + let app_version = json_value + .get("app_version") + .and_then(|app_version| app_version.as_str()) + .unwrap_or(self.0.as_str()); + app_version == "ics20-2" + } + Err(e) => { + debug!("failed to deserialise version as JSON will fallback to direct string comparison. Error: {e}"); + self.0.as_str() == "ics20-2" + } + } } } From 8ac128e63f7af43e84857c098a49017a69c18f7f Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 22 Aug 2024 10:58:26 +0200 Subject: [PATCH 09/21] Set MsgTransfer as an enum for ICS20 v1 and v2 --- .../relayer-cli/src/commands/fee/transfer.rs | 28 +++- .../relayer-cli/src/commands/tx/transfer.rs | 23 +++- .../applications/transfer/msgs/transfer.rs | 129 +++++++++++++----- crates/relayer/src/transfer.rs | 88 ++++++++---- 4 files changed, 207 insertions(+), 61 deletions(-) diff --git a/crates/relayer-cli/src/commands/fee/transfer.rs b/crates/relayer-cli/src/commands/fee/transfer.rs index 2ea80d63b3..e135e7c795 100644 --- a/crates/relayer-cli/src/commands/fee/transfer.rs +++ b/crates/relayer-cli/src/commands/fee/transfer.rs @@ -5,6 +5,7 @@ use eyre::eyre; use ibc_relayer::{ chain::handle::ChainHandle, + channel::version::Version, config::Config, transfer::{build_transfer_messages, send_messages, TransferOptions}, }; @@ -61,6 +62,14 @@ pub struct FeeTransferCmd { )] src_channel_id: ChannelId, + #[clap( + long = "ics20-version", + default_value = "1", + value_name = "ICS20_VERSION", + help = "ICS20 version of the channel. Defaults to 1" + )] + ics20_version: u64, + #[clap( long = "amount", required = true, @@ -192,6 +201,7 @@ impl FeeTransferCmd { dst_chain_id: self.dst_chain_id.clone(), src_port_id: self.src_port_id.clone(), src_channel_id: self.src_channel_id.clone(), + ics20_version: self.ics20_version, amount: self.amount, denom, receiver: self.recipient.clone(), @@ -230,6 +240,7 @@ pub struct FeeTransferOptions { pub dst_chain_id: ChainId, pub src_port_id: PortId, pub src_channel_id: ChannelId, + pub ics20_version: u64, pub amount: Amount, pub denom: String, pub receiver: Option, @@ -244,11 +255,12 @@ pub struct FeeTransferOptions { impl From for TransferOptions { fn from(f: FeeTransferOptions) -> Self { + let tokens = vec![(f.amount, f.denom)]; TransferOptions { src_port_id: f.src_port_id, src_channel_id: f.src_channel_id, - amount: f.amount, - denom: f.denom, + channel_version: Version::ics20(f.ics20_version), // TODO: Can only create transfer on ICS20 channel + tokens, receiver: f.receiver, timeout_height_offset: f.timeout_height_offset, timeout_duration: f.timeout_duration, @@ -321,6 +333,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -357,6 +370,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -393,6 +407,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "stake".to_owned(), recipient: None, @@ -431,6 +446,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: Some("other_recipient".to_owned()), @@ -469,6 +485,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -507,6 +524,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -545,6 +563,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -583,6 +602,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -621,6 +641,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -658,6 +679,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -696,6 +718,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -734,6 +757,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), + ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, diff --git a/crates/relayer-cli/src/commands/tx/transfer.rs b/crates/relayer-cli/src/commands/tx/transfer.rs index 62c3d96625..f1731cd46d 100644 --- a/crates/relayer-cli/src/commands/tx/transfer.rs +++ b/crates/relayer-cli/src/commands/tx/transfer.rs @@ -4,6 +4,7 @@ use abscissa_core::clap::Parser; use abscissa_core::{config::Override, FrameworkErrorKind}; use eyre::eyre; +use ibc_relayer::channel::version::Version; use ibc_relayer::{ chain::handle::ChainHandle, config::Config, @@ -59,6 +60,14 @@ pub struct TxIcs20MsgTransferCmd { )] src_channel_id: ChannelId, + #[clap( + long = "ics20-version", + default_value = "1", + value_name = "ICS20_VERSION", + help = "ICS20 version of the channel. Defaults to 1" + )] + ics20_version: u64, + #[clap( long = "amount", required = true, @@ -161,11 +170,12 @@ impl TxIcs20MsgTransferCmd { return Err(eyre!("number of messages should be greater than zero")); } + let tokens = vec![(self.amount, denom)]; let opts = TransferOptions { src_port_id: self.src_port_id.clone(), src_channel_id: self.src_channel_id.clone(), - amount: self.amount, - denom, + channel_version: Version::ics20(self.ics20_version), // TODO: Can only create transfer on ICS20 channel + tokens, receiver: self.receiver.clone(), timeout_height_offset: self.timeout_height_offset, timeout_duration: Duration::from_secs(self.timeout_seconds), @@ -229,6 +239,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -262,6 +273,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -295,6 +307,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -330,6 +343,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -365,6 +379,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -400,6 +415,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -435,6 +451,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 21, timeout_seconds: 0, @@ -470,6 +487,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 21, @@ -505,6 +523,7 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, diff --git a/crates/relayer-types/src/applications/transfer/msgs/transfer.rs b/crates/relayer-types/src/applications/transfer/msgs/transfer.rs index 638d42b0d6..152b021d69 100644 --- a/crates/relayer-types/src/applications/transfer/msgs/transfer.rs +++ b/crates/relayer-types/src/applications/transfer/msgs/transfer.rs @@ -14,6 +14,12 @@ use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.applications.transfer.v1.MsgTransfer"; +#[derive(Clone, Debug, PartialEq)] +pub enum MsgTransfer { + V1(MsgTransferV1), + V2(MsgTransferV2), +} + /// Message used to build an ICS20 token transfer packet. /// /// Note that this message is not a packet yet, as it lacks the proper sequence @@ -22,13 +28,33 @@ pub const TYPE_URL: &str = "/ibc.applications.transfer.v1.MsgTransfer"; /// have to specify the information related to the transfer of the token, and /// let the library figure out how to build the packet properly. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct MsgTransfer { +pub struct MsgTransferV1 { /// the port on which the packet will be sent pub source_port: PortId, /// the channel by which the packet will be sent pub source_channel: ChannelId, /// the tokens to be transferred - pub token: Option, + pub token: C, + /// the sender address + pub sender: Signer, + /// the recipient address on the destination chain + pub receiver: Signer, + /// Timeout height relative to the current block height. + /// The timeout is disabled when set to None. + pub timeout_height: TimeoutHeight, + /// Timeout timestamp relative to the current block timestamp. + /// The timeout is disabled when set to 0. + pub timeout_timestamp: Timestamp, + /// optional memo + pub memo: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MsgTransferV2 { + /// the port on which the packet will be sent + pub source_port: PortId, + /// the channel by which the packet will be sent + pub source_channel: ChannelId, /// the sender address pub sender: Signer, /// the recipient address on the destination chain @@ -70,41 +96,78 @@ impl TryFrom for MsgTransfer { let memo = Some(raw_msg.memo).filter(|m| !m.is_empty()); - Ok(MsgTransfer { - source_port: raw_msg - .source_port - .parse() - .map_err(|e| Error::invalid_port_id(raw_msg.source_port.clone(), e))?, - source_channel: raw_msg - .source_channel - .parse() - .map_err(|e| Error::invalid_channel_id(raw_msg.source_channel.clone(), e))?, - token: raw_msg.token, - sender: raw_msg.sender.parse().map_err(Error::signer)?, - receiver: raw_msg.receiver.parse().map_err(Error::signer)?, - timeout_height, - timeout_timestamp, - memo, - tokens: raw_msg.tokens, - }) + match raw_msg.token { + Some(token) => Ok(MsgTransfer::V1(MsgTransferV1 { + source_port: raw_msg + .source_port + .parse() + .map_err(|e| Error::invalid_port_id(raw_msg.source_port.clone(), e))?, + source_channel: raw_msg + .source_channel + .parse() + .map_err(|e| Error::invalid_channel_id(raw_msg.source_channel.clone(), e))?, + token, + sender: raw_msg.sender.parse().map_err(Error::signer)?, + receiver: raw_msg.receiver.parse().map_err(Error::signer)?, + timeout_height, + timeout_timestamp, + memo, + })), + None => Ok(MsgTransfer::V2(MsgTransferV2 { + source_port: raw_msg + .source_port + .parse() + .map_err(|e| Error::invalid_port_id(raw_msg.source_port.clone(), e))?, + source_channel: raw_msg + .source_channel + .parse() + .map_err(|e| Error::invalid_channel_id(raw_msg.source_channel.clone(), e))?, + sender: raw_msg.sender.parse().map_err(Error::signer)?, + receiver: raw_msg.receiver.parse().map_err(Error::signer)?, + timeout_height, + timeout_timestamp, + memo, + tokens: raw_msg.tokens, + })), + } } } impl From for RawMsgTransfer { - fn from(domain_msg: MsgTransfer) -> Self { - let memo = domain_msg.memo.unwrap_or_default(); - - RawMsgTransfer { - source_port: domain_msg.source_port.to_string(), - source_channel: domain_msg.source_channel.to_string(), - token: domain_msg.token, - sender: domain_msg.sender.to_string(), - receiver: domain_msg.receiver.to_string(), - timeout_height: domain_msg.timeout_height.into(), - timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(), - memo, - tokens: domain_msg.tokens, - forwarding: None, // TODO: fill with correct value + fn from(msg: MsgTransfer) -> Self { + match msg { + MsgTransfer::V1(domain_msg) => { + let memo = domain_msg.memo.unwrap_or_default(); + + RawMsgTransfer { + source_port: domain_msg.source_port.to_string(), + source_channel: domain_msg.source_channel.to_string(), + token: Some(domain_msg.token), + sender: domain_msg.sender.to_string(), + receiver: domain_msg.receiver.to_string(), + timeout_height: domain_msg.timeout_height.into(), + timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(), + memo, + tokens: vec![], + forwarding: None, // TODO: fill with correct value + } + } + MsgTransfer::V2(domain_msg) => { + let memo = domain_msg.memo.unwrap_or_default(); + + RawMsgTransfer { + source_port: domain_msg.source_port.to_string(), + source_channel: domain_msg.source_channel.to_string(), + token: None, + sender: domain_msg.sender.to_string(), + receiver: domain_msg.receiver.to_string(), + timeout_height: domain_msg.timeout_height.into(), + timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(), + memo, + tokens: domain_msg.tokens, + forwarding: None, // TODO: fill with correct value + } + } } } } diff --git a/crates/relayer/src/transfer.rs b/crates/relayer/src/transfer.rs index fca69d2b1e..e6c189072a 100644 --- a/crates/relayer/src/transfer.rs +++ b/crates/relayer/src/transfer.rs @@ -1,3 +1,4 @@ +use ibc_relayer_types::core::ics04_channel::version::Version; use ibc_relayer_types::signer::SignerError; use std::ops::Add; use std::str::FromStr; @@ -8,7 +9,9 @@ use flex_error::{define_error, DetailOnly}; use ibc_proto::cosmos::base::v1beta1::Coin; use ibc_proto::google::protobuf::Any; use ibc_relayer_types::applications::transfer::error::Error as Ics20Error; -use ibc_relayer_types::applications::transfer::msgs::transfer::MsgTransfer; +use ibc_relayer_types::applications::transfer::msgs::transfer::{ + MsgTransfer, MsgTransferV1, MsgTransferV2, +}; use ibc_relayer_types::applications::transfer::Amount; use ibc_relayer_types::core::ics04_channel::timeout::TimeoutHeight; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; @@ -19,6 +22,7 @@ use ibc_relayer_types::tx_msg::Msg; use crate::chain::endpoint::ChainStatus; use crate::chain::handle::ChainHandle; +use crate::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; use crate::chain::tracking::TrackedMsgs; use crate::error::Error; use crate::event::IbcEventWithHeight; @@ -120,8 +124,8 @@ impl TransferTimeout { pub struct TransferOptions { pub src_port_id: PortId, pub src_channel_id: ChannelId, - pub amount: Amount, - pub denom: String, + pub channel_version: Version, + pub tokens: Vec<(Amount, String)>, pub receiver: Option, pub timeout_height_offset: u64, pub timeout_duration: Duration, @@ -132,33 +136,58 @@ pub struct TransferOptions { pub fn build_transfer_message( src_port_id: PortId, src_channel_id: ChannelId, - amount: Amount, - denom: String, + channel_version: Version, + tokens: Vec<(Amount, String)>, sender: Signer, receiver: Signer, timeout_height: TimeoutHeight, timeout_timestamp: Timestamp, memo: Option, ) -> Any { - let msg = MsgTransfer { - source_port: src_port_id, - source_channel: src_channel_id, - token: Some(Coin { - denom, - amount: amount.to_string(), - }), - sender, - receiver, - timeout_height, - timeout_timestamp, - memo, - tokens: vec![], - }; + if channel_version.is_ics20_v2() { + let tokens = tokens + .into_iter() + .map(|(amount, denom)| Coin { + denom, + amount: amount.to_string(), + }) + .collect(); + let msg = MsgTransferV2 { + source_port: src_port_id, + source_channel: src_channel_id, + sender, + receiver, + timeout_height, + timeout_timestamp, + memo, + tokens, + }; - msg.to_any() + MsgTransfer::V2(msg).to_any() + } else { + let token = tokens + .first() + .map(|(amount, denom)| Coin { + denom: denom.to_string(), + amount: amount.to_string(), + }) + .unwrap(); + let msg = MsgTransferV1 { + source_port: src_port_id, + source_channel: src_channel_id, + token, + sender, + receiver, + timeout_height, + timeout_timestamp, + memo, + }; + + MsgTransfer::V1(msg).to_any() + } } -pub fn build_transfer_message_v2( +/*pub fn build_transfer_message_v2( src_port_id: PortId, src_channel_id: ChannelId, tokens: Vec<(Amount, String)>, @@ -188,7 +217,7 @@ pub fn build_transfer_message_v2( }; msg.to_any() -} +}*/ pub fn build_transfer_messages( src_chain: &SrcChain, // the chain whose account is debited @@ -212,11 +241,22 @@ pub fn build_transfer_messages( &destination_chain_status, )?; + let (channel, _) = src_chain + .query_channel( + QueryChannelRequest { + port_id: opts.src_port_id.clone(), + channel_id: opts.src_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::No, + ) + .map_err(TransferError::relayer)?; + let message = build_transfer_message( opts.src_port_id.clone(), opts.src_channel_id.clone(), - opts.amount, - opts.denom.clone(), + channel.version, + opts.tokens.clone(), sender, receiver, timeout.timeout_height, From 0e8832de8e6be739203ff24e5bf3d4b392f8eda7 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 22 Aug 2024 10:59:30 +0200 Subject: [PATCH 10/21] Update ibc_transfer_token to work with ICS20 v1 and v2 depending on channel version --- .../src/tests/benchmark/query_commitments.rs | 4 +- .../src/tests/channel_upgrade/flushing.rs | 33 +++++- .../src/tests/channel_upgrade/ics29.rs | 16 ++- .../src/tests/channel_upgrade/timeout.rs | 30 ++++- .../src/tests/clean_workers.rs | 10 +- .../src/tests/clear_packet.rs | 63 +++++++++-- .../src/tests/client_expiration.rs | 10 +- .../src/tests/connection_delay.rs | 10 +- .../integration-test/src/tests/denom_trace.rs | 10 +- .../src/tests/dynamic_gas_fee.rs | 20 +++- .../src/tests/error_events.rs | 10 +- .../src/tests/execute_schedule.rs | 10 +- .../src/tests/fee/auto_forward_relayer.rs | 10 +- .../src/tests/fee/filter_fees.rs | 30 ++++- .../src/tests/fee/forward_relayer.rs | 10 +- .../src/tests/fee/no_forward_relayer.rs | 20 +++- .../src/tests/fee/non_fee_channel.rs | 13 ++- .../src/tests/fee/pay_fee_async.rs | 10 +- .../src/tests/fee/register_payee.rs | 10 +- .../src/tests/fee/timeout_fee.rs | 10 +- tools/integration-test/src/tests/fee_grant.rs | 20 +++- .../src/tests/forward/forward_hop_transfer.rs | 20 +++- .../src/tests/forward/forward_transfer.rs | 45 ++++++-- .../src/tests/ics20_filter/memo.rs | 13 ++- tools/integration-test/src/tests/ics31.rs | 10 +- .../interchain_security/dynamic_gas_fee.rs | 20 +++- .../src/tests/interchain_security/icq.rs | 10 +- .../interchain_security/simple_transfer.rs | 20 +++- .../src/tests/manual/simulation.rs | 11 +- tools/integration-test/src/tests/memo.rs | 20 +++- .../src/tests/ordered_channel.rs | 13 ++- .../src/tests/ordered_channel_clear.rs | 25 ++++- .../src/tests/query_packet.rs | 20 +++- .../src/tests/sequence_filter.rs | 91 ++++++++++++++-- .../integration-test/src/tests/supervisor.rs | 12 +- .../src/tests/ternary_transfer.rs | 40 ++++++- tools/integration-test/src/tests/transfer.rs | 40 ++++++- tools/test-framework/src/chain/ext/fee.rs | 8 +- .../test-framework/src/chain/ext/transfer.rs | 59 +++------- tools/test-framework/src/relayer/fee.rs | 5 +- tools/test-framework/src/relayer/transfer.rs | 103 +++--------------- 41 files changed, 722 insertions(+), 222 deletions(-) diff --git a/tools/integration-test/src/tests/benchmark/query_commitments.rs b/tools/integration-test/src/tests/benchmark/query_commitments.rs index b05b02f5c4..8d8f816d68 100644 --- a/tools/integration-test/src/tests/benchmark/query_commitments.rs +++ b/tools/integration-test/src/tests/benchmark/query_commitments.rs @@ -1,3 +1,4 @@ +use ibc_relayer::channel::version::Version; use ibc_test_framework::prelude::*; #[test] @@ -64,9 +65,10 @@ impl BinaryChannelTest for QueryCommitmentsBenchmark { chains.node_a.chain_driver().ibc_transfer_token_multiple( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + &Version::ics20(1), &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], num_msgs as usize, None, )?; diff --git a/tools/integration-test/src/tests/channel_upgrade/flushing.rs b/tools/integration-test/src/tests/channel_upgrade/flushing.rs index e54feeac5a..5eabcdc4e7 100644 --- a/tools/integration-test/src/tests/channel_upgrade/flushing.rs +++ b/tools/integration-test/src/tests/channel_upgrade/flushing.rs @@ -114,12 +114,20 @@ impl BinaryChannelTest for ChannelUpgradeFlushing { let send_amount = random_u128_range(1000, 2000); + let channel_version_a = channels.channel.a_side.version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{}`", + channels.channel_id_a + )) + })?; + chain_driver_a.ibc_transfer_token( &port_a, &channel_id_a, + channel_version_a, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![denom_a.with_amount(send_amount).as_ref()], )?; sleep(Duration::from_secs(3)); @@ -127,9 +135,10 @@ impl BinaryChannelTest for ChannelUpgradeFlushing { chain_driver_a.ibc_transfer_token( &port_a, &channel_id_a, + &Version::ics20(1), &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![denom_a.with_amount(send_amount).as_ref()], )?; let old_ordering = channel_end_a.ordering; @@ -316,12 +325,20 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { denom_a ); + let channel_version_a = channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; // send a IBC transfer message from chain b to chain a @@ -338,12 +355,20 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { denom_b ); + let channel_version_b = channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.dst_channel_id() + )) + })?; + chains.node_b.chain_driver().ibc_transfer_token( &channels.port_b.as_ref(), &channels.channel_id_b.as_ref(), + channel_version_b, &wallet_b.as_ref(), &wallet_a.address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; info!("Will run ChanUpgradeTry step..."); diff --git a/tools/integration-test/src/tests/channel_upgrade/ics29.rs b/tools/integration-test/src/tests/channel_upgrade/ics29.rs index 5775bb97be..b3a1e7edf2 100644 --- a/tools/integration-test/src/tests/channel_upgrade/ics29.rs +++ b/tools/integration-test/src/tests/channel_upgrade/ics29.rs @@ -114,12 +114,22 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { let balance_a2 = balance_a1 - total_sent; + let channel = channels.channel.clone(); + + let channel_version_a = channels.channel.a_side.version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{}`", + channels.channel_id_a + )) + })?; + let ics29_transfer = chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version_a, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), @@ -132,7 +142,6 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { 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(1); let upgraded_attrs = ChannelUpgradableAttributes::new( @@ -192,9 +201,10 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version_a, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), diff --git a/tools/integration-test/src/tests/channel_upgrade/timeout.rs b/tools/integration-test/src/tests/channel_upgrade/timeout.rs index 033b31402e..fc40ec6492 100644 --- a/tools/integration-test/src/tests/channel_upgrade/timeout.rs +++ b/tools/integration-test/src/tests/channel_upgrade/timeout.rs @@ -451,12 +451,20 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { denom_a ); + let channel_version_a = channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; info!("Will run ChanUpgradeAck step..."); @@ -627,12 +635,20 @@ impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { denom_a ); + let channel_version_a = channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; info!("Will run ChanUpgradeAck step..."); @@ -936,15 +952,23 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck { denom_a ); + let channel_version_a = channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.src_channel_id() + )) + })?; + chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], None, Some(Duration::from_secs(600)), )?; diff --git a/tools/integration-test/src/tests/clean_workers.rs b/tools/integration-test/src/tests/clean_workers.rs index b69637780a..e9cd2a1884 100644 --- a/tools/integration-test/src/tests/clean_workers.rs +++ b/tools/integration-test/src/tests/clean_workers.rs @@ -57,13 +57,21 @@ impl BinaryChannelTest for CleanPacketWorkersTest { let supervisor = relayer.spawn_supervisor()?; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + // Transfer tokens so that the packet workers are spawned chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(amount1).as_ref(), + &vec![denom_a.with_amount(amount1).as_ref()], )?; // Assert the packet workers are correctly spawned diff --git a/tools/integration-test/src/tests/clear_packet.rs b/tools/integration-test/src/tests/clear_packet.rs index cf09b6dbad..bf837c669d 100644 --- a/tools/integration-test/src/tests/clear_packet.rs +++ b/tools/integration-test/src/tests/clear_packet.rs @@ -91,12 +91,20 @@ impl BinaryChannelTest for DisabledClearPacketTest { amount1 ); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &amount1.as_ref(), + &vec![amount1.as_ref()], )?; sleep(Duration::from_secs(1)); @@ -115,9 +123,10 @@ impl BinaryChannelTest for DisabledClearPacketTest { chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &amount2.as_ref(), + &vec![amount2.as_ref()], )?; sleep(Duration::from_secs(1)); @@ -181,12 +190,20 @@ impl BinaryChannelTest for ClearPacketRecoveryTest { let amount1 = random_u128_range(1000, 5000); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(amount1).as_ref(), + &vec![denom_a.with_amount(amount1).as_ref()], )?; let denom_b2 = derive_ibc_denom( @@ -245,12 +262,20 @@ impl BinaryChannelTest for ClearPacketNoScanTest { .chain_driver() .query_balance(&wallet_a.address(), &denom_a)?; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(amount1).as_ref(), + &vec![denom_a.with_amount(amount1).as_ref()], )?; let denom_b2 = derive_ibc_denom( @@ -365,12 +390,20 @@ impl BinaryChannelTest for ClearPacketOverrideTest { .chain_driver() .query_balance(&wallet_a.address(), &denom_a)?; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(amount1).as_ref(), + &vec![denom_a.with_amount(amount1).as_ref()], )?; let denom_b2 = derive_ibc_denom( @@ -466,12 +499,20 @@ impl BinaryChannelTest for ClearPacketSequencesTest { info!("Performing {NUM_TRANSFERS} IBC transfer, which should *not* be relayed"); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token_multiple( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &amount.as_ref(), + &vec![amount.as_ref()], NUM_TRANSFERS, None, )?; @@ -643,12 +684,20 @@ impl BinaryChannelTest for LimitedClearPacketTest { info!("Performing {num_transfers} IBC transfers with amount {amount}, for a total of {sent_amount}"); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token_multiple( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &amount.as_ref(), + &vec![amount.as_ref()], 70, None, )?; diff --git a/tools/integration-test/src/tests/client_expiration.rs b/tools/integration-test/src/tests/client_expiration.rs index 082cacf70a..96029d84e3 100644 --- a/tools/integration-test/src/tests/client_expiration.rs +++ b/tools/integration-test/src/tests/client_expiration.rs @@ -297,12 +297,20 @@ impl BinaryChainTest for PacketExpirationTest { )? }; + let channel_version = channels.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), - &chains.node_a.denom().with_amount(100u64).as_ref(), + &vec![chains.node_a.denom().with_amount(100u64).as_ref()], )?; wait_for_client_expiry(); diff --git a/tools/integration-test/src/tests/connection_delay.rs b/tools/integration-test/src/tests/connection_delay.rs index 0c8ca19e57..d4ec475a1f 100644 --- a/tools/integration-test/src/tests/connection_delay.rs +++ b/tools/integration-test/src/tests/connection_delay.rs @@ -47,12 +47,20 @@ impl BinaryChannelTest for ConnectionDelayTest { denom_a ); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let time1 = OffsetDateTime::now_utc(); diff --git a/tools/integration-test/src/tests/denom_trace.rs b/tools/integration-test/src/tests/denom_trace.rs index 3c56efbdcb..b72a4ed3bd 100644 --- a/tools/integration-test/src/tests/denom_trace.rs +++ b/tools/integration-test/src/tests/denom_trace.rs @@ -31,12 +31,20 @@ impl BinaryChannelTest for IbcDenomTraceTest { .chain_driver() .query_balance(&wallet_a.address(), &denom_a)?; + let channel_version = channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_b = derive_ibc_denom( diff --git a/tools/integration-test/src/tests/dynamic_gas_fee.rs b/tools/integration-test/src/tests/dynamic_gas_fee.rs index 3e30ec468d..e6544cab05 100644 --- a/tools/integration-test/src/tests/dynamic_gas_fee.rs +++ b/tools/integration-test/src/tests/dynamic_gas_fee.rs @@ -101,15 +101,23 @@ impl BinaryChannelTest for DynamicGasTest { let memo: String = MEMO_CHAR.repeat(MEMO_SIZE); + let channel_version_a = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], Some(memo), None, )?; @@ -158,12 +166,20 @@ impl BinaryChannelTest for DynamicGasTest { &gas_denom_a.as_ref(), )?; + let channel_version_b = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + chains.node_b.chain_driver().ibc_transfer_token( &channel.port_b.as_ref(), &channel.channel_id_b.as_ref(), + channel_version_b, &chains.node_b.wallets().user1(), &chains.node_a.wallets().user1().address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; let tx2_paid_gas_relayer = relayer.with_supervisor(|| { diff --git a/tools/integration-test/src/tests/error_events.rs b/tools/integration-test/src/tests/error_events.rs index 24602d0122..0ade1275b3 100644 --- a/tools/integration-test/src/tests/error_events.rs +++ b/tools/integration-test/src/tests/error_events.rs @@ -36,12 +36,20 @@ impl BinaryChannelTest for ErrorEventsTest { let balance_a_amount: u128 = balance_a.value().amount.0.as_u128(); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + let transfer_message = build_transfer_message( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount((balance_a_amount / 3) + 1).as_ref(), + &vec![denom_a.with_amount((balance_a_amount / 3) + 1).as_ref()], Duration::from_secs(30), None, )?; diff --git a/tools/integration-test/src/tests/execute_schedule.rs b/tools/integration-test/src/tests/execute_schedule.rs index 163439afad..c00cf8e10f 100644 --- a/tools/integration-test/src/tests/execute_schedule.rs +++ b/tools/integration-test/src/tests/execute_schedule.rs @@ -62,14 +62,22 @@ impl BinaryChannelTest for ExecuteScheduleTest { let mut relay_path_a_to_b = chain_a_link.a_to_b; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + // Construct `BATCH_SIZE` pieces of operational data and queue them up to be sent to chain B. for i in 0..BATCH_SIZE { chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), - &chains.node_a.denom().with_amount(amount1).as_ref(), + &vec![chains.node_a.denom().with_amount(amount1).as_ref()], )?; relay_path_a_to_b 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 55c9e36373..8aabd1d739 100644 --- a/tools/integration-test/src/tests/fee/auto_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/auto_forward_relayer.rs @@ -63,12 +63,20 @@ impl BinaryChannelTest for AutoForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), diff --git a/tools/integration-test/src/tests/fee/filter_fees.rs b/tools/integration-test/src/tests/fee/filter_fees.rs index 2b30e778c4..7156acbb7d 100644 --- a/tools/integration-test/src/tests/fee/filter_fees.rs +++ b/tools/integration-test/src/tests/fee/filter_fees.rs @@ -79,12 +79,20 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { let balance_a2 = balance_a1.clone() - send_amount; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![denom_a.with_amount(send_amount).as_ref()], &denom_a.with_amount(receive_fee_fail).as_ref(), &denom_a.with_amount(ack_fee).as_ref(), &denom_a.with_amount(timeout_fee).as_ref(), @@ -128,12 +136,20 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![denom_a.with_amount(send_amount).as_ref()], &denom_a.with_amount(receive_fee_success).as_ref(), &denom_a.with_amount(ack_fee).as_ref(), &denom_a.with_amount(timeout_fee).as_ref(), @@ -234,12 +250,20 @@ impl BinaryChannelTest for FilterByChannelIncentivizedFeesRelayerTest { info!("Verify that packet without enough fees is not relayed"); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), diff --git a/tools/integration-test/src/tests/fee/forward_relayer.rs b/tools/integration-test/src/tests/fee/forward_relayer.rs index ee6addfa68..93479910d6 100644 --- a/tools/integration-test/src/tests/fee/forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/forward_relayer.rs @@ -102,12 +102,20 @@ impl BinaryChannelTest for ForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), 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 f09ac98d64..c77e09ace6 100644 --- a/tools/integration-test/src/tests/fee/no_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/no_forward_relayer.rs @@ -80,12 +80,20 @@ impl BinaryChannelTest for NoForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), @@ -166,12 +174,20 @@ impl BinaryChannelTest for InvalidForwardRelayerTest { &port_b, )?; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), diff --git a/tools/integration-test/src/tests/fee/non_fee_channel.rs b/tools/integration-test/src/tests/fee/non_fee_channel.rs index b7b026ae3a..687fa17dc6 100644 --- a/tools/integration-test/src/tests/fee/non_fee_channel.rs +++ b/tools/integration-test/src/tests/fee/non_fee_channel.rs @@ -66,13 +66,21 @@ impl BinaryChannelTest for NonFeeChannelTest { assert!(res.is_err()); } + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + { let res = chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![denom_a.with_amount(send_amount).as_ref()], &denom_a.with_amount(10u64).as_ref(), &denom_a.with_amount(10u64).as_ref(), &denom_a.with_amount(10u64).as_ref(), @@ -87,9 +95,10 @@ impl BinaryChannelTest for NonFeeChannelTest { chain_driver_a.ibc_transfer_token( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![denom_a.with_amount(send_amount).as_ref()], )?; let denom_b = derive_ibc_denom( 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 a3a33c4a5d..e467f59075 100644 --- a/tools/integration-test/src/tests/fee/pay_fee_async.rs +++ b/tools/integration-test/src/tests/fee/pay_fee_async.rs @@ -96,12 +96,20 @@ impl BinaryChannelTest for PayPacketFeeAsyncTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + let events = chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), diff --git a/tools/integration-test/src/tests/fee/register_payee.rs b/tools/integration-test/src/tests/fee/register_payee.rs index 45da6e16de..4921766d66 100644 --- a/tools/integration-test/src/tests/fee/register_payee.rs +++ b/tools/integration-test/src/tests/fee/register_payee.rs @@ -117,12 +117,20 @@ impl BinaryChannelTest for ForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), diff --git a/tools/integration-test/src/tests/fee/timeout_fee.rs b/tools/integration-test/src/tests/fee/timeout_fee.rs index b960ab4d88..70c6542e45 100644 --- a/tools/integration-test/src/tests/fee/timeout_fee.rs +++ b/tools/integration-test/src/tests/fee/timeout_fee.rs @@ -60,12 +60,20 @@ impl BinaryChannelTest for TimeoutFeeTest { let balance_a2 = balance_a1 - total_sent; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chain_driver_a.ibc_token_transfer_with_fee( &port_a, &channel_id_a, + channel_version, &user_a, &user_b.address(), - &denom_a.with_amount(send_amount).as_ref(), + &vec![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(), diff --git a/tools/integration-test/src/tests/fee_grant.rs b/tools/integration-test/src/tests/fee_grant.rs index a936c02e20..d67b8ad67a 100644 --- a/tools/integration-test/src/tests/fee_grant.rs +++ b/tools/integration-test/src/tests/fee_grant.rs @@ -122,12 +122,20 @@ impl BinaryChannelTest for FeeGrantTest { let md: MonoTagged = MonoTagged::new(&modified_driver); + let channel_version = channels.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.src_channel_id() + )) + })?; + md.ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; thread::sleep(Duration::from_secs(10)); @@ -238,12 +246,20 @@ impl BinaryChannelTest for NoFeeGrantTest { &gas_denom.as_ref(), )?; + let channel_version = channels.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; thread::sleep(Duration::from_secs(10)); diff --git a/tools/integration-test/src/tests/forward/forward_hop_transfer.rs b/tools/integration-test/src/tests/forward/forward_hop_transfer.rs index f42376c5b7..e6fbfdb0c5 100644 --- a/tools/integration-test/src/tests/forward/forward_hop_transfer.rs +++ b/tools/integration-test/src/tests/forward/forward_hop_transfer.rs @@ -118,14 +118,22 @@ impl NaryChannelTest<4> for IbcForwardHopTransferTest { ); let memo = serde_json::to_string(&memo_field).unwrap(); + let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_a_to_b.channel.src_channel_id() + )) + })?; + node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_d_amount).as_ref(), + &vec![denom_a.with_amount(a_to_d_amount).as_ref()], Some(memo), None, )?; @@ -239,14 +247,22 @@ impl NaryChannelTest<4> for AtomicIbcForwardHopTransferTest { ); let memo = serde_json::to_string(&memo_field).unwrap(); + let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_a_to_b.channel.src_channel_id() + )) + })?; + node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_d_amount).as_ref(), + &vec![denom_a.with_amount(a_to_d_amount).as_ref()], Some(memo), None, )?; diff --git a/tools/integration-test/src/tests/forward/forward_transfer.rs b/tools/integration-test/src/tests/forward/forward_transfer.rs index a9569c8528..d9fc63deb8 100644 --- a/tools/integration-test/src/tests/forward/forward_transfer.rs +++ b/tools/integration-test/src/tests/forward/forward_transfer.rs @@ -124,14 +124,22 @@ impl NaryChannelTest<3> for IbcForwardTransferTest { ); let memo = serde_json::to_string(&memo_field).unwrap(); + let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_a_to_b.channel.src_channel_id() + )) + })?; + node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo), None, )?; @@ -256,6 +264,13 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { ); let memo4 = serde_json::to_string(&memo_invalid_field).unwrap(); + let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_a_to_b.channel.src_channel_id() + )) + })?; + { info!("forward transfer with invalid `port` field"); @@ -264,9 +279,10 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo1), None, )?; @@ -301,9 +317,10 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo2), None, )?; @@ -338,9 +355,10 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo3), None, )?; @@ -375,9 +393,10 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo4), None, )?; @@ -490,6 +509,13 @@ impl NaryChannelTest<3> for MisspelledMemoContentIbcForwardTransferTest { ); let memo3 = serde_json::to_string(&memo_misspelled_receiver).unwrap(); + let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_a_to_b.channel.src_channel_id() + )) + })?; + { info!("forward transfer with invalid port"); @@ -498,9 +524,10 @@ impl NaryChannelTest<3> for MisspelledMemoContentIbcForwardTransferTest { .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo2), None, )?; @@ -536,9 +563,10 @@ impl NaryChannelTest<3> for MisspelledMemoContentIbcForwardTransferTest { .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo3), None, )?; @@ -574,9 +602,10 @@ impl NaryChannelTest<3> for MisspelledMemoContentIbcForwardTransferTest { .ibc_transfer_token_with_memo_and_timeout( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a, &wallet_b.address(), - &denom_a.with_amount(a_to_c_amount).as_ref(), + &vec![denom_a.with_amount(a_to_c_amount).as_ref()], Some(memo1), None, )?; diff --git a/tools/integration-test/src/tests/ics20_filter/memo.rs b/tools/integration-test/src/tests/ics20_filter/memo.rs index 0ec207af37..4dc99dfc89 100644 --- a/tools/integration-test/src/tests/ics20_filter/memo.rs +++ b/tools/integration-test/src/tests/ics20_filter/memo.rs @@ -52,15 +52,23 @@ impl BinaryChannelTest for IbcMemoFilterTest { // Create a memo bigger than the allowed limit let memo = "a".repeat(MEMO_SIZE_LIMIT + 1); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], Some(memo), None, )?; @@ -96,9 +104,10 @@ impl BinaryChannelTest for IbcMemoFilterTest { .ibc_transfer_token_with_memo_and_timeout( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], None, None, )?; diff --git a/tools/integration-test/src/tests/ics31.rs b/tools/integration-test/src/tests/ics31.rs index 33065dc091..02e80ba960 100644 --- a/tools/integration-test/src/tests/ics31.rs +++ b/tools/integration-test/src/tests/ics31.rs @@ -92,12 +92,20 @@ impl BinaryChannelTest for ICS31Test { denom_a ); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_b = derive_ibc_denom( diff --git a/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs b/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs index 3d2f217554..8aff0b7e83 100644 --- a/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs +++ b/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs @@ -138,15 +138,23 @@ impl BinaryChannelTest for DynamicGasTest { let memo: String = MEMO_CHAR.repeat(MEMO_SIZE); + let channel_version_a = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], Some(memo), None, )?; @@ -197,12 +205,20 @@ impl BinaryChannelTest for DynamicGasTest { info!("Will ibc transfer"); + let channel_version_b = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + chains.node_b.chain_driver().ibc_transfer_token( &channel.port_b.as_ref(), &channel.channel_id_b.as_ref(), + channel_version_b, &chains.node_b.wallets().user1(), &chains.node_a.wallets().user1().address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; info!("Done ibc transfer"); diff --git a/tools/integration-test/src/tests/interchain_security/icq.rs b/tools/integration-test/src/tests/interchain_security/icq.rs index 19f2a84efb..3305df4659 100644 --- a/tools/integration-test/src/tests/interchain_security/icq.rs +++ b/tools/integration-test/src/tests/interchain_security/icq.rs @@ -121,12 +121,20 @@ impl BinaryChannelTest for InterchainSecurityIcqTest { denom_a ); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_b = derive_ibc_denom( diff --git a/tools/integration-test/src/tests/interchain_security/simple_transfer.rs b/tools/integration-test/src/tests/interchain_security/simple_transfer.rs index 05317917ed..e63b44b3a3 100644 --- a/tools/integration-test/src/tests/interchain_security/simple_transfer.rs +++ b/tools/integration-test/src/tests/interchain_security/simple_transfer.rs @@ -60,12 +60,20 @@ impl BinaryChannelTest for InterchainSecurityTransferTest { denom_a ); + let channel_version_a = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_b = derive_ibc_denom( @@ -111,12 +119,20 @@ impl BinaryChannelTest for InterchainSecurityTransferTest { b_to_a_amount, ); + let channel_version_b = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + chains.node_b.chain_driver().ibc_transfer_token( &channel.port_b.as_ref(), &channel.channel_id_b.as_ref(), + channel_version_b, &wallet_b.as_ref(), &wallet_c.address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; chains.node_b.chain_driver().assert_eventual_wallet_amount( diff --git a/tools/integration-test/src/tests/manual/simulation.rs b/tools/integration-test/src/tests/manual/simulation.rs index 30c801bfcf..3f033bab28 100644 --- a/tools/integration-test/src/tests/manual/simulation.rs +++ b/tools/integration-test/src/tests/manual/simulation.rs @@ -86,11 +86,18 @@ fn tx_raw_ft_transfer( number_messages: usize, memo: Option, ) -> Result, Error> { + let tokens = vec![(amount.into(), denom.value().to_string())]; + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; let transfer_options = TransferOptions { src_port_id: channel.port_a.value().clone(), src_channel_id: channel.channel_id_a.value().clone(), - amount: amount.into(), - denom: denom.value().to_string(), + channel_version: channel_version.clone(), + tokens, receiver: Some(recipient.value().0.clone()), timeout_height_offset, timeout_duration, diff --git a/tools/integration-test/src/tests/memo.rs b/tools/integration-test/src/tests/memo.rs index cf59bb712d..abf2ab7948 100644 --- a/tools/integration-test/src/tests/memo.rs +++ b/tools/integration-test/src/tests/memo.rs @@ -60,12 +60,20 @@ impl BinaryChannelTest for MemoTest { let a_to_b_amount = random_u128_range(1000, 5000); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_b = derive_ibc_denom( @@ -124,12 +132,20 @@ impl BinaryChannelTest for MemoOverwriteTest { let a_to_b_amount = random_u128_range(1000, 5000); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_b = derive_ibc_denom( diff --git a/tools/integration-test/src/tests/ordered_channel.rs b/tools/integration-test/src/tests/ordered_channel.rs index a72126d3f2..e297e556be 100644 --- a/tools/integration-test/src/tests/ordered_channel.rs +++ b/tools/integration-test/src/tests/ordered_channel.rs @@ -65,12 +65,20 @@ impl BinaryChannelTest for OrderedChannelTest { amount1 ); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(amount1).as_ref(), + &vec![denom_a.with_amount(amount1).as_ref()], )?; sleep(Duration::from_secs(2)); @@ -86,9 +94,10 @@ impl BinaryChannelTest for OrderedChannelTest { chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(amount2).as_ref(), + &vec![denom_a.with_amount(amount2).as_ref()], )?; sleep(Duration::from_secs(1)); diff --git a/tools/integration-test/src/tests/ordered_channel_clear.rs b/tools/integration-test/src/tests/ordered_channel_clear.rs index ed6e124e64..1f82c80a31 100644 --- a/tools/integration-test/src/tests/ordered_channel_clear.rs +++ b/tools/integration-test/src/tests/ordered_channel_clear.rs @@ -103,13 +103,20 @@ impl BinaryChannelTest for OrderedChannelClearTest { "Performing {} IBC transfers with amount {} on an ordered channel", num_msgs, amount ); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; chains.node_a.chain_driver().ibc_transfer_token_multiple( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &token.as_ref(), + &vec![token.as_ref()], num_msgs, None, )?; @@ -245,11 +252,23 @@ impl BinaryChannelTest for OrderedChannelClearEqualCLITest { num_msgs ); + let channel_version = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + + let tokens = vec![( + random_u64_range(1000, 5000).into(), + chains.node_a.denom().value().to_string(), + )]; + let transfer_options = TransferOptions { src_port_id: channel.port_a.value().clone(), src_channel_id: channel.channel_id_a.value().clone(), - amount: random_u64_range(1000, 5000).into(), - denom: chains.node_a.denom().value().to_string(), + channel_version: channel_version.clone(), + tokens, receiver: Some(chains.node_b.wallets().user1().address().value().0.clone()), timeout_height_offset: 1000, timeout_duration: Duration::from_secs(0), diff --git a/tools/integration-test/src/tests/query_packet.rs b/tools/integration-test/src/tests/query_packet.rs index 7bd3f7ad1b..5f04da0201 100644 --- a/tools/integration-test/src/tests/query_packet.rs +++ b/tools/integration-test/src/tests/query_packet.rs @@ -48,12 +48,20 @@ impl BinaryChannelTest for QueryPacketPendingTest { amount1 ); + let channel_version_a = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(amount1).as_ref(), + &vec![denom_a.with_amount(amount1).as_ref()], )?; sleep(Duration::from_secs(2)); @@ -136,12 +144,20 @@ impl BinaryChannelTest for QueryPacketPendingTest { let denom_b = chains.node_b.denom(); let amount2 = random_u128_range(1000, 5000); + let channel_version_b = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + chains.node_b.chain_driver().ibc_transfer_token( &channel.port_b.as_ref(), &channel.channel_id_b.as_ref(), + channel_version_b, &wallet_b.as_ref(), &wallet_a.address(), - &denom_b.with_amount(amount2).as_ref(), + &vec![denom_b.with_amount(amount2).as_ref()], )?; info!( diff --git a/tools/integration-test/src/tests/sequence_filter.rs b/tools/integration-test/src/tests/sequence_filter.rs index a880f7720e..d704d6ce39 100644 --- a/tools/integration-test/src/tests/sequence_filter.rs +++ b/tools/integration-test/src/tests/sequence_filter.rs @@ -17,8 +17,8 @@ use std::collections::BTreeMap; -use ibc_relayer::config::ChainConfig; use ibc_relayer::util::excluded_sequences::ExcludedSequences; +use ibc_relayer::{channel::version::Version, config::ChainConfig}; use ibc_test_framework::{ prelude::*, relayer::channel::{assert_eventually_channel_established, init_channel}, @@ -172,40 +172,58 @@ impl BinaryChannelTest for ClearNoFilterTest { .chain_driver() .query_balance(&wallet_b.address(), &denom_b)?; + let channel_version = channels.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.src_channel_id() + )) + })?; + // Create a pending transfer from A to B with sequence 1 chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; // Create a pending transfer from A to B with sequence 2 chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; + let channel_version = channels.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.dst_channel_id() + )) + })?; + // Create a pending transfer from B to A with sequence 1 chains.node_b.chain_driver().ibc_transfer_token( &channels.port_b.as_ref(), &channels.channel_id_b.as_ref(), + channel_version, &wallet_b.as_ref(), &wallet_a.address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; // Create a pending transfer from B to A with sequence 2 chains.node_b.chain_driver().ibc_transfer_token( &channels.port_b.as_ref(), &channels.channel_id_b.as_ref(), + channel_version, &wallet_b.as_ref(), &wallet_a.address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; relayer.with_supervisor(|| { @@ -298,40 +316,58 @@ impl BinaryChannelTest for StandardRelayingNoFilterTest { .chain_driver() .query_balance(&wallet_b.address(), &denom_b)?; + let channel_version = channels.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.src_channel_id() + )) + })?; + // Create a pending transfer from A to B with sequence 1 chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; // Create a pending transfer from A to B with sequence 2 chains.node_a.chain_driver().ibc_transfer_token( &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; + let channel_version = channels.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.dst_channel_id() + )) + })?; + // Create a pending transfer from B to A with sequence 1 chains.node_b.chain_driver().ibc_transfer_token( &channels.port_b.as_ref(), &channels.channel_id_b.as_ref(), + channel_version, &wallet_b.as_ref(), &wallet_a.address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; // Create a pending transfer from B to A with sequence 2 chains.node_b.chain_driver().ibc_transfer_token( &channels.port_b.as_ref(), &channels.channel_id_b.as_ref(), + channel_version, &wallet_b.as_ref(), &wallet_a.address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; info!("Assert that the send from A escrowed tokens for both transfers"); @@ -452,11 +488,19 @@ fn run_sequence_filter_test( .chain_driver() .query_balance(&wallet_b_2.address(), &denom_b)?; + let channel_version = channels.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.src_channel_id() + )) + })?; + // Double transfer from A to B on channel with filter double_transfer( chains.node_a.chain_driver(), &channels.port_a.as_ref(), &channels.channel_id_a.as_ref(), + channel_version, &wallet_a_1.as_ref(), &wallet_b_1.address(), &denom_a.with_amount(a_to_b_amount).as_ref(), @@ -467,11 +511,19 @@ fn run_sequence_filter_test( let port_a_2: DualTagged = DualTagged::new(channel_b_2.clone().flipped().a_side.port_id().clone()); + let channel_version_2 = channel_b_2.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channels.channel.src_channel_id() + )) + })?; + // Double transfer from A to B on channel without filter double_transfer( chains.node_a.chain_driver(), &port_a_2.as_ref(), &channel_id_a_2.as_ref(), + channel_version_2, &wallet_a_2.as_ref(), &wallet_b_2.address(), &denom_a.with_amount(a_to_b_amount).as_ref(), @@ -482,6 +534,7 @@ fn run_sequence_filter_test( chains.node_b.chain_driver(), &channels.port_b.as_ref(), &channels.channel_id_b.as_ref(), + channel_version, &wallet_b_1.as_ref(), &wallet_a_1.address(), &denom_b.with_amount(b_to_a_amount).as_ref(), @@ -492,6 +545,7 @@ fn run_sequence_filter_test( chains.node_b.chain_driver(), &port_b_2, &channel_id_b_2.as_ref(), + channel_version_2, &wallet_b_2.as_ref(), &wallet_a_2.address(), &denom_b.with_amount(b_to_a_amount).as_ref(), @@ -556,15 +610,30 @@ fn double_transfer( chain_driver: MonoTagged, port_id: &TaggedPortIdRef, channel_id: &TaggedChannelIdRef, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, token: &TaggedTokenRef, ) -> Result<(), Error> { // Create a pending transfer from B to A with sequence 1 - chain_driver.ibc_transfer_token(port_id, channel_id, sender, recipient, token)?; + chain_driver.ibc_transfer_token( + port_id, + channel_id, + channel_version, + sender, + recipient, + vec![token], + )?; // Create a pending transfer from B to A with sequence 2 - chain_driver.ibc_transfer_token(port_id, channel_id, sender, recipient, token)?; + chain_driver.ibc_transfer_token( + port_id, + channel_id, + channel_version, + sender, + recipient, + vec![token], + )?; Ok(()) } diff --git a/tools/integration-test/src/tests/supervisor.rs b/tools/integration-test/src/tests/supervisor.rs index 17ee1b5af7..ffbf9d768d 100644 --- a/tools/integration-test/src/tests/supervisor.rs +++ b/tools/integration-test/src/tests/supervisor.rs @@ -75,7 +75,7 @@ impl BinaryChainTest for SupervisorTest { let port_a = tagged_transfer_port(); let port_b = tagged_transfer_port(); - let (channel_id_b, _) = init_channel( + let (channel_id_b, channel) = init_channel( &chains.handle_a, &chains.handle_b, &chains.client_id_a(), @@ -134,12 +134,20 @@ impl BinaryChainTest for SupervisorTest { denom_a ); + let channel_version = channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &port_a.as_ref(), &channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(1000u64).as_ref(), + &vec![denom_a.with_amount(1000u64).as_ref()], )?; // During the test, you should see error logs showing "account sequence mismatch". diff --git a/tools/integration-test/src/tests/ternary_transfer.rs b/tools/integration-test/src/tests/ternary_transfer.rs index 527c085629..95fcad11df 100644 --- a/tools/integration-test/src/tests/ternary_transfer.rs +++ b/tools/integration-test/src/tests/ternary_transfer.rs @@ -57,12 +57,20 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { denom_a ); + let channel_version = channel_a_to_b.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_a_to_b.src_channel_id() + )) + })?; + node_a.chain_driver().ibc_transfer_token( &channel_a_to_b.port_a.as_ref(), &channel_a_to_b.channel_id_a.as_ref(), + channel_version, &wallet_a1.as_ref(), &wallet_b1.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_a_to_b = derive_ibc_denom( @@ -104,12 +112,20 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { let b_to_c_amount = 2500; + let channel_version = channel_b_to_c.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_b_to_c.src_channel_id() + )) + })?; + node_b.chain_driver().ibc_transfer_token( &channel_b_to_c.port_a.as_ref(), &channel_b_to_c.channel_id_a.as_ref(), + channel_version, &wallet_b1.as_ref(), &wallet_c1.address(), - &denom_a_to_b.with_amount(b_to_c_amount).as_ref(), + &vec![denom_a_to_b.with_amount(b_to_c_amount).as_ref()], )?; // Chain C will receive ibc/port-c/channel-c/port-b/channel-b/denom @@ -141,12 +157,20 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { let c_to_a_amount = 800; + let channel_version = channel_c_to_a.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_c_to_a.src_channel_id() + )) + })?; + node_c.chain_driver().ibc_transfer_token( &channel_c_to_a.port_a.as_ref(), &channel_c_to_a.channel_id_a.as_ref(), + channel_version, &wallet_c1.as_ref(), &wallet_a1.address(), - &denom_a_to_c.with_amount(c_to_a_amount).as_ref(), + &vec![denom_a_to_c.with_amount(c_to_a_amount).as_ref()], )?; // Chain A will receive ibc/port-a/channel-a/port-c/channel-c/port-b/channel-b/denom @@ -170,12 +194,20 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { let c_to_b_amount = 500; + let channel_version = channel_c_to_a.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel_c_to_a.src_channel_id() + )) + })?; + node_c.chain_driver().ibc_transfer_token( &channel_b_to_c.port_b.as_ref(), &channel_b_to_c.channel_id_b.as_ref(), + channel_version, &wallet_c1.as_ref(), &wallet_b2.address(), - &denom_a_to_c.with_amount(c_to_b_amount).as_ref(), + &vec![denom_a_to_c.with_amount(c_to_b_amount).as_ref()], )?; // Chain B will receive ibc/port-b/channel-b/denom diff --git a/tools/integration-test/src/tests/transfer.rs b/tools/integration-test/src/tests/transfer.rs index e477b72c91..09eab4215a 100644 --- a/tools/integration-test/src/tests/transfer.rs +++ b/tools/integration-test/src/tests/transfer.rs @@ -83,12 +83,20 @@ impl BinaryChannelTest for IbcTransferTest { denom_a ); + let channel_version_a = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(a_to_b_amount).as_ref(), + &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; let denom_b = derive_ibc_denom( @@ -132,12 +140,20 @@ impl BinaryChannelTest for IbcTransferTest { b_to_a_amount, ); + let channel_version_b = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + chains.node_b.chain_driver().ibc_transfer_token( &channel.port_b.as_ref(), &channel.channel_id_b.as_ref(), + channel_version_b, &wallet_b.as_ref(), &wallet_c.address(), - &denom_b.with_amount(b_to_a_amount).as_ref(), + &vec![denom_b.with_amount(b_to_a_amount).as_ref()], )?; chains.node_b.chain_driver().assert_eventual_wallet_amount( @@ -213,9 +229,17 @@ impl BinaryChannelTest for IbcTransferICS20V2Test { let token_denom_a = denom_a.with_amount(a_to_b_amount_denom_a); let token_other_denom = other_denom.with_amount(a_to_b_amount_other_denom); - chains.node_a.chain_driver().ibc_transfer_token_v2( + let channel_version_a = channel.channel.src_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.src_channel_id() + )) + })?; + + chains.node_a.chain_driver().ibc_transfer_token( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version_a, &wallet_a.as_ref(), &wallet_b.address(), &vec![token_denom_a.as_ref(), token_other_denom.as_ref()], @@ -292,9 +316,17 @@ impl BinaryChannelTest for IbcTransferICS20V2Test { let token_denom_b = denom_b.with_amount(b_to_a_amount_denom_b); let token_other_denom_b = other_denom_b.with_amount(b_to_a_amount_other_denom_b); - chains.node_b.chain_driver().ibc_transfer_token_v2( + let channel_version_b = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + + chains.node_b.chain_driver().ibc_transfer_token( &channel.port_b.as_ref(), &channel.channel_id_b.as_ref(), + channel_version_b, &wallet_b.as_ref(), &wallet_c.address(), &vec![token_denom_b.as_ref(), token_other_denom_b.as_ref()], diff --git a/tools/test-framework/src/chain/ext/fee.rs b/tools/test-framework/src/chain/ext/fee.rs index b3783304fa..e91de7bba5 100644 --- a/tools/test-framework/src/chain/ext/fee.rs +++ b/tools/test-framework/src/chain/ext/fee.rs @@ -1,4 +1,5 @@ use core::time::Duration; +use ibc_relayer::channel::version::Version; use ibc_relayer::event::IbcEventWithHeight; use ibc_relayer_types::applications::ics29_fee::packet_fee::IdentifiedPacketFees; use ibc_relayer_types::core::ics04_channel::packet::Sequence; @@ -20,9 +21,10 @@ pub trait ChainFeeMethodsExt { &self, port_id: &TaggedPortIdRef<'_, Chain, Counterparty>, channel_id: &TaggedChannelIdRef<'_, Chain, Counterparty>, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - send_amount: &TaggedTokenRef<'_, Chain>, + send_amount: &Vec>, receive_fee: &TaggedTokenRef<'_, Chain>, ack_fee: &TaggedTokenRef<'_, Chain>, timeout_fee: &TaggedTokenRef<'_, Chain>, @@ -74,9 +76,10 @@ impl<'a, Chain: Send> ChainFeeMethodsExt for MonoTagged, channel_id: &TaggedChannelIdRef<'_, Chain, Counterparty>, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - send_amount: &TaggedTokenRef<'_, Chain>, + send_amount: &Vec>, receive_fee: &TaggedTokenRef<'_, Chain>, ack_fee: &TaggedTokenRef<'_, Chain>, timeout_fee: &TaggedTokenRef<'_, Chain>, @@ -88,6 +91,7 @@ impl<'a, Chain: Send> ChainFeeMethodsExt for MonoTagged { &self, port_id: &TaggedPortIdRef, channel_id: &TaggedChannelIdRef, - sender: &MonoTagged, - recipient: &MonoTagged, - token: &TaggedTokenRef, - ) -> Result; - - fn ibc_transfer_token_v2( - &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, token: &Vec>, @@ -59,9 +50,10 @@ pub trait ChainTransferMethodsExt { &self, port_id: &TaggedPortIdRef, channel_id: &TaggedChannelIdRef, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - token: &TaggedTokenRef, + tokens: &Vec>, memo: Option, timeout: Option, ) -> Result; @@ -70,9 +62,10 @@ pub trait ChainTransferMethodsExt { &self, port_id: &TaggedPortIdRef, channel_id: &TaggedChannelIdRef, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - token: &TaggedTokenRef, + tokens: &Vec>, num_msgs: usize, memo: Option, ) -> Result<(), Error>; @@ -102,9 +95,10 @@ impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged, channel_id: &TaggedChannelIdRef, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - token: &TaggedTokenRef, + token: &Vec>, ) -> Result { let rpc_client = self.rpc_client()?; self.value().runtime.block_on(ibc_token_transfer( @@ -112,6 +106,7 @@ impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged ChainTransferMethodsExt for MonoTagged( - &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - sender: &MonoTagged, - recipient: &MonoTagged, - tokens: &Vec>, - ) -> Result { - let rpc_client = self.rpc_client()?; - self.value().runtime.block_on(ibc_token_transfer_v2( - rpc_client.as_ref(), - &self.tx_config(), - port_id, - channel_id, - sender, - recipient, - tokens, - None, - None, - )) - } - fn ibc_transfer_token_with_memo_and_timeout( &self, port_id: &TaggedPortIdRef, channel_id: &TaggedChannelIdRef, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - token: &TaggedTokenRef, + tokens: &Vec>, memo: Option, timeout: Option, ) -> Result { @@ -158,9 +132,10 @@ impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged ChainTransferMethodsExt for MonoTagged, channel_id: &TaggedChannelIdRef, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - token: &TaggedTokenRef, + tokens: &Vec>, num_msgs: usize, memo: Option, ) -> Result<(), Error> { @@ -182,9 +158,10 @@ impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged( tx_config: &MonoTagged, port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - send_amount: &TaggedTokenRef<'_, SrcChain>, + send_amount: &Vec>, receive_fee: &TaggedTokenRef<'_, SrcChain>, ack_fee: &TaggedTokenRef<'_, SrcChain>, timeout_fee: &TaggedTokenRef<'_, SrcChain>, @@ -39,6 +41,7 @@ pub async fn ibc_token_transfer_with_fee( let transfer_message = build_transfer_message( port_id, channel_id, + channel_version, sender, recipient, send_amount, diff --git a/tools/test-framework/src/relayer/transfer.rs b/tools/test-framework/src/relayer/transfer.rs index 78bd3589a9..e209a18631 100644 --- a/tools/test-framework/src/relayer/transfer.rs +++ b/tools/test-framework/src/relayer/transfer.rs @@ -6,6 +6,7 @@ use core::ops::Add; use core::time::Duration; use eyre::eyre; +use ibc_relayer::channel::version::Version; use ibc_relayer_types::core::ics04_channel::packet::Packet; use ibc_relayer_types::events::IbcEvent; @@ -14,7 +15,6 @@ use ibc_relayer::chain::cosmos::tx::batched_send_tx; use ibc_relayer::chain::cosmos::tx::simple_send_tx; use ibc_relayer::chain::cosmos::types::config::TxConfig; use ibc_relayer::transfer::build_transfer_message as raw_build_transfer_message; -use ibc_relayer::transfer::build_transfer_message_v2 as raw_build_transfer_message_v2; use ibc_relayer::transfer::TransferError; use ibc_relayer_types::applications::transfer::error::Error as Ics20Error; use ibc_relayer_types::core::ics04_channel::timeout::TimeoutHeight; @@ -30,45 +30,7 @@ use crate::types::wallet::{Wallet, WalletAddress}; pub fn build_transfer_message( port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, - sender: &MonoTagged, - recipient: &MonoTagged, - token: &TaggedTokenRef<'_, SrcChain>, - timeout: Duration, - memo: Option, -) -> Result { - let timeout_timestamp = Timestamp::now() - .add(timeout) - .map_err(handle_generic_error)?; - - let sender = sender - .value() - .address - .0 - .parse() - .map_err(|e| TransferError::token_transfer(Ics20Error::signer(e)))?; - - let receiver = recipient - .value() - .0 - .parse() - .map_err(|e| TransferError::token_transfer(Ics20Error::signer(e)))?; - - Ok(raw_build_transfer_message( - (*port_id.value()).clone(), - (*channel_id.value()).clone(), - token.value().amount, - token.value().denom.to_string(), - sender, - receiver, - TimeoutHeight::no_timeout(), - timeout_timestamp, - memo, - )) -} - -pub fn build_transfer_message_v2( - port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, - channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, tokens: &Vec>, @@ -92,15 +54,16 @@ pub fn build_transfer_message_v2( .parse() .map_err(|e| TransferError::token_transfer(Ics20Error::signer(e)))?; - let tokens = tokens + let raw_tokens = tokens .iter() - .map(|token| (token.value().amount, token.value().denom.to_string())) - .collect(); + .map(|t| (t.value().amount, t.value().denom.to_string())) + .collect::>(); - Ok(raw_build_transfer_message_v2( + Ok(raw_build_transfer_message( (*port_id.value()).clone(), (*channel_id.value()).clone(), - tokens, + channel_version.clone(), + raw_tokens, sender, receiver, TimeoutHeight::no_timeout(), @@ -131,55 +94,17 @@ pub async fn ibc_token_transfer( tx_config: &MonoTagged, port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, - sender: &MonoTagged, - recipient: &MonoTagged, - token: &TaggedTokenRef<'_, SrcChain>, - memo: Option, - timeout: Option, -) -> Result { - let message = build_transfer_message( - port_id, - channel_id, - sender, - recipient, - token, - timeout.unwrap_or(Duration::from_secs(60)), - memo.clone(), - )?; - - let events = simple_send_tx( - rpc_client.into_value(), - tx_config.value(), - &sender.value().key, - vec![message], - ) - .await?; - - let packet = events - .into_iter() - .find_map(|event| match event.event { - IbcEvent::SendPacket(ev) => Some(ev.packet), - _ => None, - }) - .ok_or_else(|| eyre!("failed to find send packet event"))?; - - Ok(packet) -} - -pub async fn ibc_token_transfer_v2( - rpc_client: MonoTagged, - tx_config: &MonoTagged, - port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, - channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, tokens: &Vec>, memo: Option, timeout: Option, ) -> Result { - let message = build_transfer_message_v2( + let message = build_transfer_message( port_id, channel_id, + channel_version, sender, recipient, tokens, @@ -211,9 +136,10 @@ pub async fn batched_ibc_token_transfer( tx_config: &MonoTagged, port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, + channel_version: &Version, sender: &MonoTagged, recipient: &MonoTagged, - token: &TaggedTokenRef<'_, SrcChain>, + tokens: &Vec>, num_msgs: usize, memo: Option, ) -> Result<(), Error> { @@ -221,9 +147,10 @@ pub async fn batched_ibc_token_transfer( build_transfer_message( port_id, channel_id, + channel_version, sender, recipient, - token, + tokens, Duration::from_secs(60), memo.clone(), ) From b8190340f939601a57a98a2593518cbfd44a3c81 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 22 Aug 2024 16:00:35 +0200 Subject: [PATCH 11/21] Clean ibc transfers in tests --- crates/relayer/src/channel.rs | 4 +- .../src/tests/benchmark/query_commitments.rs | 5 +- .../src/tests/channel_upgrade/flushing.rs | 52 ++------ .../src/tests/channel_upgrade/ics29.rs | 18 +-- .../src/tests/channel_upgrade/timeout.rs | 78 +++++------ .../src/tests/clean_workers.rs | 11 +- .../src/tests/clear_packet.rs | 70 +--------- .../src/tests/client_expiration.rs | 11 +- .../src/tests/connection_delay.rs | 11 +- .../integration-test/src/tests/denom_trace.rs | 11 +- .../src/tests/dynamic_gas_fee.rs | 22 +-- .../src/tests/execute_schedule.rs | 11 +- .../src/tests/fee/auto_forward_relayer.rs | 14 +- .../src/tests/fee/filter_fees.rs | 39 +----- .../src/tests/fee/forward_relayer.rs | 13 +- .../src/tests/fee/no_forward_relayer.rs | 27 +--- .../src/tests/fee/non_fee_channel.rs | 17 +-- .../src/tests/fee/pay_fee_async.rs | 11 +- .../src/tests/fee/register_payee.rs | 11 +- .../src/tests/fee/timeout_fee.rs | 14 +- tools/integration-test/src/tests/fee_grant.rs | 22 +-- .../src/tests/forward/forward_hop_transfer.rs | 22 +-- .../src/tests/forward/forward_transfer.rs | 53 ++------ .../src/tests/ics20_filter/memo.rs | 15 +-- tools/integration-test/src/tests/ics31.rs | 11 +- .../interchain_security/dynamic_gas_fee.rs | 22 +-- .../src/tests/interchain_security/icq.rs | 11 +- .../interchain_security/simple_transfer.rs | 22 +-- tools/integration-test/src/tests/memo.rs | 22 +-- .../src/tests/ordered_channel.rs | 15 +-- .../src/tests/ordered_channel_clear.rs | 10 +- .../src/tests/query_packet.rs | 22 +-- .../src/tests/sequence_filter.rs | 125 ++++-------------- .../integration-test/src/tests/supervisor.rs | 68 ++++++++-- .../src/tests/tendermint/sequential.rs | 19 ++- .../src/tests/ternary_transfer.rs | 44 +----- tools/integration-test/src/tests/transfer.rs | 44 +----- tools/test-framework/src/chain/ext/fee.rs | 36 +++-- .../test-framework/src/chain/ext/transfer.rs | 86 +++++++----- 39 files changed, 279 insertions(+), 840 deletions(-) diff --git a/crates/relayer/src/channel.rs b/crates/relayer/src/channel.rs index eb9a5a70a6..ed7288b21b 100644 --- a/crates/relayer/src/channel.rs +++ b/crates/relayer/src/channel.rs @@ -354,7 +354,7 @@ impl Channel { a_connection_id.clone(), channel.src_port_id.clone(), Some(channel.src_channel_id.clone()), - None, + Some(a_channel.version.clone()), ), b_side: ChannelSide::new( counterparty_chain.clone(), @@ -362,7 +362,7 @@ impl Channel { b_connection_id.clone(), a_channel.remote.port_id.clone(), a_channel.remote.channel_id.clone(), - None, + Some(a_channel.version.clone()), ), connection_delay: a_connection.delay_period(), }; diff --git a/tools/integration-test/src/tests/benchmark/query_commitments.rs b/tools/integration-test/src/tests/benchmark/query_commitments.rs index 8d8f816d68..2f85b148ce 100644 --- a/tools/integration-test/src/tests/benchmark/query_commitments.rs +++ b/tools/integration-test/src/tests/benchmark/query_commitments.rs @@ -1,4 +1,3 @@ -use ibc_relayer::channel::version::Version; use ibc_test_framework::prelude::*; #[test] @@ -63,9 +62,7 @@ impl BinaryChannelTest for QueryCommitmentsBenchmark { ); chains.node_a.chain_driver().ibc_transfer_token_multiple( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - &Version::ics20(1), + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/channel_upgrade/flushing.rs b/tools/integration-test/src/tests/channel_upgrade/flushing.rs index 5eabcdc4e7..24f6cb27e8 100644 --- a/tools/integration-test/src/tests/channel_upgrade/flushing.rs +++ b/tools/integration-test/src/tests/channel_upgrade/flushing.rs @@ -103,9 +103,6 @@ impl BinaryChannelTest for ChannelUpgradeFlushing { 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(); @@ -114,17 +111,8 @@ impl BinaryChannelTest for ChannelUpgradeFlushing { let send_amount = random_u128_range(1000, 2000); - let channel_version_a = channels.channel.a_side.version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{}`", - channels.channel_id_a - )) - })?; - chain_driver_a.ibc_transfer_token( - &port_a, - &channel_id_a, - channel_version_a, + &channels, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], @@ -133,9 +121,7 @@ impl BinaryChannelTest for ChannelUpgradeFlushing { sleep(Duration::from_secs(3)); chain_driver_a.ibc_transfer_token( - &port_a, - &channel_id_a, - &Version::ics20(1), + &channels, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], @@ -266,7 +252,6 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { 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(1); let old_attrs = ChannelUpgradableAttributes::new( @@ -290,8 +275,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { 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(), + channels.channel.src_port_id().as_str(), + channels.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(), @@ -325,17 +310,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { denom_a ); - let channel_version_a = channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version_a, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -355,17 +331,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { denom_b ); - let channel_version_b = channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.dst_channel_id() - )) - })?; - chains.node_b.chain_driver().ibc_transfer_token( - &channels.port_b.as_ref(), - &channels.channel_id_b.as_ref(), - channel_version_b, + &channels.clone().flip(), &wallet_b.as_ref(), &wallet_a.address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], @@ -373,7 +340,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { info!("Will run ChanUpgradeTry step..."); - channel.build_chan_upgrade_try_and_send()?; + channels.channel.build_chan_upgrade_try_and_send()?; info!("Check that the step ChanUpgradeTry was correctly executed..."); @@ -387,7 +354,10 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets { info!("Will run ChanUpgradeAck step..."); - channel.flipped().build_chan_upgrade_ack_and_send()?; + channels + .channel + .flipped() + .build_chan_upgrade_ack_and_send()?; info!("Check that the step ChanUpgradeAck was correctly executed..."); diff --git a/tools/integration-test/src/tests/channel_upgrade/ics29.rs b/tools/integration-test/src/tests/channel_upgrade/ics29.rs index b3a1e7edf2..991f316603 100644 --- a/tools/integration-test/src/tests/channel_upgrade/ics29.rs +++ b/tools/integration-test/src/tests/channel_upgrade/ics29.rs @@ -90,9 +90,6 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { 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(); @@ -116,17 +113,8 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { let channel = channels.channel.clone(); - let channel_version_a = channels.channel.a_side.version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{}`", - channels.channel_id_a - )) - })?; - let ics29_transfer = chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version_a, + &channels, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], @@ -199,9 +187,7 @@ impl BinaryChannelTest for ChannelUpgradeICS29 { } chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version_a, + &channels, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], diff --git a/tools/integration-test/src/tests/channel_upgrade/timeout.rs b/tools/integration-test/src/tests/channel_upgrade/timeout.rs index fc40ec6492..44a3f2a49b 100644 --- a/tools/integration-test/src/tests/channel_upgrade/timeout.rs +++ b/tools/integration-test/src/tests/channel_upgrade/timeout.rs @@ -387,7 +387,6 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { 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(1); let old_attrs = ChannelUpgradableAttributes::new( @@ -412,8 +411,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { 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(), + channels.channel.src_port_id().as_str(), + channels.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(), @@ -423,7 +422,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { info!("Will run ChanUpgradeTry step..."); - channel.build_chan_upgrade_try_and_send()?; + channels.channel.build_chan_upgrade_try_and_send()?; info!("Check that the step ChanUpgradeTry was correctly executed..."); @@ -451,17 +450,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { denom_a ); - let channel_version_a = channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version_a, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -469,7 +459,10 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { info!("Will run ChanUpgradeAck step..."); - channel.flipped().build_chan_upgrade_ack_and_send()?; + channels + .channel + .flipped() + .build_chan_upgrade_ack_and_send()?; info!("Check that the step ChanUpgradeAck was correctly executed..."); @@ -489,7 +482,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutWhenFlushing { // 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()?; + let timeout_event = channels.channel.build_chan_upgrade_timeout_and_send()?; assert_eq!( timeout_event.event_type(), IbcEventType::UpgradeTimeoutChannel @@ -561,7 +554,6 @@ impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { 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(1); let old_attrs = ChannelUpgradableAttributes::new( @@ -586,8 +578,8 @@ impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { 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(), + channels.channel.src_port_id().as_str(), + channels.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(), @@ -607,7 +599,7 @@ impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { info!("Will run ChanUpgradeTry step..."); - channel.build_chan_upgrade_try_and_send()?; + channels.channel.build_chan_upgrade_try_and_send()?; info!("Check that the step ChanUpgradeTry was correctly executed..."); @@ -635,17 +627,8 @@ impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { denom_a ); - let channel_version_a = channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version_a, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -653,7 +636,10 @@ impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { info!("Will run ChanUpgradeAck step..."); - channel.flipped().build_chan_upgrade_ack_and_send()?; + channels + .channel + .flipped() + .build_chan_upgrade_ack_and_send()?; info!("Check that the step ChanUpgradeAck was correctly executed..."); @@ -673,13 +659,16 @@ impl BinaryChannelTest for ChannelUpgradeManualTimeoutWhenFlushing { // 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()?; + let timeout_event = channels.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()?; + let cancel_event = channels + .channel + .flipped() + .build_chan_upgrade_cancel_and_send()?; assert_eq!( cancel_event.event_type(), IbcEventType::UpgradeCancelChannel @@ -892,7 +881,6 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck { 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(1); let old_attrs = ChannelUpgradableAttributes::new( @@ -917,8 +905,8 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck { 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(), + channels.channel.src_port_id().as_str(), + channels.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(), @@ -952,20 +940,11 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck { denom_a ); - let channel_version_a = channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.src_channel_id() - )) - })?; - chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version_a, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -975,7 +954,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck { info!("Will run ChanUpgradeTry step..."); - channel.build_chan_upgrade_try_and_send()?; + channels.channel.build_chan_upgrade_try_and_send()?; info!("Check that the step ChanUpgradeTry was correctly executed..."); @@ -989,7 +968,10 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck { info!("Will run ChanUpgradeAck step..."); - channel.flipped().build_chan_upgrade_ack_and_send()?; + channels + .channel + .flipped() + .build_chan_upgrade_ack_and_send()?; info!("Check that the step ChanUpgradeAck was correctly executed..."); diff --git a/tools/integration-test/src/tests/clean_workers.rs b/tools/integration-test/src/tests/clean_workers.rs index e9cd2a1884..9647a5878f 100644 --- a/tools/integration-test/src/tests/clean_workers.rs +++ b/tools/integration-test/src/tests/clean_workers.rs @@ -57,18 +57,9 @@ impl BinaryChannelTest for CleanPacketWorkersTest { let supervisor = relayer.spawn_supervisor()?; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - // Transfer tokens so that the packet workers are spawned chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(amount1).as_ref()], diff --git a/tools/integration-test/src/tests/clear_packet.rs b/tools/integration-test/src/tests/clear_packet.rs index bf837c669d..e255abdb6b 100644 --- a/tools/integration-test/src/tests/clear_packet.rs +++ b/tools/integration-test/src/tests/clear_packet.rs @@ -91,17 +91,8 @@ impl BinaryChannelTest for DisabledClearPacketTest { amount1 ); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![amount1.as_ref()], @@ -121,9 +112,7 @@ impl BinaryChannelTest for DisabledClearPacketTest { ); chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![amount2.as_ref()], @@ -190,17 +179,8 @@ impl BinaryChannelTest for ClearPacketRecoveryTest { let amount1 = random_u128_range(1000, 5000); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(amount1).as_ref()], @@ -262,17 +242,8 @@ impl BinaryChannelTest for ClearPacketNoScanTest { .chain_driver() .query_balance(&wallet_a.address(), &denom_a)?; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(amount1).as_ref()], @@ -390,17 +361,8 @@ impl BinaryChannelTest for ClearPacketOverrideTest { .chain_driver() .query_balance(&wallet_a.address(), &denom_a)?; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(amount1).as_ref()], @@ -499,17 +461,8 @@ impl BinaryChannelTest for ClearPacketSequencesTest { info!("Performing {NUM_TRANSFERS} IBC transfer, which should *not* be relayed"); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token_multiple( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![amount.as_ref()], @@ -684,17 +637,8 @@ impl BinaryChannelTest for LimitedClearPacketTest { info!("Performing {num_transfers} IBC transfers with amount {amount}, for a total of {sent_amount}"); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token_multiple( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![amount.as_ref()], diff --git a/tools/integration-test/src/tests/client_expiration.rs b/tools/integration-test/src/tests/client_expiration.rs index 96029d84e3..ea1482166e 100644 --- a/tools/integration-test/src/tests/client_expiration.rs +++ b/tools/integration-test/src/tests/client_expiration.rs @@ -297,17 +297,8 @@ impl BinaryChainTest for PacketExpirationTest { )? }; - let channel_version = channels.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), &vec![chains.node_a.denom().with_amount(100u64).as_ref()], diff --git a/tools/integration-test/src/tests/connection_delay.rs b/tools/integration-test/src/tests/connection_delay.rs index d4ec475a1f..972eba731b 100644 --- a/tools/integration-test/src/tests/connection_delay.rs +++ b/tools/integration-test/src/tests/connection_delay.rs @@ -47,17 +47,8 @@ impl BinaryChannelTest for ConnectionDelayTest { denom_a ); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/denom_trace.rs b/tools/integration-test/src/tests/denom_trace.rs index b72a4ed3bd..5c07ae157f 100644 --- a/tools/integration-test/src/tests/denom_trace.rs +++ b/tools/integration-test/src/tests/denom_trace.rs @@ -31,17 +31,8 @@ impl BinaryChannelTest for IbcDenomTraceTest { .chain_driver() .query_balance(&wallet_a.address(), &denom_a)?; - let channel_version = channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/dynamic_gas_fee.rs b/tools/integration-test/src/tests/dynamic_gas_fee.rs index e6544cab05..611a7463de 100644 --- a/tools/integration-test/src/tests/dynamic_gas_fee.rs +++ b/tools/integration-test/src/tests/dynamic_gas_fee.rs @@ -101,20 +101,11 @@ impl BinaryChannelTest for DynamicGasTest { let memo: String = MEMO_CHAR.repeat(MEMO_SIZE); - let channel_version_a = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version_a, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -166,17 +157,8 @@ impl BinaryChannelTest for DynamicGasTest { &gas_denom_a.as_ref(), )?; - let channel_version_b = channel.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.dst_channel_id() - )) - })?; - chains.node_b.chain_driver().ibc_transfer_token( - &channel.port_b.as_ref(), - &channel.channel_id_b.as_ref(), - channel_version_b, + &channel.flip(), &chains.node_b.wallets().user1(), &chains.node_a.wallets().user1().address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], diff --git a/tools/integration-test/src/tests/execute_schedule.rs b/tools/integration-test/src/tests/execute_schedule.rs index c00cf8e10f..2733bf8733 100644 --- a/tools/integration-test/src/tests/execute_schedule.rs +++ b/tools/integration-test/src/tests/execute_schedule.rs @@ -62,19 +62,10 @@ impl BinaryChannelTest for ExecuteScheduleTest { let mut relay_path_a_to_b = chain_a_link.a_to_b; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - // Construct `BATCH_SIZE` pieces of operational data and queue them up to be sent to chain B. for i in 0..BATCH_SIZE { chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), &vec![chains.node_a.denom().with_amount(amount1).as_ref()], 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 8aabd1d739..26dde5729c 100644 --- a/tools/integration-test/src/tests/fee/auto_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/auto_forward_relayer.rs @@ -43,9 +43,6 @@ impl BinaryChannelTest for AutoForwardRelayerTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); - let wallets_a = chains.node_a.wallets(); let wallets_b = chains.node_b.wallets(); @@ -63,17 +60,8 @@ impl BinaryChannelTest for AutoForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).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 7156acbb7d..874f3b07b1 100644 --- a/tools/integration-test/src/tests/fee/filter_fees.rs +++ b/tools/integration-test/src/tests/fee/filter_fees.rs @@ -55,9 +55,6 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); - let wallets_a = chains.node_a.wallets(); let wallets_b = chains.node_b.wallets(); @@ -79,17 +76,8 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { let balance_a2 = balance_a1.clone() - send_amount; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], @@ -136,17 +124,8 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], @@ -221,9 +200,6 @@ impl BinaryChannelTest for FilterByChannelIncentivizedFeesRelayerTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); - let wallets_a = chains.node_a.wallets(); let wallets_b = chains.node_b.wallets(); @@ -250,17 +226,8 @@ impl BinaryChannelTest for FilterByChannelIncentivizedFeesRelayerTest { info!("Verify that packet without enough fees is not relayed"); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], diff --git a/tools/integration-test/src/tests/fee/forward_relayer.rs b/tools/integration-test/src/tests/fee/forward_relayer.rs index 93479910d6..72a7f64c1b 100644 --- a/tools/integration-test/src/tests/fee/forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/forward_relayer.rs @@ -41,10 +41,8 @@ impl BinaryChannelTest for ForwardRelayerTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); let port_b = channel.port_b.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); let channel_id_b = channel.channel_id_b.as_ref(); let wallets_a = chains.node_a.wallets(); @@ -102,17 +100,8 @@ impl BinaryChannelTest for ForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], 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 c77e09ace6..595f1aa4be 100644 --- a/tools/integration-test/src/tests/fee/no_forward_relayer.rs +++ b/tools/integration-test/src/tests/fee/no_forward_relayer.rs @@ -60,9 +60,6 @@ impl BinaryChannelTest for NoForwardRelayerTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); - let wallets_a = chains.node_a.wallets(); let wallets_b = chains.node_b.wallets(); @@ -80,17 +77,8 @@ impl BinaryChannelTest for NoForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], @@ -140,10 +128,8 @@ impl BinaryChannelTest for InvalidForwardRelayerTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); let port_b = channel.port_b.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); let channel_id_b = channel.channel_id_b.as_ref(); let wallets_a = chains.node_a.wallets(); @@ -174,17 +160,8 @@ impl BinaryChannelTest for InvalidForwardRelayerTest { &port_b, )?; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], diff --git a/tools/integration-test/src/tests/fee/non_fee_channel.rs b/tools/integration-test/src/tests/fee/non_fee_channel.rs index 687fa17dc6..5aee8bd8b5 100644 --- a/tools/integration-test/src/tests/fee/non_fee_channel.rs +++ b/tools/integration-test/src/tests/fee/non_fee_channel.rs @@ -37,9 +37,7 @@ impl BinaryChannelTest for NonFeeChannelTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); let port_b = channel.port_b.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); let channel_id_b = channel.channel_id_b.as_ref(); let wallets_a = chains.node_a.wallets(); @@ -66,18 +64,9 @@ impl BinaryChannelTest for NonFeeChannelTest { assert!(res.is_err()); } - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - { let res = chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], @@ -93,9 +82,7 @@ impl BinaryChannelTest for NonFeeChannelTest { let balance_a2 = balance_a1 - send_amount; chain_driver_a.ibc_transfer_token( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], 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 e467f59075..e40ca2e2ad 100644 --- a/tools/integration-test/src/tests/fee/pay_fee_async.rs +++ b/tools/integration-test/src/tests/fee/pay_fee_async.rs @@ -96,17 +96,8 @@ impl BinaryChannelTest for PayPacketFeeAsyncTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - let events = chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], diff --git a/tools/integration-test/src/tests/fee/register_payee.rs b/tools/integration-test/src/tests/fee/register_payee.rs index 4921766d66..6927c3e45a 100644 --- a/tools/integration-test/src/tests/fee/register_payee.rs +++ b/tools/integration-test/src/tests/fee/register_payee.rs @@ -117,17 +117,8 @@ impl BinaryChannelTest for ForwardRelayerTest { let ack_fee = random_u128_range(200, 300); let timeout_fee = random_u128_range(100, 200); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], diff --git a/tools/integration-test/src/tests/fee/timeout_fee.rs b/tools/integration-test/src/tests/fee/timeout_fee.rs index 70c6542e45..0de01c5a5b 100644 --- a/tools/integration-test/src/tests/fee/timeout_fee.rs +++ b/tools/integration-test/src/tests/fee/timeout_fee.rs @@ -36,9 +36,6 @@ impl BinaryChannelTest for TimeoutFeeTest { let denom_a = chains.node_a.denom(); - let port_a = channel.port_a.as_ref(); - let channel_id_a = channel.channel_id_a.as_ref(); - let wallets_a = chains.node_a.wallets(); let wallets_b = chains.node_b.wallets(); @@ -60,17 +57,8 @@ impl BinaryChannelTest for TimeoutFeeTest { let balance_a2 = balance_a1 - total_sent; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chain_driver_a.ibc_token_transfer_with_fee( - &port_a, - &channel_id_a, - channel_version, + &channel, &user_a, &user_b.address(), &vec![denom_a.with_amount(send_amount).as_ref()], diff --git a/tools/integration-test/src/tests/fee_grant.rs b/tools/integration-test/src/tests/fee_grant.rs index d67b8ad67a..bb1418dc87 100644 --- a/tools/integration-test/src/tests/fee_grant.rs +++ b/tools/integration-test/src/tests/fee_grant.rs @@ -122,17 +122,8 @@ impl BinaryChannelTest for FeeGrantTest { let md: MonoTagged = MonoTagged::new(&modified_driver); - let channel_version = channels.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.src_channel_id() - )) - })?; - md.ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -246,17 +237,8 @@ impl BinaryChannelTest for NoFeeGrantTest { &gas_denom.as_ref(), )?; - let channel_version = channels.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/forward/forward_hop_transfer.rs b/tools/integration-test/src/tests/forward/forward_hop_transfer.rs index e6fbfdb0c5..3943b8a976 100644 --- a/tools/integration-test/src/tests/forward/forward_hop_transfer.rs +++ b/tools/integration-test/src/tests/forward/forward_hop_transfer.rs @@ -118,19 +118,10 @@ impl NaryChannelTest<4> for IbcForwardHopTransferTest { ); let memo = serde_json::to_string(&memo_field).unwrap(); - let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_a_to_b.channel.src_channel_id() - )) - })?; - node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_d_amount).as_ref()], @@ -247,19 +238,10 @@ impl NaryChannelTest<4> for AtomicIbcForwardHopTransferTest { ); let memo = serde_json::to_string(&memo_field).unwrap(); - let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_a_to_b.channel.src_channel_id() - )) - })?; - node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_d_amount).as_ref()], diff --git a/tools/integration-test/src/tests/forward/forward_transfer.rs b/tools/integration-test/src/tests/forward/forward_transfer.rs index d9fc63deb8..2af2760f2f 100644 --- a/tools/integration-test/src/tests/forward/forward_transfer.rs +++ b/tools/integration-test/src/tests/forward/forward_transfer.rs @@ -124,19 +124,10 @@ impl NaryChannelTest<3> for IbcForwardTransferTest { ); let memo = serde_json::to_string(&memo_field).unwrap(); - let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_a_to_b.channel.src_channel_id() - )) - })?; - node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], @@ -264,22 +255,13 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { ); let memo4 = serde_json::to_string(&memo_invalid_field).unwrap(); - let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_a_to_b.channel.src_channel_id() - )) - })?; - { info!("forward transfer with invalid `port` field"); node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], @@ -315,9 +297,7 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], @@ -353,9 +333,7 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], @@ -391,9 +369,7 @@ impl NaryChannelTest<3> for MisspelledMemoFieldsIbcForwardTransferTest { node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], @@ -509,22 +485,13 @@ impl NaryChannelTest<3> for MisspelledMemoContentIbcForwardTransferTest { ); let memo3 = serde_json::to_string(&memo_misspelled_receiver).unwrap(); - let channel_version = channel_a_to_b.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_a_to_b.channel.src_channel_id() - )) - })?; - { info!("forward transfer with invalid port"); node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], @@ -561,9 +528,7 @@ impl NaryChannelTest<3> for MisspelledMemoContentIbcForwardTransferTest { node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], @@ -600,9 +565,7 @@ impl NaryChannelTest<3> for MisspelledMemoContentIbcForwardTransferTest { node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a, &wallet_b.address(), &vec![denom_a.with_amount(a_to_c_amount).as_ref()], diff --git a/tools/integration-test/src/tests/ics20_filter/memo.rs b/tools/integration-test/src/tests/ics20_filter/memo.rs index 4dc99dfc89..e46fad7ff0 100644 --- a/tools/integration-test/src/tests/ics20_filter/memo.rs +++ b/tools/integration-test/src/tests/ics20_filter/memo.rs @@ -52,20 +52,11 @@ impl BinaryChannelTest for IbcMemoFilterTest { // Create a memo bigger than the allowed limit let memo = "a".repeat(MEMO_SIZE_LIMIT + 1); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -102,9 +93,7 @@ impl BinaryChannelTest for IbcMemoFilterTest { .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/ics31.rs b/tools/integration-test/src/tests/ics31.rs index 02e80ba960..ff0dddad7d 100644 --- a/tools/integration-test/src/tests/ics31.rs +++ b/tools/integration-test/src/tests/ics31.rs @@ -92,17 +92,8 @@ impl BinaryChannelTest for ICS31Test { denom_a ); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs b/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs index 8aff0b7e83..d862c4b5dc 100644 --- a/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs +++ b/tools/integration-test/src/tests/interchain_security/dynamic_gas_fee.rs @@ -138,20 +138,11 @@ impl BinaryChannelTest for DynamicGasTest { let memo: String = MEMO_CHAR.repeat(MEMO_SIZE); - let channel_version_a = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains .node_a .chain_driver() .ibc_transfer_token_with_memo_and_timeout( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version_a, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -205,17 +196,8 @@ impl BinaryChannelTest for DynamicGasTest { info!("Will ibc transfer"); - let channel_version_b = channel.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.dst_channel_id() - )) - })?; - chains.node_b.chain_driver().ibc_transfer_token( - &channel.port_b.as_ref(), - &channel.channel_id_b.as_ref(), - channel_version_b, + &channel.flip(), &chains.node_b.wallets().user1(), &chains.node_a.wallets().user1().address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], diff --git a/tools/integration-test/src/tests/interchain_security/icq.rs b/tools/integration-test/src/tests/interchain_security/icq.rs index 3305df4659..ade487988c 100644 --- a/tools/integration-test/src/tests/interchain_security/icq.rs +++ b/tools/integration-test/src/tests/interchain_security/icq.rs @@ -121,17 +121,8 @@ impl BinaryChannelTest for InterchainSecurityIcqTest { denom_a ); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/interchain_security/simple_transfer.rs b/tools/integration-test/src/tests/interchain_security/simple_transfer.rs index e63b44b3a3..7068e2b4d5 100644 --- a/tools/integration-test/src/tests/interchain_security/simple_transfer.rs +++ b/tools/integration-test/src/tests/interchain_security/simple_transfer.rs @@ -60,17 +60,8 @@ impl BinaryChannelTest for InterchainSecurityTransferTest { denom_a ); - let channel_version_a = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version_a, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -119,17 +110,8 @@ impl BinaryChannelTest for InterchainSecurityTransferTest { b_to_a_amount, ); - let channel_version_b = channel.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.dst_channel_id() - )) - })?; - chains.node_b.chain_driver().ibc_transfer_token( - &channel.port_b.as_ref(), - &channel.channel_id_b.as_ref(), - channel_version_b, + &channel.flip(), &wallet_b.as_ref(), &wallet_c.address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], diff --git a/tools/integration-test/src/tests/memo.rs b/tools/integration-test/src/tests/memo.rs index abf2ab7948..695920707c 100644 --- a/tools/integration-test/src/tests/memo.rs +++ b/tools/integration-test/src/tests/memo.rs @@ -60,17 +60,8 @@ impl BinaryChannelTest for MemoTest { let a_to_b_amount = random_u128_range(1000, 5000); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -132,17 +123,8 @@ impl BinaryChannelTest for MemoOverwriteTest { let a_to_b_amount = random_u128_range(1000, 5000); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &chains.node_a.wallets().user1(), &chains.node_b.wallets().user1().address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/ordered_channel.rs b/tools/integration-test/src/tests/ordered_channel.rs index e297e556be..6d921e26a6 100644 --- a/tools/integration-test/src/tests/ordered_channel.rs +++ b/tools/integration-test/src/tests/ordered_channel.rs @@ -65,17 +65,8 @@ impl BinaryChannelTest for OrderedChannelTest { amount1 ); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(amount1).as_ref()], @@ -92,9 +83,7 @@ impl BinaryChannelTest for OrderedChannelTest { ); chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(amount2).as_ref()], diff --git a/tools/integration-test/src/tests/ordered_channel_clear.rs b/tools/integration-test/src/tests/ordered_channel_clear.rs index 1f82c80a31..95c64c99c1 100644 --- a/tools/integration-test/src/tests/ordered_channel_clear.rs +++ b/tools/integration-test/src/tests/ordered_channel_clear.rs @@ -103,17 +103,9 @@ impl BinaryChannelTest for OrderedChannelClearTest { "Performing {} IBC transfers with amount {} on an ordered channel", num_msgs, amount ); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; chains.node_a.chain_driver().ibc_transfer_token_multiple( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![token.as_ref()], diff --git a/tools/integration-test/src/tests/query_packet.rs b/tools/integration-test/src/tests/query_packet.rs index 5f04da0201..f9af7cc821 100644 --- a/tools/integration-test/src/tests/query_packet.rs +++ b/tools/integration-test/src/tests/query_packet.rs @@ -48,17 +48,8 @@ impl BinaryChannelTest for QueryPacketPendingTest { amount1 ); - let channel_version_a = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version_a, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(amount1).as_ref()], @@ -144,17 +135,8 @@ impl BinaryChannelTest for QueryPacketPendingTest { let denom_b = chains.node_b.denom(); let amount2 = random_u128_range(1000, 5000); - let channel_version_b = channel.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.dst_channel_id() - )) - })?; - chains.node_b.chain_driver().ibc_transfer_token( - &channel.port_b.as_ref(), - &channel.channel_id_b.as_ref(), - channel_version_b, + &channel.clone().flip(), &wallet_b.as_ref(), &wallet_a.address(), &vec![denom_b.with_amount(amount2).as_ref()], diff --git a/tools/integration-test/src/tests/sequence_filter.rs b/tools/integration-test/src/tests/sequence_filter.rs index d704d6ce39..7d9a43b892 100644 --- a/tools/integration-test/src/tests/sequence_filter.rs +++ b/tools/integration-test/src/tests/sequence_filter.rs @@ -17,8 +17,8 @@ use std::collections::BTreeMap; +use ibc_relayer::config::ChainConfig; use ibc_relayer::util::excluded_sequences::ExcludedSequences; -use ibc_relayer::{channel::version::Version, config::ChainConfig}; use ibc_test_framework::{ prelude::*, relayer::channel::{assert_eventually_channel_established, init_channel}, @@ -172,18 +172,9 @@ impl BinaryChannelTest for ClearNoFilterTest { .chain_driver() .query_balance(&wallet_b.address(), &denom_b)?; - let channel_version = channels.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.src_channel_id() - )) - })?; - // Create a pending transfer from A to B with sequence 1 chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -191,26 +182,15 @@ impl BinaryChannelTest for ClearNoFilterTest { // Create a pending transfer from A to B with sequence 2 chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; - let channel_version = channels.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.dst_channel_id() - )) - })?; - // Create a pending transfer from B to A with sequence 1 chains.node_b.chain_driver().ibc_transfer_token( - &channels.port_b.as_ref(), - &channels.channel_id_b.as_ref(), - channel_version, + &channels.clone().flip(), &wallet_b.as_ref(), &wallet_a.address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], @@ -218,9 +198,7 @@ impl BinaryChannelTest for ClearNoFilterTest { // Create a pending transfer from B to A with sequence 2 chains.node_b.chain_driver().ibc_transfer_token( - &channels.port_b.as_ref(), - &channels.channel_id_b.as_ref(), - channel_version, + &channels.flip(), &wallet_b.as_ref(), &wallet_a.address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], @@ -316,18 +294,9 @@ impl BinaryChannelTest for StandardRelayingNoFilterTest { .chain_driver() .query_balance(&wallet_b.address(), &denom_b)?; - let channel_version = channels.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.src_channel_id() - )) - })?; - // Create a pending transfer from A to B with sequence 1 chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -335,26 +304,15 @@ impl BinaryChannelTest for StandardRelayingNoFilterTest { // Create a pending transfer from A to B with sequence 2 chains.node_a.chain_driver().ibc_transfer_token( - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], )?; - let channel_version = channels.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.dst_channel_id() - )) - })?; - // Create a pending transfer from B to A with sequence 1 chains.node_b.chain_driver().ibc_transfer_token( - &channels.port_b.as_ref(), - &channels.channel_id_b.as_ref(), - channel_version, + &channels.clone().flip(), &wallet_b.as_ref(), &wallet_a.address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], @@ -362,9 +320,7 @@ impl BinaryChannelTest for StandardRelayingNoFilterTest { // Create a pending transfer from B to A with sequence 2 chains.node_b.chain_driver().ibc_transfer_token( - &channels.port_b.as_ref(), - &channels.channel_id_b.as_ref(), - channel_version, + &channels.flip(), &wallet_b.as_ref(), &wallet_a.address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], @@ -488,42 +444,33 @@ fn run_sequence_filter_test( .chain_driver() .query_balance(&wallet_b_2.address(), &denom_b)?; - let channel_version = channels.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.src_channel_id() - )) - })?; - // Double transfer from A to B on channel with filter double_transfer( chains.node_a.chain_driver(), - &channels.port_a.as_ref(), - &channels.channel_id_a.as_ref(), - channel_version, + &channels, &wallet_a_1.as_ref(), &wallet_b_1.address(), &denom_a.with_amount(a_to_b_amount).as_ref(), )?; - let port_b_2: DualTagged = - DualTagged::new(channel_b_2.a_side.port_id()); + let port_b_2: DualTagged = + DualTagged::new(channel_b_2.a_side.port_id().clone()); let port_a_2: DualTagged = DualTagged::new(channel_b_2.clone().flipped().a_side.port_id().clone()); - let channel_version_2 = channel_b_2.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channels.channel.src_channel_id() - )) - })?; + let connected_channel_b_2 = ConnectedChannel { + connection: channels.clone().connection, + channel: channel_b_2.flipped(), + channel_id_a: channel_id_a_2, + channel_id_b: channel_id_b_2, + port_a: port_a_2, + port_b: port_b_2, + }; // Double transfer from A to B on channel without filter double_transfer( chains.node_a.chain_driver(), - &port_a_2.as_ref(), - &channel_id_a_2.as_ref(), - channel_version_2, + &connected_channel_b_2, &wallet_a_2.as_ref(), &wallet_b_2.address(), &denom_a.with_amount(a_to_b_amount).as_ref(), @@ -532,9 +479,7 @@ fn run_sequence_filter_test( // Double transfer from B to A on channel with filter double_transfer( chains.node_b.chain_driver(), - &channels.port_b.as_ref(), - &channels.channel_id_b.as_ref(), - channel_version, + &channels.flip(), &wallet_b_1.as_ref(), &wallet_a_1.address(), &denom_b.with_amount(b_to_a_amount).as_ref(), @@ -543,9 +488,7 @@ fn run_sequence_filter_test( // Double transfer from B to A on channel without filter double_transfer( chains.node_b.chain_driver(), - &port_b_2, - &channel_id_b_2.as_ref(), - channel_version_2, + &connected_channel_b_2.flip(), &wallet_b_2.as_ref(), &wallet_a_2.address(), &denom_b.with_amount(b_to_a_amount).as_ref(), @@ -608,32 +551,16 @@ fn run_sequence_filter_test( fn double_transfer( chain_driver: MonoTagged, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, token: &TaggedTokenRef, ) -> Result<(), Error> { // Create a pending transfer from B to A with sequence 1 - chain_driver.ibc_transfer_token( - port_id, - channel_id, - channel_version, - sender, - recipient, - vec![token], - )?; + chain_driver.ibc_transfer_token(channel, sender, recipient, &vec![token.clone()])?; // Create a pending transfer from B to A with sequence 2 - chain_driver.ibc_transfer_token( - port_id, - channel_id, - channel_version, - sender, - recipient, - vec![token], - )?; + chain_driver.ibc_transfer_token(channel, sender, recipient, &vec![token.clone()])?; Ok(()) } diff --git a/tools/integration-test/src/tests/supervisor.rs b/tools/integration-test/src/tests/supervisor.rs index ffbf9d768d..e662e81741 100644 --- a/tools/integration-test/src/tests/supervisor.rs +++ b/tools/integration-test/src/tests/supervisor.rs @@ -1,13 +1,17 @@ +use ibc_relayer::chain::requests::QueryHeight; +use ibc_relayer::channel::Channel; use ibc_relayer::config::{self, ModeConfig}; - +use ibc_relayer::connection::Connection; +use ibc_relayer::object::Channel as ObjectChannel; use ibc_test_framework::prelude::*; use ibc_test_framework::relayer::channel::{assert_eventually_channel_established, init_channel}; use ibc_test_framework::relayer::connection::{ assert_eventually_connection_established, init_connection, }; +use ibc_test_framework::types::binary::client::ClientIdPair; #[test] -fn test_supervisor1() -> Result<(), Error> { +fn test_supervisor() -> Result<(), Error> { run_binary_chain_test(&SupervisorTest) } @@ -59,13 +63,37 @@ impl BinaryChainTest for SupervisorTest { MonoTagged::new(Denom::base(config.native_token(0))); let fee_denom_b: MonoTagged = MonoTagged::new(Denom::base(config.native_token(1))); - let (connection_id_b, _) = init_connection( + let (connection_id_b, connection) = init_connection( &chains.handle_a, &chains.handle_b, &chains.foreign_clients.client_id_a(), &chains.foreign_clients.client_id_b(), )?; + let connection_a_to_b = Connection::new( + chains.foreign_clients.clone().client_b_to_a, + chains.foreign_clients.clone().client_a_to_b, + Default::default(), + )?; + + let client_id_pair = ClientIdPair::new( + chains.foreign_clients.client_id_a().cloned(), + chains.foreign_clients.client_id_b().cloned(), + ); + + let connection_id_a: DualTagged = + DualTagged::new(connection.a_connection_id().ok_or_else(|| { + Error::generic(eyre!("failed to retrieve connection ID for A side")) + })?) + .cloned(); + + let connected_connection: ConnectedConnection = ConnectedConnection { + client_ids: client_id_pair, + connection: connection_a_to_b.clone(), + connection_id_a, + connection_id_b: connection_id_b.clone(), + }; + let connection_id_a = assert_eventually_connection_established( &chains.handle_b, &chains.handle_a, @@ -75,7 +103,7 @@ impl BinaryChainTest for SupervisorTest { let port_a = tagged_transfer_port(); let port_b = tagged_transfer_port(); - let (channel_id_b, channel) = init_channel( + let (channel_id_b, _) = init_channel( &chains.handle_a, &chains.handle_b, &chains.client_id_a(), @@ -93,6 +121,27 @@ impl BinaryChainTest for SupervisorTest { &port_b.as_ref(), )?; + let (channel, _) = Channel::restore_from_state( + chains.handle_a.clone(), + chains.handle_b.clone(), + ObjectChannel { + dst_chain_id: chains.handle_b().id(), + src_chain_id: chains.handle_a().id(), + src_channel_id: channel_id_a.0.clone(), + src_port_id: port_a.0.clone(), + }, + QueryHeight::Latest, + )?; + + let connected_channel = ConnectedChannel { + connection: connected_connection, + channel: channel.clone(), + channel_id_a, + channel_id_b: channel_id_b.clone(), + port_a: port_a.clone(), + port_b: port_b.clone(), + }; + let denom_a = chains.node_a.denom(); let denom_b = derive_ibc_denom(&port_b.as_ref(), &channel_id_b.as_ref(), &denom_a)?; @@ -134,17 +183,8 @@ impl BinaryChainTest for SupervisorTest { denom_a ); - let channel_version = channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &port_a.as_ref(), - &channel_id_a.as_ref(), - channel_version, + &connected_channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(1000u64).as_ref()], diff --git a/tools/integration-test/src/tests/tendermint/sequential.rs b/tools/integration-test/src/tests/tendermint/sequential.rs index be9d254873..7736e5255a 100644 --- a/tools/integration-test/src/tests/tendermint/sequential.rs +++ b/tools/integration-test/src/tests/tendermint/sequential.rs @@ -66,13 +66,20 @@ impl BinaryChannelTest for SequentialCommitTest { { let denom_a = chains.node_a.denom(); + let channel_version = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; let transfer_message = build_transfer_message( &channel.port_a.as_ref(), &channel.channel_id_a.as_ref(), + channel_version, &wallet_a.as_ref(), &wallet_b.address(), - &denom_a.with_amount(100u64).as_ref(), + &vec![denom_a.with_amount(100u64).as_ref()], Duration::from_secs(30), None, )?; @@ -109,13 +116,21 @@ impl BinaryChannelTest for SequentialCommitTest { { let denom_b = chains.node_b.denom(); + let flipped_channel = channel.channel.flipped().clone(); + let channel_version = flipped_channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; let transfer_message = build_transfer_message( &channel.port_b.as_ref(), &channel.channel_id_b.as_ref(), + channel_version, &wallet_b.as_ref(), &wallet_a.address(), - &denom_b.with_amount(100u64).as_ref(), + &vec![denom_b.with_amount(100u64).as_ref()], Duration::from_secs(30), None, )?; diff --git a/tools/integration-test/src/tests/ternary_transfer.rs b/tools/integration-test/src/tests/ternary_transfer.rs index 95fcad11df..0a2bb6e3e3 100644 --- a/tools/integration-test/src/tests/ternary_transfer.rs +++ b/tools/integration-test/src/tests/ternary_transfer.rs @@ -57,17 +57,8 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { denom_a ); - let channel_version = channel_a_to_b.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_a_to_b.src_channel_id() - )) - })?; - node_a.chain_driver().ibc_transfer_token( - &channel_a_to_b.port_a.as_ref(), - &channel_a_to_b.channel_id_a.as_ref(), - channel_version, + &channel_a_to_b, &wallet_a1.as_ref(), &wallet_b1.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -112,17 +103,8 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { let b_to_c_amount = 2500; - let channel_version = channel_b_to_c.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_b_to_c.src_channel_id() - )) - })?; - node_b.chain_driver().ibc_transfer_token( - &channel_b_to_c.port_a.as_ref(), - &channel_b_to_c.channel_id_a.as_ref(), - channel_version, + &channel_b_to_c, &wallet_b1.as_ref(), &wallet_c1.address(), &vec![denom_a_to_b.with_amount(b_to_c_amount).as_ref()], @@ -157,17 +139,8 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { let c_to_a_amount = 800; - let channel_version = channel_c_to_a.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_c_to_a.src_channel_id() - )) - })?; - node_c.chain_driver().ibc_transfer_token( - &channel_c_to_a.port_a.as_ref(), - &channel_c_to_a.channel_id_a.as_ref(), - channel_version, + &channel_c_to_a, &wallet_c1.as_ref(), &wallet_a1.address(), &vec![denom_a_to_c.with_amount(c_to_a_amount).as_ref()], @@ -194,17 +167,8 @@ impl NaryChannelTest<3> for TernaryIbcTransferTest { let c_to_b_amount = 500; - let channel_version = channel_c_to_a.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel_c_to_a.src_channel_id() - )) - })?; - node_c.chain_driver().ibc_transfer_token( - &channel_b_to_c.port_b.as_ref(), - &channel_b_to_c.channel_id_b.as_ref(), - channel_version, + &channel_b_to_c.flip(), &wallet_c1.as_ref(), &wallet_b2.address(), &vec![denom_a_to_c.with_amount(c_to_b_amount).as_ref()], diff --git a/tools/integration-test/src/tests/transfer.rs b/tools/integration-test/src/tests/transfer.rs index 09eab4215a..6f45cf1865 100644 --- a/tools/integration-test/src/tests/transfer.rs +++ b/tools/integration-test/src/tests/transfer.rs @@ -83,17 +83,8 @@ impl BinaryChannelTest for IbcTransferTest { denom_a ); - let channel_version_a = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version_a, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![denom_a.with_amount(a_to_b_amount).as_ref()], @@ -140,17 +131,8 @@ impl BinaryChannelTest for IbcTransferTest { b_to_a_amount, ); - let channel_version_b = channel.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.dst_channel_id() - )) - })?; - chains.node_b.chain_driver().ibc_transfer_token( - &channel.port_b.as_ref(), - &channel.channel_id_b.as_ref(), - channel_version_b, + &channel.flip(), &wallet_b.as_ref(), &wallet_c.address(), &vec![denom_b.with_amount(b_to_a_amount).as_ref()], @@ -229,17 +211,8 @@ impl BinaryChannelTest for IbcTransferICS20V2Test { let token_denom_a = denom_a.with_amount(a_to_b_amount_denom_a); let token_other_denom = other_denom.with_amount(a_to_b_amount_other_denom); - let channel_version_a = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - chains.node_a.chain_driver().ibc_transfer_token( - &channel.port_a.as_ref(), - &channel.channel_id_a.as_ref(), - channel_version_a, + &channel, &wallet_a.as_ref(), &wallet_b.address(), &vec![token_denom_a.as_ref(), token_other_denom.as_ref()], @@ -316,17 +289,8 @@ impl BinaryChannelTest for IbcTransferICS20V2Test { let token_denom_b = denom_b.with_amount(b_to_a_amount_denom_b); let token_other_denom_b = other_denom_b.with_amount(b_to_a_amount_other_denom_b); - let channel_version_b = channel.channel.dst_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.dst_channel_id() - )) - })?; - chains.node_b.chain_driver().ibc_transfer_token( - &channel.port_b.as_ref(), - &channel.channel_id_b.as_ref(), - channel_version_b, + &channel.flip(), &wallet_b.as_ref(), &wallet_c.address(), &vec![token_denom_b.as_ref(), token_other_denom_b.as_ref()], diff --git a/tools/test-framework/src/chain/ext/fee.rs b/tools/test-framework/src/chain/ext/fee.rs index e91de7bba5..7b0c835d99 100644 --- a/tools/test-framework/src/chain/ext/fee.rs +++ b/tools/test-framework/src/chain/ext/fee.rs @@ -1,5 +1,7 @@ use core::time::Duration; -use ibc_relayer::channel::version::Version; +use eyre::eyre; + +use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::event::IbcEventWithHeight; use ibc_relayer_types::applications::ics29_fee::packet_fee::IdentifiedPacketFees; use ibc_relayer_types::core::ics04_channel::packet::Sequence; @@ -8,6 +10,7 @@ use crate::chain::driver::ChainDriver; use crate::chain::tagged::TaggedChainDriverExt; use crate::error::Error; use crate::ibc::token::TaggedTokenRef; +use crate::prelude::ConnectedChannel; use crate::relayer::fee::{ ibc_token_transfer_with_fee, pay_packet_fee, query_counterparty_payee, query_incentivized_packets, register_counterparty_payee, register_payee, @@ -16,12 +19,10 @@ use crate::types::id::{TaggedChannelIdRef, TaggedPortIdRef}; use crate::types::tagged::*; use crate::types::wallet::{Wallet, WalletAddress}; -pub trait ChainFeeMethodsExt { - fn ibc_token_transfer_with_fee( +pub trait ChainFeeMethodsExt { + fn ibc_token_transfer_with_fee( &self, - port_id: &TaggedPortIdRef<'_, Chain, Counterparty>, - channel_id: &TaggedChannelIdRef<'_, Chain, Counterparty>, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, send_amount: &Vec>, @@ -71,12 +72,12 @@ pub trait ChainFeeMethodsExt { ) -> Result, Error>; } -impl<'a, Chain: Send> ChainFeeMethodsExt for MonoTagged { - fn ibc_token_transfer_with_fee( +impl<'a, Chain: ChainHandle + Send> ChainFeeMethodsExt + for MonoTagged +{ + fn ibc_token_transfer_with_fee( &self, - port_id: &TaggedPortIdRef<'_, Chain, Counterparty>, - channel_id: &TaggedChannelIdRef<'_, Chain, Counterparty>, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, send_amount: &Vec>, @@ -85,12 +86,21 @@ impl<'a, Chain: Send> ChainFeeMethodsExt for MonoTagged, timeout: Duration, ) -> Result, Error> { + let port_id = channel.port_a.clone(); + let channel_id = channel.channel_id_a.clone(); + let channel_version = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + let rpc_client = self.rpc_client()?; self.value().runtime.block_on(ibc_token_transfer_with_fee( rpc_client.as_ref(), &self.tx_config(), - port_id, - channel_id, + &port_id.as_ref(), + &channel_id.as_ref(), channel_version, sender, recipient, diff --git a/tools/test-framework/src/chain/ext/transfer.rs b/tools/test-framework/src/chain/ext/transfer.rs index 2a0eb8636c..a612fe86a2 100644 --- a/tools/test-framework/src/chain/ext/transfer.rs +++ b/tools/test-framework/src/chain/ext/transfer.rs @@ -1,6 +1,7 @@ use core::time::Duration; +use eyre::eyre; -use ibc_relayer::channel::version::Version; +use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer_types::core::ics02_client::height::Height; use ibc_relayer_types::core::ics04_channel::packet::Packet; use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId}; @@ -10,12 +11,12 @@ use crate::chain::driver::ChainDriver; use crate::chain::tagged::TaggedChainDriverExt; use crate::error::Error; use crate::ibc::token::TaggedTokenRef; +use crate::prelude::ConnectedChannel; use crate::relayer::transfer::{batched_ibc_token_transfer, ibc_token_transfer}; -use crate::types::id::{TaggedChannelIdRef, TaggedPortIdRef}; use crate::types::tagged::*; use crate::types::wallet::{Wallet, WalletAddress}; -pub trait ChainTransferMethodsExt { +pub trait ChainTransferMethodsExt { /** Submits an IBC token transfer transaction to `Chain` to any other `Counterparty` chain. @@ -36,21 +37,17 @@ pub trait ChainTransferMethodsExt { - The transfer amount. */ - fn ibc_transfer_token( + fn ibc_transfer_token( &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, token: &Vec>, ) -> Result; - fn ibc_transfer_token_with_memo_and_timeout( + fn ibc_transfer_token_with_memo_and_timeout( &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, tokens: &Vec>, @@ -58,11 +55,9 @@ pub trait ChainTransferMethodsExt { timeout: Option, ) -> Result; - fn ibc_transfer_token_multiple( + fn ibc_transfer_token_multiple( &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, tokens: &Vec>, @@ -90,22 +85,31 @@ pub trait ChainTransferMethodsExt { ) -> Result<(), Error>; } -impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged { - fn ibc_transfer_token( +impl<'a, Chain: ChainHandle + Send> ChainTransferMethodsExt + for MonoTagged +{ + fn ibc_transfer_token( &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, token: &Vec>, ) -> Result { + let port_id = channel.port_a.clone(); + let channel_id = channel.channel_id_a.clone(); + let channel_version = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + let rpc_client = self.rpc_client()?; self.value().runtime.block_on(ibc_token_transfer( rpc_client.as_ref(), &self.tx_config(), - port_id, - channel_id, + &port_id.as_ref(), + &channel_id.as_ref(), channel_version, sender, recipient, @@ -115,23 +119,30 @@ impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged( + fn ibc_transfer_token_with_memo_and_timeout( &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, tokens: &Vec>, memo: Option, timeout: Option, ) -> Result { + let port_id = channel.port_a.clone(); + let channel_id = channel.channel_id_a.clone(); + let channel_version = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + let rpc_client = self.rpc_client()?; self.value().runtime.block_on(ibc_token_transfer( rpc_client.as_ref(), &self.tx_config(), - port_id, - channel_id, + &port_id.as_ref(), + &channel_id.as_ref(), channel_version, sender, recipient, @@ -141,23 +152,30 @@ impl<'a, Chain: Send> ChainTransferMethodsExt for MonoTagged( + fn ibc_transfer_token_multiple( &self, - port_id: &TaggedPortIdRef, - channel_id: &TaggedChannelIdRef, - channel_version: &Version, + channel: &ConnectedChannel, sender: &MonoTagged, recipient: &MonoTagged, tokens: &Vec>, num_msgs: usize, memo: Option, ) -> Result<(), Error> { + let port_id = channel.port_a.clone(); + let channel_id = channel.channel_id_a.clone(); + let channel_version = channel.channel.dst_version().ok_or_else(|| { + Error::generic(eyre!( + "failed to retrieve channel version for channel `{:#?}`", + channel.channel.dst_channel_id() + )) + })?; + let rpc_client = self.rpc_client()?; self.value().runtime.block_on(batched_ibc_token_transfer( rpc_client.as_ref(), &self.tx_config(), - port_id, - channel_id, + &port_id.as_ref(), + &channel_id.as_ref(), channel_version, sender, recipient, From 9475ced9b6463f29794ca4906ba9cb398424b318 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 22 Aug 2024 16:08:54 +0200 Subject: [PATCH 12/21] Fix clippy error --- tools/integration-test/src/tests/sequence_filter.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/integration-test/src/tests/sequence_filter.rs b/tools/integration-test/src/tests/sequence_filter.rs index 7d9a43b892..ef69df6e87 100644 --- a/tools/integration-test/src/tests/sequence_filter.rs +++ b/tools/integration-test/src/tests/sequence_filter.rs @@ -557,10 +557,10 @@ fn double_transfer( token: &TaggedTokenRef, ) -> Result<(), Error> { // Create a pending transfer from B to A with sequence 1 - chain_driver.ibc_transfer_token(channel, sender, recipient, &vec![token.clone()])?; + chain_driver.ibc_transfer_token(channel, sender, recipient, &vec![*token])?; // Create a pending transfer from B to A with sequence 2 - chain_driver.ibc_transfer_token(channel, sender, recipient, &vec![token.clone()])?; + chain_driver.ibc_transfer_token(channel, sender, recipient, &vec![*token])?; Ok(()) } From 661c3f4dc4578e2c5c69ce2934dc5e4d604f0bd3 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 23 Aug 2024 13:56:27 +0200 Subject: [PATCH 13/21] Fix denom trace query --- crates/relayer/src/chain/cosmos.rs | 2 +- .../src/chain/cosmos/query/denom_trace.rs | 45 ++++++++++++------- crates/relayer/src/error.rs | 5 +++ 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index e6512a628d..e64bb7e08f 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -1236,7 +1236,7 @@ impl ChainEndpoint for CosmosSdkChain { } fn query_denom_trace(&self, hash: String) -> Result { - let denom_trace = self.block_on(query_denom_trace(&self.grpc_addr, &hash))?; + let denom_trace = self.block_on(query_denom_trace(&self.rpc_client, &hash))?; Ok(denom_trace) } diff --git a/crates/relayer/src/chain/cosmos/query/denom_trace.rs b/crates/relayer/src/chain/cosmos/query/denom_trace.rs index 3faccf6a63..5a2b1b20e1 100644 --- a/crates/relayer/src/chain/cosmos/query/denom_trace.rs +++ b/crates/relayer/src/chain/cosmos/query/denom_trace.rs @@ -1,5 +1,8 @@ -use http::uri::Uri; -use serde::Deserialize; +use prost::Message; + +use ibc_proto::ibc::applications::transfer::v1::DenomTrace as RawDenomTrace; +use tendermint_rpc::Client; +use tendermint_rpc::HttpClient; use crate::denom::DenomTrace; use crate::error::Error; @@ -14,27 +17,39 @@ pub struct QueryDenomTraceRequest { pub hash: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct QueryDenomTraceResponse { /// denom_trace returns the requested denomination trace information. - pub denom_trace: ::core::option::Option, + #[prost(message, optional, tag = "1")] + pub denom_trace: ::core::option::Option, +} +impl ::prost::Name for QueryDenomTraceResponse { + const NAME: &'static str = "QueryDenomTraceResponse"; + const PACKAGE: &'static str = "ibc.applications.transfer.v1"; + fn full_name() -> ::prost::alloc::string::String { + "ibc.applications.transfer.v1.QueryDenomTraceResponse".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/ibc.applications.transfer.v1.QueryDenomTraceResponse".into() + } } // Uses the GRPC client to retrieve the denom trace for a specific hash -pub async fn query_denom_trace(rpc_address: &Uri, hash: &str) -> Result { - let url = format!( - "{}abci_query?path=\"/ibc.applications.transfer.v1.Query/QueryDenomTraceRequest\"&hash={}", - rpc_address, hash - ); +pub async fn query_denom_trace(client: &HttpClient, hash: &str) -> Result { + let request = QueryDenomTraceRequest { + hash: hash.to_string(), + }; + let path = "/ibc.applications.transfer.v1.Query/DenomTrace".to_owned(); - let response = reqwest::get(&url).await.map_err(Error::http_request)?; + let data = prost::Message::encode_to_vec(&request); - if !response.status().is_success() { - return Err(Error::http_response(response.status())); - } + let response = client + .abci_query(Some(path.clone()), data, None, false) + .await + .map_err(|e| Error::failed_abci_query(path, e))?; - let result: QueryDenomTraceResponse = - response.json().await.map_err(Error::http_response_body)?; + let result = QueryDenomTraceResponse::decode(response.value.as_slice()) + .map_err(|e| Error::protobuf_decode("QueryDenomTraceResponse".to_owned(), e))?; let denom_trace = result .denom_trace diff --git a/crates/relayer/src/error.rs b/crates/relayer/src/error.rs index cbadb37506..5c4ad51f4d 100644 --- a/crates/relayer/src/error.rs +++ b/crates/relayer/src/error.rs @@ -594,6 +594,11 @@ define_error! { [ TendermintRpcError ] |_| { "Invalid CompatMode queried from chain and no `compat_mode` configured in Hermes. This can be fixed by specifying a `compat_mode` in Hermes config.toml" }, + FailedAbciQuery + { path: String } + [ TendermintRpcError ] + |e| { format_args!("ABCI query with path `{}` failed", e.path) }, + HttpRequest [ TraceError ] |_| { "HTTP request error" }, From 01fcc799c186f1e94b813a06f80f27c227233325 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 23 Aug 2024 15:03:34 +0200 Subject: [PATCH 14/21] Fix sequential filter tests --- .../src/tests/sequence_filter.rs | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tools/integration-test/src/tests/sequence_filter.rs b/tools/integration-test/src/tests/sequence_filter.rs index ef69df6e87..8c20f671ea 100644 --- a/tools/integration-test/src/tests/sequence_filter.rs +++ b/tools/integration-test/src/tests/sequence_filter.rs @@ -17,8 +17,10 @@ use std::collections::BTreeMap; -use ibc_relayer::config::ChainConfig; +use ibc_relayer::channel::Channel; +use ibc_relayer::object::Channel as ObjectChannel; use ibc_relayer::util::excluded_sequences::ExcludedSequences; +use ibc_relayer::{chain::requests::QueryHeight, config::ChainConfig}; use ibc_test_framework::{ prelude::*, relayer::channel::{assert_eventually_channel_established, init_channel}, @@ -361,7 +363,7 @@ fn run_sequence_filter_test( chains: ConnectedChains, channels: ConnectedChannel, ) -> Result<(), Error> { - let (channel_id_a_2, channel_id_b_2, channel_b_2) = relayer.with_supervisor(|| { + let (channel_id_a_2, channel_id_b_2) = relayer.with_supervisor(|| { // During test bootstrap channel padding initialises a channel with ID 0. // Before creating the new channel with sequence filter, complete the handshake of // the pad channel in order to insure that the retrieved channel IDs `channel_id_a_2` and @@ -373,7 +375,7 @@ fn run_sequence_filter_test( &pad_channel_id.as_ref(), &channels.port_b.as_ref(), )?; - let (channel_id_b_2, channel_b_2) = init_channel( + let (channel_id_b_2, _) = init_channel( chains.handle_a(), chains.handle_b(), &chains.client_id_a(), @@ -390,9 +392,21 @@ fn run_sequence_filter_test( &channel_id_b_2.as_ref(), &channels.port_b.as_ref(), )?; - Ok((channel_id_a_2, channel_id_b_2, channel_b_2)) + Ok((channel_id_a_2, channel_id_b_2)) })?; + let (channel_2, _) = Channel::restore_from_state( + chains.handle_a.clone(), + chains.handle_b.clone(), + ObjectChannel { + dst_chain_id: chains.handle_b().id(), + src_chain_id: chains.handle_a().id(), + src_channel_id: channel_id_a_2.0.clone(), + src_port_id: channels.port_a.0.clone(), + }, + QueryHeight::Latest, + )?; + let denom_a = chains.node_a.denom(); let denom_a_to_b_1 = derive_ibc_denom( &channels.port_b.as_ref(), @@ -454,13 +468,13 @@ fn run_sequence_filter_test( )?; let port_b_2: DualTagged = - DualTagged::new(channel_b_2.a_side.port_id().clone()); + DualTagged::new(channel_2.a_side.port_id().clone()); let port_a_2: DualTagged = - DualTagged::new(channel_b_2.clone().flipped().a_side.port_id().clone()); + DualTagged::new(channel_2.clone().flipped().a_side.port_id().clone()); - let connected_channel_b_2 = ConnectedChannel { + let connected_channel_2 = ConnectedChannel { connection: channels.clone().connection, - channel: channel_b_2.flipped(), + channel: channel_2, channel_id_a: channel_id_a_2, channel_id_b: channel_id_b_2, port_a: port_a_2, @@ -470,7 +484,7 @@ fn run_sequence_filter_test( // Double transfer from A to B on channel without filter double_transfer( chains.node_a.chain_driver(), - &connected_channel_b_2, + &connected_channel_2, &wallet_a_2.as_ref(), &wallet_b_2.address(), &denom_a.with_amount(a_to_b_amount).as_ref(), @@ -488,7 +502,7 @@ fn run_sequence_filter_test( // Double transfer from B to A on channel without filter double_transfer( chains.node_b.chain_driver(), - &connected_channel_b_2.flip(), + &connected_channel_2.flip(), &wallet_b_2.as_ref(), &wallet_a_2.address(), &denom_b.with_amount(b_to_a_amount).as_ref(), From 5fad8a761632d6b4037caf9ee24690e2030e9a41 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 23 Aug 2024 15:20:26 +0200 Subject: [PATCH 15/21] Update guide template --- guide/src/templates/help_templates/fee/transfer.md | 3 +++ guide/src/templates/help_templates/tx/ft-transfer.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/guide/src/templates/help_templates/fee/transfer.md b/guide/src/templates/help_templates/fee/transfer.md index f3eec45f90..9e20316f11 100644 --- a/guide/src/templates/help_templates/fee/transfer.md +++ b/guide/src/templates/help_templates/fee/transfer.md @@ -14,6 +14,9 @@ OPTIONS: -h, --help Print help information + --ics20-version + ICS20 version of the channel. Defaults to 1 [default: 1] + --key-name Use the given signing key name (default: `key_name` config) diff --git a/guide/src/templates/help_templates/tx/ft-transfer.md b/guide/src/templates/help_templates/tx/ft-transfer.md index 80efc23fd9..91e8636db6 100644 --- a/guide/src/templates/help_templates/tx/ft-transfer.md +++ b/guide/src/templates/help_templates/tx/ft-transfer.md @@ -11,6 +11,9 @@ OPTIONS: -h, --help Print help information + --ics20-version + ICS20 version of the channel. Defaults to 1 [default: 1] + --key-name Use the given signing key name (default: `key_name` config) From 4ab202ead1e32894285b6722bf2497c9fb04c8e5 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 23 Aug 2024 16:32:03 +0200 Subject: [PATCH 16/21] Patch ibc-proto-rs in check-guide --- .../src/core/ics23_commitment/merkle.rs | 2 +- tools/check-guide/Cargo.lock | 434 ++++++++++++------ tools/check-guide/Cargo.toml | 3 + 3 files changed, 307 insertions(+), 132 deletions(-) diff --git a/crates/relayer-types/src/core/ics23_commitment/merkle.rs b/crates/relayer-types/src/core/ics23_commitment/merkle.rs index 0b81ca67ae..ab6a43bfca 100644 --- a/crates/relayer-types/src/core/ics23_commitment/merkle.rs +++ b/crates/relayer-types/src/core/ics23_commitment/merkle.rs @@ -91,7 +91,7 @@ impl MerkleProof { match &proof.proof { Some(Proof::Exist(existence_proof)) => { subroot = - calculate_existence_root::(existence_proof) + calculate_existence_root::(&existence_proof) .map_err(|_| Error::invalid_merkle_proof())?; if !verify_membership::( diff --git a/tools/check-guide/Cargo.lock b/tools/check-guide/Cargo.lock index 645b211df2..2fc24cd8bb 100644 --- a/tools/check-guide/Cargo.lock +++ b/tools/check-guide/Cargo.lock @@ -190,9 +190,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", @@ -216,6 +216,12 @@ dependencies = [ "tungstenite", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "atty" version = "0.2.14" @@ -240,13 +246,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.3.4", "bitflags 1.3.2", "bytes", "futures-util", "http 0.2.12", - "http-body", - "hyper", + "http-body 0.4.6", + "hyper 0.14.28", "itoa", "matchit", "memchr", @@ -258,13 +264,40 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "tokio", "tower", "tower-layer", "tower-service", ] +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core 0.4.3", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 1.0.1", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "axum-core" version = "0.3.4" @@ -275,9 +308,29 @@ dependencies = [ "bytes", "futures-util", "http 0.2.12", - "http-body", + "http-body 0.4.6", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] @@ -479,9 +532,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -867,13 +920,13 @@ checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.65", ] [[package]] @@ -1378,6 +1431,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "1.8.3" @@ -1538,6 +1610,29 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "pin-project-lite", +] + [[package]] name = "httparse" version = "1.8.0" @@ -1576,9 +1671,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", - "http-body", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1590,6 +1685,27 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -1598,7 +1714,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper", + "hyper 0.14.28", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", @@ -1606,14 +1722,35 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.4.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ - "hyper", + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", "pin-project-lite", + "socket2", "tokio", - "tokio-io-timeout", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -1641,15 +1778,16 @@ dependencies = [ [[package]] name = "ibc-chain-registry" -version = "0.27.2" +version = "0.29.2" dependencies = [ "async-trait", "flex-error", "futures", - "http 0.2.12", + "http 1.1.0", "ibc-proto", + "ibc-relayer", "ibc-relayer-types", - "itertools", + "itertools 0.13.0", "reqwest", "serde", "serde_json", @@ -1660,9 +1798,8 @@ dependencies = [ [[package]] name = "ibc-proto" -version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66080040d5a4800d52966d55b055400f86b79c34b854b935bef03c87aacda62a" +version = "0.47.0" +source = "git+https://github.com/cosmos/ibc-proto-rs.git?branch=luca_joss/update-ibc-go-commit#385e32cfbbc27ac3db0a03d2469fcecdc6f24111" dependencies = [ "base64 0.22.1", "bytes", @@ -1678,7 +1815,7 @@ dependencies = [ [[package]] name = "ibc-relayer" -version = "0.27.2" +version = "0.29.2" dependencies = [ "anyhow", "async-stream", @@ -1698,13 +1835,13 @@ dependencies = [ "generic-array", "hdpath", "hex", - "http 0.2.12", + "http 1.1.0", "humantime", "humantime-serde", "ibc-proto", "ibc-relayer-types", "ibc-telemetry", - "itertools", + "itertools 0.13.0", "moka", "num-bigint", "num-rational", @@ -1734,7 +1871,7 @@ dependencies = [ "tiny-keccak", "tokio", "tokio-stream", - "toml 0.8.13", + "toml 0.8.19", "tonic", "tracing", "tracing-subscriber", @@ -1743,7 +1880,7 @@ dependencies = [ [[package]] name = "ibc-relayer-cli" -version = "1.8.2" +version = "1.10.2" dependencies = [ "abscissa_core", "clap 3.2.25", @@ -1757,14 +1894,14 @@ dependencies = [ "flex-error", "futures", "hdpath", - "http 0.2.12", + "http 1.1.0", "humantime", "ibc-chain-registry", "ibc-relayer", "ibc-relayer-rest", "ibc-relayer-types", "ibc-telemetry", - "itertools", + "itertools 0.13.0", "oneline-eyre", "regex", "serde", @@ -1782,9 +1919,9 @@ dependencies = [ [[package]] name = "ibc-relayer-rest" -version = "0.27.2" +version = "0.29.2" dependencies = [ - "axum", + "axum 0.6.20", "crossbeam-channel", "ibc-relayer", "ibc-relayer-types", @@ -1795,14 +1932,14 @@ dependencies = [ [[package]] name = "ibc-relayer-types" -version = "0.27.2" +version = "0.29.2" dependencies = [ "bytes", "derive_more", "flex-error", "ibc-proto", "ics23", - "itertools", + "itertools 0.13.0", "num-rational", "primitive-types", "prost", @@ -1821,9 +1958,9 @@ dependencies = [ [[package]] name = "ibc-telemetry" -version = "0.27.2" +version = "0.29.2" dependencies = [ - "axum", + "axum 0.6.20", "dashmap", "ibc-relayer-types", "moka", @@ -1840,9 +1977,9 @@ dependencies = [ [[package]] name = "ics23" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc3b8be84e7285c73b88effdc3294b552277d6b0ec728ee016c861b7b9a2c19c" +checksum = "73b17f1a5bd7d12ad30a21445cfa5f52fd7651cb3243ba866f9916b1ec112f12" dependencies = [ "anyhow", "blake2", @@ -1975,6 +2112,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -2222,11 +2368,23 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "moka" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e0d88686dc561d743b40de8269b26eaf0dc58781bde087b0984646602021d08" +checksum = "32cf62eb4dd975d2dde76432fb1075c49e3ee2331cf36f1f8fd4b66550d32b6f" dependencies = [ "crossbeam-channel", "crossbeam-epoch", @@ -2271,7 +2429,7 @@ dependencies = [ "kqueue", "libc", "log", - "mio", + "mio 0.8.11", "walkdir", "windows-sys 0.48.0", ] @@ -2344,16 +2502,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.9", - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -2789,9 +2937,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" dependencies = [ "bytes", "prost-derive", @@ -2799,12 +2947,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" dependencies = [ "anyhow", - "itertools", + "itertools 0.12.1", "proc-macro2", "quote", "syn 2.0.65", @@ -2812,9 +2960,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" dependencies = [ "prost", ] @@ -2937,9 +3085,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -2990,10 +3138,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", - "http-body", - "hyper", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls", "ipnet", "js-sys", @@ -3008,7 +3156,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-rustls 0.24.1", @@ -3120,6 +3268,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls" +version = "0.23.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.4", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3322,9 +3485,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.202" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] @@ -3350,9 +3513,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", @@ -3361,11 +3524,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -3393,9 +3557,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -3669,6 +3833,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "synstructure" version = "0.12.6" @@ -3722,9 +3892,9 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.36.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b50aae6ec24c3429149ad59b5b8d3374d7804d4c7d6125ceb97cb53907fb68d" +checksum = "505d9d6ffeb83b1de47c307c6e0d2dff56c6256989299010ad03cd80a8491e97" dependencies = [ "bytes", "digest 0.10.7", @@ -3753,23 +3923,23 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.36.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e07b383dc8780ebbec04cfb603f3fdaba6ea6663d8dd861425b1ffa7761fe90d" +checksum = "9de111ea653b2adaef627ac2452b463c77aa615c256eaaddf279ec5a1cf9775f" dependencies = [ "flex-error", "serde", "serde_json", "tendermint", - "toml 0.8.13", + "toml 0.8.19", "url", ] [[package]] name = "tendermint-light-client" -version = "0.36.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "331544139bbcf353acb5f56e733093d8e4bf2522cda0491b4bba7039ef0b944e" +checksum = "d91e5abb448c65e8abdfe0e17a3a189e005a71b4169b89f36aaa2053ff239577" dependencies = [ "contracts", "crossbeam-channel", @@ -3792,9 +3962,9 @@ dependencies = [ [[package]] name = "tendermint-light-client-detector" -version = "0.36.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73d0ffaf614bd2db605c4762e3a31a536b73cd45488fa5bace050135ca348f28" +checksum = "eb1ac1607eb7a3393313558b339c36eebeba15aa7f2d101d1d47299e65825152" dependencies = [ "crossbeam-channel", "derive_more", @@ -3815,9 +3985,9 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" -version = "0.36.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4216e487165e5dbd7af79952eaa0d5f06c5bde861eb76c690acd7f2d2a19395c" +checksum = "7a2674adbf0dc51aa0c8eaf8462c7d6692ec79502713e50ed5432a442002be90" dependencies = [ "derive_more", "flex-error", @@ -3828,9 +3998,9 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.36.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f193d04afde6592c20fd70788a10b8cb3823091c07456db70d8a93f5fb99c1" +checksum = "8ed14abe3b0502a3afe21ca74ca5cdd6c7e8d326d982c26f98a394445eb31d6e" dependencies = [ "bytes", "flex-error", @@ -3844,9 +4014,9 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.36.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e3c231a3632cab53f92ad4161c730c468c08cfe4f0aa5a6735b53b390aecbd" +checksum = "02f96a2b8a0d3d0b59e4024b1a6bdc1589efc6af4709d08a480a20cc4ba90f63" dependencies = [ "async-trait", "async-tungstenite", @@ -3914,18 +4084,18 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -4017,38 +4187,27 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.2", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -4076,6 +4235,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.10", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -4123,9 +4293,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", @@ -4135,18 +4305,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ "indexmap 2.2.6", "serde", @@ -4157,28 +4327,30 @@ dependencies = [ [[package]] name = "tonic" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" dependencies = [ "async-stream", "async-trait", - "axum", - "base64 0.21.7", + "axum 0.7.5", + "base64 0.22.1", "bytes", - "h2", - "http 0.2.12", - "http-body", - "hyper", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", "prost", "rustls-native-certs 0.7.0", "rustls-pemfile 2.1.2", - "rustls-pki-types", + "socket2", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-stream", "tower", "tower-layer", @@ -4462,9 +4634,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom", ] @@ -4520,7 +4692,7 @@ dependencies = [ "futures-util", "headers", "http 0.2.12", - "hyper", + "hyper 0.14.28", "log", "mime", "mime_guess", @@ -4800,9 +4972,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] diff --git a/tools/check-guide/Cargo.toml b/tools/check-guide/Cargo.toml index e5a77be25f..f698941ef8 100644 --- a/tools/check-guide/Cargo.toml +++ b/tools/check-guide/Cargo.toml @@ -11,3 +11,6 @@ lazy_static = "1.4.0" mdbook-template = "1.1.0" regex = "1" walkdir = "2.3.3" + +[patch.crates-io] +ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "luca_joss/update-ibc-go-commit" } \ No newline at end of file From 788b70dfb47d09b344c7438d77edf49c5ba2b8a7 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 23 Aug 2024 16:55:20 +0200 Subject: [PATCH 17/21] Revert change required with patched ibc-proto-rs --- crates/relayer-types/src/core/ics23_commitment/merkle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/relayer-types/src/core/ics23_commitment/merkle.rs b/crates/relayer-types/src/core/ics23_commitment/merkle.rs index ab6a43bfca..0b81ca67ae 100644 --- a/crates/relayer-types/src/core/ics23_commitment/merkle.rs +++ b/crates/relayer-types/src/core/ics23_commitment/merkle.rs @@ -91,7 +91,7 @@ impl MerkleProof { match &proof.proof { Some(Proof::Exist(existence_proof)) => { subroot = - calculate_existence_root::(&existence_proof) + calculate_existence_root::(existence_proof) .map_err(|_| Error::invalid_merkle_proof())?; if !verify_membership::( From 91f930654e7ca4f2d62e8ab982ac88027dca740c Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 26 Aug 2024 11:10:07 +0200 Subject: [PATCH 18/21] Remove unnecessary channel/ics20 version field in options and flags from CLIs --- .../relayer-cli/src/commands/fee/transfer.rs | 24 ------------------- .../relayer-cli/src/commands/tx/transfer.rs | 19 --------------- crates/relayer/src/error.rs | 4 ++++ crates/relayer/src/transfer.rs | 1 - .../src/tests/manual/simulation.rs | 7 ------ .../src/tests/ordered_channel_clear.rs | 8 ------- 6 files changed, 4 insertions(+), 59 deletions(-) diff --git a/crates/relayer-cli/src/commands/fee/transfer.rs b/crates/relayer-cli/src/commands/fee/transfer.rs index e135e7c795..e6e9a0450c 100644 --- a/crates/relayer-cli/src/commands/fee/transfer.rs +++ b/crates/relayer-cli/src/commands/fee/transfer.rs @@ -5,7 +5,6 @@ use eyre::eyre; use ibc_relayer::{ chain::handle::ChainHandle, - channel::version::Version, config::Config, transfer::{build_transfer_messages, send_messages, TransferOptions}, }; @@ -62,14 +61,6 @@ pub struct FeeTransferCmd { )] src_channel_id: ChannelId, - #[clap( - long = "ics20-version", - default_value = "1", - value_name = "ICS20_VERSION", - help = "ICS20 version of the channel. Defaults to 1" - )] - ics20_version: u64, - #[clap( long = "amount", required = true, @@ -201,7 +192,6 @@ impl FeeTransferCmd { dst_chain_id: self.dst_chain_id.clone(), src_port_id: self.src_port_id.clone(), src_channel_id: self.src_channel_id.clone(), - ics20_version: self.ics20_version, amount: self.amount, denom, receiver: self.recipient.clone(), @@ -240,7 +230,6 @@ pub struct FeeTransferOptions { pub dst_chain_id: ChainId, pub src_port_id: PortId, pub src_channel_id: ChannelId, - pub ics20_version: u64, pub amount: Amount, pub denom: String, pub receiver: Option, @@ -259,7 +248,6 @@ impl From for TransferOptions { TransferOptions { src_port_id: f.src_port_id, src_channel_id: f.src_channel_id, - channel_version: Version::ics20(f.ics20_version), // TODO: Can only create transfer on ICS20 channel tokens, receiver: f.receiver, timeout_height_offset: f.timeout_height_offset, @@ -333,7 +321,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -370,7 +357,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -407,7 +393,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "stake".to_owned(), recipient: None, @@ -446,7 +431,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: Some("other_recipient".to_owned()), @@ -485,7 +469,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -524,7 +507,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -563,7 +545,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -602,7 +583,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -641,7 +621,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -679,7 +658,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -718,7 +696,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, @@ -757,7 +734,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_a"), src_port_id: PortId::from_str("port_a").unwrap(), src_channel_id: ChannelId::from_str("channel_a").unwrap(), - ics20_version: 1, amount: Amount::from(1000u64), denom: "samoleans".to_owned(), recipient: None, diff --git a/crates/relayer-cli/src/commands/tx/transfer.rs b/crates/relayer-cli/src/commands/tx/transfer.rs index f1731cd46d..182da8c317 100644 --- a/crates/relayer-cli/src/commands/tx/transfer.rs +++ b/crates/relayer-cli/src/commands/tx/transfer.rs @@ -4,7 +4,6 @@ use abscissa_core::clap::Parser; use abscissa_core::{config::Override, FrameworkErrorKind}; use eyre::eyre; -use ibc_relayer::channel::version::Version; use ibc_relayer::{ chain::handle::ChainHandle, config::Config, @@ -60,14 +59,6 @@ pub struct TxIcs20MsgTransferCmd { )] src_channel_id: ChannelId, - #[clap( - long = "ics20-version", - default_value = "1", - value_name = "ICS20_VERSION", - help = "ICS20 version of the channel. Defaults to 1" - )] - ics20_version: u64, - #[clap( long = "amount", required = true, @@ -174,7 +165,6 @@ impl TxIcs20MsgTransferCmd { let opts = TransferOptions { src_port_id: self.src_port_id.clone(), src_channel_id: self.src_channel_id.clone(), - channel_version: Version::ics20(self.ics20_version), // TODO: Can only create transfer on ICS20 channel tokens, receiver: self.receiver.clone(), timeout_height_offset: self.timeout_height_offset, @@ -239,7 +229,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -273,7 +262,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -307,7 +295,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -343,7 +330,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -379,7 +365,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -415,7 +400,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, @@ -451,7 +435,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 21, timeout_seconds: 0, @@ -487,7 +470,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 21, @@ -523,7 +505,6 @@ mod tests { src_chain_id: ChainId::from_string("chain_sender"), src_port_id: PortId::from_str("port_sender").unwrap(), src_channel_id: ChannelId::from_str("channel_sender").unwrap(), - ics20_version: 1, amount: Amount::from(42u64), timeout_height_offset: 0, timeout_seconds: 0, diff --git a/crates/relayer/src/error.rs b/crates/relayer/src/error.rs index 5c4ad51f4d..d927a44b6c 100644 --- a/crates/relayer/src/error.rs +++ b/crates/relayer/src/error.rs @@ -638,6 +638,10 @@ define_error! { InvalidChannelString { channel: String } |e| { format!("invalid channel string {}", e.channel) }, + + UnknownIcs20Version + { version_str: String } + |e| { format!("unknown ICS20 version string {}", e.version_str) }, } } diff --git a/crates/relayer/src/transfer.rs b/crates/relayer/src/transfer.rs index e6c189072a..5a2de94638 100644 --- a/crates/relayer/src/transfer.rs +++ b/crates/relayer/src/transfer.rs @@ -124,7 +124,6 @@ impl TransferTimeout { pub struct TransferOptions { pub src_port_id: PortId, pub src_channel_id: ChannelId, - pub channel_version: Version, pub tokens: Vec<(Amount, String)>, pub receiver: Option, pub timeout_height_offset: u64, diff --git a/tools/integration-test/src/tests/manual/simulation.rs b/tools/integration-test/src/tests/manual/simulation.rs index 3f033bab28..da55ed359e 100644 --- a/tools/integration-test/src/tests/manual/simulation.rs +++ b/tools/integration-test/src/tests/manual/simulation.rs @@ -87,16 +87,9 @@ fn tx_raw_ft_transfer( memo: Option, ) -> Result, Error> { let tokens = vec![(amount.into(), denom.value().to_string())]; - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; let transfer_options = TransferOptions { src_port_id: channel.port_a.value().clone(), src_channel_id: channel.channel_id_a.value().clone(), - channel_version: channel_version.clone(), tokens, receiver: Some(recipient.value().0.clone()), timeout_height_offset, diff --git a/tools/integration-test/src/tests/ordered_channel_clear.rs b/tools/integration-test/src/tests/ordered_channel_clear.rs index 95c64c99c1..f1f85387f8 100644 --- a/tools/integration-test/src/tests/ordered_channel_clear.rs +++ b/tools/integration-test/src/tests/ordered_channel_clear.rs @@ -244,13 +244,6 @@ impl BinaryChannelTest for OrderedChannelClearEqualCLITest { num_msgs ); - let channel_version = channel.channel.src_version().ok_or_else(|| { - Error::generic(eyre!( - "failed to retrieve channel version for channel `{:#?}`", - channel.channel.src_channel_id() - )) - })?; - let tokens = vec![( random_u64_range(1000, 5000).into(), chains.node_a.denom().value().to_string(), @@ -259,7 +252,6 @@ impl BinaryChannelTest for OrderedChannelClearEqualCLITest { let transfer_options = TransferOptions { src_port_id: channel.port_a.value().clone(), src_channel_id: channel.channel_id_a.value().clone(), - channel_version: channel_version.clone(), tokens, receiver: Some(chains.node_b.wallets().user1().address().value().0.clone()), timeout_height_offset: 1000, From af93eb6793ca610d060296b19571164230f1b5d1 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 26 Aug 2024 11:10:43 +0200 Subject: [PATCH 19/21] Update template --- guide/src/templates/help_templates/fee/transfer.md | 3 --- guide/src/templates/help_templates/tx/ft-transfer.md | 3 --- 2 files changed, 6 deletions(-) diff --git a/guide/src/templates/help_templates/fee/transfer.md b/guide/src/templates/help_templates/fee/transfer.md index 9e20316f11..f3eec45f90 100644 --- a/guide/src/templates/help_templates/fee/transfer.md +++ b/guide/src/templates/help_templates/fee/transfer.md @@ -14,9 +14,6 @@ OPTIONS: -h, --help Print help information - --ics20-version - ICS20 version of the channel. Defaults to 1 [default: 1] - --key-name Use the given signing key name (default: `key_name` config) diff --git a/guide/src/templates/help_templates/tx/ft-transfer.md b/guide/src/templates/help_templates/tx/ft-transfer.md index 91e8636db6..80efc23fd9 100644 --- a/guide/src/templates/help_templates/tx/ft-transfer.md +++ b/guide/src/templates/help_templates/tx/ft-transfer.md @@ -11,9 +11,6 @@ OPTIONS: -h, --help Print help information - --ics20-version - ICS20 version of the channel. Defaults to 1 [default: 1] - --key-name Use the given signing key name (default: `key_name` config) From fcf2b23d61d638472cef9ba81197642d2982c938 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 26 Aug 2024 11:26:48 +0200 Subject: [PATCH 20/21] Cleanup code --- .../src/applications/transfer/packet.rs | 2 -- .../src/core/ics23_commitment/merkle.rs | 7 ---- crates/relayer/src/transfer.rs | 32 ------------------- tools/integration-test/Cargo.toml | 2 +- 4 files changed, 1 insertion(+), 42 deletions(-) diff --git a/crates/relayer-types/src/applications/transfer/packet.rs b/crates/relayer-types/src/applications/transfer/packet.rs index 2f1dbac84b..8da7ef6410 100644 --- a/crates/relayer-types/src/applications/transfer/packet.rs +++ b/crates/relayer-types/src/applications/transfer/packet.rs @@ -66,8 +66,6 @@ impl TryFrom for PacketDataV2 { .into_iter() .map(|token| token.try_into()) .collect::, _>>()?; - //let denom = PrefixedDenom::from_str(&raw_pkt_data.denom)?; - //let amount = Amount::from_str(&raw_pkt_data.amount)?; let memo = Some(raw_pkt_data.memo).filter(|m| !m.is_empty()); Ok(Self { tokens, diff --git a/crates/relayer-types/src/core/ics23_commitment/merkle.rs b/crates/relayer-types/src/core/ics23_commitment/merkle.rs index 0b81ca67ae..cc7abb220d 100644 --- a/crates/relayer-types/src/core/ics23_commitment/merkle.rs +++ b/crates/relayer-types/src/core/ics23_commitment/merkle.rs @@ -9,17 +9,10 @@ use ics23::{ NonExistenceProof, }; -//use crate::core::ics23_commitment::commitment::{CommitmentPrefix, CommitmentRoot}; use crate::core::ics23_commitment::commitment::CommitmentRoot; use crate::core::ics23_commitment::error::Error; use crate::core::ics23_commitment::specs::ProofSpecs; -/*pub fn apply_prefix(prefix: &CommitmentPrefix, mut path: Vec) -> MerklePath { - let mut key_path: Vec = vec![format!("{prefix:?}")]; - key_path.append(&mut path); - MerklePath { key_path } -}*/ - impl From for MerkleRoot { fn from(root: CommitmentRoot) -> Self { Self { diff --git a/crates/relayer/src/transfer.rs b/crates/relayer/src/transfer.rs index 5a2de94638..afd45da6c5 100644 --- a/crates/relayer/src/transfer.rs +++ b/crates/relayer/src/transfer.rs @@ -186,38 +186,6 @@ pub fn build_transfer_message( } } -/*pub fn build_transfer_message_v2( - src_port_id: PortId, - src_channel_id: ChannelId, - tokens: Vec<(Amount, String)>, - sender: Signer, - receiver: Signer, - timeout_height: TimeoutHeight, - timeout_timestamp: Timestamp, - memo: Option, -) -> Any { - let tokens = tokens - .iter() - .map(|(amount, denom)| Coin { - denom: denom.clone(), - amount: amount.to_string(), - }) - .collect(); - let msg = MsgTransfer { - source_port: src_port_id, - source_channel: src_channel_id, - token: None, - sender, - receiver, - timeout_height, - timeout_timestamp, - memo, - tokens, - }; - - msg.to_any() -}*/ - pub fn build_transfer_messages( src_chain: &SrcChain, // the chain whose account is debited dst_chain: &DstChain, // the chain whose account eventually gets credited diff --git a/tools/integration-test/Cargo.toml b/tools/integration-test/Cargo.toml index dfdf956887..44f69a8a4d 100644 --- a/tools/integration-test/Cargo.toml +++ b/tools/integration-test/Cargo.toml @@ -50,7 +50,7 @@ new-register-interchain-account = [] authz = [] benchmark = [] no-denom-trace = [] -ics20-v2 = [] +ics20-v2 = [] [[bin]] name = "test_setup_with_binary_channel" From d4816ff86c005ded6f11fb6c123016d9f8d3f6bb Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:40:44 +0200 Subject: [PATCH 21/21] Deserialize ics20 v2 packet data with Protobuf (#4165) * Deserialize PacketData for ICS20 v2 with Protobuf * Add memo field filter test for ICS20 v2 * Set ICS20 v2 memo filter test behind feature * Add changelog entry * Update comment when creating new Link from opts --- ...lize-ics20-v2-packet-data-with-protobuf.md | 2 ++ crates/relayer/src/link.rs | 19 ++++++++++++++++-- crates/relayer/src/link/relay_path.rs | 12 ++++++----- .../src/tests/ics20_filter/memo.rs | 20 ++++++++++++++++--- 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 .changelog/unreleased/improvements/ibc-relayer/4098-deserialize-ics20-v2-packet-data-with-protobuf.md diff --git a/.changelog/unreleased/improvements/ibc-relayer/4098-deserialize-ics20-v2-packet-data-with-protobuf.md b/.changelog/unreleased/improvements/ibc-relayer/4098-deserialize-ics20-v2-packet-data-with-protobuf.md new file mode 100644 index 0000000000..96cc10baa8 --- /dev/null +++ b/.changelog/unreleased/improvements/ibc-relayer/4098-deserialize-ics20-v2-packet-data-with-protobuf.md @@ -0,0 +1,2 @@ +- Deserialize ICS20 v2 packet data using Protobuf instead of JSON + ([\#4098](https://github.com/informalsystems/hermes/issues/4098)) \ No newline at end of file diff --git a/crates/relayer/src/link.rs b/crates/relayer/src/link.rs index 3d87499480..e264a590e3 100644 --- a/crates/relayer/src/link.rs +++ b/crates/relayer/src/link.rs @@ -145,6 +145,21 @@ impl Link { )); } + // Query the channel if it exists in order to retrieve the channel version. + // If the channel doesn't exist or the query fails, set the version to None. + let maybe_channel_a = a_chain.query_channel( + QueryChannelRequest { + port_id: opts.src_port_id.clone(), + channel_id: opts.src_channel_id.clone(), + height: QueryHeight::Latest, + }, + IncludeProof::Yes, + ); + let channel_version = match maybe_channel_a { + Ok((channel_a, _)) => Some(channel_a.version), + Err(_) => None, + }; + let channel = Channel { ordering: a_channel.ordering, a_side: ChannelSide::new( @@ -153,7 +168,7 @@ impl Link { a_connection_id, opts.src_port_id.clone(), Some(opts.src_channel_id.clone()), - None, + channel_version.clone(), ), b_side: ChannelSide::new( b_chain.clone(), @@ -161,7 +176,7 @@ impl Link { a_connection.counterparty().connection_id().unwrap().clone(), a_channel.counterparty().port_id.clone(), Some(b_channel_id.clone()), - None, + channel_version, ), connection_delay: a_connection.delay_period(), }; diff --git a/crates/relayer/src/link/relay_path.rs b/crates/relayer/src/link/relay_path.rs index bb1d917540..02af243b21 100644 --- a/crates/relayer/src/link/relay_path.rs +++ b/crates/relayer/src/link/relay_path.rs @@ -2,13 +2,15 @@ use alloc::collections::BTreeMap as HashMap; use alloc::collections::VecDeque; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics04_channel::version::Version; +use prost::Message; +use serde::de::Error as _; use serde_json::Error; use std::ops::Sub; use std::time::{Duration, Instant}; use ibc_proto::google::protobuf::Any; -use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketData as RawPacketData; -use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketDataV2 as RawPacketDataV2; +use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketData; +use ibc_proto::ibc::applications::transfer::v2::FungibleTokenPacketDataV2; use itertools::Itertools; use tracing::{debug, error, info, span, trace, warn, Level}; @@ -2020,12 +2022,12 @@ fn extract_memo_and_receiver( data: &[u8], ) -> Result<(String, String), Error> { if channel_version.is_ics20_v2() { - match serde_json::from_slice::(data) { + match FungibleTokenPacketDataV2::decode(data) { Ok(packet_data) => Ok((packet_data.memo, packet_data.receiver)), - Err(e) => Err(e), + Err(e) => Err(Error::custom(e.to_string())), } } else { - match serde_json::from_slice::(data) { + match serde_json::from_slice::(data) { Ok(packet_data) => Ok((packet_data.memo, packet_data.receiver)), Err(e) => Err(e), } diff --git a/tools/integration-test/src/tests/ics20_filter/memo.rs b/tools/integration-test/src/tests/ics20_filter/memo.rs index e46fad7ff0..f02da4bbf5 100644 --- a/tools/integration-test/src/tests/ics20_filter/memo.rs +++ b/tools/integration-test/src/tests/ics20_filter/memo.rs @@ -1,16 +1,26 @@ use byte_unit::Byte; -use ibc_relayer::config::types::ics20_field_size_limit::Ics20FieldSizeLimit; +use ibc_relayer::{ + channel::version::Version, config::types::ics20_field_size_limit::Ics20FieldSizeLimit, +}; use ibc_test_framework::prelude::*; #[test] fn test_memo_filter() -> Result<(), Error> { - run_binary_channel_test(&IbcMemoFilterTest) + run_binary_channel_test(&IbcMemoFilterTest { ics20_version: 1 }) +} + +#[cfg(any(doc, feature = "ics20-v2"))] +#[test] +fn test_memo_filter_ics20_v2() -> Result<(), Error> { + run_binary_channel_test(&IbcMemoFilterTest { ics20_version: 2 }) } const MEMO_SIZE_LIMIT: usize = 2000; -pub struct IbcMemoFilterTest; +pub struct IbcMemoFilterTest { + pub ics20_version: u64, +} impl TestOverrides for IbcMemoFilterTest { fn modify_relayer_config(&self, config: &mut Config) { @@ -19,6 +29,10 @@ impl TestOverrides for IbcMemoFilterTest { config.mode.clients.misbehaviour = false; } + + fn channel_version(&self) -> Version { + Version::ics20(self.ics20_version) + } } impl BinaryChannelTest for IbcMemoFilterTest {