From 4ee782e4bc38ce02b7357a5b5b6d846562b86bb4 Mon Sep 17 00:00:00 2001 From: Bo QIU <35757521+boqiu@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:47:33 +0800 Subject: [PATCH] enhance default config value (#97) --- node/src/config/convert.rs | 12 ++++++------ node/src/config/mod.rs | 8 ++++---- run/config.toml | 13 ++++++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/node/src/config/convert.rs b/node/src/config/convert.rs index 51dbbc3..724f51a 100644 --- a/node/src/config/convert.rs +++ b/node/src/config/convert.rs @@ -24,12 +24,12 @@ impl ZgsConfig { network_config.libp2p_port = self.network_libp2p_port; network_config.disable_discovery = self.network_disable_discovery; network_config.discovery_port = self.network_discovery_port; - network_config.enr_tcp_port = self.network_enr_tcp_port; - network_config.enr_udp_port = self.network_enr_udp_port; - network_config.enr_address = self - .network_enr_address - .as_ref() - .map(|x| x.parse::().unwrap()); + + if let Some(addr) = &self.network_enr_address { + network_config.enr_tcp_port = Some(self.network_enr_tcp_port); + network_config.enr_udp_port = Some(self.network_enr_udp_port); + network_config.enr_address = Some(addr.parse().unwrap()); + } network_config.boot_nodes_multiaddr = self .network_boot_nodes diff --git a/node/src/config/mod.rs b/node/src/config/mod.rs index b59cfe7..7364a17 100644 --- a/node/src/config/mod.rs +++ b/node/src/config/mod.rs @@ -10,8 +10,8 @@ build_config! { (network_dir, (String), "network".to_string()) (network_listen_address, (String), "0.0.0.0".to_string()) (network_enr_address, (Option), None) - (network_enr_tcp_port, (Option), None) - (network_enr_udp_port, (Option), None) + (network_enr_tcp_port, (u16), 1234) + (network_enr_udp_port, (u16), 1234) (network_libp2p_port, (u16), 1234) (network_discovery_port, (u16), 1234) (network_target_peers, (usize), 50) @@ -34,7 +34,7 @@ build_config! { (log_contract_address, (String), "".to_string()) (log_sync_start_block_number, (u64), 0) (confirmation_block_count, (u64), 12) - (log_page_size, (u64), 1000) + (log_page_size, (u64), 999) (max_cache_data_size, (usize), 100 * 1024 * 1024) // 100 MB (cache_tx_seq_ttl, (usize), 500) @@ -49,7 +49,7 @@ build_config! { // rpc (rpc_enabled, (bool), true) - (rpc_listen_address, (String), "127.0.0.1:5678".to_string()) + (rpc_listen_address, (String), "0.0.0.0:5678".to_string()) (rpc_listen_address_admin, (String), "127.0.0.1:5679".to_string()) (max_request_body_size, (u32), 100*1024*1024) // 100MB (rpc_chunks_per_segment, (usize), 1024) diff --git a/run/config.toml b/run/config.toml index 7ff8cda..5510861 100644 --- a/run/config.toml +++ b/run/config.toml @@ -11,9 +11,8 @@ # IP address to listen on. # network_listen_address = "0.0.0.0" -# The address to broadcast to peers about which address we are listening on. Empty indicates -# 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. +# The address to broadcast to peers about which address we are listening on. Empty indicates that +# no discovery address has been set. Generally, configure public IP address to enable UDP discovery. # network_enr_address = "" # The tcp port to broadcast to peers in order to reach back for libp2p services. @@ -31,8 +30,8 @@ # Target number of connected peers. # network_target_peers = 50 -# 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. +# List of nodes to bootstrap UDP discovery. Note, `network_enr_address` 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"] # List of libp2p nodes to initially connect to. @@ -90,7 +89,7 @@ log_sync_start_block_number = 512567 # confirmation_block_count = 12 # Maximum number of event logs to poll at a time. -log_page_size = 999 +# log_page_size = 999 # Maximum data size to cache in memory (by default, 100MB). # max_cache_data_size = 104857600 @@ -128,7 +127,7 @@ log_page_size = 999 # rpc_enabled = true # HTTP server address to bind for public RPC. -rpc_listen_address = "0.0.0.0:5678" +# rpc_listen_address = "0.0.0.0:5678" # HTTP server address to bind for admin and debug RPC. # rpc_listen_address_admin = "127.0.0.1:5679"