Skip to content

Commit

Permalink
Merge #3915
Browse files Browse the repository at this point in the history
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
bors[bot] and AurelienFT authored May 8, 2023
2 parents 93333bf + 6910564 commit 08c3593
Show file tree
Hide file tree
Showing 26 changed files with 661 additions and 285 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- uses: ilammy/setup-nasm@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions massa-async-pool/src/changes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///! Copyright (c) 2022 MASSA LABS <info@massa.net>
//! Copyright (c) 2022 MASSA LABS <info@massa.net>
///! This file provides structures representing changes to the asynchronous message pool
//! This file provides structures representing changes to the asynchronous message pool
use std::ops::Bound::Included;

use crate::{
Expand Down
8 changes: 4 additions & 4 deletions massa-models/src/config/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ lazy_static::lazy_static! {
)
)
} else {
1683291600000.into() // Friday, May 5, 2023 01:00:00 PM UTC
1683498600000.into() // Sunday, May 7, 2023 10:30:00 PM UTC
};

/// TESTNET: time when the blockclique is ended.
pub static ref END_TIMESTAMP: Option<MassaTime> = if cfg!(feature = "sandbox") {
None
} else {
Some(1685556000000.into()) // Sunday, April 30, 2023 06:00:00 PM UTC
Some(1685556000000.into()) // Sunday, May 30, 2023 06:00:00 PM UTC
};
/// `KeyPair` to sign genesis blocks.
pub static ref GENESIS_KEY: KeyPair = KeyPair::from_str("S1UxdCJv5ckDK8z87E5Jq5fEfSVLi2cTHgtpfZy7iURs3KpPns8")
Expand All @@ -68,9 +68,9 @@ lazy_static::lazy_static! {
/// node version
pub static ref VERSION: Version = {
if cfg!(feature = "sandbox") {
"SAND.22.0"
"SAND.22.1"
} else {
"TEST.22.0"
"TEST.22.1"
}
.parse()
.unwrap()
Expand Down
7 changes: 6 additions & 1 deletion massa-models/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl serde::Serialize for Version {
}

/// Serializer for `Version`
#[derive(Clone)]
pub struct VersionSerializer {
u32_serializer: U32VarIntSerializer,
}
Expand Down Expand Up @@ -108,6 +109,7 @@ impl Serializer<Version> for VersionSerializer {
}

/// Serializer for `Version`
#[derive(Clone)]
pub struct VersionDeserializer {
u32_deserializer: U32VarIntDeserializer,
}
Expand Down Expand Up @@ -189,7 +191,10 @@ impl Deserializer<Version> for VersionDeserializer {
impl Version {
/// true if instance and major are the same
pub fn is_compatible(&self, other: &Version) -> bool {
self.instance == other.instance && self.major == other.major
self.instance == other.instance
&& self.major == other.major
&& self.minor >= 1
&& other.minor >= 1
}
}

Expand Down
2 changes: 1 addition & 1 deletion massa-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tracing = { version = "0.1", features = [
"max_level_debug",
"release_max_level_debug",
] }
peernet = { git = "https://github.com/massalabs/PeerNet", rev = "9300cb35b09347f3848c9a232f9aaf3f3f100ece" }
peernet = { git = "https://github.com/massalabs/PeerNet", rev = "cf4cb09deda8cdd9b8893cc9595ac3b255aa74c9" }
tracing-subscriber = "0.3"
paw = "1.0"
structopt = { version = "0.3", features = ["paw"] }
Expand Down
15 changes: 11 additions & 4 deletions massa-node/base_config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@
keypair_file = "config/node_privkey.key"
# path to the initial peers file
initial_peers_file = "base_config/initial_peers.json"
# maximum of incoming connections
max_incoming_connections = 15
# maximum of outgoing connections
max_outgoing_connections = 10
# Limit of read/write number of bytes per second with a peer (Should be a 10 multiple)
read_write_limit_bytes_per_second = 2_000_000_000
# timeout after which without answer a hanshake is ended
Expand Down Expand Up @@ -196,12 +192,23 @@
operation_announcement_interval = 300
# max number of operation per message, same as network param but can be smaller
max_operations_per_message = 1024
# Number of millis seconds between each try out connections
try_connection_timer = 5000
# Number of millis seconds that create a timeout for out connections
timeout_connection = 1000
# time threshold after which operation are not propagated
max_operations_propagation_time = 32000
# time threshold after which endorsement are not propagated
max_endorsements_propagation_time = 48000
# number of thread tester
thread_tester_count = 5
# Peer default category limits
default_category_info = { target_out_connections = 10, max_in_connections_per_ip = 2, max_in_connections_pre_handshake = 100, max_in_connections_post_handshake = 15}
# Peer categories limits
[protocol.peers_categories]
Bootstrap = { target_out_connections = 1, max_in_connections_per_ip = 1, max_in_connections_pre_handshake = 8, max_in_connections_post_handshake = 1}

[network]

[bootstrap]
# list of bootstrap (ip, node id)
Expand Down
41 changes: 33 additions & 8 deletions massa-node/base_config/initial_peers.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
{
"P12UbyLJDS7zimGWf3LTHe8hYY67RdLke1iDRZqJbQQLHQSKPW8j": {
"149.202.86.103:31244": "Tcp"
"listeners": {
"149.202.86.103:31244": "Tcp"
},
"category": "Bootstrap"

},
"P12vxrYTQzS5TRzxLfFNYxn6PyEsphKWkdqx2mVfEuvJ9sPF43uq": {
"149.202.89.125:31244": "Tcp"
"listeners": {
"149.202.89.125:31244": "Tcp"
},
"category": "Bootstrap"
},
"P12rPDBmpnpnbECeAKDjbmeR19dYjAUwyLzsa8wmYJnkXLCNF28E": {
"158.69.120.215:31244": "Tcp"
"listeners": {
"158.69.120.215:31244": "Tcp"
},
"category": "Bootstrap"
},
"P1XxexKa3XNzvmakNmPawqFrE9Z2NFhfq1AhvV1Qx4zXq5p1Bp9": {
"158.69.23.120:31244": "Tcp"
"listeners": {
"158.69.23.120:31244": "Tcp"
},
"category": "Bootstrap"
},
"P1qxuqNnx9kyAMYxUfsYiv2gQd5viiBX126SzzexEdbbWd2vQKu": {
"198.27.74.5:31244": "Tcp"
"listeners": {
"198.27.74.5:31244": "Tcp"
},
"category": "Bootstrap"
},
"P1hdgsVsd4zkNp8cF1rdqqG6JPRQasAmx12QgJaJHBHFU1fRHEH": {
"198.27.74.52:31244": "Tcp"
"listeners": {
"198.27.74.52:31244": "Tcp"
},
"category": "Bootstrap"
},
"P1gEdBVEbRFbBxBtrjcTDDK9JPbJFDay27uiJRE3vmbFAFDKNh7": {
"54.36.174.177:31244": "Tcp"
"listeners": {
"54.36.174.177:31244": "Tcp"
},
"category": "Bootstrap"
},
"P13Ykon8Zo73PTKMruLViMMtE2rEG646JQ4sCcee2DnopmVM3P5": {
"51.75.60.228:31244": "Tcp"
"listeners": {
"51.75.60.228:31244": "Tcp"
},
"category": "Bootstrap"
}
}
2 changes: 1 addition & 1 deletion massa-node/base_config/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openrpc": "1.2.4",
"info": {
"title": "Massa OpenRPC Specification",
"version": "TEST.22.0",
"version": "TEST.22.1",
"description": "Massa OpenRPC Specification document. Find more information on https://docs.massa.net/en/latest/technical-doc/api.html",
"termsOfService": "https://open-rpc.org",
"contact": {
Expand Down
24 changes: 18 additions & 6 deletions massa-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,15 @@ async fn launch(
// NOTE: this is temporary, since we cannot currently handle bootstrap from remaining ledger
if args.keep_ledger || args.restart_from_snapshot_at_period.is_some() {
info!("Loading old ledger for next episode");
} else if SETTINGS.ledger.disk_ledger_path.exists() {
std::fs::remove_dir_all(SETTINGS.ledger.disk_ledger_path.clone())
.expect("disk ledger delete failed");
} else {
if SETTINGS.ledger.disk_ledger_path.exists() {
std::fs::remove_dir_all(SETTINGS.ledger.disk_ledger_path.clone())
.expect("disk ledger delete failed");
}
if SETTINGS.execution.hd_cache_path.exists() {
std::fs::remove_dir_all(SETTINGS.execution.hd_cache_path.clone())
.expect("disk hd cache delete failed");
}
}

// Create final ledger
Expand Down Expand Up @@ -479,8 +485,6 @@ async fn launch(
initial_peers: SETTINGS.protocol.initial_peers_file.clone(),
listeners,
keypair_file: SETTINGS.protocol.keypair_file.clone(),
max_in_connections: SETTINGS.protocol.max_incoming_connections,
max_out_connections: SETTINGS.protocol.max_outgoing_connections,
max_known_blocks_saved_size: SETTINGS.protocol.max_known_blocks_size,
asked_operations_buffer_capacity: SETTINGS.protocol.max_known_ops_size,
thread_tester_count: SETTINGS.protocol.thread_tester_count,
Expand Down Expand Up @@ -515,8 +519,16 @@ async fn launch(
max_size_peers_announcement: MAX_PEERS_IN_ANNOUNCEMENT_LIST,
read_write_limit_bytes_per_second: SETTINGS.protocol.read_write_limit_bytes_per_second
as u128,
routable_ip: SETTINGS.protocol.routable_ip,
try_connection_timer: SETTINGS.protocol.try_connection_timer,
timeout_connection: SETTINGS.protocol.timeout_connection,
routable_ip: SETTINGS
.protocol
.routable_ip
.or(SETTINGS.network.routable_ip),
debug: false,
peers_categories: SETTINGS.protocol.peers_categories.clone(),
default_category_info: SETTINGS.protocol.default_category_info,
version: *VERSION,
};

let (protocol_controller, protocol_channels) =
Expand Down
23 changes: 18 additions & 5 deletions massa-node/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copyright (c) 2022 MASSA LABS <info@massa.net>

//! Build here the default node settings from the configuration file toml
use std::path::PathBuf;
use std::{collections::HashMap, path::PathBuf};

use massa_bootstrap::IpType;
use massa_models::{config::build_massa_settings, node::NodeId};
use massa_protocol_exports::PeerCategoryInfo;
use massa_time::MassaTime;
use serde::Deserialize;
use std::net::{IpAddr, SocketAddr};
Expand Down Expand Up @@ -124,6 +125,7 @@ pub struct Settings {
pub protocol: ProtocolSettings,
pub consensus: ConsensusSettings,
pub api: APISettings,
pub network: NetworkSettings,
pub bootstrap: BootstrapSettings,
pub pool: PoolSettings,
pub execution: ExecutionSettings,
Expand Down Expand Up @@ -163,6 +165,13 @@ pub struct ConsensusSettings {
pub broadcast_filled_blocks_channel_capacity: usize,
}

// TODO: Remove one date. Kept for retro compatibility.
#[derive(Debug, Deserialize, Clone)]
pub struct NetworkSettings {
/// Ip seen by others. If none the bind ip is used
pub routable_ip: Option<IpAddr>,
}

/// Protocol Configuration, read from toml user configuration file
#[derive(Debug, Deserialize, Clone)]
pub struct ProtocolSettings {
Expand Down Expand Up @@ -214,14 +223,18 @@ pub struct ProtocolSettings {
pub routable_ip: Option<IpAddr>,
/// Time threshold to have a connection to a node
pub connect_timeout: MassaTime,
/// Max number of connection in
pub max_incoming_connections: usize,
/// Max number of connection out
pub max_outgoing_connections: usize,
/// Number of tester threads
pub thread_tester_count: u8,
/// Number of bytes we can read/write by seconds in a connection (must be a 10 multiple)
pub read_write_limit_bytes_per_second: u64,
/// try connection timer
pub try_connection_timer: MassaTime,
/// Timeout connection
pub timeout_connection: MassaTime,
/// Peers limits per category
pub peers_categories: HashMap<String, PeerCategoryInfo>,
/// Limits for default category
pub default_category_info: PeerCategoryInfo,
}

/// gRPC settings
Expand Down
2 changes: 1 addition & 1 deletion massa-protocol-exports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ thiserror = "1.0"
nom = "7.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
peernet = { git = "https://github.com/massalabs/PeerNet", rev = "9300cb35b09347f3848c9a232f9aaf3f3f100ece" }
peernet = { git = "https://github.com/massalabs/PeerNet", rev = "cf4cb09deda8cdd9b8893cc9595ac3b255aa74c9" }
tempfile = { version = "3.3", optional = true } # use with testing feature
mockall = "0.11.4"

Expand Down
7 changes: 7 additions & 0 deletions massa-protocol-exports/src/bootstrap_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ use peernet::peer_id::PeerId;
use peernet::transports::TransportType;
use serde::{Deserialize, Serialize};

/// Peer info provided in bootstrap
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PeerData {
pub listeners: HashMap<SocketAddr, TransportType>,
pub category: String,
}

/// Peers that are transmitted during bootstrap
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BootstrapPeers(pub Vec<(PeerId, HashMap<SocketAddr, TransportType>)>);
Expand Down
6 changes: 4 additions & 2 deletions massa-protocol-exports/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ mod controller_trait;
mod error;
mod settings;

pub use bootstrap_peers::{BootstrapPeers, BootstrapPeersDeserializer, BootstrapPeersSerializer};
pub use bootstrap_peers::{
BootstrapPeers, BootstrapPeersDeserializer, BootstrapPeersSerializer, PeerData,
};
pub use controller_trait::{ProtocolController, ProtocolManager};
pub use error::ProtocolError;
pub use peernet::peer::PeerConnectionType;
pub use peernet::peer_id::PeerId;
pub use peernet::transports::TransportType;
pub use settings::ProtocolConfig;
pub use settings::{PeerCategoryInfo, ProtocolConfig};

#[cfg(feature = "testing")]
pub mod test_exports;
Expand Down
Loading

0 comments on commit 08c3593

Please sign in to comment.