Skip to content

Commit 814db6b

Browse files
committed
squashing localnet-v2 commits (again)
fixes to localnet purge provide path in the error message output args log failed exec print based on tty check-prerequisites cmd checked iptables update basic kernel features check enable ipv6 rules add forwarding rules squashing localnet-v2 commits additional changes propagate custom-dns flag to all run containers remove is_mock from EcashManager another localnet squash unused import chore: remove redundant testnet manager missing impl additional linux fixes command to rebuild container image wait for at least 2 blocks additional node startup fixes added --custom-dns flag to nym node setup add gateway probe + wait for DKG magic file fixed localnet down on linux container ls re-enable state resync additional feature locking macos adjustments working nyxd startup on linux wip linux box wip separating network inspect betweewn macos and linux initial linux feature locking moved all container commands into a single location finally working initial node performance squashing orchestrator commits cleanup fixed condition for naive rearrangement added cache of cosmwasm contracts for speed up on subsequent runs 'down' command refreshing described cache after nodes are bonded nym nodes setup + wip on nym api refresh nodes setup WIP first pass cleanup placeholder for nym-node setup bypassing the dkg further progress on nym-api setup wip: api setup up/down/purge placeholders persisting contract setup data fix contract upload by forcing amd64 container platform wip: contracts setup4 wip: contracts setup3 wip: contracts setup2 wip: contracts setup include network setup init and spawn nyxd build nyxd image in dedicated orchestrator build nyxd image
1 parent d3c4eb2 commit 814db6b

File tree

172 files changed

+9829
-5562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+9829
-5562
lines changed

Cargo.lock

Lines changed: 451 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ members = [
153153
"tools/internal/contract-state-importer/importer-cli",
154154
"tools/internal/contract-state-importer/importer-contract",
155155
"tools/internal/mixnet-connectivity-check",
156-
# "tools/internal/sdk-version-bump",
156+
# "tools/internal/sdk-version-bump",
157157
"tools/internal/ssl-inject",
158-
"tools/internal/testnet-manager",
159-
"tools/internal/testnet-manager/dkg-bypass-contract",
158+
"tools/internal/localnet-orchestrator",
159+
"tools/internal/localnet-orchestrator/dkg-bypass-contract",
160160
"tools/internal/validator-status-check",
161161
"tools/nym-cli",
162162
"tools/nym-id-cli",
@@ -186,6 +186,7 @@ default-members = [
186186
"service-providers/ip-packet-router",
187187
"service-providers/network-requester",
188188
"tools/nymvisor",
189+
"tools/internal/localnet-orchestrator"
189190
]
190191

191192
exclude = ["contracts", "nym-wallet", "cpu-cycles"]
@@ -225,6 +226,7 @@ bloomfilter = "3.0.1"
225226
bs58 = "0.5.1"
226227
bytecodec = "0.4.15"
227228
bytes = "1.10.1"
229+
cargo-edit = "0.13.8"
228230
cargo_metadata = "0.19.2"
229231
celes = "2.6.0"
230232
cfg-if = "1.0.0"

common/client-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "nym-client-core"
33
version = "1.1.15"
44
authors = ["Dave Hrycyszyn <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66
rust-version = "1.85"
77
license.workspace = true
88

common/client-core/config-types/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const DEFAULT_MIN_MIXNODE_PERFORMANCE: u8 = 50;
3232
const DEFAULT_MIN_GATEWAY_PERFORMANCE: u8 = 50;
3333

3434
const DEFAULT_MAX_STARTUP_GATEWAY_WAITING_PERIOD: Duration = Duration::from_secs(70 * 60); // 70min -> full epoch (1h) + a bit of overhead
35+
const DEFAULT_MAX_STARTUP_TOPOLOGY_WAITING_PERIOD: Duration = Duration::from_secs(70 * 60); // 70min -> full epoch (1h) + a bit of overhead
3536

3637
// Set this to a high value for now, so that we don't risk sporadic timeouts that might cause
3738
// bought bandwidth tokens to not have time to be spent; Once we remove the gateway from the
@@ -555,6 +556,11 @@ pub struct Topology {
555556
#[serde(with = "humantime_serde")]
556557
pub max_startup_gateway_waiting_period: Duration,
557558

559+
/// Defines how long the client is going to wait on startup for minimal topology to become online,
560+
/// before abandoning the procedure.
561+
#[serde(with = "humantime_serde")]
562+
pub max_startup_network_waiting_period: Duration,
563+
558564
/// Specifies a minimum performance of a mixnode that is used on route construction.
559565
/// This setting is only applicable when `NymApi` topology is used.
560566
pub minimum_mixnode_performance: u8,
@@ -583,6 +589,7 @@ impl Default for Topology {
583589
topology_resolution_timeout: DEFAULT_TOPOLOGY_RESOLUTION_TIMEOUT,
584590
disable_refreshing: false,
585591
max_startup_gateway_waiting_period: DEFAULT_MAX_STARTUP_GATEWAY_WAITING_PERIOD,
592+
max_startup_network_waiting_period: DEFAULT_MAX_STARTUP_TOPOLOGY_WAITING_PERIOD,
586593
minimum_mixnode_performance: DEFAULT_MIN_MIXNODE_PERFORMANCE,
587594
minimum_gateway_performance: DEFAULT_MIN_GATEWAY_PERFORMANCE,
588595
use_extended_topology: false,

common/client-core/config-types/src/old/v6.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ impl From<ConfigV6> for Config {
159159
use_extended_topology: value.debug.topology.use_extended_topology,
160160
ignore_egress_epoch_role: value.debug.topology.ignore_egress_epoch_role,
161161
ignore_ingress_epoch_role: value.debug.topology.ignore_ingress_epoch_role,
162+
..Default::default()
162163
},
163164
reply_surbs: ReplySurbs {
164165
minimum_reply_surb_storage_threshold: value

common/client-core/src/cli_helpers/client_add_gateway.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ where
160160
)
161161
.await?;
162162
} else {
163-
info!("registered with new gateway {} (under address {address}), but this will not be our default address", gateway_details.gateway_id);
163+
info!(
164+
"registered with new gateway {} (under address {address}), but this will not be our default address",
165+
gateway_details.gateway_id
166+
);
164167
}
165168

166169
Ok(GatewayInfo {

common/client-core/src/client/base_client/mod.rs

Lines changed: 72 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
use super::mix_traffic::ClientRequestSender;
55
use super::received_buffer::ReceivedBufferMessage;
66
use super::statistics_control::StatisticsControl;
7-
use crate::client::base_client::storage::helpers::store_client_keys;
87
use crate::client::base_client::storage::MixnetClientStorage;
8+
use crate::client::base_client::storage::helpers::store_client_keys;
99
use crate::client::cover_traffic_stream::LoopCoverTrafficStream;
1010
use crate::client::event_control::EventControl;
1111
use crate::client::inbound_messages::{InputMessage, InputMessageReceiver, InputMessageSender};
12-
use crate::client::key_manager::persistence::KeyStore;
1312
use crate::client::key_manager::ClientKeys;
13+
use crate::client::key_manager::persistence::KeyStore;
1414
use crate::client::mix_traffic::transceiver::{GatewayReceiver, GatewayTransceiver, RemoteGateway};
1515
use crate::client::mix_traffic::{BatchMixMessageSender, MixTrafficController, MixTrafficEvent};
1616
use crate::client::real_messages_control;
@@ -52,12 +52,12 @@ use nym_sphinx::addressing::nodes::NodeIdentity;
5252
use nym_sphinx::receiver::{ReconstructedMessage, SphinxMessageReceiver};
5353
use nym_statistics_common::clients::ClientStatsSender;
5454
use nym_statistics_common::generate_client_stats_id;
55-
use nym_task::connections::{ConnectionCommandReceiver, ConnectionCommandSender, LaneQueueLengths};
5655
use nym_task::ShutdownTracker;
57-
use nym_topology::provider_trait::TopologyProvider;
56+
use nym_task::connections::{ConnectionCommandReceiver, ConnectionCommandSender, LaneQueueLengths};
5857
use nym_topology::HardcodedTopologyProvider;
58+
use nym_topology::provider_trait::TopologyProvider;
5959
use nym_validator_client::nym_api::NymApiClientExt;
60-
use nym_validator_client::{nyxd::contract_traits::DkgQueryClient, UserAgent};
60+
use nym_validator_client::{UserAgent, nyxd::contract_traits::DkgQueryClient};
6161
use rand::prelude::SliceRandom;
6262
use rand::rngs::OsRng;
6363
use rand::thread_rng;
@@ -220,6 +220,7 @@ pub struct BaseClientBuilder<C, S: MixnetClientStorage> {
220220
nym_api_urls: Option<Vec<nym_network_defaults::ApiUrl>>,
221221

222222
wait_for_gateway: bool,
223+
wait_for_initial_topology: bool,
223224
custom_topology_provider: Option<Box<dyn TopologyProvider + Send + Sync>>,
224225
custom_gateway_transceiver: Option<Box<dyn GatewayTransceiver + Send>>,
225226
shutdown: Option<ShutdownTracker>,
@@ -250,6 +251,7 @@ where
250251
dkg_query_client,
251252
nym_api_urls: None,
252253
wait_for_gateway: false,
254+
wait_for_initial_topology: false,
253255
custom_topology_provider: None,
254256
custom_gateway_transceiver: None,
255257
shutdown: None,
@@ -305,6 +307,12 @@ where
305307
self
306308
}
307309

310+
#[must_use]
311+
pub fn with_wait_for_initial_topology(mut self, wait_for_initial_topology: bool) -> Self {
312+
self.wait_for_initial_topology = wait_for_initial_topology;
313+
self
314+
}
315+
308316
#[must_use]
309317
pub fn with_topology_provider(
310318
mut self,
@@ -674,6 +682,7 @@ where
674682
topology_accessor: TopologyAccessor,
675683
local_gateway: NodeIdentity,
676684
wait_for_gateway: bool,
685+
wait_for_initial_topology: bool,
677686
shutdown_tracker: &ShutdownTracker,
678687
) -> Result<(), ClientCoreError> {
679688
let topology_refresher_config =
@@ -694,6 +703,46 @@ where
694703
tracing::info!("Obtaining initial network topology");
695704
topology_refresher.try_refresh().await;
696705

706+
// 1. wait for the minimum topology (if applicable)
707+
if topology_refresher
708+
.ensure_topology_is_routable()
709+
.await
710+
.is_err()
711+
&& wait_for_initial_topology
712+
{
713+
if let Err(err) = topology_refresher
714+
.wait_for_initial_network(topology_config.max_startup_network_waiting_period)
715+
.await
716+
{
717+
tracing::error!(
718+
"the network did not come become online within the specified timeout: {err}"
719+
);
720+
return Err(err.into());
721+
}
722+
}
723+
724+
// 2. wait for our gateway (if applicable)
725+
if topology_refresher
726+
.ensure_contains_routable_egress(local_gateway)
727+
.await
728+
.is_err()
729+
&& wait_for_gateway
730+
{
731+
if let Err(err) = topology_refresher
732+
.wait_for_gateway(
733+
local_gateway,
734+
topology_config.max_startup_gateway_waiting_period,
735+
)
736+
.await
737+
{
738+
tracing::error!(
739+
"the gateway did not come back online within the specified timeout: {err}"
740+
);
741+
return Err(err.into());
742+
}
743+
}
744+
745+
// 3. check if the topology is routable (in case we were NOT waiting for it)
697746
if let Err(err) = topology_refresher.ensure_topology_is_routable().await {
698747
tracing::error!(
699748
"The current network topology seem to be insufficient to route any packets through \
@@ -702,30 +751,15 @@ where
702751
return Err(ClientCoreError::InsufficientNetworkTopology(err));
703752
}
704753

705-
let gateway_wait_timeout = if wait_for_gateway {
706-
Some(topology_config.max_startup_gateway_waiting_period)
707-
} else {
708-
None
709-
};
710-
754+
// 4. check if the gateway exists (in case we were NOT waiting for it)
711755
if let Err(err) = topology_refresher
712756
.ensure_contains_routable_egress(local_gateway)
713757
.await
714758
{
715-
if let Some(waiting_timeout) = gateway_wait_timeout {
716-
if let Err(err) = topology_refresher
717-
.wait_for_gateway(local_gateway, waiting_timeout)
718-
.await
719-
{
720-
tracing::error!(
721-
"the gateway did not come back online within the specified timeout: {err}"
722-
);
723-
return Err(err.into());
724-
}
725-
} else {
726-
tracing::error!("the gateway we're supposedly connected to does not exist. We'll not be able to send any packets to ourselves: {err}");
727-
return Err(err.into());
728-
}
759+
tracing::error!(
760+
"the gateway we're supposedly connected to does not exist. We'll not be able to send any packets to ourselves: {err}"
761+
);
762+
return Err(err.into());
729763
}
730764

731765
if !topology_config.disable_refreshing {
@@ -1024,6 +1058,7 @@ where
10241058
shared_topology_accessor.clone(),
10251059
self_address.gateway(),
10261060
self.wait_for_gateway,
1061+
self.wait_for_initial_topology,
10271062
&shutdown_tracker.clone(),
10281063
)
10291064
.await?;
@@ -1195,9 +1230,11 @@ mod tests {
11951230
]);
11961231

11971232
assert_eq!(network_details.nym_api_urls.as_ref().unwrap().len(), 2);
1198-
assert!(network_details.nym_api_urls.as_ref().unwrap()[1]
1199-
.front_hosts
1200-
.is_some());
1233+
assert!(
1234+
network_details.nym_api_urls.as_ref().unwrap()[1]
1235+
.front_hosts
1236+
.is_some()
1237+
);
12011238
}
12021239

12031240
#[test]
@@ -1210,11 +1247,13 @@ mod tests {
12101247

12111248
assert_eq!(api_url.url, "https://nym-frontdoor.vercel.app/api/");
12121249
assert_eq!(api_url.front_hosts.as_ref().unwrap().len(), 2);
1213-
assert!(api_url
1214-
.front_hosts
1215-
.as_ref()
1216-
.unwrap()
1217-
.contains(&"vercel.app".to_string()));
1250+
assert!(
1251+
api_url
1252+
.front_hosts
1253+
.as_ref()
1254+
.unwrap()
1255+
.contains(&"vercel.app".to_string())
1256+
);
12181257
}
12191258

12201259
#[test]

common/client-core/src/client/base_client/non_wasm_helpers.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use crate::{
5-
client::replies::reply_storage::{fs_backend, CombinedReplyStorage, ReplyStorageBackend},
5+
client::replies::reply_storage::{CombinedReplyStorage, ReplyStorageBackend, fs_backend},
66
config,
77
config::Config,
88
error::ClientCoreError,
99
};
1010
use nym_bandwidth_controller::BandwidthController;
1111
use nym_client_core_gateways_storage::OnDiskGatewaysDetails;
1212
use nym_credential_storage::storage::Storage as CredentialStorage;
13-
use nym_validator_client::{nyxd, QueryHttpRpcNyxdClient};
13+
use nym_validator_client::{QueryHttpRpcNyxdClient, nyxd};
1414
use std::{io, path::Path};
1515
use time::OffsetDateTime;
1616
use tracing::{error, info, trace};
@@ -24,7 +24,9 @@ async fn setup_fresh_backend<P: AsRef<Path>>(
2424
let mut storage_backend = match fs_backend::Backend::init(db_path).await {
2525
Ok(backend) => backend,
2626
Err(err) => {
27-
error!("setup_fresh_backend: Failed to setup persistent storage backend for our reply needs: {err}");
27+
error!(
28+
"setup_fresh_backend: Failed to setup persistent storage backend for our reply needs: {err}"
29+
);
2830
return Err(ClientCoreError::SurbStorageError {
2931
source: Box::new(err),
3032
});
@@ -93,7 +95,9 @@ pub async fn setup_fs_reply_surb_backend<P: AsRef<Path>>(
9395
match fs_backend::Backend::try_load(db_path).await {
9496
Ok(backend) => Ok(backend),
9597
Err(err) => {
96-
error!("setup_fs_reply_surb_backend: Failed to setup persistent storage backend for our reply needs: {err}. We're going to create a fresh database instead. This behaviour might change in the future");
98+
error!(
99+
"setup_fs_reply_surb_backend: Failed to setup persistent storage backend for our reply needs: {err}. We're going to create a fresh database instead. This behaviour might change in the future"
100+
);
97101
archive_corrupted_database(db_path).await?;
98102
setup_fresh_backend(db_path, surb_config).await
99103
}

common/client-core/src/client/base_client/storage/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2024 - Nym Technologies SA <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use crate::client::key_manager::persistence::KeyStore;
54
use crate::client::key_manager::ClientKeys;
5+
use crate::client::key_manager::persistence::KeyStore;
66
use crate::error::ClientCoreError;
77
use nym_client_core_gateways_storage::{
88
ActiveGateway, GatewayPublishedData, GatewayRegistration, GatewaysDetailsStore,

common/client-core/src/client/cover_traffic_stream.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ use nym_sphinx::addressing::clients::Recipient;
1111
use nym_sphinx::cover::generate_loop_cover_packet;
1212
use nym_sphinx::params::{PacketSize, PacketType};
1313
use nym_sphinx::utils::sample_poisson_duration;
14-
use nym_statistics_common::clients::{packet_statistics::PacketStatisticsEvent, ClientStatsSender};
15-
use rand::{rngs::OsRng, CryptoRng, Rng};
14+
use nym_statistics_common::clients::{ClientStatsSender, packet_statistics::PacketStatisticsEvent};
15+
use rand::{CryptoRng, Rng, rngs::OsRng};
1616
use std::pin::Pin;
1717
use std::sync::Arc;
1818
use std::time::Duration;
1919
use tokio::sync::mpsc::error::TrySendError;
2020
use tracing::*;
2121

2222
#[cfg(not(target_arch = "wasm32"))]
23-
use tokio::time::{sleep, Sleep};
23+
use tokio::time::{Sleep, sleep};
2424

2525
#[cfg(target_arch = "wasm32")]
26-
use wasmtimer::tokio::{sleep, Sleep};
26+
use wasmtimer::tokio::{Sleep, sleep};
2727

2828
pub struct LoopCoverTrafficStream<R>
2929
where
@@ -179,7 +179,9 @@ impl LoopCoverTrafficStream<OsRng> {
179179
) {
180180
Ok(topology) => topology,
181181
Err(err) => {
182-
warn!("We're not going to send any loop cover message this time, as the current topology seem to be invalid - {err}");
182+
warn!(
183+
"We're not going to send any loop cover message this time, as the current topology seem to be invalid - {err}"
184+
);
183185
return;
184186
}
185187
};

0 commit comments

Comments
 (0)