Skip to content

feat(p2p): Add misbehavior score for unsolicited vertices#1296

Merged
msbrogli merged 1 commit intomasterfrom
feat/p2p-misbehavior-score
Jun 6, 2025
Merged

feat(p2p): Add misbehavior score for unsolicited vertices#1296
msbrogli merged 1 commit intomasterfrom
feat/p2p-misbehavior-score

Conversation

@msbrogli
Copy link
Member

@msbrogli msbrogli commented Jun 6, 2025

Motivation

This PR introduces a misbehavior score but simply close the connection when the threshold is reached. A future PR can enforce better responses to misbehavior (e.g., temporary ban for the peer id or ip address).

Acceptance Criteria

  1. Reject unsolicited vertices.
  2. Add _inbound_relay_enabled: bool to control whether we request relay from the peer.
  3. Add a misbehavior score for each connection which decays to zero in 1h.
  4. If a peer misbehaves above a threshold, its connection is closed.

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@msbrogli msbrogli requested a review from jansegre as a code owner June 6, 2025 15:42
@msbrogli msbrogli self-assigned this Jun 6, 2025
@msbrogli msbrogli moved this from Todo to In Progress (Done) in Hathor Network Jun 6, 2025
@msbrogli msbrogli requested a review from glevco June 6, 2025 15:42
@msbrogli msbrogli changed the base branch from master to refactor/split-on-new-vertex June 6, 2025 15:53
@msbrogli msbrogli force-pushed the feat/p2p-misbehavior-score branch from 99ebfe1 to d0043ba Compare June 6, 2025 15:54
Base automatically changed from refactor/split-on-new-vertex to master June 6, 2025 16:04
@codecov
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.

Project coverage is 82.90%. Comparing base (b6a3221) to head (d0043ba).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
hathor/p2p/protocol.py 60.00% 3 Missing and 1 partial ⚠️
hathor/p2p/sync_v2/agent.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1296      +/-   ##
==========================================
+ Coverage   82.86%   82.90%   +0.03%     
==========================================
  Files         362      362              
  Lines       25823    25838      +15     
  Branches     3954     3956       +2     
==========================================
+ Hits        21399    21420      +21     
+ Misses       3697     3691       -6     
  Partials      727      727              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@glevco glevco moved this from In Progress (Done) to In Review (WIP) in Hathor Network Jun 6, 2025
@msbrogli msbrogli merged commit d0043ba into master Jun 6, 2025
7 checks passed
@msbrogli msbrogli deleted the feat/p2p-misbehavior-score branch June 6, 2025 19:51
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Jun 6, 2025
@jansegre jansegre mentioned this pull request Jul 22, 2025
2 tasks
@jansegre jansegre moved this from Waiting to be deployed to Done in Hathor Network Jul 22, 2025
@jansegre jansegre mentioned this pull request Aug 7, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants