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

Log reason of peer banning #2667

Merged
merged 1 commit into from
Jun 22, 2024
Merged

Conversation

Eligioo
Copy link
Member

@Eligioo Eligioo commented Jun 21, 2024

What's in this pull request?

All paths to a CloseReason::MaliciousPeer as reason for closing the connection now contain a WARN log message to annotate the reason for banning a peer.

I chose for WARN as log level for now but can easily changed if one believes there is a reason for it.

This fixes #2661 .

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

@Eligioo Eligioo requested review from jsdanielh and hrxi June 21, 2024 11:41
@Eligioo Eligioo force-pushed the stefan/log-malicious-peer-reasons branch 2 times, most recently from e63fd0d to fb96e4d Compare June 21, 2024 11:47
Copy link
Member

@jsdanielh jsdanielh left a comment

Choose a reason for hiding this comment

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

I'd have changed the CloseReason::MaliciousPeer variant to be CloseReason::MaliciousPeer(String) such that we enforce always the reason and then we log it in the network

validator/src/proposal_buffer.rs Outdated Show resolved Hide resolved
validator/src/proposal_buffer.rs Outdated Show resolved Hide resolved
@Eligioo
Copy link
Member Author

Eligioo commented Jun 21, 2024

@jsdanielh

I'd have changed the CloseReason::MaliciousPeer variant to be CloseReason::MaliciousPeer(String) such that we enforce always the reason and then we log it in the network

I thought about this but this will cause the log messages to double:

  • the new log in the network layer as you suggested
  • the existing tracing logs creating context at the caller location that initiates the closing connection e.g.:
log::warn!(
    given_checkpoint_epoch,
    expected_checkpoint_epoch,
    %peer_id,
    "Banning peer because requesting macro chain failed: invalid checkpoint",
);

Basically to remove the existing tracing logs but don't lose context, you would need to format the extra values into the String of CloseReason::MaliciousPeer(String). I'm not a fan of that.

@Eligioo Eligioo force-pushed the stefan/log-malicious-peer-reasons branch from fb96e4d to a90a2d2 Compare June 21, 2024 14:12
Copy link
Contributor

@hrxi hrxi left a comment

Choose a reason for hiding this comment

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

LGTM.

@Eligioo remarked that the peer banning in the testnet should already have a log for the ban unless it came from validator/src/proposal_buffer.rs.

@hrxi hrxi force-pushed the stefan/log-malicious-peer-reasons branch from a90a2d2 to 37e0a9d Compare June 21, 2024 16:25
@hrxi
Copy link
Contributor

hrxi commented Jun 21, 2024

Rebased for merge.

@hrxi hrxi mentioned this pull request Jun 21, 2024
@hrxi hrxi merged commit 37e0a9d into albatross Jun 22, 2024
6 checks passed
@hrxi hrxi deleted the stefan/log-malicious-peer-reasons branch June 22, 2024 07:39
@jsdanielh jsdanielh added this to the Nimiq PoS Mainnet milestone Jun 22, 2024
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.

Logging the ban reason
3 participants