fix(comms): only permit a single inbound messaging substream per peer #5731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Only permit a single inbound messaging session per peer
Only emit MessageReceived event in tests
Ban peer if they exceed the frame size
Motivation and Context
A node may initiate boundless inbound messaging sessions. This PR limits the number of sessions to one. Tari nodes only initiate a single session as needed so this shouldn't have any effect on non-malicious nodes.
MessageReceived events would be generated for each message received. This was only used in tests. Since these events aren't read in non-test contexts and because it can be very busy, this PR disables them by default and only enables in tests. This does not affect the message count in the minotari node status line.
How Has This Been Tested?
New unit test that checks sessions are closed as long as the first one is active.
What process can a PR reviewer use to test or verify this change?
Messaging still works as expected (ping-peer, discover-peer etc)
Breaking Changes