From a2ce63674224923b54af541291a4637b3832ff45 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 31 May 2023 15:15:38 +0200 Subject: [PATCH 1/3] Collate sequence numbers of unreceived acknowledgements in packet clear CLI --- crates/relayer/src/link/cli.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/relayer/src/link/cli.rs b/crates/relayer/src/link/cli.rs index 30d7ad55e7..3eee884e9a 100644 --- a/crates/relayer/src/link/cli.rs +++ b/crates/relayer/src/link/cli.rs @@ -3,6 +3,7 @@ use std::thread; use std::time::{Duration, Instant}; use ibc_relayer_types::core::ics04_channel::packet::Sequence; +use itertools::Itertools; use tracing::{error_span, info}; use ibc_relayer_types::events::IbcEvent; @@ -23,6 +24,7 @@ use crate::link::relay_path::RelayPath; use crate::link::relay_sender::SyncSender; use crate::link::Link; use crate::path::PathIdentifiers; +use crate::util::collate::CollatedIterExt; use crate::util::pretty::{PrettyDuration, PrettySlice}; impl RelayPath { @@ -150,7 +152,7 @@ impl Link { info!( "{} unreceived acknowledgements found: {} ", sequences.len(), - PrettySlice(&sequences) + sequences.iter().copied().collated().format(", "), ); let query_height = match packet_data_query_height { From bb160b037e7f4e254577ab93d0cf2b1c076a1efe Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 31 May 2023 15:19:50 +0200 Subject: [PATCH 2/3] Remove `Timestamp(..)` wrapper when formatting a `Timestamp` --- crates/relayer-types/src/timestamp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/relayer-types/src/timestamp.rs b/crates/relayer-types/src/timestamp.rs index c3d3668e29..80a3ba9f7d 100644 --- a/crates/relayer-types/src/timestamp.rs +++ b/crates/relayer-types/src/timestamp.rs @@ -169,9 +169,9 @@ impl Display for Timestamp { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { write!( f, - "Timestamp({})", + "{}", self.time - .map_or("NoTimestamp".to_string(), |time| time.to_rfc3339()) + .map_or_else(|| "NoTimestamp".to_string(), |time| time.to_rfc3339()) ) } } From e709eed1073144adb95784981bcb0aef7dbac4e1 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Wed, 31 May 2023 15:38:34 +0200 Subject: [PATCH 3/3] Derive `Hash` on `Timestamp` --- crates/relayer-types/src/timestamp.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/crates/relayer-types/src/timestamp.rs b/crates/relayer-types/src/timestamp.rs index 80a3ba9f7d..3cda62807f 100644 --- a/crates/relayer-types/src/timestamp.rs +++ b/crates/relayer-types/src/timestamp.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use core::fmt::{Display, Error as FmtError, Formatter}; -use core::hash::{Hash, Hasher}; +use core::hash::Hash; use core::num::ParseIntError; use core::ops::{Add, Sub}; use core::str::FromStr; @@ -21,21 +21,13 @@ pub const ZERO_DURATION: Duration = Duration::from_secs(0); /// a `u64` value and a raw timestamp. In protocol buffer, the timestamp is /// represented as a `u64` Unix timestamp in nanoseconds, with 0 representing the absence /// of timestamp. -#[derive(PartialEq, Eq, Copy, Clone, Debug, Default, Deserialize, Serialize, PartialOrd, Ord)] +#[derive( + Copy, Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash, +)] pub struct Timestamp { time: Option