From ed203356c6719e9cc9b38b4e0794f8a5115669d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=A4=E7=8B=90=E4=B8=80=E5=86=B2?= <43949039+anonymousGiga@users.noreply.github.com> Date: Thu, 4 Jul 2024 23:38:09 +0800 Subject: [PATCH] Fix: fix the issue of not being able to specify bootnode through command parameters (#9237) --- crates/node/core/src/args/network.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/node/core/src/args/network.rs b/crates/node/core/src/args/network.rs index 03bd6a307..65f6f5834 100644 --- a/crates/node/core/src/args/network.rs +++ b/crates/node/core/src/args/network.rs @@ -123,6 +123,12 @@ impl NetworkArgs { /// /// The `default_peers_file` will be used as the default location to store the persistent peers /// file if `no_persist_peers` is false, and there is no provided `peers_file`. + /// + /// Configured Bootnodes are prioritized, if unset, the chain spec bootnodes are used + /// Priority order for bootnodes configuration: + /// 1. --bootnodes flag + /// 2. Network preset flags (e.g. --holesky) + /// 3. default to mainnet nodes pub fn network_config( &self, config: &Config, @@ -130,7 +136,16 @@ impl NetworkArgs { secret_key: SecretKey, default_peers_file: PathBuf, ) -> NetworkConfigBuilder { - let chain_bootnodes = chain_spec.bootnodes().unwrap_or_else(mainnet_nodes); + let chain_bootnodes = self + .bootnodes + .clone() + .map(|bootnodes| { + bootnodes + .into_iter() + .filter_map(|trusted_peer| trusted_peer.resolve_blocking().ok()) + .collect() + }) + .unwrap_or_else(|| chain_spec.bootnodes().unwrap_or_else(mainnet_nodes)); let peers_file = self.peers_file.clone().unwrap_or(default_peers_file); // Configure peer connections