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

Priority nodes #2891

Draft
wants to merge 7 commits into
base: testnet
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.20)
# Set current version of the project
set(TARAXA_MAJOR_VERSION 1)
set(TARAXA_MINOR_VERSION 12)
set(TARAXA_PATCH_VERSION 0)
set(TARAXA_PATCH_VERSION 1)
set(TARAXA_VERSION ${TARAXA_MAJOR_VERSION}.${TARAXA_MINOR_VERSION}.${TARAXA_PATCH_VERSION})

# Any time a change in the network protocol is introduced this version should be increased
Expand Down
3 changes: 2 additions & 1 deletion libraries/aleth/libp2p/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ void Host::startPeerSession(Public const& _id, RLP const& _hello, unique_ptr<RLP
}
}
}
if (!disconnect_reason && !peerSlotsAvailable()) {
auto is_priority_node = m_netConfig.priority_nodes.contains(peer->address());
if (!disconnect_reason && (!peerSlotsAvailable() && !is_priority_node)) {
cnetdetails << "Too many peers, can't connect. peer count: " << peer_count_()
<< " pending peers: " << m_pendingPeerConns.size();
disconnect_reason = TooManyPeers;
Expand Down
3 changes: 3 additions & 0 deletions libraries/aleth/libp2p/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ struct NetworkConfig {
if (!publicIPAddress.empty() && !isPublicAddress(publicIPAddress)) BOOST_THROW_EXCEPTION(InvalidPublicIPAddress());
}

/// Priority Nodes
std::unordered_set<dev::p2p::NodeID> priority_nodes;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could be const


/// Addressing

std::string publicIPAddress;
Expand Down
1 change: 1 addition & 0 deletions libraries/aleth/libp2p/taraxa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct TaraxaNetworkConfig {
bool is_boot_node = false;
unsigned chain_id = 0;
uint expected_parallelism = 1;

std::chrono::seconds peer_healthcheck_interval{30};
std::chrono::seconds peer_healthcheck_timeout{1};
std::chrono::milliseconds main_loop_interval{100};
Expand Down
22 changes: 20 additions & 2 deletions libraries/cli/include/cli/config_jsons/testnet/testnet_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"listen_port": 10002,
"transaction_interval_ms": 100,
"ideal_peer_count": 10,
"max_peer_count": 50,
"max_peer_count": 20,
"sync_level_size": 10,
"packets_processing_threads": 14,
"peer_blacklist_timeout": 600,
Expand All @@ -51,7 +51,25 @@
"ip": "boot-node-2.testnet.taraxa.io",
"port": 10002
}
]
],
"priority_nodes" : [
"b4ab8c09f711866b067debd9ab075df1a965ade72bc7409d53799b9783543d89d2264e2650e364d9c84694c2fdaaeb69fe500d720a2f1ad17d4bb37a31ca31a6",
"3c87eb8991fda4728c41752d4e374aab555ce76daac92657e9656aa33615e90a64d9582861bc00954332052c3ac3c969b3e23683533db5ae24f8126ce6de427e",
"adbb7940b859e8fde19a93ce26910d51ddd8490b813f8bfc77381665439f11e42c58b626ae4d9da06a4a1730bf28a19bce146e4ba618760f8ee89ccee2bd64aa",
"835b8270274bee693362f8a1357bde3bffaeb40e43c9d47a731ed8ef982554213e6b66e559c6d647a8782483b243704402122a8826fb97ec36cf722bbfc8c3a1",
"28da51fa13108af8e852c5310d4e137e347232129e0503809b9f30588d20ada6c38989f518ae564a82a6c742196d4beed1374585298ba9dad1d551af7a3adf90",
"71b4f525338f2398bee7574d4904c6e4893ca7e39f2f3bed3a9ed44f8fc45e5346a5fee7650475ce012f872c8883f4bd386989172d9bb486e3cb320a0f09b944",
"7bcb52c0011734b394f2e485d48a942ec2a9daa5038acb2a008d6953c1180c604a5f2213c6e581bf3d58d8bbbdf5f8879a3d833105c99332c3ba567aaf67a116",
"7926670f70d032170be1956a1aecdb836717417f86794574ef01e70593396cd3fe4d888aedca5bd6c1b7ee55d8624016547c6fd5faad73e986f6aa0ac30ee2c7",
"fcafab2f0e9736fdefef9bea757c27fd75c2da4c81c175118d74a41a9de3ba340d72e649672f891e9416f23d6963ef52af81e054e84a5eece5f411de31f1206b",
"9419d4d29352d22f924fd49965eefb36d03efc35d2bde7cd3d98b3b583a4c1137837f85663ec206db66c88b2ba92269b4b702f4fc7685f3816d4ce5e81c0c7fb",
"1e4a866fd64d1a88d8f3181f59b5c5e0655f04c48bb92abe5e21e235334db799e64af79334eec9bebc0de1262766f48f0f5df644a49a7bddfb8506d1bb0dcfb1",
"f820fec3f4679d8b9125a47be802d985294fd59d76aca9ff489e50deb5b438682effbd486b11258a3d6e12076af9f09adc948861ed38e91ad9f5a84b3d33f1f4",
"dcc7f60f64eee9fc470e24fd821b3d82acca646c6c951169a8f5b3de297e241cd9987e1cca1083c85b6482ba09715bbea8765710b149c55493e0bb16fc1c29cc",
"dedae37d9c96e0f2c8ef2796351f5560234a3e8e0407ef5cd16aaf93dd8ffd437608a585d5dc3eea54e30e1392591cfc61c6fce3cbf12b46dcc479b5fbdcde96",
"edc73153c2aa5991aee267f46d3ca153fa15f61eb7847b3f4c8b8fa308282b93a315a071bd5ff4327dd321faf4d979710b0e681a7088f65552ce0065fa7683fd",
"00dd2e12a91efcf2f458c039942d16607cca05dfe1f5a94ca59e573aadd86b576f4660ab1baa1ce475c9513b4c9fd04d48a4d9a8173479ccd301e012d21d8239",
"4ba3ebf739ee9fca54e4502dccecf0d4c1390cf87fe54af7356d9da0dc7be0db64d5272d277ae9f1a2f020d0edbdd8286a9b999a875ea6df3585d0939152fe05" ]
},
"db_config": {
"db_snapshot_each_n_pbft_block": 10000,
Expand Down
2 changes: 2 additions & 0 deletions libraries/config/include/config/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>

#include "common/types.hpp"
#include "libp2p/Common.h"

namespace taraxa {

Expand Down Expand Up @@ -82,6 +83,7 @@ struct NetworkConfig {
bool disable_peer_blacklist = false;
uint16_t deep_syncing_threshold = 10;
DdosProtectionConfig ddos_protection;
std::unordered_set<dev::p2p::NodeID> priority_nodes;

std::optional<ConnectionConfig> rpc;
std::optional<ConnectionConfig> graphql;
Expand Down
7 changes: 7 additions & 0 deletions libraries/config/src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ void dec_json(const Json::Value &json, NetworkConfig &network) {
network.listen_port = getConfigDataAsUInt(json, {"listen_port"});
network.transaction_interval_ms = getConfigDataAsUInt(json, {"transaction_interval_ms"});
network.ideal_peer_count = getConfigDataAsUInt(json, {"ideal_peer_count"});
Json::Value priority_nodes = json["priority_nodes"];
if (!priority_nodes.isNull()) {
for (const auto &item : priority_nodes) {
network.priority_nodes.insert(dev::p2p::NodeID(item.asString()));
}
}

network.max_peer_count = getConfigDataAsUInt(json, {"max_peer_count"});
network.sync_level_size = getConfigDataAsUInt(json, {"sync_level_size"});
network.packets_processing_threads = getConfigDataAsUInt(json, {"packets_processing_threads"});
Expand Down
1 change: 1 addition & 0 deletions libraries/core_libs/network/src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Network::Network(const FullNodeConfig &config, const h256 &genesis_hash, std::fi
net_conf.traverseNAT = false;
net_conf.publicIPAddress = config.network.public_ip;
net_conf.pin = false;
net_conf.priority_nodes = config.network.priority_nodes;

dev::p2p::TaraxaNetworkConfig taraxa_net_conf;
taraxa_net_conf.ideal_peer_count = config.network.ideal_peer_count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ void StatusPacketHandler::process(const threadpool::PacketData& packet_data, con
return;
}

if (node_major_version < 1 || (node_major_version == 1 && node_minor_version < 12) ||
(node_major_version == 1 && node_minor_version == 12 && node_patch_version < 1)) {
LOG(log_er_) << "Disconnect node which is not at least 1.12.1";
disconnect(packet_data.from_node_id_, dev::p2p::UserReason);
return;
}

Comment on lines +78 to +84
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should put TODO here to remove before merging to master

// If this is a light node and it cannot serve our sync request disconnect from it
if (is_light_node) {
selected_peer->peer_light_node = true;
Expand Down