Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dcd1776b5 | |||
| e3169c95c6 |
@@ -376,11 +376,7 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn simulate<I, M>(
|
pub async fn simulate<I, M>(&self, messages: I) -> Result<SimulateResponse, NyxdError>
|
||||||
&self,
|
|
||||||
messages: I,
|
|
||||||
memo: impl Into<String> + Send + 'static,
|
|
||||||
) -> Result<SimulateResponse, NyxdError>
|
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = M> + Send,
|
I: IntoIterator<Item = M> + Send,
|
||||||
M: Msg,
|
M: Msg,
|
||||||
@@ -395,7 +391,7 @@ where
|
|||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
NyxdError::SerializationError("custom simulate messages".to_owned())
|
NyxdError::SerializationError("custom simulate messages".to_owned())
|
||||||
})?,
|
})?,
|
||||||
memo,
|
"simulating execution of transactions",
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl GatewayBond {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct GatewayNodeDetailsResponse {
|
pub struct GatewayNodeDetailsResponse {
|
||||||
pub identity_key: String,
|
pub identity_key: String,
|
||||||
pub sphinx_key: String,
|
pub sphinx_key: String,
|
||||||
@@ -88,7 +88,6 @@ pub struct GatewayNodeDetailsResponse {
|
|||||||
pub data_store: String,
|
pub data_store: String,
|
||||||
|
|
||||||
pub network_requester: Option<GatewayNetworkRequesterDetails>,
|
pub network_requester: Option<GatewayNetworkRequesterDetails>,
|
||||||
pub ip_packet_router: Option<GatewayIpPacketRouterDetails>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for GatewayNodeDetailsResponse {
|
impl fmt::Display for GatewayNodeDetailsResponse {
|
||||||
@@ -99,7 +98,7 @@ impl fmt::Display for GatewayNodeDetailsResponse {
|
|||||||
writeln!(f, "bind address: {}", self.bind_address)?;
|
writeln!(f, "bind address: {}", self.bind_address)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
"mix port: {}, clients port: {}",
|
"mix Port: {}, clients port: {}",
|
||||||
self.mix_port, self.clients_port
|
self.mix_port, self.clients_port
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -108,15 +107,11 @@ impl fmt::Display for GatewayNodeDetailsResponse {
|
|||||||
if let Some(nr) = &self.network_requester {
|
if let Some(nr) = &self.network_requester {
|
||||||
nr.fmt(f)?;
|
nr.fmt(f)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ipr) = &self.ip_packet_router {
|
|
||||||
ipr.fmt(f)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct GatewayNetworkRequesterDetails {
|
pub struct GatewayNetworkRequesterDetails {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
|
|
||||||
@@ -154,7 +149,7 @@ impl fmt::Display for GatewayNetworkRequesterDetails {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct GatewayIpPacketRouterDetails {
|
pub struct GatewayIpPacketRouterDetails {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
|
|
||||||
@@ -169,7 +164,7 @@ pub struct GatewayIpPacketRouterDetails {
|
|||||||
|
|
||||||
impl fmt::Display for GatewayIpPacketRouterDetails {
|
impl fmt::Display for GatewayIpPacketRouterDetails {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
writeln!(f, "ip packet router:")?;
|
writeln!(f, "IP packet router:")?;
|
||||||
writeln!(f, "\tenabled: {}", self.enabled)?;
|
writeln!(f, "\tenabled: {}", self.enabled)?;
|
||||||
writeln!(f, "\tconfig path: {}", self.config_path)?;
|
writeln!(f, "\tconfig path: {}", self.config_path)?;
|
||||||
|
|
||||||
|
|||||||
@@ -127,26 +127,7 @@ pub fn query(deps: Deps<'_>, _env: Env, msg: QueryMsg) -> Result<QueryResponse,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[entry_point]
|
#[entry_point]
|
||||||
pub fn migrate(deps: DepsMut<'_>, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
|
pub fn migrate(_deps: DepsMut<'_>, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
|
||||||
let mut current_epoch = CURRENT_EPOCH.load(deps.storage)?;
|
|
||||||
current_epoch
|
|
||||||
.time_configuration
|
|
||||||
.public_key_submission_time_secs = 1200;
|
|
||||||
current_epoch.time_configuration.dealing_exchange_time_secs = 1200;
|
|
||||||
current_epoch
|
|
||||||
.time_configuration
|
|
||||||
.verification_key_submission_time_secs = 600;
|
|
||||||
current_epoch
|
|
||||||
.time_configuration
|
|
||||||
.verification_key_validation_time_secs = 600;
|
|
||||||
current_epoch
|
|
||||||
.time_configuration
|
|
||||||
.verification_key_finalization_time_secs = 600;
|
|
||||||
current_epoch.time_configuration.in_progress_time_secs = 60 * 60 * 24 * 365 * 10;
|
|
||||||
|
|
||||||
CURRENT_EPOCH.save(deps.storage, ¤t_epoch)?;
|
|
||||||
|
|
||||||
//
|
|
||||||
Ok(Default::default())
|
Ok(Default::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ type DealingKey<'a> = &'a Addr;
|
|||||||
// if TOTAL_DEALINGS is modified to anything other then current value (5), this part will also need
|
// if TOTAL_DEALINGS is modified to anything other then current value (5), this part will also need
|
||||||
// to be modified
|
// to be modified
|
||||||
pub(crate) const DEALINGS_BYTES: [Map<'_, DealingKey<'_>, ContractSafeBytes>; TOTAL_DEALINGS] = [
|
pub(crate) const DEALINGS_BYTES: [Map<'_, DealingKey<'_>, ContractSafeBytes>; TOTAL_DEALINGS] = [
|
||||||
Map::new("dbyt1-tmp2"),
|
Map::new("dbyt1"),
|
||||||
Map::new("dbyt2-tmp2"),
|
Map::new("dbyt2"),
|
||||||
Map::new("dbyt3-tmp2"),
|
Map::new("dbyt3"),
|
||||||
Map::new("dbyt4-tmp2"),
|
Map::new("dbyt4"),
|
||||||
Map::new("dbyt5-tmp2"),
|
Map::new("dbyt5"),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -103,50 +103,10 @@ fn load_network_requester_details(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_ip_packet_router_details(
|
|
||||||
config: &Config,
|
|
||||||
ip_packet_router_config: &nym_ip_packet_router::Config,
|
|
||||||
) -> Result<api_requests::v1::ip_packet_router::models::IpPacketRouter, GatewayError> {
|
|
||||||
let identity_public_key: identity::PublicKey = load_public_key(
|
|
||||||
&ip_packet_router_config
|
|
||||||
.storage_paths
|
|
||||||
.common_paths
|
|
||||||
.keys
|
|
||||||
.public_identity_key_file,
|
|
||||||
"ip packet router identity",
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let dh_public_key: encryption::PublicKey = load_public_key(
|
|
||||||
&ip_packet_router_config
|
|
||||||
.storage_paths
|
|
||||||
.common_paths
|
|
||||||
.keys
|
|
||||||
.public_encryption_key_file,
|
|
||||||
"ip packet router diffie hellman",
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let gateway_identity_public_key: identity::PublicKey = load_public_key(
|
|
||||||
&config.storage_paths.keys.public_identity_key_file,
|
|
||||||
"gateway identity",
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(api_requests::v1::ip_packet_router::models::IpPacketRouter {
|
|
||||||
encoded_identity_key: identity_public_key.to_base58_string(),
|
|
||||||
encoded_x25519_key: dh_public_key.to_base58_string(),
|
|
||||||
address: Recipient::new(
|
|
||||||
identity_public_key,
|
|
||||||
dh_public_key,
|
|
||||||
gateway_identity_public_key,
|
|
||||||
)
|
|
||||||
.to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct HttpApiBuilder<'a> {
|
pub(crate) struct HttpApiBuilder<'a> {
|
||||||
gateway_config: &'a Config,
|
gateway_config: &'a Config,
|
||||||
network_requester_config: Option<&'a nym_network_requester::Config>,
|
network_requester_config: Option<&'a nym_network_requester::Config>,
|
||||||
exit_policy: Option<UsedExitPolicy>,
|
exit_policy: Option<UsedExitPolicy>,
|
||||||
ip_packet_router_config: Option<&'a nym_ip_packet_router::Config>,
|
|
||||||
|
|
||||||
identity_keypair: &'a identity::KeyPair,
|
identity_keypair: &'a identity::KeyPair,
|
||||||
// TODO: this should be a wg specific key and not re-used sphinx
|
// TODO: this should be a wg specific key and not re-used sphinx
|
||||||
@@ -164,7 +124,6 @@ impl<'a> HttpApiBuilder<'a> {
|
|||||||
HttpApiBuilder {
|
HttpApiBuilder {
|
||||||
gateway_config,
|
gateway_config,
|
||||||
network_requester_config: None,
|
network_requester_config: None,
|
||||||
ip_packet_router_config: None,
|
|
||||||
exit_policy: None,
|
exit_policy: None,
|
||||||
identity_keypair,
|
identity_keypair,
|
||||||
sphinx_keypair,
|
sphinx_keypair,
|
||||||
@@ -228,15 +187,6 @@ impl<'a> HttpApiBuilder<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
pub(crate) fn with_maybe_ip_packet_router(
|
|
||||||
mut self,
|
|
||||||
ip_packet_router_config: Option<&'a nym_ip_packet_router::Config>,
|
|
||||||
) -> Self {
|
|
||||||
self.ip_packet_router_config = ip_packet_router_config;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub(crate) fn with_wireguard_client_registry(
|
pub(crate) fn with_wireguard_client_registry(
|
||||||
mut self,
|
mut self,
|
||||||
@@ -275,13 +225,6 @@ impl<'a> HttpApiBuilder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ipr_config) = self.ip_packet_router_config {
|
|
||||||
config = config.with_ip_packet_router(load_ip_packet_router_details(
|
|
||||||
self.gateway_config,
|
|
||||||
ipr_config,
|
|
||||||
)?);
|
|
||||||
}
|
|
||||||
|
|
||||||
let wireguard_private_network = IpNetwork::new(
|
let wireguard_private_network = IpNetwork::new(
|
||||||
IpAddr::from(Ipv4Addr::new(10, 1, 0, 0)),
|
IpAddr::from(Ipv4Addr::new(10, 1, 0, 0)),
|
||||||
self.gateway_config.wireguard.private_network_prefix,
|
self.gateway_config.wireguard.private_network_prefix,
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ use nym_crypto::asymmetric::{encryption, identity};
|
|||||||
use nym_pemstore::traits::{PemStorableKey, PemStorableKeyPair};
|
use nym_pemstore::traits::{PemStorableKey, PemStorableKeyPair};
|
||||||
use nym_pemstore::KeyPairPath;
|
use nym_pemstore::KeyPairPath;
|
||||||
use nym_sphinx::addressing::clients::Recipient;
|
use nym_sphinx::addressing::clients::Recipient;
|
||||||
use nym_types::gateway::{
|
use nym_types::gateway::{GatewayNetworkRequesterDetails, GatewayNodeDetailsResponse};
|
||||||
GatewayIpPacketRouterDetails, GatewayNetworkRequesterDetails, GatewayNodeDetailsResponse,
|
|
||||||
};
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn display_maybe_path<P: AsRef<Path>>(path: Option<P>) -> String {
|
fn display_maybe_path<P: AsRef<Path>>(path: Option<P>) -> String {
|
||||||
@@ -73,40 +71,6 @@ pub(crate) fn node_details(config: &Config) -> Result<GatewayNodeDetailsResponse
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let ip_packet_router = if let Some(nr_cfg_path) = &config.storage_paths.ip_packet_router_config
|
|
||||||
{
|
|
||||||
let cfg = load_ip_packet_router_config(&config.gateway.id, nr_cfg_path)?;
|
|
||||||
|
|
||||||
let nr_identity_public_key: identity::PublicKey = load_public_key(
|
|
||||||
&cfg.storage_paths.common_paths.keys.public_identity_key_file,
|
|
||||||
"ip packet router identity",
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let nr_encryption_key: encryption::PublicKey = load_public_key(
|
|
||||||
&cfg.storage_paths
|
|
||||||
.common_paths
|
|
||||||
.keys
|
|
||||||
.public_encryption_key_file,
|
|
||||||
"ip packet router encryption",
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let address = Recipient::new(
|
|
||||||
nr_identity_public_key,
|
|
||||||
nr_encryption_key,
|
|
||||||
gateway_identity_public_key,
|
|
||||||
);
|
|
||||||
|
|
||||||
Some(GatewayIpPacketRouterDetails {
|
|
||||||
enabled: config.ip_packet_router.enabled,
|
|
||||||
identity_key: nr_identity_public_key.to_base58_string(),
|
|
||||||
encryption_key: nr_encryption_key.to_base58_string(),
|
|
||||||
address: address.to_string(),
|
|
||||||
config_path: display_path(nr_cfg_path),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(GatewayNodeDetailsResponse {
|
Ok(GatewayNodeDetailsResponse {
|
||||||
identity_key: gateway_identity_public_key.to_base58_string(),
|
identity_key: gateway_identity_public_key.to_base58_string(),
|
||||||
sphinx_key: gateway_sphinx_public_key.to_base58_string(),
|
sphinx_key: gateway_sphinx_public_key.to_base58_string(),
|
||||||
@@ -116,7 +80,6 @@ pub(crate) fn node_details(config: &Config) -> Result<GatewayNodeDetailsResponse
|
|||||||
config_path: display_maybe_path(config.save_path.as_ref()),
|
config_path: display_maybe_path(config.save_path.as_ref()),
|
||||||
data_store: display_path(&config.storage_paths.clients_storage),
|
data_store: display_path(&config.storage_paths.clients_storage),
|
||||||
network_requester,
|
network_requester,
|
||||||
ip_packet_router,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -519,7 +519,6 @@ impl<St> Gateway<St> {
|
|||||||
.with_wireguard_client_registry(self.client_registry.clone())
|
.with_wireguard_client_registry(self.client_registry.clone())
|
||||||
.with_maybe_network_requester(self.network_requester_opts.as_ref().map(|o| &o.config))
|
.with_maybe_network_requester(self.network_requester_opts.as_ref().map(|o| &o.config))
|
||||||
.with_maybe_network_request_filter(nr_request_filter)
|
.with_maybe_network_request_filter(nr_request_filter)
|
||||||
.with_maybe_ip_packet_router(self.ip_packet_router_opts.as_ref().map(|o| &o.config))
|
|
||||||
.start(shutdown.subscribe().named("http-api"))?;
|
.start(shutdown.subscribe().named("http-api"))?;
|
||||||
|
|
||||||
// Once this is a bit more mature, make this a commandline flag instead of a compile time
|
// Once this is a bit more mature, make this a commandline flag instead of a compile time
|
||||||
|
|||||||
@@ -366,9 +366,6 @@ pub struct NymNodeDescription {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub network_requester: Option<NetworkRequesterDetails>,
|
pub network_requester: Option<NetworkRequesterDetails>,
|
||||||
|
|
||||||
#[serde(default)]
|
|
||||||
pub ip_packet_router: Option<IpPacketRouterDetails>,
|
|
||||||
|
|
||||||
// for now we only care about their ws/wss situation, nothing more
|
// for now we only care about their ws/wss situation, nothing more
|
||||||
pub mixnet_websockets: WebSockets,
|
pub mixnet_websockets: WebSockets,
|
||||||
}
|
}
|
||||||
@@ -396,9 +393,3 @@ pub struct NetworkRequesterDetails {
|
|||||||
/// flag indicating whether this network requester uses the exit policy rather than the deprecated allow list
|
/// flag indicating whether this network requester uses the exit policy rather than the deprecated allow list
|
||||||
pub uses_exit_policy: bool,
|
pub uses_exit_policy: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, schemars::JsonSchema)]
|
|
||||||
pub struct IpPacketRouterDetails {
|
|
||||||
/// address of the embedded ip packet router
|
|
||||||
pub address: String,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ use crate::coconut::keypair::KeyPair as CoconutKeyPair;
|
|||||||
use crate::nyxd;
|
use crate::nyxd;
|
||||||
use crate::support::config;
|
use crate::support::config;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use nym_coconut_dkg_common::types::EpochState;
|
use nym_coconut_dkg_common::types::{Epoch, EpochState};
|
||||||
use nym_dkg::bte::keys::KeyPair as DkgKeyPair;
|
use nym_dkg::bte::keys::KeyPair as DkgKeyPair;
|
||||||
use nym_task::{TaskClient, TaskManager};
|
use nym_task::{TaskClient, TaskManager};
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use rand::{CryptoRng, RngCore};
|
use rand::{CryptoRng, RngCore};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::Duration;
|
||||||
|
use time::OffsetDateTime;
|
||||||
use tokio::time::interval;
|
use tokio::time::interval;
|
||||||
|
|
||||||
pub(crate) fn init_keypair(config: &config::CoconutSigner) -> Result<()> {
|
pub(crate) fn init_keypair(config: &config::CoconutSigner) -> Result<()> {
|
||||||
@@ -97,99 +98,121 @@ impl<R: RngCore + CryptoRng + Clone> DkgController<R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn handle_epoch_state(&mut self) {
|
async fn maybe_advance_dkg_state(&self, epoch: Epoch) {
|
||||||
match self.dkg_client.get_current_epoch().await {
|
let end =
|
||||||
Err(err) => warn!("Could not get current epoch state {err}"),
|
OffsetDateTime::from_unix_timestamp(epoch.finish_timestamp.seconds() as i64).unwrap();
|
||||||
Ok(epoch) => {
|
|
||||||
if self
|
let remaining = end - OffsetDateTime::now_utc();
|
||||||
.dkg_client
|
|
||||||
.group_member()
|
// TODO: after debugging is finished, change that to `debug!`
|
||||||
.await
|
info!(
|
||||||
.map(|resp| resp.weight.is_none())
|
"there are {} seconds until the current DKG epoch [stage] end",
|
||||||
.unwrap_or(true)
|
remaining.whole_seconds()
|
||||||
{
|
);
|
||||||
debug!("Not a member of the group, DKG won't be run");
|
|
||||||
return;
|
if remaining.is_negative() {
|
||||||
}
|
// We try advancing the epoch state, on a best-effort basis
|
||||||
if let Err(err) = self.state.is_consistent(epoch.state).await {
|
info!("DKG: Trying to advance the epoch");
|
||||||
debug!("Epoch state is corrupted - {err}. Awaiting for a DKG restart.");
|
if let Err(err) = self.dkg_client.advance_epoch_state().await {
|
||||||
} else {
|
error!("failed to advance DKG epoch: {err}")
|
||||||
let ret = match epoch.state {
|
|
||||||
EpochState::PublicKeySubmission { resharing } => {
|
|
||||||
public_key_submission(&self.dkg_client, &mut self.state, resharing)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
EpochState::DealingExchange { resharing } => {
|
|
||||||
dealing_exchange(
|
|
||||||
&self.dkg_client,
|
|
||||||
&mut self.state,
|
|
||||||
self.rng.clone(),
|
|
||||||
resharing,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeySubmission { resharing } => {
|
|
||||||
let keypair_path = nym_pemstore::KeyPairPath::new(
|
|
||||||
self.secret_key_path.clone(),
|
|
||||||
self.verification_key_path.clone(),
|
|
||||||
);
|
|
||||||
verification_key_submission(
|
|
||||||
&self.dkg_client,
|
|
||||||
&mut self.state,
|
|
||||||
&keypair_path,
|
|
||||||
resharing,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyValidation { resharing } => {
|
|
||||||
verification_key_validation(
|
|
||||||
&self.dkg_client,
|
|
||||||
&mut self.state,
|
|
||||||
resharing,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyFinalization { resharing } => {
|
|
||||||
verification_key_finalization(
|
|
||||||
&self.dkg_client,
|
|
||||||
&mut self.state,
|
|
||||||
resharing,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
// Just wait, in case we need to redo dkg at some point
|
|
||||||
EpochState::InProgress => {
|
|
||||||
self.state.set_was_in_progress();
|
|
||||||
// We're dumping state here so that we don't do it uselessly during the
|
|
||||||
// long InProgress state
|
|
||||||
self.dump_persistent_state().await;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if let Err(err) = ret {
|
|
||||||
warn!("Could not handle this iteration for the epoch state: {err}");
|
|
||||||
} else if epoch.state != EpochState::InProgress {
|
|
||||||
self.dump_persistent_state().await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Ok(current_timestamp) =
|
|
||||||
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)
|
|
||||||
{
|
|
||||||
if current_timestamp.as_secs() >= epoch.finish_timestamp.seconds() {
|
|
||||||
// We try advancing the epoch state, on a best-effort basis
|
|
||||||
info!("DKG: Trying to advance the epoch");
|
|
||||||
self.dkg_client.advance_epoch_state().await.ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn handle_epoch_state(&mut self) {
|
||||||
|
let epoch = match self.dkg_client.get_current_epoch().await {
|
||||||
|
Ok(epoch) => epoch,
|
||||||
|
Err(err) => {
|
||||||
|
warn!("Could not get current epoch state: {err}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if self
|
||||||
|
.dkg_client
|
||||||
|
.group_member()
|
||||||
|
.await
|
||||||
|
.map(|resp| resp.weight.is_none())
|
||||||
|
.unwrap_or(true)
|
||||||
|
{
|
||||||
|
debug!("Not a member of the group, DKG won't be run");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(err) = self.state.is_consistent(epoch.state).await {
|
||||||
|
warn!("Epoch state is corrupted - {err}. Awaiting for a DKG restart.");
|
||||||
|
self.maybe_advance_dkg_state(epoch).await;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let ret = match epoch.state {
|
||||||
|
EpochState::PublicKeySubmission { resharing } => {
|
||||||
|
info!("attempting to perform DKG key submission");
|
||||||
|
public_key_submission(&self.dkg_client, &mut self.state, resharing).await
|
||||||
|
}
|
||||||
|
EpochState::DealingExchange { resharing } => {
|
||||||
|
info!("attempting to perform DKG dealing exchange");
|
||||||
|
dealing_exchange(
|
||||||
|
&self.dkg_client,
|
||||||
|
&mut self.state,
|
||||||
|
self.rng.clone(),
|
||||||
|
resharing,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
EpochState::VerificationKeySubmission { resharing } => {
|
||||||
|
info!("attempting to perform DKG verification key submission");
|
||||||
|
let keypair_path = nym_pemstore::KeyPairPath::new(
|
||||||
|
self.secret_key_path.clone(),
|
||||||
|
self.verification_key_path.clone(),
|
||||||
|
);
|
||||||
|
verification_key_submission(
|
||||||
|
&self.dkg_client,
|
||||||
|
&mut self.state,
|
||||||
|
&keypair_path,
|
||||||
|
resharing,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
EpochState::VerificationKeyValidation { resharing } => {
|
||||||
|
info!("attempting to perform DKG verification key validation");
|
||||||
|
verification_key_validation(&self.dkg_client, &mut self.state, resharing).await
|
||||||
|
}
|
||||||
|
EpochState::VerificationKeyFinalization { resharing } => {
|
||||||
|
info!("attempting to perform DKG verification key finalization");
|
||||||
|
verification_key_finalization(&self.dkg_client, &mut self.state, resharing).await
|
||||||
|
}
|
||||||
|
// Just wait, in case we need to redo dkg at some point
|
||||||
|
EpochState::InProgress => {
|
||||||
|
info!(
|
||||||
|
"DKG epoch is in progress - dumping the persistent state to {}",
|
||||||
|
self.state.persistent_state_path().display()
|
||||||
|
);
|
||||||
|
|
||||||
|
self.state.set_was_in_progress();
|
||||||
|
// We're dumping state here so that we don't do it uselessly during the
|
||||||
|
// long InProgress state
|
||||||
|
self.dump_persistent_state().await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Err(err) = ret {
|
||||||
|
warn!("Could not handle this iteration for the epoch state: {err}");
|
||||||
|
} else if epoch.state != EpochState::InProgress {
|
||||||
|
self.dump_persistent_state().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.maybe_advance_dkg_state(epoch).await
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) async fn run(mut self, mut shutdown: TaskClient) {
|
pub(crate) async fn run(mut self, mut shutdown: TaskClient) {
|
||||||
let mut interval = interval(self.polling_rate);
|
let mut interval = interval(self.polling_rate);
|
||||||
while !shutdown.is_shutdown() {
|
while !shutdown.is_shutdown() {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = interval.tick() => self.handle_epoch_state().await,
|
_ = interval.tick() => {
|
||||||
|
info!("DkgController tick (this should be happening every {:?}", self.polling_rate);
|
||||||
|
self.handle_epoch_state().await
|
||||||
|
}
|
||||||
_ = shutdown.recv() => {
|
_ = shutdown.recv() => {
|
||||||
trace!("DkgController: Received shutdown");
|
trace!("DkgController: Received shutdown");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ use crate::support::caching::refresher::{CacheItemProvider, CacheRefresher};
|
|||||||
use crate::support::config;
|
use crate::support::config;
|
||||||
use crate::support::config::DEFAULT_NODE_DESCRIBE_BATCH_SIZE;
|
use crate::support::config::DEFAULT_NODE_DESCRIBE_BATCH_SIZE;
|
||||||
use futures_util::{stream, StreamExt};
|
use futures_util::{stream, StreamExt};
|
||||||
use nym_api_requests::models::{
|
use nym_api_requests::models::{NetworkRequesterDetails, NymNodeDescription};
|
||||||
IpPacketRouterDetails, NetworkRequesterDetails, NymNodeDescription,
|
|
||||||
};
|
|
||||||
use nym_config::defaults::{mainnet, DEFAULT_NYM_NODE_HTTP_PORT};
|
use nym_config::defaults::{mainnet, DEFAULT_NYM_NODE_HTTP_PORT};
|
||||||
use nym_contracts_common::IdentityKey;
|
use nym_contracts_common::IdentityKey;
|
||||||
use nym_mixnet_contract_common::Gateway;
|
use nym_mixnet_contract_common::Gateway;
|
||||||
@@ -172,19 +170,10 @@ async fn get_gateway_description(
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let ip_packet_router = if let Ok(ipr) = client.get_ip_packet_router().await {
|
|
||||||
Some(IpPacketRouterDetails {
|
|
||||||
address: ipr.address,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let description = NymNodeDescription {
|
let description = NymNodeDescription {
|
||||||
host_information: host_info.data,
|
host_information: host_info.data,
|
||||||
build_information: build_info,
|
build_information: build_info,
|
||||||
network_requester,
|
network_requester,
|
||||||
ip_packet_router,
|
|
||||||
mixnet_websockets: websockets,
|
mixnet_websockets: websockets,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ impl crate::coconut::client::Client for Client {
|
|||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<(), CoconutError> {
|
) -> Result<(), CoconutError> {
|
||||||
self.0
|
self.0
|
||||||
.write()
|
.read()
|
||||||
.await
|
.await
|
||||||
.vote_proposal(proposal_id, vote_yes, fee)
|
.vote_proposal(proposal_id, vote_yes, fee)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -384,7 +384,7 @@ impl crate::coconut::client::Client for Client {
|
|||||||
|
|
||||||
async fn execute_proposal(&self, proposal_id: u64) -> crate::coconut::error::Result<()> {
|
async fn execute_proposal(&self, proposal_id: u64) -> crate::coconut::error::Result<()> {
|
||||||
self.0
|
self.0
|
||||||
.write()
|
.read()
|
||||||
.await
|
.await
|
||||||
.execute_proposal(proposal_id, None)
|
.execute_proposal(proposal_id, None)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use nym_bin_common::build_information::BinaryBuildInformationOwned;
|
|||||||
use nym_wireguard_types::{ClientMessage, ClientRegistrationResponse};
|
use nym_wireguard_types::{ClientMessage, ClientRegistrationResponse};
|
||||||
|
|
||||||
use crate::api::v1::health::models::NodeHealth;
|
use crate::api::v1::health::models::NodeHealth;
|
||||||
use crate::api::v1::ip_packet_router::models::IpPacketRouter;
|
|
||||||
use crate::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
use crate::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
||||||
use crate::api::v1::network_requester::models::NetworkRequester;
|
use crate::api::v1::network_requester::models::NetworkRequester;
|
||||||
pub use http_api_client::Client;
|
pub use http_api_client::Client;
|
||||||
@@ -55,11 +54,6 @@ pub trait NymNodeApiClientExt: ApiClient {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_ip_packet_router(&self) -> Result<IpPacketRouter, NymNodeApiClientError> {
|
|
||||||
self.get_json_from(routes::api::v1::ip_packet_router_absolute())
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn post_gateway_register_client(
|
async fn post_gateway_register_client(
|
||||||
&self,
|
&self,
|
||||||
client_message: &ClientMessage,
|
client_message: &ClientMessage,
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
pub mod models;
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
use schemars::JsonSchema;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
|
|
||||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
|
||||||
pub struct IpPacketRouter {
|
|
||||||
/// Base58 encoded ed25519 EdDSA public key of the ip-packet-router.
|
|
||||||
pub encoded_identity_key: String,
|
|
||||||
|
|
||||||
/// Base58-encoded x25519 public key used for performing key exchange with remote clients.
|
|
||||||
pub encoded_x25519_key: String,
|
|
||||||
|
|
||||||
/// Nym address of this ip packet router.
|
|
||||||
pub address: String,
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
pub mod gateway;
|
pub mod gateway;
|
||||||
pub mod health;
|
pub mod health;
|
||||||
pub mod ip_packet_router;
|
|
||||||
pub mod mixnode;
|
pub mod mixnode;
|
||||||
pub mod network_requester;
|
pub mod network_requester;
|
||||||
pub mod node;
|
pub mod node;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ pub struct NodeRoles {
|
|||||||
pub mixnode_enabled: bool,
|
pub mixnode_enabled: bool,
|
||||||
pub gateway_enabled: bool,
|
pub gateway_enabled: bool,
|
||||||
pub network_requester_enabled: bool,
|
pub network_requester_enabled: bool,
|
||||||
pub ip_packet_router_enabled: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ pub mod routes {
|
|||||||
pub const GATEWAY: &str = "/gateway";
|
pub const GATEWAY: &str = "/gateway";
|
||||||
pub const MIXNODE: &str = "/mixnode";
|
pub const MIXNODE: &str = "/mixnode";
|
||||||
pub const NETWORK_REQUESTER: &str = "/network-requester";
|
pub const NETWORK_REQUESTER: &str = "/network-requester";
|
||||||
pub const IP_PACKET_ROUTER: &str = "/ip-packet-router";
|
|
||||||
pub const SWAGGER: &str = "/swagger";
|
pub const SWAGGER: &str = "/swagger";
|
||||||
|
|
||||||
// define helper functions to get absolute routes
|
// define helper functions to get absolute routes
|
||||||
@@ -44,7 +43,6 @@ pub mod routes {
|
|||||||
absolute_route!(gateway_absolute, v1_absolute(), GATEWAY);
|
absolute_route!(gateway_absolute, v1_absolute(), GATEWAY);
|
||||||
absolute_route!(mixnode_absolute, v1_absolute(), MIXNODE);
|
absolute_route!(mixnode_absolute, v1_absolute(), MIXNODE);
|
||||||
absolute_route!(network_requester_absolute, v1_absolute(), NETWORK_REQUESTER);
|
absolute_route!(network_requester_absolute, v1_absolute(), NETWORK_REQUESTER);
|
||||||
absolute_route!(ip_packet_router_absolute, v1_absolute(), IP_PACKET_ROUTER);
|
|
||||||
absolute_route!(swagger_absolute, v1_absolute(), SWAGGER);
|
absolute_route!(swagger_absolute, v1_absolute(), SWAGGER);
|
||||||
|
|
||||||
pub mod gateway {
|
pub mod gateway {
|
||||||
@@ -98,10 +96,6 @@ pub mod routes {
|
|||||||
EXIT_POLICY
|
EXIT_POLICY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod ip_packet_router {
|
|
||||||
// use super::*;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,9 +146,5 @@ mod tests {
|
|||||||
"/api/v1/network-requester",
|
"/api/v1/network-requester",
|
||||||
routes::api::v1::network_requester_absolute()
|
routes::api::v1::network_requester_absolute()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
|
||||||
"/api/v1/ip-packet-router",
|
|
||||||
routes::api::v1::ip_packet_router_absolute()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
use axum::routing::get;
|
|
||||||
use axum::Router;
|
|
||||||
use nym_node_requests::api::v1::ip_packet_router::models;
|
|
||||||
|
|
||||||
pub mod root;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
|
||||||
pub struct Config {
|
|
||||||
pub details: Option<models::IpPacketRouter>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn routes<S: Send + Sync + 'static + Clone>(config: Config) -> Router<S> {
|
|
||||||
Router::new().route(
|
|
||||||
"/",
|
|
||||||
get({
|
|
||||||
let ip_packet_router_details = config.details;
|
|
||||||
move |query| root::root_ip_packet_router(ip_packet_router_details, query)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
use crate::http::router::api::{FormattedResponse, OutputParams};
|
|
||||||
use axum::extract::Query;
|
|
||||||
use axum::http::StatusCode;
|
|
||||||
use nym_node_requests::api::v1::ip_packet_router::models::IpPacketRouter;
|
|
||||||
|
|
||||||
/// Returns root network requester information
|
|
||||||
#[utoipa::path(
|
|
||||||
get,
|
|
||||||
path = "",
|
|
||||||
context_path = "/api/v1/ip-packet-router",
|
|
||||||
tag = "IP Packet Router",
|
|
||||||
responses(
|
|
||||||
(status = 501, description = "the endpoint hasn't been implemented yet"),
|
|
||||||
(status = 200, content(
|
|
||||||
("application/json" = IpPacketRouter),
|
|
||||||
("application/yaml" = IpPacketRouter)
|
|
||||||
))
|
|
||||||
),
|
|
||||||
params(OutputParams)
|
|
||||||
)]
|
|
||||||
pub(crate) async fn root_ip_packet_router(
|
|
||||||
details: Option<IpPacketRouter>,
|
|
||||||
Query(output): Query<OutputParams>,
|
|
||||||
) -> Result<IpPacketRouterResponse, StatusCode> {
|
|
||||||
let details = details.ok_or(StatusCode::NOT_IMPLEMENTED)?;
|
|
||||||
let output = output.output.unwrap_or_default();
|
|
||||||
Ok(output.to_response(details))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type IpPacketRouterResponse = FormattedResponse<IpPacketRouter>;
|
|
||||||
@@ -9,7 +9,6 @@ use nym_node_requests::routes::api::v1;
|
|||||||
|
|
||||||
pub mod gateway;
|
pub mod gateway;
|
||||||
pub mod health;
|
pub mod health;
|
||||||
pub mod ip_packet_router;
|
|
||||||
pub mod mixnode;
|
pub mod mixnode;
|
||||||
pub mod network_requester;
|
pub mod network_requester;
|
||||||
pub mod node;
|
pub mod node;
|
||||||
@@ -21,7 +20,6 @@ pub struct Config {
|
|||||||
pub gateway: gateway::Config,
|
pub gateway: gateway::Config,
|
||||||
pub mixnode: mixnode::Config,
|
pub mixnode: mixnode::Config,
|
||||||
pub network_requester: network_requester::Config,
|
pub network_requester: network_requester::Config,
|
||||||
pub ip_packet_router: ip_packet_router::Config,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn routes(config: Config, initial_wg_state: WireguardAppState) -> Router<AppState> {
|
pub(super) fn routes(config: Config, initial_wg_state: WireguardAppState) -> Router<AppState> {
|
||||||
@@ -36,10 +34,6 @@ pub(super) fn routes(config: Config, initial_wg_state: WireguardAppState) -> Rou
|
|||||||
v1::NETWORK_REQUESTER,
|
v1::NETWORK_REQUESTER,
|
||||||
network_requester::routes(config.network_requester),
|
network_requester::routes(config.network_requester),
|
||||||
)
|
)
|
||||||
.nest(
|
|
||||||
v1::IP_PACKET_ROUTER,
|
|
||||||
ip_packet_router::routes(config.ip_packet_router),
|
|
||||||
)
|
|
||||||
.merge(node::routes(config.node))
|
.merge(node::routes(config.node))
|
||||||
.merge(openapi::route())
|
.merge(openapi::route())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ use utoipa_swagger_ui::SwaggerUi;
|
|||||||
api::v1::mixnode::root::root_mixnode,
|
api::v1::mixnode::root::root_mixnode,
|
||||||
api::v1::network_requester::root::root_network_requester,
|
api::v1::network_requester::root::root_network_requester,
|
||||||
api::v1::network_requester::exit_policy::node_exit_policy,
|
api::v1::network_requester::exit_policy::node_exit_policy,
|
||||||
api::v1::ip_packet_router::root::root_ip_packet_router,
|
|
||||||
),
|
),
|
||||||
components(
|
components(
|
||||||
schemas(
|
schemas(
|
||||||
@@ -57,7 +56,6 @@ use utoipa_swagger_ui::SwaggerUi;
|
|||||||
api_requests::v1::network_requester::exit_policy::models::AddressPortPattern,
|
api_requests::v1::network_requester::exit_policy::models::AddressPortPattern,
|
||||||
api_requests::v1::network_requester::exit_policy::models::PortRange,
|
api_requests::v1::network_requester::exit_policy::models::PortRange,
|
||||||
api_requests::v1::network_requester::exit_policy::models::UsedExitPolicy,
|
api_requests::v1::network_requester::exit_policy::models::UsedExitPolicy,
|
||||||
api_requests::v1::ip_packet_router::models::IpPacketRouter,
|
|
||||||
),
|
),
|
||||||
responses(RequestError)
|
responses(RequestError)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use crate::http::state::AppState;
|
|||||||
use crate::http::NymNodeHTTPServer;
|
use crate::http::NymNodeHTTPServer;
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use nym_node_requests::api::v1::gateway::models::{Gateway, Wireguard};
|
use nym_node_requests::api::v1::gateway::models::{Gateway, Wireguard};
|
||||||
use nym_node_requests::api::v1::ip_packet_router::models::IpPacketRouter;
|
|
||||||
use nym_node_requests::api::v1::mixnode::models::Mixnode;
|
use nym_node_requests::api::v1::mixnode::models::Mixnode;
|
||||||
use nym_node_requests::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
use nym_node_requests::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
||||||
use nym_node_requests::api::v1::network_requester::models::NetworkRequester;
|
use nym_node_requests::api::v1::network_requester::models::NetworkRequester;
|
||||||
@@ -46,7 +45,6 @@ impl Config {
|
|||||||
gateway: Default::default(),
|
gateway: Default::default(),
|
||||||
mixnode: Default::default(),
|
mixnode: Default::default(),
|
||||||
network_requester: Default::default(),
|
network_requester: Default::default(),
|
||||||
ip_packet_router: Default::default(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -96,13 +94,6 @@ impl Config {
|
|||||||
self.api.v1_config.network_requester.exit_policy = Some(exit_policy);
|
self.api.v1_config.network_requester.exit_policy = Some(exit_policy);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
pub fn with_ip_packet_router(mut self, ip_packet_router: IpPacketRouter) -> Self {
|
|
||||||
self.api.v1_config.node.roles.ip_packet_router_enabled = true;
|
|
||||||
self.api.v1_config.ip_packet_router.details = Some(ip_packet_router);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NymNodeRouter {
|
pub struct NymNodeRouter {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { RadioGroup } from '@headlessui/react';
|
import { RadioGroup } from '@headlessui/react';
|
||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
@@ -16,12 +16,6 @@ function NetworkModeSelect() {
|
|||||||
|
|
||||||
const { t } = useTranslation('home');
|
const { t } = useTranslation('home');
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (state.vpnMode !== selected) {
|
|
||||||
setSelected(state.vpnMode);
|
|
||||||
}
|
|
||||||
}, [state.vpnMode, selected]);
|
|
||||||
|
|
||||||
const handleNetworkModeChange = async (value: VpnMode) => {
|
const handleNetworkModeChange = async (value: VpnMode) => {
|
||||||
if (state.state === 'Disconnected' && value !== state.vpnMode) {
|
if (state.state === 'Disconnected' && value !== state.vpnMode) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|||||||
Generated
+2
-3
@@ -490,9 +490,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.5.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
|
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@@ -3566,7 +3566,6 @@ dependencies = [
|
|||||||
"nym-crypto",
|
"nym-crypto",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
|
||||||
"x25519-dalek 2.0.0",
|
"x25519-dalek 2.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub const REMOTE_SOURCE_OF_NYXD_URLS: &str =
|
|||||||
|
|
||||||
const CURRENT_GLOBAL_CONFIG_VERSION: u32 = 1;
|
const CURRENT_GLOBAL_CONFIG_VERSION: u32 = 1;
|
||||||
const CURRENT_NETWORK_CONFIG_VERSION: u32 = 1;
|
const CURRENT_NETWORK_CONFIG_VERSION: u32 = 1;
|
||||||
pub(crate) const CUSTOM_SIMULATED_GAS_MULTIPLIER: f32 = 1.5;
|
pub(crate) const CUSTOM_SIMULATED_GAS_MULTIPLIER: f32 = 1.4;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ pub async fn simulate_update_contract_settings(
|
|||||||
vec![],
|
vec![],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let result = client.nyxd.simulate(vec![msg], "").await?;
|
let result = client.nyxd.simulate(vec![msg]).await?;
|
||||||
guard.create_detailed_fee(result)
|
guard.create_detailed_fee(result)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use std::str::FromStr;
|
|||||||
pub async fn simulate_send(
|
pub async fn simulate_send(
|
||||||
address: &str,
|
address: &str,
|
||||||
amount: DecCoin,
|
amount: DecCoin,
|
||||||
memo: String,
|
|
||||||
state: tauri::State<'_, WalletState>,
|
state: tauri::State<'_, WalletState>,
|
||||||
) -> Result<FeeDetails, BackendError> {
|
) -> Result<FeeDetails, BackendError> {
|
||||||
let guard = state.read().await;
|
let guard = state.read().await;
|
||||||
@@ -31,7 +30,7 @@ pub async fn simulate_send(
|
|||||||
amount,
|
amount,
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = client.nyxd.simulate(vec![msg], memo).await?;
|
let result = client.nyxd.simulate(vec![msg]).await?;
|
||||||
guard.create_detailed_fee(result)
|
guard.create_detailed_fee(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ async fn simulate_mixnet_operation(
|
|||||||
.nyxd
|
.nyxd
|
||||||
.wrap_contract_execute_message(mixnet_contract, &msg, funds)?;
|
.wrap_contract_execute_message(mixnet_contract, &msg, funds)?;
|
||||||
|
|
||||||
let result = client.nyxd.simulate(vec![msg], "").await?;
|
let result = client.nyxd.simulate(vec![msg]).await?;
|
||||||
guard.create_detailed_fee(result)
|
guard.create_detailed_fee(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ async fn simulate_vesting_operation(
|
|||||||
.nyxd
|
.nyxd
|
||||||
.wrap_contract_execute_message(vesting_contract, &msg, funds)?;
|
.wrap_contract_execute_message(vesting_contract, &msg, funds)?;
|
||||||
|
|
||||||
let result = client.nyxd.simulate(vec![msg], "").await?;
|
let result = client.nyxd.simulate(vec![msg]).await?;
|
||||||
guard.create_detailed_fee(result)
|
guard.create_detailed_fee(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import {
|
import { isLessThan, isValidHostname, validateAmount, validateKey, validateRawPort, validateVersion } from 'src/utils';
|
||||||
isGreaterThan,
|
|
||||||
isLessThan,
|
|
||||||
isValidHostname,
|
|
||||||
validateAmount,
|
|
||||||
validateKey,
|
|
||||||
validateRawPort,
|
|
||||||
validateVersion,
|
|
||||||
} from 'src/utils';
|
|
||||||
|
|
||||||
export const mixnodeValidationSchema = Yup.object().shape({
|
export const mixnodeValidationSchema = Yup.object().shape({
|
||||||
identityKey: Yup.string()
|
identityKey: Yup.string()
|
||||||
@@ -42,21 +34,18 @@ export const mixnodeValidationSchema = Yup.object().shape({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const operatingCostAndPmValidation = {
|
const operatingCostAndPmValidation = {
|
||||||
profitMargin: Yup.number().required('Profit Percentage is required').min(7).max(80),
|
profitMargin: Yup.number().required('Profit Percentage is required').min(0).max(100),
|
||||||
operatorCost: Yup.object().shape({
|
operatorCost: Yup.object().shape({
|
||||||
amount: Yup.string()
|
amount: Yup.string()
|
||||||
.required('An operating cost is required')
|
.required('An operating cost is required')
|
||||||
// eslint-disable-next-line prefer-arrow-callback
|
// eslint-disable-next-line prefer-arrow-callback
|
||||||
.test(
|
.test('valid-operating-cost', 'A valid amount is required (min 40)', async function isValidAmount(this, value) {
|
||||||
'valid-operating-cost',
|
if (value && (!Number(value) || isLessThan(+value, 40))) {
|
||||||
'A valid amount is required (min 500 - max 2000)',
|
return false;
|
||||||
async function isValidAmount(this, value) {
|
}
|
||||||
if (value && (!Number(value) || isLessThan(+value, 500) || isGreaterThan(+value, 2000))) {
|
|
||||||
return this.createError({ message: 'A valid amount is required (min 500 - max 2000)' });
|
return true;
|
||||||
}
|
}),
|
||||||
return true;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const defaultMixnodeValues: MixnodeData = {
|
|||||||
|
|
||||||
const defaultAmountValues = (denom: CurrencyDenom) => ({
|
const defaultAmountValues = (denom: CurrencyDenom) => ({
|
||||||
amount: { amount: '100', denom },
|
amount: { amount: '100', denom },
|
||||||
operatorCost: { amount: '500', denom },
|
operatorCost: { amount: '40', denom },
|
||||||
profitMargin: '10',
|
profitMargin: '10',
|
||||||
tokenPool: 'balance',
|
tokenPool: 'balance',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export const SendModal = ({ onClose, hasStorybookStyles }: { onClose: () => void
|
|||||||
const [gasError, setGasError] = useState<string>();
|
const [gasError, setGasError] = useState<string>();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [userFees, setUserFees] = useState<DecCoin>();
|
const [userFees, setUserFees] = useState<DecCoin>();
|
||||||
const [memo, setMemo] = useState<string>('');
|
const [memo, setMemo] = useState<string>();
|
||||||
const [txDetails, setTxDetails] = useState<TTransactionDetails>();
|
const [txDetails, setTxDetails] = useState<TTransactionDetails>();
|
||||||
const [showMoreOptions, setShowMoreOptions] = useState(false);
|
const [showMoreOptions, setShowMoreOptions] = useState(false);
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ export const SendModal = ({ onClose, hasStorybookStyles }: { onClose: () => void
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showMoreOptions) {
|
if (!showMoreOptions) {
|
||||||
setUserFees(undefined);
|
setUserFees(undefined);
|
||||||
setMemo('');
|
setMemo(undefined);
|
||||||
}
|
}
|
||||||
}, [showMoreOptions]);
|
}, [showMoreOptions]);
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ export const SendModal = ({ onClose, hasStorybookStyles }: { onClose: () => void
|
|||||||
if (userFees) {
|
if (userFees) {
|
||||||
await setFeeManually(userFees);
|
await setFeeManually(userFees);
|
||||||
} else {
|
} else {
|
||||||
await getFee(simulateSend, { address: toAddress, amount, memo });
|
await getFee(simulateSend, { address: toAddress, amount });
|
||||||
}
|
}
|
||||||
setModal('send details');
|
setModal('send details');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -13,12 +13,7 @@ export const Balance = () => {
|
|||||||
const { userBalance, clientDetails, network } = useContext(AppContext);
|
const { userBalance, clientDetails, network } = useContext(AppContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
userBalance.fetchBalance();
|
||||||
userBalance.fetchBalance();
|
|
||||||
userBalance.fetchTokenAllocation();
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleShowTransferModal = async () => {
|
const handleShowTransferModal = async () => {
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ const Bonding = () => {
|
|||||||
{confirmationDetails && confirmationDetails.status === 'success' && (
|
{confirmationDetails && confirmationDetails.status === 'success' && (
|
||||||
<ConfirmationDetailsModal
|
<ConfirmationDetailsModal
|
||||||
title={confirmationDetails.title}
|
title={confirmationDetails.title}
|
||||||
subtitle={confirmationDetails.subtitle}
|
subtitle={confirmationDetails.subtitle || 'This operation can take up to one hour to process'}
|
||||||
status={confirmationDetails.status}
|
status={confirmationDetails.status}
|
||||||
txUrl={confirmationDetails.txUrl}
|
txUrl={confirmationDetails.txUrl}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ export const simulateVestingUpdateGatewayConfig = async (update: GatewayConfigUp
|
|||||||
export const simulateWithdrawVestedCoins = async (args: any) =>
|
export const simulateWithdrawVestedCoins = async (args: any) =>
|
||||||
invokeWrapper<FeeDetails>('simulate_withdraw_vested_coins', args);
|
invokeWrapper<FeeDetails>('simulate_withdraw_vested_coins', args);
|
||||||
|
|
||||||
export const simulateSend = async ({ address, amount, memo }: { address: string; amount: DecCoin; memo: string }) =>
|
export const simulateSend = async ({ address, amount }: { address: string; amount: DecCoin }) =>
|
||||||
invokeWrapper<FeeDetails>('simulate_send', { address, amount, memo });
|
invokeWrapper<FeeDetails>('simulate_send', { address, amount });
|
||||||
|
|
||||||
export const getCustomFees = async ({ feesAmount }: { feesAmount: DecCoin }) =>
|
export const getCustomFees = async ({ feesAmount }: { feesAmount: DecCoin }) =>
|
||||||
invokeWrapper<FeeDetails>('get_custom_fees', { feesAmount });
|
invokeWrapper<FeeDetails>('get_custom_fees', { feesAmount });
|
||||||
|
|||||||
Reference in New Issue
Block a user