Skip to content

Commit

Permalink
Merge #3789
Browse files Browse the repository at this point in the history
3789: Testnet 22 r=AurelienFT a=AurelienFT

<!--
copilot:all
-->
### <samp>πŸ€– Generated by Copilot at deb5818</samp>

### Summary
πŸ§ΉπŸ”‘πŸ”„

<!--
1.  🧹 - This emoji represents the removal of unused or unnecessary dependencies and code, which can be seen as a form of cleaning or tidying up the project.
2.  πŸ”‘ - This emoji represents the addition of the node signature feature, which involves using a keypair to sign and verify private API messages, enhancing the security and authenticity of the communication.
3.  πŸ”„ - This emoji represents the update and adaptation of the API and network components to the new architecture and protocol interface, which can be seen as a form of changing or updating the code to match the new design.
-->
This pull request implements the network refactoring and the node signature feature for the `massa-api` component. It also adds a `max_coins` field to the `OperationInput` struct and a `last_de_step` field to the bootstrap time message. It removes unused dependencies and simplifies the error handling and the bootstrap server logic. It affects the following files: `massa-api-exports/src/config.rs`, `massa-api-exports/src/error.rs`, `massa-api-exports/src/operation.rs`, `massa-api/Cargo.toml`, `massa-api/src/lib.rs`, `massa-api/src/private.rs`, `massa-api/src/public.rs`, `massa-bootstrap/src/messages.rs`, `massa-bootstrap/src/server_binder.rs`, `massa-bootstrap/src/server/white_black_list.rs`, `massa-bootstrap/src/establisher.rs`, `Cargo.toml`, and `massa-api-exports/Cargo.toml`.

> _We're breaking free from the old network chains_
> _We're simplifying the code and the errors_
> _We're signing our messages with our own keys_
> _We're synchronizing our steps with our peers_

### Walkthrough
*  Remove dependencies on `massa-network-worker` and `massa-network-exports` crates, which are no longer used after the network refactoring ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542L21-L22), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-2959d6fef477da4a71811ca94245288a9c1e687d27eb49df9e4e518299e74418L23), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-be015cdf8704641ee1b0d76a224fa824f8cc65247b118c10a7078e45a8533b35L11), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-be015cdf8704641ee1b0d76a224fa824f8cc65247b118c10a7078e45a8533b35L30-L31), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-be015cdf8704641ee1b0d76a224fa824f8cc65247b118c10a7078e45a8533b35L68), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-1af91190966c29d2c4636cd9f9d4f909f82b8b7c52aec79d094a805294697085L26), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-b221394fc05ee73e5759394fd6b5e2e3b64665df85e1921cb779ea3a960b5ffcL37-R39), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-b221394fc05ee73e5759394fd6b5e2e3b64665df85e1921cb779ea3a960b5ffcL67-R74), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-b221394fc05ee73e5759394fd6b5e2e3b64665df85e1921cb779ea3a960b5ffcL84-R82), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L31-R32), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L36-R36), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L57-R58))
*  Add dependency on `massa-signature` crate to use the `KeyPair` type for the API keypair configuration and the `PublicKey` and `PUBLIC_KEY_SIZE_BYTES` types for the node ban and unban features and the node status feature ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c6bbc12efc4e84178e7e0dccfd43b57cc8cb3425f0b003a85f9e3cdb197f188cR3), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3R21), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L31-R32), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L36-R36), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L57-R58))
*  Add dependency on `massa-models` crate to use the `Amount` type for the max coins configuration ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-d29f8d12abf345eb45db7b9dfda4d03e121bca9e404626af4f21450ee8c1e819L71-R74))
*  Add dependency on `massa-hash` crate to use the `Hash` type for the node signature feature ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-1af91190966c29d2c4636cd9f9d4f909f82b8b7c52aec79d094a805294697085L35-L33), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3R21), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L57-R58))
*  Add dependency on `massa-protocol-exports` crate to provide the interface to the protocol component ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-b221394fc05ee73e5759394fd6b5e2e3b64665df85e1921cb779ea3a960b5ffcL37-R39), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L31-R32), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L36-R36))
*  Add a new field `keypair` to the `APIConfig` struct, which holds the keypair used by the node to sign messages for the private API ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c6bbc12efc4e84178e7e0dccfd43b57cc8cb3425f0b003a85f9e3cdb197f188cR70-R71))
*  Add a new field `max_coins` to the `OperationInput` struct, which holds the maximum amount of coins that can be transferred in a single operation ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-d29f8d12abf345eb45db7b9dfda4d03e121bca9e404626af4f21450ee8c1e819R81))
*  Add a new field `last_de_step` to the `BootstrapServerMessage::BootstrapTime` variant, which represents the last received executed denunciations associated slot ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-41607f7ffed8d02fd90cdd3df790dec7da29fb51656780c87efca2242a0f5728R631-R632), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-41607f7ffed8d02fd90cdd3df790dec7da29fb51656780c87efca2242a0f5728R729), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-41607f7ffed8d02fd90cdd3df790dec7da29fb51656780c87efca2242a0f5728R746), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-41607f7ffed8d02fd90cdd3df790dec7da29fb51656780c87efca2242a0f5728R892), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-41607f7ffed8d02fd90cdd3df790dec7da29fb51656780c87efca2242a0f5728R917-R919), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-41607f7ffed8d02fd90cdd3df790dec7da29fb51656780c87efca2242a0f5728R935), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-41607f7ffed8d02fd90cdd3df790dec7da29fb51656780c87efca2242a0f5728R946))
*  Replace the implementation of the `node_sign_message` function of the `Private` struct, which uses the keypair from the API settings to sign the message hash and returns the public key and signature as a `PubkeySig` struct ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L89-R105))
*  Replace the implementation of the `node_ban_by_id`, `node_unban_by_id`, `node_ban_by_ip`, and `node_unban_by_ip` functions of the `Private` struct, which use the protocol controller to ban or unban peers by their peer ids ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L138-R209))
*  Replace the implementation of the `node_peers_whitelist`, `node_add_to_peers_whitelist`, and `node_remove_from_peers_whitelist` functions of the `Private` struct, which return an error indicating that they are not available for now ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L222-R297))
*  Replace the `async` imports of `AsyncReadExt` and `AsyncWriteExt` from `tokio::io` with the `sync` imports of `Read` and `Write` from `std::io` in the `server_binder` module ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL19-R26))
*  Replace the `duplex` field of the `BootstrapServerBinder` struct from a generic type `D` that implements `Duplex` to a concrete type `TcpStream` and remove the `Limiter` wrapper ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL37-R35), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL44-R42), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL52-R53), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL68-R67))
*  Replace the `async` methods of the `BootstrapServerBinder` struct with `sync` methods that take optional `Duration` parameters and use blocking IO instead of async IO ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL79-R83), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL88-R91), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL105-R125), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL120-R136), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL149-R177), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL185-R211), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL202-R239), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL216-R257))
*  Remove the `server_outer_rt_hnd` parameter from the `BootstrapServerBinder::close_and_send_error` method ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL120-R136))
*  Remove the `Box` wrapper from the `Result` types returned by the `SharedWhiteBlackList` and `WhiteBlackListInner` methods ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-6eb54fbc36294a88123d5489e54673ade6e4afe8b45c1aac39df00b1ada8704cL27-R27), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-6eb54fbc36294a88123d5489e54673ade6e4afe8b45c1aac39df00b1ada8704cL44-R41), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-6eb54fbc36294a88123d5489e54673ade6e4afe8b45c1aac39df00b1ada8704cL70-R67), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-6eb54fbc36294a88123d5489e54673ade6e4afe8b45c1aac39df00b1ada8704cL82-R80), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-6eb54fbc36294a88123d5489e54673ade6e4afe8b45c1aac39df00b1ada8704cL94-R92), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-6eb54fbc36294a88123d5489e54673ade6e4afe8b45c1aac39df00b1ada8704cL110-R103), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-6eb54fbc36294a88123d5489e54673ade6e4afe8b45c1aac39df00b1ada8704cL120-R113))
*  Remove the `&` reference from the `msg_bytes` argument in the `extend`, `compute_from`, and `deserialize` methods in the `BootstrapServerBinder::next_timeout` method ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL240-R276), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL253-R285))
*  Remove the unused imports of `Duplex` from `establisher` and `Limiter`, `Resource` and `StandardClock` from `async_speed_limit` in the `server_binder` module ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL4), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-c466f10d83d65872818177400869847c2fb10f2d07937e0b79be0659d80f8ecbL10-L11))
*  Remove the `network_settings`, `network_command_sender`, and `protocol_command_sender` fields from the `Public` struct and the `network_command_sender` field from the `Private` struct and replace them with the `protocol_controller` and `protocol_config` fields ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-b221394fc05ee73e5759394fd6b5e2e3b64665df85e1921cb779ea3a960b5ffcL67-R74), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-b221394fc05ee73e5759394fd6b5e2e3b64665df85e1921cb779ea3a960b5ffcL84-R82), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L47-R47), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L55-R55),  [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L84-R87))
*  Remove the `network_settings`, `network_command_sender`, and `protocol_command_sender` parameters from the `new` function of the `Public` struct and the `network_command_sender` parameter from the `new` function of the `Private` struct and replace them with the `protocol_controller` and `protocol_config` parameters ( [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L47-R47), [link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-05bc7781e17033a0835212792e1acfd48ff78d9d6e07aff848519c5e3ba016b1L73-R74))
*  Remove the unused import of `itertools` from the `massa-api/src/private.rs` file ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-cd4f41c909f44d643e1f76870f7f75ff91d50d28240998b23795e3f314e4a3a3L6))
*  Remove the file `massa-bootstrap/src/establisher.rs`, which was no longer used after the network refactoring ([link](https://github.com/massalabs/massa/pull/3789/files?diff=unified&w=0#diff-4ba6a8d2fcf0282e4616dd00a1667f7cb0be0dbd2cc76beb32a66dacf1442916))



Co-authored-by: Sydhds <sylvain.delhomme@gmail.com>
Co-authored-by: Moncef AOUDIA <22281426+aoudiamoncef@users.noreply.github.com>
Co-authored-by: AurelienFT <32803821+AurelienFT@users.noreply.github.com>
Co-authored-by: AurelienFT <aurelien.foucault@epitech.eu>
Co-authored-by: Modship <yeskinokay@gmail.com>
Co-authored-by: Ben <benphawke@gmail.com>
Co-authored-by: JF <jfm@laposte.net>
Co-authored-by: Modship <lu@massa.net>
Co-authored-by: Damir Vodenicarevic <damipator@gmail.com>
Co-authored-by: damip <damipator@gmail.com>
Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Co-authored-by: Thomas Plisson <thomas.plisson@epitech.eu>
Co-authored-by: Eitu33 <89928840+Eitu33@users.noreply.github.com>
  • Loading branch information
12 people authored May 4, 2023
2 parents d969f7d + 18277fa commit 426a6ef
Show file tree
Hide file tree
Showing 247 changed files with 21,499 additions and 19,065 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:
- macOS-latest
- windows-latest
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v3
with:
submodules: "recursive"
Expand Down Expand Up @@ -204,7 +205,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: doc
args: --no-deps --all-features --document-private-items
args: --no-deps --document-private-items
- uses: JamesIves/github-pages-deploy-action@4.1.7
with:
branch: gh-pages
Expand Down
Loading

0 comments on commit 426a6ef

Please sign in to comment.