bugfix: key-rotation + reply SURBs (#5876)
* wip: changes to surb logic + stronger db typing * surb invalidation logic * chore: remove unused deps * resolving todos * a lot of additional bugfixes * 1.88 clippy * wasm fixes * wasm clippy * wallet clippy * wait for epoch end when setting up new network * split ReplyController into Sender and Receiver for easier reasoning * additional reply surbs improvements includes, but is not limited to: unconditionally reseting sender tag on restart, limiting number of surb re-requests, resetting stale surbs on load * fixed calculation of number of removed surbs * add additional calculated field to key rotation info * DBG: 'request_reply_surbs_for_queue_clearing' temp logs * fixes for silly mistakes * conditionally reduce log severity
This commit is contained in:
committed by
GitHub
parent
d6bb0979d0
commit
833114372a
@@ -430,7 +430,7 @@ async fn db_connection(database_url: Option<&String>) -> Result<Option<(Client,
|
||||
|
||||
let handle = tokio::spawn(async move {
|
||||
if let Err(e) = connection.await {
|
||||
error!("Postgres connection error: {}", e);
|
||||
error!("Postgres connection error: {e}");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -487,7 +487,7 @@ async fn submit_accounting_routes_to_db(client: Arc<Client>) -> anyhow::Result<(
|
||||
|
||||
pub async fn submit_metrics(database_url: Option<&String>) -> anyhow::Result<()> {
|
||||
if let Err(e) = submit_metrics_to_db(database_url).await {
|
||||
error!("Error submitting metrics to db: {}", e);
|
||||
error!("Error submitting metrics to db: {e}");
|
||||
}
|
||||
|
||||
if let Some(private_key) = PRIVATE_KEY.get() {
|
||||
|
||||
@@ -84,7 +84,7 @@ impl HttpServer {
|
||||
axum::serve(listener, app).with_graceful_shutdown(self.cancel.cancelled_owned());
|
||||
|
||||
info!("##########################################################################################");
|
||||
info!("######################### HTTP server running, with {} clients ############################################", n_clients);
|
||||
info!("######################### HTTP server running, with {n_clients} clients ############################################");
|
||||
info!("##########################################################################################");
|
||||
|
||||
server_future.await?;
|
||||
|
||||
@@ -10,7 +10,8 @@ use nym_network_defaults::setup_env;
|
||||
use nym_network_defaults::var_names::NYM_API;
|
||||
use nym_sdk::mixnet::{self, MixnetClient};
|
||||
use nym_sphinx::chunking::monitoring;
|
||||
use nym_topology::{HardcodedTopologyProvider, NymTopology, NymTopologyMetadata};
|
||||
use nym_topology::provider_trait::ToTopologyMetadata;
|
||||
use nym_topology::{HardcodedTopologyProvider, NymTopology};
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::sync::LazyLock;
|
||||
@@ -26,7 +27,7 @@ use tokio::{signal::ctrl_c, sync::RwLock};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
static NYM_API_URL: LazyLock<String> = LazyLock::new(|| {
|
||||
std::env::var(NYM_API).unwrap_or_else(|_| panic!("{} env var not set", NYM_API))
|
||||
std::env::var(NYM_API).unwrap_or_else(|_| panic!("{NYM_API} env var not set"))
|
||||
});
|
||||
|
||||
static MIXNET_TIMEOUT: OnceCell<u64> = OnceCell::const_new();
|
||||
@@ -48,10 +49,10 @@ async fn make_clients(
|
||||
) {
|
||||
loop {
|
||||
let spawned_clients = clients.read().await.len();
|
||||
info!("Currently spawned clients: {}", spawned_clients);
|
||||
info!("Currently spawned clients: {spawned_clients}");
|
||||
// If we have enough clients, sleep for a minute and remove the oldest one
|
||||
if spawned_clients >= n_clients {
|
||||
info!("New client will be spawned in {} seconds", lifetime);
|
||||
info!("New client will be spawned in {lifetime} seconds");
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(lifetime)).await;
|
||||
info!("Removing oldest client");
|
||||
if let Some(dropped_client) = clients.write().await.pop_front() {
|
||||
@@ -74,7 +75,7 @@ async fn make_clients(
|
||||
let client = match make_client(topology.clone()).await {
|
||||
Ok(client) => client,
|
||||
Err(err) => {
|
||||
warn!("{}, moving on", err);
|
||||
warn!("{err}, moving on");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@@ -171,12 +172,10 @@ async fn nym_topology_from_env() -> anyhow::Result<NymTopology> {
|
||||
let nodes = nodes_response.nodes;
|
||||
let metadata = nodes_response.metadata;
|
||||
|
||||
Ok(NymTopology::new(
|
||||
NymTopologyMetadata::new(metadata.rotation_id, metadata.absolute_epoch_id),
|
||||
rewarded_set,
|
||||
Vec::new(),
|
||||
Ok(
|
||||
NymTopology::new(metadata.to_topology_metadata(), rewarded_set, Vec::new())
|
||||
.with_skimmed_nodes(&nodes),
|
||||
)
|
||||
.with_skimmed_nodes(&nodes))
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
||||
Reference in New Issue
Block a user