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

fix: ban peer if it sends bad liveness data #5844

Conversation

stringhandler
Copy link
Collaborator

Description

Bans the peer if they sent invalid liveness data.

Motivation and Context

I think there was a change to the chainmetadata struct recently, and this resulted in a bunch of warnings on my igor node. This PR now bans the node if they sent data that doesn't deserialize.

How Has This Been Tested?

Tested with igor trying to connect to old nodes

What process can a PR reviewer use to test or verify this change?

Try to connect to an igor node running 0.52.0-pre.1

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

@github-actions
Copy link

github-actions bot commented Oct 18, 2023

Test Results (Integration tests)

33 tests   33 ✔️  13m 22s ⏱️
11 suites    0 💤
  2 files      0

Results for commit 281b3e6.

♻️ This comment has been updated with latest results.

@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Oct 18, 2023
@github-actions
Copy link

github-actions bot commented Oct 18, 2023

Test Results (CI)

1 222 tests   1 222 ✔️  9m 35s ⏱️
     39 suites         0 💤
       1 files           0

Results for commit 281b3e6.

♻️ This comment has been updated with latest results.

@brianp brianp self-requested a review October 18, 2023 12:37
Copy link
Contributor

@brianp brianp left a comment

Choose a reason for hiding this comment

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

Tested with expected results. My node banned existing older nodes.
image

Would like to change the log level before merge.

Ack

Comment on lines 88 to 91
level: debug,
level: warn,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe info ?

From an outsiders perspective there's a high likelihood at any time they could receive data with unserailizable information but showing them big red warnings in the console makes them feel like they need to do something, when in fact this is a perfectly fine event to happen, and there's not actually any user required interaction that needs to occur.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll meet you halfway with info. I think it is an indication that you are using the wrong build or network

error!( target: LOG_TARGET, "Failed to handle liveness event because '{}'", e);
if let ChainMetadataSyncError::ReceivedInvalidChainMetadata(node_id,reason) = e {
log_if_error!(
level: warn,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Banning a peer is informational not deserving of anything alerting to an end user.

Ok(_) => {}
Err(e) => {
error!( target: LOG_TARGET, "Failed to handle liveness event because '{}'", e);
if let ChainMetadataSyncError::ReceivedInvalidChainMetadata(node_id,reason) = e {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, i'm surprised rustfmt didn't fix this.

Suggested change
if let ChainMetadataSyncError::ReceivedInvalidChainMetadata(node_id,reason) = e {
if let ChainMetadataSyncError::ReceivedInvalidChainMetadata(node_id, reason) = e {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

rustfmt can't seem to format anything in a tokio::select I've tried to make it neat manually, but it's the wild west of fmtland

Copy link
Collaborator

Choose a reason for hiding this comment

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

This issue on it was closed.

Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

I agree with the logic, but is it possible to have an integration unit test for the if let ChainMetadataSyncError::ReceivedInvalidChainMetadata(node_id,reason) = e branch in ChainMetadataService::run?

@stringhandler stringhandler merged commit eb40fc4 into tari-project:development Oct 18, 2023
14 checks passed
@stringhandler stringhandler deleted the st-ban-on-bad-liveness-data branch October 18, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants