Skip to content

Commit

Permalink
Merge branch 'master' into luca_joss/skip-sequences-on-clear
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 authored Mar 6, 2024
2 parents b9a46f3 + 40d74f6 commit 3916039
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Add a per-chain configuration `memo_overwrite` allowing users
to overwite the relayer memo used for each transaction
([\#3811](https://github.com/informalsystems/hermes/issues/3811))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Recover from gas simulation failures on legacy chains.
([\#3792](https://github.com/informalsystems/hermes/issues/3792))
2 changes: 1 addition & 1 deletion .github/workflows/cargo-doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: nightly-2024-03-03
override: true

- name: Build API documentation
Expand Down
25 changes: 12 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ trust_threshold = '2/3'
# operational debugging information, e.g., relayer build version.
memo_prefix = ''

# If this is set to a string, it will overwrite the memo used by Hermes for each transaction
# it submits to this chain.
# Default: not set.
# This is used for chains which have a very small character limit for the memo,
# and the additional information appended by Hermes would overflow that limit.
# memo_overwrite = ''

# This section specifies the filters for policy based relaying.
#
# Default: no policy / filters, allow all packets on all channels.
Expand Down
1 change: 1 addition & 0 deletions crates/relayer-cli/src/chain_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ where
client_refresh_rate: default::client_refresh_rate(),
ccv_consumer_chain: false,
memo_prefix: Memo::default(),
memo_overwrite: None,
proof_specs: Default::default(),
trust_threshold: TrustThreshold::default(),
gas_price: GasPrice {
Expand Down
6 changes: 5 additions & 1 deletion crates/relayer-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ impl Configurable<Config> for CliCmd {
for ccfg in config.chains.iter_mut() {
#[allow(irrefutable_let_patterns)]
if let ChainConfig::CosmosSdk(ref mut cosmos_ccfg) = ccfg {
cosmos_ccfg.memo_prefix.apply_suffix(&suffix);
if let Some(memo) = &cosmos_ccfg.memo_overwrite {
cosmos_ccfg.memo_prefix = memo.clone();
} else {
cosmos_ccfg.memo_prefix.apply_suffix(&suffix);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ subtle-encoding = "0.5"
humantime-serde = "1.1.1"
serde = "1.0"
serde_derive = "1.0"
thiserror = "1.0.56"
thiserror = "1.0.57"
toml = "0.8"
tracing = "0.1.36"
tokio = { version = "1.0", features = ["rt-multi-thread", "time", "sync"] }
Expand Down Expand Up @@ -66,7 +66,7 @@ ed25519 = "2.2.2"
ed25519-dalek = { version = "2.0.0", features = ["serde"] }
ed25519-dalek-bip32 = "0.3.0"
generic-array = "0.14.7"
secp256k1 = { version = "0.28.1", features = ["rand-std"] }
secp256k1 = { version = "0.28.2", features = ["rand-std"] }
strum = { version = "0.25", features = ["derive"] }
tokio-stream = "0.1.14"
once_cell = "1.19.0"
Expand Down
3 changes: 3 additions & 0 deletions crates/relayer/src/chain/cosmos/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ pub struct CosmosSdkConfig {
#[serde(default)]
pub memo_prefix: Memo,

#[serde(default)]
pub memo_overwrite: Option<Memo>,

// This is an undocumented and hidden config to make the relayer wait for
// DeliverTX before sending the next transaction when sending messages in
// multiple batches. We will instruct relayer operators to turn this on
Expand Down
1 change: 1 addition & 0 deletions crates/relayer/src/chain/cosmos/estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ fn can_recover_from_simulation_failure(e: &Error) -> bool {
detail.is_client_state_height_too_low()
|| detail.is_account_sequence_mismatch_that_can_be_ignored()
|| detail.is_out_of_order_packet_sequence_error()
|| detail.is_empty_tx_error()
}
_ => false,
}
Expand Down
8 changes: 8 additions & 0 deletions crates/relayer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,14 @@ impl GrpcStatusSubdetail {
Some((expected, got)) => expected < got,
}
}

/// Check whether this gRPC error message contains the string "invalid empty tx".
///
/// ## Note
/// This error may happen for older chains that does not properly support simulation.
pub fn is_empty_tx_error(&self) -> bool {
self.status.message().contains("invalid empty tx")
}
}

/// Assumes that the cosmos-sdk account sequence mismatch error message, that may be seen
Expand Down
2 changes: 1 addition & 1 deletion tools/integration-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ name = "test_setup_with_binary_channel"
doc = true

[dev-dependencies]
tempfile = "3.6.0"
tempfile = "3.10.1"

[dependencies.tendermint]
version = "0.34.0"
Expand Down
73 changes: 73 additions & 0 deletions tools/integration-test/src/tests/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ use ibc_test_framework::ibc::denom::derive_ibc_denom;
use ibc_test_framework::prelude::*;
use ibc_test_framework::util::random::{random_string, random_u128_range};

const OVERWRITE_MEMO: &str = "Overwritten memo";

#[test]
fn test_memo() -> Result<(), Error> {
let memo = Memo::new(random_string()).unwrap();
let test = MemoTest { memo };
run_binary_channel_test(&test)
}

#[test]
fn test_memo_overwrite() -> Result<(), Error> {
let memo = Memo::new(random_string()).unwrap();
let test = MemoTest { memo };
run_binary_channel_test(&test)
}

pub struct MemoTest {
memo: Memo,
}
Expand Down Expand Up @@ -82,6 +91,70 @@ impl BinaryChannelTest for MemoTest {
}
}

pub struct MemoOverwriteTest {
memo: Memo,
}

impl TestOverrides for MemoOverwriteTest {
fn modify_relayer_config(&self, config: &mut Config) {
for chain in config.chains.iter_mut() {
match chain {
ChainConfig::CosmosSdk(chain_config) => {
chain_config.memo_prefix = self.memo.clone();
chain_config.memo_overwrite = Some(Memo::new(OVERWRITE_MEMO).unwrap())
}
}
}
}
}

impl BinaryChannelTest for MemoOverwriteTest {
fn run<ChainA: ChainHandle, ChainB: ChainHandle>(
&self,
_config: &TestConfig,
_relayer: RelayerDriver,
chains: ConnectedChains<ChainA, ChainB>,
channel: ConnectedChannel<ChainA, ChainB>,
) -> Result<(), Error> {
info!(
"testing IBC transfer with memo configured: \"{}\"",
self.memo
);

let denom_a = chains.node_a.denom();

let a_to_b_amount = random_u128_range(1000, 5000);

chains.node_a.chain_driver().ibc_transfer_token(
&channel.port_a.as_ref(),
&channel.channel_id_a.as_ref(),
&chains.node_a.wallets().user1(),
&chains.node_b.wallets().user1().address(),
&denom_a.with_amount(a_to_b_amount).as_ref(),
)?;

let denom_b = derive_ibc_denom(
&channel.port_b.as_ref(),
&channel.channel_id_b.as_ref(),
&denom_a,
)?;

chains.node_b.chain_driver().assert_eventual_wallet_amount(
&chains.node_b.wallets().user1().address(),
&denom_b.with_amount(a_to_b_amount).as_ref(),
)?;

let tx_info = chains
.node_b
.chain_driver()
.query_recipient_transactions(&chains.node_b.wallets().user1().address())?;

assert_tx_memo_equals(&tx_info, OVERWRITE_MEMO)?;

Ok(())
}
}

fn assert_tx_memo_equals(tx_info: &json::Value, expected_memo: &str) -> Result<(), Error> {
debug!("comparing memo field from json value {}", tx_info);

Expand Down
1 change: 1 addition & 0 deletions tools/test-framework/src/types/single/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl FullNode {
packet_filter: Default::default(),
address_type: chain_type.address_type(),
memo_prefix: Default::default(),
memo_overwrite: None,
proof_specs: Default::default(),
extension_options: Default::default(),
sequential_batch_tx: false,
Expand Down

0 comments on commit 3916039

Please sign in to comment.