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

cli overhaul #1600

Merged
merged 99 commits into from
Jul 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
b6c9ad7
cli commands
debris Jul 5, 2016
a64aa61
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 6, 2016
bf3bd39
cleanup parity/signer
debris Jul 6, 2016
dee25f7
cleanup parity/signer
debris Jul 6, 2016
c2fa4cf
remove redundant import of signer crate from main.rs
debris Jul 6, 2016
b23f8c2
Merge branch 'parity_signer' into cli_commands
debris Jul 6, 2016
a580b5b
cli cleanup in progress
debris Jul 7, 2016
9cf50cf
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 7, 2016
183c375
cli cleanup in progress
debris Jul 7, 2016
88f4e32
moved few commonly used functions to separate methods with tests
debris Jul 7, 2016
49044ea
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 7, 2016
5bc98ec
cleaning up blockchain import in progress
debris Jul 7, 2016
24e5d77
cleaning up blockchain import in progress2
debris Jul 7, 2016
115b18d
cleaning up blockchain import in progress3
debris Jul 8, 2016
9b727fb
tests for database compaction profile parsing
debris Jul 8, 2016
74d87bd
cleaning up blockchain import in progress4
debris Jul 8, 2016
b53efea
cleaning up blockchain import in progress5
debris Jul 10, 2016
04afde6
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 10, 2016
6784625
blockchain import
debris Jul 10, 2016
3159fa9
export blockchain in progress
debris Jul 10, 2016
518b9fc
cleanup execute_export
debris Jul 10, 2016
02461a4
Configuration::to_duration cleaned up
debris Jul 10, 2016
b137b20
removed unused code, tests for to_duration
debris Jul 10, 2016
aabbf4f
cleanup Configuration::mode function
debris Jul 10, 2016
f71c525
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 11, 2016
76d7f3a
parsing some of the cli params in params.rs
debris Jul 11, 2016
5f9350d
Merge branch 'master' of github.com:ethcore/parity into parity_signer
debris Jul 11, 2016
f99ba1d
rpc and signer are no longer optional
debris Jul 11, 2016
df9d9c2
move importing extern crates to main.rs file
debris Jul 11, 2016
c4c944e
Merge branch 'parity_signer' into cli_commands
debris Jul 11, 2016
45bc7f9
swipe dies from rpc module
debris Jul 11, 2016
b0ee8c6
swipe dies from dapps
debris Jul 11, 2016
5cbc7a1
finding deprecated
debris Jul 11, 2016
82b8b2f
several tests and fixes for parity
debris Jul 11, 2016
5329d6c
parity cleanup in progress
debris Jul 11, 2016
ab6854f
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 11, 2016
fa3cd2b
cleanup price parsing
debris Jul 11, 2016
93192e7
parity cleanup in progress
debris Jul 11, 2016
220e852
swiped all dies
debris Jul 11, 2016
1dab0f2
parity cleanup in progress
debris Jul 12, 2016
a446756
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 12, 2016
f1754e6
replace usages of from_str with parse() in parity/params.rs
debris Jul 12, 2016
6d81cd5
removed few more from_str
debris Jul 12, 2016
bad6666
split parity/params.rs into params and helpers
debris Jul 12, 2016
6367fd9
removed wildcard import from configuration.rs
debris Jul 12, 2016
45fc449
cleanup directories/path creation
debris Jul 12, 2016
0329d39
cleaning up run cmd
debris Jul 12, 2016
a6d77fc
moved LoggerConfig
debris Jul 12, 2016
2b083d0
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 12, 2016
0d4c764
defaults for cli params
debris Jul 12, 2016
7adbff9
fixed indention in raise_fd_limit
debris Jul 12, 2016
46a4c44
tests for rpc_apis
debris Jul 12, 2016
60d6f81
tests for default ipc and rpc settings
debris Jul 12, 2016
1764c2f
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 12, 2016
6b86100
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 12, 2016
c5c98a6
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 15, 2016
14d49f8
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 15, 2016
7560316
ipc socket
debris Jul 18, 2016
c7a13ce
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 18, 2016
9f53814
cleanup in progress
debris Jul 18, 2016
f4d2a8c
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 18, 2016
c4483c2
account service
debris Jul 18, 2016
0c3f156
cleanup miner config
debris Jul 18, 2016
c52edd6
Merge branch 'fixed_failing_master' into cli_commands
debris Jul 19, 2016
cce81f1
BlockChain commands use Directiores structure now
debris Jul 19, 2016
dcff6fa
client_config
debris Jul 19, 2016
0bb6cba
network settings and dapps configuration
debris Jul 19, 2016
b0f711e
removing warnings
debris Jul 19, 2016
9cbbffe
default logger config
debris Jul 19, 2016
1f79314
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 19, 2016
c08eea7
fixed client_path
debris Jul 19, 2016
cbe2a0b
overhaul
debris Jul 19, 2016
8f3afb6
fixing export && import
debris Jul 19, 2016
86bd033
default export DataFormat
debris Jul 19, 2016
f82b5a5
import and export also upgrade db
debris Jul 19, 2016
c3e06f0
fixed export && import
debris Jul 20, 2016
ba3e025
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 20, 2016
f71633e
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 20, 2016
596f64e
polishing pr
debris Jul 20, 2016
27b6fc6
Merge branch 'master' of github.com:ethcore/parity into cli_commands
debris Jul 20, 2016
9c6a8b2
polishing pr
debris Jul 21, 2016
5a58b4b
fixed custom bootnodes
debris Jul 21, 2016
e0deef6
fixed daemonize on windows
debris Jul 21, 2016
58736b2
fixed setting up enable network
debris Jul 21, 2016
792b246
finished pr
debris Jul 21, 2016
151b8ff
fixed compiling on windows
debris Jul 21, 2016
baaadb5
Fixed warning; windows build
arkpar Jul 23, 2016
bcef32d
Merge remote-tracking branch 'origin/master' into cli_commands
arkpar Jul 23, 2016
2619dbf
Better cache management
arkpar Jul 23, 2016
ad8e8a6
Merge branch 'master' of github.com:ethcore/parity into cli_commands
arkpar Jul 23, 2016
c475db8
Fixed tests on windows
arkpar Jul 24, 2016
dbdc9c8
Fixed test
arkpar Jul 24, 2016
6a0f37e
Restored pruning method names
arkpar Jul 24, 2016
f6959d5
--cache alias
arkpar Jul 24, 2016
bab266e
Merge branch 'cli_commands' of github.com:ethcore/parity into cli_com…
arkpar Jul 24, 2016
286812d
Fixed more tests
arkpar Jul 24, 2016
0218c6e
Merge branch 'master' of github.com:ethcore/parity into cli_commands
arkpar Jul 25, 2016
ce6f59e
Merge branch 'master' of github.com:ethcore/parity into cli_commands
arkpar Jul 25, 2016
6d9fe7f
Ensure default options actually listed as valid
gavofyork Jul 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ install:
build: off

test_script:
- cargo test --verbose --release --no-default-features
- cargo test --verbose --release

after_test:
- cargo build --verbose --release --no-default-features
- cargo build --verbose --release
- ps: if($env:cert) { Start-FileDownload $env:cert -FileName $env:keyfile }
- ps: if($env:cert) { signtool sign /f $env:keyfile /p $env:certpass target\release\parity.exe }
- makensis.exe nsis\installer.nsi
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/block_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MIN_MEM_LIMIT: usize = 16384;
const MIN_QUEUE_LIMIT: usize = 512;

/// Block queue configuration
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct BlockQueueConfig {
/// Maximum number of blocks to keep in unverified queue.
/// When the limit is reached, is_full returns true.
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/blockchain/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Blockchain configuration.

/// Blockchain configuration.
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct Config {
/// Preferred cache size in bytes.
pub pref_cache_size: usize,
Expand Down
24 changes: 4 additions & 20 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::collections::{HashSet, HashMap, VecDeque};
use std::ops::Deref;
use std::sync::{Arc, Weak};
use std::path::{Path, PathBuf};
use std::path::{Path};
use std::fmt;
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
use std::time::{Instant};
Expand Down Expand Up @@ -141,26 +141,10 @@ pub struct Client {
}

const HISTORY: u64 = 1200;
// DO NOT TOUCH THIS ANY MORE UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.
// Altering it will force a blanket DB update for *all* JournalDB-derived
// databases.
// Instead, add/upgrade the version string of the individual JournalDB-derived database
// of which you actually want force an upgrade.
const CLIENT_DB_VER_STR: &'static str = "5.3";

/// Get the path for the databases given the root path and information on the databases.
pub fn get_db_path(path: &Path, pruning: journaldb::Algorithm, genesis_hash: H256, fork_name: Option<&String>) -> PathBuf {
let mut dir = path.to_path_buf();
dir.push(format!("{:?}{}", H64::from(genesis_hash), fork_name.map(|f| format!("-{}", f)).unwrap_or_default()));
//TODO: sec/fat: pruned/full versioning
// version here is a bit useless now, since it's controlled only be the pruning algo.
dir.push(format!("v{}-sec-{}", CLIENT_DB_VER_STR, pruning));
dir
}

/// Append a path element to the given path and return the string.
pub fn append_path(path: &Path, item: &str) -> String {
let mut p = path.to_path_buf();
pub fn append_path<P>(path: P, item: &str) -> String where P: AsRef<Path> {
let mut p = path.as_ref().to_path_buf();
p.push(item);
p.to_str().unwrap().to_owned()
}
Expand All @@ -174,7 +158,7 @@ impl Client {
miner: Arc<Miner>,
message_channel: IoChannel<ClientIoMessage>,
) -> Result<Arc<Client>, ClientError> {
let path = get_db_path(path, config.pruning, spec.genesis_header().hash(), spec.fork_name.as_ref());
let path = path.to_path_buf();
let gb = spec.genesis_block();
let chain = Arc::new(BlockChain::new(config.blockchain, &gb, &path));
let tracedb = Arc::new(try!(TraceDB::new(config.tracing, &path, chain.clone())));
Expand Down
45 changes: 42 additions & 3 deletions ethcore/src/client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use std::str::FromStr;
pub use std::time::Duration;
pub use block_queue::BlockQueueConfig;
pub use blockchain::Config as BlockChainConfig;
Expand All @@ -33,7 +34,21 @@ pub enum DatabaseCompactionProfile {
}

impl Default for DatabaseCompactionProfile {
fn default() -> Self { DatabaseCompactionProfile::Default }
fn default() -> Self {
DatabaseCompactionProfile::Default
}
}

impl FromStr for DatabaseCompactionProfile {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ssd" | "default" => Ok(DatabaseCompactionProfile::Default),
"hdd" => Ok(DatabaseCompactionProfile::HDD),
_ => Err(format!("Invalid compaction profile given. Expected hdd/ssd (default).")),
}
}
}

/// Operating mode for the client.
Expand All @@ -50,11 +65,13 @@ pub enum Mode {
}

impl Default for Mode {
fn default() -> Self { Mode::Active }
fn default() -> Self {
Mode::Active
}
}

/// Client configuration. Includes configs for all sub-systems.
#[derive(Debug, Default)]
#[derive(Debug, PartialEq, Default)]
pub struct ClientConfig {
/// Block queue configuration.
pub queue: BlockQueueConfig,
Expand All @@ -79,3 +96,25 @@ pub struct ClientConfig {
/// Type of block verifier used by client.
pub verifier_type: VerifierType,
}

#[cfg(test)]
mod test {
use super::{DatabaseCompactionProfile, Mode};

#[test]
fn test_default_compaction_profile() {
assert_eq!(DatabaseCompactionProfile::default(), DatabaseCompactionProfile::Default);
}

#[test]
fn test_parsing_compaction_profile() {
assert_eq!(DatabaseCompactionProfile::Default, "ssd".parse().unwrap());
assert_eq!(DatabaseCompactionProfile::Default, "default".parse().unwrap());
assert_eq!(DatabaseCompactionProfile::HDD, "hdd".parse().unwrap());
}

#[test]
fn test_mode_default() {
assert_eq!(Mode::default(), Mode::Active);
}
}
2 changes: 1 addition & 1 deletion ethcore/src/evm/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::fmt;
use evm::Evm;
use util::{U256, Uint};

#[derive(Debug, Clone)]
#[derive(Debug, PartialEq, Clone)]
/// Type of EVM to use.
pub enum VMType {
/// JIT EVM
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use ethjson;
use util::{H256, MemoryDB, TrieMut, TrieSpec, TrieFactory};
use util::{H256, MemoryDB, TrieSpec, TrieFactory};

fn test_trie(json: &[u8], trie: TrieSpec) -> Vec<String> {
let tests = ethjson::trie::Test::load(json).unwrap();
Expand Down
12 changes: 7 additions & 5 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use client::TransactionImportResult;
use miner::price_info::PriceInfo;

/// Different possible definitions for pending transaction set.
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum PendingSet {
/// Always just the transactions in the queue. These have had only cheap checks.
AlwaysQueue,
Expand All @@ -48,7 +48,7 @@ pub enum PendingSet {
}

/// Configures the behaviour of the miner.
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct MinerOptions {
/// URLs to notify when there is new work.
pub new_work_notify: Vec<String>,
Expand Down Expand Up @@ -77,19 +77,20 @@ impl Default for MinerOptions {
MinerOptions {
new_work_notify: vec![],
force_sealing: false,
reseal_on_external_tx: true,
reseal_on_external_tx: false,
reseal_on_own_tx: true,
tx_gas_limit: !U256::zero(),
tx_queue_size: 1024,
pending_set: PendingSet::AlwaysQueue,
reseal_min_period: Duration::from_secs(0),
reseal_min_period: Duration::from_secs(2),
work_queue_size: 20,
enable_resubmission: true,
}
}
}

/// Options for the dynamic gas price recalibrator.
#[derive(Debug, PartialEq)]
pub struct GasPriceCalibratorOptions {
/// Base transaction price to match against.
pub usd_per_tx: f32,
Expand All @@ -98,9 +99,9 @@ pub struct GasPriceCalibratorOptions {
}

/// The gas price validator variant for a `GasPricer`.
#[derive(Debug, PartialEq)]
pub struct GasPriceCalibrator {
options: GasPriceCalibratorOptions,

next_calibration: Instant,
}

Expand Down Expand Up @@ -128,6 +129,7 @@ impl GasPriceCalibrator {
}

/// Struct to look after updating the acceptable gas price of a miner.
#[derive(Debug, PartialEq)]
pub enum GasPricer {
/// A fixed gas price in terms of Wei - always the argument given.
Fixed(U256),
Expand Down
41 changes: 39 additions & 2 deletions ethcore/src/trace/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

//! Traces config.
use std::str::FromStr;
use bloomchain::Config as BloomConfig;
use trace::Error;

Expand All @@ -29,6 +30,25 @@ pub enum Switch {
Auto,
}

impl Default for Switch {
fn default() -> Self {
Switch::Auto
}
}

impl FromStr for Switch {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"on" => Ok(Switch::On),
"off" => Ok(Switch::Off),
"auto" => Ok(Switch::Auto),
other => Err(format!("Invalid switch value: {}", other))
}
}
}

impl Switch {
/// Tries to turn old switch to new value.
pub fn turn_to(&self, to: Switch) -> Result<bool, Error> {
Expand All @@ -41,7 +61,7 @@ impl Switch {
}

/// Traces config.
#[derive(Debug, Clone)]
#[derive(Debug, PartialEq, Clone)]
pub struct Config {
/// Indicates if tracing should be enabled or not.
/// If it's None, it will be automatically configured.
Expand All @@ -55,7 +75,7 @@ pub struct Config {
impl Default for Config {
fn default() -> Self {
Config {
enabled: Switch::Auto,
enabled: Switch::default(),
blooms: BloomConfig {
levels: 3,
elements_per_index: 16,
Expand All @@ -64,3 +84,20 @@ impl Default for Config {
}
}
}

#[cfg(test)]
mod tests {
use super::Switch;

#[test]
fn test_switch_parsing() {
assert_eq!(Switch::On, "on".parse().unwrap());
assert_eq!(Switch::Off, "off".parse().unwrap());
assert_eq!(Switch::Auto, "auto".parse().unwrap());
}

#[test]
fn test_switch_default() {
assert_eq!(Switch::default(), Switch::Auto);
}
}
2 changes: 1 addition & 1 deletion ethcore/src/verification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use self::canon_verifier::CanonVerifier;
pub use self::noop_verifier::NoopVerifier;

/// Verifier type.
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum VerifierType {
/// Verifies block normally.
Canon,
Expand Down
8 changes: 5 additions & 3 deletions ethstore/src/dir/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use std::{fs, ffi, io};
use std::{fs, io};
use std::path::{PathBuf, Path};
use std::collections::HashMap;
use time;
use ethkey::Address;
use {libc, json, SafeAccount, Error};
use {json, SafeAccount, Error};
use super::KeyDirectory;

#[cfg(not(windows))]
fn restrict_permissions_to_owner(file_path: &Path) -> Result<(), i32> {
use std::ffi;
use libc;
let cstr = ffi::CString::new(file_path.to_str().unwrap()).unwrap();
match unsafe { libc::chmod(cstr.as_ptr(), libc::S_IWUSR | libc::S_IRUSR) } {
0 => Ok(()),
Expand All @@ -32,7 +34,7 @@ fn restrict_permissions_to_owner(file_path: &Path) -> Result<(), i32> {
}

#[cfg(windows)]
fn restrict_permissions_to_owner(file_path: &Path) -> Result<(), i32> {
fn restrict_permissions_to_owner(_file_path: &Path) -> Result<(), i32> {
Ok(())
}

Expand Down
Loading