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(gadget-sdk)!: prevent duplicate and self-referential messages #458

Merged
merged 6 commits into from
Nov 8, 2024

Conversation

tbraun96
Copy link
Collaborator

@tbraun96 tbraun96 commented Nov 8, 2024

This pull request includes several changes to improve the network and gossip handling in the sdk module. The updates mainly focus on enhancing the peer connection logic, adding new fields to structures, and refining the message handling process to avoid redundant operations and ensure efficient memory usage.

Network and Gossip Handling Improvements:

  • Peer Connection Logic:

    • Replaced JoinSet with FuturesOrdered to manage peer connection tasks more efficiently in blueprint-manager/src/sdk/setup.rs.
    • Added a new method wait_for_peers to handle peer connections asynchronously.
  • Structure Enhancements:

    • Added my_id field to NetworkServiceWithoutSwarm and NetworkService structures to track the peer's own ID in sdk/src/network/gossip.rs. [1] [2]
    • Introduced recent_messages field using LruCache to store recently received message hashes and prevent processing duplicates in GossipHandle. [1] [2]
  • Message Handling:

    • Implemented logic to reject messages originating from the peer itself to avoid processing self-sent messages in sdk/src/network/handlers/gossip.rs and sdk/src/network/handlers/p2p.rs. [1] [2]
    • Improved message deserialization and added checks to prevent duplicate message processing using recent_messages in GossipHandle. [1] [2]
  • Test Improvements:

    • Refactored test functions for clarity and removed unnecessary synchronization barriers in sdk/src/network/mod.rs. [1] [2] [3] [4]
  • Dependency Updates:

    • Added lru-mem dependency to manage the LRU cache for recent messages in Cargo.toml and sdk/Cargo.toml. [1] [2]

@shekohex shekohex changed the title fix: prevent duplicate and self-referential messages fix(gadget-sdk)!: prevent duplicate and self-referential messages Nov 8, 2024
feat: auto impl Network for & and Arc
Copy link
Contributor

@drewstone drewstone left a comment

Choose a reason for hiding this comment

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

Nit

blueprint-manager/src/sdk/setup.rs Outdated Show resolved Hide resolved
blueprint-manager/src/sdk/setup.rs Outdated Show resolved Hide resolved
blueprint-manager/src/sdk/setup.rs Outdated Show resolved Hide resolved
@shekohex shekohex added DO NOT MERGE Please do not merge this PR yet, even if it is ready and removed DO NOT MERGE Please do not merge this PR yet, even if it is ready labels Nov 8, 2024
@shekohex shekohex force-pushed the fix-duplicate-messages branch from 6ae36f2 to 29372c7 Compare November 8, 2024 19:31
@shekohex shekohex merged commit 1494dfa into main Nov 8, 2024
9 checks passed
@shekohex shekohex deleted the fix-duplicate-messages branch November 8, 2024 19:32
@webb-spider webb-spider bot mentioned this pull request Nov 8, 2024
@tbraun96 tbraun96 mentioned this pull request Nov 11, 2024
3 tasks
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.

3 participants