Skip to content

Commit

Permalink
Ensure all events in a batch are processed, even when it contains eve…
Browse files Browse the repository at this point in the history
…nts for unknown chains (#4022)

* Add a filter at supervisor level for CCQ to verify if the destination chain is configured

* Update all MSRVs to v1.76.0

* Add changelog entry

* Renaming

* Move changelog entry under bug fixes

* Ensure we process all events in a batch, even when some of them are rejected by the filtering policy

---------

Co-authored-by: Romain Ruetschi <[email protected]>
  • Loading branch information
ljoss17 and romac authored Jun 10, 2024
1 parent 1cb909a commit acde373
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fix a bug where in some cases, Hermes would drop all events in a
batch that came after an event rejected by the filtering policy
([\#4034](https://github.com/informalsystems/hermes/issues/4034))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Discard CrossChain queries intended for unconfigured chains.
([\#4021](https://github.com/informalsystems/hermes/issues/4021))
2 changes: 1 addition & 1 deletion crates/chain-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
keywords = ["cosmos", "ibc", "relayer", "chain", "registry"]
repository = "https://github.com/informalsystems/hermes"
authors = ["Informal Systems <[email protected]>"]
rust-version = "1.71.1"
rust-version = "1.76.0"
description = """
Service to fetch data from the chain-registry
"""
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readme = "README.md"
keywords = ["ibc", "rest", "api", "cosmos", "tendermint"]
homepage = "https://hermes.informal.systems/"
repository = "https://github.com/informalsystems/hermes"
rust-version = "1.71.1"
rust-version = "1.76.0"
description = """
Rust implementation of a RESTful API server for Hermes
"""
Expand Down
4 changes: 2 additions & 2 deletions crates/relayer-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![End to End testing][e2e-image]][e2e-link]
[![Apache 2.0 Licensed][license-image]][license-link]
![Rust Stable][rustc-image]
![Rust 1.71.1+][rustc-version]
![Rust 1.76.0+][rustc-version]

This is the repository for the IBC REST server for use in the Hermes IBC relayer.

Expand Down Expand Up @@ -39,4 +39,4 @@ Unless required by applicable law or agreed to in writing, software distributed
[license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg
[license-link]: https://github.com/informalsystems/hermes/blob/master/LICENSE
[rustc-image]: https://img.shields.io/badge/rustc-stable-blue.svg
[rustc-version]: https://img.shields.io/badge/rustc-1.71.1+-blue.svg
[rustc-version]: https://img.shields.io/badge/rustc-1.76.0+-blue.svg
2 changes: 1 addition & 1 deletion crates/relayer-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
keywords = ["blockchain", "consensus", "cosmos", "ibc", "tendermint"]
repository = "https://github.com/informalsystems/hermes"
authors = ["Informal Systems <[email protected]>"]
rust-version = "1.71.1"
rust-version = "1.76.0"
description = """
Implementation of the Inter-Blockchain Communication Protocol (IBC).
This crate comprises the main data structures and on-chain logic.
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
keywords = ["blockchain", "consensus", "cosmos", "ibc", "tendermint"]
repository = "https://github.com/informalsystems/hermes"
authors = ["Informal Systems <[email protected]>"]
rust-version = "1.71.1"
rust-version = "1.76.0"
description = """
Implementation of an IBC Relayer in Rust, as a library
"""
Expand Down
56 changes: 37 additions & 19 deletions crates/relayer/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,15 @@ fn relay_on_object<Chain: ChainHandle>(
};

// Then, apply the client filter
// If the object is a CrossChain query discard it if the destination chain
// is not configured
let client_filter_outcome = match object {
Object::Client(client) => client_state_filter.control_client_object(registry, client),
Object::Connection(conn) => client_state_filter.control_conn_object(registry, conn),
Object::Channel(chan) => client_state_filter.control_chan_object(registry, chan),
Object::Packet(packet) => client_state_filter.control_packet_object(registry, packet),
Object::CrossChainQuery(_ccq) => Ok(Permission::Allow),
Object::Wallet(_wallet) => Ok(Permission::Allow),
Object::CrossChainQuery(_) => Ok(Permission::Allow),
};

match client_filter_outcome {
Expand Down Expand Up @@ -814,8 +816,33 @@ fn process_batch<Chain: ChainHandle>(
workers.notify_new_block(&src_chain.id(), batch.height, new_block);
}

// Forward the IBC events.
// Forward the IBC events to the appropriate workers
for (object, events_with_heights) in collected.per_object.into_iter() {
if events_with_heights.is_empty() {
// Event batch is empty, nothing to do
continue;
}

let Ok(src_chain) = registry.get_or_spawn(object.src_chain_id()) else {
trace!(
"skipping events for '{}': source chain '{}' is not registered",
object.short_name(),
object.src_chain_id()
);

continue;
};

let Ok(dst_chain) = registry.get_or_spawn(object.dst_chain_id()) else {
trace!(
"skipping events for '{}': destination chain '{}' is not registered",
object.short_name(),
object.src_chain_id()
);

continue;
};

if !relay_on_object(
config,
registry,
Expand All @@ -824,32 +851,23 @@ fn process_batch<Chain: ChainHandle>(
&object,
) {
trace!(
"skipping events for '{}'. \
reason: filtering is enabled and channel does not match any allowed channels",
"skipping events for '{}': rejected by filtering policy",
object.short_name()
);

continue;
}

if events_with_heights.is_empty() {
continue;
}

let src = registry
.get_or_spawn(object.src_chain_id())
.map_err(Error::spawn)?;

let dst = registry
.get_or_spawn(object.dst_chain_id())
.map_err(Error::spawn)?;

if let Object::Packet(ref _path) = object {
// Update telemetry info
telemetry!(send_telemetry(&src, &dst, &events_with_heights, _path));
telemetry!(send_telemetry(
&src_chain,
&dst_chain,
&events_with_heights,
_path
));
}

let worker = workers.get_or_spawn(object, src, dst, config);
let worker = workers.get_or_spawn(object, src_chain, dst_chain, config);

worker.send_events(
batch.height,
Expand Down
2 changes: 1 addition & 1 deletion crates/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
keywords = ["cosmos", "ibc", "relayer", "telemetry"]
repository = "https://github.com/informalsystems/hermes"
authors = ["Informal Systems <[email protected]>"]
rust-version = "1.71.1"
rust-version = "1.76.0"
description = """
Telemetry service for the Hermes IBC relayer
"""
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 @@ -2,7 +2,7 @@
name = "ibc-integration-test"
version = "0.28.0"
edition = "2021"
rust-version = "1.71.1"
rust-version = "1.76.0"
license = "Apache-2.0"
readme = "README.md"
keywords = ["blockchain", "consensus", "cosmos", "ibc", "tendermint"]
Expand Down

0 comments on commit acde373

Please sign in to comment.