v2.5.10 stable (#11239)
* ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
This commit is contained in:
@@ -81,7 +81,7 @@ mod accounts {
|
||||
hardware_wallet_classic_key: spec == &SpecType::Classic,
|
||||
unlock_keep_secret: cfg.enable_fast_unlock,
|
||||
blacklisted_accounts: match *spec {
|
||||
SpecType::Morden | SpecType::Ropsten | SpecType::Kovan | SpecType::Sokol | SpecType::Dev => vec![],
|
||||
SpecType::Morden | SpecType::Mordor | SpecType::Ropsten | SpecType::Kovan | SpecType::Goerli | SpecType::Kotti | SpecType::Sokol | SpecType::Dev => vec![],
|
||||
_ => vec![
|
||||
"00a329c0648769a73afac7f9381e08fb43dbea72".into()
|
||||
],
|
||||
|
||||
@@ -14,20 +14,22 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::str::{FromStr, from_utf8};
|
||||
use std::str::from_utf8;
|
||||
use std::{io, fs};
|
||||
use std::io::{BufReader, BufRead};
|
||||
use std::time::{Instant, Duration};
|
||||
use std::thread::sleep;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_hex::FromHex;
|
||||
use hash::{keccak, KECCAK_NULL_RLP};
|
||||
use ethereum_types::{U256, H256, Address};
|
||||
use bytes::ToPretty;
|
||||
use rlp::PayloadInfo;
|
||||
use ethcore::client::{
|
||||
Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset
|
||||
Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset, ImportExportBlocks
|
||||
};
|
||||
use types::data_format::DataFormat;
|
||||
use ethcore::error::{ImportErrorKind, ErrorKind as EthcoreErrorKind, Error as EthcoreError};
|
||||
use ethcore::miner::Miner;
|
||||
use ethcore::verification::queue::VerifierSettings;
|
||||
@@ -43,30 +45,6 @@ use ethcore_private_tx;
|
||||
use db;
|
||||
use ansi_term::Colour;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum DataFormat {
|
||||
Hex,
|
||||
Binary,
|
||||
}
|
||||
|
||||
impl Default for DataFormat {
|
||||
fn default() -> Self {
|
||||
DataFormat::Binary
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for DataFormat {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"binary" | "bin" => Ok(DataFormat::Binary),
|
||||
"hex" => Ok(DataFormat::Hex),
|
||||
x => Err(format!("Invalid format: {}", x))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum BlockchainCmd {
|
||||
Kill(KillBlockchain),
|
||||
@@ -228,7 +206,7 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> {
|
||||
&cmd.cache_config,
|
||||
&cmd.compaction).map_err(|e| format!("Failed to open database: {:?}", e))?;
|
||||
|
||||
// TODO: could epoch signals be avilable at the end of the file?
|
||||
// TODO: could epoch signals be available at the end of the file?
|
||||
let fetch = ::light::client::fetch::unavailable();
|
||||
let service = LightClientService::start(config, &spec, fetch, db, cache)
|
||||
.map_err(|e| format!("Failed to start client: {}", e))?;
|
||||
@@ -238,7 +216,7 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> {
|
||||
|
||||
let client = service.client();
|
||||
|
||||
let mut instream: Box<io::Read> = match cmd.file_path {
|
||||
let mut instream: Box<dyn io::Read> = match cmd.file_path {
|
||||
Some(f) => Box::new(fs::File::open(&f).map_err(|_| format!("Cannot open given file: {}", f))?),
|
||||
None => Box::new(io::stdin()),
|
||||
};
|
||||
@@ -406,27 +384,11 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> {
|
||||
|
||||
let client = service.client();
|
||||
|
||||
let mut instream: Box<io::Read> = match cmd.file_path {
|
||||
let instream: Box<dyn io::Read> = match cmd.file_path {
|
||||
Some(f) => Box::new(fs::File::open(&f).map_err(|_| format!("Cannot open given file: {}", f))?),
|
||||
None => Box::new(io::stdin()),
|
||||
};
|
||||
|
||||
const READAHEAD_BYTES: usize = 8;
|
||||
|
||||
let mut first_bytes: Vec<u8> = vec![0; READAHEAD_BYTES];
|
||||
let mut first_read = 0;
|
||||
|
||||
let format = match cmd.format {
|
||||
Some(format) => format,
|
||||
None => {
|
||||
first_read = instream.read(&mut first_bytes).map_err(|_| "Error reading from the file/stream.")?;
|
||||
match first_bytes[0] {
|
||||
0xf9 => DataFormat::Binary,
|
||||
_ => DataFormat::Hex,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let informant = Arc::new(Informant::new(
|
||||
FullNodeInformantData {
|
||||
client: client.clone(),
|
||||
@@ -440,49 +402,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> {
|
||||
|
||||
service.register_io_handler(informant).map_err(|_| "Unable to register informant handler".to_owned())?;
|
||||
|
||||
let do_import = |bytes| {
|
||||
let block = Unverified::from_rlp(bytes).map_err(|_| "Invalid block rlp")?;
|
||||
while client.queue_info().is_full() { sleep(Duration::from_secs(1)); }
|
||||
match client.import_block(block) {
|
||||
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => {
|
||||
trace!("Skipping block already in chain.");
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(format!("Cannot import block: {:?}", e));
|
||||
},
|
||||
Ok(_) => {},
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
|
||||
match format {
|
||||
DataFormat::Binary => {
|
||||
loop {
|
||||
let mut bytes = if first_read > 0 {first_bytes.clone()} else {vec![0; READAHEAD_BYTES]};
|
||||
let n = if first_read > 0 {
|
||||
first_read
|
||||
} else {
|
||||
instream.read(&mut bytes).map_err(|_| "Error reading from the file/stream.")?
|
||||
};
|
||||
if n == 0 { break; }
|
||||
first_read = 0;
|
||||
let s = PayloadInfo::from(&bytes).map_err(|e| format!("Invalid RLP in the file/stream: {:?}", e))?.total();
|
||||
bytes.resize(s, 0);
|
||||
instream.read_exact(&mut bytes[n..]).map_err(|_| "Error reading from the file/stream.")?;
|
||||
do_import(bytes)?;
|
||||
}
|
||||
}
|
||||
DataFormat::Hex => {
|
||||
for line in BufReader::new(instream).lines() {
|
||||
let s = line.map_err(|_| "Error reading from the file/stream.")?;
|
||||
let s = if first_read > 0 {from_utf8(&first_bytes).unwrap().to_owned() + &(s[..])} else {s};
|
||||
first_read = 0;
|
||||
let bytes = s.from_hex().map_err(|_| "Invalid hex in file/stream.")?;
|
||||
do_import(bytes)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
client.flush_queue();
|
||||
client.import_blocks(instream, cmd.format)?;
|
||||
|
||||
// save user defaults
|
||||
user_defaults.pruning = algorithm;
|
||||
@@ -611,32 +531,14 @@ fn execute_export(cmd: ExportBlockchain) -> Result<(), String> {
|
||||
false,
|
||||
cmd.max_round_blocks_to_import,
|
||||
)?;
|
||||
let format = cmd.format.unwrap_or_default();
|
||||
|
||||
let client = service.client();
|
||||
|
||||
let mut out: Box<io::Write> = match cmd.file_path {
|
||||
let out: Box<dyn io::Write> = match cmd.file_path {
|
||||
Some(f) => Box::new(fs::File::create(&f).map_err(|_| format!("Cannot write to file given: {}", f))?),
|
||||
None => Box::new(io::stdout()),
|
||||
};
|
||||
|
||||
let from = client.block_number(cmd.from_block).ok_or("From block could not be found")?;
|
||||
let to = client.block_number(cmd.to_block).ok_or("To block could not be found")?;
|
||||
|
||||
for i in from..(to + 1) {
|
||||
if i % 10000 == 0 {
|
||||
info!("#{}", i);
|
||||
}
|
||||
let b = client.block(BlockId::Number(i)).ok_or("Error exporting incomplete chain")?.into_inner();
|
||||
match format {
|
||||
DataFormat::Binary => {
|
||||
out.write(&b).map_err(|e| format!("Couldn't write to stream. Cause: {}", e))?;
|
||||
}
|
||||
DataFormat::Hex => {
|
||||
out.write_fmt(format_args!("{}", b.pretty())).map_err(|e| format!("Couldn't write to stream. Cause: {}", e))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
client.export_blocks(out, cmd.from_block, cmd.to_block, cmd.format)?;
|
||||
|
||||
info!("Export completed.");
|
||||
Ok(())
|
||||
@@ -659,7 +561,7 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
|
||||
|
||||
let client = service.client();
|
||||
|
||||
let mut out: Box<io::Write> = match cmd.file_path {
|
||||
let mut out: Box<dyn io::Write> = match cmd.file_path {
|
||||
Some(f) => Box::new(fs::File::create(&f).map_err(|_| format!("Cannot write to file given: {}", f))?),
|
||||
None => Box::new(io::stdout()),
|
||||
};
|
||||
|
||||
@@ -300,7 +300,7 @@ usage! {
|
||||
|
||||
ARG arg_chain: (String) = "foundation", or |c: &Config| c.parity.as_ref()?.chain.clone(),
|
||||
"--chain=[CHAIN]",
|
||||
"Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, poacore, xdai, volta, ewc, expanse, musicoin, ellaism, mix, callisto, morden, ropsten, kovan, rinkeby, goerli, kotti, poasokol, testnet, or dev.",
|
||||
"Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, poacore, xdai, volta, ewc, musicoin, ellaism, mix, callisto, morden, mordor, ropsten, kovan, rinkeby, goerli, kotti, poasokol, testnet, or dev.",
|
||||
|
||||
ARG arg_keys_path: (String) = "$BASE/keys", or |c: &Config| c.parity.as_ref()?.keys_path.clone(),
|
||||
"--keys-path=[PATH]",
|
||||
@@ -1556,14 +1556,14 @@ mod tests {
|
||||
// given
|
||||
let mut config = Config::default();
|
||||
let mut operating = Operating::default();
|
||||
operating.chain = Some("morden".into());
|
||||
operating.chain = Some("mordor".into());
|
||||
config.parity = Some(operating);
|
||||
|
||||
// when
|
||||
let args = Args::parse_with_config(&["parity"], config).unwrap();
|
||||
|
||||
// then
|
||||
assert_eq!(args.arg_chain, "morden".to_owned());
|
||||
assert_eq!(args.arg_chain, "mordor".to_owned());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1571,7 +1571,7 @@ mod tests {
|
||||
// given
|
||||
let mut config = Config::default();
|
||||
let mut operating = Operating::default();
|
||||
operating.chain = Some("morden".into());
|
||||
operating.chain = Some("mordor".into());
|
||||
config.parity = Some(operating);
|
||||
|
||||
// when
|
||||
|
||||
@@ -50,7 +50,8 @@ use ethcore_private_tx::{ProviderConfig, EncryptorConfig};
|
||||
use secretstore::{NodeSecretKey, Configuration as SecretStoreConfiguration, ContractAddress as SecretStoreContractAddress};
|
||||
use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack};
|
||||
use run::RunCmd;
|
||||
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, KillBlockchain, ExportState, DataFormat, ResetBlockchain};
|
||||
use types::data_format::DataFormat;
|
||||
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, KillBlockchain, ExportState, ResetBlockchain};
|
||||
use export_hardcoded_sync::ExportHsyncCmd;
|
||||
use presale::ImportWallet;
|
||||
use account::{AccountCmd, NewAccount, ListAccounts, ImportAccounts, ImportFromGethAccounts};
|
||||
@@ -59,6 +60,7 @@ use network::{IpFilter};
|
||||
|
||||
const DEFAULT_MAX_PEERS: u16 = 50;
|
||||
const DEFAULT_MIN_PEERS: u16 = 25;
|
||||
pub const ETHERSCAN_ETH_PRICE_ENDPOINT: &str = "https://api.etherscan.io/api?module=stats&action=ethprice";
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Cmd {
|
||||
@@ -668,23 +670,30 @@ impl Configuration {
|
||||
}
|
||||
|
||||
let usd_per_tx = to_price(&self.args.arg_usd_per_tx)?;
|
||||
if "auto" == self.args.arg_usd_per_eth.as_str() {
|
||||
return Ok(GasPricerConfig::Calibrated {
|
||||
|
||||
if "auto" == self.args.arg_usd_per_eth {
|
||||
Ok(GasPricerConfig::Calibrated {
|
||||
usd_per_tx: usd_per_tx,
|
||||
recalibration_period: to_duration(self.args.arg_price_update_period.as_str())?,
|
||||
});
|
||||
api_endpoint: ETHERSCAN_ETH_PRICE_ENDPOINT.to_string(),
|
||||
})
|
||||
} else if let Ok(usd_per_eth_parsed) = to_price(&self.args.arg_usd_per_eth) {
|
||||
let wei_per_gas = wei_per_gas(usd_per_tx, usd_per_eth_parsed);
|
||||
|
||||
info!(
|
||||
"Using a fixed conversion rate of Ξ1 = {} ({} wei/gas)",
|
||||
Colour::White.bold().paint(format!("US${:.2}", usd_per_eth_parsed)),
|
||||
Colour::Yellow.bold().paint(format!("{}", wei_per_gas))
|
||||
);
|
||||
|
||||
Ok(GasPricerConfig::Fixed(wei_per_gas))
|
||||
} else {
|
||||
Ok(GasPricerConfig::Calibrated {
|
||||
usd_per_tx: usd_per_tx,
|
||||
recalibration_period: to_duration(self.args.arg_price_update_period.as_str())?,
|
||||
api_endpoint: self.args.arg_usd_per_eth.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
let usd_per_eth = to_price(&self.args.arg_usd_per_eth)?;
|
||||
let wei_per_gas = wei_per_gas(usd_per_tx, usd_per_eth);
|
||||
|
||||
info!(
|
||||
"Using a fixed conversion rate of Ξ1 = {} ({} wei/gas)",
|
||||
Colour::White.bold().paint(format!("US${:.2}", usd_per_eth)),
|
||||
Colour::Yellow.bold().paint(format!("{}", wei_per_gas))
|
||||
);
|
||||
|
||||
Ok(GasPricerConfig::Fixed(wei_per_gas))
|
||||
}
|
||||
|
||||
fn extra_data(&self) -> Result<Bytes, String> {
|
||||
@@ -1195,14 +1204,15 @@ mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use tempdir::TempDir;
|
||||
use ethcore::client::{VMType, BlockId};
|
||||
use ethcore::client::VMType;
|
||||
use ethcore::miner::MinerOptions;
|
||||
use miner::pool::PrioritizationStrategy;
|
||||
use parity_rpc::NetworkSettings;
|
||||
use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack};
|
||||
|
||||
use types::ids::BlockId;
|
||||
use types::data_format::DataFormat;
|
||||
use account::{AccountCmd, NewAccount, ImportAccounts, ListAccounts};
|
||||
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, DataFormat, ExportState};
|
||||
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, ExportState};
|
||||
use cli::Args;
|
||||
use dir::{Directories, default_hypervisor_path};
|
||||
use helpers::{default_network_config};
|
||||
@@ -1564,7 +1574,7 @@ mod tests {
|
||||
// then
|
||||
assert_eq!(conf.network_settings(), Ok(NetworkSettings {
|
||||
name: "testname".to_owned(),
|
||||
chain: "kovan".to_owned(),
|
||||
chain: "goerli".to_owned(),
|
||||
is_dev_chain: false,
|
||||
network_port: 30303,
|
||||
rpc_enabled: true,
|
||||
|
||||
@@ -132,7 +132,7 @@ pub fn to_addresses(s: &Option<String>) -> Result<Vec<Address>, String> {
|
||||
|
||||
/// Tries to parse string as a price.
|
||||
pub fn to_price(s: &str) -> Result<f32, String> {
|
||||
s.parse::<f32>().map_err(|_| format!("Invalid transaciton price 's' given. Must be a decimal number."))
|
||||
s.parse::<f32>().map_err(|_| format!("Invalid transaction price {:?} given. Must be a decimal number.", s))
|
||||
}
|
||||
|
||||
pub fn join_set(set: Option<&HashSet<String>>) -> Option<String> {
|
||||
|
||||
@@ -285,6 +285,7 @@ fn main_direct(force_can_restart: bool) -> i32 {
|
||||
let e = exit.clone();
|
||||
let exiting = exiting.clone();
|
||||
move |panic_msg| {
|
||||
warn!("Panic occured, see stderr for details");
|
||||
eprintln!("{}", panic_msg);
|
||||
if !exiting.swap(true, Ordering::SeqCst) {
|
||||
*e.0.lock() = ExitStatus {
|
||||
|
||||
@@ -31,6 +31,8 @@ use miner::gas_price_calibrator::{GasPriceCalibratorOptions, GasPriceCalibrator}
|
||||
use parity_version::version_data;
|
||||
use user_defaults::UserDefaults;
|
||||
|
||||
use crate::configuration;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum SpecType {
|
||||
Foundation,
|
||||
@@ -45,6 +47,7 @@ pub enum SpecType {
|
||||
Mix,
|
||||
Callisto,
|
||||
Morden,
|
||||
Mordor,
|
||||
Ropsten,
|
||||
Kovan,
|
||||
Rinkeby,
|
||||
@@ -66,8 +69,8 @@ impl str::FromStr for SpecType {
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let spec = match s {
|
||||
"ethereum" | "frontier" | "homestead" | "byzantium" | "foundation" | "mainnet" => SpecType::Foundation,
|
||||
"classic" | "frontier-dogmatic" | "homestead-dogmatic" => SpecType::Classic,
|
||||
"eth" | "ethereum" | "foundation" | "mainnet" => SpecType::Foundation,
|
||||
"etc" | "classic" => SpecType::Classic,
|
||||
"poanet" | "poacore" => SpecType::Poanet,
|
||||
"xdai" => SpecType::Xdai,
|
||||
"volta" => SpecType::Volta,
|
||||
@@ -77,11 +80,12 @@ impl str::FromStr for SpecType {
|
||||
"ellaism" => SpecType::Ellaism,
|
||||
"mix" => SpecType::Mix,
|
||||
"callisto" => SpecType::Callisto,
|
||||
"morden" | "classic-testnet" => SpecType::Morden,
|
||||
"morden" => SpecType::Morden,
|
||||
"mordor" | "classic-testnet" => SpecType::Mordor,
|
||||
"ropsten" => SpecType::Ropsten,
|
||||
"kovan" | "testnet" => SpecType::Kovan,
|
||||
"kovan" => SpecType::Kovan,
|
||||
"rinkeby" => SpecType::Rinkeby,
|
||||
"goerli" | "görli" => SpecType::Goerli,
|
||||
"goerli" | "görli" | "testnet" => SpecType::Goerli,
|
||||
"kotti" => SpecType::Kotti,
|
||||
"sokol" | "poasokol" => SpecType::Sokol,
|
||||
"dev" => SpecType::Dev,
|
||||
@@ -106,6 +110,7 @@ impl fmt::Display for SpecType {
|
||||
SpecType::Mix => "mix",
|
||||
SpecType::Callisto => "callisto",
|
||||
SpecType::Morden => "morden",
|
||||
SpecType::Mordor => "mordor",
|
||||
SpecType::Ropsten => "ropsten",
|
||||
SpecType::Kovan => "kovan",
|
||||
SpecType::Rinkeby => "rinkeby",
|
||||
@@ -134,6 +139,7 @@ impl SpecType {
|
||||
SpecType::Mix => Ok(ethereum::new_mix(params)),
|
||||
SpecType::Callisto => Ok(ethereum::new_callisto(params)),
|
||||
SpecType::Morden => Ok(ethereum::new_morden(params)),
|
||||
SpecType::Mordor => Ok(ethereum::new_mordor(params)),
|
||||
SpecType::Ropsten => Ok(ethereum::new_ropsten(params)),
|
||||
SpecType::Kovan => Ok(ethereum::new_kovan(params)),
|
||||
SpecType::Rinkeby => Ok(ethereum::new_rinkeby(params)),
|
||||
@@ -257,6 +263,7 @@ pub enum GasPricerConfig {
|
||||
Calibrated {
|
||||
usd_per_tx: f32,
|
||||
recalibration_period: Duration,
|
||||
api_endpoint: String
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +272,7 @@ impl Default for GasPricerConfig {
|
||||
GasPricerConfig::Calibrated {
|
||||
usd_per_tx: 0.0001f32,
|
||||
recalibration_period: Duration::from_secs(3600),
|
||||
api_endpoint: configuration::ETHERSCAN_ETH_PRICE_ENDPOINT.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,7 +281,7 @@ impl GasPricerConfig {
|
||||
pub fn to_gas_pricer(&self, fetch: FetchClient, p: Executor) -> GasPricer {
|
||||
match *self {
|
||||
GasPricerConfig::Fixed(u) => GasPricer::Fixed(u),
|
||||
GasPricerConfig::Calibrated { usd_per_tx, recalibration_period, .. } => {
|
||||
GasPricerConfig::Calibrated { usd_per_tx, recalibration_period, ref api_endpoint } => {
|
||||
GasPricer::new_calibrated(
|
||||
GasPriceCalibrator::new(
|
||||
GasPriceCalibratorOptions {
|
||||
@@ -282,6 +290,7 @@ impl GasPricerConfig {
|
||||
},
|
||||
fetch,
|
||||
p,
|
||||
api_endpoint.clone(),
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -373,15 +382,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_spec_type_parsing() {
|
||||
assert_eq!(SpecType::Foundation, "foundation".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "frontier".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "homestead".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "byzantium".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "mainnet".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "eth".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "ethereum".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "foundation".parse().unwrap());
|
||||
assert_eq!(SpecType::Foundation, "mainnet".parse().unwrap());
|
||||
assert_eq!(SpecType::Classic, "etc".parse().unwrap());
|
||||
assert_eq!(SpecType::Classic, "classic".parse().unwrap());
|
||||
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());
|
||||
assert_eq!(SpecType::Xdai, "xdai".parse().unwrap());
|
||||
@@ -394,13 +400,14 @@ mod tests {
|
||||
assert_eq!(SpecType::Mix, "mix".parse().unwrap());
|
||||
assert_eq!(SpecType::Callisto, "callisto".parse().unwrap());
|
||||
assert_eq!(SpecType::Morden, "morden".parse().unwrap());
|
||||
assert_eq!(SpecType::Morden, "classic-testnet".parse().unwrap());
|
||||
assert_eq!(SpecType::Mordor, "mordor".parse().unwrap());
|
||||
assert_eq!(SpecType::Mordor, "classic-testnet".parse().unwrap());
|
||||
assert_eq!(SpecType::Ropsten, "ropsten".parse().unwrap());
|
||||
assert_eq!(SpecType::Kovan, "kovan".parse().unwrap());
|
||||
assert_eq!(SpecType::Kovan, "testnet".parse().unwrap());
|
||||
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::Goerli, "testnet".parse().unwrap());
|
||||
assert_eq!(SpecType::Kotti, "kotti".parse().unwrap());
|
||||
assert_eq!(SpecType::Sokol, "sokol".parse().unwrap());
|
||||
assert_eq!(SpecType::Sokol, "poasokol".parse().unwrap());
|
||||
@@ -425,6 +432,7 @@ mod tests {
|
||||
assert_eq!(format!("{}", SpecType::Mix), "mix");
|
||||
assert_eq!(format!("{}", SpecType::Callisto), "callisto");
|
||||
assert_eq!(format!("{}", SpecType::Morden), "morden");
|
||||
assert_eq!(format!("{}", SpecType::Mordor), "mordor");
|
||||
assert_eq!(format!("{}", SpecType::Ropsten), "ropsten");
|
||||
assert_eq!(format!("{}", SpecType::Kovan), "kovan");
|
||||
assert_eq!(format!("{}", SpecType::Rinkeby), "rinkeby");
|
||||
|
||||
@@ -29,7 +29,8 @@ use parity_rpc::{self as rpc, Metadata, DomainsValidation};
|
||||
use rpc_apis::{self, ApiSet};
|
||||
|
||||
pub use parity_rpc::{IpcServer, HttpServer, RequestMiddleware};
|
||||
pub use parity_rpc::ws::Server as WsServer;
|
||||
//pub use parity_rpc::ws::Server as WsServer;
|
||||
pub use parity_rpc::ws::{Server as WsServer, ws};
|
||||
|
||||
pub const DAPPS_DOMAIN: &'static str = "web3.site";
|
||||
|
||||
@@ -185,9 +186,18 @@ pub fn new_ws<D: rpc_apis::Dependencies>(
|
||||
rpc::WsStats::new(deps.stats.clone()),
|
||||
);
|
||||
|
||||
// match start_result {
|
||||
// Ok(server) => Ok(Some(server)),
|
||||
// Err(rpc::ws::Error::Io(rpc::ws::ErrorKind::Io(ref err), _)) if err.kind() == io::ErrorKind::AddrInUse => Err(
|
||||
// format!("WebSockets address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --ws-port and --ws-interface options.", url)
|
||||
// ),
|
||||
// Err(e) => Err(format!("WebSockets error: {:?}", e)),
|
||||
// }
|
||||
match start_result {
|
||||
Ok(server) => Ok(Some(server)),
|
||||
Err(rpc::ws::Error(rpc::ws::ErrorKind::Io(ref err), _)) if err.kind() == io::ErrorKind::AddrInUse => Err(
|
||||
Err(rpc::ws::Error::WsError(ws::Error {
|
||||
kind: ws::ErrorKind::Io(ref err), ..
|
||||
})) if err.kind() == io::ErrorKind::AddrInUse => Err(
|
||||
format!("WebSockets address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --ws-port and --ws-interface options.", url)
|
||||
),
|
||||
Err(e) => Err(format!("WebSockets error: {:?}", e)),
|
||||
|
||||
Reference in New Issue
Block a user