Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7213bb54a | |||
| 005d074209 | |||
| be733fab5a | |||
| 1fc3c2b792 | |||
| f09b984b20 |
@@ -29,6 +29,7 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
||||
|
||||
- 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
|
||||
- mixnode: listen out for SIGTERM and SIGQUIT too, making it play nicely as a system service.
|
||||
- native & socks5 clients: fail early when clients try to re-init with a different gateway, which is not supported yet ([#1322])
|
||||
- native & socks5 clients: rerun init will now reuse previous gateway configuration instead of failing ([#1353])
|
||||
- native & socks5 clients: deduplicate big chunks of init logic
|
||||
|
||||
Generated
+2
-25
@@ -1343,9 +1343,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "3.0.2"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
@@ -3156,7 +3156,6 @@ dependencies = [
|
||||
"rand 0.7.3",
|
||||
"rocket",
|
||||
"serde",
|
||||
"serial_test",
|
||||
"sysinfo",
|
||||
"task",
|
||||
"tokio",
|
||||
@@ -5019,28 +5018,6 @@ dependencies = [
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"parking_lot 0.11.2",
|
||||
"serial_test_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test_derive"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.8.2"
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dirs = "3.0"
|
||||
dirs = "4.0"
|
||||
futures = "0.3"
|
||||
humantime-serde = "1.0"
|
||||
log = "0.4"
|
||||
|
||||
@@ -272,7 +272,7 @@ impl<T: NymConfig> Default for Config<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct GatewayEndpoint {
|
||||
/// gateway_id specifies ID of the gateway to which the client should send messages.
|
||||
/// If initially omitted, a random gateway will be chosen from the available topology.
|
||||
@@ -296,7 +296,7 @@ impl From<topology::gateway::Node> for GatewayEndpoint {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct Client<T> {
|
||||
/// Version of the client for which this configuration was created.
|
||||
#[serde(default = "missing_string_value")]
|
||||
@@ -419,7 +419,7 @@ impl<T: NymConfig> Client<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Logging {}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ futures = "0.3" # bunch of futures stuff, however, now that I think about it, it
|
||||
url = "2.2"
|
||||
|
||||
clap = "2.33.0" # for the command line arguments
|
||||
dirs = "3.0" # for determining default store directories in config
|
||||
dirs = "4.0"
|
||||
dotenv = "0.15.0" # for obtaining environmental variables (only used for RUST_LOG for time being)
|
||||
log = "0.4" # self explanatory
|
||||
pretty_env_logger = "0.4" # for formatting log messages
|
||||
|
||||
@@ -11,7 +11,7 @@ use std::path::PathBuf;
|
||||
|
||||
mod template;
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize, Clone, Copy)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Clone, Copy)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub enum SocketType {
|
||||
WebSocket,
|
||||
@@ -105,7 +105,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Socket {
|
||||
socket_type: SocketType,
|
||||
|
||||
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
// no need to go fancy here like we've done in other places.
|
||||
#[derive(PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
pub struct Error {
|
||||
pub kind: ErrorKind,
|
||||
pub message: String,
|
||||
@@ -30,7 +30,7 @@ impl Error {
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
pub enum ErrorKind {
|
||||
/// The received request contained no data.
|
||||
EmptyRequest = 0x01,
|
||||
|
||||
@@ -11,7 +11,7 @@ path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = "2.33.0"
|
||||
dirs = "3.0" # for determining default store directories in config
|
||||
dirs = "4.0"
|
||||
dotenv = "0.15.0"
|
||||
futures = "0.3"
|
||||
log = "0.4"
|
||||
|
||||
@@ -89,7 +89,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Socks5 {
|
||||
/// The port on which the client will be listening for incoming requests
|
||||
|
||||
@@ -9,7 +9,7 @@ pub(crate) enum AuthenticationMethods {
|
||||
NoMethods = 0xFF,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
/// A socks5 user with a matching password.
|
||||
pub struct User {
|
||||
pub username: String,
|
||||
|
||||
@@ -5,7 +5,7 @@ use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// Serializable structures for what we find in common/crypto
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct PublicKey([u8; 32]);
|
||||
|
||||
impl PublicKey {
|
||||
@@ -24,7 +24,7 @@ impl AsRef<[u8]> for PublicKey {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct Signature([u8; 32], [u8; 32]);
|
||||
|
||||
impl Signature {
|
||||
|
||||
@@ -7,16 +7,16 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::keys::PublicKey;
|
||||
use crate::payment::LinkPaymentData;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct InstantiateMsg {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ExecuteMsg {
|
||||
LinkPayment { data: LinkPaymentData },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum QueryMsg {
|
||||
GetPayments {
|
||||
@@ -25,6 +25,6 @@ pub enum QueryMsg {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MigrateMsg {}
|
||||
|
||||
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::keys::{PublicKey, Signature};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct Payment {
|
||||
verification_key: PublicKey,
|
||||
gateway_identity: PublicKey,
|
||||
@@ -27,7 +27,7 @@ impl Payment {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct LinkPaymentData {
|
||||
pub verification_key: PublicKey,
|
||||
pub gateway_identity: PublicKey,
|
||||
@@ -51,7 +51,7 @@ impl LinkPaymentData {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct PagedPaymentResponse {
|
||||
pub payments: Vec<Payment>,
|
||||
pub per_page: usize,
|
||||
|
||||
@@ -6,14 +6,14 @@ use std::fmt;
|
||||
pub use cosmrs::Coin as CosmosCoin;
|
||||
pub use cosmwasm_std::Coin as CosmWasmCoin;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Default, Debug, PartialEq)]
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Default, Debug, PartialEq, Eq)]
|
||||
pub struct MismatchedDenoms;
|
||||
|
||||
// the reason the coin is created here as opposed to different place in the codebase is that
|
||||
// eventually we want to either publish the cosmwasm client separately or commit it to
|
||||
// some other project, like cosmrs. Either way, in that case we can't really have
|
||||
// a dependency on an internal type
|
||||
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq)]
|
||||
pub struct Coin {
|
||||
pub amount: u128,
|
||||
pub denom: String,
|
||||
|
||||
@@ -10,7 +10,7 @@ use error::CoconutInterfaceError;
|
||||
|
||||
pub use nymcoconut::*;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Getters, CopyGetters, Clone, PartialEq)]
|
||||
#[derive(Debug, Serialize, Deserialize, Getters, CopyGetters, Clone, PartialEq, Eq)]
|
||||
pub struct Credential {
|
||||
#[getset(get = "pub")]
|
||||
n_params: u32,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct DepositData {
|
||||
deposit_info: String,
|
||||
identity_key: String,
|
||||
|
||||
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::deposit::DepositData;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct InstantiateMsg {
|
||||
pub multisig_addr: String,
|
||||
pub pool_addr: String,
|
||||
@@ -20,10 +20,10 @@ pub enum ExecuteMsg {
|
||||
ReleaseFunds { funds: Coin },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum QueryMsg {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MigrateMsg {}
|
||||
|
||||
@@ -123,7 +123,7 @@ impl Display for Delegation {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct PagedMixDelegationsResponse {
|
||||
pub delegations: Vec<Delegation>,
|
||||
pub start_next_after: Option<(String, u64)>,
|
||||
@@ -138,7 +138,7 @@ impl PagedMixDelegationsResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct PagedDelegatorDelegationsResponse {
|
||||
pub delegations: Vec<Delegation>,
|
||||
pub start_next_after: Option<IdentityKey>,
|
||||
@@ -153,7 +153,7 @@ impl PagedDelegatorDelegationsResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct PagedAllDelegationsResponse {
|
||||
pub delegations: Vec<Delegation>,
|
||||
pub start_next_after: Option<(IdentityKey, Vec<u8>, u64)>,
|
||||
|
||||
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize, JsonSchema)]
|
||||
pub struct Gateway {
|
||||
pub host: String,
|
||||
pub mix_port: u16,
|
||||
|
||||
@@ -59,7 +59,7 @@ pub(crate) mod string_rfc3339_offset_date_time {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize)]
|
||||
pub struct Interval {
|
||||
id: u32,
|
||||
#[serde(with = "string_rfc3339_offset_date_time")]
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::fmt::Display;
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/RewardedSetNodeStatus.ts")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq)]
|
||||
pub enum RewardedSetNodeStatus {
|
||||
Active,
|
||||
Standby,
|
||||
@@ -106,7 +106,7 @@ impl PendingUndelegate {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize, JsonSchema)]
|
||||
pub struct MixNode {
|
||||
pub host: String,
|
||||
pub mix_port: u16,
|
||||
@@ -245,7 +245,7 @@ impl DelegatorRewardParams {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||
pub struct StoredNodeRewardResult {
|
||||
reward: Uint128,
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ use crate::{Gateway, IdentityKey, MixNode};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct InstantiateMsg {
|
||||
pub rewarding_validator_address: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ExecuteMsg {
|
||||
UpdateRewardingValidatorAddress {
|
||||
@@ -112,7 +112,7 @@ pub enum ExecuteMsg {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum QueryMsg {
|
||||
GetCurrentOperatorCost {},
|
||||
@@ -205,6 +205,6 @@ pub enum QueryMsg {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MigrateMsg {}
|
||||
|
||||
@@ -4,7 +4,7 @@ use cosmwasm_std::Uint128;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||
pub struct NodeEpochRewards {
|
||||
params: NodeRewardParams,
|
||||
result: StoredNodeRewardResult,
|
||||
@@ -105,7 +105,7 @@ impl NodeEpochRewards {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||
pub struct EpochRewardParams {
|
||||
epoch_reward_pool: Uint128,
|
||||
rewarded_set_size: Uint128,
|
||||
@@ -175,7 +175,7 @@ impl EpochRewardParams {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||
pub struct NodeRewardParams {
|
||||
reward_blockstamp: u64,
|
||||
uptime: Uint128,
|
||||
@@ -208,7 +208,7 @@ impl NodeRewardParams {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||
pub struct RewardParams {
|
||||
pub epoch: EpochRewardParams,
|
||||
pub node: NodeRewardParams,
|
||||
|
||||
@@ -27,7 +27,7 @@ impl LayerDistribution {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct ContractStateParams {
|
||||
// so currently interval_length is being unused and validator API performs rewarding
|
||||
// based on its own interval length config value. I guess that's fine for time being
|
||||
@@ -72,7 +72,7 @@ impl Display for ContractStateParams {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct RewardingResult {
|
||||
pub node_reward: Uint128,
|
||||
}
|
||||
@@ -124,21 +124,21 @@ pub type IdentityKey = String;
|
||||
pub type IdentityKeyRef<'a> = &'a str;
|
||||
pub type SphinxKey = String;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
pub struct PagedRewardedSetResponse {
|
||||
pub identities: Vec<(IdentityKey, RewardedSetNodeStatus)>,
|
||||
pub start_next_after: Option<IdentityKey>,
|
||||
pub at_height: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct RewardedSetUpdateDetails {
|
||||
pub refresh_rate_blocks: u64,
|
||||
pub last_refreshed_block: u64,
|
||||
pub current_height: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct IntervalRewardedSetHeightsResponse {
|
||||
pub interval_id: u32,
|
||||
pub heights: Vec<u64>,
|
||||
|
||||
@@ -44,7 +44,7 @@ pub enum ExecuteMsg {
|
||||
}
|
||||
|
||||
// We can also add this as a cw3 extension
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum QueryMsg {
|
||||
/// Return ThresholdResponse
|
||||
|
||||
@@ -19,7 +19,7 @@ pub fn one_ucoin() -> Coin {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Period.ts")
|
||||
)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||
pub enum Period {
|
||||
Before,
|
||||
In(usize),
|
||||
|
||||
@@ -3,17 +3,17 @@ use mixnet_contract_common::{Gateway, IdentityKey, MixNode};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct InitMsg {
|
||||
pub mixnet_contract_address: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MigrateMsg {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, Default)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
|
||||
pub struct VestingSpecification {
|
||||
start_time: Option<u64>,
|
||||
period_seconds: Option<u64>,
|
||||
@@ -118,7 +118,7 @@ pub enum ExecuteMsg {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum QueryMsg {
|
||||
LockedCoins {
|
||||
|
||||
@@ -335,7 +335,7 @@ pub fn keygen(params: &Params, mut rng: impl RngCore) -> (DecryptionKey, PublicK
|
||||
(dk, key_with_proof)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct PublicKey(pub(crate) G1Projective);
|
||||
|
||||
impl PublicKey {
|
||||
|
||||
@@ -243,7 +243,7 @@ impl Zeroize for Tau {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd)]
|
||||
pub struct Epoch(EpochStore);
|
||||
|
||||
impl Epoch {
|
||||
|
||||
@@ -10,7 +10,7 @@ use rand_core::RngCore;
|
||||
use std::ops::{Add, Index, IndexMut};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct PublicCoefficients {
|
||||
pub(crate) coefficients: Vec<G2Projective>,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use config::defaults::DEFAULT_NETWORK;
|
||||
use subtle_encoding::bech32;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Bech32Error {
|
||||
DecodeFailed(String),
|
||||
WrongPrefix(String),
|
||||
|
||||
@@ -5,6 +5,7 @@ fn main() {
|
||||
match option_env!("NETWORK") {
|
||||
None | Some("mainnet") => println!("cargo:rustc-cfg=network=\"mainnet\"",),
|
||||
Some("sandbox") => println!("cargo:rustc-cfg=network=\"sandbox\"",),
|
||||
Some("sandbox2") => println!("cargo:rustc-cfg=network=\"sandbox2\"",),
|
||||
Some("qa") => println!("cargo:rustc-cfg=network=\"qa\""),
|
||||
_ => panic!("No such network"),
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::{
|
||||
DefaultNetworkDetails, DenomDetailsOwned, NymNetworkDetails, ValidatorDetails,
|
||||
MAINNET_DEFAULTS, QA_DEFAULTS, SANDBOX_DEFAULTS,
|
||||
MAINNET_DEFAULTS, QA_DEFAULTS, SANDBOX_DEFAULTS, SANDBOX2_DEFAULTS
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, fmt, str::FromStr};
|
||||
@@ -21,6 +21,7 @@ pub enum NetworkDefaultsError {
|
||||
pub enum Network {
|
||||
QA,
|
||||
SANDBOX,
|
||||
SANDBOX2,
|
||||
MAINNET,
|
||||
CUSTOM { details: NymNetworkDetails },
|
||||
}
|
||||
@@ -34,6 +35,7 @@ impl Network {
|
||||
match self {
|
||||
Self::QA => (&*QA_DEFAULTS).into(),
|
||||
Self::SANDBOX => (&*SANDBOX_DEFAULTS).into(),
|
||||
Self::SANDBOX2 => (&*SANDBOX2_DEFAULTS).into(),
|
||||
Self::MAINNET => (&*MAINNET_DEFAULTS).into(),
|
||||
// I dislike the clone here, but for compatibility reasons we cannot define other networks with `NymNetworkDetails` directly yet
|
||||
Self::CUSTOM { details } => details.clone(),
|
||||
@@ -89,6 +91,7 @@ impl Network {
|
||||
match self {
|
||||
Network::QA => crate::qa::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::SANDBOX => crate::sandbox::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::SANDBOX2 => crate::sandbox2::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::MAINNET => crate::mainnet::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::CUSTOM { .. } => {
|
||||
panic!("rewarding validator address is unavailable for a custom network")
|
||||
@@ -114,6 +117,7 @@ impl FromStr for Network {
|
||||
match s.to_lowercase().as_str() {
|
||||
"qa" => Ok(Network::QA),
|
||||
"sandbox" => Ok(Network::SANDBOX),
|
||||
"sandbox2" => Ok(Network::SANDBOX2),
|
||||
"mainnet" => Ok(Network::MAINNET),
|
||||
_ => Err(NetworkDefaultsError::MalformedNetworkProvided(
|
||||
s.to_string(),
|
||||
@@ -127,6 +131,7 @@ impl fmt::Display for Network {
|
||||
match *self {
|
||||
Network::QA => f.write_str("QA"),
|
||||
Network::SANDBOX => f.write_str("Sandbox"),
|
||||
Network::SANDBOX2 => f.write_str("Sandbox2"),
|
||||
Network::MAINNET => f.write_str("Mainnet"),
|
||||
Network::CUSTOM { .. } => f.write_str("Custom"),
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ pub mod eth_contract;
|
||||
pub mod mainnet;
|
||||
pub mod qa;
|
||||
pub mod sandbox;
|
||||
pub mod sandbox2;
|
||||
|
||||
// The set of defaults that are decided at compile time. Ideally we want to reduce these to a
|
||||
// minimum.
|
||||
@@ -38,6 +39,13 @@ cfg_if::cfg_if! {
|
||||
|
||||
pub const ETH_CONTRACT_ADDRESS: [u8; 20] = sandbox::_ETH_CONTRACT_ADDRESS;
|
||||
pub const ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] = sandbox::_ETH_ERC20_CONTRACT_ADDRESS;
|
||||
} else if #[cfg(network = "sandbox2")] {
|
||||
pub const DEFAULT_NETWORK: all::Network = all::Network::SANDBOX2;
|
||||
pub const MIX_DENOM: DenomDetails = sandbox2::MIX_DENOM;
|
||||
pub const STAKE_DENOM: DenomDetails = sandbox2::STAKE_DENOM;
|
||||
|
||||
pub const ETH_CONTRACT_ADDRESS: [u8; 20] = sandbox2::_ETH_CONTRACT_ADDRESS;
|
||||
pub const ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] = sandbox2::_ETH_ERC20_CONTRACT_ADDRESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +243,20 @@ static SANDBOX_DEFAULTS: Lazy<DefaultNetworkDetails> = Lazy::new(|| DefaultNetwo
|
||||
validators: sandbox::validators(),
|
||||
});
|
||||
|
||||
static SANDBOX2_DEFAULTS: Lazy<DefaultNetworkDetails> = Lazy::new(|| DefaultNetworkDetails {
|
||||
bech32_prefix: sandbox2::BECH32_PREFIX,
|
||||
mix_denom: sandbox2::MIX_DENOM,
|
||||
stake_denom: sandbox2::STAKE_DENOM,
|
||||
mixnet_contract_address: sandbox2::MIXNET_CONTRACT_ADDRESS,
|
||||
vesting_contract_address: sandbox2::VESTING_CONTRACT_ADDRESS,
|
||||
bandwidth_claim_contract_address: sandbox2::BANDWIDTH_CLAIM_CONTRACT_ADDRESS,
|
||||
coconut_bandwidth_contract_address: sandbox2::COCONUT_BANDWIDTH_CONTRACT_ADDRESS,
|
||||
multisig_contract_address: sandbox2::MULTISIG_CONTRACT_ADDRESS,
|
||||
rewarding_validator_address: sandbox2::REWARDING_VALIDATOR_ADDRESS,
|
||||
statistics_service_url: sandbox2::STATISTICS_SERVICE_DOMAIN_ADDRESS,
|
||||
validators: sandbox2::validators(),
|
||||
});
|
||||
|
||||
static QA_DEFAULTS: Lazy<DefaultNetworkDetails> = Lazy::new(|| DefaultNetworkDetails {
|
||||
bech32_prefix: qa::BECH32_PREFIX,
|
||||
mix_denom: qa::MIX_DENOM,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::{DenomDetails, ValidatorDetails};
|
||||
|
||||
pub(crate) const BECH32_PREFIX: &str = "ns";
|
||||
|
||||
pub const MIX_DENOM: DenomDetails = DenomDetails::new("unymt", "nymt", 6);
|
||||
pub const STAKE_DENOM: DenomDetails = DenomDetails::new("unyxt", "nyxt", 6);
|
||||
|
||||
pub(crate) const MIXNET_CONTRACT_ADDRESS: &str = "ns17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgsrtzqqx";
|
||||
pub(crate) const VESTING_CONTRACT_ADDRESS: &str = "ns1aakfpghcanxtc45gpqlx8j3rq0zcpyf49qmhm9mdjrfx036h4z5sptexdf";
|
||||
pub(crate) const BANDWIDTH_CLAIM_CONTRACT_ADDRESS: &str =
|
||||
"";
|
||||
pub(crate) const COCONUT_BANDWIDTH_CONTRACT_ADDRESS: &str =
|
||||
"";
|
||||
pub(crate) const MULTISIG_CONTRACT_ADDRESS: &str = "";
|
||||
pub(crate) const _ETH_CONTRACT_ADDRESS: [u8; 20] =
|
||||
hex_literal::hex!("8e0DcFF7F3085235C32E845f3667aEB3f1e83133");
|
||||
pub(crate) const _ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] =
|
||||
hex_literal::hex!("E8883BAeF3869e14E4823F46662e81D4F7d2A81F");
|
||||
pub(crate) const REWARDING_VALIDATOR_ADDRESS: &str = "ns1a4542dv9tvsa95zyztqsev6erjd2l3ywxhxnpg";
|
||||
|
||||
pub(crate) const STATISTICS_SERVICE_DOMAIN_ADDRESS: &str = "";
|
||||
pub(crate) fn validators() -> Vec<ValidatorDetails> {
|
||||
vec![ValidatorDetails::new(
|
||||
"https://sandbox2-validator1.nymtech.net",
|
||||
Some("https://sandbox2-validator-api1.nymte.ch/api"),
|
||||
)]
|
||||
}
|
||||
@@ -327,7 +327,7 @@ impl ProofCmCs {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ProofKappaZeta {
|
||||
// c
|
||||
challenge: Scalar,
|
||||
|
||||
@@ -114,7 +114,7 @@ impl Base58 for SecretKey {}
|
||||
|
||||
// TODO: perhaps change points to affine representation
|
||||
// to make verification slightly more efficient?
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct VerificationKey {
|
||||
// TODO add gen2 as per the paper or imply it from the fact library is using bls381?
|
||||
pub(crate) alpha: G2Projective,
|
||||
|
||||
@@ -28,7 +28,7 @@ pub mod verification;
|
||||
pub type SignerIndex = u64;
|
||||
|
||||
// (h, s)
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Signature(pub(crate) G1Projective, pub(crate) G1Projective);
|
||||
|
||||
pub type PartialSignature = Signature;
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::Attribute;
|
||||
|
||||
// TODO NAMING: this whole thing
|
||||
// Theta
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Theta {
|
||||
// blinded_message (kappa)
|
||||
pub blinded_message: G2Projective,
|
||||
|
||||
@@ -45,7 +45,7 @@ pub mod set;
|
||||
/// Both of those concepts as well as their structures, i.e. `Set` and `Fragment`
|
||||
/// are further explained in the respective files.
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum ChunkingError {
|
||||
InvalidPayloadLengthError,
|
||||
TooBigMessageToSplit,
|
||||
|
||||
@@ -46,7 +46,7 @@ impl FramedSphinxPacket {
|
||||
// Contains any metadata that might be useful for sending between mix nodes.
|
||||
// TODO: in theory all those data could be put in a single `u8` by setting appropriate bits,
|
||||
// but would that really be worth it?
|
||||
#[derive(Debug, Default, PartialEq, Copy, Clone)]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
|
||||
pub struct Header {
|
||||
/// Represents type and consequently size of the included SphinxPacket.
|
||||
pub(crate) packet_size: PacketSize,
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::convert::TryFrom;
|
||||
pub struct InvalidPacketMode;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum PacketMode {
|
||||
/// Represents 'normal' packet sent through the network that should be delayed by an appropriate
|
||||
/// value at each hop.
|
||||
|
||||
@@ -21,7 +21,7 @@ const EXTENDED_PACKET_SIZE: usize = HEADER_SIZE + PAYLOAD_OVERHEAD_SIZE + 32 * 1
|
||||
pub struct InvalidPacketSize;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum PacketSize {
|
||||
// for example instant messaging use case
|
||||
RegularPacket = 1,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::cmp::Ordering;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum MessageError {
|
||||
NoData,
|
||||
IndexTooShort,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::ConnectionId;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ResponseError {
|
||||
ConnectionIdTooShort,
|
||||
NoData,
|
||||
|
||||
@@ -18,4 +18,4 @@ sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "chrono"]}
|
||||
thiserror = "1"
|
||||
tokio = { version = "1.19.1", features = [ "time" ] }
|
||||
|
||||
network-defaults = { path = "../network-defaults" }
|
||||
network-defaults = { path = "../network-defaults" }
|
||||
|
||||
@@ -26,6 +26,7 @@ use validator_client::nymd::{Coin, CosmosCoin};
|
||||
EnumString,
|
||||
EnumVariantNames,
|
||||
PartialEq,
|
||||
Eq,
|
||||
JsonSchema,
|
||||
)]
|
||||
#[serde(rename_all = "UPPERCASE")]
|
||||
@@ -59,7 +60,7 @@ impl TryFrom<CosmosDenom> for CurrencyDenom {
|
||||
type Error = TypesError;
|
||||
|
||||
fn try_from(value: CosmosDenom) -> Result<Self, Self::Error> {
|
||||
CurrencyDenom::parse(&value.to_string())
|
||||
CurrencyDenom::parse(value.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ impl TryFrom<CosmosDenom> for CurrencyDenom {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/CurrencyStringMajorAmount.ts")
|
||||
)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct MajorAmountString(String); // see https://github.com/Aleph-Alpha/ts-rs/issues/51 for exporting type aliases
|
||||
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
@@ -77,7 +78,7 @@ pub struct MajorAmountString(String); // see https://github.com/Aleph-Alpha/ts-r
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Currency.ts")
|
||||
)]
|
||||
// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct MajorCurrencyAmount {
|
||||
// temporarly going back to original impl to speed up merge
|
||||
pub amount: MajorAmountString,
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::error::TypesError;
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Delegation.ts")
|
||||
)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
pub struct Delegation {
|
||||
pub owner: String,
|
||||
pub node_identity: String,
|
||||
@@ -52,7 +52,7 @@ impl TryFrom<MixnetContractDelegation> for Delegation {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DelegationRecord.ts")
|
||||
)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
pub struct DelegationRecord {
|
||||
pub amount: MajorCurrencyAmount,
|
||||
pub block_height: u64,
|
||||
@@ -88,7 +88,7 @@ pub struct DelegationWithEverything {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DelegationResult.ts")
|
||||
)]
|
||||
#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug)]
|
||||
#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct DelegationResult {
|
||||
source_address: String,
|
||||
target_address: String,
|
||||
@@ -127,7 +127,7 @@ impl TryFrom<MixnetContractDelegation> for DelegationResult {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DelegationEventKind.ts")
|
||||
)]
|
||||
#[derive(Clone, Deserialize, Serialize, PartialEq, JsonSchema, Debug)]
|
||||
#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, Debug)]
|
||||
pub enum DelegationEventKind {
|
||||
Delegate,
|
||||
Undelegate,
|
||||
@@ -138,7 +138,7 @@ pub enum DelegationEventKind {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DelegationEvent.ts")
|
||||
)]
|
||||
#[derive(Clone, Deserialize, Serialize, PartialEq, JsonSchema, Debug)]
|
||||
#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, Debug)]
|
||||
pub struct DelegationEvent {
|
||||
pub kind: DelegationEventKind,
|
||||
pub node_identity: String,
|
||||
@@ -181,7 +181,7 @@ impl TryFrom<ContractDelegationEvent> for DelegationEvent {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/PendingUndelegate.ts")
|
||||
)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, JsonSchema, Clone, Debug)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Eq, JsonSchema, Clone, Debug)]
|
||||
pub struct PendingUndelegate {
|
||||
mix_identity: String,
|
||||
delegate: String,
|
||||
|
||||
@@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Gateway.ts")
|
||||
)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize, JsonSchema)]
|
||||
pub struct Gateway {
|
||||
pub host: String,
|
||||
pub mix_port: u16,
|
||||
@@ -52,7 +52,7 @@ impl From<MixnetContractGateway> for Gateway {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/GatewayBond.ts")
|
||||
)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct GatewayBond {
|
||||
pub pledge_amount: MajorCurrencyAmount,
|
||||
pub owner: String,
|
||||
|
||||
@@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Mixnode.ts")
|
||||
)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize, JsonSchema)]
|
||||
pub struct MixNode {
|
||||
pub host: String,
|
||||
pub mix_port: u16,
|
||||
@@ -56,7 +56,7 @@ impl From<MixnetContractMixNode> for MixNode {
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/MixNodeBond.ts")
|
||||
)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct MixNodeBond {
|
||||
pub pledge_amount: MajorCurrencyAmount,
|
||||
pub total_delegation: MajorCurrencyAmount,
|
||||
|
||||
@@ -12,7 +12,7 @@ use bandwidth_claim_contract::payment::Payment;
|
||||
const PREFIX_PAYMENTS: &[u8] = b"payments";
|
||||
const PREFIX_STATUS: &[u8] = b"status";
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub enum Status {
|
||||
Unchecked,
|
||||
Checked,
|
||||
|
||||
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const ADMIN: Admin = Admin::new("admin");
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
|
||||
pub struct Config {
|
||||
pub multisig_addr: Addr,
|
||||
pub pool_addr: Addr,
|
||||
|
||||
@@ -1076,168 +1076,168 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
// TODO: Probably delete due to reconciliation logic
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn fails_if_delegation_never_existed() {
|
||||
let mut deps = test_helpers::init_contract();
|
||||
let env = mock_env();
|
||||
let mixnode_owner = "bob";
|
||||
let identity = test_helpers::add_mixnode(
|
||||
mixnode_owner,
|
||||
tests::fixtures::good_mixnode_pledge(),
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
assert_eq!(
|
||||
Err(ContractError::NoMixnodeDelegationFound {
|
||||
identity: identity.clone(),
|
||||
address: delegation_owner.to_string(),
|
||||
}),
|
||||
try_remove_delegation_from_mixnode(
|
||||
deps.as_mut(),
|
||||
env,
|
||||
mock_info(delegation_owner.as_str(), &[]),
|
||||
identity,
|
||||
)
|
||||
);
|
||||
}
|
||||
//#[ignore]
|
||||
//#[test]
|
||||
//fn fails_if_delegation_never_existed() {
|
||||
// let mut deps = test_helpers::init_contract();
|
||||
// let env = mock_env();
|
||||
// let mixnode_owner = "bob";
|
||||
// let identity = test_helpers::add_mixnode(
|
||||
// mixnode_owner,
|
||||
// tests::fixtures::good_mixnode_pledge(),
|
||||
// deps.as_mut(),
|
||||
// );
|
||||
// let delegation_owner = Addr::unchecked("sender");
|
||||
// assert_eq!(
|
||||
// Err(ContractError::NoMixnodeDelegationFound {
|
||||
// identity: identity.clone(),
|
||||
// address: delegation_owner.to_string(),
|
||||
// }),
|
||||
// try_remove_delegation_from_mixnode(
|
||||
// deps.as_mut(),
|
||||
// env,
|
||||
// mock_info(delegation_owner.as_str(), &[]),
|
||||
// identity,
|
||||
// )
|
||||
// );
|
||||
//}
|
||||
|
||||
// TODO: Update to work with reconciliation
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn succeeds_if_delegation_existed() {
|
||||
let mut deps = test_helpers::init_contract();
|
||||
let mixnode_owner = "bob";
|
||||
let env = mock_env();
|
||||
let identity = test_helpers::add_mixnode(
|
||||
mixnode_owner,
|
||||
tests::fixtures::good_mixnode_pledge(),
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, MIX_DENOM.base)),
|
||||
identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
//#[ignore]
|
||||
//#[test]
|
||||
//fn succeeds_if_delegation_existed() {
|
||||
// let mut deps = test_helpers::init_contract();
|
||||
// let mixnode_owner = "bob";
|
||||
// let env = mock_env();
|
||||
// let identity = test_helpers::add_mixnode(
|
||||
// mixnode_owner,
|
||||
// tests::fixtures::good_mixnode_pledge(),
|
||||
// deps.as_mut(),
|
||||
// );
|
||||
// let delegation_owner = Addr::unchecked("sender");
|
||||
// try_delegate_to_mixnode(
|
||||
// deps.as_mut(),
|
||||
// mock_env(),
|
||||
// mock_info(delegation_owner.as_str(), &coins(100, MIX_DENOM.base)),
|
||||
// identity.clone(),
|
||||
// )
|
||||
// .unwrap();
|
||||
|
||||
_try_reconcile_all_delegation_events(&mut deps.storage, &deps.api).unwrap();
|
||||
// _try_reconcile_all_delegation_events(&mut deps.storage, &deps.api).unwrap();
|
||||
|
||||
let _delegation = query_mixnode_delegation(
|
||||
&deps.storage,
|
||||
&deps.api,
|
||||
identity.clone(),
|
||||
delegation_owner.clone().into_string(),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
// let _delegation = query_mixnode_delegation(
|
||||
// &deps.storage,
|
||||
// &deps.api,
|
||||
// identity.clone(),
|
||||
// delegation_owner.clone().into_string(),
|
||||
// None,
|
||||
// )
|
||||
// .unwrap();
|
||||
|
||||
let expected_response = Response::new()
|
||||
.add_message(BankMsg::Send {
|
||||
to_address: delegation_owner.clone().into(),
|
||||
amount: coins(100, MIX_DENOM.base),
|
||||
})
|
||||
.add_event(new_undelegation_event(
|
||||
&delegation_owner,
|
||||
&None,
|
||||
&identity,
|
||||
Uint128::new(100),
|
||||
));
|
||||
// let expected_response = Response::new()
|
||||
// .add_message(BankMsg::Send {
|
||||
// to_address: delegation_owner.clone().into(),
|
||||
// amount: coins(100, MIX_DENOM.base),
|
||||
// })
|
||||
// .add_event(new_undelegation_event(
|
||||
// &delegation_owner,
|
||||
// &None,
|
||||
// &identity,
|
||||
// Uint128::new(100),
|
||||
// ));
|
||||
|
||||
assert_eq!(
|
||||
Ok(expected_response),
|
||||
try_remove_delegation_from_mixnode(
|
||||
deps.as_mut(),
|
||||
env,
|
||||
mock_info(delegation_owner.as_str(), &[]),
|
||||
identity.clone(),
|
||||
)
|
||||
);
|
||||
assert!(storage::delegations()
|
||||
.may_load(
|
||||
&deps.storage,
|
||||
(identity.clone(), delegation_owner.as_bytes().to_vec(), 0),
|
||||
)
|
||||
.unwrap()
|
||||
.is_none());
|
||||
// assert_eq!(
|
||||
// Ok(expected_response),
|
||||
// try_remove_delegation_from_mixnode(
|
||||
// deps.as_mut(),
|
||||
// env,
|
||||
// mock_info(delegation_owner.as_str(), &[]),
|
||||
// identity.clone(),
|
||||
// )
|
||||
// );
|
||||
// assert!(storage::delegations()
|
||||
// .may_load(
|
||||
// &deps.storage,
|
||||
// (identity.clone(), delegation_owner.as_bytes().to_vec(), 0),
|
||||
// )
|
||||
// .unwrap()
|
||||
// .is_none());
|
||||
|
||||
// and total delegation is cleared
|
||||
assert_eq!(
|
||||
Uint128::zero(),
|
||||
mixnodes_storage::TOTAL_DELEGATION
|
||||
.load(&deps.storage, &identity)
|
||||
.unwrap()
|
||||
)
|
||||
}
|
||||
// // and total delegation is cleared
|
||||
// assert_eq!(
|
||||
// Uint128::zero(),
|
||||
// mixnodes_storage::TOTAL_DELEGATION
|
||||
// .load(&deps.storage, &identity)
|
||||
// .unwrap()
|
||||
// )
|
||||
//}
|
||||
|
||||
// TODO: Update to work with reconciliation
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn succeeds_if_delegation_existed_even_if_node_unbonded() {
|
||||
let mut deps = test_helpers::init_contract();
|
||||
let mixnode_owner = "bob";
|
||||
let env = mock_env();
|
||||
let identity = test_helpers::add_mixnode(
|
||||
mixnode_owner,
|
||||
tests::fixtures::good_mixnode_pledge(),
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, MIX_DENOM.base)),
|
||||
identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
//#[ignore]
|
||||
//#[test]
|
||||
//fn succeeds_if_delegation_existed_even_if_node_unbonded() {
|
||||
// let mut deps = test_helpers::init_contract();
|
||||
// let mixnode_owner = "bob";
|
||||
// let env = mock_env();
|
||||
// let identity = test_helpers::add_mixnode(
|
||||
// mixnode_owner,
|
||||
// tests::fixtures::good_mixnode_pledge(),
|
||||
// deps.as_mut(),
|
||||
// );
|
||||
// let delegation_owner = Addr::unchecked("sender");
|
||||
// try_delegate_to_mixnode(
|
||||
// deps.as_mut(),
|
||||
// mock_env(),
|
||||
// mock_info(delegation_owner.as_str(), &coins(100, MIX_DENOM.base)),
|
||||
// identity.clone(),
|
||||
// )
|
||||
// .unwrap();
|
||||
|
||||
_try_reconcile_all_delegation_events(&mut deps.storage, &deps.api).unwrap();
|
||||
// _try_reconcile_all_delegation_events(&mut deps.storage, &deps.api).unwrap();
|
||||
|
||||
let delegation = query_mixnode_delegation(
|
||||
&deps.storage,
|
||||
&deps.api,
|
||||
identity.clone(),
|
||||
delegation_owner.clone().into_string(),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
// let delegation = query_mixnode_delegation(
|
||||
// &deps.storage,
|
||||
// &deps.api,
|
||||
// identity.clone(),
|
||||
// delegation_owner.clone().into_string(),
|
||||
// None,
|
||||
// )
|
||||
// .unwrap();
|
||||
|
||||
let expected_response = Response::new()
|
||||
.add_message(BankMsg::Send {
|
||||
to_address: delegation_owner.clone().into(),
|
||||
amount: coins(100, MIX_DENOM.base),
|
||||
})
|
||||
.add_event(new_undelegation_event(
|
||||
&delegation_owner,
|
||||
&None,
|
||||
&identity,
|
||||
Uint128::new(100),
|
||||
));
|
||||
// let expected_response = Response::new()
|
||||
// .add_message(BankMsg::Send {
|
||||
// to_address: delegation_owner.clone().into(),
|
||||
// amount: coins(100, MIX_DENOM.base),
|
||||
// })
|
||||
// .add_event(new_undelegation_event(
|
||||
// &delegation_owner,
|
||||
// &None,
|
||||
// &identity,
|
||||
// Uint128::new(100),
|
||||
// ));
|
||||
|
||||
try_remove_mixnode(mock_env(), deps.as_mut(), mock_info(mixnode_owner, &[])).unwrap();
|
||||
// try_remove_mixnode(mock_env(), deps.as_mut(), mock_info(mixnode_owner, &[])).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
Ok(expected_response),
|
||||
try_remove_delegation_from_mixnode(
|
||||
deps.as_mut(),
|
||||
env,
|
||||
mock_info(delegation_owner.as_str(), &[]),
|
||||
identity.clone(),
|
||||
)
|
||||
);
|
||||
// assert_eq!(
|
||||
// Ok(expected_response),
|
||||
// try_remove_delegation_from_mixnode(
|
||||
// deps.as_mut(),
|
||||
// env,
|
||||
// mock_info(delegation_owner.as_str(), &[]),
|
||||
// identity.clone(),
|
||||
// )
|
||||
// );
|
||||
|
||||
_try_reconcile_all_delegation_events(&mut deps.storage, &deps.api).unwrap();
|
||||
// _try_reconcile_all_delegation_events(&mut deps.storage, &deps.api).unwrap();
|
||||
|
||||
assert!(test_helpers::read_delegation(
|
||||
&deps.storage,
|
||||
identity,
|
||||
delegation_owner.as_bytes(),
|
||||
mock_env().block.height
|
||||
)
|
||||
.is_none());
|
||||
}
|
||||
// assert!(test_helpers::read_delegation(
|
||||
// &deps.storage,
|
||||
// identity,
|
||||
// delegation_owner.as_bytes(),
|
||||
// mock_env().block.height
|
||||
// )
|
||||
// .is_none());
|
||||
//}
|
||||
|
||||
#[test]
|
||||
fn total_delegation_is_preserved_if_only_some_undelegate() {
|
||||
|
||||
@@ -6,7 +6,7 @@ use mixnet_contract_common::ContractStateParams;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct ContractState {
|
||||
pub owner: Addr, // only the owner account can update state
|
||||
pub rewarding_validator_address: Addr,
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn try_claim_operator_reward(
|
||||
env: &Env,
|
||||
info: &MessageInfo,
|
||||
) -> Result<Response, ContractError> {
|
||||
_try_claim_operator_reward(deps.storage, deps.api, env, &info.sender.to_string(), None)
|
||||
_try_claim_operator_reward(deps.storage, deps.api, env, info.sender.as_ref(), None)
|
||||
}
|
||||
|
||||
pub fn try_claim_operator_reward_on_behalf(
|
||||
@@ -206,7 +206,7 @@ pub fn try_claim_delegator_reward(
|
||||
deps.storage,
|
||||
deps.api,
|
||||
env,
|
||||
&info.sender.to_string(),
|
||||
info.sender.as_ref(),
|
||||
mix_identity,
|
||||
None,
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ pub enum ExecuteMsg {
|
||||
RemoveHook { addr: String },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum QueryMsg {
|
||||
/// Return AdminResponse
|
||||
|
||||
@@ -7,7 +7,7 @@ pub use account::*;
|
||||
|
||||
use vesting_contract_common::messages::VestingSpecification;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
pub struct VestingPeriod {
|
||||
pub start_time: u64,
|
||||
pub period_seconds: u64,
|
||||
|
||||
@@ -92,9 +92,9 @@ fn get_servers() -> Vec<rocket_okapi::okapi::openapi3::Server> {
|
||||
if std::env::var_os("CARGO").is_some() {
|
||||
return vec![];
|
||||
}
|
||||
return vec![rocket_okapi::okapi::openapi3::Server {
|
||||
vec![rocket_okapi::okapi::openapi3::Server {
|
||||
url: std::env::var("OPEN_API_BASE").unwrap_or_else(|_| "/api/v1/".to_owned()),
|
||||
description: Some("API".to_owned()),
|
||||
..Default::default()
|
||||
}];
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ pub(crate) async fn get_single_mixnode_delegations(
|
||||
client: &ThreadsafeValidatorClient,
|
||||
pubkey: &str,
|
||||
) -> Vec<Delegation> {
|
||||
let delegates = match client
|
||||
match client
|
||||
.0
|
||||
.get_all_nymd_single_mixnode_delegations(pubkey.to_string())
|
||||
.await
|
||||
@@ -22,8 +22,7 @@ pub(crate) async fn get_single_mixnode_delegations(
|
||||
error!("Could not get delegations for mix node {}: {:?}", pubkey, e);
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
delegates
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn get_single_mixnode_delegations_summed(
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ bs58 = "0.4.0"
|
||||
clap = { version = "3.0.10", features = ["cargo", "derive"] }
|
||||
colored = "2.0"
|
||||
dashmap = "4.0"
|
||||
dirs = "3.0"
|
||||
dirs = "4.0"
|
||||
dotenv = "0.15.0"
|
||||
futures = "0.3"
|
||||
humantime-serde = "1.0.1"
|
||||
|
||||
@@ -306,7 +306,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct Gateway {
|
||||
/// Version of the gateway for which this configuration was created.
|
||||
#[serde(default = "missing_string_value")]
|
||||
|
||||
+1
-2
@@ -21,7 +21,7 @@ bs58 = "0.4.0"
|
||||
clap = { version = "3.0.10", features = ["cargo", "derive"] }
|
||||
colored = "2.0"
|
||||
cupid = "0.6.1"
|
||||
dirs = "3.0"
|
||||
dirs = "4.0"
|
||||
dotenv = "0.15.0"
|
||||
futures = "0.3.0"
|
||||
humantime-serde = "1.0"
|
||||
@@ -51,7 +51,6 @@ validator-client = { path="../common/client-libs/validator-client" }
|
||||
version-checker = { path="../common/version-checker" }
|
||||
|
||||
[dev-dependencies]
|
||||
serial_test = "0.5"
|
||||
tokio = { version="1.19.1", features = ["rt-multi-thread", "net", "signal", "test-util"] }
|
||||
|
||||
nymsphinx-types = { path = "../common/nymsphinx/types" }
|
||||
|
||||
@@ -60,7 +60,7 @@ impl From<Init> for OverrideConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn execute(args: &Init) {
|
||||
pub(crate) fn execute(args: &Init) {
|
||||
let override_config_fields = OverrideConfig::from(args.clone());
|
||||
let id = &override_config_fields.id;
|
||||
println!("Initialising mixnode {}...", id);
|
||||
|
||||
@@ -52,7 +52,7 @@ struct OverrideConfig {
|
||||
pub(crate) async fn execute(args: Cli) {
|
||||
match &args.command {
|
||||
Commands::Describe(m) => describe::execute(m),
|
||||
Commands::Init(m) => init::execute(m).await,
|
||||
Commands::Init(m) => init::execute(m),
|
||||
Commands::Run(m) => run::execute(m).await,
|
||||
Commands::Sign(m) => sign::execute(m),
|
||||
Commands::Upgrade(m) => upgrade::execute(m),
|
||||
@@ -136,7 +136,9 @@ pub(crate) fn validate_bech32_address_or_exit(address: &str) {
|
||||
pub(crate) fn version_check(cfg: &Config) -> bool {
|
||||
let binary_version = env!("CARGO_PKG_VERSION");
|
||||
let config_version = cfg.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 version_checker::is_minor_version_compatible(binary_version, config_version) {
|
||||
info!("but they are still semver compatible. However, consider running the `upgrade` command");
|
||||
@@ -145,7 +147,5 @@ pub(crate) fn version_check(cfg: &Config) -> bool {
|
||||
error!("and they are semver incompatible! - please run the `upgrade` command before attempting `run` again");
|
||||
false
|
||||
}
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ impl From<Run> for OverrideConfig {
|
||||
}
|
||||
}
|
||||
|
||||
fn show_binding_warning(address: String) {
|
||||
fn show_binding_warning(address: &str) {
|
||||
println!("\n##### NOTE #####");
|
||||
println!(
|
||||
"\nYou are trying to bind to {} - you might not be accessible to other nodes\n\
|
||||
@@ -97,7 +97,7 @@ pub(crate) async fn execute(args: &Run) {
|
||||
}
|
||||
|
||||
if special_addresses().contains(&&*config.get_listening_address().to_string()) {
|
||||
show_binding_warning(config.get_listening_address().to_string());
|
||||
show_binding_warning(&config.get_listening_address().to_string());
|
||||
}
|
||||
|
||||
let mut mixnode = MixNode::new(config);
|
||||
|
||||
@@ -10,6 +10,7 @@ pub(crate) struct Hardware {
|
||||
crypto_hardware: Option<CryptoHardware>,
|
||||
}
|
||||
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[derive(Serialize, Debug)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
pub(crate) struct CryptoHardware {
|
||||
@@ -44,9 +45,9 @@ fn hardware_from_sysinfo(crypto_hardware: Option<CryptoHardware>) -> Option<Hard
|
||||
let cores = system.cpus();
|
||||
let num_cores = cores.len();
|
||||
Some(Hardware {
|
||||
crypto_hardware,
|
||||
ram,
|
||||
num_cores,
|
||||
crypto_hardware,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
||||
+29
-11
@@ -286,17 +286,7 @@ impl MixNode {
|
||||
}
|
||||
|
||||
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",
|
||||
e
|
||||
);
|
||||
}
|
||||
println!(
|
||||
"Received SIGINT - the mixnode will terminate now \
|
||||
(threads are not yet nicely stopped, if you see stack traces that's alright)."
|
||||
);
|
||||
wait_for_signal().await;
|
||||
|
||||
log::info!("Sending shutdown");
|
||||
shutdown.signal_shutdown().ok();
|
||||
@@ -344,3 +334,31 @@ impl MixNode {
|
||||
self.wait_for_interrupt(shutdown).await
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
async fn wait_for_signal() {
|
||||
use tokio::signal::unix::{signal, SignalKind};
|
||||
let mut sigterm = signal(SignalKind::terminate()).expect("Failed to setup SIGTERM channel");
|
||||
let mut sigquit = signal(SignalKind::quit()).expect("Failed to setup SIGQUIT channel");
|
||||
|
||||
tokio::select! {
|
||||
_ = tokio::signal::ctrl_c() => {
|
||||
log::info!("Received SIGINT");
|
||||
},
|
||||
_ = sigterm.recv() => {
|
||||
log::info!("Received SIGTERM");
|
||||
}
|
||||
_ = sigquit.recv() => {
|
||||
log::info!("Received SIGQUIT");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
async fn wait_for_signal() {
|
||||
tokio::select! {
|
||||
_ = tokio::signal::ctrl_c() => {
|
||||
log::info!("Received SIGINT");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{fs, io};
|
||||
|
||||
pub(crate) const DESCRIPTION_FILE: &str = "description.toml";
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct NodeDescription {
|
||||
pub(crate) name: String,
|
||||
pub(crate) description: String,
|
||||
|
||||
@@ -51,14 +51,14 @@ impl SharedNodeStats {
|
||||
guard.update_time = snapshot_time;
|
||||
|
||||
guard.packets_received_since_startup += new_received;
|
||||
for (mix, count) in new_sent.iter() {
|
||||
for (mix, count) in &new_sent {
|
||||
*guard
|
||||
.packets_sent_since_startup
|
||||
.entry(mix.clone())
|
||||
.or_insert(0) += *count;
|
||||
}
|
||||
|
||||
for (mix, count) in new_dropped.iter() {
|
||||
for (mix, count) in &new_dropped {
|
||||
*guard
|
||||
.packets_explicitly_dropped_since_last_update
|
||||
.entry(mix.clone())
|
||||
|
||||
Generated
+3
-12
@@ -590,7 +590,7 @@ version = "1.0.1"
|
||||
dependencies = [
|
||||
"config",
|
||||
"crypto",
|
||||
"dirs 3.0.2",
|
||||
"dirs",
|
||||
"futures",
|
||||
"gateway-client",
|
||||
"gateway-requests",
|
||||
@@ -1295,15 +1295,6 @@ dependencies = [
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
@@ -3386,7 +3377,7 @@ dependencies = [
|
||||
"bip39",
|
||||
"client-core",
|
||||
"config",
|
||||
"dirs 4.0.0",
|
||||
"dirs",
|
||||
"eyre",
|
||||
"fix-path-env",
|
||||
"futures",
|
||||
@@ -3418,7 +3409,7 @@ dependencies = [
|
||||
"config",
|
||||
"credential-storage",
|
||||
"crypto",
|
||||
"dirs 3.0.2",
|
||||
"dirs",
|
||||
"dotenv",
|
||||
"futures",
|
||||
"gateway-client",
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg_attr(test, derive(ts_rs::TS))]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct ConnectResult {
|
||||
pub address: String,
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(ts_rs::TS))]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct DisconnectResult {
|
||||
pub success: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(ts_rs::TS))]
|
||||
#[cfg_attr(test, ts(rename_all = "lowercase"))]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ConnectionStatusKind {
|
||||
Disconnected,
|
||||
|
||||
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
feature = "generate-ts",
|
||||
ts(export, export_to = "nym-wallet/src/types/rust/AppEnv.ts")
|
||||
)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct AppEnv {
|
||||
pub ADMIN_ADDRESS: Option<String>,
|
||||
pub SHOW_TERMINAL: Option<String>,
|
||||
|
||||
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "nym-wallet/src/types/rust/Epoch.ts")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize)]
|
||||
pub struct Epoch {
|
||||
id: u32,
|
||||
start: i64,
|
||||
|
||||
@@ -12,7 +12,7 @@ edition = "2021"
|
||||
[dependencies]
|
||||
async-trait = { version = "0.1.51" }
|
||||
clap = "2.33.0"
|
||||
dirs = "3.0"
|
||||
dirs = "4.0"
|
||||
futures = "0.3"
|
||||
ipnetwork = "0.17"
|
||||
log = "0.4"
|
||||
|
||||
@@ -349,7 +349,7 @@ impl ServiceProvider {
|
||||
|
||||
// Make the websocket connection so we can receive incoming Mixnet messages.
|
||||
async fn connect_websocket(&self, uri: &str) -> TSWebsocketStream {
|
||||
let ws_stream = match websocket::Connection::new(uri).connect().await {
|
||||
match websocket::Connection::new(uri).connect().await {
|
||||
Ok(ws_stream) => {
|
||||
info!("* connected to local websocket server at {}", uri);
|
||||
ws_stream
|
||||
@@ -357,7 +357,6 @@ impl ServiceProvider {
|
||||
Err(WebsocketConnectionError::ConnectionNotEstablished) => {
|
||||
panic!("Error: websocket connection attempt failed, is the Nym client running?")
|
||||
}
|
||||
};
|
||||
ws_stream
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dirs = "3.0"
|
||||
dirs = "4.0"
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0.4"
|
||||
rocket = { version = "0.5.0-rc.2", features = ["json"] }
|
||||
|
||||
@@ -17,7 +17,7 @@ rust-version = "1.56"
|
||||
[dependencies]
|
||||
async-trait = "0.1.52"
|
||||
clap = "2.33.0"
|
||||
dirs = "3.0"
|
||||
dirs = "4.0"
|
||||
dotenv = "0.15.0"
|
||||
futures = "0.3"
|
||||
humantime-serde = "1.0"
|
||||
|
||||
@@ -40,7 +40,7 @@ const DEFAULT_MONITOR_THRESHOLD: u8 = 60;
|
||||
const DEFAULT_MIN_MIXNODE_RELIABILITY: u8 = 50;
|
||||
const DEFAULT_MIN_GATEWAY_RELIABILITY: u8 = 20;
|
||||
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct Config {
|
||||
#[serde(default)]
|
||||
base: Base,
|
||||
@@ -86,7 +86,7 @@ impl NymConfig for Config {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct Base {
|
||||
/// ID specifies the human readable ID of this particular validator-api.
|
||||
@@ -116,7 +116,7 @@ impl Default for Base {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct NetworkMonitor {
|
||||
// Mixnodes and gateways with relialability lower the this get blacklisted by network monitor, get no traffic and cannot be selected into a rewarded set.
|
||||
@@ -220,7 +220,7 @@ impl Default for NetworkMonitor {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct NodeStatusAPI {
|
||||
/// Path to the database file containing uptime statuses for all mixnodes and gateways.
|
||||
@@ -243,7 +243,7 @@ impl Default for NodeStatusAPI {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct TopologyCacher {
|
||||
#[serde(with = "humantime_serde")]
|
||||
@@ -258,7 +258,7 @@ impl Default for TopologyCacher {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct Rewarding {
|
||||
/// Specifies whether rewarding service is enabled in this process.
|
||||
@@ -279,7 +279,7 @@ impl Default for Rewarding {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct CoconutSigner {
|
||||
/// Specifies whether rewarding service is enabled in this process.
|
||||
|
||||
@@ -492,11 +492,11 @@ fn get_servers() -> Vec<rocket_okapi::okapi::openapi3::Server> {
|
||||
if std::env::var_os("CARGO").is_some() {
|
||||
return vec![];
|
||||
}
|
||||
return vec![rocket_okapi::okapi::openapi3::Server {
|
||||
vec![rocket_okapi::okapi::openapi3::Server {
|
||||
url: std::env::var("OPEN_API_BASE").unwrap_or_else(|_| "/api/v1/".to_owned()),
|
||||
description: Some("API".to_owned()),
|
||||
..Default::default()
|
||||
}];
|
||||
}]
|
||||
}
|
||||
|
||||
async fn run_validator_api(matches: ArgMatches<'static>) -> Result<()> {
|
||||
|
||||
@@ -19,4 +19,4 @@ mixnet-contract-common = { path= ".../../../../common/cosmwasm-smart-contracts/m
|
||||
[features]
|
||||
default = []
|
||||
coconut = ["coconut-interface"]
|
||||
generate-ts = []
|
||||
generate-ts = []
|
||||
|
||||
Reference in New Issue
Block a user