Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3915: Fixes in peer and handler and delete cache of sc at start r=AurelienFT a=AurelienFT <!-- copilot:all --> ### <samp>🤖 Generated by Copilot at 6910564</samp> ### Summary 🛠️,📝,🚀, <!-- 1. 🛠️, which represents the addition of a new dependency and tool for building the project, as well as the bug fixes and enhancements in the `peernet` crate. 2. 📝, which represents the documentation and formatting updates in the file header comment and the JSON files. 3. 🚀, which represents the new features and improvements in the protocol layer, such as the peer categories, connection management, and versioning. --> This pull request introduces new features and improvements for the protocol layer of the Massa project, such as peer categories, connection management, version compatibility, and bootstrap file format. It also updates some constants, dependencies, and configuration files to prepare for testing and deployment. It affects the `massa-node`, `massa-protocol-worker`, `massa-protocol-exports`, and `massa-models` crates, as well as some GitHub workflow and base config files. > _We are the peers of the protocol_ > _We connect and reject by the `PeerCategory`_ > _We test and handshake with the `Version`_ > _We are the peers of the protocol_ ### Walkthrough * Add a new dependency for assembling x86_64 binaries to the GitHub workflow file ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-ea3ea8c9932adc7ba8161ceda844fedd43b006848ef1140c050cbd7ea0788a18R51)) * Update the protocol version to `TEST.22.1` and the genesis end and endorsement timestamps in the constants file ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-e151d5d22edfdbbd0bc0fb2bb32a88393e99a976e67ee8be309af16d59816332L54-R54), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-e151d5d22edfdbbd0bc0fb2bb32a88393e99a976e67ee8be309af16d59816332L61-R61), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-e151d5d22edfdbbd0bc0fb2bb32a88393e99a976e67ee8be309af16d59816332L71-R73)) * Update the version field in the openrpc file to match the protocol version ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-0ae615e89ac5087cf506ebd730e3f0162188e2ed41bffbd89494e8c066ba3a4cL5-R5)) * Add `Clone` trait to `Version` and `VersionParseError` structs and modify the `is_compatible` method of `Version` to require a minimum minor version of 1 ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-59d0f65638a1dddfc982c77e84dedbc6e1a242fb8c6f6bee236da53fa29287c1R67), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-59d0f65638a1dddfc982c77e84dedbc6e1a242fb8c6f6bee236da53fa29287c1R112), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-59d0f65638a1dddfc982c77e84dedbc6e1a242fb8c6f6bee236da53fa29287c1L192-R197)) * Replace `max_in_connections` and `max_out_connections` options with `try_connection_timer`, `timeout_connection`, and `peers_categories` options in the config file and the protocol configuration structs ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5275c26ef00940f5cb65a70bbaac1ffe9e40f1fd639b1bec4e7ae9f131972184L158-L161), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5275c26ef00940f5cb65a70bbaac1ffe9e40f1fd639b1bec4e7ae9f131972184R195-R198), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5275c26ef00940f5cb65a70bbaac1ffe9e40f1fd639b1bec4e7ae9f131972184L205-R212), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-535b75052259fc1e2f15ad89ecd55326f762d8a118074d573377d09116533761L482-L483), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-535b75052259fc1e2f15ad89ecd55326f762d8a118074d573377d09116533761L518-R531), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-1f883ba25a829313ad70daa6c31595706cf842a63e6e7bc0c342d89081084226L217-R237), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-eb8c5d490beee62cda13bb1581047df56f3fcb788f0f3f6c99415103a19ed6f4L22-L25), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-fa36f6d7efdb6a2d5059eeda9610afd0e6a43f17d6beaeae152cedce23bd0261L78-R87)) * Update the format of the initial peers file to include listeners and category fields for each peer ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-4ce80eb0f3ac8170313ae6ab4659ec29f5c8a193014be58952470a3401b3ec5bL3-R48), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-4b18110711dfaf5073f90bfba4adbd8da4bf483ed8846d383da45e4a3d7d49f2R22-R28)) * Update the dependency on the `peernet` crate to a newer revision in the `massa-node`, `massa-protocol-exports`, and `massa-protocol-worker` crates ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-655645797644d73140a0a9e2513c216d9c8ec054bf1d4ff31a48b27c1298eb3eL21-R21), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-33d1008be2011f2ebfbc183a09d2cdb71ffac47ad7f6ca0aa77ad2689f749e55L13-R13), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-0d7be3dd8cebdc0ebf253cd4e3c33327b00c6b186d57698e9673065328c8a103L15-R15)) * Add a `network` field to the `Settings` struct to store the network-related settings, such as the `routable_ip` option ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-1f883ba25a829313ad70daa6c31595706cf842a63e6e7bc0c342d89081084226R128), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-1f883ba25a829313ad70daa6c31595706cf842a63e6e7bc0c342d89081084226R168-R174)) * Remove the `hd_cache_path` directory if the `keep_ledger` or `restart_from_snapshot_at_period` arguments are false in the main file ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-535b75052259fc1e2f15ad89ecd55326f762d8a118074d573377d09116533761L189-R197)) * Include the version in the handshake and the messages, and check the compatibility with the local version, using the `VersionSerializer` and `VersionDeserializer` structs in the peer handler and tester modules ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171R249-R250), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171R271-R272), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L279-R297), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171R325), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L421-R447), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L428-R454), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L441-R464), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171R487-R496), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L496-R566), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL35-R39), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edR51-R52), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL80-R105), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL93-R113), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL137-R162), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edR203-R204), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edR222-R223), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edR237-R238), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL221-R253)) * Implement the peer selection and connection management logic based on peer categories and available slots in the connectivity, peer handler, and tester modules, using the `target_out_connections`, `default_target_out_connections`, and `peers_categories` fields ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-535b75052259fc1e2f15ad89ecd55326f762d8a118074d573377d09116533761L518-R531), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-1f883ba25a829313ad70daa6c31595706cf842a63e6e7bc0c342d89081084226L217-R237), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-eb8c5d490beee62cda13bb1581047df56f3fcb788f0f3f6c99415103a19ed6f4L22-L25), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-eb8c5d490beee62cda13bb1581047df56f3fcb788f0f3f6c99415103a19ed6f4R143-R146), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-eb8c5d490beee62cda13bb1581047df56f3fcb788f0f3f6c99415103a19ed6f4R153-R158), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-9f36e927de8aa652ad9551722e28e41bf1bfb1443535be838170eb1d313a119eL47), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-9f36e927de8aa652ad9551722e28e41bf1bfb1443535be838170eb1d313a119eL56-R63), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-9f36e927de8aa652ad9551722e28e41bf1bfb1443535be838170eb1d313a119eR110-R111), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-9f36e927de8aa652ad9551722e28e41bf1bfb1443535be838170eb1d313a119eL195-R195), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-9f36e927de8aa652ad9551722e28e41bf1bfb1443535be838170eb1d313a119eL204-R259), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171R75-R76), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171R86-R87), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L315-L322), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5dbf1df75082c84b45ba07758f820b43b2dad8974dd5e93904390276e5d74320L21-R25), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5dbf1df75082c84b45ba07758f820b43b2dad8974dd5e93904390276e5d74320L76-R96), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edR203-R204), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edR222-R223), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edR237-R238), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL221-R253), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL233-R344), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL275-R383)) * Handle the case where the peer does not have a slot for the connection and does not send an announcement, by returning an error or sending a message that the connection is refused, in the connectivity and peer handler modules ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-9f36e927de8aa652ad9551722e28e41bf1bfb1443535be838170eb1d313a119eL195-R195), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-9f36e927de8aa652ad9551722e28e41bf1bfb1443535be838170eb1d313a119eL204-R259), , [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L335-R361), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171L349-R375)) * Add a `tested_addresses` field to the `PeerDB` struct to store the last tested time for each address, and use a cooldown mechanism to avoid testing the same address too often, in the peer handler and tester modules ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5dbf1df75082c84b45ba07758f820b43b2dad8974dd5e93904390276e5d74320L21-R25), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL233-R344), [link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-6398fb7788e93f0022ddc50d92772a0c87e272a1d7b9326d03c9b404d4e6a9edL275-R383)) * Add a comment to the `get_rand_peers_to_send` method of the `PeerDB` struct to suggest adding the local peer to the vector ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5dbf1df75082c84b45ba07758f820b43b2dad8974dd5e93904390276e5d74320R103)) * Update the file header comment in the `changes.rs` file to use the Rust doc comment syntax ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-5183cc3779c811c3969e22fdc32f7d154ed49ae3d11f452fdd5e5edfdcb09e3dL1-R3)) * Clone the endpoint in the `send_list_peers` function of the `PeerManagementHandler` struct to avoid blocking the main thread, and add error handling for the serialization and sending operations ([link](https://github.com/massalabs/massa/pull/3915/files?diff=unified&w=0#diff-557c1c47bb0831129009ad6c041a68ca82eb1b53b5ed104886d6bbb348189171R487-R496)) Co-authored-by: AurelienFT <aurelien.foucault@epitech.eu>
- Loading branch information