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

Fixes in peer and handler and delete cache of sc at start #3915

Merged
merged 35 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0e9781e
Errors in fallback function doesn't panic
AurelienFT May 5, 2023
66ebf03
Fix tester pause time
AurelienFT May 6, 2023
d08ad33
Fix clippy warning
AurelienFT May 6, 2023
a07638c
Install nasm in CD.
AurelienFT May 6, 2023
73b71e9
Change return to continue because we are not in for each anymore.
AurelienFT May 6, 2023
cf6348b
Readd network section for routable ip for backward compatibility purp…
AurelienFT May 6, 2023
f28da96
Add different cooldown depending on slots in out connections
AurelienFT May 6, 2023
9121672
Change timeout connection
AurelienFT May 6, 2023
1331518
Add todo block send
AurelienFT May 6, 2023
bf4a3de
Add management of peers by category.
AurelienFT May 6, 2023
cf963cb
Fix comparison wrong direction and bad check delete hd cache.
AurelienFT May 7, 2023
c598072
remove debug print
AurelienFT May 7, 2023
f4a0f8c
Remove sleep in fallback
AurelienFT May 7, 2023
c6e49a2
Don't mark a peer as error when trying to connect and it's full.
AurelienFT May 7, 2023
dc94781
Fix tests
AurelienFT May 7, 2023
5cc3702
Add peer tests cooldown by category.
AurelienFT May 7, 2023
35832e4
Use new version of peernet and verify versions in handshake
AurelienFT May 7, 2023
ae54c06
Add debug print
AurelienFT May 7, 2023
bd455ca
Fix comparison in a bad way.
AurelienFT May 7, 2023
23e39ca
Fix trying out connections in loop
AurelienFT May 7, 2023
12ad7b3
Update peernet and remove debug print
AurelienFT May 7, 2023
7837328
Update peernet with debug prints.
AurelienFT May 7, 2023
a9bf45b
Update peernet
AurelienFT May 7, 2023
72653a9
Fix connection launch thread.
AurelienFT May 7, 2023
10a487a
Update peernet
AurelienFT May 7, 2023
6df2a07
Update peernet
AurelienFT May 7, 2023
d84d1e7
Update config and fix clippy
AurelienFT May 7, 2023
45f4768
Update timestamp and version update
AurelienFT May 7, 2023
21f0d36
Update initial peers.
AurelienFT May 7, 2023
71052d5
Update timestamp and fix compile error.
AurelienFT May 7, 2023
786c985
Fix version check and cooldown
AurelienFT May 8, 2023
bf688d6
Add config variables for timers and improve flexibility
AurelienFT May 8, 2023
c29f6f6
If an peers couldn't be connected because full. Make it unavailable b…
AurelienFT May 8, 2023
d2489b3
Update peernet
AurelienFT May 8, 2023
6910564
Use fixed commit of peernet
AurelienFT May 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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