Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten error message on debug assertion #6988

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions crates/net/network/src/transactions/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,8 @@ impl TransactionFetcher {
for hash in hashes.into_iter() {
debug_assert!(
self.hashes_fetch_inflight_and_pending_fetch.peek(&hash).is_some(),
"`%hash` in `@buffered_hashes` that's not in `@unknown_hashes`, `@buffered_hashes` should be a subset of keys in `@unknown_hashes`, broken invariant `@buffered_hashes` and `@unknown_hashes`,
`%hash`: {hash},
`@self`: {self:?}",
"`%hash` in `@buffered_hashes` that's not in `@hashes_fetch_inflight_and_pending_fetch`, `@buffered_hashes` should be a subset of keys in `@hashes_fetch_inflight_and_pending_fetch`, broken invariant `@buffered_hashes` and `@hashes_fetch_inflight_and_pending_fetch`,
`%hash`: {hash}"
);

let Some(TxFetchMetadata { retries, fallback_peers, .. }) =
Expand Down Expand Up @@ -676,10 +675,10 @@ impl TransactionFetcher {
true
}(),
"`%new_announced_hashes` should been taken out of buffer before packing in a request, breaks invariant `@buffered_hashes` and `@inflight_requests`,
`%new_announced_hashes`: {:?},
`@self`: {:?}",
new_announced_hashes, self
);
`@hashes_fetch_inflight_and_pending_fetch` for `%new_announced_hashes`: {:?}",
new_announced_hashes.iter().map(|hash|
(*hash, self.hashes_fetch_inflight_and_pending_fetch.get(hash).cloned())
).collect::<Vec<(TxHash, Option<TxFetchMetadata>)>>());

let (response, rx) = oneshot::channel();
let req: PeerRequest = PeerRequest::GetPooledTransactions {
Expand Down Expand Up @@ -910,12 +909,13 @@ impl TransactionFetcher {
let GetPooledTxResponse { peer_id, mut requested_hashes, result } = response;

debug_assert!(
self.active_peers.get(&peer_id).is_some(),
"`%peer_id` has been removed from `@active_peers` before inflight request(s) resolved, broken invariant `@active_peers` and `@inflight_requests`,
self.active_peers.get(&peer_id).is_some(),
"`%peer_id` has been removed from `@active_peers` before inflight request(s) resolved, broken invariant `@active_peers` and `@inflight_requests`,
`%peer_id`: {},
`@self`: {:?}",
peer_id, self
);
`@hashes_fetch_inflight_and_pending_fetch` for `%requested_hashes`: {:?}",
peer_id, requested_hashes.iter().map(|hash|
(*hash, self.hashes_fetch_inflight_and_pending_fetch.get(hash).cloned())
).collect::<Vec<(TxHash, Option<TxFetchMetadata>)>>());

self.decrement_inflight_request_count_for(&peer_id);

Expand Down Expand Up @@ -1071,7 +1071,7 @@ impl Default for TransactionFetcher {
}

/// Metadata of a transaction hash that is yet to be fetched.
#[derive(Debug, Constructor)]
#[derive(Debug, Constructor, Clone)]
pub struct TxFetchMetadata {
/// The number of times a request attempt has been made for the hash.
retries: u8,
Expand Down
Loading