Supports discv5 related configurations (#84)

* Supports discv5 related configurations

* fix fmt
This commit is contained in:
Bo QIU 2024-06-13 16:14:20 +08:00 committed by GitHub
parent 489d973347
commit dea518a0aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 3 deletions

View File

@ -46,8 +46,14 @@ impl ZgsConfig {
.map_err(|e| format!("Unable to parse network_libp2p_nodes: {:?}", e))?; .map_err(|e| format!("Unable to parse network_libp2p_nodes: {:?}", e))?;
network_config.discv5_config.table_filter = |_| true; network_config.discv5_config.table_filter = |_| true;
network_config.discv5_config.request_timeout =
Duration::from_secs(self.discv5_request_timeout_secs);
network_config.discv5_config.query_peer_timeout =
Duration::from_secs(self.discv5_query_peer_timeout_secs);
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;
// TODO
network_config.target_peers = self.network_target_peers; network_config.target_peers = self.network_target_peers;
network_config.private = self.network_private; network_config.private = self.network_private;

View File

@ -20,6 +20,13 @@ build_config! {
(network_private, (bool), false) (network_private, (bool), false)
(network_disable_discovery, (bool), false) (network_disable_discovery, (bool), false)
// discv5
(discv5_request_timeout_secs, (u64), 5)
(discv5_query_peer_timeout_secs, (u64), 2)
(discv5_request_retries, (u8), 1)
(discv5_query_parallelism, (usize), 5)
(discv5_report_discovered_peers, (bool), false)
// log sync // log sync
(blockchain_rpc_endpoint, (String), "http://127.0.0.1:8545".to_string()) (blockchain_rpc_endpoint, (String), "http://127.0.0.1:8545".to_string())
(log_contract_address, (String), "".to_string()) (log_contract_address, (String), "".to_string())

View File

@ -12,7 +12,8 @@
# network_listen_address = "0.0.0.0" # network_listen_address = "0.0.0.0"
# The address to broadcast to peers about which address we are listening on. Empty indicates # The address to broadcast to peers about which address we are listening on. Empty indicates
# that no discovery address has been set. # that no discovery address has been set. Generally, configure public IP address along with
# `network_enr_tcp_port` and `network_enr_udp_port` with default values to enable UDP discovery.
# network_enr_address = "" # network_enr_address = ""
# The tcp port to broadcast to peers in order to reach back for libp2p services. # The tcp port to broadcast to peers in order to reach back for libp2p services.
@ -30,7 +31,8 @@
# Target number of connected peers. # Target number of connected peers.
# network_target_peers = 50 # network_target_peers = 50
# List of nodes to initially connect to # List of nodes to bootstrap UDP discovery. Note, `network_enr_address`, `network_enr_tcp_port`
# and `network_enr_udp_port` should be configured as well to enable UDP discovery.
network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmPxGNWu9eVAQPJww79J32pTJLKGcpjRMb4Qb8xxKkyuG1","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAm93Hd5azfhkGBbkx1zero3nYHvfjQYM2NtiW4R3r5bE2g"] network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmPxGNWu9eVAQPJww79J32pTJLKGcpjRMb4Qb8xxKkyuG1","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAm93Hd5azfhkGBbkx1zero3nYHvfjQYM2NtiW4R3r5bE2g"]
# List of libp2p nodes to initially connect to. # List of libp2p nodes to initially connect to.
@ -43,6 +45,26 @@ network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmPxGNWu9eVAQPJww79
# Disables the discovery protocol from starting. # Disables the discovery protocol from starting.
# network_disable_discovery = false # network_disable_discovery = false
#######################################################################
### UDP Discovery Config Options ###
#######################################################################
# The request timeout for each UDP request.
# discv5_request_timeout_secs = 5
# The timeout after which a `QueryPeer` in an ongoing query is marked unresponsive.
# Unresponsive peers don't count towards the parallelism limits for a query.
# Hence, we may potentially end up making more requests to good peers.
# discv5_query_peer_timeout_secs = 2
# The number of retries for each UDP request.
# discv5_request_retries = 1
# The number of peers to request in parallel in a single query.
# discv5_query_parallelism = 5
# Reports all discovered ENR's when traversing the DHT to the event stream.
# discv5_report_discovered_peers = false
####################################################################### #######################################################################
### Log Sync Config Options ### ### Log Sync Config Options ###
####################################################################### #######################################################################