114d92f93f
* changed NymConfigTemplate trait to call 'template' by reference * network requester lib * introduced generic parameter to 'MixTrafficController' to allow non-remote gateways * allowing for custom gateway sender * types cleanup * minor gateway cmds refactor + initial NR work * wip * running a NR inside gateway note: this NR isnt tied to the gateway yet * rebase fixes * propagating same shutdown handle * wip * starting NR with appropriate local transceiver * fixed premature shutdown * wiring up PacketRouter * both ends wired together * actually working so much cleanup to do now * started removing dead code * wip * temp: hardcode gateway * further cleanup * fixed build of other binaries * setup-network-requester subcmd * overriding NR config in gateway init/run * wip making it wasm-compatible [again] * refactored 'GatewaySetup' * clippy and friends * removed debug code * rust 1.72 lints * ensuring local gateway is available + some comments * correctly putting network requester data in the same underlying details struct * improved gateway errors * changed 'network_requester_config' deserialization * missing clap annotation for 'enabled' flag in 'setup-network-requester' command * saving config file after 'setup-network-requester' * removed dead code * review comments * make embedded NR wait for gateway to come online (for at most 70min) * fixed shutdown on successful gateway wait * updated NR config override
119 lines
3.5 KiB
Rust
119 lines
3.5 KiB
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use crate::node::storage::error::StorageError;
|
|
use nym_network_requester::error::{ClientCoreError, NetworkRequesterError};
|
|
use nym_validator_client::nyxd::error::NyxdError;
|
|
use nym_validator_client::nyxd::AccountId;
|
|
use nym_validator_client::ValidatorClientError;
|
|
use std::io;
|
|
use std::path::PathBuf;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub(crate) enum GatewayError {
|
|
#[error("failed to load {keys} keys from '{}' (private key) and '{}' (public key): {err}", .paths.private_key_path.display(), .paths.public_key_path.display())]
|
|
KeyPairLoadFailure {
|
|
keys: String,
|
|
paths: nym_pemstore::KeyPairPath,
|
|
#[source]
|
|
err: io::Error,
|
|
},
|
|
|
|
#[error("failed to load {key} public key from '{}': {err}", .path.display())]
|
|
PublicKeyLoadFailure {
|
|
key: String,
|
|
path: PathBuf,
|
|
#[source]
|
|
err: io::Error,
|
|
},
|
|
|
|
#[error(
|
|
"failed to load config file for id {id} using path '{}'. detailed message: {source}", path.display()
|
|
)]
|
|
ConfigLoadFailure {
|
|
id: String,
|
|
path: PathBuf,
|
|
#[source]
|
|
source: io::Error,
|
|
},
|
|
|
|
#[error(
|
|
"failed to load config file for network requester (gateway-id: '{id}') using path '{}'. detailed message: {source}", path.display()
|
|
)]
|
|
NetworkRequesterConfigLoadFailure {
|
|
id: String,
|
|
path: PathBuf,
|
|
#[source]
|
|
source: io::Error,
|
|
},
|
|
|
|
#[error(
|
|
"failed to save config file for id {id} using path '{}'. detailed message: {source}", path.display()
|
|
)]
|
|
ConfigSaveFailure {
|
|
id: String,
|
|
path: PathBuf,
|
|
#[source]
|
|
source: io::Error,
|
|
},
|
|
|
|
#[error("the configured version of the gateway ({config_version}) is incompatible with the binary version ({binary_version})")]
|
|
LocalVersionCheckFailure {
|
|
binary_version: String,
|
|
config_version: String,
|
|
},
|
|
|
|
#[error("could not obtain the information about current gateways on the network: {source}")]
|
|
NetworkGatewaysQueryFailure {
|
|
#[source]
|
|
source: ValidatorClientError,
|
|
},
|
|
|
|
#[error("address {account} has an invalid bech32 prefix. it uses '{actual_prefix}' while '{expected_prefix}' was expected")]
|
|
InvalidBech32AccountPrefix {
|
|
account: AccountId,
|
|
expected_prefix: String,
|
|
actual_prefix: String,
|
|
},
|
|
|
|
#[error("storage failure: {source}")]
|
|
StorageError {
|
|
#[from]
|
|
source: StorageError,
|
|
},
|
|
|
|
#[error("Path to network requester configuration file hasn't been specified. Perhaps try to run `setup-network-requester`?")]
|
|
UnspecifiedNetworkRequesterConfig,
|
|
|
|
#[error("there was an issue with the local network requester: {source}")]
|
|
NetworkRequesterFailure {
|
|
#[from]
|
|
source: NetworkRequesterError,
|
|
},
|
|
|
|
#[error("failed to startup local network requester")]
|
|
NetworkRequesterStartupFailure,
|
|
|
|
#[error("there are no nym API endpoints available")]
|
|
NoNymApisAvailable,
|
|
|
|
#[error("there are no nyxd endpoints available")]
|
|
NoNyxdAvailable,
|
|
|
|
#[error("there was an issue attempting to use the validator [nyxd]: {source}")]
|
|
ValidatorFailure {
|
|
#[from]
|
|
source: NyxdError,
|
|
},
|
|
}
|
|
|
|
impl From<ClientCoreError> for GatewayError {
|
|
fn from(value: ClientCoreError) -> Self {
|
|
// if we ever get a client core error, it must have come from the network requester
|
|
GatewayError::NetworkRequesterFailure {
|
|
source: value.into(),
|
|
}
|
|
}
|
|
}
|