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

Turn ChangeString into a PeerChange enum #263

Merged
merged 3 commits into from
Jun 1, 2023
Merged

Conversation

bschwind
Copy link
Member

...So that we don't print NAT traversal reattempts as a "modification" on the peer. This should reduce "Peer X was modified" messages which can occur over and over on subsequent calls to innernet fetch

Closes #261

@bschwind bschwind requested review from mcginty and strohel May 28, 2023 14:34
Comment on lines +180 to +189
if change_action == ChangeAction::Modified
&& diff
.changes()
.iter()
.all(|c| *c == PeerChange::NatTraverseReattempt)
{
// If this peer was "modified" but the only change is a NAT Traversal Reattempt,
// don't bother printing this peer.
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was what resulted in lots of "peer was modified" messages, because the NatTraverseReattempt "change" was somewhat of a hack to trigger NAT traversal attempts for that peer.

It might actually make more sense to remove this PeerChange::NatTraverseReattempt "change" (which again, isn't actually a change) and instead just collect all unconnected peers that have endpoint candidates and try to connect to them after calls to fetch.

That would probably remove a decent amount of special-cased code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for removing PeerChange::NatTraverseReattempt in some future PR.

);

for change in diff.changes() {
log::debug!(" {}", change);
if let PeerChange::Endpoint { .. } = change {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt that endpoint changes merited an info print instead of debug. When I see that a peer was modified I typically want to know if they got a sensible endpoint.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes good sense. If we want to prevent micro-duplication, we could do something like:

let level = if matches!(update, PeerChange::Endpoint { .. }) { Level::Info } else { Level::Debug };
log::log(level, "    {}", change);

Copy link
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bschwind just to understand this better before I fully review: did #262 remove all the spurious "peer modified" messages, or not yet and this fix is needed to make the logs "completely nice"?

Turning ChangeString into less dynamic enum makes good sense to me, I just need to think more about the functional changes.

shared/src/types.rs Outdated Show resolved Hide resolved
@bschwind
Copy link
Member Author

did #262 remove all the spurious "peer modified" messages, or not yet and this fix is needed to make the logs "completely nice"?

No, there were still spurious "peer modified" messages because it counts a "NAT traversal reattempt" as a modification of the peer.

@mcginty
Copy link
Collaborator

mcginty commented May 29, 2023

Nice, so much cleaner. I didn't look deeper than this diff but I definitely agree if "NAT Traverse Reattempt" is all that's adding these extra lines and not actually producing any useful information to the user, we should just get rid of it.

Base automatically changed from reset-endpoint-on-no-connect to main May 31, 2023 02:48
@bschwind bschwind force-pushed the change-string-enum branch from 3bacbb5 to 6222d5d Compare May 31, 2023 02:59
@bschwind
Copy link
Member Author

Rebased on the latest main

@bschwind bschwind merged commit 0057a70 into main Jun 1, 2023
@bschwind bschwind deleted the change-string-enum branch June 1, 2023 03:11
Copy link
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Porst-merge LGTM! Sorry I was too slow and didn't manage to submit my pending comments before merge, but good you went ahead.

It wouldn't be me if I didn't add one optional supernit.

);

for change in diff.changes() {
log::debug!(" {}", change);
if let PeerChange::Endpoint { .. } = change {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes good sense. If we want to prevent micro-duplication, we could do something like:

let level = if matches!(update, PeerChange::Endpoint { .. }) { Level::Info } else { Level::Debug };
log::log(level, "    {}", change);

Comment on lines +180 to +189
if change_action == ChangeAction::Modified
&& diff
.changes()
.iter()
.all(|c| *c == PeerChange::NatTraverseReattempt)
{
// If this peer was "modified" but the only change is a NAT Traversal Reattempt,
// don't bother printing this peer.
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for removing PeerChange::NatTraverseReattempt in some future PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace ChangeString with an enum
3 participants