fc2eedfc66
add offline ecash library minor changes in coconut benchmarks add ecash smart contract change contract traits from coconut to ecash first wave of andrew's suggestion first wave of andrew's suggestion second wave of andrew's suggestion for ecash lib andrew's suggestion for ecash contract licensing commit safety comments for most unwraps more unwrap handling change chrono crate for time latest cargo lock error revamp small visibility fix small fix remove indexedmap from contract + some tweaks add cw2 version in ecash contract remove envryption key from contract change types from coconut to ecash types adapt api model for credential issuance adapt issued credential storage on API add signatures cache on API change API routes for new blind signing modify issued_credential table add issuance logic client-side credential and signature storage client side utils for credential issuance first wave of fix some of andrew's suggestions remove encryption key from deposit freepass issuance client side freepass issuance API side andrew's suggested fixes other suggested fix adapt change from PR below allow offline verification flag credential spending models credential spending models for client credential preperation for the client credential preperation for the client credential storage for spending on client bloom filter for API spent credential storage on validators API route for spending online and offline ecash API routes in the client lib credential storage on gateway ecash verifier to replace coconut verifier accept credentials on gateway bandwidth expiration for gateways client ask for more bandwidth if it runs out credential import adapt nym validator rewarder and sdk fix tests api tests and add constants cargo fmt and lock and small test fix cargo fmt and lock and small test fix cargo lock move stuff where they belong in ecash and static parameters move some constants, error handling and phase out time crate error revamp part 2 secret key by ref instead of clone change l in wallet and v visibility rework payinfo rework monster tuples fix expiration date signature cloning minor fixes final bits and bobs fixes final bits and bobs fixes rename l accessor to tickets_spent wave of fixes second wave of fixes change hash domain value removed benchmark flag remove useless stringification in storage nuke Bandwidth voucher change timestamps to offsetdatetime key name change post-rebase fixes update nym-connect 'time' dep due to broken semver upload ecash contract to the build server make wasm zknym-lib compile but it won't work properly just yet make wasm zknym-lib compile but it won't work properly just yet fix typo in ecash contract deps make sure to use 0.1.0 sphinx packet optimise pairings in 'check_vk_pairing' derive serde for ecash types simplified g1 tuple byte conversion further optimise the pairing unified signature type + renamed nym-api coconut module to ecash using bincode serialiser for more complex binary types using multimiller loop instead of rayon for verifying coin indices signatures batching signature verification wherever possible feature-locked rayon clippy refactor ecash contract a bit + introduce deposit storage reworked find_proposal_id various minor fixed add offline_zk_nyms to nym-node everywhere add missing #query change test value to fit new serialization optimised deposits storage removed duplicate decompression code using deposit_id instead of transaction hash removed freepasses split up ecash handling unified shared state fixed deposit_id parsing log recovered deposit id removed online verification add detailed build info to ecash contract fixed deserialisation of deposit amount received from nyxd queries changed deposit to only persist attached pubkey first iteration of split of verification and redemption basic tool for setting up new network expanded the tool with the option to bypass DKG rename + init network without DKG setting up locally running apis ecash key migration more local functionalities wip fixing sql schemas gateway immediately submitting redemption proposal and getting it passed if valid most of the gateway logic for split redemption with error recovery fixed gateway not persisting ecash signers simplify creation of compatible client create properly serialised ecash key from the beginning rebuild missing tickets and proposals on startup stop ticket issuance during DKG transition fixing build issues split out ecash storage on nym-api side master-verification-key route caching all the signatures and keys implemented aggregated routes for nym-apis swagger UI for ecash endpoints added explicit annotation for index and expiration signatures revamped client ticketbook storage save all recovery information in the same underlying storage wrapper for bloomfilter being more aggressive with marking tickets as used ensure client has correct signatures before making deposit fix deserialisation of AggregatedExpirationDateSignatureResponse + add ticketbook table split nym-api ecash routes handlers into multiple files fixed deserialisation of encoded expiration date add tt_gamma1 to challenge and change naming for paper consistency rotating double spending bloomfilter nym-api test fixes + make sure to insert initial BF params fixed ecash benchmark code updated contract schema updated CI to not upload gateway/mixnode binaries ticket bandwidth revocation added default deserialisation for zk nym config post-rebase fixes
107 lines
3.9 KiB
Rust
107 lines
3.9 KiB
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
use crate::commands::helpers::{initialise_local_network_requester, try_load_current_config};
|
|
use clap::Args;
|
|
use nym_bin_common::output_format::OutputFormat;
|
|
use nym_gateway::helpers::{load_public_key, OverrideNetworkRequesterConfig};
|
|
use std::io::IsTerminal;
|
|
use std::path::PathBuf;
|
|
use std::time::Duration;
|
|
use tracing::warn;
|
|
|
|
#[derive(Args, Clone)]
|
|
pub struct CmdArgs {
|
|
/// The id of the gateway you want to initialise local network requester for.
|
|
#[clap(long)]
|
|
id: String,
|
|
|
|
/// Path to custom location for network requester's config.
|
|
#[clap(long)]
|
|
custom_config_path: Option<PathBuf>,
|
|
|
|
/// Specify whether the network requester should be enabled.
|
|
// (you might want to create all the configs, generate keys, etc. but not actually run the NR just yet)
|
|
#[clap(long)]
|
|
enabled: Option<bool>,
|
|
|
|
// note: those flags are set as bools as we want to explicitly override any settings values
|
|
// so say `open_proxy` was set to true in the config.toml. youd have to explicitly state `open-proxy=false`
|
|
// as an argument here to override it as opposed to not providing the value at all.
|
|
/// Specifies whether this network requester should run in 'open-proxy' mode
|
|
#[clap(long)]
|
|
open_proxy: Option<bool>,
|
|
|
|
/// Mostly debug-related option to increase default traffic rate so that you would not need to
|
|
/// modify config post init
|
|
#[clap(long, hide = true, conflicts_with = "medium_toggle")]
|
|
fastmode: bool,
|
|
|
|
/// Disable loop cover traffic and the Poisson rate limiter (for debugging only)
|
|
#[clap(long, hide = true, conflicts_with = "medium_toggle")]
|
|
no_cover: bool,
|
|
|
|
/// Enable medium mixnet traffic, for experiments only.
|
|
/// This includes things like disabling cover traffic, no per hop delays, etc.
|
|
#[clap(
|
|
long,
|
|
hide = true,
|
|
conflicts_with = "no_cover",
|
|
conflicts_with = "fastmode"
|
|
)]
|
|
medium_toggle: bool,
|
|
|
|
#[clap(short, long, default_value_t = OutputFormat::default())]
|
|
output: OutputFormat,
|
|
}
|
|
|
|
impl<'a> From<&'a CmdArgs> for OverrideNetworkRequesterConfig {
|
|
fn from(value: &'a CmdArgs) -> Self {
|
|
OverrideNetworkRequesterConfig {
|
|
fastmode: value.fastmode,
|
|
no_cover: value.no_cover,
|
|
medium_toggle: value.medium_toggle,
|
|
open_proxy: value.open_proxy,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub async fn execute(args: CmdArgs) -> anyhow::Result<()> {
|
|
warn!("standalone gateways have been deprecated - please consider migrating it to a `nym-node` via `nym-node migrate gateway` command");
|
|
if std::io::stdout().is_terminal() {
|
|
// if user is running it in terminal session,
|
|
// introduce the delay, so they'd notice the message
|
|
tokio::time::sleep(Duration::from_secs(1)).await
|
|
}
|
|
|
|
let mut config = try_load_current_config(&args.id)?;
|
|
let opts = (&args).into();
|
|
|
|
// if somebody provided config file of a custom NR, that's fine
|
|
// but in 90% cases, I'd assume, it won't work due to invalid gateway configuration
|
|
// but it might be nice to be able to move files around.
|
|
if let Some(custom_config_path) = args.custom_config_path {
|
|
// if you specified anything as the argument, overwrite whatever was already in the config file
|
|
config.storage_paths.network_requester_config = Some(custom_config_path);
|
|
}
|
|
|
|
if let Some(override_enabled) = args.enabled {
|
|
config.network_requester.enabled = override_enabled;
|
|
}
|
|
|
|
if config.storage_paths.network_requester_config.is_none() {
|
|
config = config.with_default_network_requester_config_path()
|
|
}
|
|
|
|
let identity_public_key = load_public_key(
|
|
&config.storage_paths.keys.public_identity_key_file,
|
|
"gateway identity",
|
|
)?;
|
|
let details = initialise_local_network_requester(&config, opts, identity_public_key).await?;
|
|
config.try_save()?;
|
|
|
|
args.output.to_stdout(&details);
|
|
|
|
Ok(())
|
|
}
|