Feature/default values (#700)
* Put endpoints and contract address in one place * Put common ports in one place * Split cache version from route * Share validator-api port value between server and client * Put BECH32 prefix in defaults * Put DENOM in defaults * Put network monitor address in defaults * Fix clippy * Fix another clippy + tests import of DENOM
This commit is contained in:
committed by
GitHub
parent
2354828481
commit
18f5d4084d
@@ -1,6 +1,7 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use config::defaults::*;
|
||||
use config::{deserialize_duration, deserialize_validators, NymConfig};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::marker::PhantomData;
|
||||
@@ -11,13 +12,6 @@ pub mod persistence;
|
||||
|
||||
pub const MISSING_VALUE: &str = "MISSING VALUE";
|
||||
|
||||
// 'CLIENT'
|
||||
pub const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &[
|
||||
"http://testnet-milhon-validator1.nymtech.net:1317",
|
||||
"http://testnet-milhon-validator2.nymtech.net:1317",
|
||||
];
|
||||
pub const DEFAULT_MIXNET_CONTRACT_ADDRESS: &str = "punk10pyejy66429refv3g35g2t7am0was7yalwrzen";
|
||||
|
||||
// 'DEBUG'
|
||||
const DEFAULT_ACK_WAIT_MULTIPLIER: f64 = 1.5;
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
use crate::client::config::{Config, MISSING_VALUE};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use client_core::config::{default_validator_rest_endpoints, DEFAULT_MIXNET_CONTRACT_ADDRESS};
|
||||
use client_core::config::default_validator_rest_endpoints;
|
||||
use config::defaults::DEFAULT_MIXNET_CONTRACT_ADDRESS;
|
||||
use config::NymConfig;
|
||||
use std::fmt::Display;
|
||||
use std::process;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
use crate::client::config::{Config, MISSING_VALUE};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use client_core::config::{default_validator_rest_endpoints, DEFAULT_MIXNET_CONTRACT_ADDRESS};
|
||||
use client_core::config::default_validator_rest_endpoints;
|
||||
use config::defaults::DEFAULT_MIXNET_CONTRACT_ADDRESS;
|
||||
use config::NymConfig;
|
||||
use std::fmt::Display;
|
||||
use std::process;
|
||||
|
||||
@@ -17,7 +17,7 @@ use url::Url;
|
||||
mod error;
|
||||
mod models;
|
||||
pub(crate) mod serde_helpers;
|
||||
mod validator_api;
|
||||
pub mod validator_api;
|
||||
|
||||
// Implement caching with a global hashmap that has two fields, queryresponse and as_at, there is a side process
|
||||
pub struct Config {
|
||||
@@ -208,7 +208,11 @@ impl Client {
|
||||
}
|
||||
|
||||
pub async fn get_cached_mix_nodes(&self) -> Result<Vec<MixNodeBond>, ValidatorClientError> {
|
||||
let query_content = validator_api::VALIDATOR_API_MIXNODES.to_string();
|
||||
let query_content = format!(
|
||||
"{}{}",
|
||||
validator_api::VALIDATOR_API_CACHE_VERSION.to_string(),
|
||||
validator_api::VALIDATOR_API_MIXNODES.to_string()
|
||||
);
|
||||
self.query_validators(query_content, true).await
|
||||
}
|
||||
|
||||
@@ -246,7 +250,11 @@ impl Client {
|
||||
}
|
||||
|
||||
pub async fn get_cached_gateways(&self) -> Result<Vec<GatewayBond>, ValidatorClientError> {
|
||||
let query_content = validator_api::VALIDATOR_API_GATEWAYS.to_string();
|
||||
let query_content = format!(
|
||||
"{}{}",
|
||||
validator_api::VALIDATOR_API_CACHE_VERSION.to_string(),
|
||||
validator_api::VALIDATOR_API_GATEWAYS.to_string()
|
||||
);
|
||||
self.query_validators(query_content, true).await
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,21 @@ use crate::validator_api::error::ValidatorAPIClientError;
|
||||
use serde::Deserialize;
|
||||
use url::Url;
|
||||
|
||||
// TODO: This should be linked to the validator-api as well
|
||||
pub(crate) const VALIDATOR_API_PORT: u16 = 8080;
|
||||
pub(crate) const VALIDATOR_API_MIXNODES: &str = "v1/mixnodes";
|
||||
pub(crate) const VALIDATOR_API_GATEWAYS: &str = "v1/gateways";
|
||||
pub const VALIDATOR_API_PORT: u16 = 8080;
|
||||
pub const VALIDATOR_API_CACHE_VERSION: &str = "/v1";
|
||||
pub(crate) const VALIDATOR_API_MIXNODES: &str = "/mixnodes";
|
||||
pub(crate) const VALIDATOR_API_GATEWAYS: &str = "/gateways";
|
||||
|
||||
pub struct Client {
|
||||
reqwest_client: reqwest::Client,
|
||||
}
|
||||
|
||||
impl Default for Client {
|
||||
fn default() -> Self {
|
||||
Client::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn new() -> Self {
|
||||
let reqwest_client = reqwest::Client::new();
|
||||
@@ -32,7 +38,7 @@ impl Client {
|
||||
validator_api_url
|
||||
.set_port(Some(VALIDATOR_API_PORT))
|
||||
.unwrap();
|
||||
let query_url = format!("{}/{}", validator_api_url.as_str(), query);
|
||||
let query_url = format!("{}{}", validator_api_url.as_str(), query);
|
||||
Ok(self
|
||||
.reqwest_client
|
||||
.get(query_url)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2020 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &[
|
||||
"http://testnet-milhon-validator1.nymtech.net:1317",
|
||||
"http://testnet-milhon-validator2.nymtech.net:1317",
|
||||
];
|
||||
pub const DEFAULT_MIXNET_CONTRACT_ADDRESS: &str = "punk10pyejy66429refv3g35g2t7am0was7yalwrzen";
|
||||
pub const NETWORK_MONITOR_ADDRESS: &str = "punk1v9qauwdq5terag6uvfsdytcs2d0sdmfdy7hgk3";
|
||||
pub const BECH32_PREFIX: &str = "punk";
|
||||
pub const DENOM: &str = "upunk";
|
||||
|
||||
pub const DEFAULT_MIX_LISTENING_PORT: u16 = 1789;
|
||||
|
||||
// 'GATEWAY'
|
||||
pub const DEFAULT_CLIENT_LISTENING_PORT: u16 = 9000;
|
||||
|
||||
// 'MIXNODE'
|
||||
pub const DEFAULT_VERLOC_LISTENING_PORT: u16 = 1790;
|
||||
pub const DEFAULT_HTTP_API_LISTENING_PORT: u16 = 8000;
|
||||
@@ -7,6 +7,7 @@ use serde::Serialize;
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, io};
|
||||
|
||||
pub mod defaults;
|
||||
pub mod helpers;
|
||||
|
||||
pub use helpers::{deserialize_duration, deserialize_validators};
|
||||
|
||||
Generated
+201
-12
@@ -19,15 +19,42 @@ dependencies = [
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"byte-tools",
|
||||
"byteorder",
|
||||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
|
||||
dependencies = [
|
||||
"byte-tools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
@@ -40,6 +67,16 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "config"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"handlebars",
|
||||
"humantime-serde",
|
||||
"serde",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.4.5"
|
||||
@@ -52,7 +89,7 @@ version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "038089cdadfe61e4e85617d91cecec2c49f828db8e5986bb85e29d0b29c59b77"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"digest 0.9.0",
|
||||
"ed25519-zebra",
|
||||
"k256",
|
||||
"rand_core",
|
||||
@@ -125,7 +162,7 @@ version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.4",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
@@ -136,7 +173,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"digest",
|
||||
"digest 0.9.0",
|
||||
"rand_core",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
@@ -151,13 +188,22 @@ dependencies = [
|
||||
"const-oid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||
dependencies = [
|
||||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -198,10 +244,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"digest",
|
||||
"digest 0.9.0",
|
||||
"ff",
|
||||
"funty",
|
||||
"generic-array",
|
||||
"generic-array 0.14.4",
|
||||
"group",
|
||||
"pkcs8",
|
||||
"rand_core",
|
||||
@@ -209,6 +255,12 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
|
||||
[[package]]
|
||||
name = "ff"
|
||||
version = "0.8.0"
|
||||
@@ -226,6 +278,15 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.4"
|
||||
@@ -258,6 +319,20 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "3.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"quick-error",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
@@ -271,7 +346,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15"
|
||||
dependencies = [
|
||||
"crypto-mac",
|
||||
"digest",
|
||||
"digest 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "humantime-serde"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac34a56cfd4acddb469cc7fff187ed5ac36f498ba085caf8bbc725e3ff474058"
|
||||
dependencies = [
|
||||
"humantime",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -298,6 +389,21 @@ version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maplit"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
||||
|
||||
[[package]]
|
||||
name = "mixnet-contract"
|
||||
version = "0.1.0"
|
||||
@@ -312,6 +418,7 @@ dependencies = [
|
||||
name = "mixnet-contracts"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"config",
|
||||
"cosmwasm-schema",
|
||||
"cosmwasm-std",
|
||||
"cosmwasm-storage",
|
||||
@@ -321,12 +428,61 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
|
||||
dependencies = [
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
|
||||
dependencies = [
|
||||
"maplit",
|
||||
"pest",
|
||||
"sha-1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkcs8"
|
||||
version = "0.3.3"
|
||||
@@ -345,6 +501,12 @@ dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.8"
|
||||
@@ -461,17 +623,29 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
|
||||
dependencies = [
|
||||
"block-buffer 0.7.3",
|
||||
"digest 0.8.1",
|
||||
"fake-simd",
|
||||
"opaque-debug 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"block-buffer 0.9.0",
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
"opaque-debug",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -480,7 +654,7 @@ version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"digest 0.9.0",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
@@ -527,12 +701,27 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||
|
||||
[[package]]
|
||||
name = "uint"
|
||||
version = "0.9.0"
|
||||
|
||||
@@ -34,6 +34,7 @@ backtraces = ["cosmwasm-std/backtraces"]
|
||||
|
||||
[dependencies]
|
||||
mixnet-contract = { path = "../../common/mixnet-contract" }
|
||||
config = { path = "../../common/config"}
|
||||
cosmwasm-std = { version = "0.14.1", features = ["iterator"] }
|
||||
cosmwasm-storage = { version = "0.14.1", features = ["iterator"] }
|
||||
schemars = "0.8"
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
|
||||
use crate::state::{State, StateParams};
|
||||
use crate::storage::{config, layer_distribution};
|
||||
use crate::{error::ContractError, queries, transactions};
|
||||
use config::defaults::NETWORK_MONITOR_ADDRESS;
|
||||
use cosmwasm_std::{
|
||||
entry_point, to_binary, Addr, Decimal, Deps, DepsMut, Env, MessageInfo, QueryResponse,
|
||||
Response, Uint128,
|
||||
@@ -22,11 +23,6 @@ pub const INITIAL_GATEWAY_BOND_REWARD_RATE: u64 = 110;
|
||||
|
||||
pub const INITIAL_MIXNODE_ACTIVE_SET_SIZE: u32 = 100;
|
||||
|
||||
const NETWORK_MONITOR_ADDRESS: &str = "punk1v9qauwdq5terag6uvfsdytcs2d0sdmfdy7hgk3";
|
||||
|
||||
/// Constant specifying denomination of the coin used for bonding
|
||||
pub const DENOM: &str = "upunk";
|
||||
|
||||
fn default_initial_state(owner: Addr) -> State {
|
||||
let mixnode_bond_reward_rate = Decimal::percent(INITIAL_MIXNODE_BOND_REWARD_RATE);
|
||||
let gateway_bond_reward_rate = Decimal::percent(INITIAL_GATEWAY_BOND_REWARD_RATE);
|
||||
@@ -176,6 +172,7 @@ pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response,
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::support::tests::helpers::*;
|
||||
use config::defaults::DENOM;
|
||||
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
|
||||
use cosmwasm_std::{coins, from_binary};
|
||||
use mixnet_contract::PagedMixnodeResponse;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::contract::DENOM;
|
||||
use config::defaults::DENOM;
|
||||
use cosmwasm_std::{Addr, StdError};
|
||||
use mixnet_contract::IdentityKey;
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::contract::DENOM;
|
||||
use crate::error::ContractError;
|
||||
use crate::state::StateParams;
|
||||
use crate::storage::{
|
||||
gateway_delegations_read, gateways_owners_read, gateways_read, mix_delegations_read,
|
||||
mixnodes_owners_read, mixnodes_read, read_layer_distribution, read_state_params,
|
||||
};
|
||||
use config::defaults::DENOM;
|
||||
use cosmwasm_std::Deps;
|
||||
use cosmwasm_std::Order;
|
||||
use cosmwasm_std::StdResult;
|
||||
|
||||
@@ -305,10 +305,10 @@ pub(crate) fn read_gateway_bond(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::contract::DENOM;
|
||||
use crate::support::tests::helpers::{
|
||||
gateway_bond_fixture, gateway_fixture, mix_node_fixture, mixnode_bond_fixture,
|
||||
};
|
||||
use config::defaults::DENOM;
|
||||
use cosmwasm_std::testing::MockStorage;
|
||||
use cosmwasm_std::{coin, Addr, Uint128};
|
||||
use mixnet_contract::{Gateway, MixNode};
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
pub mod helpers {
|
||||
use super::*;
|
||||
use crate::contract::query;
|
||||
use crate::contract::DENOM;
|
||||
use crate::contract::{instantiate, INITIAL_MIXNODE_BOND};
|
||||
use crate::msg::InstantiateMsg;
|
||||
use crate::msg::QueryMsg;
|
||||
use crate::transactions::{try_add_gateway, try_add_mixnode};
|
||||
use config::defaults::DENOM;
|
||||
use cosmwasm_std::coin;
|
||||
use cosmwasm_std::from_binary;
|
||||
use cosmwasm_std::testing::mock_dependencies;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::contract::DENOM;
|
||||
use crate::error::ContractError;
|
||||
use crate::helpers::{calculate_epoch_reward_rate, scale_reward_by_uptime};
|
||||
use crate::queries;
|
||||
use crate::state::StateParams;
|
||||
use crate::storage::*;
|
||||
use config::defaults::DENOM;
|
||||
use cosmwasm_std::{
|
||||
attr, coins, BankMsg, Coin, Decimal, DepsMut, MessageInfo, Order, Response, StdResult, Uint128,
|
||||
};
|
||||
|
||||
@@ -6,10 +6,10 @@ use std::process;
|
||||
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
|
||||
use config::defaults::DEFAULT_MIXNET_CONTRACT_ADDRESS;
|
||||
use config::NymConfig;
|
||||
use version_checker::{parse_version, Version};
|
||||
|
||||
use crate::config::DEFAULT_MIXNET_CONTRACT_ADDRESS;
|
||||
use crate::config::{default_validator_rest_endpoints, Config, MISSING_VALUE};
|
||||
|
||||
fn fail_upgrade<D1: Display, D2: Display>(from_version: D1, to_version: D2) -> ! {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::template::config_template;
|
||||
use config::defaults::*;
|
||||
use config::{deserialize_duration, deserialize_validators, NymConfig};
|
||||
use log::error;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -14,15 +15,6 @@ mod template;
|
||||
|
||||
pub(crate) const MISSING_VALUE: &str = "MISSING VALUE";
|
||||
|
||||
// 'GATEWAY'
|
||||
const DEFAULT_MIX_LISTENING_PORT: u16 = 1789;
|
||||
const DEFAULT_CLIENT_LISTENING_PORT: u16 = 9000;
|
||||
pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &[
|
||||
"http://testnet-milhon-validator1.nymtech.net:1317",
|
||||
"http://testnet-milhon-validator2.nymtech.net:1317",
|
||||
];
|
||||
pub const DEFAULT_MIXNET_CONTRACT_ADDRESS: &str = "punk10pyejy66429refv3g35g2t7am0was7yalwrzen";
|
||||
|
||||
// 'DEBUG'
|
||||
// where applicable, the below are defined in milliseconds
|
||||
const DEFAULT_PRESENCE_SENDING_DELAY: Duration = Duration::from_millis(10_000);
|
||||
|
||||
@@ -2,6 +2,7 @@ use crate::commands::*;
|
||||
use crate::config::{persistence::pathfinder::MixNodePathfinder, Config};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use colored::*;
|
||||
use config::defaults::BECH32_PREFIX;
|
||||
use config::NymConfig;
|
||||
use crypto::asymmetric::identity;
|
||||
use log::error;
|
||||
@@ -59,10 +60,10 @@ pub fn execute(matches: &ArgMatches) {
|
||||
|
||||
let channel_name = "https://t.me/nympunkbot".bright_cyan();
|
||||
|
||||
// the text should consists of two parts, telegram handle and punk address - we can perform some very basic validation here already
|
||||
// the text should consists of two parts, telegram handle and wallet address - we can perform some very basic validation here already
|
||||
let split = text.split(' ').collect::<Vec<_>>();
|
||||
if split.len() != 2 {
|
||||
let error_message = r#"You haven't provided correct sign arguments. You need to provide --text "@your_telegram_handle your_punk_wallet_address" with the quotes and space in between"#.red();
|
||||
let error_message = format!(r#"You haven't provided correct sign arguments. You need to provide --text "@your_telegram_handle your_{}_wallet_address" with the quotes and space in between"#, BECH32_PREFIX).red();
|
||||
println!("{}", error_message);
|
||||
process::exit(1);
|
||||
}
|
||||
@@ -73,8 +74,9 @@ pub fn execute(matches: &ArgMatches) {
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
if !split[1].starts_with("punk") {
|
||||
let error_message = "Your wallet address must start with a 'punk'".red();
|
||||
if !split[1].starts_with(BECH32_PREFIX) {
|
||||
let error_message =
|
||||
format!("Your wallet address must start with a '{}'", BECH32_PREFIX).red();
|
||||
println!("{}", error_message);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
use crate::commands::*;
|
||||
use crate::config::{
|
||||
default_validator_rest_endpoints, missing_string_value, Config,
|
||||
DEFAULT_MIXNET_CONTRACT_ADDRESS, MISSING_VALUE,
|
||||
default_validator_rest_endpoints, missing_string_value, Config, MISSING_VALUE,
|
||||
};
|
||||
use crate::node::node_description::{NodeDescription, DESCRIPTION_FILE};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use config::defaults::DEFAULT_MIXNET_CONTRACT_ADDRESS;
|
||||
use config::NymConfig;
|
||||
use crypto::asymmetric::identity;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::template::config_template;
|
||||
use config::defaults::*;
|
||||
use config::{deserialize_duration, deserialize_validators, NymConfig};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
@@ -14,17 +15,6 @@ mod template;
|
||||
|
||||
pub(crate) const MISSING_VALUE: &str = "MISSING VALUE";
|
||||
|
||||
// 'MIXNODE'
|
||||
const DEFAULT_MIX_LISTENING_PORT: u16 = 1789;
|
||||
const DEFAULT_VERLOC_LISTENING_PORT: u16 = 1790;
|
||||
const DEFAULT_HTTP_API_LISTENING_PORT: u16 = 8000;
|
||||
|
||||
pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &[
|
||||
"http://testnet-milhon-validator1.nymtech.net:1317",
|
||||
"http://testnet-milhon-validator2.nymtech.net:1317",
|
||||
];
|
||||
pub const DEFAULT_MIXNET_CONTRACT_ADDRESS: &str = "punk10pyejy66429refv3g35g2t7am0was7yalwrzen";
|
||||
|
||||
// 'RTT MEASUREMENT'
|
||||
const DEFAULT_PACKETS_PER_NODE: usize = 100;
|
||||
const DEFAULT_CONNECTION_TIMEOUT: Duration = Duration::from_millis(5000);
|
||||
|
||||
Vendored
+5
-3
@@ -10,6 +10,7 @@ use std::sync::Arc;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
use tokio::sync::RwLock;
|
||||
use tokio::time;
|
||||
use validator_client::validator_api::VALIDATOR_API_CACHE_VERSION;
|
||||
use validator_client::Client;
|
||||
|
||||
pub(crate) mod routes;
|
||||
@@ -111,9 +112,10 @@ impl ValidatorCache {
|
||||
|
||||
pub fn stage() -> AdHoc {
|
||||
AdHoc::on_ignite("Validator Cache Stage", |rocket| async {
|
||||
rocket
|
||||
.manage(Self::new())
|
||||
.mount("/v1", routes![routes::get_mixnodes, routes::get_gateways])
|
||||
rocket.manage(Self::new()).mount(
|
||||
VALIDATOR_API_CACHE_VERSION,
|
||||
routes![routes::get_mixnodes, routes::get_gateways],
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::template::config_template;
|
||||
use config::defaults::DEFAULT_MIXNET_CONTRACT_ADDRESS;
|
||||
use config::NymConfig;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -10,7 +11,6 @@ use std::time::Duration;
|
||||
mod template;
|
||||
|
||||
const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &["http://localhost:1317"];
|
||||
const DEFAULT_MIXNET_CONTRACT: &str = "punk10pyejy66429refv3g35g2t7am0was7yalwrzen";
|
||||
|
||||
const DEFAULT_GATEWAY_SENDING_RATE: usize = 500;
|
||||
const DEFAULT_MAX_CONCURRENT_GATEWAY_CLIENTS: usize = 50;
|
||||
@@ -81,7 +81,7 @@ impl Default for Base {
|
||||
.iter()
|
||||
.map(|&endpoint| endpoint.to_string())
|
||||
.collect(),
|
||||
mixnet_contract_address: DEFAULT_MIXNET_CONTRACT.to_string(),
|
||||
mixnet_contract_address: DEFAULT_MIXNET_CONTRACT_ADDRESS.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use log::info;
|
||||
use rocket::http::Method;
|
||||
use rocket_cors::{AllowedHeaders, AllowedOrigins, Cors};
|
||||
use std::process;
|
||||
use validator_client::validator_api::VALIDATOR_API_PORT;
|
||||
|
||||
pub(crate) mod cache;
|
||||
pub(crate) mod config;
|
||||
@@ -195,7 +196,11 @@ async fn main() -> Result<()> {
|
||||
let config = override_config(config, &matches);
|
||||
|
||||
// let's build our rocket!
|
||||
let rocket = rocket::build()
|
||||
let rocket_config = rocket::config::Config {
|
||||
port: VALIDATOR_API_PORT,
|
||||
..Default::default()
|
||||
};
|
||||
let rocket = rocket::custom(rocket_config)
|
||||
.attach(setup_cors()?)
|
||||
.attach(ValidatorCache::stage());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user