Bleeding edge discovery (#2435)

* Update discovery banning logic and tokio

* Update to latest discovery

* Shift to latest discovery

* Fmt
This commit is contained in:
Age Manning
2021-07-07 18:18:44 +10:00
parent f4bc9db16d
commit c1d2e35c9e
28 changed files with 50 additions and 33 deletions

View File

@@ -26,7 +26,7 @@ slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_tr
slog-term = "2.6.0"
slog-async = "2.5.0"
ctrlc = { version = "3.1.6", features = ["termination"] }
tokio = { version = "1.1.0", features = ["time"] }
tokio = { version = "1.7.1", features = ["time"] }
exit-future = "0.2.0"
dirs = "3.0.1"
logging = { path = "../common/logging" }

View File

@@ -40,7 +40,7 @@ eth2_ssz_derive = "0.1.0"
state_processing = { path = "../../consensus/state_processing" }
tree_hash = "0.1.1"
types = { path = "../../consensus/types" }
tokio = "1.1.0"
tokio = "1.7.1"
eth1 = { path = "../eth1" }
futures = "0.3.7"
genesis = { path = "../genesis" }

View File

@@ -26,7 +26,7 @@ error-chain = "0.12.4"
serde_yaml = "0.8.13"
slog = { version = "2.5.2", features = ["max_level_trace"] }
slog-async = "2.5.0"
tokio = "1.1.0"
tokio = "1.7.1"
dirs = "3.0.1"
futures = "0.3.7"
reqwest = { version = "0.11.0", features = ["native-tls-vendored"] }

View File

@@ -26,7 +26,7 @@ tree_hash = "0.1.1"
eth2_hashing = "0.1.0"
parking_lot = "0.11.0"
slog = "2.5.2"
tokio = { version = "1.1.0", features = ["full"] }
tokio = { version = "1.7.1", features = ["full"] }
state_processing = { path = "../../consensus/state_processing" }
libflate = "1.0.2"
lighthouse_metrics = { path = "../../common/lighthouse_metrics"}

View File

@@ -5,7 +5,7 @@ authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
[dependencies]
discv5 = { version = "0.1.0-beta.5", features = ["libp2p"] }
discv5 = { version = "0.1.0-beta.6", features = ["libp2p"] }
unsigned-varint = { version = "0.6.0", features = ["codec"] }
types = { path = "../../consensus/types" }
hashset_delay = { path = "../../common/hashset_delay" }
@@ -16,7 +16,7 @@ eth2_ssz = "0.1.2"
eth2_ssz_derive = "0.1.0"
slog = { version = "2.5.2", features = ["max_level_trace"] }
lighthouse_version = { path = "../../common/lighthouse_version" }
tokio = { version = "1.1.0", features = ["time", "macros"] }
tokio = { version = "1.7.1", features = ["time", "macros"] }
futures = "0.3.7"
futures-io = "0.3.7"
error-chain = "0.12.4"
@@ -47,7 +47,7 @@ default-features = false
features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns-tokio", "tcp-tokio"]
[dev-dependencies]
tokio = { version = "1.1.0", features = ["full"] }
tokio = { version = "1.7.1", features = ["full"] }
slog-term = "2.6.0"
slog-async = "2.5.0"
tempfile = "3.1.0"

View File

@@ -151,6 +151,16 @@ impl Default for Config {
.build()
.expect("valid gossipsub configuration");
// Discv5 Unsolicited Packet Rate Limiter
let filter_rate_limiter = Some(
discv5::RateLimiterBuilder::new()
.total_n_every(10, Duration::from_secs(1)) // Allow bursts, average 10 per second
.ip_n_every(9, Duration::from_secs(1)) // Allow bursts, average 9 per second
.node_n_every(8, Duration::from_secs(1)) // Allow bursts, average 8 per second
.build()
.expect("The total rate limit has been specified"),
);
// discv5 configuration
let discv5_config = Discv5ConfigBuilder::new()
.enable_packet_filter()
@@ -164,6 +174,10 @@ impl Default for Config {
.disable_report_discovered_peers()
.ip_limit() // limits /24 IP's in buckets.
.incoming_bucket_limit(8) // half the bucket size
.filter_rate_limiter(filter_rate_limiter)
.filter_max_bans_per_ip(Some(5))
.filter_max_nodes_per_ip(Some(10))
.ban_duration(Some(Duration::from_secs(3600)))
.ping_interval(Duration::from_secs(300))
.build();

View File

@@ -497,13 +497,13 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
// first try and convert the peer_id to a node_id.
if let Ok(node_id) = peer_id_to_node_id(peer_id) {
// If we could convert this peer id, remove it from the DHT and ban it from discovery.
self.discv5.ban_node(&node_id);
self.discv5.ban_node(&node_id, None);
// Remove the node from the routing table.
self.discv5.remove_node(&node_id);
}
for ip_address in ip_addresses {
self.discv5.ban_ip(ip_address);
self.discv5.ban_ip(ip_address, None);
}
}
@@ -512,11 +512,11 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
// first try and convert the peer_id to a node_id.
if let Ok(node_id) = peer_id_to_node_id(peer_id) {
// If we could convert this peer id, remove it from the DHT and ban it from discovery.
self.discv5.permit_node(&node_id);
self.discv5.ban_node_remove(&node_id);
}
for ip_address in ip_addresses {
self.discv5.permit_ip(ip_address);
self.discv5.ban_ip_remove(&ip_address);
}
}
@@ -944,7 +944,9 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
*self.network_globals.local_enr.write() = enr;
return Poll::Ready(DiscoveryEvent::SocketUpdated(socket));
}
_ => {} // Ignore all other discv5 server events
Discv5Event::EnrAdded { .. }
| Discv5Event::TalkRequest(_)
| Discv5Event::NodeInserted { .. } => {} // Ignore all other discv5 server events
}
}
}

View File

@@ -20,7 +20,7 @@ merkle_proof = { path = "../../consensus/merkle_proof" }
eth2_ssz = "0.1.2"
eth2_hashing = "0.1.0"
tree_hash = "0.1.1"
tokio = { version = "1.1.0", features = ["full"] }
tokio = { version = "1.7.1", features = ["full"] }
parking_lot = "0.11.0"
slog = "2.5.2"
exit-future = "0.2.0"

View File

@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
warp = { git = "https://github.com/paulhauner/warp ", branch = "cors-wildcard" }
serde = { version = "1.0.116", features = ["derive"] }
tokio = { version = "1.1.0", features = ["macros","sync"] }
tokio = { version = "1.7.1", features = ["macros","sync"] }
tokio-stream = { version = "0.1.3", features = ["sync"] }
tokio-util = "0.6.3"
parking_lot = "0.11.0"

View File

@@ -23,7 +23,7 @@ warp_utils = { path = "../../common/warp_utils" }
malloc_utils = { path = "../../common/malloc_utils" }
[dev-dependencies]
tokio = { version = "1.1.0", features = ["sync"] }
tokio = { version = "1.7.1", features = ["sync"] }
reqwest = { version = "0.11.0", features = ["json"] }
environment = { path = "../../lighthouse/environment" }
types = { path = "../../consensus/types" }

View File

@@ -31,7 +31,7 @@ eth2_ssz_types = { path = "../../consensus/ssz_types" }
tree_hash = "0.1.1"
futures = "0.3.7"
error-chain = "0.12.4"
tokio = { version = "1.1.0", features = ["full"] }
tokio = { version = "1.7.1", features = ["full"] }
tokio-stream = "0.1.3"
parking_lot = "0.11.0"
smallvec = "1.6.1"

View File

@@ -8,7 +8,7 @@ edition = "2018"
beacon_chain = { path = "../beacon_chain" }
types = { path = "../../consensus/types" }
slot_clock = { path = "../../common/slot_clock" }
tokio = { version = "1.1.0", features = ["full"] }
tokio = { version = "1.7.1", features = ["full"] }
slog = "2.5.2"
parking_lot = "0.11.0"
futures = "0.3.7"