shifting network information into a specific block with DNS info

This commit is contained in:
jmwample
2026-06-11 09:30:50 -06:00
parent 56846fee77
commit 24478e30ec
6 changed files with 180 additions and 83 deletions
Generated
+1 -1
View File
@@ -11482,7 +11482,7 @@ dependencies = [
"nym-sdk",
"reqwest 0.13.4",
"rustls 0.23.40",
"smoltcp",
"smoltcp 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"thiserror 2.0.18",
"tokio",
"tokio-rustls 0.26.4",
+1
View File
@@ -12,6 +12,7 @@ pub mod ecash;
#[cfg(all(feature = "env", feature = "network"))]
pub mod env_setup;
pub mod mainnet;
pub mod sandbox;
#[cfg(feature = "network")]
pub mod network;
+39
View File
@@ -61,6 +61,7 @@ pub struct NymNetworkDetails {
pub nym_vpn_api_url: Option<String>,
pub nym_api_urls: Option<Vec<ApiUrl>>,
pub nym_vpn_api_urls: Option<Vec<ApiUrl>>,
pub networking: NetworkingSpecifics,
}
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize, JsonSchema)]
@@ -102,6 +103,30 @@ impl From<ApiUrlConst<'_>> for ApiUrl {
}
}
#[derive(Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct DnsFallback {
pub url: String,
pub addresses: Vec<String>,
}
#[derive(Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct NetworkingSpecifics {
pub nym_api_urls: Vec<ApiUrl>,
pub nym_vpn_api_urls: Vec<ApiUrl>,
pub dns_fallbacks: Vec<DnsFallback>,
// pub internal_nameservers: std::any::Any,
// pub covert channels: std::any::Any,
}
// by default we assume the same defaults as mainnet, i.e. same prefixes and denoms
impl Default for NetworkingSpecifics {
fn default() -> Self {
NymNetworkDetails::mainnet_specifics()
}
}
// by default we assume the same defaults as mainnet, i.e. same prefixes and denoms
impl Default for NymNetworkDetails {
fn default() -> Self {
@@ -131,6 +156,7 @@ impl NymNetworkDetails {
nym_vpn_api_url: Default::default(),
nym_api_urls: Default::default(),
nym_vpn_api_urls: Default::default(),
networking: Default::default(),
}
}
@@ -241,6 +267,19 @@ impl NymNetworkDetails {
.map(Into::into)
.collect(),
),
networking: Self::mainnet_specifics(),
}
}
pub(crate) fn mainnet_specifics() -> NetworkingSpecifics {
NetworkingSpecifics {
nym_api_urls: mainnet::NYM_APIS.iter().copied().map(Into::into).collect(),
nym_vpn_api_urls: mainnet::NYM_VPN_APIS
.iter()
.copied()
.map(Into::into)
.collect(),
dns_fallbacks: Vec::new(),
}
}
+138
View File
@@ -0,0 +1,138 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
#[cfg(feature = "network")]
use crate::{
ApiUrlConst, ChainDetails, DenomDetails, NetworkingSpecifics, NymContracts, NymNetworkDetails,
ValidatorDetails,
};
#[cfg(feature = "network")]
use std::ops::Not;
pub const NETWORK_NAME: &str = "sandbox";
pub const BECH32_PREFIX: &str = "n";
#[cfg(feature = "network")]
pub const MIX_DENOM: DenomDetails = DenomDetails::new("unym", "nym", 6);
#[cfg(feature = "network")]
pub const STAKE_DENOM: DenomDetails = DenomDetails::new("unyx", "nyx", 6);
// -- Contract addresses --
pub const MIXNET_CONTRACT_ADDRESS: &str =
"n1xr3rq8yvd7qplsw5yx90ftsr2zdhg4e9z60h5duusgxpv72hud3sjkxkav";
pub const VESTING_CONTRACT_ADDRESS: &str =
"n1unyuj8qnmygvzuex3dwmg9yzt9alhvyeat0uu0jedg2wj33efl5qackslz";
pub const ECASH_CONTRACT_ADDRESS: &str =
"n1v3vydvs2ued84yv3khqwtgldmgwn0elljsdh08dr5s2j9x4rc5fs9jlwz9";
pub const GROUP_CONTRACT_ADDRESS: &str =
"n1ewmwz97xm0h8rdk8sw7h9mwn866qkx9hl9zlmagqfkhuzvwk5hhq844ue9";
pub const MULTISIG_CONTRACT_ADDRESS: &str =
"n1tz0setr8vkh9udp8xyxgpqc89ns27k4d0jx2h942hr0ax63yjhmqz6xct8";
pub const COCONUT_DKG_CONTRACT_ADDRESS: &str =
"n1v3n2ly2dp3a9ng3ff6rh26yfkn0pc5hed7w2shc5u9ca5c865utqj5elvh";
// \/ TODO: this has to be updated once the contract is deployed
pub const PERFORMANCE_CONTRACT_ADDRESS: &str = "";
// /\ TODO: this has to be updated once the contract is deployed
pub const NETWORK_MONITORS_CONTRACT_ADDRESS: &str =
"n1x5krtvyqklj360x38v62ze42g8s8trfsfqzlv8c9296chcpvqadssqnem5";
// \/ TODO: this has to be updated once the contract is deployed
pub const NODE_FAMILIES_CONTRACT_ADDRESS: &str =
"n13clyapdqk5umyynp20kqwf59rxlwlp24yf2ltzasflhsdhrxq7fsahyr6z";
// /\ TODO: this has to be updated once the contract is deployed
pub const NYXD_URL: &str = "https://rpc.nymtech.net";
pub const NYXD_WS: &str = "wss://rpc.nymtech.net/websocket";
// cluster of lite rpc nodes (not part of consensus, aggressive pruning, no archival state)
pub const NYXD_QUERY_LITE: &str = "https://blockstream.nymtech.net";
pub const NYXD_WS_LITE: &str = "wss://blockstream.nymtech.net/websocket";
pub const UPGRADE_MODE_ATTESTATION_URL: &str =
"https://nymtech.net/.wellknown/upgrade-mode/attestation.json";
pub const UPGRADE_MODE_ATTESTER_ED25519_BS58_PUBKEY: &str =
"3bgffBYcfFkTTXc2npNNn9MkddFZ3H2LrPjXDmnJzrqd";
#[cfg(feature = "network")]
pub const NYM_VPN_APIS: &[ApiUrlConst] = &[
ApiUrlConst {
url: "https://nym-vpn-api-git-deploy-sandbox-nyx-network-staging.vercel.app/api/",
front_hosts: None,
},
ApiUrlConst {
url: "https://nym-frontdoor.vercel.app/sandbox/nym-vpn-api/",
front_hosts: Some(&["vercel.com", "vercel.app"]),
},
];
#[cfg(feature = "network")]
pub const NYM_APIS: &[ApiUrlConst] = &[
ApiUrlConst {
url: "https://sandbox-nym-api1.nymtech.net/api/",
front_hosts: Some(&["yelp.global.ssl.fastly.net"]),
},
ApiUrlConst {
url: "https://nym-frontdoor.vercel.app/sandbox/nym-api/",
front_hosts: Some(&["vercel.com", "vercel.app"]),
},
];
pub const EXIT_POLICY_URL: &str =
"https://nymtech.net/.wellknown/network-requester/exit-policy.txt";
#[cfg(feature = "network")]
pub fn validators() -> Vec<ValidatorDetails> {
vec![ValidatorDetails::new(
"https://rpc.sandbox.nymtech.net",
Some("https://sandbox-nym-api1.nymtech.net/api"),
Some("wss://rpc.sandbox.nymtech.net/websocket"),
)]
}
#[cfg(feature = "network")]
pub fn network_details() -> NymNetworkDetails {
NymNetworkDetails {
network_name: NETWORK_NAME.into(),
chain_details: ChainDetails {
bech32_account_prefix: BECH32_PREFIX.to_string(),
mix_denom: MIX_DENOM.into(),
stake_denom: STAKE_DENOM.into(),
},
endpoints: validators(),
contracts: NymContracts {
mixnet_contract_address: parse_optional_str(MIXNET_CONTRACT_ADDRESS),
vesting_contract_address: parse_optional_str(VESTING_CONTRACT_ADDRESS),
performance_contract_address: parse_optional_str(PERFORMANCE_CONTRACT_ADDRESS),
network_monitors_contract_address: parse_optional_str(
NETWORK_MONITORS_CONTRACT_ADDRESS,
),
node_families_contract_address: parse_optional_str(NODE_FAMILIES_CONTRACT_ADDRESS),
ecash_contract_address: parse_optional_str(ECASH_CONTRACT_ADDRESS),
group_contract_address: parse_optional_str(GROUP_CONTRACT_ADDRESS),
multisig_contract_address: parse_optional_str(MULTISIG_CONTRACT_ADDRESS),
coconut_dkg_contract_address: parse_optional_str(COCONUT_DKG_CONTRACT_ADDRESS),
},
nym_vpn_api_url: None,
nym_vpn_api_urls: None,
nym_api_urls: None,
networking: network_specifics(),
}
}
#[cfg(feature = "network")]
pub fn network_specifics() -> NetworkingSpecifics {
NetworkingSpecifics {
nym_api_urls: NYM_APIS.iter().copied().map(Into::into).collect(),
nym_vpn_api_urls: NYM_VPN_APIS.iter().copied().map(Into::into).collect(),
dns_fallbacks: Vec::new(),
}
}
#[cfg(feature = "network")]
fn parse_optional_str(raw: &str) -> Option<String> {
raw.is_empty().not().then(|| raw.into())
}
+1 -7
View File
@@ -1,14 +1,12 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use nym_config::defaults::{mainnet, DenomDetails, NymNetworkDetails};
use nym_config::defaults::{mainnet, sandbox, DenomDetails, NymNetworkDetails};
use nym_types::{currency::DecCoin, error::TypesError};
use serde::{Deserialize, Serialize};
use std::{fmt, ops::Not, str::FromStr};
use strum_macros::EnumIter;
mod sandbox;
#[allow(clippy::upper_case_acronyms)]
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
#[cfg_attr(
@@ -79,7 +77,3 @@ impl FromStr for Network {
}
}
}
fn parse_optional_str(raw: &str) -> Option<String> {
raw.is_empty().not().then(|| raw.into())
}
@@ -1,75 +0,0 @@
use super::parse_optional_str;
use nym_network_defaults::{ChainDetails, DenomDetails, NymContracts, ValidatorDetails};
// -- Chain details --
pub(crate) const NETWORK_NAME: &str = "sandbox";
pub(crate) const BECH32_PREFIX: &str = "n";
pub(crate) const MIX_DENOM: DenomDetails = DenomDetails::new("unym", "nym", 6);
pub(crate) const STAKE_DENOM: DenomDetails = DenomDetails::new("unyx", "nyx", 6);
// -- Contract addresses --
pub(crate) const MIXNET_CONTRACT_ADDRESS: &str =
"n1xr3rq8yvd7qplsw5yx90ftsr2zdhg4e9z60h5duusgxpv72hud3sjkxkav";
pub(crate) const VESTING_CONTRACT_ADDRESS: &str =
"n1unyuj8qnmygvzuex3dwmg9yzt9alhvyeat0uu0jedg2wj33efl5qackslz";
pub(crate) const ECASH_CONTRACT_ADDRESS: &str =
"n1v3vydvs2ued84yv3khqwtgldmgwn0elljsdh08dr5s2j9x4rc5fs9jlwz9";
pub(crate) const GROUP_CONTRACT_ADDRESS: &str =
"n1ewmwz97xm0h8rdk8sw7h9mwn866qkx9hl9zlmagqfkhuzvwk5hhq844ue9";
pub(crate) const MULTISIG_CONTRACT_ADDRESS: &str =
"n1tz0setr8vkh9udp8xyxgpqc89ns27k4d0jx2h942hr0ax63yjhmqz6xct8";
pub(crate) const COCONUT_DKG_CONTRACT_ADDRESS: &str =
"n1v3n2ly2dp3a9ng3ff6rh26yfkn0pc5hed7w2shc5u9ca5c865utqj5elvh";
// \/ TODO: this has to be updated once the contract is deployed
pub(crate) const PERFORMANCE_CONTRACT_ADDRESS: &str = "";
// /\ TODO: this has to be updated once the contract is deployed
pub const NETWORK_MONITORS_CONTRACT_ADDRESS: &str =
"n1x5krtvyqklj360x38v62ze42g8s8trfsfqzlv8c9296chcpvqadssqnem5";
// \/ TODO: this has to be updated once the contract is deployed
pub(crate) const NODE_FAMILIES_CONTRACT_ADDRESS: &str =
"n13clyapdqk5umyynp20kqwf59rxlwlp24yf2ltzasflhsdhrxq7fsahyr6z";
// /\ TODO: this has to be updated once the contract is deployed
// -- Constructor functions --
pub(crate) fn validators() -> Vec<ValidatorDetails> {
vec![ValidatorDetails::new(
"https://rpc.sandbox.nymtech.net",
Some("https://sandbox-nym-api1.nymtech.net/api"),
Some("wss://rpc.sandbox.nymtech.net/websocket"),
)]
}
pub(crate) fn network_details() -> nym_network_defaults::NymNetworkDetails {
nym_network_defaults::NymNetworkDetails {
network_name: NETWORK_NAME.into(),
chain_details: ChainDetails {
bech32_account_prefix: BECH32_PREFIX.to_string(),
mix_denom: MIX_DENOM.into(),
stake_denom: STAKE_DENOM.into(),
},
endpoints: validators(),
contracts: NymContracts {
mixnet_contract_address: parse_optional_str(MIXNET_CONTRACT_ADDRESS),
vesting_contract_address: parse_optional_str(VESTING_CONTRACT_ADDRESS),
performance_contract_address: parse_optional_str(PERFORMANCE_CONTRACT_ADDRESS),
network_monitors_contract_address: parse_optional_str(
NETWORK_MONITORS_CONTRACT_ADDRESS,
),
node_families_contract_address: parse_optional_str(NODE_FAMILIES_CONTRACT_ADDRESS),
ecash_contract_address: parse_optional_str(ECASH_CONTRACT_ADDRESS),
group_contract_address: parse_optional_str(GROUP_CONTRACT_ADDRESS),
multisig_contract_address: parse_optional_str(MULTISIG_CONTRACT_ADDRESS),
coconut_dkg_contract_address: parse_optional_str(COCONUT_DKG_CONTRACT_ADDRESS),
},
nym_vpn_api_url: None,
nym_vpn_api_urls: None,
nym_api_urls: None,
}
}