From 47fcbb17d3fab1e2b93af49ea66ca7954a032c4b Mon Sep 17 00:00:00 2001 From: bengtlofgren Date: Tue, 4 Jul 2023 18:34:27 +0200 Subject: [PATCH 1/3] hopefully fixes init_network --- apps/src/lib/client/utils.rs | 40 +++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 95a2a6e11f..411a5f515b 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -788,31 +788,39 @@ pub fn init_network( let net_address = validator_config.net_address.take().unwrap(); let ip = SocketAddr::from_str(&net_address).unwrap().ip(); let first_port = SocketAddr::from_str(&net_address).unwrap().port(); - if !localhost { + if localhost { config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str( - &format!("0.0.0.0:{}", first_port), + &format!("127.0.0.1:{}", first_port), ) .unwrap(); } - config.ledger.cometbft.p2p.laddr = - TendermintAddress::from_str(&format!("{}:{}", ip, first_port)) - .unwrap(); - if !localhost { + else{ + config.ledger.cometbft.p2p.laddr = + TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port)) + .unwrap(); + } + if localhost { + config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( + &format!("127.0.0.1:{}", first_port + 1), + ) + .unwrap(); + } + else{ config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( &format!("0.0.0.0:{}", first_port + 1), ) .unwrap(); } - config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( - &format!("{}:{}", ip, first_port + 1), - ) - .unwrap(); - - config.ledger.cometbft.proxy_app = TendermintAddress::from_str( - &format!("{}:{}", ip, first_port + 2), - ) - .unwrap(); - + if localhost { + config.ledger.cometbft.proxy_app = + TendermintAddress::from_str(&format!("127.0.0.1:{}", first_port + 2)) + .unwrap(); + } + else{ + config.ledger.cometbft.proxy_app = + TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port + 2)) + .unwrap(); + } config.write(&validator_dir, &chain_id, true).unwrap(); }, ); From 87bec10cb03cf81ed38b33e6fc6d7fb9bf263a9d Mon Sep 17 00:00:00 2001 From: bengtlofgren Date: Wed, 5 Jul 2023 10:58:43 +0200 Subject: [PATCH 2/3] fmt and clippy --- apps/src/lib/client/utils.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 411a5f515b..c0dc787152 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -793,32 +793,32 @@ pub fn init_network( &format!("127.0.0.1:{}", first_port), ) .unwrap(); - } - else{ - config.ledger.cometbft.p2p.laddr = - TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port)) - .unwrap(); + } else { + config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str( + &format!("0.0.0.0:{}", first_port), + ) + .unwrap(); } if localhost { config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( &format!("127.0.0.1:{}", first_port + 1), ) .unwrap(); - } - else{ + } else { config.ledger.cometbft.rpc.laddr = TendermintAddress::from_str( &format!("0.0.0.0:{}", first_port + 1), ) .unwrap(); } if localhost { - config.ledger.cometbft.proxy_app = - TendermintAddress::from_str(&format!("127.0.0.1:{}", first_port + 2)) + config.ledger.cometbft.proxy_app = TendermintAddress::from_str( + &format!("127.0.0.1:{}", first_port + 2), + ) .unwrap(); - } - else{ - config.ledger.cometbft.proxy_app = - TendermintAddress::from_str(&format!("0.0.0.0:{}", first_port + 2)) + } else { + config.ledger.cometbft.proxy_app = TendermintAddress::from_str( + &format!("0.0.0.0:{}", first_port + 2), + ) .unwrap(); } config.write(&validator_dir, &chain_id, true).unwrap(); From f55eb6603fd94af0a126205dbff66751f613d7b7 Mon Sep 17 00:00:00 2001 From: bengtlofgren Date: Wed, 5 Jul 2023 12:03:54 +0200 Subject: [PATCH 3/3] clippy --- apps/src/lib/client/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index c0dc787152..4eaaf97fdf 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -786,7 +786,7 @@ pub fn init_network( config.ledger.cometbft.p2p.addr_book_strict = !localhost; // Clear the net address from the config and use it to set ports let net_address = validator_config.net_address.take().unwrap(); - let ip = SocketAddr::from_str(&net_address).unwrap().ip(); + let _ip = SocketAddr::from_str(&net_address).unwrap().ip(); let first_port = SocketAddr::from_str(&net_address).unwrap().port(); if localhost { config.ledger.cometbft.p2p.laddr = TendermintAddress::from_str(