Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into ao-lmdb
Browse files Browse the repository at this point in the history
* master:
  Add message to IO errors (#10324)
  chore(bump parity-daemonize): require rust >= 1.31 (#10359)
  SecretStore: use in-memory transport in cluster tests (#9850)
  Add fields to `memzero`'s Cargo.toml (#10362)
  snap: release untagged versions from branches to the candidate snap channel (#10357)
  fix(compilation warns): `no-default-features` (#10346)
  • Loading branch information
ordian committed Feb 19, 2019
2 parents 0695f94 + ca67dc2 commit b2519f6
Show file tree
Hide file tree
Showing 30 changed files with 3,602 additions and 2,503 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ethstore = { path = "accounts/ethstore" }
node-filter = { path = "ethcore/node-filter" }
rlp = { version = "0.3.0", features = ["ethereum"] }
cli-signer= { path = "cli-signer" }
parity-daemonize = "0.2"
parity-daemonize = "0.3"
parity-hash-fetch = { path = "updater/hash-fetch" }
parity-ipfs-api = { path = "ipfs" }
parity-local-store = { path = "miner/local-store" }
Expand Down
2 changes: 1 addition & 1 deletion parity/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct ImportFromGethAccounts {


#[cfg(not(feature = "accounts"))]
pub fn execute(cmd: AccountCmd) -> Result<String, String> {
pub fn execute(_cmd: AccountCmd) -> Result<String, String> {
Err("Account management is deprecated. Please see #9997 for alternatives:\nhttps://github.com/paritytech/parity-ethereum/issues/9997".into())
}

Expand Down
4 changes: 2 additions & 2 deletions parity/account_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ mod accounts {
pub struct AccountProvider;

impl ::ethcore::miner::LocalAccounts for AccountProvider {
fn is_local(&self, address: &Address) -> bool {
fn is_local(&self, _address: &Address) -> bool {
false
}
}

pub fn prepare_account_provider(_spec: &SpecType, _dirs: &Directories, _data_dir: &str, cfg: AccountsConfig, _passwords: &[Password]) -> Result<AccountProvider, String> {
pub fn prepare_account_provider(_spec: &SpecType, _dirs: &Directories, _data_dir: &str, _cfg: AccountsConfig, _passwords: &[Password]) -> Result<AccountProvider, String> {
warn!("Note: Your instance of Parity Ethereum is running without account support. Some CLI options are ignored.");
Ok(AccountProvider)
}
Expand Down
8 changes: 6 additions & 2 deletions parity/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::{process, env};

use ansi_term::Colour;
use ctrlc::CtrlC;
use dir::default_hypervisor_path;
use fdlimit::raise_fd_limit;
use ethcore_logger::setup_log;
use parity_ethereum::{start, ExecutionAction};
use parity_daemonize::AsHandle;
use parking_lot::{Condvar, Mutex};
use ethcore_logger::setup_log;

const PLEASE_RESTART_EXIT_CODE: i32 = 69;
const PARITY_EXECUTABLE_NAME: &str = "parity";
Expand Down Expand Up @@ -195,7 +197,9 @@ fn main_direct(force_can_restart: bool) -> i32 {
conf.args.arg_chain = spec_override;
}

let handle = if let Some(ref pid) = conf.args.arg_daemon_pid_file {
// FIXME: `pid_file` shouldn't need to cloned here
// see: `https://github.com/paritytech/parity-daemonize/pull/13` for more info
let handle = if let Some(pid) = conf.args.arg_daemon_pid_file.clone() {
info!("{}", Colour::Blue.paint("starting in daemon mode").to_string());
let _ = std::io::stdout().flush();

Expand Down
13 changes: 7 additions & 6 deletions parity/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use journaldb::Algorithm;

#[derive(Debug)]
pub enum Error {
CannotCreateConfigPath,
CannotWriteVersionFile,
CannotUpdateVersionFile,
CannotCreateConfigPath(io::Error),
CannotWriteVersionFile(io::Error),
CannotUpdateVersionFile(io::Error),
SemVer(SemVerError),
}

Expand Down Expand Up @@ -105,7 +105,7 @@ fn with_locked_version<F>(db_path: &str, script: F) -> Result<usize, Error>
where F: Fn(&Version) -> Result<usize, Error>
{
let mut path = PathBuf::from(db_path);
create_dir_all(&path).map_err(|_| Error::CannotCreateConfigPath)?;
create_dir_all(&path).map_err(Error::CannotCreateConfigPath)?;
path.push("ver.lock");

let version =
Expand All @@ -118,11 +118,11 @@ fn with_locked_version<F>(db_path: &str, script: F) -> Result<usize, Error>
})
.unwrap_or(Version::new(0, 9, 0));

let mut lock = File::create(&path).map_err(|_| Error::CannotWriteVersionFile)?;
let mut lock = File::create(&path).map_err(Error::CannotWriteVersionFile)?;
let result = script(&version);

let written_version = Version::parse(CURRENT_VERSION)?;
lock.write_all(written_version.to_string().as_bytes()).map_err(|_| Error::CannotUpdateVersionFile)?;
lock.write_all(written_version.to_string().as_bytes()).map_err(Error::CannotUpdateVersionFile)?;
result
}

Expand All @@ -139,6 +139,7 @@ fn file_exists(path: &Path) -> bool {
}
}

#[cfg(any(test, feature = "accounts"))]
pub fn upgrade_key_location(from: &PathBuf, to: &PathBuf) {
match fs::create_dir_all(&to).and_then(|()| fs::read_dir(from)) {
Ok(entries) => {
Expand Down
1 change: 1 addition & 0 deletions rpc/src/v1/helpers/dispatch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ pub enum SignWith {
}

impl SignWith {
#[cfg(any(test, feature = "accounts"))]
fn is_password(&self) -> bool {
if let SignWith::Password(_) = *self {
true
Expand Down
3 changes: 3 additions & 0 deletions rpc/src/v1/helpers/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ mod codes {
pub const EXECUTION_ERROR: i64 = -32015;
pub const EXCEPTION_ERROR: i64 = -32016;
pub const DATABASE_ERROR: i64 = -32017;
#[cfg(any(test, feature = "accounts"))]
pub const ACCOUNT_LOCKED: i64 = -32020;
#[cfg(any(test, feature = "accounts"))]
pub const PASSWORD_INVALID: i64 = -32021;
pub const ACCOUNT_ERROR: i64 = -32023;
pub const PRIVATE_ERROR: i64 = -32024;
Expand Down Expand Up @@ -336,6 +338,7 @@ pub fn fetch<T: fmt::Debug>(error: T) -> Error {
}
}

#[cfg(any(test, feature = "accounts"))]
pub fn invalid_call_data<T: fmt::Display>(error: T) -> Error {
Error {
code: ErrorCode::ServerError(codes::ENCODING_ERROR),
Expand Down
2 changes: 2 additions & 0 deletions rpc/src/v1/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod errors;
pub mod block_import;
pub mod deprecated;
pub mod dispatch;
#[cfg(any(test, feature = "accounts"))]
pub mod eip191;
#[cfg(any(test, feature = "accounts"))]
pub mod engine_signer;
Expand All @@ -28,6 +29,7 @@ pub mod fake_sign;
pub mod ipfs;
pub mod light_fetch;
pub mod nonce;
#[cfg(any(test, feature = "accounts"))]
pub mod secretstore;

mod network_settings;
Expand Down
2 changes: 2 additions & 0 deletions rpc/src/v1/types/derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ impl From<DeriveHash> for Derive {
}

/// Error converting request data
#[cfg(any(test, feature = "accounts"))]
#[derive(Debug)]
pub enum ConvertError {
IndexOverlfow(u64),
}

impl Derive {
/// Convert to account provider struct dealing with possible overflows
#[cfg(any(test, feature = "accounts"))]
pub fn to_derivation(self) -> Result<ethstore::Derivation, ConvertError> {
Ok(match self {
Derive::Hierarchical(drv) => {
Expand Down
9 changes: 6 additions & 3 deletions scripts/gitlab/publish-snap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ set -u # treat unset variables as error
TRACK=`awk -F '=' '/^track/ {gsub(/"/, "", $2); gsub(/ /, "", $2); print $2}' ./util/version/Cargo.toml`
echo Track is: $TRACK

# Choose snap release channel based on parity ethereum version track
case ${TRACK} in
nightly) export GRADE="devel" CHANNEL="edge";;
beta) export GRADE="stable" CHANNEL="beta";;
stable) export GRADE="stable" CHANNEL="stable";;
*) echo "No release" && exit 0;;
esac

# Release untagged versions from branches to the candidate snap channel
case ${CI_COMMIT_REF_NAME} in
beta|stable) export GRADE="stable" CHANNEL="candidate";;
esac

VERSION="v"$VERSION
SNAP_PACKAGE="parity_"$VERSION"_"$BUILD_ARCH".snap"

Expand Down Expand Up @@ -49,8 +55,5 @@ echo "Release channel :" $CHANNEL " Branch/tag: " $CI_COMMIT_REF_NAME
echo $SNAPCRAFT_LOGIN_PARITY_BASE64 | base64 --decode > snapcraft.login
snapcraft login --with snapcraft.login
snapcraft push --release $CHANNEL $SNAP_PACKAGE
case ${CHANNEL} in
beta) snapcraft push --release candidate $SNAP_PACKAGE;;
esac
snapcraft status parity
snapcraft logout
37 changes: 20 additions & 17 deletions secret-store/src/key_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use parity_runtime::Executor;
use super::acl_storage::AclStorage;
use super::key_storage::KeyStorage;
use super::key_server_set::KeyServerSet;
use key_server_cluster::{math, ClusterCore};
use key_server_cluster::{math, new_network_cluster};
use traits::{AdminSessionsServer, ServerKeyGenerator, DocumentKeyServer, MessageSigner, KeyServer, NodeKeyPair};
use types::{Error, Public, RequestSignature, Requester, ServerKeyId, EncryptedDocumentKey, EncryptedDocumentKeyShadow,
ClusterConfiguration, MessageHash, EncryptedMessageSignature, NodeId};
use key_server_cluster::{ClusterClient, ClusterConfiguration as NetClusterConfiguration};
use key_server_cluster::{ClusterClient, ClusterConfiguration as NetClusterConfiguration, NetConnectionsManagerConfig};

/// Secret store key server implementation
pub struct KeyServerImpl {
Expand Down Expand Up @@ -175,20 +175,23 @@ impl KeyServerCore {
pub fn new(config: &ClusterConfiguration, key_server_set: Arc<KeyServerSet>, self_key_pair: Arc<NodeKeyPair>,
acl_storage: Arc<AclStorage>, key_storage: Arc<KeyStorage>, executor: Executor) -> Result<Self, Error>
{
let config = NetClusterConfiguration {
let cconfig = NetClusterConfiguration {
self_key_pair: self_key_pair.clone(),
listen_address: (config.listener_address.address.clone(), config.listener_address.port),
key_server_set: key_server_set,
allow_connecting_to_higher_nodes: config.allow_connecting_to_higher_nodes,
acl_storage: acl_storage,
key_storage: key_storage,
admin_public: config.admin_public.clone(),
admin_public: config.admin_public,
preserve_sessions: false,
};
let net_config = NetConnectionsManagerConfig {
listen_address: (config.listener_address.address.clone(), config.listener_address.port),
allow_connecting_to_higher_nodes: config.allow_connecting_to_higher_nodes,
auto_migrate_enabled: config.auto_migrate_enabled,
};

let cluster = ClusterCore::new(executor, config)
.and_then(|c| c.run().map(|_| c.client()))
.map_err(|err| Error::from(err))?;
let core = new_network_cluster(executor, cconfig, net_config)?;
let cluster = core.client();
core.run()?;

Ok(KeyServerCore {
cluster,
Expand Down Expand Up @@ -297,14 +300,14 @@ pub mod tests {
let start = time::Instant::now();
let mut tried_reconnections = false;
loop {
if key_servers.iter().all(|ks| ks.cluster().cluster_state().connected.len() == num_nodes - 1) {
if key_servers.iter().all(|ks| ks.cluster().is_fully_connected()) {
break;
}

let old_tried_reconnections = tried_reconnections;
let mut fully_connected = true;
for key_server in &key_servers {
if key_server.cluster().cluster_state().connected.len() != num_nodes - 1 {
if !key_server.cluster().is_fully_connected() {
fully_connected = false;
if !old_tried_reconnections {
tried_reconnections = true;
Expand Down Expand Up @@ -434,7 +437,7 @@ pub mod tests {
#[test]
fn decryption_session_is_delegated_when_node_does_not_have_key_share() {
let _ = ::env_logger::try_init();
let (key_servers, _, runtime) = make_key_servers(6110, 3);
let (key_servers, key_storages, runtime) = make_key_servers(6110, 3);

// generate document key
let threshold = 0;
Expand All @@ -445,7 +448,7 @@ pub mod tests {
let generated_key = crypto::ecies::decrypt(&secret, &DEFAULT_MAC, &generated_key).unwrap();

// remove key from node0
key_servers[0].cluster().key_storage().remove(&document).unwrap();
key_storages[0].remove(&document).unwrap();

// now let's try to retrieve key back by requesting it from node0, so that session must be delegated
let retrieved_key = key_servers[0].restore_document_key(&document, &signature.into()).unwrap();
Expand All @@ -457,7 +460,7 @@ pub mod tests {
#[test]
fn schnorr_signing_session_is_delegated_when_node_does_not_have_key_share() {
let _ = ::env_logger::try_init();
let (key_servers, _, runtime) = make_key_servers(6114, 3);
let (key_servers, key_storages, runtime) = make_key_servers(6114, 3);
let threshold = 1;

// generate server key
Expand All @@ -467,7 +470,7 @@ pub mod tests {
let server_public = key_servers[0].generate_key(&server_key_id, &signature.clone().into(), threshold).unwrap();

// remove key from node0
key_servers[0].cluster().key_storage().remove(&server_key_id).unwrap();
key_storages[0].remove(&server_key_id).unwrap();

// sign message
let message_hash = H256::from(42);
Expand All @@ -484,7 +487,7 @@ pub mod tests {
#[test]
fn ecdsa_signing_session_is_delegated_when_node_does_not_have_key_share() {
let _ = ::env_logger::try_init();
let (key_servers, _, runtime) = make_key_servers(6117, 4);
let (key_servers, key_storages, runtime) = make_key_servers(6117, 4);
let threshold = 1;

// generate server key
Expand All @@ -494,7 +497,7 @@ pub mod tests {
let server_public = key_servers[0].generate_key(&server_key_id, &signature.clone().into(), threshold).unwrap();

// remove key from node0
key_servers[0].cluster().key_storage().remove(&server_key_id).unwrap();
key_storages[0].remove(&server_key_id).unwrap();

// sign message
let message_hash = H256::random();
Expand Down
Loading

0 comments on commit b2519f6

Please sign in to comment.