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

Remove assumptions about knowing a peer in protocol and fix memory leak #3904

Merged
merged 12 commits into from
May 5, 2023

Conversation

AurelienFT
Copy link
Contributor

@AurelienFT AurelienFT commented May 4, 2023

🤖 Generated by Copilot at c7138c1

Summary

🐛🚀🎨

This pull request improves the code quality, performance, and reliability of the massa-protocol-worker and massa-async-pool crates, and updates the peernet dependency in several other crates. It also fixes some minor code style issues and documentation comments. The main changes include using the tracing crate for logging, simplifying the data structures and algorithms for indexing and retrieving blocks and operations, and increasing the timeout durations for peer connections.

peernet updated
code style and performance
enhanced by autumn

Walkthrough

  • Add a comment header to massa-async-pool/src/changes.rs and remove the redundant one (link, link)
  • Update the dependency on the peernet crate in three Cargo.toml files to use a newer revision (link, link, link)
  • Add an import for the info macro and replace a println! call with an info! call in massa-protocol-worker/src/connectivity.rs to use the proper logging mechanism (link, link)
  • Remove empty lines from massa-pool-worker/src/denunciation_pool.rs and massa-protocol-worker/src/handlers/block_handler/retrieval.rs for code style consistency (link, link, link, link, link, link)
  • Move the cache_write lock acquisition inside the loop over the block_wishlist in massa-protocol-worker/src/handlers/block_handler/retrieval.rs to avoid blocking other threads (link)
  • Replace the iter and break pattern with the retain method on the stored_operations BTreeMap in massa-protocol-worker/src/handlers/operation_handler/retrieval.rs to simplify the code (link)
  • Change the type of the index_by_newest field in the PeerDB struct from a BTreeMap to a BTreeSet, and update the corresponding methods and calls in massa-protocol-worker/src/handlers/peer_handler/mod.rs, massa-protocol-worker/src/handlers/peer_handler/models.rs, and massa-protocol-worker/src/handlers/peer_handler/tester.rs to use the set operations (link, link, link, link, link, link)
  • Increase the sleep and timeout durations in the test_peer function and the try_connect calls in massa-protocol-worker/src/handlers/peer_handler/mod.rs and massa-protocol-worker/src/handlers/peer_handler/tester.rs to give more time for the peer to respond (link, link, link)

@AurelienFT AurelienFT requested a review from damip May 4, 2023 12:34
@AurelienFT AurelienFT requested a review from damip May 4, 2023 13:23
@AurelienFT AurelienFT marked this pull request as draft May 4, 2023 14:22
@AurelienFT AurelienFT changed the title Remove assumptions about knowing a peer in protocol Remove assumptions about knowing a peer in protocol and fix memory leak May 4, 2023
@AurelienFT AurelienFT marked this pull request as ready for review May 5, 2023 06:39
Copy link
Member

@damip damip left a comment

Choose a reason for hiding this comment

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

LGTM

@damip damip merged commit 93333bf into main May 5, 2023
@AurelienFT AurelienFT deleted the debug_protocol branch May 29, 2023 09:43
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