Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memo_overwrite configuration #4103

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/unreleased/bug-fixe/4104-memo-overwrite-bug.md
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/commands/tx/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/relayer-cli/src/conclude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions crates/relayer-cli/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use once_cell::sync::Lazy;
pub static RUNNER: Lazy<CmdRunner> = 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();
Expand All @@ -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();
Expand Down
26 changes: 22 additions & 4 deletions crates/relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -799,7 +805,7 @@ impl CosmosSdkChain {
&self.tx_config,
&key_pair,
account,
&self.config.memo_prefix,
&memo_prefix,
proto_msgs,
)
.await
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions crates/relayer/src/config/filter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Custom `serde` deserializer for `FilterMatch`

#![allow(clippy::mutable_key_type)]

use core::fmt;
use core::str::FromStr;
use itertools::Itertools;
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/link/relay_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> RelayPath<ChainA, ChainB> {
/// 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.
Expand Down
2 changes: 2 additions & 0 deletions tools/integration-test/src/tests/fee/filter_fees.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::mutable_key_type)]

use std::collections::HashMap;

use ibc_relayer::config::filter::{ChannelPolicy, FeePolicy, FilterPattern, MinFee};
Expand Down
2 changes: 1 addition & 1 deletion tools/integration-test/src/tests/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Loading