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(net): limit SR connections to relay nodes #5882

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

zeusoo001
Copy link
Contributor

@zeusoo001 zeusoo001 commented Jun 24, 2024

What does this PR do?
Limit the number of connections between an SR and relay nodes

Why are these changes required?
Avoid malicious witnesses from affecting the block propagation efficiency by establishing multiple connections with relay nodes.

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

@lvs007 lvs007 merged commit dfbd1ff into tronprotocol:develop Jul 1, 2024
7 checks passed
@@ -139,6 +141,13 @@ public boolean checkHelloMessage(HelloMessage message, Channel channel) {
return false;
}

if (getPeerCountByAddress(msg.getAddress()) >= MAX_PEER_COUNT_PER_ADDRESS) {
logger.warn("HelloMessage from {}, the number of peers of {} exceeds 2.",
Copy link
Contributor

@yuekun0707 yuekun0707 Jul 1, 2024

Choose a reason for hiding this comment

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

should add "equal to 2" here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should "2" be replaced with the variable "{MAX_PEER_COUNT_PER_ADDRESS}"?

@zeusoo001 zeusoo001 deleted the relay-opt branch August 13, 2024 06:33
@zeusoo001 zeusoo001 restored the relay-opt branch August 13, 2024 06:34
@zeusoo001 zeusoo001 deleted the relay-opt branch October 15, 2024 07:03
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.

6 participants