Skip to content

Commit 3c93c01

Browse files
committed
Bleeding edge discovery (#2435)
* Update discovery banning logic and tokio * Update to latest discovery * Shift to latest discovery * Fmt
1 parent e672212 commit 3c93c01

File tree

28 files changed

+50
-33
lines changed

28 files changed

+50
-33
lines changed

account_manager/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ eth2_wallet = { path = "../crypto/eth2_wallet" }
2727
eth2_wallet_manager = { path = "../common/eth2_wallet_manager" }
2828
rand = "0.7.3"
2929
validator_dir = { path = "../common/validator_dir" }
30-
tokio = { version = "1.1.0", features = ["full"] }
30+
tokio = { version = "1.7.1", features = ["full"] }
3131
eth2_keystore = { path = "../crypto/eth2_keystore" }
3232
account_utils = { path = "../common/account_utils" }
3333
slashing_protection = { path = "../validator_client/slashing_protection" }

beacon_node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_tr
2626
slog-term = "2.6.0"
2727
slog-async = "2.5.0"
2828
ctrlc = { version = "3.1.6", features = ["termination"] }
29-
tokio = { version = "1.1.0", features = ["time"] }
29+
tokio = { version = "1.7.1", features = ["time"] }
3030
exit-future = "0.2.0"
3131
dirs = "3.0.1"
3232
logging = { path = "../common/logging" }

beacon_node/beacon_chain/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ eth2_ssz_derive = "0.1.0"
4040
state_processing = { path = "../../consensus/state_processing" }
4141
tree_hash = "0.1.1"
4242
types = { path = "../../consensus/types" }
43-
tokio = "1.1.0"
43+
tokio = "1.7.1"
4444
eth1 = { path = "../eth1" }
4545
futures = "0.3.7"
4646
genesis = { path = "../genesis" }

beacon_node/client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ error-chain = "0.12.4"
2626
serde_yaml = "0.8.13"
2727
slog = { version = "2.5.2", features = ["max_level_trace"] }
2828
slog-async = "2.5.0"
29-
tokio = "1.1.0"
29+
tokio = "1.7.1"
3030
dirs = "3.0.1"
3131
futures = "0.3.7"
3232
reqwest = { version = "0.11.0", features = ["native-tls-vendored"] }

beacon_node/eth1/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tree_hash = "0.1.1"
2626
eth2_hashing = "0.1.0"
2727
parking_lot = "0.11.0"
2828
slog = "2.5.2"
29-
tokio = { version = "1.1.0", features = ["full"] }
29+
tokio = { version = "1.7.1", features = ["full"] }
3030
state_processing = { path = "../../consensus/state_processing" }
3131
libflate = "1.0.2"
3232
lighthouse_metrics = { path = "../../common/lighthouse_metrics"}

beacon_node/eth2_libp2p/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Sigma Prime <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
discv5 = { version = "0.1.0-beta.5", features = ["libp2p"] }
8+
discv5 = { version = "0.1.0-beta.6", features = ["libp2p"] }
99
unsigned-varint = { version = "0.6.0", features = ["codec"] }
1010
types = { path = "../../consensus/types" }
1111
hashset_delay = { path = "../../common/hashset_delay" }
@@ -16,7 +16,7 @@ eth2_ssz = "0.1.2"
1616
eth2_ssz_derive = "0.1.0"
1717
slog = { version = "2.5.2", features = ["max_level_trace"] }
1818
lighthouse_version = { path = "../../common/lighthouse_version" }
19-
tokio = { version = "1.1.0", features = ["time", "macros"] }
19+
tokio = { version = "1.7.1", features = ["time", "macros"] }
2020
futures = "0.3.7"
2121
futures-io = "0.3.7"
2222
error-chain = "0.12.4"
@@ -47,7 +47,7 @@ default-features = false
4747
features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns-tokio", "tcp-tokio"]
4848

4949
[dev-dependencies]
50-
tokio = { version = "1.1.0", features = ["full"] }
50+
tokio = { version = "1.7.1", features = ["full"] }
5151
slog-term = "2.6.0"
5252
slog-async = "2.5.0"
5353
tempfile = "3.1.0"

beacon_node/eth2_libp2p/src/config.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ impl Default for Config {
151151
.build()
152152
.expect("valid gossipsub configuration");
153153

154+
// Discv5 Unsolicited Packet Rate Limiter
155+
let filter_rate_limiter = Some(
156+
discv5::RateLimiterBuilder::new()
157+
.total_n_every(10, Duration::from_secs(1)) // Allow bursts, average 10 per second
158+
.ip_n_every(9, Duration::from_secs(1)) // Allow bursts, average 9 per second
159+
.node_n_every(8, Duration::from_secs(1)) // Allow bursts, average 8 per second
160+
.build()
161+
.expect("The total rate limit has been specified"),
162+
);
163+
154164
// discv5 configuration
155165
let discv5_config = Discv5ConfigBuilder::new()
156166
.enable_packet_filter()
@@ -164,6 +174,10 @@ impl Default for Config {
164174
.disable_report_discovered_peers()
165175
.ip_limit() // limits /24 IP's in buckets.
166176
.incoming_bucket_limit(8) // half the bucket size
177+
.filter_rate_limiter(filter_rate_limiter)
178+
.filter_max_bans_per_ip(Some(5))
179+
.filter_max_nodes_per_ip(Some(10))
180+
.ban_duration(Some(Duration::from_secs(3600)))
167181
.ping_interval(Duration::from_secs(300))
168182
.build();
169183

beacon_node/eth2_libp2p/src/discovery/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,13 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
497497
// first try and convert the peer_id to a node_id.
498498
if let Ok(node_id) = peer_id_to_node_id(peer_id) {
499499
// If we could convert this peer id, remove it from the DHT and ban it from discovery.
500-
self.discv5.ban_node(&node_id);
500+
self.discv5.ban_node(&node_id, None);
501501
// Remove the node from the routing table.
502502
self.discv5.remove_node(&node_id);
503503
}
504504

505505
for ip_address in ip_addresses {
506-
self.discv5.ban_ip(ip_address);
506+
self.discv5.ban_ip(ip_address, None);
507507
}
508508
}
509509

@@ -512,11 +512,11 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
512512
// first try and convert the peer_id to a node_id.
513513
if let Ok(node_id) = peer_id_to_node_id(peer_id) {
514514
// If we could convert this peer id, remove it from the DHT and ban it from discovery.
515-
self.discv5.permit_node(&node_id);
515+
self.discv5.ban_node_remove(&node_id);
516516
}
517517

518518
for ip_address in ip_addresses {
519-
self.discv5.permit_ip(ip_address);
519+
self.discv5.ban_ip_remove(&ip_address);
520520
}
521521
}
522522

@@ -944,7 +944,9 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
944944
*self.network_globals.local_enr.write() = enr;
945945
return Poll::Ready(DiscoveryEvent::SocketUpdated(socket));
946946
}
947-
_ => {} // Ignore all other discv5 server events
947+
Discv5Event::EnrAdded { .. }
948+
| Discv5Event::TalkRequest(_)
949+
| Discv5Event::NodeInserted { .. } => {} // Ignore all other discv5 server events
948950
}
949951
}
950952
}

beacon_node/genesis/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ merkle_proof = { path = "../../consensus/merkle_proof" }
2020
eth2_ssz = "0.1.2"
2121
eth2_hashing = "0.1.0"
2222
tree_hash = "0.1.1"
23-
tokio = { version = "1.1.0", features = ["full"] }
23+
tokio = { version = "1.7.1", features = ["full"] }
2424
parking_lot = "0.11.0"
2525
slog = "2.5.2"
2626
exit-future = "0.2.0"

beacon_node/http_api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2018"
77
[dependencies]
88
warp = { git = "https://github.com/paulhauner/warp ", branch = "cors-wildcard" }
99
serde = { version = "1.0.116", features = ["derive"] }
10-
tokio = { version = "1.1.0", features = ["macros","sync"] }
10+
tokio = { version = "1.7.1", features = ["macros","sync"] }
1111
tokio-stream = { version = "0.1.3", features = ["sync"] }
1212
tokio-util = "0.6.3"
1313
parking_lot = "0.11.0"

beacon_node/http_metrics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ warp_utils = { path = "../../common/warp_utils" }
2323
malloc_utils = { path = "../../common/malloc_utils" }
2424

2525
[dev-dependencies]
26-
tokio = { version = "1.1.0", features = ["sync"] }
26+
tokio = { version = "1.7.1", features = ["sync"] }
2727
reqwest = { version = "0.11.0", features = ["json"] }
2828
environment = { path = "../../lighthouse/environment" }
2929
types = { path = "../../consensus/types" }

beacon_node/network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ eth2_ssz_types = { path = "../../consensus/ssz_types" }
3131
tree_hash = "0.1.1"
3232
futures = "0.3.7"
3333
error-chain = "0.12.4"
34-
tokio = { version = "1.1.0", features = ["full"] }
34+
tokio = { version = "1.7.1", features = ["full"] }
3535
tokio-stream = "0.1.3"
3636
parking_lot = "0.11.0"
3737
smallvec = "1.6.1"

beacon_node/timer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2018"
88
beacon_chain = { path = "../beacon_chain" }
99
types = { path = "../../consensus/types" }
1010
slot_clock = { path = "../../common/slot_clock" }
11-
tokio = { version = "1.1.0", features = ["full"] }
11+
tokio = { version = "1.7.1", features = ["full"] }
1212
slog = "2.5.2"
1313
parking_lot = "0.11.0"
1414
futures = "0.3.7"

boot_node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ eth2_network_config = { path = "../common/eth2_network_config" }
1313
eth2_ssz = "0.1.2"
1414
slog = "2.5.2"
1515
sloggers = "1.0.1"
16-
tokio = "1.1.0"
16+
tokio = "1.7.1"
1717
log = "0.4.11"
1818
slog-term = "2.6.0"
1919
logging = { path = "../common/logging" }

boot_node/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pub async fn run<T: EthSpec>(config: BootNodeConfig<T>, log: slog::Logger) {
8989
// Ignore these events here
9090
}
9191
Discv5Event::EnrAdded { .. } => {} // Ignore
92+
Discv5Event::TalkRequest(_) => {} // Ignore
9293
Discv5Event::NodeInserted { .. } => {} // Ignore
9394
Discv5Event::SocketUpdated(socket_addr) => {
9495
info!(log, "External socket address updated"; "socket_addr" => format!("{:?}", socket_addr));

common/hashset_delay/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ futures = "0.3.7"
99
tokio-util = { version = "0.6.2", features = ["time"] }
1010

1111
[dev-dependencies]
12-
tokio = { version = "1.1.0", features = ["time", "rt-multi-thread", "macros"] }
12+
tokio = { version = "1.7.1", features = ["time", "rt-multi-thread", "macros"] }

common/monitoring_api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010
reqwest = { version = "0.11.0", features = ["json","stream"] }
1111
futures = "0.3.7"
1212
task_executor = { path = "../task_executor" }
13-
tokio = "1.1.0"
13+
tokio = "1.7.1"
1414
eth2 = {path = "../eth2"}
1515
serde_json = "1.0.58"
1616
serde = "1.0.116"

common/remote_signer_consumer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ remote_signer_test = { path = "../../testing/remote_signer_test" }
1111
[dependencies]
1212
reqwest = { version = "0.11.0", features = ["json"] }
1313
serde = { version = "1.0.116", features = ["derive"] }
14-
tokio = { version = "1.1.0", features = ["time"] }
14+
tokio = { version = "1.7.1", features = ["time"] }
1515
types = { path = "../../consensus/types" }
1616
sensitive_url = { path = "../sensitive_url" }

common/task_executor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Sigma Prime <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
tokio = { version = "1.1.0", features = ["rt"] }
8+
tokio = { version = "1.7.1", features = ["rt"] }
99
slog = "2.5.2"
1010
futures = "0.3.7"
1111
exit-future = "0.2.0"

common/warp_utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ beacon_chain = { path = "../../beacon_node/beacon_chain" }
1414
state_processing = { path = "../../consensus/state_processing" }
1515
safe_arith = { path = "../../consensus/safe_arith" }
1616
serde = { version = "1.0.116", features = ["derive"] }
17-
tokio = { version = "1.1.0", features = ["sync"] }
17+
tokio = { version = "1.7.1", features = ["sync"] }
1818
headers = "0.3.2"
1919
lighthouse_metrics = { path = "../lighthouse_metrics" }
2020
lazy_static = "1.4.0"

lcli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dirs = "3.0.1"
2727
genesis = { path = "../beacon_node/genesis" }
2828
deposit_contract = { path = "../common/deposit_contract" }
2929
tree_hash = "0.1.1"
30-
tokio = { version = "1.1.0", features = ["full"] }
30+
tokio = { version = "1.7.1", features = ["full"] }
3131
clap_utils = { path = "../common/clap_utils" }
3232
eth2_libp2p = { path = "../beacon_node/eth2_libp2p" }
3333
validator_dir = { path = "../common/validator_dir", features = ["insecure_keys"] }

lighthouse/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spec-minimal = []
1919

2020
[dependencies]
2121
beacon_node = { "path" = "../beacon_node" }
22-
tokio = "1.1.0"
22+
tokio = "1.7.1"
2323
slog = { version = "2.5.2", features = ["max_level_trace"] }
2424
sloggers = "1.0.1"
2525
types = { "path" = "../consensus/types" }

lighthouse/environment/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Paul Hauner <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
tokio = { version = "1.1.0", features = ["macros", "rt", "rt-multi-thread" ] }
8+
tokio = { version = "1.7.1", features = ["macros", "rt", "rt-multi-thread" ] }
99
slog = { version = "2.5.2", features = ["max_level_trace"] }
1010
sloggers = "1.0.1"
1111
types = { "path" = "../../consensus/types" }

slasher/service/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ slog = "2.5.2"
1414
slot_clock = { path = "../../common/slot_clock" }
1515
state_processing = { path = "../../consensus/state_processing" }
1616
task_executor = { path = "../../common/task_executor" }
17-
tokio = { version = "1.1.0", features = ["full"] }
17+
tokio = { version = "1.7.1", features = ["full"] }
1818
tokio-stream = "0.1.3"
1919
types = { path = "../../consensus/types" }

testing/eth1_test_rig/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Paul Hauner <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
tokio = { version = "1.1.0", features = ["time"] }
8+
tokio = { version = "1.7.1", features = ["time"] }
99
tokio-compat-02 = "0.2.0"
1010
web3 = { version = "0.16.0", default-features = false, features = ["http-tls", "signing", "ws-tls-tokio"] }
1111
futures = "0.3.7"

testing/remote_signer_test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ reqwest = { version = "0.11.0", features = ["blocking", "json"] }
1515
serde = { version = "1.0.116", features = ["derive"] }
1616
serde_json = "1.0.58"
1717
tempfile = "3.1.0"
18-
tokio = { version = "1.1.0", features = ["time"] }
18+
tokio = { version = "1.7.1", features = ["time"] }
1919
types = { path = "../../consensus/types" }
2020
sensitive_url = { path = "../../common/sensitive_url" }
2121

testing/simulator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ types = { path = "../../consensus/types" }
1313
validator_client = { path = "../../validator_client" }
1414
parking_lot = "0.11.0"
1515
futures = "0.3.7"
16-
tokio = "1.1.0"
16+
tokio = "1.7.1"
1717
eth1_test_rig = { path = "../eth1_test_rig" }
1818
env_logger = "0.8.2"
1919
clap = "2.33.3"

validator_client/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "validator_client"
99
path = "src/lib.rs"
1010

1111
[dev-dependencies]
12-
tokio = { version = "1.1.0", features = ["time", "rt-multi-thread", "macros"] }
12+
tokio = { version = "1.7.1", features = ["time", "rt-multi-thread", "macros"] }
1313
deposit_contract = { path = "../common/deposit_contract" }
1414

1515
[dependencies]
@@ -30,7 +30,7 @@ serde_yaml = "0.8.13"
3030
slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_trace"] }
3131
slog-async = "2.5.0"
3232
slog-term = "2.6.0"
33-
tokio = { version = "1.1.0", features = ["time"] }
33+
tokio = { version = "1.7.1", features = ["time"] }
3434
futures = "0.3.7"
3535
dirs = "3.0.1"
3636
directory = { path = "../common/directory" }

0 commit comments

Comments
 (0)