Add discv5 config and enlarge the default rate limiter (#86)

This commit is contained in:
Bo QIU 2024-06-14 18:04:35 +08:00 committed by GitHub
parent dea518a0aa
commit d8d8c28c64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 3 deletions

View File

@ -145,9 +145,9 @@ impl Default for Config {
// 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
.total_n_every(300, Duration::from_secs(1)) // Allow bursts, average 300 per second
.ip_n_every(300, Duration::from_secs(1)) // Allow bursts, average 300 per second
.node_n_every(300, Duration::from_secs(1)) // Allow bursts, average 300 per second
.build()
.expect("The total rate limit has been specified"),
);

View File

@ -53,6 +53,8 @@ impl ZgsConfig {
network_config.discv5_config.request_retries = self.discv5_request_retries;
network_config.discv5_config.query_parallelism = self.discv5_query_parallelism;
network_config.discv5_config.report_discovered_peers = self.discv5_report_discovered_peers;
network_config.discv5_config.enable_packet_filter = !self.discv5_disable_packet_filter;
network_config.discv5_config.ip_limit = !self.discv5_disable_ip_limit;
network_config.target_peers = self.network_target_peers;
network_config.private = self.network_private;

View File

@ -26,6 +26,8 @@ build_config! {
(discv5_request_retries, (u8), 1)
(discv5_query_parallelism, (usize), 5)
(discv5_report_discovered_peers, (bool), false)
(discv5_disable_packet_filter, (bool), false)
(discv5_disable_ip_limit, (bool), false)
// log sync
(blockchain_rpc_endpoint, (String), "http://127.0.0.1:8545".to_string())

View File

@ -65,6 +65,13 @@ network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmPxGNWu9eVAQPJww79
# Reports all discovered ENR's when traversing the DHT to the event stream.
# discv5_report_discovered_peers = false
# Disables the incoming packet filter.
# discv5_disable_packet_filter = false
# Disable to limit the number of IP addresses from the same
# /24 subnet in the kbuckets table. This is to mitigate eclipse attacks.
# discv5_disable_ip_limit = false
#######################################################################
### Log Sync Config Options ###
#######################################################################