Skip to content

Commit

Permalink
Fix sequences filtering when clearing packets with CLI (#4159)
Browse files Browse the repository at this point in the history
* Filter packets using excluded_sequences when calling clear packet CLI

* Add changelog entry

* Apply excluded sequences to acks when clearing packets with CLI
  • Loading branch information
ljoss17 authored Aug 26, 2024
1 parent 0d3b57c commit 217f0b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Correctly filter out sequences from the `excluded_sequences` configuration
when clearing packets with the `clear packet` CLI.
([\#4158](https://github.com/informalsystems/hermes/issues/4158))
24 changes: 18 additions & 6 deletions crates/relayer/src/link/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,16 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> Link<ChainA, ChainB> {
sequences.retain(|seq| sequence_filter.iter().any(|range| range.contains(seq)));
}

// Retain only sequences which should not be filtered out
let raw_sequences: Vec<Sequence> = sequences
.into_iter()
.filter(|sequence| !self.a_to_b.exclude_src_sequences.contains(sequence))
.collect();

info!(
"{} unreceived packets found: {} ",
sequences.len(),
PrettySlice(&sequences)
raw_sequences.len(),
PrettySlice(&raw_sequences)
);

let query_height = match packet_data_query_height {
Expand All @@ -128,7 +134,7 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> Link<ChainA, ChainB> {
.map_or(50, |cfg| cfg.query_packets_chunk_size());

self.relay_packet_messages(
sequences,
raw_sequences,
query_height,
chunk_size,
query_send_packet_events,
Expand Down Expand Up @@ -179,10 +185,16 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> Link<ChainA, ChainB> {
sequences.retain(|seq| sequence_filter.iter().any(|range| range.contains(seq)));
}

// Retain only sequences which should not be filtered out
let raw_sequences: Vec<Sequence> = sequences
.into_iter()
.filter(|sequence| !self.a_to_b.exclude_src_sequences.contains(sequence))
.collect();

info!(
"{} unreceived acknowledgements found: {} ",
sequences.len(),
sequences.iter().copied().collated().format(", "),
raw_sequences.len(),
raw_sequences.iter().copied().collated().format(", "),
);

let query_height = match packet_data_query_height {
Expand All @@ -197,7 +209,7 @@ impl<ChainA: ChainHandle, ChainB: ChainHandle> Link<ChainA, ChainB> {
.map_or(50, |cfg| cfg.query_packets_chunk_size());

self.relay_packet_messages(
sequences,
raw_sequences,
query_height,
chunk_size,
query_write_ack_events,
Expand Down

0 comments on commit 217f0b7

Please sign in to comment.