2019-01-07 11:33:07 +01:00
|
|
|
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
|
|
|
// This file is part of Parity Ethereum.
|
2016-07-25 16:09:47 +02:00
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is free software: you can redistribute it and/or modify
|
2016-07-25 16:09:47 +02:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is distributed in the hope that it will be useful,
|
2016-07-25 16:09:47 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2019-01-07 11:33:07 +01:00
|
|
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
2016-07-25 16:09:47 +02:00
|
|
|
|
2019-02-07 14:34:24 +01:00
|
|
|
use std::collections::HashSet;
|
|
|
|
use std::time::Duration;
|
2017-09-25 19:45:33 +02:00
|
|
|
use std::{str, fs, fmt};
|
2019-02-06 17:53:34 +01:00
|
|
|
use std::num::NonZeroU32;
|
2018-04-13 17:34:27 +02:00
|
|
|
|
|
|
|
use ethcore::client::Mode;
|
|
|
|
use ethcore::ethereum;
|
|
|
|
use ethcore::spec::{Spec, SpecParams};
|
2018-01-10 13:35:18 +01:00
|
|
|
use ethereum_types::{U256, Address};
|
2018-10-22 09:40:50 +02:00
|
|
|
use parity_runtime::Executor;
|
2017-07-16 18:22:45 +02:00
|
|
|
use hash_fetch::fetch::Client as FetchClient;
|
2018-04-13 17:34:27 +02:00
|
|
|
use journaldb::Algorithm;
|
2018-07-05 07:19:59 +02:00
|
|
|
use miner::gas_pricer::GasPricer;
|
|
|
|
use miner::gas_price_calibrator::{GasPriceCalibratorOptions, GasPriceCalibrator};
|
2018-04-13 17:34:27 +02:00
|
|
|
use parity_version::version_data;
|
2016-09-26 19:21:25 +02:00
|
|
|
use user_defaults::UserDefaults;
|
2016-07-25 16:09:47 +02:00
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub enum SpecType {
|
2017-03-03 13:33:49 +01:00
|
|
|
Foundation,
|
2016-07-25 16:09:47 +02:00
|
|
|
Classic,
|
2018-08-30 21:32:47 +02:00
|
|
|
Poanet,
|
2019-08-12 18:55:11 +02:00
|
|
|
Volta,
|
|
|
|
Ewc,
|
2018-01-05 13:49:07 +01:00
|
|
|
Expanse,
|
2017-10-08 18:17:59 +02:00
|
|
|
Musicoin,
|
2017-12-06 13:48:32 +01:00
|
|
|
Ellaism,
|
2018-11-01 11:06:53 +01:00
|
|
|
Mix,
|
2018-10-11 11:03:57 +02:00
|
|
|
Callisto,
|
2018-08-30 21:32:47 +02:00
|
|
|
Morden,
|
|
|
|
Ropsten,
|
|
|
|
Kovan,
|
2019-03-26 23:31:52 +01:00
|
|
|
Rinkeby,
|
|
|
|
Goerli,
|
|
|
|
Kotti,
|
2018-08-30 21:32:47 +02:00
|
|
|
Sokol,
|
2016-11-11 18:27:20 +01:00
|
|
|
Dev,
|
2016-07-25 16:09:47 +02:00
|
|
|
Custom(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for SpecType {
|
|
|
|
fn default() -> Self {
|
2017-03-03 13:33:49 +01:00
|
|
|
SpecType::Foundation
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-26 19:21:25 +02:00
|
|
|
impl str::FromStr for SpecType {
|
2016-07-25 16:09:47 +02:00
|
|
|
type Err = String;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
let spec = match s {
|
2018-08-30 21:32:47 +02:00
|
|
|
"ethereum" | "frontier" | "homestead" | "byzantium" | "foundation" | "mainnet" => SpecType::Foundation,
|
|
|
|
"classic" | "frontier-dogmatic" | "homestead-dogmatic" => SpecType::Classic,
|
|
|
|
"poanet" | "poacore" => SpecType::Poanet,
|
2019-08-12 18:55:11 +02:00
|
|
|
"volta" => SpecType::Volta,
|
|
|
|
"ewc" | "energyweb" => SpecType::Ewc,
|
2018-01-05 13:49:07 +01:00
|
|
|
"expanse" => SpecType::Expanse,
|
2017-10-08 18:17:59 +02:00
|
|
|
"musicoin" => SpecType::Musicoin,
|
2017-12-06 13:48:32 +01:00
|
|
|
"ellaism" => SpecType::Ellaism,
|
2018-11-01 11:06:53 +01:00
|
|
|
"mix" => SpecType::Mix,
|
2018-10-11 11:03:57 +02:00
|
|
|
"callisto" => SpecType::Callisto,
|
2018-08-30 21:32:47 +02:00
|
|
|
"morden" | "classic-testnet" => SpecType::Morden,
|
|
|
|
"ropsten" => SpecType::Ropsten,
|
|
|
|
"kovan" | "testnet" => SpecType::Kovan,
|
2019-03-26 23:31:52 +01:00
|
|
|
"rinkeby" => SpecType::Rinkeby,
|
|
|
|
"goerli" | "görli" => SpecType::Goerli,
|
|
|
|
"kotti" => SpecType::Kotti,
|
2018-08-30 21:32:47 +02:00
|
|
|
"sokol" | "poasokol" => SpecType::Sokol,
|
2016-11-11 18:27:20 +01:00
|
|
|
"dev" => SpecType::Dev,
|
2016-07-25 16:09:47 +02:00
|
|
|
other => SpecType::Custom(other.into()),
|
|
|
|
};
|
|
|
|
Ok(spec)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-04 16:51:27 +01:00
|
|
|
impl fmt::Display for SpecType {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.write_str(match *self {
|
2017-03-03 13:33:49 +01:00
|
|
|
SpecType::Foundation => "foundation",
|
2017-01-04 16:51:27 +01:00
|
|
|
SpecType::Classic => "classic",
|
2018-08-30 21:32:47 +02:00
|
|
|
SpecType::Poanet => "poanet",
|
2019-08-12 18:55:11 +02:00
|
|
|
SpecType::Volta => "volta",
|
|
|
|
SpecType::Ewc => "energyweb",
|
2018-01-05 13:49:07 +01:00
|
|
|
SpecType::Expanse => "expanse",
|
2017-10-08 18:17:59 +02:00
|
|
|
SpecType::Musicoin => "musicoin",
|
2017-12-06 13:48:32 +01:00
|
|
|
SpecType::Ellaism => "ellaism",
|
2018-11-01 11:06:53 +01:00
|
|
|
SpecType::Mix => "mix",
|
2018-10-11 11:03:57 +02:00
|
|
|
SpecType::Callisto => "callisto",
|
2018-08-30 21:32:47 +02:00
|
|
|
SpecType::Morden => "morden",
|
|
|
|
SpecType::Ropsten => "ropsten",
|
2017-03-02 20:24:27 +01:00
|
|
|
SpecType::Kovan => "kovan",
|
2019-03-26 23:31:52 +01:00
|
|
|
SpecType::Rinkeby => "rinkeby",
|
|
|
|
SpecType::Goerli => "goerli",
|
|
|
|
SpecType::Kotti => "kotti",
|
2018-08-30 21:32:47 +02:00
|
|
|
SpecType::Sokol => "sokol",
|
2017-01-04 16:51:27 +01:00
|
|
|
SpecType::Dev => "dev",
|
|
|
|
SpecType::Custom(ref custom) => custom,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
impl SpecType {
|
2017-09-25 19:45:33 +02:00
|
|
|
pub fn spec<'a, T: Into<SpecParams<'a>>>(&self, params: T) -> Result<Spec, String> {
|
|
|
|
let params = params.into();
|
2016-07-25 16:09:47 +02:00
|
|
|
match *self {
|
2017-09-25 19:45:33 +02:00
|
|
|
SpecType::Foundation => Ok(ethereum::new_foundation(params)),
|
|
|
|
SpecType::Classic => Ok(ethereum::new_classic(params)),
|
2018-08-30 21:32:47 +02:00
|
|
|
SpecType::Poanet => Ok(ethereum::new_poanet(params)),
|
2019-08-12 18:55:11 +02:00
|
|
|
SpecType::Volta => Ok(ethereum::new_volta(params)),
|
|
|
|
SpecType::Ewc => Ok(ethereum::new_ewc(params)),
|
2018-01-05 13:49:07 +01:00
|
|
|
SpecType::Expanse => Ok(ethereum::new_expanse(params)),
|
2017-10-08 18:17:59 +02:00
|
|
|
SpecType::Musicoin => Ok(ethereum::new_musicoin(params)),
|
2017-12-06 13:48:32 +01:00
|
|
|
SpecType::Ellaism => Ok(ethereum::new_ellaism(params)),
|
2018-11-01 11:06:53 +01:00
|
|
|
SpecType::Mix => Ok(ethereum::new_mix(params)),
|
2018-10-11 11:03:57 +02:00
|
|
|
SpecType::Callisto => Ok(ethereum::new_callisto(params)),
|
2018-08-30 21:32:47 +02:00
|
|
|
SpecType::Morden => Ok(ethereum::new_morden(params)),
|
|
|
|
SpecType::Ropsten => Ok(ethereum::new_ropsten(params)),
|
2017-09-25 19:45:33 +02:00
|
|
|
SpecType::Kovan => Ok(ethereum::new_kovan(params)),
|
2019-03-26 23:31:52 +01:00
|
|
|
SpecType::Rinkeby => Ok(ethereum::new_rinkeby(params)),
|
|
|
|
SpecType::Goerli => Ok(ethereum::new_goerli(params)),
|
|
|
|
SpecType::Kotti => Ok(ethereum::new_kotti(params)),
|
2018-08-30 21:32:47 +02:00
|
|
|
SpecType::Sokol => Ok(ethereum::new_sokol(params)),
|
2016-11-11 18:27:20 +01:00
|
|
|
SpecType::Dev => Ok(Spec::new_instant()),
|
2016-09-05 17:41:34 +02:00
|
|
|
SpecType::Custom(ref filename) => {
|
2017-07-10 12:57:40 +02:00
|
|
|
let file = fs::File::open(filename).map_err(|e| format!("Could not load specification file at {}: {}", filename, e))?;
|
2017-09-25 19:45:33 +02:00
|
|
|
Spec::load(params, file)
|
2016-09-05 17:41:34 +02:00
|
|
|
}
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-12 16:51:07 +01:00
|
|
|
|
|
|
|
pub fn legacy_fork_name(&self) -> Option<String> {
|
|
|
|
match *self {
|
|
|
|
SpecType::Classic => Some("classic".to_owned()),
|
2018-01-05 13:49:07 +01:00
|
|
|
SpecType::Expanse => Some("expanse".to_owned()),
|
2017-10-08 18:17:59 +02:00
|
|
|
SpecType::Musicoin => Some("musicoin".to_owned()),
|
2016-12-12 16:51:07 +01:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub enum Pruning {
|
|
|
|
Specific(Algorithm),
|
|
|
|
Auto,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Pruning {
|
|
|
|
fn default() -> Self {
|
|
|
|
Pruning::Auto
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-26 19:21:25 +02:00
|
|
|
impl str::FromStr for Pruning {
|
2016-07-25 16:09:47 +02:00
|
|
|
type Err = String;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
match s {
|
|
|
|
"auto" => Ok(Pruning::Auto),
|
|
|
|
other => other.parse().map(Pruning::Specific),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Pruning {
|
2016-09-26 19:21:25 +02:00
|
|
|
pub fn to_algorithm(&self, user_defaults: &UserDefaults) -> Algorithm {
|
2016-07-25 16:09:47 +02:00
|
|
|
match *self {
|
|
|
|
Pruning::Specific(algo) => algo,
|
2016-09-26 19:21:25 +02:00
|
|
|
Pruning::Auto => user_defaults.pruning,
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct ResealPolicy {
|
|
|
|
pub own: bool,
|
|
|
|
pub external: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for ResealPolicy {
|
|
|
|
fn default() -> Self {
|
|
|
|
ResealPolicy {
|
|
|
|
own: true,
|
|
|
|
external: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-26 19:21:25 +02:00
|
|
|
impl str::FromStr for ResealPolicy {
|
2016-07-25 16:09:47 +02:00
|
|
|
type Err = String;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
let (own, external) = match s {
|
|
|
|
"none" => (false, false),
|
|
|
|
"own" => (true, false),
|
|
|
|
"ext" => (false, true),
|
|
|
|
"all" => (true, true),
|
|
|
|
x => return Err(format!("Invalid reseal value: {}", x)),
|
|
|
|
};
|
|
|
|
|
|
|
|
let reseal = ResealPolicy {
|
|
|
|
own: own,
|
|
|
|
external: external,
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(reseal)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct AccountsConfig {
|
2019-02-06 17:53:34 +01:00
|
|
|
pub iterations: NonZeroU32,
|
2017-12-22 04:33:49 +01:00
|
|
|
pub refresh_time: u64,
|
2016-07-25 16:09:47 +02:00
|
|
|
pub testnet: bool,
|
|
|
|
pub password_files: Vec<String>,
|
|
|
|
pub unlocked_accounts: Vec<Address>,
|
2017-02-10 01:07:06 +01:00
|
|
|
pub enable_hardware_wallets: bool,
|
2017-06-06 18:06:40 +02:00
|
|
|
pub enable_fast_unlock: bool,
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for AccountsConfig {
|
|
|
|
fn default() -> Self {
|
|
|
|
AccountsConfig {
|
2019-02-06 17:53:34 +01:00
|
|
|
iterations: NonZeroU32::new(10240).expect("10240 > 0; qed"),
|
2017-12-22 04:33:49 +01:00
|
|
|
refresh_time: 5,
|
2016-07-25 16:09:47 +02:00
|
|
|
testnet: false,
|
|
|
|
password_files: Vec::new(),
|
|
|
|
unlocked_accounts: Vec::new(),
|
2017-02-10 01:07:06 +01:00
|
|
|
enable_hardware_wallets: true,
|
2017-06-06 18:06:40 +02:00
|
|
|
enable_fast_unlock: false,
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub enum GasPricerConfig {
|
|
|
|
Fixed(U256),
|
|
|
|
Calibrated {
|
|
|
|
usd_per_tx: f32,
|
|
|
|
recalibration_period: Duration,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for GasPricerConfig {
|
|
|
|
fn default() -> Self {
|
|
|
|
GasPricerConfig::Calibrated {
|
Reduce usd_per_tx (#7058)
* Update config.full.toml
* Update mod.rs
* Patch 1 (#1)
* Iterate over both buffered and unbuffered database entries
* Fix iterator issues
* no default uncles
* prepare cargo configuration for upload of crates
* update bigint version number
* update ethcore-bigint version
* rename hash crate to keccak-hash
* update memorydb
* update rlp
* update patricia-trie cargo.toml
* use error-chain in ethcore-network
* interleaved-ordered 0.1.1
* static linking for snappy
* removed redundant imports
* Add the desktop file for the snap
Now that we have added plugs to allow accessing the display, the snap needs
a desktop file. And bonus point, it will appear on the menu when it's
installed, and once you make a stable relase, it will appear in the gnome
software center app! So, one-click install for parity :)
Closes: #7056
* update icon for desktop
* Properly display Signer errors (Snackbar display popup) (#7053)
* Update to fixed @parity/ui (Errors component)
* Update ParityBar radius to align with Snackbar/Errors
* Update to latest @parity/ui
* Update dependencies @parity/signer-plugin-*
* Really pull in @parity/signer-plugin-* deps
* CHANGELOG for 1.7.8, 1.7.9, 1.8.2, and 1.8.3 (#7055)
* Update changelog for 1.7.8 stable
* Update changelog for 1.7.9 stable
* Improve wording in Changelog
* Update changelog for 1.8.2 beta
* Update changelog for 1.8.3 beta
* [ci skip] js-precompiled 20171115-103846
* ECIP-1039: Monetary policy rounding specification
Fix potential rounding errors between geth and parity in the long-term future.
* Change reward calculation to only use divide once
* SecretStore: servers set change session api (#6925)
* SecretStore: first key versions flush
* SecretStore: key versions in encryption session
* SecretStore: flush key versions negotiation session
* SecretStore: connected key version negotiation session to cluster
* SecretStore: cluster sessions container refactoring
* SecretStore: flush
* SecretStore: flush key versions
* SecretStore: flush
* SecretStore: delegation proto
* SecretStore: decryption_session_is_delegated_when_node_does_not_have_key_share
* SecretStore: fixed version in decryption session
* SecretStore: signing_session_is_delegated_when_node_does_not_have_key_share
* SecretStore: started restoring admin sessions
* SecretStore: restoring admin sessions
* SecretStore: removed obsolete ShareRemove && ShareMove sessions
* SecretStore: ShareAdd math tests only require old_t+1 nodes
* SecretStore: ShareAdd revamp using new math backend
* SecretStore: do not include isolated nodes into consensus_group
* SecretStore: ServersSetChange + ShareAdd revamp
* removed debug printlns
* SecretStore: key version negotiation tests
* SecretStore: removed debug/merge artifacts
* SecretStore: fixed master node selection
* SecretStore: cleanup + tests + fixes
* SecretStore: uncommented tests
* SecretStore: cleaning up
* SecretStore: cleaning up + tests
* SecretStore: cleaning up
* SecretStore: cleaning up && tests
* SecretStore: fixing TODOs
* SecretStore: fixing TODOs + cleanup
* SecretStore: fixing TODOs
* SecretStore: nodes_add_to_the_node_with_obsolete_version
* SecretStore: nodes_add_fails_when_not_enough_share_owners_are_connected
* SecretStore: tests
* SecretStore: signing && delegation tests
* SecretStore: signing && decryption tests when some nodes are isolated
* SecretStore: sessions_are_removed_when_initialization_fails
* SecretStore: ceaning up
* SecretStore: removed obsolete comments
* SecretStore: signing_session_completes_if_node_does_not_have_a_share
* SecretStore: initial ServersSetChange API
* SecretStore: added secretstore_signServersSet RPC
* SecretStore: ChangeServersSet parse tests
* SecretStore: fixes after manual ServersSetChange tests
* lost file
* fixed network ports overlap in tests
* lost files
* fix tests on patricia-trie
* updated eth-secp256k1
* Fix no-default-features.
* Parse payload from panic
Impl payload
empty str is none
Update tests
Clean
Update wasm-tests
* Allow localUrl in manifest
* Improve Github Issue Template: IT CROWD approved version.
* Remove seperator that causes issue descriptions to become headlines sometimes
* Add to all icon_url places
* Add appId as needed to local dapps
* localUrl only from manifest
* Update panic_payload.rs
* Use query-string for search parsing
* spaces to tabs.
* Add localUrl to serialization
* Make storage_read/write return nothing
* Update gas values
* Update wasm-tests
* Cleanup debug info
* Remove debug log
* Optimize & group dapp requests (#7083)
* Group similar methods in same grouping
* Add a shell_getMethodGroups API
* Small code clean changes
* Fix bug dapp.name not showing
* Additional error handling
* Store sources in own map
* Remove observable variables where not needed
* Refactor code and fix bug dapp not showing on approve
* [ci skip] js-precompiled 20171121-150329
* Remove unused and duplicated files in js-old (#7082)
* Cleanup v1 build process, application-only
* Remove built-in dapps from build (duplicated)
* User @parity/api instead of local version
* Update references to @parity/abi
* Remove unused js-old api/abi folders
* Remove duplicated v1 jsonrpc
* Cleanup unused routes
* Update manifest with wallet image
* Update wallet logo
* Re-add missing test.sh
* Update rpc mocks
* Update tests for Providers
* Use flex for iframe & status
* Additional cleanups (Home screen for embed)
* Keep statusbar fixed (and non-overallping with dapps)
* [ci skip] js-precompiled 20171121-164807
* Cleanup top bar, add Home icon for navigation (#7118)
* Localise images to config.js file
* Remove sample status plugin (commented)
* Update image references from config
* Remove Unknown capability & Capable (only display actions)
* Update to @parity/ui 2.2.14
* Add Home icon on statusbar (go back)
* 2.2.14 -> 2.2.x
* Builtin dapp icons where dappreg not available
* [ci skip] js-precompiled 20171122-140247
* fixed RotatingLogger after migrating to new arrayvec
* Update packages, pull in compiled-only repos (#7125)
* Update packages, pull in compiled-only repos
* Update js-precompiled to point to js-dist-paritytech
* Trigger both js & js-old builds to force update
* Update to bring scripts 100% in-sync
* Fixed build && test (#7128)
* fixed build && test
* fixed rpc tests
* Update js-precompiled ref, trigger JS build
* Add test for ECIP1017 at block 250000000
* Wrong era used in ECIP1017 test
It is era 49, and should correspond to ECIP1017/ECIP1039's era 50.
* [ci skip] js-precompiled 20171124-124119
* Push to correct shell branch (#7135)
* Push to correct shell branch
* Trigger both js & js-old builds
* [ci skip] js-precompiled 20171124-134823
* pwasm-run-test utility
* WASM Remove blockhash error (#7121)
* Remove blockhash error
* Update tests.
* Pull in new dapp-{methods,visible} dapps (#7150)
* [ci skip] js-precompiled 20171128-091552
* fixes typo in user config path (#7159)
* Cleanup JS build artifacts (#7164)
* Cleanup JS build artifacts
* Trigger js & js-old
* [ci skip] js-precompiled 20171129-135441
* Use git flag to remove old js artifacts (#7165)
* [ci skip] js-precompiled 20171129-144917
* Remove *.css.map & *.js.map (#7168)
* [ci skip] js-precompiled 20171129-172021
* Delete unused package.json (dist) (#7173)
* [ci skip] js-precompiled 20171130-103432
* Assorted improvements for ethstore and ethkey (#6961)
* Testing many passwords for presale wallet.
* Add multiple threads.
* WiP: ethkey brain wallets recover.
* Refactor pre-sale-wallet cracking.
* Generate in multiple threads. Brain with prefix.
* Validate bain wallet phrase.
* Brain wallet recovery.
* Self-review fixes.
* Fix tests.
* More docs.
* Bump versions.
* Remove cmd_find from borked merge.
* Update wasm submodules.
* Use threadpool.
* upper limit is gas limit * 10 in estimate gas
* React 16 (#7174)
* Update packages to use React 16
* Rollback to react-router v3
* Use component instead of pure one
* Remove warning about mobx
* Make webpack load css from @parity/ui
* Update enzyme to support react16
* Fix lint
* Use @parity/ui v3
* Update refs of plugin-signer-* deps
* Exclude plugin-signer-* from babel processing
* Reupdate refs to old method
* Update refs again
* [ci skip] js-precompiled 20171201-114538
* pwasm-run-test utility upgrade
* Removed ethcore-util dependency from ethcore-network (#7180)
* Removed ethcore-util dependency
* Removed snappy
* New account selector UI in top bar (#7179)
* Add a dropdown popup for account selector
* Install sui latest version for hideOnScroll bug fix
* Update ui
* Update package-lock after rebase
* Require parity/ui v3.0.3
* Pass accountStore as props
* Require parity/ui v3.0.4
* [ci skip] js-precompiled 20171204-115345
* Update mocha import stubs (#7191)
* Update mocha import stubs
* Add .md files to ignore list
* [ci skip] js-precompiled 20171205-084709
* Update FirstRun for UI-2 (#7195)
* WIP
* Update after @parity/ui update
* Update to latest
* Update semver for @parity
* Update & -> &
* [ci skip] js-precompiled 20171205-102703
* Maximum uncle count transition (#7196)
* Enable delayed maximum_uncle_count activation.
* Fix tests.
* Defer kovan HF.
* mistake comment in calc difficulty (#7154)
* Send each log as a separate notifications. (#7175)
* Update config.full.toml
* Revert "Patch 1 (#1)" (#2)
This reverts commit 2fa0af6392f75cf9f7dd5f8250906e3767da8a5b.
* Update usd_per_tx test
* Fix tests
* Fix initial_minimum
2018-01-30 16:10:12 +01:00
|
|
|
usd_per_tx: 0.0001f32,
|
2016-07-25 16:09:47 +02:00
|
|
|
recalibration_period: Duration::from_secs(3600),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-16 18:22:45 +02:00
|
|
|
impl GasPricerConfig {
|
2018-10-22 09:40:50 +02:00
|
|
|
pub fn to_gas_pricer(&self, fetch: FetchClient, p: Executor) -> GasPricer {
|
2017-07-16 18:22:45 +02:00
|
|
|
match *self {
|
2016-07-25 16:09:47 +02:00
|
|
|
GasPricerConfig::Fixed(u) => GasPricer::Fixed(u),
|
2017-01-18 19:44:24 +01:00
|
|
|
GasPricerConfig::Calibrated { usd_per_tx, recalibration_period, .. } => {
|
2017-07-16 18:22:45 +02:00
|
|
|
GasPricer::new_calibrated(
|
2018-07-05 07:19:59 +02:00
|
|
|
GasPriceCalibrator::new(
|
|
|
|
GasPriceCalibratorOptions {
|
|
|
|
usd_per_tx: usd_per_tx,
|
|
|
|
recalibration_period: recalibration_period,
|
|
|
|
},
|
|
|
|
fetch,
|
|
|
|
p,
|
|
|
|
)
|
2017-07-16 18:22:45 +02:00
|
|
|
)
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct MinerExtras {
|
|
|
|
pub author: Address,
|
2016-12-05 22:31:38 +01:00
|
|
|
pub engine_signer: Address,
|
2018-04-13 17:34:27 +02:00
|
|
|
pub extra_data: Vec<u8>,
|
|
|
|
pub gas_range_target: (U256, U256),
|
|
|
|
pub work_notify: Vec<String>,
|
2019-02-07 14:34:24 +01:00
|
|
|
pub local_accounts: HashSet<Address>,
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for MinerExtras {
|
|
|
|
fn default() -> Self {
|
|
|
|
MinerExtras {
|
|
|
|
author: Default::default(),
|
2016-12-05 22:31:38 +01:00
|
|
|
engine_signer: Default::default(),
|
2018-04-13 17:34:27 +02:00
|
|
|
extra_data: version_data(),
|
2018-09-17 08:33:00 +02:00
|
|
|
gas_range_target: (8_000_000.into(), 10_000_000.into()),
|
2018-04-13 17:34:27 +02:00
|
|
|
work_notify: Default::default(),
|
2019-02-07 14:34:24 +01:00
|
|
|
local_accounts: Default::default(),
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-26 19:21:25 +02:00
|
|
|
/// 3-value enum.
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
pub enum Switch {
|
|
|
|
/// True.
|
|
|
|
On,
|
|
|
|
/// False.
|
|
|
|
Off,
|
|
|
|
/// Auto.
|
|
|
|
Auto,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Switch {
|
|
|
|
fn default() -> Self {
|
|
|
|
Switch::Auto
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl str::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))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn tracing_switch_to_bool(switch: Switch, user_defaults: &UserDefaults) -> Result<bool, String> {
|
|
|
|
match (user_defaults.is_first_launch, switch, user_defaults.tracing) {
|
|
|
|
(false, Switch::On, false) => Err("TraceDB resync required".into()),
|
|
|
|
(_, Switch::On, _) => Ok(true),
|
|
|
|
(_, Switch::Off, _) => Ok(false),
|
|
|
|
(_, Switch::Auto, def) => Ok(def),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-27 12:58:14 +01:00
|
|
|
pub fn fatdb_switch_to_bool(switch: Switch, user_defaults: &UserDefaults, _algorithm: Algorithm) -> Result<bool, String> {
|
2016-10-03 19:31:50 +02:00
|
|
|
let result = match (user_defaults.is_first_launch, switch, user_defaults.fat_db) {
|
2016-10-03 11:13:10 +02:00
|
|
|
(false, Switch::On, false) => Err("FatDB resync required".into()),
|
|
|
|
(_, Switch::On, _) => Ok(true),
|
|
|
|
(_, Switch::Off, _) => Ok(false),
|
|
|
|
(_, Switch::Auto, def) => Ok(def),
|
2016-10-03 19:31:50 +02:00
|
|
|
};
|
|
|
|
result
|
2016-10-03 11:13:10 +02:00
|
|
|
}
|
|
|
|
|
2016-11-05 10:38:00 +01:00
|
|
|
pub fn mode_switch_to_bool(switch: Option<Mode>, user_defaults: &UserDefaults) -> Result<Mode, String> {
|
2018-07-23 13:57:50 +02:00
|
|
|
Ok(switch.unwrap_or(user_defaults.mode().clone()))
|
2016-11-05 10:38:00 +01:00
|
|
|
}
|
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2017-10-17 07:12:46 +02:00
|
|
|
use journaldb::Algorithm;
|
2016-09-26 19:21:25 +02:00
|
|
|
use user_defaults::UserDefaults;
|
|
|
|
use super::{SpecType, Pruning, ResealPolicy, Switch, tracing_switch_to_bool};
|
2016-07-25 16:09:47 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_spec_type_parsing() {
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Foundation, "foundation".parse().unwrap());
|
2017-03-03 13:33:49 +01:00
|
|
|
assert_eq!(SpecType::Foundation, "frontier".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Foundation, "homestead".parse().unwrap());
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Foundation, "byzantium".parse().unwrap());
|
2017-03-03 13:33:49 +01:00
|
|
|
assert_eq!(SpecType::Foundation, "mainnet".parse().unwrap());
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Foundation, "ethereum".parse().unwrap());
|
2016-12-11 14:25:02 +01:00
|
|
|
assert_eq!(SpecType::Classic, "classic".parse().unwrap());
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Classic, "frontier-dogmatic".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Classic, "homestead-dogmatic".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Poanet, "poanet".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Poanet, "poacore".parse().unwrap());
|
2019-08-12 18:55:11 +02:00
|
|
|
assert_eq!(SpecType::Volta, "volta".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Ewc, "ewc".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Ewc, "energyweb".parse().unwrap());
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Expanse, "expanse".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Musicoin, "musicoin".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Ellaism, "ellaism".parse().unwrap());
|
2018-11-01 11:06:53 +01:00
|
|
|
assert_eq!(SpecType::Mix, "mix".parse().unwrap());
|
2018-10-11 11:03:57 +02:00
|
|
|
assert_eq!(SpecType::Callisto, "callisto".parse().unwrap());
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Morden, "morden".parse().unwrap());
|
2016-12-30 15:52:49 +01:00
|
|
|
assert_eq!(SpecType::Morden, "classic-testnet".parse().unwrap());
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Ropsten, "ropsten".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Kovan, "kovan".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Kovan, "testnet".parse().unwrap());
|
2019-03-26 23:31:52 +01:00
|
|
|
assert_eq!(SpecType::Rinkeby, "rinkeby".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Goerli, "goerli".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Goerli, "görli".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Kotti, "kotti".parse().unwrap());
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(SpecType::Sokol, "sokol".parse().unwrap());
|
|
|
|
assert_eq!(SpecType::Sokol, "poasokol".parse().unwrap());
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_spec_type_default() {
|
2017-03-03 13:33:49 +01:00
|
|
|
assert_eq!(SpecType::Foundation, SpecType::default());
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 16:51:27 +01:00
|
|
|
#[test]
|
|
|
|
fn test_spec_type_display() {
|
2017-03-03 13:33:49 +01:00
|
|
|
assert_eq!(format!("{}", SpecType::Foundation), "foundation");
|
2017-01-04 16:51:27 +01:00
|
|
|
assert_eq!(format!("{}", SpecType::Classic), "classic");
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(format!("{}", SpecType::Poanet), "poanet");
|
2019-08-12 18:55:11 +02:00
|
|
|
assert_eq!(format!("{}", SpecType::Volta), "volta");
|
|
|
|
assert_eq!(format!("{}", SpecType::Ewc), "energyweb");
|
2018-01-05 13:49:07 +01:00
|
|
|
assert_eq!(format!("{}", SpecType::Expanse), "expanse");
|
2017-10-08 18:17:59 +02:00
|
|
|
assert_eq!(format!("{}", SpecType::Musicoin), "musicoin");
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(format!("{}", SpecType::Ellaism), "ellaism");
|
2018-11-01 11:06:53 +01:00
|
|
|
assert_eq!(format!("{}", SpecType::Mix), "mix");
|
2018-10-11 11:03:57 +02:00
|
|
|
assert_eq!(format!("{}", SpecType::Callisto), "callisto");
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(format!("{}", SpecType::Morden), "morden");
|
|
|
|
assert_eq!(format!("{}", SpecType::Ropsten), "ropsten");
|
2017-03-02 20:24:27 +01:00
|
|
|
assert_eq!(format!("{}", SpecType::Kovan), "kovan");
|
2019-03-26 23:31:52 +01:00
|
|
|
assert_eq!(format!("{}", SpecType::Rinkeby), "rinkeby");
|
|
|
|
assert_eq!(format!("{}", SpecType::Goerli), "goerli");
|
|
|
|
assert_eq!(format!("{}", SpecType::Kotti), "kotti");
|
2018-08-30 21:32:47 +02:00
|
|
|
assert_eq!(format!("{}", SpecType::Sokol), "sokol");
|
2017-01-04 16:51:27 +01:00
|
|
|
assert_eq!(format!("{}", SpecType::Dev), "dev");
|
|
|
|
assert_eq!(format!("{}", SpecType::Custom("foo/bar".into())), "foo/bar");
|
|
|
|
}
|
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
#[test]
|
|
|
|
fn test_pruning_parsing() {
|
|
|
|
assert_eq!(Pruning::Auto, "auto".parse().unwrap());
|
|
|
|
assert_eq!(Pruning::Specific(Algorithm::Archive), "archive".parse().unwrap());
|
|
|
|
assert_eq!(Pruning::Specific(Algorithm::EarlyMerge), "light".parse().unwrap());
|
|
|
|
assert_eq!(Pruning::Specific(Algorithm::OverlayRecent), "fast".parse().unwrap());
|
|
|
|
assert_eq!(Pruning::Specific(Algorithm::RefCounted), "basic".parse().unwrap());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_pruning_default() {
|
|
|
|
assert_eq!(Pruning::Auto, Pruning::default());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_reseal_policy_parsing() {
|
|
|
|
let none = ResealPolicy { own: false, external: false };
|
|
|
|
let own = ResealPolicy { own: true, external: false };
|
|
|
|
let ext = ResealPolicy { own: false, external: true };
|
|
|
|
let all = ResealPolicy { own: true, external: true };
|
|
|
|
assert_eq!(none, "none".parse().unwrap());
|
|
|
|
assert_eq!(own, "own".parse().unwrap());
|
|
|
|
assert_eq!(ext, "ext".parse().unwrap());
|
|
|
|
assert_eq!(all, "all".parse().unwrap());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_reseal_policy_default() {
|
|
|
|
let all = ResealPolicy { own: true, external: true };
|
|
|
|
assert_eq!(all, ResealPolicy::default());
|
|
|
|
}
|
2016-09-26 19:21:25 +02:00
|
|
|
|
|
|
|
#[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);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn user_defaults_with_tracing(first_launch: bool, tracing: bool) -> UserDefaults {
|
|
|
|
let mut ud = UserDefaults::default();
|
|
|
|
ud.is_first_launch = first_launch;
|
|
|
|
ud.tracing = tracing;
|
|
|
|
ud
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_switch_to_bool() {
|
|
|
|
assert!(!tracing_switch_to_bool(Switch::Off, &user_defaults_with_tracing(true, true)).unwrap());
|
|
|
|
assert!(!tracing_switch_to_bool(Switch::Off, &user_defaults_with_tracing(true, false)).unwrap());
|
|
|
|
assert!(!tracing_switch_to_bool(Switch::Off, &user_defaults_with_tracing(false, true)).unwrap());
|
|
|
|
assert!(!tracing_switch_to_bool(Switch::Off, &user_defaults_with_tracing(false, false)).unwrap());
|
|
|
|
|
|
|
|
assert!(tracing_switch_to_bool(Switch::On, &user_defaults_with_tracing(true, true)).unwrap());
|
|
|
|
assert!(tracing_switch_to_bool(Switch::On, &user_defaults_with_tracing(true, false)).unwrap());
|
|
|
|
assert!(tracing_switch_to_bool(Switch::On, &user_defaults_with_tracing(false, true)).unwrap());
|
|
|
|
assert!(tracing_switch_to_bool(Switch::On, &user_defaults_with_tracing(false, false)).is_err());
|
|
|
|
}
|
2016-07-25 16:09:47 +02:00
|
|
|
}
|