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

feat: limit connection by measurement #459

Merged
merged 7 commits into from
Aug 1, 2023
Merged

feat: limit connection by measurement #459

merged 7 commits into from
Aug 1, 2023

Conversation

RyanKung
Copy link
Member

@RyanKung RyanKung commented Jul 26, 2023

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added / updated (for bug fixes / features)

🔵 What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

feature

🟤 What is the current behavior? (You can also link to an open issue here)

related issue #399

In the current scenario, the DHT may attempt to establish a connection to did_a, but this can fail due to incorrect configuration or network issues. The existing implementation might repeatedly try to establish the connection, potentially causing the system's file descriptor limit to be reached very quickly.

🟢 What is the new behavior (if this is a feature change)?

  1. A judgement for node behaviour, make sure node is behaviour good.
  2. A measurement of node behavior, ensuring that the difference between disconnect and connect counts exceeds the THRESHOLD.
  3. Throw a new error type: NodeBehaviourBad.
  4. Record behaviour on function connect, connect_via and disconnect.

☢️ Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No

ℹ️ Other information

After this modify, if a node is behaviour no good, it will printout errors.

Screenshot 2023-07-26 at 6 51 21 PM

Closes #issue

@RyanKung RyanKung changed the title feat: limit connection count feat: limit connection sum by measurement Jul 26, 2023
@RyanKung RyanKung requested a review from Ma233 July 26, 2023 10:55
@RyanKung RyanKung changed the title feat: limit connection sum by measurement feat: limit connection by measurement Jul 27, 2023
Copy link
Member

@Ma233 Ma233 left a comment

Choose a reason for hiding this comment

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

Others LGTM

#[cfg(not(feature = "core_crate"))]
quote! {
use rings_core::measure::measure::MessageRecvBehaviour;
use rings_core::measure::measure::MessageSendehaviour;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
use rings_core::measure::measure::MessageSendehaviour;
use rings_core::measure::measure::MessageSendBehaviour;

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

disconn,
conn - disconn
);
((conn - disconn) as i16) < THRESHOLD
Copy link
Member

Choose a reason for hiding this comment

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

To ensure adaptability across different orders of magnitude, it may be more effective to calculate using the admission base and ratio rather than simply taking the difference.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, this algorithm is just a very basically impl for current situation, we needs ratio based, time weighted based and so on. And futher more, we allow users to compose those impls together.

@RyanKung RyanKung merged commit 1e17402 into RingsNetwork:master Aug 1, 2023
3 checks passed
@RyanKung RyanKung deleted the feat_fix_log_output branch August 1, 2023 09:22
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.

2 participants