Compare commits

...

21 Commits

Author SHA1 Message Date
Mark Sinclair e4ad1e2e1b wip 2025-07-06 17:11:10 +01:00
Mark Sinclair 5b39cb9d8c wip 2025-07-06 13:23:53 +01:00
Mark Sinclair c4fec04fb0 wip 2025-07-06 13:19:53 +01:00
Mark Sinclair a6f156df47 wip 2025-07-06 13:13:00 +01:00
Mark Sinclair e8f76aa7ee wip 2025-07-06 13:10:58 +01:00
Jędrzej Stuczyński 83c84bfd2d use postgres in chain scraper 2025-07-04 18:15:24 +01:00
Jędrzej Stuczyński 71090c85c2 initial postgres support - missing some proto -> json parsing 2025-07-04 18:04:37 +01:00
Jędrzej Stuczyński 976961471b psql scaffolding 2025-07-04 12:45:06 +01:00
Jędrzej Stuczyński 655fd421a6 using sqlite instance for rewarder and chain watcher 2025-07-04 12:25:08 +01:00
Jędrzej Stuczyński 81eaf7b1cc implemented traits for sqlite instance 2025-07-04 12:09:45 +01:00
Jędrzej Stuczyński 027bd85200 changed error types to make modules dyn compatible 2025-07-04 11:23:25 +01:00
Jędrzej Stuczyński 08cff312af wip: made storage mostly generic minus modules 2025-07-04 11:08:05 +01:00
Jędrzej Stuczyński 2920e6ff01 rename nyxd-scraper to sqlite 2025-07-03 16:33:32 +01:00
Jack Wampler a7b57d7e58 Make Mix hops optional for Mixnet Client SURBs (#5861)
* allow SURBs to be configured without mix hops

* gateways require consistency in surb format so if disabling mixnhops - use updated format
2025-07-03 09:21:50 -06:00
benedettadavico 84e10a654c Revert "Bump ns-api version"
This reverts commit d724f94319.
2025-07-01 15:26:55 +02:00
benedetta davico d724f94319 Bump ns-api version 2025-07-01 15:19:56 +02:00
Jędrzej Stuczyński d0692a567a feat: basic performance contract integration [within Nym API] (#5871)
* renamed nym-api config fields

* decouple rewarder startup from network monitor

* additional sections in nym-api config

* removed vesting queries in circulating supply calculator

* added memoized field for last submitted performance measurement

* wip: performance contract refresher

* cleaned up various contract caches

* modified cache refresher to allow passing update fn

* implement performance cache refreshing

* updated lefthook.yml to run cargo fmt

* impl NodePerformanceProvider trait

* dynamically using specific performance provider

* pre warm up performance contract cache and forbid the mode if its empty

* clippy

* introduce fallback setting for performance contract if value for given epoch is not available

* move some functions around
2025-07-01 11:29:50 +01:00
Jędrzej Stuczyński 2ae38b9e49 chore: 1.88 clippy (#5877)
* 1.88 clippy

* wasm clippy

* wallet clippy
2025-07-01 10:28:57 +01:00
benedetta davico ef5990658a Merge pull request #5873 from nymtech/wallet/fix-link 2025-06-26 13:26:36 +02:00
benedettadavico 658dec8299 fix the broken link 2025-06-26 12:44:47 +02:00
dynco-nym 447352b8d6 Set busy_timeout in sqlx (#5872)
* Set busy_timeout

* Bump version
2025-06-26 10:44:06 +02:00
430 changed files with 11655 additions and 2638 deletions
@@ -3,7 +3,7 @@ on:
workflow_dispatch:
env:
WORKING_DIRECTORY: "nyx-chain-watcher"
WORKING_DIRECTORY: "nyx-chain-watcher/sqlite"
CONTAINER_NAME: "nyx-chain-watcher"
jobs:
Generated
+65 -5
View File
@@ -6135,6 +6135,7 @@ dependencies = [
"futures",
"mime",
"serde",
"serde_json",
"serde_yaml",
"subtle 2.6.1",
"time",
@@ -6684,7 +6685,7 @@ dependencies = [
[[package]]
name = "nym-node-status-api"
version = "3.1.0"
version = "3.1.1"
dependencies = [
"ammonia",
"anyhow",
@@ -6998,6 +6999,7 @@ dependencies = [
"tap",
"tempfile",
"thiserror 2.0.12",
"time",
"tokio",
"tokio-stream",
"tokio-util",
@@ -7852,7 +7854,7 @@ dependencies = [
"nym-task 0.1.0",
"nym-ticketbooks-merkle 0.1.0",
"nym-validator-client 0.1.0",
"nyxd-scraper",
"nyxd-scraper-sqlite",
"rand 0.8.5",
"rand_chacha 0.3.1",
"serde",
@@ -8059,7 +8061,7 @@ dependencies = [
"nym-network-defaults 0.1.0",
"nym-task 0.1.0",
"nym-validator-client 0.1.0",
"nyxd-scraper",
"nyxd-scraper-sqlite",
"reqwest 0.12.15",
"schemars",
"serde",
@@ -8077,7 +8079,54 @@ dependencies = [
]
[[package]]
name = "nyxd-scraper"
name = "nyx-chain-watcher-pgsql"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"axum 0.7.9",
"chrono",
"clap",
"nym-bin-common 0.6.0",
"nym-config 0.1.0",
"nym-network-defaults 0.1.0",
"nym-task 0.1.0",
"nym-validator-client 0.1.0",
"nyxd-scraper-psql",
"reqwest 0.12.15",
"schemars",
"serde",
"sqlx",
"thiserror 2.0.12",
"time",
"tokio",
"tokio-util",
"tower-http",
"tracing",
"tracing-subscriber",
"utoipa",
"utoipa-swagger-ui",
"utoipauto",
]
[[package]]
name = "nyxd-scraper-psql"
version = "0.1.0"
dependencies = [
"async-trait",
"base64 0.22.1",
"cosmrs",
"nyxd-scraper-shared",
"serde",
"serde_json",
"sqlx",
"thiserror 2.0.12",
"tokio",
"tracing",
]
[[package]]
name = "nyxd-scraper-shared"
version = "0.1.0"
dependencies = [
"async-trait",
@@ -8088,7 +8137,6 @@ dependencies = [
"humantime",
"serde",
"sha2 0.10.9",
"sqlx",
"tendermint",
"tendermint-rpc",
"thiserror 2.0.12",
@@ -8100,6 +8148,18 @@ dependencies = [
"url",
]
[[package]]
name = "nyxd-scraper-sqlite"
version = "0.1.0"
dependencies = [
"async-trait",
"nyxd-scraper-shared",
"sqlx",
"thiserror 2.0.12",
"tokio",
"tracing",
]
[[package]]
name = "object"
version = "0.36.7"
+7 -3
View File
@@ -80,7 +80,9 @@ members = [
"common/nymsphinx/params",
"common/nymsphinx/routing",
"common/nymsphinx/types",
"common/nyxd-scraper",
"common/nyxd-scraper-sqlite",
"common/nyxd-scraper-psql",
"common/nyxd-scraper-shared",
"common/pemstore",
"common/serde-helpers",
"common/service-provider-requests-common",
@@ -118,7 +120,8 @@ members = [
"nym-outfox",
"nym-statistics-api",
"nym-validator-rewarder",
"nyx-chain-watcher",
"nyx-chain-watcher/pgsql",
"nyx-chain-watcher/sqlite",
"sdk/ffi/cpp",
"sdk/ffi/go",
"sdk/ffi/shared",
@@ -160,7 +163,8 @@ default-members = [
"nym-node-status-api/nym-node-status-api",
"nym-statistics-api",
"nym-validator-rewarder",
"nyx-chain-watcher",
"nyx-chain-watcher/sqlite",
"nyx-chain-watcher/pgsql",
"service-providers/authenticator",
"service-providers/ip-packet-router",
"service-providers/network-requester",
+1 -1
View File
@@ -318,7 +318,7 @@ impl Handler {
async fn handle_text_message(&mut self, msg: String) -> Option<WsMessage> {
debug!("Handling text message request");
trace!("Content: {:?}", msg);
trace!("Content: {msg:?}");
self.received_response_type = ReceivedResponseType::Text;
let client_request = ClientRequest::try_from_text(msg);
+2 -2
View File
@@ -68,9 +68,9 @@ impl Listener {
new_conn = tcp_listener.accept() => {
match new_conn {
Ok((mut socket, remote_addr)) => {
debug!("Received connection from {:?}", remote_addr);
debug!("Received connection from {remote_addr:?}");
if self.state.is_connected() {
warn!("Tried to open a duplicate websocket connection. The request came from {}", remote_addr);
warn!("Tried to open a duplicate websocket connection. The request came from {remote_addr}");
// if we've already got a connection, don't allow another one
// while we only ever want to accept a single connection, we don't want
// to leave clients hanging (and also allow for reconnection if it somehow
+1 -1
View File
@@ -137,7 +137,7 @@ impl AsyncFileWatcher {
log::error!("the file watcher receiver has been dropped!");
}
} else {
log::debug!("will not propagate information about {:?}", event);
log::debug!("will not propagate information about {event:?}");
}
}
Err(err) => {
+1 -1
View File
@@ -11,7 +11,7 @@ impl std::fmt::Display for BandwidthStatusMessage {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BandwidthStatusMessage::RemainingBandwidth(b) => {
write!(f, "remaining bandwidth: {}", b)
write!(f, "remaining bandwidth: {b}")
}
BandwidthStatusMessage::NoBandwidth => write!(f, "no bandwidth left"),
}
@@ -418,6 +418,9 @@ pub struct Traffic {
/// will be routed as usual, to the entry gateway, through three mix nodes, egressing
/// through the exit gateway. If mix hops are disabled, traffic will be routed directly
/// from the entry gateway to the exit gateway, bypassing the mix nodes.
///
/// This overrides the `use_legacy_sphinx_format` setting as reduced mix hops
/// requires use of the updated SURB packet format.
pub disable_mix_hops: bool,
}
@@ -146,7 +146,7 @@ impl MixTrafficController {
Some(client_request) => {
match self.gateway_transceiver.send_client_request(client_request).await {
Ok(_) => (),
Err(e) => error!("Failed to send client request: {}", e),
Err(e) => error!("Failed to send client request: {e}"),
};
},
None => {
@@ -65,7 +65,7 @@ impl AcknowledgementListener {
return;
}
trace!("Received {} from the mix network", frag_id);
trace!("Received {frag_id} from the mix network");
self.stats_tx
.report(PacketStatisticsEvent::RealAckReceived(ack_content.len()).into());
if let Err(err) = self
@@ -126,7 +126,7 @@ impl ActionController {
fn handle_insert(&mut self, pending_acks: Vec<PendingAcknowledgement>) {
for pending_ack in pending_acks {
let frag_id = pending_ack.message_chunk.fragment_identifier();
trace!("{} is inserted", frag_id);
trace!("{frag_id} is inserted");
if self
.pending_acks_data
@@ -161,22 +161,16 @@ impl ActionController {
let new_queue_key = self.pending_acks_timers.insert(frag_id, timeout);
*queue_key = Some(new_queue_key)
} else {
debug!(
"Tried to START TIMER on pending ack that is already gone! - {}",
frag_id
);
debug!("Tried to START TIMER on pending ack that is already gone! - {frag_id}");
}
}
fn handle_remove(&mut self, frag_id: FragmentIdentifier) {
trace!("{} is getting removed", frag_id);
trace!("{frag_id} is getting removed");
match self.pending_acks_data.remove(&frag_id) {
None => {
debug!(
"Tried to REMOVE pending ack that is already gone! - {}",
frag_id
);
debug!("Tried to REMOVE pending ack that is already gone! - {frag_id}");
}
Some((_, queue_key)) => {
if let Some(queue_key) = queue_key {
@@ -188,10 +182,7 @@ impl ActionController {
} else {
// I'm not 100% sure if having a `None` key is even possible here
// (REMOVE would have to be called before START TIMER),
debug!(
"Tried to REMOVE pending ack without TIMER active - {}",
frag_id
);
debug!("Tried to REMOVE pending ack without TIMER active - {frag_id}");
}
}
}
@@ -200,7 +191,7 @@ impl ActionController {
// initiated basically as a first step of retransmission. At first data has its delay updated
// (as new sphinx packet was created with new expected delivery time)
fn handle_update_pending_ack(&mut self, frag_id: FragmentIdentifier, delay: SphinxDelay) {
trace!("{} is updating its delay", frag_id);
trace!("{frag_id} is updating its delay");
// TODO: is it possible to solve this without either locking or temporarily removing the value?
if let Some((pending_ack_data, queue_key)) = self.pending_acks_data.remove(&frag_id) {
// this Action is triggered by `RetransmissionRequestListener` (for 'normal' packets)
@@ -213,10 +204,7 @@ impl ActionController {
self.pending_acks_data
.insert(frag_id, (Arc::new(inner_data), queue_key));
} else {
debug!(
"Tried to UPDATE TIMER on pending ack that is already gone! - {}",
frag_id
);
debug!("Tried to UPDATE TIMER on pending ack that is already gone! - {frag_id}");
}
}
@@ -105,6 +105,9 @@ pub(crate) struct Config {
/// will be routed as usual, to the entry gateway, through three mix nodes, egressing
/// through the exit gateway. If mix hops are disabled, traffic will be routed directly
/// from the entry gateway to the exit gateway, bypassing the mix nodes.
///
/// This overrides the `use_legacy_sphinx_format` setting as reduced mix hops
/// requires use of the updated SURB packet format.
disable_mix_hops: bool,
/// Average delay a data packet is going to get delay at a single mixnode.
@@ -159,8 +162,12 @@ impl Config {
}
/// Configure whether messages senders using this config should use mix hops or not when sending messages.
///
/// This overrides the `use_legacy_sphinx_format` setting as disabled mix hops
/// requires use of the updated SURB packet format.
pub fn disable_mix_hops(mut self, disable_mix_hops: bool) -> Self {
self.disable_mix_hops = disable_mix_hops;
self.use_legacy_sphinx_format = false;
self
}
}
@@ -202,7 +202,7 @@ where
// well technically the message was not sent just yet, but now it's up to internal
// queues and client load rather than the required delay. So realistically we can treat
// whatever is about to happen as negligible additional delay.
trace!("{} is about to get sent to the mixnet", frag_id);
trace!("{frag_id} is about to get sent to the mixnet");
if let Err(err) = self.sent_notifier.unbounded_send(frag_id) {
error!("Failed to notify about sent message: {err}");
}
@@ -164,11 +164,11 @@ impl SendingDelayController {
self.current_multiplier()
);
if self.current_multiplier() > 0 {
log::debug!("{}", status_str);
log::debug!("{status_str}");
} else if self.current_multiplier() > 1 {
log::info!("{}", status_str);
log::info!("{status_str}");
} else if self.current_multiplier() > 2 {
log::warn!("{}", status_str);
log::warn!("{status_str}");
}
self.time_when_logged_about_elevated_multiplier = now;
}
@@ -221,10 +221,7 @@ impl<R: MessageReceiver> ReceivedMessagesBuffer<R> {
let stored_messages = std::mem::take(&mut guard.messages);
if !stored_messages.is_empty() {
if let Err(err) = sender.unbounded_send(stored_messages) {
error!(
"The sender channel we just received is already invalidated - {:?}",
err
);
error!("The sender channel we just received is already invalidated - {err:?}");
// put the values back to the buffer
// the returned error has two fields: err: SendError and val: T,
// where val is the value that was failed to get sent;
@@ -217,14 +217,14 @@ where
.surbs_storage_ref()
.contains_surbs_for(&recipient_tag)
{
warn!("received reply request for {:?} but we don't have any surbs stored for that recipient!", recipient_tag);
warn!("received reply request for {recipient_tag:?} but we don't have any surbs stored for that recipient!");
return;
}
trace!("handling reply to {:?}", recipient_tag);
trace!("handling reply to {recipient_tag:?}");
let mut fragments = self.message_handler.split_reply_message(data);
let total_size = fragments.len();
trace!("This reply requires {:?} SURBs", total_size);
trace!("This reply requires {total_size:?} SURBs");
let available_surbs = self
.full_reply_storage
@@ -327,10 +327,7 @@ where
.await
{
let err = err.return_unused_surbs(self.full_reply_storage.surbs_storage_ref(), &target);
warn!(
"failed to request additional surbs from {:?} - {err}",
target
);
warn!("failed to request additional surbs from {target:?} - {err}");
return Err(err);
} else {
self.full_reply_storage
@@ -409,10 +406,7 @@ where
err.return_unused_surbs(self.full_reply_storage.surbs_storage_ref(), &target);
self.re_insert_pending_retransmission(&target, to_take);
warn!(
"failed to clear pending retransmission queue for {:?} - {err}",
target
);
warn!("failed to clear pending retransmission queue for {target:?} - {err}");
return;
}
};
@@ -489,7 +483,7 @@ where
let err =
err.return_unused_surbs(self.full_reply_storage.surbs_storage_ref(), &target);
self.re_insert_pending_replies(&target, to_send);
warn!("failed to clear pending queue for {:?} - {err}", target);
warn!("failed to clear pending queue for {target:?} - {err}");
}
} else {
trace!("the pending queue is empty");
@@ -816,7 +810,7 @@ where
if diff > max_drop_wait {
to_remove.push(*pending_reply_target)
} else {
debug!("We haven't received any surbs in {:?} from {pending_reply_target}. Going to explicitly ask for more", diff);
debug!("We haven't received any surbs in {diff:?} from {pending_reply_target}. Going to explicitly ask for more");
to_request.push(*pending_reply_target);
}
}
@@ -93,7 +93,7 @@ impl StatisticsControl {
None,
);
if let Err(err) = self.report_tx.send(report_message).await {
log::error!("Failed to report client stats: {:?}", err);
log::error!("Failed to report client stats: {err:?}");
} else {
self.stats.reset();
}
@@ -211,7 +211,7 @@ impl<T> TransmissionBuffer<T> {
};
let msg = self.pop_front_from_lane(&lane)?;
log::trace!("picking to send from lane: {:?}", lane);
log::trace!("picking to send from lane: {lane:?}");
Some((lane, msg))
}
+3 -3
View File
@@ -110,7 +110,7 @@ pub async fn gateways_for_init<R: Rng>(
let gateways = client.get_all_basic_entry_assigned_nodes_v2().await?.nodes;
info!("nym api reports {} gateways", gateways.len());
log::trace!("Gateways: {:#?}", gateways);
log::trace!("Gateways: {gateways:#?}");
// filter out gateways below minimum performance and ones that could operate as a mixnode
// (we don't want instability)
@@ -121,7 +121,7 @@ pub async fn gateways_for_init<R: Rng>(
.filter_map(|gateway| gateway.try_into().ok())
.collect::<Vec<_>>();
log::debug!("After checking validity: {}", valid_gateways.len());
log::trace!("Valid gateways: {:#?}", valid_gateways);
log::trace!("Valid gateways: {valid_gateways:#?}");
log::info!(
"and {} after validity and performance filtering",
@@ -286,7 +286,7 @@ pub(super) fn get_specified_gateway(
gateways: &[RoutingNode],
must_use_tls: bool,
) -> Result<RoutingNode, ClientCoreError> {
log::debug!("Requesting specified gateway: {}", gateway_identity);
log::debug!("Requesting specified gateway: {gateway_identity}");
let user_gateway = ed25519::PublicKey::from_base58_string(gateway_identity)
.map_err(ClientCoreError::UnableToCreatePublicKeyFromGatewayId)?;
@@ -7,18 +7,17 @@ use crate::nyxd::error::NyxdError;
use crate::nyxd::CosmWasmClient;
use async_trait::async_trait;
use cosmrs::AccountId;
pub use nym_performance_contract_common::{
msg::QueryMsg as PerformanceQueryMsg, types::NetworkMonitorResponse,
};
use nym_performance_contract_common::{
EpochId, EpochMeasurementsPagedResponse, EpochNodePerformance, EpochPerformancePagedResponse,
FullHistoricalPerformancePagedResponse, HistoricalPerformance, NetworkMonitorInformation,
NetworkMonitorsPagedResponse, NodeId, NodeMeasurement, NodeMeasurementsResponse,
NodePerformance, NodePerformancePagedResponse, NodePerformanceResponse, RetiredNetworkMonitor,
RetiredNetworkMonitorsPagedResponse,
};
use serde::Deserialize;
pub use nym_performance_contract_common::{
msg::QueryMsg as PerformanceQueryMsg, types::NetworkMonitorResponse, EpochId,
EpochMeasurementsPagedResponse, EpochNodePerformance, EpochPerformancePagedResponse,
FullHistoricalPerformancePagedResponse, HistoricalPerformance, LastSubmission,
NetworkMonitorInformation, NetworkMonitorsPagedResponse, NodeId, NodeMeasurement,
NodeMeasurementsResponse, NodePerformance, NodePerformancePagedResponse,
NodePerformanceResponse, RetiredNetworkMonitor, RetiredNetworkMonitorsPagedResponse,
};
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait PerformanceQueryClient {
@@ -139,6 +138,11 @@ pub trait PerformanceQueryClient {
})
.await
}
async fn get_last_submission(&self) -> Result<LastSubmission, NyxdError> {
self.query_performance_contract(PerformanceQueryMsg::LastSubmittedMeasurement {})
.await
}
}
// extension trait to the query client to deal with the paged queries
@@ -212,6 +216,7 @@ where
mod tests {
use super::*;
use crate::nyxd::contract_traits::tests::IgnoreValue;
use nym_performance_contract_common::QueryMsg;
// it's enough that this compiles and clippy is happy about it
#[allow(dead_code)]
@@ -260,6 +265,7 @@ mod tests {
PerformanceQueryMsg::RetiredNetworkMonitorsPaged { start_after, limit } => client
.get_retired_network_monitors_paged(start_after, limit)
.ignore(),
QueryMsg::LastSubmittedMeasurement {} => client.get_last_submission().ignore(),
};
}
}
+2 -2
View File
@@ -49,14 +49,14 @@ pub fn show_error<E>(e: E)
where
E: Display,
{
error!("{}", e);
error!("{e}");
}
pub fn show_error_passthrough<E>(e: E) -> E
where
E: Error + Display,
{
error!("{}", e);
error!("{e}");
e
}
@@ -42,7 +42,7 @@ pub async fn query_balance(
.address
.unwrap_or_else(|| address_from_mnemonic.expect("please provide a mnemonic"));
info!("Getting balance for {}...", address);
info!("Getting balance for {address}...");
match client.get_all_balances(&address).await {
Ok(coins) => {
@@ -57,17 +57,17 @@ pub fn get_pubkey_from_mnemonic(address: AccountId, prefix: &str, mnemonic: bip3
println!("{}", account.public_key().to_string());
}
None => {
error!("Could not derive key that matches {}", address)
error!("Could not derive key that matches {address}")
}
},
Err(e) => {
error!("Failed to derive accounts. {}", e);
error!("Failed to derive accounts. {e}");
}
}
}
pub async fn get_pubkey_from_chain(address: AccountId, client: &QueryClient) {
info!("Getting public key for address {} from chain...", address);
info!("Getting public key for address {address} from chain...");
match client.get_account(&address).await {
Ok(Some(account)) => {
if let Ok(base_account) = account.try_get_base_account() {
@@ -37,7 +37,7 @@ pub async fn send_multiple(args: Args, client: &SigningClient) {
let rows = InputFileReader::new(&args.input);
if let Err(e) = rows {
error!("Failed to read input file: {}", e);
error!("Failed to read input file: {e}");
return;
}
let rows = rows.unwrap();
@@ -67,7 +67,7 @@ pub async fn send_multiple(args: Args, client: &SigningClient) {
.prompt();
if let Err(e) = ans {
info!("Aborting, {}...", e);
info!("Aborting, {e}...");
return;
}
if let Ok(false) = ans {
@@ -100,13 +100,10 @@ pub async fn send_multiple(args: Args, client: &SigningClient) {
println!("Transaction hash: {}", &res.hash);
if let Some(output_filename) = args.output {
println!("\nWriting output log to {}", output_filename);
println!("\nWriting output log to {output_filename}");
if let Err(e) = write_output_file(rows, res, &output_filename) {
error!(
"Failed to write output file {} with error {}",
output_filename, e
);
error!("Failed to write output file {output_filename} with error {e}");
}
}
}
@@ -136,7 +133,7 @@ fn write_output_file(
.collect::<Vec<String>>()
.join("\n");
Ok(file.write_all(format!("{}\n", data).as_bytes())?)
Ok(file.write_all(format!("{data}\n").as_bytes())?)
}
#[derive(Debug)]
@@ -171,7 +168,7 @@ impl InputFileReader {
// multiply when a whole token amount, e.g. 50nym (50.123456nym is not allowed, that must be input as 50123456unym)
let (amount, denom) = if !denom.starts_with('u') {
(amount * 1_000_000u128, format!("u{}", denom))
(amount * 1_000_000u128, format!("u{denom}"))
} else {
(amount, denom)
};
@@ -55,6 +55,6 @@ pub async fn execute(args: Args, client: SigningClient) {
.await
{
Ok(res) => info!("SUCCESS ✅\n{}", json!(res)),
Err(e) => error!("FAILURE ❌\n{}", e),
Err(e) => error!("FAILURE ❌\n{e}"),
}
}
@@ -43,7 +43,7 @@ pub struct Args {
pub async fn generate(args: Args) {
info!("Starting to generate vesting contract instantiate msg");
debug!("Received arguments: {:?}", args);
debug!("Received arguments: {args:?}");
let multisig_addr = args.multisig_addr.unwrap_or_else(|| {
let address = std::env::var(nym_network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
@@ -97,7 +97,7 @@ pub async fn generate(args: Args) {
key_size: DEFAULT_DEALINGS as u32,
};
debug!("instantiate_msg: {:?}", instantiate_msg);
debug!("instantiate_msg: {instantiate_msg:?}");
let res =
serde_json::to_string(&instantiate_msg).expect("failed to convert instantiate msg to json");
@@ -28,7 +28,7 @@ pub struct Args {
pub async fn generate(args: Args) {
info!("Starting to generate vesting contract instantiate msg");
debug!("Received arguments: {:?}", args);
debug!("Received arguments: {args:?}");
let group_addr = args.group_addr.unwrap_or_else(|| {
let address = std::env::var(nym_network_defaults::var_names::GROUP_CONTRACT_ADDRESS)
@@ -51,7 +51,7 @@ pub async fn generate(args: Args) {
deposit_amount: args.deposit_amount,
};
debug!("instantiate_msg: {:?}", instantiate_msg);
debug!("instantiate_msg: {instantiate_msg:?}");
let res =
serde_json::to_string(&instantiate_msg).expect("failed to convert instantiate msg to json");
@@ -88,7 +88,7 @@ pub struct Args {
pub async fn generate(args: Args) {
info!("Starting to generate mixnet contract instantiate msg");
debug!("Received arguments: {:?}", args);
debug!("Received arguments: {args:?}");
let initial_rewarding_params = InitialRewardingParams {
initial_reward_pool: Decimal::from_atomics(args.initial_reward_pool, 0)
@@ -114,7 +114,7 @@ pub async fn generate(args: Args) {
},
};
debug!("initial_rewarding_params: {:?}", initial_rewarding_params);
debug!("initial_rewarding_params: {initial_rewarding_params:?}");
let rewarding_validator_address = args.rewarding_validator_address.unwrap_or_else(|| {
let address = std::env::var(nym_network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
@@ -160,7 +160,7 @@ pub async fn generate(args: Args) {
key_validity_in_epochs: None,
};
debug!("instantiate_msg: {:?}", instantiate_msg);
debug!("instantiate_msg: {instantiate_msg:?}");
let res =
serde_json::to_string(&instantiate_msg).expect("failed to convert instantiate msg to json");
@@ -31,7 +31,7 @@ pub struct Args {
pub async fn generate(args: Args) {
info!("Starting to generate vesting contract instantiate msg");
debug!("Received arguments: {:?}", args);
debug!("Received arguments: {args:?}");
let ecash_contract_address = args.ecash_contract_address.unwrap_or_else(|| {
let address = std::env::var(nym_network_defaults::var_names::ECASH_CONTRACT_ADDRESS)
@@ -60,7 +60,7 @@ pub async fn generate(args: Args) {
coconut_dkg_contract_address: coconut_dkg_contract_address.to_string(),
};
debug!("instantiate_msg: {:?}", instantiate_msg);
debug!("instantiate_msg: {instantiate_msg:?}");
let res =
serde_json::to_string(&instantiate_msg).expect("failed to convert instantiate msg to json");
@@ -21,7 +21,7 @@ pub struct Args {
pub async fn generate(args: Args) {
info!("Starting to generate vesting contract instantiate msg");
debug!("Received arguments: {:?}", args);
debug!("Received arguments: {args:?}");
let mixnet_contract_address = args.mixnet_contract_address.unwrap_or_else(|| {
let address = std::env::var(nym_network_defaults::var_names::MIXNET_CONTRACT_ADDRESS)
@@ -39,7 +39,7 @@ pub async fn generate(args: Args) {
mix_denom,
};
debug!("instantiate_msg: {:?}", instantiate_msg);
debug!("instantiate_msg: {instantiate_msg:?}");
let res =
serde_json::to_string(&instantiate_msg).expect("failed to convert instantiate msg to json");
@@ -72,7 +72,7 @@ pub async fn init(args: Args, client: SigningClient, network_details: &NymNetwor
.await
.expect("failed to instantiate the contract!");
info!("Init result: {:?}", res);
info!("Init result: {res:?}");
println!("{}", res.contract_address)
}
@@ -47,5 +47,5 @@ pub async fn migrate(args: Args, client: SigningClient) {
.expect("failed to migrate the contract!")
};
info!("Migrate result: {:?}", res);
info!("Migrate result: {res:?}");
}
@@ -31,7 +31,7 @@ pub async fn upload(args: Args, client: SigningClient) {
.await
.expect("failed to upload the contract!");
info!("Upload result: {:?}", res);
info!("Upload result: {res:?}");
println!("{}", res.code_id)
}
@@ -47,5 +47,5 @@ pub async fn delegate_to_mixnode(args: Args, client: SigningClient) {
.await
.expect("failed to delegate to mixnode!");
info!("delegating to mixnode: {:?}", res);
info!("delegating to mixnode: {res:?}");
}
@@ -196,7 +196,7 @@ pub async fn delegate_to_multiple_mixnodes(args: Args, client: SigningClient) {
let records = match InputFileReader::new(&args.input) {
Ok(records) => records,
Err(e) => {
println!("Error reading input file: {}", e);
println!("Error reading input file: {e}");
return;
}
};
@@ -262,11 +262,11 @@ pub async fn delegate_to_multiple_mixnodes(args: Args, client: SigningClient) {
}
if !undelegation_msgs.is_empty() {
println!("Undelegation records : \n{}\n\n", undelegation_table);
println!("Undelegation records : \n{undelegation_table}\n\n");
}
if !delegation_msgs.is_empty() {
println!("Delegation records : \n{}\n\n", delegation_table);
println!("Delegation records : \n{delegation_table}\n\n");
}
let ans = inquire::Confirm::new("Do you want to continue with the shown operations?")
@@ -275,7 +275,7 @@ pub async fn delegate_to_multiple_mixnodes(args: Args, client: SigningClient) {
.prompt();
if let Err(e) = ans {
info!("Aborting, {}...", e);
info!("Aborting, {e}...");
return;
}
@@ -348,7 +348,7 @@ pub async fn delegate_to_multiple_mixnodes(args: Args, client: SigningClient) {
if args.output.is_some() {
if let Err(e) = write_to_csv(output_details, args.output) {
info!("Failed to write to CSV, {}", e);
info!("Failed to write to CSV, {e}");
}
}
}
@@ -38,5 +38,5 @@ pub async fn migrate_vested_delegation(args: Args, client: SigningClient) {
.await
.expect("failed to migrate delegation!");
info!("migration result: {:?}", res)
info!("migration result: {res:?}")
}
@@ -40,5 +40,5 @@ pub async fn claim_delegator_reward(args: Args, client: SigningClient) {
.await
.expect("failed to claim delegator-reward");
info!("Claiming delegator reward: {:?}", res)
info!("Claiming delegator reward: {res:?}")
}
@@ -40,5 +40,5 @@ pub async fn vesting_claim_delegator_reward(args: Args, client: SigningClient) {
.await
.expect("failed to claim vesting delegator-reward");
info!("Claiming vesting delegator reward: {:?}", res)
info!("Claiming vesting delegator reward: {res:?}")
}
@@ -40,5 +40,5 @@ pub async fn undelegate_from_mixnode(args: Args, client: SigningClient) {
.await
.expect("failed to remove stake from mixnode!");
info!("removing stake from mixnode: {:?}", res)
info!("removing stake from mixnode: {res:?}")
}
@@ -53,5 +53,5 @@ pub async fn vesting_delegate_to_mixnode(args: Args, client: SigningClient) {
.await
.expect("failed to delegate to mixnode!");
info!("vesting delegating to mixnode: {:?}", res);
info!("vesting delegating to mixnode: {res:?}");
}
@@ -45,5 +45,5 @@ pub async fn vesting_undelegate_from_mixnode(args: Args, client: SigningClient)
.await
.expect("failed to remove stake from vesting account on mixnode!");
info!("removing stake from vesting mixnode: {:?}", res)
info!("removing stake from vesting mixnode: {res:?}")
}
@@ -73,5 +73,5 @@ pub async fn bond_gateway(args: Args, client: SigningClient) {
.await
.expect("failed to bond gateway!");
info!("Bonding result: {:?}", res)
info!("Bonding result: {res:?}")
}
@@ -52,5 +52,5 @@ pub async fn migrate_to_nymnode(args: Args, client: SigningClient) {
.await
.expect("failed to migrate gateway!");
info!("migration result: {:?}", res)
info!("migration result: {res:?}")
}
@@ -56,5 +56,5 @@ pub async fn update_config(args: Args, client: SigningClient) {
.await
.expect("updating gateway config");
info!("gateway config updated: {:?}", res)
info!("gateway config updated: {res:?}")
}
@@ -57,5 +57,5 @@ pub async fn vesting_update_config(args: Args, client: SigningClient) {
.await
.expect("updating vesting gateway config");
info!("gateway config updated: {:?}", res)
info!("gateway config updated: {res:?}")
}
@@ -17,5 +17,5 @@ pub async fn unbond_gateway(client: SigningClient) {
.await
.expect("failed to unbond gateway!");
info!("Unbonding result: {:?}", res)
info!("Unbonding result: {res:?}")
}
@@ -73,5 +73,5 @@ pub async fn vesting_bond_gateway(args: Args, client: SigningClient) {
.await
.expect("failed to bond gateway!");
info!("Vesting bonding gateway result: {:?}", res)
info!("Vesting bonding gateway result: {res:?}")
}
@@ -17,5 +17,5 @@ pub async fn vesting_unbond_gateway(client: SigningClient) {
.await
.expect("failed to unbond vesting gateway!");
info!("Unbonding vesting result: {:?}", res)
info!("Unbonding vesting result: {res:?}")
}
@@ -106,5 +106,5 @@ pub async fn bond_mixnode(args: Args, client: SigningClient) {
.await
.expect("failed to bond mixnode!");
info!("Bonding result: {:?}", res)
info!("Bonding result: {res:?}")
}
@@ -25,5 +25,5 @@ pub async fn decrease_pledge(args: Args, client: SigningClient) {
.await
.expect("failed to decrease pledge!");
info!("decreasing pledge: {:?}", res);
info!("decreasing pledge: {res:?}");
}
@@ -15,5 +15,5 @@ pub async fn migrate_vested_mixnode(_args: Args, client: SigningClient) {
.await
.expect("failed to migrate mixnode!");
info!("migration result: {:?}", res)
info!("migration result: {res:?}")
}
@@ -15,5 +15,5 @@ pub async fn migrate_to_nymnode(_args: Args, client: SigningClient) {
.await
.expect("failed to migrate mixnode!");
info!("migration result: {:?}", res)
info!("migration result: {res:?}")
}
@@ -25,5 +25,5 @@ pub async fn pledge_more(args: Args, client: SigningClient) {
.await
.expect("failed to pledge more!");
info!("pledging more: {:?}", res);
info!("pledging more: {res:?}");
}
@@ -17,5 +17,5 @@ pub async fn claim_operator_reward(_args: Args, client: SigningClient) {
.await
.expect("failed to claim operator reward");
info!("Claiming operator reward: {:?}", res)
info!("Claiming operator reward: {res:?}")
}
@@ -20,5 +20,5 @@ pub async fn vesting_claim_operator_reward(client: SigningClient) {
.await
.expect("failed to claim vesting operator reward");
info!("Claiming vesting operator reward: {:?}", res)
info!("Claiming vesting operator reward: {res:?}")
}
@@ -64,5 +64,5 @@ pub async fn update_config(args: Args, client: SigningClient) {
.await
.expect("updating mix-node config");
info!("mixnode config updated: {:?}", res)
info!("mixnode config updated: {res:?}")
}
@@ -65,5 +65,5 @@ pub async fn vesting_update_config(client: SigningClient, args: Args) {
.await
.expect("updating vesting mix-node config");
info!("mixnode config updated: {:?}", res)
info!("mixnode config updated: {res:?}")
}
@@ -18,5 +18,5 @@ pub async fn unbond_mixnode(_args: Args, client: SigningClient) {
.await
.expect("failed to unbond mixnode!");
info!("Unbonding result: {:?}", res)
info!("Unbonding result: {res:?}")
}
@@ -106,5 +106,5 @@ pub async fn vesting_bond_mixnode(client: SigningClient, args: Args, denom: &str
.await
.expect("failed to bond vesting mixnode!");
info!("Bonding vesting result: {:?}", res)
info!("Bonding vesting result: {res:?}")
}
@@ -25,5 +25,5 @@ pub async fn vesting_decrease_pledge(args: Args, client: SigningClient) {
.await
.expect("failed to vesting decrease pledge!");
info!("vesting decreasing pledge: {:?}", res);
info!("vesting decreasing pledge: {res:?}");
}
@@ -26,5 +26,5 @@ pub async fn vesting_pledge_more(args: Args, client: SigningClient) {
.await
.expect("failed to pledge more!");
info!("vesting pledge more: {:?}", res);
info!("vesting pledge more: {res:?}");
}
@@ -20,5 +20,5 @@ pub async fn vesting_unbond_mixnode(client: SigningClient) {
.await
.expect("failed to unbond vesting mixnode!");
info!("Unbonding vesting result: {:?}", res)
info!("Unbonding vesting result: {res:?}")
}
@@ -85,5 +85,5 @@ pub async fn bond_nymnode(args: Args, client: SigningClient) {
.await
.expect("failed to bond nymnode!");
info!("Bonding result: {:?}", res)
info!("Bonding result: {res:?}")
}
@@ -25,5 +25,5 @@ pub async fn decrease_pledge(args: Args, client: SigningClient) {
.await
.expect("failed to decrease pledge!");
info!("decreasing pledge: {:?}", res);
info!("decreasing pledge: {res:?}");
}
@@ -25,5 +25,5 @@ pub async fn increase_pledge(args: Args, client: SigningClient) {
.await
.expect("failed to pledge more!");
info!("pledging more: {:?}", res);
info!("pledging more: {res:?}");
}
@@ -17,5 +17,5 @@ pub async fn claim_operator_reward(_args: Args, client: SigningClient) {
.await
.expect("failed to claim operator reward");
info!("Claiming operator reward: {:?}", res)
info!("Claiming operator reward: {res:?}")
}
@@ -46,5 +46,5 @@ pub async fn update_config(args: Args, client: SigningClient) {
.await
.expect("updating nym node config");
info!("nym node config updated: {:?}", res)
info!("nym node config updated: {res:?}")
}
@@ -68,6 +68,6 @@ pub async fn update_cost_params(args: Args, client: SigningClient) -> anyhow::Re
.await
.expect("failed to update cost params");
info!("Cost params result: {:?}", res);
info!("Cost params result: {res:?}");
Ok(())
}
@@ -18,5 +18,5 @@ pub async fn unbond_nymnode(_args: Args, client: SigningClient) {
.await
.expect("failed to unbond Nym Node!");
info!("Unbonding result: {:?}", res)
info!("Unbonding result: {res:?}")
}
@@ -52,7 +52,7 @@ pub fn sign(args: Args, prefix: &str, mnemonic: Option<bip39::Mnemonic>) {
println!("{}", json!(output));
}
Err(e) => {
error!("Failed to sign message. {}", e);
error!("Failed to sign message. {e}");
}
}
}
@@ -61,7 +61,7 @@ pub fn sign(args: Args, prefix: &str, mnemonic: Option<bip39::Mnemonic>) {
}
},
Err(e) => {
error!("Failed to derive accounts. {}", e);
error!("Failed to derive accounts. {e}");
}
}
}
@@ -38,7 +38,7 @@ pub async fn verify(args: Args, client: &QueryClient) {
let public_key = match AccountId::from_str(&args.public_key_or_address) {
Ok(address) => {
info!("Found account address instead of public key, so looking up public key for {} from chain", address);
info!("Found account address instead of public key, so looking up public key for {address} from chain");
match client.get_account_public_key(&address).await.ok() {
Some(public_key) => {
if let Some(k) = public_key {
@@ -48,8 +48,7 @@ pub async fn verify(args: Args, client: &QueryClient) {
}
None => {
error!(
"Address {} does not have a public key recorded on the chain. This is probably because the account has never signed a transaction.",
address
"Address {address} does not have a public key recorded on the chain. This is probably because the account has never signed a transaction."
);
None
}
@@ -58,7 +57,7 @@ pub async fn verify(args: Args, client: &QueryClient) {
Err(_) => match PublicKey::from_json(&args.public_key_or_address) {
Ok(parsed) => Some(parsed),
Err(e) => {
error!("Public key should be JSON. Unable to parse: {}", e);
error!("Public key should be JSON. Unable to parse: {e}");
None
}
},
@@ -78,7 +77,7 @@ pub async fn verify(args: Args, client: &QueryClient) {
) {
Ok(()) => println!("SUCCESS ✅ signature verified"),
Err(e) => {
error!("FAILURE ❌ Signature verification failed: {}", e);
error!("FAILURE ❌ Signature verification failed: {e}");
}
}
}
@@ -86,6 +86,6 @@ pub async fn create(args: Args, client: SigningClient, network_details: &NymNetw
.await
.unwrap();
info!("Vesting result: {:?}", res);
info!("Coin send result: {:?}", send_coin_response);
info!("Vesting result: {res:?}");
info!("Coin send result: {send_coin_response:?}");
}
@@ -29,7 +29,7 @@ pub async fn query(args: Args, client: QueryClient, address_from_mnemonic: Optio
.address
.unwrap_or_else(|| address_from_mnemonic.expect("please provide a mnemonic"));
info!("Checking account {} for a vesting schedule...", account_id);
info!("Checking account {account_id} for a vesting schedule...");
let vesting_address = account_id.to_string();
let denom = client.current_chain_details().mix_denom.base.as_str();
@@ -44,6 +44,17 @@ pub struct RewardEstimate {
pub operating_cost: Decimal,
}
impl RewardEstimate {
pub const fn zero() -> RewardEstimate {
RewardEstimate {
total_node_reward: Decimal::zero(),
operator: Decimal::zero(),
delegates: Decimal::zero(),
operating_cost: Decimal::zero(),
}
}
}
#[cw_serde]
#[derive(Copy, Default)]
pub struct RewardDistribution {
@@ -4,6 +4,7 @@
pub mod storage_keys {
pub const CONTRACT_ADMIN: &str = "contract-admin";
pub const INITIAL_EPOCH_ID: &str = "initial-epoch-id";
pub const LAST_SUBMISSION: &str = "last-submission";
pub const MIXNET_CONTRACT: &str = "mixnet-contract";
pub const AUTHORISED_COUNT: &str = "authorised-count";
pub const AUTHORISED: &str = "authorised";
@@ -7,9 +7,9 @@ use cosmwasm_schema::cw_serde;
#[cfg(feature = "schema")]
use crate::types::{
EpochMeasurementsPagedResponse, EpochPerformancePagedResponse,
FullHistoricalPerformancePagedResponse, NetworkMonitorResponse, NetworkMonitorsPagedResponse,
NodeMeasurementsResponse, NodePerformancePagedResponse, NodePerformanceResponse,
RetiredNetworkMonitorsPagedResponse,
FullHistoricalPerformancePagedResponse, LastSubmission, NetworkMonitorResponse,
NetworkMonitorsPagedResponse, NodeMeasurementsResponse, NodePerformancePagedResponse,
NodePerformanceResponse, RetiredNetworkMonitorsPagedResponse,
};
#[cw_serde]
@@ -113,6 +113,10 @@ pub enum QueryMsg {
start_after: Option<String>,
limit: Option<u32>,
},
/// Returns information regarding the latest submitted performance data
#[cfg_attr(feature = "schema", returns(LastSubmission))]
LastSubmittedMeasurement {},
}
#[cw_serde]
@@ -2,12 +2,28 @@
// SPDX-License-Identifier: Apache-2.0
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Env};
use cosmwasm_std::{Addr, Env, Timestamp};
use nym_contracts_common::Percent;
pub type EpochId = u32;
pub type NodeId = u32;
#[cw_serde]
pub struct LastSubmission {
pub block_height: u64,
pub block_time: Timestamp,
// not as relevant, but might as well store it
pub data: Option<LastSubmittedData>,
}
#[cw_serde]
pub struct LastSubmittedData {
pub sender: Addr,
pub epoch_id: EpochId,
pub data: NodePerformance,
}
#[cw_serde]
pub struct NetworkMonitorDetails {
pub address: Addr,
+1 -1
View File
@@ -95,7 +95,7 @@ where
} else if let Some(final_timestamp) = epoch.final_timestamp_secs() {
// Use 1 additional second to not start the next iteration immediately and spam get_current_epoch queries
let secs_until_final = final_timestamp.saturating_sub(current_timestamp_secs) + 1;
info!("Approximately {} seconds until coconut is available. Sleeping until then. You can safely kill the process at any moment.", secs_until_final);
info!("Approximately {secs_until_final} seconds until coconut is available. Sleeping until then. You can safely kill the process at any moment.");
tokio::time::sleep(Duration::from_secs(secs_until_final)).await;
} else if matches!(epoch.state, EpochState::WaitingInitialisation) {
info!("dkg hasn't been initialised yet and it is not known when it will be. Going to check again later");
+2 -2
View File
@@ -7,9 +7,9 @@ use std::env;
#[tokio::main]
async fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let database_path = format!("{}/gateway-stats-example.sqlite", out_dir);
let database_path = format!("{out_dir}/gateway-stats-example.sqlite");
let mut conn = SqliteConnection::connect(&format!("sqlite://{}?mode=rwc", database_path))
let mut conn = SqliteConnection::connect(&format!("sqlite://{database_path}?mode=rwc"))
.await
.expect("Failed to create SQLx database connection");
+2 -2
View File
@@ -7,9 +7,9 @@ use std::env;
#[tokio::main]
async fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let database_path = format!("{}/gateway-example.sqlite", out_dir);
let database_path = format!("{out_dir}/gateway-example.sqlite");
let mut conn = SqliteConnection::connect(&format!("sqlite://{}?mode=rwc", database_path))
let mut conn = SqliteConnection::connect(&format!("sqlite://{database_path}?mode=rwc"))
.await
.expect("Failed to create SQLx database connection");
+1 -1
View File
@@ -37,7 +37,7 @@ impl std::fmt::Display for ClientType {
ClientType::EntryWireguard => "entry_wireguard",
ClientType::ExitWireguard => "exit_wireguard",
};
write!(f, "{}", s)
write!(f, "{s}")
}
}
+1 -1
View File
@@ -141,7 +141,7 @@ mod tests {
};
assert_eq!(
format!("{}", user_agent),
format!("{user_agent}"),
"nym-mixnode/0.11.0/x86_64-unknown-linux-gnu/abcdefg"
);
}
+1
View File
@@ -19,6 +19,7 @@ colored = { workspace = true, optional = true }
futures = { workspace = true, optional = true }
mime = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
serde_yaml = { workspace = true, optional = true }
subtle = { workspace = true, optional = true }
time = { workspace = true, optional = true, features = ["macros"] }
@@ -7,7 +7,6 @@ use axum::http::{header, HeaderValue};
use axum::response::{IntoResponse, Response};
use bytes::{BufMut, BytesMut};
use serde::Serialize;
use utoipa::gen::serde_json;
// don't use axum's Json directly as we need to be able to define custom headers
#[derive(Debug, Clone, Default)]
+1 -1
View File
@@ -191,7 +191,7 @@ impl fmt::Display for IpPacketRequestData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
IpPacketRequestData::Data(_) => write!(f, "Data"),
IpPacketRequestData::Control(c) => write!(f, "Control({})", c),
IpPacketRequestData::Control(c) => write!(f, "Control({c})"),
}
}
}
+4 -6
View File
@@ -30,7 +30,7 @@ fn main() {
for var in variables_to_track {
// if script fails, debug with `cargo check -vv``
println!("Looking for {}", var);
println!("Looking for {var}");
// read pattern that looks like:
// <var>: &str = "<whatever is between quotes>"
@@ -41,7 +41,7 @@ fn main() {
.captures(source_of_truth)
.and_then(|caps| caps.get(1).map(|match_| match_.as_str().to_string()))
.expect("Couldn't find var in source file");
println!("Storing {}={}", var, value);
println!("Storing {var}={value}");
replace_with.insert(var, value);
}
@@ -57,13 +57,11 @@ fn main() {
// <var>=<value>
let re = Regex::new(&pattern).unwrap();
contents = re
.replace(&contents, |_: &regex::Captures| {
format!(r#"{}={}"#, var, value)
})
.replace(&contents, |_: &regex::Captures| format!(r#"{var}={value}"#))
.to_string();
}
println!("File contents to write:\n{}", contents);
println!("File contents to write:\n{contents}");
if output_path.exists() {
fs::write(output_path, contents).unwrap();
} else {
+1 -1
View File
@@ -25,7 +25,7 @@ fn print_env_vars_with_keys_in_file<P: AsRef<Path> + Copy>(config_env_file: P) {
.expect("Invalid path to environment configuration file");
for item in items {
let (key, val) = item.expect("Invalid item in environment configuration file");
log::debug!("{}: {}", key, val);
log::debug!("{key}: {val}");
}
}
+1 -1
View File
@@ -119,7 +119,7 @@ impl NymNetworkDetails {
}
}
Err(VarError::NotPresent) => None,
err => panic!("Unable to set: {:?}", err),
err => panic!("Unable to set: {err:?}"),
}
}
+3 -3
View File
@@ -344,9 +344,9 @@ impl fmt::Display for MetricsController {
let metrics = self.gather();
let output = match String::from_utf8(metrics) {
Ok(output) => output,
Err(e) => return write!(f, "Error decoding metrics to String: {}", e),
Err(e) => return write!(f, "Error decoding metrics to String: {e}"),
};
write!(f, "{}", output)
write!(f, "{output}")
}
}
@@ -597,7 +597,7 @@ mod tests {
assert_eq!(literal, "nym_metrics_foo");
let bar = "bar";
let format = format!("foomp_{}", bar);
let format = format!("foomp_{bar}");
let formatted = prepend_package_name!(format);
assert_eq!(formatted, "nym_metrics_foomp_bar");
}
@@ -26,7 +26,7 @@ impl GroupParameters {
pub fn new(attributes: usize) -> GroupParameters {
assert!(attributes > 0);
let gammas = (1..=attributes)
.map(|i| hash_g1(format!("gamma{}", i)))
.map(|i| hash_g1(format!("gamma{i}")))
.collect();
let delta = hash_g1("delta");
@@ -56,6 +56,13 @@ impl ReplySurb {
packet_size.plaintext_size() - ack_overhead - ReplySurbKeyDigestAlgorithm::output_size() - 1
}
/// Construct a ResplySurb object. Selects mix hops for the surb unique to this
/// individual construction.
///
/// If mix hops are disabled, the route will consistency of the recipient
/// (i.e. the ingress hop) only. When `disable_mix_hops` is enabled
/// `use_legacy_surb_format` is ignored as disabled mix hops requires use of
/// the updated SURB format.
// TODO: should this return `ReplySURBError` for consistency sake
// or keep `NymTopologyError` because it's the only error it can actually return?
pub fn construct<R>(
@@ -64,17 +71,21 @@ impl ReplySurb {
average_delay: Duration,
use_legacy_surb_format: bool,
topology: &NymRouteProvider,
_disable_mix_hops: bool, // TODO: support SURBs with no mix hops after changes to surb format / construction
disable_mix_hops: bool,
) -> Result<Self, NymTopologyError>
where
R: RngCore + CryptoRng,
{
let route = topology.random_route_to_egress(rng, recipient.gateway())?;
let route = if disable_mix_hops {
topology.empty_route_to_egress(recipient.gateway())?
} else {
topology.random_route_to_egress(rng, recipient.gateway())?
};
let delays = nym_sphinx_routing::generate_hop_delays(average_delay, route.len());
let destination = recipient.as_sphinx_destination();
let mut surb_material = SURBMaterial::new(route, delays, destination);
if use_legacy_surb_format {
if use_legacy_surb_format && !disable_mix_hops {
surb_material = surb_material.with_version(X25519_WITH_EXPLICIT_PAYLOAD_KEYS_VERSION)
}
+4 -1
View File
@@ -335,6 +335,9 @@ pub struct MessagePreparer<R> {
/// will be routed as usual, to the entry gateway, through three mix nodes, egressing
/// through the exit gateway. If mix hops are disabled, traffic will be routed directly
/// from the entry gateway to the exit gateway, bypassing the mix nodes.
///
/// This overrides the `use_legacy_sphinx_format` setting as reduced/disabled mix hops
/// requires use of the updated SURB packet format.
pub disable_mix_hops: bool,
}
@@ -388,7 +391,7 @@ where
self.average_packet_delay,
use_legacy_reply_surb_format,
topology,
disabled_mix_hops, // TODO: support SURBs with no mix hops after changes to surb format / construction
disabled_mix_hops,
)?
.with_key_rotation(key_rotation);
reply_surbs.push(reply_surb)
@@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO validator (consensus_address, consensus_pubkey)\n VALUES ($1, $2)\n ON CONFLICT DO NOTHING\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Text",
"Text"
]
},
"nullable": []
},
"hash": "0d3709efacf763b06bf14803bb803b5ee5b27879b0026bb0480b3f2722318a75"
}
@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM pre_commit WHERE height < $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "1c2fb0e9ffceca21ef8dbea19b116422b1f723d0a316314b50c43c8b29f8891d"
}
@@ -0,0 +1,26 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO transaction\n (hash, height, index, success, messages, memo, signatures, signer_infos, fee, gas_wanted, gas_used, raw_log, logs)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)\n ON CONFLICT (hash) DO UPDATE\n SET height = excluded.height,\n index = excluded.index,\n success = excluded.success,\n messages = excluded.messages,\n memo = excluded.memo,\n signatures = excluded.signatures,\n signer_infos = excluded.signer_infos,\n fee = excluded.fee,\n gas_wanted = excluded.gas_wanted,\n gas_used = excluded.gas_used,\n raw_log = excluded.raw_log,\n logs = excluded.logs\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Text",
"Int8",
"Int4",
"Bool",
"Json",
"Text",
"TextArray",
"Jsonb",
"Jsonb",
"Int8",
"Int8",
"Text",
"Jsonb"
]
},
"nullable": []
},
"hash": "1e344c1dff8b98eb0eb2e530e28f3cb2eed5b5d35391fd30a4d5f44f2e2178b7"
}
@@ -0,0 +1,20 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT height\n FROM block\n ORDER BY height ASC\n LIMIT 1\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "height",
"type_info": "Int8"
}
],
"parameters": {
"Left": []
},
"nullable": [
false
]
},
"hash": "2561fb016951ea4cd29e43fb9a4a93e944b0d44ed1f7c1036f306e34372da11c"
}
@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE metadata SET last_processed_height = GREATEST(last_processed_height, $1)",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int4"
]
},
"nullable": []
},
"hash": "2679cdf11fa66c7920678cde860c57402119ec7c3aae731b0da831327301466f"
}
@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE pruning SET last_pruned_height = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "36ba5941aca6e7b604a10b8b0aba70635028f392fe794d6131827b083e1755e1"
}
@@ -0,0 +1,20 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT last_pruned_height FROM pruning\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "last_pruned_height",
"type_info": "Int8"
}
],
"parameters": {
"Left": []
},
"nullable": [
false
]
},
"hash": "3bdf81a9db6075f6f77224c30553f419a849d4ec45af40b052a4cbf09b44f3ec"
}
@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM message WHERE height < $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "52c27143720ddfdfd0f5644b60f5b67fd9281ce1de0653efa53b9d9b93cf335d"
}

Some files were not shown because too many files have changed in this diff Show More