From 1db5a3ff2e1541f745db898ac1c4f2ca7ff90014 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 29 Jul 2024 15:01:25 +0200 Subject: [PATCH 1/5] Fix clippy warnings from v1.80 --- crates/relayer-cli/src/commands/tx/channel.rs | 2 +- crates/relayer-cli/src/conclude.rs | 6 +++--- crates/relayer-cli/tests/acceptance.rs | 2 -- crates/relayer/src/config.rs | 2 ++ crates/relayer/src/config/filter.rs | 2 ++ crates/relayer/src/link/relay_path.rs | 2 +- tools/integration-test/src/tests/fee/filter_fees.rs | 4 ++++ tools/integration-test/src/tests/memo.rs | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/relayer-cli/src/commands/tx/channel.rs b/crates/relayer-cli/src/commands/tx/channel.rs index de75a48aaf..7db47011e7 100644 --- a/crates/relayer-cli/src/commands/tx/channel.rs +++ b/crates/relayer-cli/src/commands/tx/channel.rs @@ -23,7 +23,7 @@ use crate::prelude::*; /// /// The macro takes the following arguments: /// - `$dbg_string`: a string literal that will be used to identify the subcommand -/// in debug logs +/// in debug logs /// - `$func`: the method that will be called to build and send the `Channel` message /// - `$self`: the type that `Runnable` is being implemented for /// - `$chan`: a closure that specifies how to build the `Channel` object diff --git a/crates/relayer-cli/src/conclude.rs b/crates/relayer-cli/src/conclude.rs index f2190ceb42..7ee650583c 100644 --- a/crates/relayer-cli/src/conclude.rs +++ b/crates/relayer-cli/src/conclude.rs @@ -17,9 +17,9 @@ //! ``` //! //! - Exit from a query/tx with an error of type `anomaly`: -//! In the case where the error is a complex type such as anomaly (including backtraces), it is -//! better to simplify the output and only write out the chain of error sources, which we can -//! achieve with `format!("{}", e)`. The complete solution is as follows: +//! In the case where the error is a complex type such as anomaly (including backtraces), it is +//! better to simplify the output and only write out the chain of error sources, which we can +//! achieve with `format!("{}", e)`. The complete solution is as follows: //! //! ```ignore //! let e: Error = Kind::Query.into(); diff --git a/crates/relayer-cli/tests/acceptance.rs b/crates/relayer-cli/tests/acceptance.rs index 208164e0bf..6b568ee1ef 100644 --- a/crates/relayer-cli/tests/acceptance.rs +++ b/crates/relayer-cli/tests/acceptance.rs @@ -24,7 +24,6 @@ use once_cell::sync::Lazy; pub static RUNNER: Lazy = Lazy::new(CmdRunner::default); /// Use `Config::default()` value if no config or args -#[cfg(not(tarpaulin))] #[test] fn start_no_args() { let mut runner = RUNNER.clone(); @@ -40,7 +39,6 @@ fn start_no_args() { cmd.wait().unwrap().expect_success(); } -#[cfg(not(tarpaulin))] #[test] fn example_configuration_is_valid() { let mut runner = RUNNER.clone(); diff --git a/crates/relayer/src/config.rs b/crates/relayer/src/config.rs index 80e4923aa1..c782927eab 100644 --- a/crates/relayer/src/config.rs +++ b/crates/relayer/src/config.rs @@ -3,6 +3,8 @@ pub mod compat_mode; pub mod dynamic_gas; pub mod error; +/// TODO: Fix mutable_key_type warning +#[allow(clippy::mutable_key_type)] pub mod filter; pub mod gas_multiplier; pub mod proof_specs; diff --git a/crates/relayer/src/config/filter.rs b/crates/relayer/src/config/filter.rs index 576c62a8ee..b888e4eccf 100644 --- a/crates/relayer/src/config/filter.rs +++ b/crates/relayer/src/config/filter.rs @@ -31,6 +31,8 @@ impl Default for PacketFilter { } } +/// TODO: Fix mutable_key_type warning +#[allow(clippy::mutable_key_type)] impl PacketFilter { pub fn new( channel_policy: ChannelPolicy, diff --git a/crates/relayer/src/link/relay_path.rs b/crates/relayer/src/link/relay_path.rs index 04a34947b9..790571f482 100644 --- a/crates/relayer/src/link/relay_path.rs +++ b/crates/relayer/src/link/relay_path.rs @@ -744,7 +744,7 @@ impl RelayPath { /// Return value: /// - `Some(..)`: a new operational data from which to retry sending, /// - `None`: all the events in the initial operational data were exhausted (i.e., turned - /// into timeouts), so there is nothing to retry. + /// into timeouts), so there is nothing to retry. /// /// Side effects: may schedule a new operational data targeting the source chain, comprising /// new timeout messages. diff --git a/tools/integration-test/src/tests/fee/filter_fees.rs b/tools/integration-test/src/tests/fee/filter_fees.rs index 218229d65f..a8da7472f6 100644 --- a/tools/integration-test/src/tests/fee/filter_fees.rs +++ b/tools/integration-test/src/tests/fee/filter_fees.rs @@ -18,6 +18,8 @@ fn test_filter_by_channel_incentivized_fees_relayer() -> Result<(), Error> { struct FilterIncentivizedFeesRelayerTest; +/// TODO: Fix mutable_key_type warning +#[allow(clippy::mutable_key_type)] impl TestOverrides for FilterIncentivizedFeesRelayerTest { fn modify_relayer_config(&self, config: &mut Config) { config.mode.packets.auto_register_counterparty_payee = true; @@ -166,6 +168,8 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { struct FilterByChannelIncentivizedFeesRelayerTest; +/// TODO: Fix mutable_key_type warning +#[allow(clippy::mutable_key_type)] impl TestOverrides for FilterByChannelIncentivizedFeesRelayerTest { fn modify_relayer_config(&self, config: &mut Config) { config.mode.packets.auto_register_counterparty_payee = true; diff --git a/tools/integration-test/src/tests/memo.rs b/tools/integration-test/src/tests/memo.rs index a44ee417cf..cf59bb712d 100644 --- a/tools/integration-test/src/tests/memo.rs +++ b/tools/integration-test/src/tests/memo.rs @@ -23,7 +23,7 @@ fn test_memo() -> Result<(), Error> { #[test] fn test_memo_overwrite() -> Result<(), Error> { let memo = Memo::new(random_string()).unwrap(); - let test = MemoTest { memo }; + let test = MemoOverwriteTest { memo }; run_binary_channel_test(&test) } From 66a52fa92081297b1ec9121bac512d4d6fa186c1 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 29 Jul 2024 15:12:41 +0200 Subject: [PATCH 2/5] Move clippy allow mutable_key_type --- crates/relayer/src/config.rs | 2 -- crates/relayer/src/config/filter.rs | 2 ++ tools/integration-test/src/tests/fee/filter_fees.rs | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/relayer/src/config.rs b/crates/relayer/src/config.rs index c782927eab..80e4923aa1 100644 --- a/crates/relayer/src/config.rs +++ b/crates/relayer/src/config.rs @@ -3,8 +3,6 @@ pub mod compat_mode; pub mod dynamic_gas; pub mod error; -/// TODO: Fix mutable_key_type warning -#[allow(clippy::mutable_key_type)] pub mod filter; pub mod gas_multiplier; pub mod proof_specs; diff --git a/crates/relayer/src/config/filter.rs b/crates/relayer/src/config/filter.rs index b888e4eccf..71f7b0177b 100644 --- a/crates/relayer/src/config/filter.rs +++ b/crates/relayer/src/config/filter.rs @@ -1,5 +1,7 @@ //! Custom `serde` deserializer for `FilterMatch` +#![allow(clippy::mutable_key_type)] + use core::fmt; use core::str::FromStr; use itertools::Itertools; diff --git a/tools/integration-test/src/tests/fee/filter_fees.rs b/tools/integration-test/src/tests/fee/filter_fees.rs index a8da7472f6..963e93e2d8 100644 --- a/tools/integration-test/src/tests/fee/filter_fees.rs +++ b/tools/integration-test/src/tests/fee/filter_fees.rs @@ -1,3 +1,5 @@ +#![allow(clippy::mutable_key_type)] + use std::collections::HashMap; use ibc_relayer::config::filter::{ChannelPolicy, FeePolicy, FilterPattern, MinFee}; @@ -18,8 +20,6 @@ fn test_filter_by_channel_incentivized_fees_relayer() -> Result<(), Error> { struct FilterIncentivizedFeesRelayerTest; -/// TODO: Fix mutable_key_type warning -#[allow(clippy::mutable_key_type)] impl TestOverrides for FilterIncentivizedFeesRelayerTest { fn modify_relayer_config(&self, config: &mut Config) { config.mode.packets.auto_register_counterparty_payee = true; @@ -168,8 +168,6 @@ impl BinaryChannelTest for FilterIncentivizedFeesRelayerTest { struct FilterByChannelIncentivizedFeesRelayerTest; -/// TODO: Fix mutable_key_type warning -#[allow(clippy::mutable_key_type)] impl TestOverrides for FilterByChannelIncentivizedFeesRelayerTest { fn modify_relayer_config(&self, config: &mut Config) { config.mode.packets.auto_register_counterparty_payee = true; From 16ef49e4f03b3cda76a3cd07e3ae9216fa71aaac Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 29 Jul 2024 15:13:27 +0200 Subject: [PATCH 3/5] Remove unnecessary clippy allow mutable_key_type --- crates/relayer/src/config/filter.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/relayer/src/config/filter.rs b/crates/relayer/src/config/filter.rs index 71f7b0177b..5feb4376e1 100644 --- a/crates/relayer/src/config/filter.rs +++ b/crates/relayer/src/config/filter.rs @@ -33,8 +33,6 @@ impl Default for PacketFilter { } } -/// TODO: Fix mutable_key_type warning -#[allow(clippy::mutable_key_type)] impl PacketFilter { pub fn new( channel_policy: ChannelPolicy, From a3f0a31bbc2dd51e8baf3000d2a50a4b2c06c75d Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 29 Jul 2024 16:22:17 +0200 Subject: [PATCH 4/5] Fix overwrite memo implementation --- crates/relayer/src/chain/cosmos.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index ae1291a625..c0f6e9c3ad 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -783,13 +783,19 @@ impl CosmosSdkChain { let account = get_or_fetch_account(&self.grpc_addr, &key_account, &mut self.account).await?; + let memo_prefix = if let Some(memo_overwrite) = &self.config.memo_overwrite { + memo_overwrite.clone() + } else { + self.config.memo_prefix.clone() + }; + if self.config.sequential_batch_tx { sequential_send_batched_messages_and_wait_commit( &self.rpc_client, &self.tx_config, &key_pair, account, - &self.config.memo_prefix, + &memo_prefix, proto_msgs, ) .await @@ -799,7 +805,7 @@ impl CosmosSdkChain { &self.tx_config, &key_pair, account, - &self.config.memo_prefix, + &memo_prefix, proto_msgs, ) .await @@ -834,12 +840,18 @@ impl CosmosSdkChain { let account = get_or_fetch_account(&self.grpc_addr, &key_account, &mut self.account).await?; + let memo_prefix = if let Some(memo_overwrite) = &self.config.memo_overwrite { + memo_overwrite.clone() + } else { + self.config.memo_prefix.clone() + }; + send_batched_messages_and_wait_check_tx( &self.rpc_client, &self.tx_config, &key_pair, account, - &self.config.memo_prefix, + &memo_prefix, proto_msgs, ) .await @@ -2379,12 +2391,18 @@ impl ChainEndpoint for CosmosSdkChain { let address = self.get_signer()?; let key_pair = self.key()?; + let memo_prefix = if let Some(memo_overwrite) = &self.config.memo_overwrite { + memo_overwrite.clone() + } else { + self.config.memo_prefix.clone() + }; + self.rt.block_on(maybe_register_counterparty_payee( &self.rpc_client, &self.tx_config, &key_pair, &mut self.account, - &self.config.memo_prefix, + &memo_prefix, channel_id, port_id, &address, From 5536e3543a74bb1eac26b655253d400a0ef152b9 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 29 Jul 2024 16:30:21 +0200 Subject: [PATCH 5/5] Add changelog entry --- .changelog/unreleased/bug-fixe/4104-memo-overwrite-bug.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/unreleased/bug-fixe/4104-memo-overwrite-bug.md diff --git a/.changelog/unreleased/bug-fixe/4104-memo-overwrite-bug.md b/.changelog/unreleased/bug-fixe/4104-memo-overwrite-bug.md new file mode 100644 index 0000000000..785c896cc6 --- /dev/null +++ b/.changelog/unreleased/bug-fixe/4104-memo-overwrite-bug.md @@ -0,0 +1,3 @@ +- Fix the `memo_overwrite` configuration to correctly apply the + overwrite if it is configured. + ([\#4104](https://github.com/informalsystems/hermes/issues/4104)) \ No newline at end of file