Compare commits

...

23 Commits

Author SHA1 Message Date
gala1234 71ea0b6b5f starting logic 2022-06-09 14:00:15 +02:00
Jon Häggblad be938cf4f0 client/native: tidy some logging (#1320)
* client/native: some logging refinement

* client/native: fix pedantic clippy warn

* client/native: another pedantic clippy warn

* rustfmt
2022-06-08 21:51:00 +02:00
Bogdan-Ștefan Neacşu 12412d32e6 Panic early if re-init with new gateway (#1322)
* Panic early if re-init with new gateway

* Update CHANGELOG
2022-06-08 14:07:17 +03:00
Bogdan-Ștefan Neacşu fb5193163e Remove coconut debugging code (#1321) 2022-06-08 12:08:12 +03:00
Jędrzej Stuczyński c13d3ab15d Updated cosmwasm dependencies to 1.0.0 (#1318)
* Updated cosmwasm dependencies to 1.0.0

* changelog
2022-06-07 12:55:10 +01:00
Bogdan-Ștefan Neacşu f655a9d8c6 Replace default network with provided network (#1317) 2022-06-07 14:44:48 +03:00
gala1234 73a2fd68c6 Merge branch 'develop' of github.com:nymtech/nym into develop 2022-06-07 13:18:33 +02:00
gala1234 ca16dc6d66 Revert "Adding discord icon"
This reverts commit 24d3089458.
2022-06-07 13:17:15 +02:00
Jon Häggblad d5c456a370 wallet: additional wallet test (#1312) 2022-06-07 13:16:00 +02:00
gala1234 24d3089458 Adding discord icon 2022-06-07 13:14:16 +02:00
Tommy Verrall b020251b62 Merge pull request #1309 from nymtech/feature-219-explorer-small-changes
Explorer: Feature 219 explorer small changes
2022-06-07 11:31:29 +01:00
Jon Häggblad f15ecdda06 mixnode: graceful shutdown on ctrl-c (#1304)
* mixnode: add graceful notification to most tasks

* Add note about remaining work

* task/shutdown: add shutdown timer

* changelog: add entry for shutdown

* mixnode: revert some temp changes

* common/task: make sure to use latest tokio
2022-06-07 11:41:58 +02:00
Raphaël Walther 7a74bb9ad5 Fixed unused variables in test (#1311) 2022-06-07 09:47:59 +01:00
gala1234 67625fe768 explorer: move stake-sat column in node list 2022-06-07 09:40:55 +02:00
gala1234 858ef7b3f9 cleaning 2022-06-06 16:49:04 +02:00
gala1234 c7dd48edbb remove delegators number column on node list and hardcode 2022-06-06 16:47:30 +02:00
gala1234 7c6d8daba2 Merge branch 'develop' into feature-219-explorer-small-changes 2022-06-06 16:40:22 +02:00
gala1234 c65c1ef7cb re-organising node list columns and validators column name change 2022-05-30 13:03:25 +02:00
gala1234 e7a8221005 Merge branch 'develop' into feature-219-explorer-small-changes 2022-05-26 12:05:28 +02:00
gala1234 1ee1d4ebf7 explorer: altering api response to make ui work 2022-05-26 11:32:57 +02:00
gala1234 780c6041ef bond, stake and pledge re-wording 2022-05-25 14:09:09 +02:00
gala1234 e9280f2c17 swap bond to stake and pledge to bond 2022-05-25 10:45:08 +02:00
gala1234 ddd84295c4 remove layer column 2022-05-25 10:11:36 +02:00
46 changed files with 681 additions and 468 deletions
+7
View File
@@ -1,5 +1,7 @@
# Changelog
Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
@@ -29,11 +31,14 @@
- mixnet-contract: replaced integer division with fixed for performance calculations ([#1284])
- mixnet-contract: Under certain circumstances nodes could not be unbonded ([#1255](https://github.com/nymtech/nym/issues/1255)) ([#1258])
- mixnode, gateway: attempting to determine reconnection backoff to persistently failing mixnode could result in a crash ([#1260])
- mixnode: the mixnode learned how to shutdown gracefully.
- vesting-contract: replaced `checked_sub` with `saturating_sub` to fix the underflow in `get_vesting_tokens` ([#1275])
- native & socks5 clients: fail early when clients try to re-init with a different gateway, which is not supported yet ([#1322])
### Changed
- validator-client: created internal `Coin` type that replaces coins from `cosmrs` and `cosmwasm` for API entrypoints [[#1295]]
- all: updated all `cosmwasm`-related dependencies to `1.0.0` and `cw-storage-plus` to `0.13.4` [[#1318]]
[#1249]: https://github.com/nymtech/nym/pull/1249
[#1256]: https://github.com/nymtech/nym/pull/1256
@@ -49,6 +54,8 @@
[#1292]: https://github.com/nymtech/nym/pull/1292
[#1295]: https://github.com/nymtech/nym/pull/1295
[#1302]: https://github.com/nymtech/nym/pull/1302
[#1318]: https://github.com/nymtech/nym/pull/1318
[#1322]: https://github.com/nymtech/nym/pull/1322
## [nym-wallet-v1.0.4](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.4) (2022-05-04)
Generated
+38 -114
View File
@@ -245,7 +245,7 @@ checksum = "873faa4363bfc54c36a48321da034c92a0645a363eed34d948683ffc1706e37f"
dependencies = [
"bs58",
"hmac 0.11.0",
"k256 0.10.4",
"k256",
"once_cell",
"pbkdf2",
"rand_core 0.6.3",
@@ -695,12 +695,6 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "const-oid"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b"
[[package]]
name = "const-oid"
version = "0.7.1"
@@ -778,10 +772,10 @@ checksum = "8413275b23cb5a0734d9d1e3e33f0b5b94547c1e94776dbc3149dbf46588a533"
dependencies = [
"bip32",
"cosmos-sdk-proto",
"ecdsa 0.13.4",
"ecdsa",
"eyre",
"getrandom 0.2.6",
"k256 0.10.4",
"k256",
"prost 0.10.3",
"prost-types 0.10.1",
"rand_core 0.6.3",
@@ -795,31 +789,31 @@ dependencies = [
[[package]]
name = "cosmwasm-crypto"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e70111e9701c3ec43bfbff0e523cd4cb115876b4d3433813436dd0934ee962"
checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd"
dependencies = [
"digest 0.9.0",
"ed25519-zebra",
"k256 0.9.6",
"k256",
"rand_core 0.6.3",
"thiserror",
]
[[package]]
name = "cosmwasm-derive"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58bc2ad5d86be5f6068833f63e20786768db6890019c095dd7775232184fb7b3"
checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4"
dependencies = [
"syn",
]
[[package]]
name = "cosmwasm-std"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915ca82bd944f116f3a9717481f3fa657e4a73f28c4887288761ebb24e6fbe10"
checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195"
dependencies = [
"base64",
"cosmwasm-crypto",
@@ -1037,18 +1031,6 @@ dependencies = [
"x25519-dalek",
]
[[package]]
name = "crypto-bigint"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03"
dependencies = [
"generic-array 0.14.5",
"rand_core 0.6.3",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "crypto-bigint"
version = "0.3.2"
@@ -1156,9 +1138,9 @@ dependencies = [
[[package]]
name = "cw-storage-plus"
version = "0.13.2"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9336ecef1e19d56cf6e3e932475fc6a3dee35eec5a386e07917a1d1ba6bb0e35"
checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a"
dependencies = [
"cosmwasm-std",
"schemars",
@@ -1246,22 +1228,13 @@ dependencies = [
"num_cpus",
]
[[package]]
name = "der"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4"
dependencies = [
"const-oid 0.6.2",
]
[[package]]
name = "der"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c"
dependencies = [
"const-oid 0.7.1",
"const-oid",
]
[[package]]
@@ -1404,26 +1377,14 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28"
[[package]]
name = "ecdsa"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372"
dependencies = [
"der 0.4.5",
"elliptic-curve 0.10.6",
"hmac 0.11.0",
"signature",
]
[[package]]
name = "ecdsa"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9"
dependencies = [
"der 0.5.1",
"elliptic-curve 0.11.12",
"der",
"elliptic-curve",
"rfc6979",
"signature",
]
@@ -1474,22 +1435,6 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "elliptic-curve"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b"
dependencies = [
"crypto-bigint 0.2.11",
"ff 0.10.1",
"generic-array 0.14.5",
"group 0.10.0",
"pkcs8 0.7.6",
"rand_core 0.6.3",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "elliptic-curve"
version = "0.11.12"
@@ -1497,8 +1442,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6"
dependencies = [
"base16ct",
"crypto-bigint 0.3.2",
"der 0.5.1",
"crypto-bigint",
"der",
"ff 0.11.0",
"generic-array 0.14.5",
"group 0.11.0",
@@ -2641,18 +2586,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "k256"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea"
dependencies = [
"cfg-if 1.0.0",
"ecdsa 0.12.4",
"elliptic-curve 0.10.6",
"sha2",
]
[[package]]
name = "k256"
version = "0.10.4"
@@ -2660,8 +2593,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d"
dependencies = [
"cfg-if 1.0.0",
"ecdsa 0.13.4",
"elliptic-curve 0.11.12",
"ecdsa",
"elliptic-curve",
"sec1",
"sha2",
"sha3",
@@ -3181,6 +3114,7 @@ dependencies = [
"rocket",
"serde",
"serial_test",
"task",
"tokio",
"tokio-util 0.7.3",
"toml",
@@ -3812,24 +3746,14 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkcs8"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447"
dependencies = [
"der 0.4.5",
"spki 0.4.1",
]
[[package]]
name = "pkcs8"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0"
dependencies = [
"der 0.5.1",
"spki 0.5.4",
"der",
"spki",
"zeroize",
]
@@ -4454,7 +4378,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525"
dependencies = [
"crypto-bigint 0.3.2",
"crypto-bigint",
"hmac 0.11.0",
"zeroize",
]
@@ -4787,9 +4711,9 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1"
dependencies = [
"der 0.5.1",
"der",
"generic-array 0.14.5",
"pkcs8 0.8.0",
"pkcs8",
"subtle 2.4.1",
"zeroize",
]
@@ -4891,9 +4815,9 @@ dependencies = [
[[package]]
name = "serde-json-wasm"
version = "0.3.2"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "042ac496d97e5885149d34139bad1d617192770d7eb8f1866da2317ff4501853"
checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5"
dependencies = [
"serde",
]
@@ -5240,15 +5164,6 @@ dependencies = [
"lock_api",
]
[[package]]
name = "spki"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32"
dependencies = [
"der 0.4.5",
]
[[package]]
name = "spki"
version = "0.5.4"
@@ -5256,7 +5171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27"
dependencies = [
"base64ct",
"der 0.5.1",
"der",
]
[[package]]
@@ -5509,6 +5424,15 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "task"
version = "0.1.0"
dependencies = [
"log",
"tokio",
"tokio-util 0.7.3",
]
[[package]]
name = "tempfile"
version = "3.3.0"
@@ -5535,7 +5459,7 @@ dependencies = [
"ed25519-dalek",
"flex-error",
"futures",
"k256 0.10.4",
"k256",
"num-traits",
"once_cell",
"prost 0.10.3",
+1
View File
@@ -55,6 +55,7 @@ members = [
"common/pemstore",
"common/socks5/proxy-helpers",
"common/socks5/requests",
"common/task",
"common/topology",
"common/wasm-utils",
"explorer-api",
+14 -2
View File
@@ -119,6 +119,7 @@ async fn gateway_details(
.expect("The list of validator apis is empty");
let validator_client = validator_client::ApiClient::new(validator_api.clone());
log::trace!("Fetching list of gateways from: {}", validator_api);
let gateways = validator_client.get_cached_gateways().await.unwrap();
let valid_gateways = gateways
.into_iter()
@@ -186,6 +187,9 @@ pub async fn execute(matches: ArgMatches<'static>) {
let id = matches.value_of("id").unwrap(); // required for now
let already_init = if Config::default_config_file_path(Some(id)).exists() {
if matches.is_present("gateway") {
panic!("At the moment, gateway information can't be overwritten. If you want to point to a different gateway, client {}'s directory will need to be manually removed", id);
}
println!("Client \"{}\" was already initialised before! Config information will be overwritten (but keys will be kept)!", id);
true
} else {
@@ -210,12 +214,14 @@ pub async fn execute(matches: ArgMatches<'static>) {
let mut key_manager = KeyManager::new(&mut rng);
let chosen_gateway_id = matches.value_of("gateway");
log::trace!("Chosen gateway: {:?}", chosen_gateway_id);
let gateway_details = gateway_details(
config.get_base().get_validator_api_endpoints(),
chosen_gateway_id,
)
.await;
log::trace!("Used gateway: {}", gateway_details);
let shared_keys =
register_with_gateway(&gateway_details, key_manager.identity_keypair()).await;
@@ -238,8 +244,14 @@ pub async fn execute(matches: ArgMatches<'static>) {
.save_to_file(None)
.expect("Failed to save the config file");
println!("Saved configuration file to {:?}", config_save_location);
println!("Using gateway: {}", config.get_base().get_gateway_id(),);
println!("Client configuration completed.\n\n\n");
println!("Using gateway: {}", config.get_base().get_gateway_id());
log::debug!("Gateway id: {}", config.get_base().get_gateway_id());
log::debug!("Gateway owner: {}", config.get_base().get_gateway_owner());
log::debug!(
"Gateway listener: {}",
config.get_base().get_gateway_listener()
);
println!("Client configuration completed.");
show_address(&config);
}
+1 -5
View File
@@ -39,15 +39,11 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> C
.set_custom_validator_apis(parse_validators(raw_validators));
}
if let Some(gateway_id) = matches.value_of("gateway") {
config.get_base_mut().with_gateway_id(gateway_id);
}
if matches.is_present("disable-socket") {
config = config.with_socket(SocketType::None);
}
if let Some(port) = matches.value_of("port").map(|port| port.parse::<u16>()) {
if let Some(port) = matches.value_of("port").map(str::parse) {
if let Err(err) = port {
// if port was overridden, it must be parsable
panic!("Invalid port value provided - {:?}", err);
+3 -3
View File
@@ -70,7 +70,9 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
fn version_check(cfg: &Config) -> bool {
let binary_version = env!("CARGO_PKG_VERSION");
let config_version = cfg.get_base().get_version();
if binary_version != config_version {
if binary_version == config_version {
true
} else {
warn!("The mixnode binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
if is_minor_version_compatible(binary_version, config_version) {
info!("but they are still semver compatible. However, consider running the `upgrade` command");
@@ -79,8 +81,6 @@ fn version_check(cfg: &Config) -> bool {
error!("and they are semver incompatible! - please run the `upgrade` command before attempting `run` again");
false
}
} else {
true
}
}
+7 -7
View File
@@ -131,22 +131,22 @@ fn minor_0_12_upgrade(
config
}
fn do_upgrade(mut config: Config, matches: &ArgMatches<'_>, package_version: Version) {
fn do_upgrade(mut config: Config, matches: &ArgMatches<'_>, package_version: &Version) {
loop {
let config_version = parse_config_version(&config);
if config_version == package_version {
if &config_version == package_version {
println!("You're using the most recent version!");
return;
}
config = match config_version.major {
0 => match config_version.minor {
9 | 10 => outdated_upgrade(&config_version, &package_version),
11 => minor_0_12_upgrade(config, matches, &config_version, &package_version),
_ => unsupported_upgrade(&config_version, &package_version),
9 | 10 => outdated_upgrade(&config_version, package_version),
11 => minor_0_12_upgrade(config, matches, &config_version, package_version),
_ => unsupported_upgrade(&config_version, package_version),
},
_ => unsupported_upgrade(&config_version, &package_version),
_ => unsupported_upgrade(&config_version, package_version),
}
}
}
@@ -167,5 +167,5 @@ pub fn execute(matches: &ArgMatches<'_>) {
}
// here be upgrade path to 0.9.X and beyond based on version number from config
do_upgrade(existing_config, matches, package_version)
do_upgrade(existing_config, matches, &package_version)
}
+2
View File
@@ -108,5 +108,7 @@ fn setup_logging() {
.filter_module("want", log::LevelFilter::Warn)
.filter_module("tungstenite", log::LevelFilter::Warn)
.filter_module("tokio_tungstenite", log::LevelFilter::Warn)
.filter_module("handlebars", log::LevelFilter::Warn)
.filter_module("sled", log::LevelFilter::Warn)
.init();
}
+3
View File
@@ -187,6 +187,9 @@ pub async fn execute(matches: ArgMatches<'static>) {
let provider_address = matches.value_of("provider").unwrap();
let already_init = if Config::default_config_file_path(Some(id)).exists() {
if matches.is_present("gateway") {
panic!("At the moment, gateway information can't be overwritten. If you want to point to a different gateway, client {}'s directory will need to be manually removed", id);
}
println!("Socks5 client \"{}\" was already initialised before! Config information will be overwritten (but keys will be kept)!", id);
true
} else {
-4
View File
@@ -39,10 +39,6 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> C
.set_custom_validator_apis(parse_validators(raw_validators));
}
if let Some(gateway_id) = matches.value_of("gateway") {
config.get_base_mut().with_gateway_id(gateway_id);
}
if let Some(port) = matches.value_of("port").map(|port| port.parse::<u16>()) {
if let Err(err) = port {
// if port was overridden, it must be parsable
@@ -83,7 +83,7 @@ impl GatewayClient {
) -> Self {
GatewayClient {
authenticated: false,
disabled_credentials_mode: false,
disabled_credentials_mode: true,
bandwidth_remaining: 0,
gateway_address,
gateway_identity,
@@ -100,8 +100,8 @@ impl GatewayClient {
}
}
pub fn set_disabled_credentials_mode(&mut self, _disabled_credentials_mode: bool) {
self.disabled_credentials_mode = false;
pub fn set_disabled_credentials_mode(&mut self, disabled_credentials_mode: bool) {
self.disabled_credentials_mode = disabled_credentials_mode;
}
// TODO: later convert into proper builder methods
@@ -40,7 +40,7 @@ prost = { version = "0.10", default-features = false, optional = true }
flate2 = { version = "1.0.20", optional = true }
sha2 = { version = "0.9.5", optional = true }
itertools = { version = "0.10", optional = true }
cosmwasm-std = { version = "1.0.0-beta8", optional = true }
cosmwasm-std = { version = "1.0.0", optional = true }
execute = { path = "../../execute" }
[dev-dependencies]
@@ -189,23 +189,23 @@ impl NymdClient<SigningNymdClient> {
client: SigningNymdClient::connect_with_signer(endpoint, wallet, gas_price)?,
client_address: Some(client_address),
simulated_gas_multiplier: DEFAULT_SIMULATED_GAS_MULTIPLIER,
mixnet_contract_address: DEFAULT_NETWORK
mixnet_contract_address: network
.mixnet_contract_address()
.parse()
.expect("Error parsing mixnet contract address"),
vesting_contract_address: DEFAULT_NETWORK
vesting_contract_address: network
.vesting_contract_address()
.parse()
.expect("Error parsing vesting contract address"),
bandwidth_claim_contract_address: DEFAULT_NETWORK
bandwidth_claim_contract_address: network
.bandwidth_claim_contract_address()
.parse()
.expect("Error parsing bandwidth claim contract address"),
coconut_bandwidth_contract_address: DEFAULT_NETWORK
coconut_bandwidth_contract_address: network
.coconut_bandwidth_contract_address()
.parse()
.unwrap(),
multisig_contract_address: DEFAULT_NETWORK.multisig_contract_address().parse().unwrap(),
multisig_contract_address: network.multisig_contract_address().parse().unwrap(),
})
}
}
-4
View File
@@ -15,7 +15,6 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
fn template() -> &'static str;
fn config_file_name() -> String {
log::trace!("NymdConfig::config_file_name");
"config.toml".to_string()
}
@@ -23,7 +22,6 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
// default, most probable, implementations; can be easily overridden where required
fn default_config_directory(id: Option<&str>) -> PathBuf {
log::trace!("NymdConfig::default_config_directory");
if let Some(id) = id {
Self::default_root_directory().join(id).join("config")
} else {
@@ -32,7 +30,6 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
}
fn default_data_directory(id: Option<&str>) -> PathBuf {
log::trace!("NymdConfig::default_data_path");
if let Some(id) = id {
Self::default_root_directory().join(id).join("data")
} else {
@@ -41,7 +38,6 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
}
fn default_config_file_path(id: Option<&str>) -> PathBuf {
log::trace!("NymdConfig::default_config_file_path");
Self::default_config_directory(id).join(Self::config_file_name())
}
@@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cosmwasm-std = "1.0.0-beta6"
cosmwasm-std = "1.0.0"
schemars = "0.8"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
@@ -7,4 +7,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cosmwasm-std = "1.0.0-beta8"
cosmwasm-std = "1.0.0"
@@ -7,7 +7,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cosmwasm-std = "1.0.0-beta8"
cosmwasm-std = "1.0.0"
serde = { version = "1.0", features = ["derive"] }
serde_repr = "0.1"
@@ -9,6 +9,6 @@ edition = "2021"
cw-utils = { version = "0.13.1" }
cw3 = { version = "0.13.1" }
cw4 = { version = "0.13.1" }
cosmwasm-std = "1.0.0-beta6"
cosmwasm-std = "1.0.0"
schemars = "0.8"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
@@ -6,11 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cosmwasm-std = "1.0.0-beta8"
cosmwasm-std = "1.0.0"
mixnet-contract-common = { path = "../mixnet-contract" }
serde = { version = "1.0", features = ["derive"] }
schemars = "0.8"
cw-storage-plus = "0.13.2"
cw-storage-plus = "0.13.4"
config = { path = "../../config" }
[dev-dependencies]
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "task"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
log = "0.4"
tokio = { version = "1.19.1", features = ["rt-multi-thread", "net", "signal"] }
tokio-util = { version = "0.7.3", features = ["codec"] }
[dev-dependencies]
tokio = { version = "1.19.1", features = ["rt-multi-thread", "net", "signal", "test-util", "macros"] }
+6
View File
@@ -0,0 +1,6 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
pub mod shutdown;
pub use shutdown::{ShutdownListener, ShutdownNotifier};
+106
View File
@@ -0,0 +1,106 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use std::time::Duration;
use tokio::sync::watch::{self, error::SendError};
const SHUTDOWN_TIMER_SECS: u64 = 5;
/// Used to notify other tasks to gracefully shutdown
#[derive(Debug)]
pub struct ShutdownNotifier {
notify_tx: watch::Sender<()>,
notify_rx: Option<watch::Receiver<()>>,
}
impl Default for ShutdownNotifier {
fn default() -> Self {
let (notify_tx, notify_rx) = watch::channel(());
Self {
notify_tx,
notify_rx: Some(notify_rx),
}
}
}
impl ShutdownNotifier {
pub fn subscribe(&self) -> ShutdownListener {
ShutdownListener::new(
self.notify_rx
.as_ref()
.expect("Unable to subscribe to shutdown notifier that is already shutdown")
.clone(),
)
}
pub fn signal_shutdown(&self) -> Result<(), SendError<()>> {
self.notify_tx.send(())
}
pub async fn wait_for_shutdown(&mut self) {
if let Some(notify_rx) = self.notify_rx.take() {
drop(notify_rx);
}
tokio::select! {
_ = self.notify_tx.closed() => {
log::info!("All registered tasks succesfully shutdown");
},
_ = tokio::signal::ctrl_c() => {
log::info!("Forcing shutdown");
}
_ = tokio::time::sleep(Duration::from_secs(SHUTDOWN_TIMER_SECS)) => {
log::info!("Timout reached, forcing shutdown");
},
}
}
}
/// Listen for shutdown notifications
#[derive(Clone, Debug)]
pub struct ShutdownListener {
shutdown: bool,
notify: watch::Receiver<()>,
}
impl ShutdownListener {
pub fn new(notify: watch::Receiver<()>) -> ShutdownListener {
ShutdownListener {
shutdown: false,
notify,
}
}
pub fn is_shutdown(&self) -> bool {
self.shutdown
}
pub async fn recv(&mut self) {
if self.shutdown {
return;
}
let _ = self.notify.changed().await;
self.shutdown = true;
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn signal_shutdown() {
let shutdown = ShutdownNotifier::default();
let mut listener = shutdown.subscribe();
let task = tokio::spawn(async move {
tokio::select! {
_ = listener.recv() => 42,
}
});
shutdown.signal_shutdown().unwrap();
assert_eq!(task.await.unwrap(), 42);
}
}
+10
View File
@@ -93,6 +93,16 @@ impl Node {
}
}
impl fmt::Display for Node {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Node(id: {}, owner: {}, stake: {}, location: {}, host: {})",
self.identity_key, self.owner, self.stake, self.location, self.host,
)
}
}
impl filter::Versioned for Node {
fn version(&self) -> String {
self.version.clone()
+81 -40
View File
@@ -60,12 +60,24 @@ dependencies = [
"serde",
]
[[package]]
name = "base16ct"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce"
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "base64ct"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179"
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -239,9 +251,9 @@ dependencies = [
[[package]]
name = "const-oid"
version = "0.6.2"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b"
checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3"
[[package]]
name = "contracts-common"
@@ -252,9 +264,9 @@ dependencies = [
[[package]]
name = "cosmwasm-crypto"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e70111e9701c3ec43bfbff0e523cd4cb115876b4d3433813436dd0934ee962"
checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd"
dependencies = [
"digest 0.9.0",
"ed25519-zebra",
@@ -265,18 +277,18 @@ dependencies = [
[[package]]
name = "cosmwasm-derive"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58bc2ad5d86be5f6068833f63e20786768db6890019c095dd7775232184fb7b3"
checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4"
dependencies = [
"syn",
]
[[package]]
name = "cosmwasm-schema"
version = "1.0.0-beta7"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63f79866e7b2190b6b6cb06959e308183c8d9511a8530f7292073f3cddc963db"
checksum = "772e80bbad231a47a2068812b723a1ff81dd4a0d56c9391ac748177bea3a61da"
dependencies = [
"schemars",
"serde_json",
@@ -284,9 +296,9 @@ dependencies = [
[[package]]
name = "cosmwasm-std"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915ca82bd944f116f3a9717481f3fa657e4a73f28c4887288761ebb24e6fbe10"
checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195"
dependencies = [
"base64",
"cosmwasm-crypto",
@@ -301,9 +313,9 @@ dependencies = [
[[package]]
name = "cosmwasm-storage"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c4be9fd8c9d3ae7d0c32a925ecbc20707007ce0cba1f7538c0d78b7a2d3729b"
checksum = "d18403b07304d15d304dad11040d45bbcaf78d603b4be3fb5e2685c16f9229b5"
dependencies = [
"cosmwasm-std",
"serde",
@@ -340,9 +352,9 @@ dependencies = [
[[package]]
name = "crypto-bigint"
version = "0.2.11"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03"
checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21"
dependencies = [
"generic-array 0.14.5",
"rand_core 0.6.3",
@@ -394,9 +406,9 @@ dependencies = [
[[package]]
name = "cw-controllers"
version = "0.13.2"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bc6d042b14823b0e9f33f5cdd67a1eb9b16a7d79f7547b1a73c8870b518b97b"
checksum = "4f0bc6019b4d3d81e11f5c384bcce7173e2210bd654d75c6c9668e12cca05dfa"
dependencies = [
"cosmwasm-std",
"cw-storage-plus",
@@ -427,9 +439,9 @@ dependencies = [
[[package]]
name = "cw-storage-plus"
version = "0.13.2"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9336ecef1e19d56cf6e3e932475fc6a3dee35eec5a386e07917a1d1ba6bb0e35"
checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a"
dependencies = [
"cosmwasm-std",
"schemars",
@@ -438,9 +450,9 @@ dependencies = [
[[package]]
name = "cw-utils"
version = "0.13.2"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "babd2c090f39d07ce5bf2556962305e795daa048ce20a93709eb591476e4a29e"
checksum = "9dbaecb78c8e8abfd6b4258c7f4fbeb5c49a5e45ee4d910d3240ee8e1d714e1b"
dependencies = [
"cosmwasm-std",
"schemars",
@@ -538,9 +550,9 @@ dependencies = [
[[package]]
name = "der"
version = "0.4.5"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4"
checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c"
dependencies = [
"const-oid",
]
@@ -582,13 +594,13 @@ checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf"
[[package]]
name = "ecdsa"
version = "0.12.4"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372"
checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9"
dependencies = [
"der",
"elliptic-curve",
"hmac",
"rfc6979",
"signature",
]
@@ -638,16 +650,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "elliptic-curve"
version = "0.10.6"
version = "0.11.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b"
checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6"
dependencies = [
"base16ct",
"crypto-bigint",
"der",
"ff",
"generic-array 0.14.5",
"group",
"pkcs8",
"rand_core 0.6.3",
"sec1",
"subtle 2.4.1",
"zeroize",
]
@@ -680,9 +694,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "ff"
version = "0.10.1"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f"
checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924"
dependencies = [
"rand_core 0.6.3",
"subtle 2.4.1",
@@ -787,9 +801,9 @@ dependencies = [
[[package]]
name = "group"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912"
checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89"
dependencies = [
"ff",
"rand_core 0.6.3",
@@ -910,13 +924,14 @@ dependencies = [
[[package]]
name = "k256"
version = "0.9.6"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea"
checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d"
dependencies = [
"cfg-if",
"ecdsa",
"elliptic-curve",
"sec1",
"sha2",
]
@@ -1190,12 +1205,13 @@ dependencies = [
[[package]]
name = "pkcs8"
version = "0.7.6"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447"
checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0"
dependencies = [
"der",
"spki",
"zeroize",
]
[[package]]
@@ -1356,6 +1372,17 @@ version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rfc6979"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525"
dependencies = [
"crypto-bigint",
"hmac",
"zeroize",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
@@ -1401,6 +1428,19 @@ dependencies = [
"syn",
]
[[package]]
name = "sec1"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1"
dependencies = [
"der",
"generic-array 0.14.5",
"pkcs8",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "semver"
version = "1.0.4"
@@ -1418,9 +1458,9 @@ dependencies = [
[[package]]
name = "serde-json-wasm"
version = "0.3.2"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "042ac496d97e5885149d34139bad1d617192770d7eb8f1866da2317ff4501853"
checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5"
dependencies = [
"serde",
]
@@ -1529,10 +1569,11 @@ dependencies = [
[[package]]
name = "spki"
version = "0.4.1"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32"
checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27"
dependencies = [
"base64ct",
"der",
]
+2 -2
View File
@@ -14,8 +14,8 @@ config = { path = "../../common/config"}
[dependencies]
bandwidth-claim-contract = { path = "../../common/bandwidth-claim-contract" }
cosmwasm-std = "1.0.0-beta8"
cosmwasm-storage = "1.0.0-beta8"
cosmwasm-std = "1.0.0"
cosmwasm-storage = "1.0.0"
schemars = "0.8"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
+4 -4
View File
@@ -13,10 +13,10 @@ bandwidth-claim-contract = { path = "../../common/bandwidth-claim-contract" }
coconut-bandwidth-contract-common = { path = "../../common/cosmwasm-smart-contracts/coconut-bandwidth-contract" }
config = { path = "../../common/config"}
cosmwasm-std = "1.0.0-beta8"
cosmwasm-storage = "1.0.0-beta8"
cw-storage-plus = "0.13.2"
cw-controllers = "0.13.2"
cosmwasm-std = "1.0.0"
cosmwasm-storage = "1.0.0"
cw-storage-plus = "0.13.4"
cw-controllers = "0.13.4"
schemars = "0.8"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
+4 -4
View File
@@ -20,9 +20,9 @@ mixnet-contract-common = { path = "../../common/cosmwasm-smart-contracts/mixnet-
vesting-contract-common = { path = "../../common/cosmwasm-smart-contracts/vesting-contract" }
config = { path = "../../common/config"}
cosmwasm-std = "1.0.0-beta8"
cosmwasm-storage = "1.0.0-beta8"
cw-storage-plus = "0.13.2"
cosmwasm-std = "1.0.0"
cosmwasm-storage = "1.0.0"
cw-storage-plus = "0.13.4"
az = "1.2.0"
bs58 = "0.4.0"
@@ -33,7 +33,7 @@ time = { version = "0.3", features = ["macros"] }
hex = "0.4.3"
[dev-dependencies]
cosmwasm-schema = "1.0.0-beta3"
cosmwasm-schema = "1.0.0"
fixed = "1.1"
rand_chacha = "0.2"
rand = "0.7"
@@ -23,7 +23,7 @@ cw3 = { version = "0.13.1" }
cw3-fixed-multisig = { version = "0.13.1", features = ["library"] }
cw4 = { version = "0.13.1" }
cw-storage-plus = { version = "0.13.1" }
cosmwasm-std = { version = "1.0.0-beta6" }
cosmwasm-std = { version = "1.0.0" }
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.23" }
@@ -31,6 +31,6 @@ thiserror = { version = "1.0.23" }
multisig-contract-common = { path= "../../../common/cosmwasm-smart-contracts/multisig-contract" }
[dev-dependencies]
cosmwasm-schema = { version = "1.0.0-beta6" }
cosmwasm-schema = { version = "1.0.0" }
cw4-group = { path = "../cw4-group", version = "0.13.1" }
cw-multi-test = { version = "0.13.1" }
+2 -2
View File
@@ -29,10 +29,10 @@ cw2 = { version = "0.13.1" }
cw4 = { version = "0.13.1" }
cw-controllers = { version = "0.13.1" }
cw-storage-plus = { version = "0.13.1" }
cosmwasm-std = { version = "1.0.0-beta6" }
cosmwasm-std = { version = "1.0.0" }
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.23" }
[dev-dependencies]
cosmwasm-schema = { version = "1.0.0-beta6" }
cosmwasm-schema = { version = "1.0.0" }
+2 -2
View File
@@ -18,8 +18,8 @@ mixnet-contract-common = { path = "../../common/cosmwasm-smart-contracts/mixnet-
vesting-contract-common = { path = "../../common/cosmwasm-smart-contracts/vesting-contract" }
config = { path = "../../common/config" }
cosmwasm-std = { version = "1.0.0-beta8"}
cw-storage-plus = { version = "0.13.1", features = ["iterator"] }
cosmwasm-std = { version = "1.0.0 "}
cw-storage-plus = { version = "0.13.4", features = ["iterator"] }
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
@@ -91,14 +91,14 @@ export const BondBreakdownTable: React.FC = () => {
}}
align="left"
>
Bond total
Stake total
</TableCell>
<TableCell align="left" data-testid="bond-total-amount">
{bonds.bondsTotal}
</TableCell>
</TableRow>
<TableRow>
<TableCell align="left">Self</TableCell>
<TableCell align="left">Bond</TableCell>
<TableCell align="left" data-testid="pledge-total-amount">
{bonds.pledges}
</TableCell>
@@ -177,7 +177,7 @@ export const BondBreakdownTable: React.FC = () => {
}}
align="left"
>
Stake
Amount
</TableCell>
<TableCell
sx={{
@@ -187,7 +187,7 @@ export const BondBreakdownTable: React.FC = () => {
}}
align="left"
>
Share from bond
Share of stake
</TableCell>
</TableRow>
</TableHead>
+2 -2
View File
@@ -29,7 +29,7 @@ const columns: ColumnsType[] = [
{
field: 'bond',
title: 'Bond',
title: 'Stake',
flex: 1,
headerAlign: 'left',
},
@@ -95,7 +95,7 @@ const PageMixnodeDetailWithState: React.FC = () => {
<Grid container spacing={2} mt={0}>
<Grid item xs={12}>
<ContentCard title="Bond Breakdown">
<ContentCard title="Stake Breakdown">
<BondBreakdownTable />
</ContentCard>
</Grid>
+46 -63
View File
@@ -125,24 +125,6 @@ export const PageMixnodes: React.FC = () => {
</>
),
},
{
field: 'bond',
headerName: 'Bond',
renderHeader: () => <CustomColumnHeading headingTitle="Bond" />,
type: 'number',
headerClassName: 'MuiDataGrid-header-override',
width: 200,
headerAlign: 'left',
renderCell: (params: GridRenderCellParams) => (
<MuiLink
sx={getCellStyles(theme, params.row)}
component={RRDLink}
to={`/network-components/mixnode/${params.row.identity_key}`}
>
{currencyToString(params.value)}
</MuiLink>
),
},
{
field: 'location',
headerName: 'Location',
@@ -162,24 +144,6 @@ export const PageMixnodes: React.FC = () => {
</Button>
),
},
{
field: 'self_percentage',
headerName: 'Self %',
width: 110,
headerClassName: 'MuiDataGrid-header-override',
renderHeader: () => <CustomColumnHeading headingTitle="Self %" />,
type: 'number',
headerAlign: 'left',
renderCell: (params: GridRenderCellParams) => (
<MuiLink
sx={getCellStyles(theme, params.row)}
component={RRDLink}
to={`/network-components/mixnode/${params.row.identity_key}`}
>
{params.value}%
</MuiLink>
),
},
{
field: 'host',
headerName: 'Host',
@@ -198,19 +162,59 @@ export const PageMixnodes: React.FC = () => {
),
},
{
field: 'layer',
headerName: 'Layer',
renderHeader: () => <CustomColumnHeading headingTitle="Layer" />,
field: 'bond',
headerName: 'Stake',
renderHeader: () => <CustomColumnHeading headingTitle="Stake" />,
type: 'number',
headerClassName: 'MuiDataGrid-header-override',
width: 110,
width: 200,
headerAlign: 'left',
renderCell: (params: GridRenderCellParams) => (
<MuiLink
sx={{ ...getCellStyles(theme, params.row), textAlign: 'left' }}
sx={getCellStyles(theme, params.row)}
component={RRDLink}
to={`/network-components/mixnode/${params.row.identity_key}`}
>
{params.value}
{currencyToString(params.value)}
</MuiLink>
),
},
{
field: 'stake_saturation',
headerName: 'Stake Saturation',
renderHeader: () => <CustomColumnHeading headingTitle="Stake Saturation" />,
headerClassName: 'MuiDataGrid-header-override',
width: 175,
headerAlign: 'left',
renderCell: (params: GridRenderCellParams) => (
<MuiLink
sx={{
textAlign: 'left',
color: params.value > 100 ? theme.palette.warning.main : 'inherit',
...getCellStyles(theme, params.row),
}}
component={RRDLink}
to={`/network-components/mixnode/${params.row.identity_key}`}
>
{`${params.value.toFixed(2)} %`}
</MuiLink>
),
},
{
field: 'self_percentage',
headerName: 'Self %',
width: 110,
headerClassName: 'MuiDataGrid-header-override',
renderHeader: () => <CustomColumnHeading headingTitle="Self %" />,
type: 'number',
headerAlign: 'left',
renderCell: (params: GridRenderCellParams) => (
<MuiLink
sx={getCellStyles(theme, params.row)}
component={RRDLink}
to={`/network-components/mixnode/${params.row.identity_key}`}
>
{params.value}%
</MuiLink>
),
},
@@ -248,27 +252,6 @@ export const PageMixnodes: React.FC = () => {
</MuiLink>
),
},
{
field: 'stake_saturation',
headerName: 'Stake Saturation',
renderHeader: () => <CustomColumnHeading headingTitle="Stake Saturation" />,
headerClassName: 'MuiDataGrid-header-override',
width: 175,
headerAlign: 'left',
renderCell: (params: GridRenderCellParams) => (
<MuiLink
sx={{
textAlign: 'left',
color: params.value > 100 ? theme.palette.warning.main : 'inherit',
...getCellStyles(theme, params.row),
}}
component={RRDLink}
to={`/network-components/mixnode/${params.row.identity_key}`}
>
{`${params.value.toFixed(2)} %`}
</MuiLink>
),
},
];
const handlePageSize = (event: SelectChangeEvent<string>) => {
+1
View File
@@ -43,6 +43,7 @@ mixnode-common = { path="../common/mixnode-common" }
nonexhaustive-delayqueue = { path="../common/nonexhaustive-delayqueue" }
nymsphinx = { path="../common/nymsphinx" }
pemstore = { path="../common/pemstore" }
task = { path = "../common/task" }
topology = { path="../common/topology" }
validator-client = { path="../common/client-libs/validator-client" }
version-checker = { path="../common/version-checker" }
@@ -5,6 +5,7 @@ use crate::node::listener::connection_handler::packet_processing::{
MixProcessingResult, PacketProcessor,
};
use crate::node::packet_delayforwarder::PacketDelayForwardSender;
use crate::node::ShutdownListener;
use futures::StreamExt;
use log::{error, info};
use nymsphinx::forwarding::packet::MixPacket;
@@ -69,28 +70,40 @@ impl ConnectionHandler {
}
}
pub(crate) async fn handle_connection(self, conn: TcpStream, remote: SocketAddr) {
pub(crate) async fn handle_connection(
self,
conn: TcpStream,
remote: SocketAddr,
mut shutdown: ShutdownListener,
) {
debug!("Starting connection handler for {:?}", remote);
let mut framed_conn = Framed::new(conn, SphinxCodec);
while let Some(framed_sphinx_packet) = framed_conn.next().await {
match framed_sphinx_packet {
Ok(framed_sphinx_packet) => {
// TODO: benchmark spawning tokio task with full processing vs just processing it
// synchronously (without delaying inside of course,
// delay is moved to a global DelayQueue)
// under higher load in single and multi-threaded situation.
while !shutdown.is_shutdown() {
tokio::select! {
Some(framed_sphinx_packet) = framed_conn.next() => {
match framed_sphinx_packet {
Ok(framed_sphinx_packet) => {
// TODO: benchmark spawning tokio task with full processing vs just processing it
// synchronously (without delaying inside of course,
// delay is moved to a global DelayQueue)
// under higher load in single and multi-threaded situation.
// in theory we could process multiple sphinx packet from the same connection in parallel,
// but we already handle multiple concurrent connections so if anything, making
// that change would only slow things down
self.handle_received_packet(framed_sphinx_packet);
}
Err(err) => {
error!(
"The socket connection got corrupted with error: {:?}. Closing the socket",
err
);
return;
// in theory we could process multiple sphinx packet from the same connection in parallel,
// but we already handle multiple concurrent connections so if anything, making
// that change would only slow things down
self.handle_received_packet(framed_sphinx_packet);
}
Err(err) => {
error!(
"The socket connection got corrupted with error: {:?}. Closing the socket",
err
);
return;
}
}
},
_ = shutdown.recv() => {
log::trace!("ConnectionHandler: received shutdown");
}
}
}
@@ -99,5 +112,6 @@ impl ConnectionHandler {
"Closing connection from {:?}",
framed_conn.into_inner().peer_addr()
);
log::trace!("ConnectionHandler: Exiting");
}
}
+21 -9
View File
@@ -8,18 +8,22 @@ use std::process;
use tokio::net::TcpListener;
use tokio::task::JoinHandle;
use super::ShutdownListener;
pub(crate) mod connection_handler;
pub(crate) struct Listener {
address: SocketAddr,
shutdown: ShutdownListener,
}
impl Listener {
pub(crate) fn new(address: SocketAddr) -> Self {
Listener { address }
pub(crate) fn new(address: SocketAddr, shutdown: ShutdownListener) -> Self {
Listener { address, shutdown }
}
async fn run(&mut self, connection_handler: ConnectionHandler) {
log::trace!("Starting Listener");
let listener = match TcpListener::bind(self.address).await {
Ok(listener) => listener,
Err(err) => {
@@ -28,15 +32,23 @@ impl Listener {
}
};
loop {
match listener.accept().await {
Ok((socket, remote_addr)) => {
let handler = connection_handler.clone();
tokio::spawn(handler.handle_connection(socket, remote_addr));
while !self.shutdown.is_shutdown() {
tokio::select! {
connection = listener.accept() => {
match connection {
Ok((socket, remote_addr)) => {
let handler = connection_handler.clone();
tokio::spawn(handler.handle_connection(socket, remote_addr, self.shutdown.clone()));
}
Err(err) => warn!("Failed to accept incoming connection - {:?}", err),
}
},
_ = self.shutdown.recv() => {
log::trace!("Listener: Received shutdown");
}
Err(err) => warn!("Failed to accept incoming connection - {:?}", err),
}
};
}
log::trace!("Listener: Exiting");
}
pub(crate) fn start(mut self, connection_handler: ConnectionHandler) -> JoinHandle<()> {
+40 -11
View File
@@ -25,6 +25,7 @@ use rand::thread_rng;
use std::net::SocketAddr;
use std::process;
use std::sync::Arc;
use task::{ShutdownListener, ShutdownNotifier};
use version_checker::parse_version;
mod http;
@@ -149,11 +150,15 @@ impl MixNode {
});
}
fn start_node_stats_controller(&self) -> (SharedNodeStats, node_statistics::UpdateSender) {
fn start_node_stats_controller(
&self,
shutdown: ShutdownListener,
) -> (SharedNodeStats, node_statistics::UpdateSender) {
info!("Starting node stats controller...");
let controller = node_statistics::Controller::new(
self.config.get_node_stats_logging_delay(),
self.config.get_node_stats_updating_delay(),
shutdown,
);
let node_stats_pointer = controller.get_node_stats_data_pointer();
let update_sender = controller.start();
@@ -165,6 +170,7 @@ impl MixNode {
&self,
node_stats_update_sender: node_statistics::UpdateSender,
delay_forwarding_channel: PacketDelayForwardSender,
shutdown: ShutdownListener,
) {
info!("Starting socket listener...");
@@ -178,12 +184,13 @@ impl MixNode {
self.config.get_mix_port(),
);
Listener::new(listening_address).start(connection_handler);
Listener::new(listening_address, shutdown).start(connection_handler);
}
fn start_packet_delay_forwarder(
&mut self,
node_stats_update_sender: node_statistics::UpdateSender,
shutdown: ShutdownListener,
) -> PacketDelayForwardSender {
info!("Starting packet delay-forwarder...");
@@ -197,6 +204,7 @@ impl MixNode {
let mut packet_forwarder = DelayForwarder::new(
mixnet_client::Client::new(client_config),
node_stats_update_sender,
shutdown,
);
let packet_sender = packet_forwarder.sender();
@@ -259,7 +267,10 @@ impl MixNode {
let existing_nodes = match validator_client.get_cached_mixnodes().await {
Ok(nodes) => nodes,
Err(err) => {
error!("failed to grab initial network mixnodes - {}\n Please try to startup again in few minutes", err);
error!(
"failed to grab initial network mixnodes - {err}\n \
Please try to startup again in few minutes",
);
process::exit(1);
}
};
@@ -272,16 +283,26 @@ impl MixNode {
.map(|node| node.mix_node.identity_key.clone())
}
async fn wait_for_interrupt(&self) {
async fn wait_for_interrupt(&self, mut shutdown: ShutdownNotifier) {
if let Err(e) = tokio::signal::ctrl_c().await {
error!(
"There was an error while capturing SIGINT - {:?}. We will terminate regardless",
"There was an error while capturing SIGINT - {:?}. \
We will terminate regardless",
e
);
}
println!(
"Received SIGINT - the mixnode will terminate now (threads are not yet nicely stopped, if you see stack traces that's alright)."
"Received SIGINT - the mixnode will terminate now \
(threads are not yet nicely stopped, if you see stack traces that's alright)."
);
log::info!("Sending shutdown");
shutdown.signal_shutdown().ok();
log::info!("Waiting for tasks to finish... (Press ctrl-c to force)");
shutdown.wait_for_shutdown().await;
log::info!("Stopping nym mixnode");
}
pub async fn run(&mut self) {
@@ -299,15 +320,23 @@ impl MixNode {
}
}
let (node_stats_pointer, node_stats_update_sender) = self.start_node_stats_controller();
let delay_forwarding_channel =
self.start_packet_delay_forwarder(node_stats_update_sender.clone());
self.start_socket_listener(node_stats_update_sender, delay_forwarding_channel);
let shutdown = ShutdownNotifier::default();
let (node_stats_pointer, node_stats_update_sender) =
self.start_node_stats_controller(shutdown.subscribe());
let delay_forwarding_channel = self
.start_packet_delay_forwarder(node_stats_update_sender.clone(), shutdown.subscribe());
self.start_socket_listener(
node_stats_update_sender,
delay_forwarding_channel,
shutdown.subscribe(),
);
// TODO: these two also needs to be shutdown
let atomic_verloc_results = self.start_verloc_measurements();
self.start_http_api(atomic_verloc_results, node_stats_pointer);
info!("Finished nym mixnode startup procedure - it should now be able to receive mix traffic!");
self.wait_for_interrupt().await
self.wait_for_interrupt(shutdown).await
}
}
+72 -21
View File
@@ -9,6 +9,8 @@ use std::sync::Arc;
use std::time::{Duration, SystemTime};
use tokio::sync::{RwLock, RwLockReadGuard};
use super::ShutdownListener;
// convenience aliases
type PacketsMap = HashMap<String, u64>;
type PacketDataReceiver = mpsc::UnboundedReceiver<PacketEvent>;
@@ -209,28 +211,45 @@ impl CurrentPacketData {
struct UpdateHandler {
current_data: CurrentPacketData,
update_receiver: PacketDataReceiver,
shutdown: ShutdownListener,
}
impl UpdateHandler {
fn new(current_data: CurrentPacketData, update_receiver: PacketDataReceiver) -> Self {
fn new(
current_data: CurrentPacketData,
update_receiver: PacketDataReceiver,
shutdown: ShutdownListener,
) -> Self {
UpdateHandler {
current_data,
update_receiver,
shutdown,
}
}
async fn run(&mut self) {
while let Some(packet_data) = self.update_receiver.next().await {
match packet_data {
PacketEvent::Received => self.current_data.increment_received(),
PacketEvent::Sent(destination) => {
self.current_data.increment_sent(destination).await
log::trace!("Starting UpdateHandler");
while !self.shutdown.is_shutdown() {
tokio::select! {
Some(packet_data) = self.update_receiver.next() => {
match packet_data {
PacketEvent::Received => self.current_data.increment_received(),
PacketEvent::Sent(destination) => {
self.current_data.increment_sent(destination).await
}
PacketEvent::Dropped(destination) => {
self.current_data.increment_dropped(destination).await
}
}
}
PacketEvent::Dropped(destination) => {
self.current_data.increment_dropped(destination).await
_ = self.shutdown.recv() => {
log::trace!("UpdateHandler: Received shutdown");
break;
}
}
}
log::trace!("UpdateHandler: Exiting");
}
}
@@ -274,6 +293,7 @@ struct StatsUpdater {
updating_delay: Duration,
current_packet_data: CurrentPacketData,
current_stats: SharedNodeStats,
shutdown: ShutdownListener,
}
impl StatsUpdater {
@@ -281,11 +301,13 @@ impl StatsUpdater {
updating_delay: Duration,
current_packet_data: CurrentPacketData,
current_stats: SharedNodeStats,
shutdown: ShutdownListener,
) -> Self {
StatsUpdater {
updating_delay,
current_packet_data,
current_stats,
shutdown,
}
}
@@ -295,11 +317,16 @@ impl StatsUpdater {
self.current_stats.update(received, sent, dropped).await;
}
async fn run(&self) {
loop {
tokio::time::sleep(self.updating_delay).await;
self.update_stats().await
async fn run(&mut self) {
while !self.shutdown.is_shutdown() {
tokio::select! {
_ = tokio::time::sleep(self.updating_delay) => self.update_stats().await,
_ = self.shutdown.recv() => {
log::trace!("StatsUpdater: Received shutdown");
}
}
}
log::trace!("StatsUpdater: Exiting");
}
}
@@ -308,13 +335,15 @@ impl StatsUpdater {
struct PacketStatsConsoleLogger {
logging_delay: Duration,
stats: SharedNodeStats,
shutdown: ShutdownListener,
}
impl PacketStatsConsoleLogger {
fn new(logging_delay: Duration, stats: SharedNodeStats) -> Self {
fn new(logging_delay: Duration, stats: SharedNodeStats, shutdown: ShutdownListener) -> Self {
PacketStatsConsoleLogger {
logging_delay,
stats,
shutdown,
}
}
@@ -387,10 +416,16 @@ impl PacketStatsConsoleLogger {
}
async fn run(&mut self) {
loop {
tokio::time::sleep(self.logging_delay).await;
self.log_running_stats().await;
log::trace!("Starting PacketStatsConsoleLogger");
while !self.shutdown.is_shutdown() {
tokio::select! {
_ = tokio::time::sleep(self.logging_delay) => self.log_running_stats().await,
_ = self.shutdown.recv() => {
log::trace!("PacketStatsConsoleLogger: Received shutdown");
}
};
}
log::trace!("PacketStatsConsoleLogger: Exiting");
}
}
@@ -413,19 +448,32 @@ pub struct Controller {
}
impl Controller {
pub(crate) fn new(logging_delay: Duration, stats_updating_delay: Duration) -> Self {
pub(crate) fn new(
logging_delay: Duration,
stats_updating_delay: Duration,
shutdown: ShutdownListener,
) -> Self {
let (sender, receiver) = mpsc::unbounded();
let shared_packet_data = CurrentPacketData::new();
let shared_node_stats = SharedNodeStats::new();
Controller {
update_handler: UpdateHandler::new(shared_packet_data.clone(), receiver),
update_handler: UpdateHandler::new(
shared_packet_data.clone(),
receiver,
shutdown.clone(),
),
update_sender: UpdateSender::new(sender),
console_logger: PacketStatsConsoleLogger::new(logging_delay, shared_node_stats.clone()),
console_logger: PacketStatsConsoleLogger::new(
logging_delay,
shared_node_stats.clone(),
shutdown.clone(),
),
stats_updater: StatsUpdater::new(
stats_updating_delay,
shared_packet_data,
shared_node_stats.clone(),
shutdown,
),
node_stats: shared_node_stats,
}
@@ -441,7 +489,7 @@ impl Controller {
pub(crate) fn start(self) -> UpdateSender {
// move out of self
let mut update_handler = self.update_handler;
let stats_updater = self.stats_updater;
let mut stats_updater = self.stats_updater;
let mut console_logger = self.console_logger;
tokio::spawn(async move { update_handler.run().await });
@@ -455,12 +503,15 @@ impl Controller {
#[cfg(test)]
mod tests {
use super::*;
use task::ShutdownNotifier;
#[tokio::test]
async fn node_stats_reported_are_received() {
let logging_delay = Duration::from_millis(20);
let stats_updating_delay = Duration::from_millis(10);
let node_stats_controller = Controller::new(logging_delay, stats_updating_delay);
let shutdown = ShutdownNotifier::default();
let node_stats_controller =
Controller::new(logging_delay, stats_updating_delay, shutdown.subscribe());
let node_stats_pointer = node_stats_controller.get_node_stats_data_pointer();
let update_sender = node_stats_controller.start();
+20 -2
View File
@@ -9,6 +9,8 @@ use nymsphinx::forwarding::packet::MixPacket;
use std::io;
use tokio::time::Instant;
use super::ShutdownListener;
// Delay + MixPacket vs Instant + MixPacket
// rather than using Duration directly, we use an Instant, this way we minimise skew due to
@@ -26,13 +28,18 @@ where
packet_sender: PacketDelayForwardSender,
packet_receiver: PacketDelayForwardReceiver,
node_stats_update_sender: UpdateSender,
shutdown: ShutdownListener,
}
impl<C> DelayForwarder<C>
where
C: mixnet_client::SendWithoutResponse,
{
pub(crate) fn new(client: C, node_stats_update_sender: UpdateSender) -> DelayForwarder<C> {
pub(crate) fn new(
client: C,
node_stats_update_sender: UpdateSender,
shutdown: ShutdownListener,
) -> DelayForwarder<C> {
let (packet_sender, packet_receiver) = mpsc::unbounded();
DelayForwarder::<C> {
@@ -41,6 +48,7 @@ where
packet_sender,
packet_receiver,
node_stats_update_sender,
shutdown,
}
}
@@ -97,6 +105,7 @@ where
}
pub(crate) async fn run(&mut self) {
log::trace!("Starting DelayForwarder");
loop {
tokio::select! {
delayed = self.delay_queue.next() => {
@@ -107,8 +116,13 @@ where
// and hence it can't happen that ALL senders are dropped
self.handle_new_packet(new_packet.unwrap())
}
_ = self.shutdown.recv() => {
log::trace!("DelayForwarder: Received shutdown");
break;
}
}
}
log::trace!("DelayForwarder: Exiting");
}
}
@@ -120,6 +134,8 @@ mod tests {
use std::sync::{Arc, Mutex};
use std::time::Duration;
use task::ShutdownNotifier;
use nymsphinx::addressing::nodes::NymNodeRoutingAddress;
use nymsphinx_params::packet_sizes::PacketSize;
use nymsphinx_params::PacketMode;
@@ -189,7 +205,9 @@ mod tests {
let node_stats_update_sender = UpdateSender::new(stats_sender);
let client = TestClient::default();
let client_packets_sent = client.packets_sent.clone();
let mut delay_forwarder = DelayForwarder::new(client, node_stats_update_sender);
let shutdown = ShutdownNotifier::default();
let mut delay_forwarder =
DelayForwarder::new(client, node_stats_update_sender, shutdown.subscribe());
let packet_sender = delay_forwarder.sender();
// Spawn the worker, listening on packet_sender channel
+42 -120
View File
@@ -328,7 +328,7 @@ checksum = "873faa4363bfc54c36a48321da034c92a0645a363eed34d948683ffc1706e37f"
dependencies = [
"bs58",
"hmac",
"k256 0.10.2",
"k256",
"once_cell",
"pbkdf2",
"rand_core 0.6.3",
@@ -763,12 +763,6 @@ dependencies = [
"url",
]
[[package]]
name = "const-oid"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b"
[[package]]
name = "const-oid"
version = "0.7.1"
@@ -854,10 +848,10 @@ checksum = "8413275b23cb5a0734d9d1e3e33f0b5b94547c1e94776dbc3149dbf46588a533"
dependencies = [
"bip32",
"cosmos-sdk-proto",
"ecdsa 0.13.4",
"ecdsa",
"eyre",
"getrandom 0.2.5",
"k256 0.10.2",
"k256",
"prost",
"prost-types",
"rand_core 0.6.3",
@@ -871,31 +865,31 @@ dependencies = [
[[package]]
name = "cosmwasm-crypto"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e70111e9701c3ec43bfbff0e523cd4cb115876b4d3433813436dd0934ee962"
checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd"
dependencies = [
"digest 0.9.0",
"ed25519-zebra",
"k256 0.9.6",
"k256",
"rand_core 0.6.3",
"thiserror",
]
[[package]]
name = "cosmwasm-derive"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58bc2ad5d86be5f6068833f63e20786768db6890019c095dd7775232184fb7b3"
checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4"
dependencies = [
"syn",
]
[[package]]
name = "cosmwasm-std"
version = "1.0.0-beta8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915ca82bd944f116f3a9717481f3fa657e4a73f28c4887288761ebb24e6fbe10"
checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195"
dependencies = [
"base64",
"cosmwasm-crypto",
@@ -976,18 +970,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "crypto-bigint"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03"
dependencies = [
"generic-array 0.14.5",
"rand_core 0.6.3",
"subtle",
"zeroize",
]
[[package]]
name = "crypto-bigint"
version = "0.3.2"
@@ -1096,9 +1078,9 @@ dependencies = [
[[package]]
name = "cw-storage-plus"
version = "0.13.2"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9336ecef1e19d56cf6e3e932475fc6a3dee35eec5a386e07917a1d1ba6bb0e35"
checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a"
dependencies = [
"cosmwasm-std",
"schemars",
@@ -1231,22 +1213,13 @@ dependencies = [
"byteorder",
]
[[package]]
name = "der"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4"
dependencies = [
"const-oid 0.6.2",
]
[[package]]
name = "der"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c"
dependencies = [
"const-oid 0.7.1",
"const-oid",
]
[[package]]
@@ -1382,26 +1355,14 @@ version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6907e25393cdcc1f4f3f513d9aac1e840eb1cc341a0fccb01171f7d14d10b946"
[[package]]
name = "ecdsa"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372"
dependencies = [
"der 0.4.5",
"elliptic-curve 0.10.6",
"hmac",
"signature",
]
[[package]]
name = "ecdsa"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9"
dependencies = [
"der 0.5.1",
"elliptic-curve 0.11.12",
"der",
"elliptic-curve",
"rfc6979",
"signature",
]
@@ -1448,22 +1409,6 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "elliptic-curve"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b"
dependencies = [
"crypto-bigint 0.2.11",
"ff 0.10.1",
"generic-array 0.14.5",
"group 0.10.0",
"pkcs8 0.7.6",
"rand_core 0.6.3",
"subtle",
"zeroize",
]
[[package]]
name = "elliptic-curve"
version = "0.11.12"
@@ -1471,8 +1416,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6"
dependencies = [
"base16ct",
"crypto-bigint 0.3.2",
"der 0.5.1",
"crypto-bigint",
"der",
"ff 0.11.0",
"generic-array 0.14.5",
"group 0.11.0",
@@ -2625,25 +2570,13 @@ dependencies = [
[[package]]
name = "k256"
version = "0.9.6"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea"
checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d"
dependencies = [
"cfg-if",
"ecdsa 0.12.4",
"elliptic-curve 0.10.6",
"sha2 0.9.9",
]
[[package]]
name = "k256"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cc5937366afd3b38071f400d1ce5bd8b1d40b5083cc14e6f8dbcc4032a7f5bb"
dependencies = [
"cfg-if",
"ecdsa 0.13.4",
"elliptic-curve 0.11.12",
"ecdsa",
"elliptic-curve",
"sec1",
"sha2 0.9.9",
"sha3",
@@ -2816,14 +2749,15 @@ dependencies = [
[[package]]
name = "mio"
version = "0.8.0"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2"
checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"wasi 0.11.0+wasi-snapshot-preview1",
"winapi",
]
@@ -3545,24 +3479,14 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkcs8"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447"
dependencies = [
"der 0.4.5",
"spki 0.4.1",
]
[[package]]
name = "pkcs8"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0"
dependencies = [
"der 0.5.1",
"spki 0.5.4",
"der",
"spki",
"zeroize",
]
@@ -4087,7 +4011,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525"
dependencies = [
"crypto-bigint 0.3.2",
"crypto-bigint",
"hmac",
"zeroize",
]
@@ -4271,9 +4195,9 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1"
dependencies = [
"der 0.5.1",
"der",
"generic-array 0.14.5",
"pkcs8 0.8.0",
"pkcs8",
"subtle",
"zeroize",
]
@@ -4356,9 +4280,9 @@ dependencies = [
[[package]]
name = "serde-json-wasm"
version = "0.3.2"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "042ac496d97e5885149d34139bad1d617192770d7eb8f1866da2317ff4501853"
checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5"
dependencies = [
"serde",
]
@@ -4633,15 +4557,6 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "spki"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32"
dependencies = [
"der 0.4.5",
]
[[package]]
name = "spki"
version = "0.5.4"
@@ -4649,7 +4564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27"
dependencies = [
"base64ct",
"der 0.5.1",
"der",
]
[[package]]
@@ -5081,7 +4996,7 @@ dependencies = [
"ed25519-dalek",
"flex-error",
"futures",
"k256 0.10.2",
"k256",
"num-traits",
"once_cell",
"prost",
@@ -5256,15 +5171,16 @@ checksum = "25eb0ca3468fc0acc11828786797f6ef9aa1555e4a211a60d64cc8e4d1be47d6"
[[package]]
name = "tokio"
version = "1.17.0"
version = "1.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee"
checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439"
dependencies = [
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
"once_cell",
"pin-project-lite",
"socket2",
"tokio-macros",
@@ -5681,6 +5597,12 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.79"
+1 -1
View File
@@ -47,7 +47,7 @@ argon2 = { version = "0.3.2", features = ["std"] }
base64 = "0.13"
zeroize = "1.4.3"
cosmwasm-std = "1.0.0-beta8"
cosmwasm-std = "1.0.0"
validator-client = { path = "../../common/client-libs/validator-client", features = [
"nymd-client",
@@ -679,8 +679,51 @@ mod tests {
);
}
// This decryptes a stored wallet file using the same procedure as when signing in. Most tests
// related to the encryped wallet storage is in `wallet_storage`.
#[test]
fn decrypt_stored_wallet_multiple_for_sign_in() {
// WIP(JON): same as above but with file containing multiple accounts
const SAVED_WALLET: &str = "src/wallet_storage/test-data/saved-wallet-1.0.5.json";
let wallet_file = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(SAVED_WALLET);
let login_id = wallet_storage::LoginId::new(DEFAULT_LOGIN_ID.to_string());
let account_id = wallet_storage::AccountId::new("default".to_string());
let password = wallet_storage::UserPassword::new("password11!".to_string());
let hd_path: DerivationPath = COSMOS_DERIVATION_PATH.parse().unwrap();
let stored_login =
wallet_storage::load_existing_login_at_file(&wallet_file, &login_id, &password)
.unwrap();
let mnemonic = extract_first_mnemonic(&stored_login).unwrap();
let expected_mnemonic = bip39::Mnemonic::from_str("arrow capable abstract industry elevator nominee december piece hotel feed lounge web faint sword veteran bundle hour page actual laptop horror gold test warrior").unwrap();
assert_eq!(mnemonic, expected_mnemonic);
let all_accounts: Vec<_> = stored_login
.unwrap_into_multiple_accounts(account_id.clone())
.into_accounts()
.collect();
let expected_mn2 = bip39::Mnemonic::from_str("border hurt skull lunar goddess second danger game dismiss exhaust oven thumb dog drama onion false orchard spice tent next predict invite cherry green").unwrap();
let expected_mn3 = bip39::Mnemonic::from_str("gentle crowd rule snap girl urge flat jump winner cluster night sand museum stock grunt quick tree acquire traffic major awake tag rack peasant").unwrap();
let expected_mn4 = bip39::Mnemonic::from_str("debris blue skin annual inhale text border rigid spatial lesson coconut yard horn crystal control survey version vote hawk neck frame arrive oblige width").unwrap();
assert_eq!(
all_accounts,
vec![
WalletAccount::new(
"default".into(),
MnemonicAccount::new(expected_mnemonic, hd_path.clone())
),
WalletAccount::new(
"account2".into(),
MnemonicAccount::new(expected_mn2, hd_path.clone()),
),
WalletAccount::new(
"foobar".into(),
MnemonicAccount::new(expected_mn3, hd_path.clone()),
),
WalletAccount::new("42".into(), MnemonicAccount::new(expected_mn4, hd_path)),
]
);
}
}
+1
View File
@@ -26,6 +26,7 @@ export const Bond = () => {
}
}, [status, checkOwnership]);
return (
<PageLayout>
<NymCard title="Bond" subheader="Bond a node or gateway" noPadding>
+27 -2
View File
@@ -1,4 +1,4 @@
import React, { useEffect, useContext } from 'react';
import React, { useEffect, useContext, useState } from 'react';
import { Box, Button, CircularProgress, FormControl, Grid, InputAdornment, TextField } from '@mui/material';
import { yupResolver } from '@hookform/resolvers/yup';
import { useForm } from 'react-hook-form';
@@ -8,6 +8,7 @@ import { AppContext } from '../../context/main';
import { delegate, majorToMinor, vestingDelegateToMixnode } from '../../requests';
import { Fee, TokenPoolSelector } from '../../components';
import { Console } from '../../utils/console';
import { getMixnodeStakeSaturation } from '../../requests';
type TDelegateForm = {
identity: string;
@@ -41,12 +42,24 @@ export const DelegateForm = ({
resolver: yupResolver(validationSchema),
});
const [saturation, setSaturation] = useState<number>(0);
const { userBalance, currency, clientDetails } = useContext(AppContext);
useEffect(() => {
reset();
}, [clientDetails]);
useEffect(() => {
console.log('saturation', saturation);
}, [saturation]);
const getStakeSaturation = async (mixnodeKey: string) => {
const newSaturation = await getMixnodeStakeSaturation(mixnodeKey);
if (newSaturation) {
setSaturation(Math.round(newSaturation.saturation * 100));
}
};
const onSubmit = async (data: TDelegateForm, cb: (data: TDelegateArgs) => Promise<DelegationResult>) => {
const amount = await majorToMinor(data.amount);
@@ -69,6 +82,15 @@ export const DelegateForm = ({
});
};
const checkNodeSaturation = (value: string) => {
console.log(value, value.length);
if (value.length === 44) {
getStakeSaturation(value);
} else {
setSaturation(0);
}
};
return (
<FormControl fullWidth>
<Box sx={{ p: 3 }}>
@@ -84,7 +106,10 @@ export const DelegateForm = ({
fullWidth
error={!!errors.identity}
helperText={errors?.identity?.message}
onBlur={(e) => checkNodeSaturation(e.target.value)}
onChange={(e) => setSaturation(0)}
/>
{saturation > 100 && <p>Please choose another node, the selected is oversaturated</p>}
</Grid>
{userBalance.originalVesting && (
@@ -127,7 +152,7 @@ export const DelegateForm = ({
onClick={handleSubmit((data) =>
onSubmit(data, data.tokenPool === 'balance' ? delegate : vestingDelegateToMixnode),
)}
disabled={isSubmitting}
disabled={isSubmitting || saturation > 100}
data-testid="delegate-button"
variant="contained"
color="primary"
+1 -1
View File
@@ -50,7 +50,7 @@ schemars = { version = "0.8", features = ["preserve_order"] }
## internal
coconut-bandwidth-contract-common = { path = "../common/cosmwasm-smart-contracts/coconut-bandwidth-contract" }
config = { path = "../common/config" }
cosmwasm-std = "1.0.0-beta8"
cosmwasm-std = "1.0.0"
crypto = { path="../common/crypto" }
gateway-client = { path="../common/client-libs/gateway-client" }
mixnet-contract-common = { path= "../common/cosmwasm-smart-contracts/mixnet-contract" }
+2 -2
View File
@@ -83,8 +83,8 @@ impl super::client::Client for DummyClient {
async fn execute_proposal(
&self,
proposal_id: u64,
fee: Option<Fee>,
_proposal_id: u64,
_fee: Option<Fee>,
) -> crate::coconut::error::Result<()> {
todo!()
}