-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collate consecutive heights and sequence numbers shown in logs (#2847)
* Remove unused `num-traits` dependency * Implement `Add<u64>` and `Sub<u64>` for `Height` * Implement `Add<u64>` and `Sub<u64>` for `Sequence` * Collate consecutive sequence numbers and heights in logs For example, whereas before we would only show the first 50 sequence numbers: sequence numbers of ack packets to send to the destination chain out of the ones with acknowledgments on the source chain (first 50 shown here) dst_chain=ibc-0 src_chain=ibc-1 total=184 sequences=[1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308] We now show all sequences numbers where consecutive ones are collated together: sequence numbers of ack packets to send to the destination chain out of the ones with acknowledgments on the source chain dst_chain=ibc-0 src_chain=ibc-1 total=184 sequences=1259..=1329, 1359..=1439, 1469..=1500 * Add changelog entry * Rename `collate` extension method to `collated` to match `copied`, `cloned`, etc. * Collate the output of the `query packet` commands
- Loading branch information
Showing
21 changed files
with
336 additions
and
117 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
.changelog/unreleased/improvements/ibc-relayer-cli/2847-collate-seqs.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Collate consecutive heights and sequence numbers shown in logs | ||
([#2847](https://github.com/informalsystems/ibc-rs/issues/2847)) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use core::fmt; | ||
|
||
use serde::Serialize; | ||
|
||
use ibc_relayer::util::collate::{Collated, CollatedIterExt}; | ||
use ibc_relayer_types::core::ics04_channel::packet::Sequence; | ||
use ibc_relayer_types::Height; | ||
|
||
pub use ibc_relayer::chain::counterparty::PendingPackets; | ||
|
||
#[derive(Serialize)] | ||
pub struct CollatedPendingPackets { | ||
pub unreceived_packets: Vec<Collated<Sequence>>, | ||
pub unreceived_acks: Vec<Collated<Sequence>>, | ||
} | ||
|
||
impl fmt::Debug for CollatedPendingPackets { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.debug_struct("PendingPackets") | ||
.field("unreceived_packets", &self.unreceived_packets) | ||
.field("unreceived_acks", &self.unreceived_acks) | ||
.finish() | ||
} | ||
} | ||
|
||
impl CollatedPendingPackets { | ||
pub fn new(pending: PendingPackets) -> Self { | ||
Self { | ||
unreceived_packets: pending.unreceived_packets.into_iter().collated().collect(), | ||
unreceived_acks: pending.unreceived_acks.into_iter().collated().collect(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize, Debug)] | ||
pub struct PacketSeqs { | ||
pub height: Height, | ||
pub seqs: Vec<Sequence>, | ||
} | ||
|
||
impl PacketSeqs { | ||
pub fn collated(self) -> CollatedPacketSeqs { | ||
CollatedPacketSeqs { | ||
height: self.height, | ||
seqs: self.seqs.into_iter().collated().collect(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct CollatedPacketSeqs { | ||
pub height: Height, | ||
pub seqs: Vec<Collated<Sequence>>, | ||
} | ||
|
||
impl fmt::Debug for CollatedPacketSeqs { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.debug_struct("PacketSeqs") | ||
.field("height", &self.height) | ||
.field("seqs", &self.seqs) | ||
.finish() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.