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

Commit 5dff9e1

Browse files
committed
Merge branch 'master' into dp/chore/aura-warn-when-validators-is-1-or-even
* master: [devp2p] Update to 2018 edition (#10716) Add a way to signal shutdown to snapshotting threads (#10744) Enable aesni (#10756) remove support of old SS db formats (#10757) [devp2p] Don't use `rust-crypto` (#10714) updater: fix static id hashes initialization (#10755) Use fewer threads for snapshotting (#10752) Die error_chain, die (#10747) Fix deprectation warnings on nightly (#10746) fix docker tags for publishing (#10741) DevP2p: Get node IP address and udp port from Socket, if not included in PING packet (#10705) ethcore: enable ECIP-1054 for classic (#10731)
2 parents 353e6b9 + 859a413 commit 5dff9e1

File tree

105 files changed

+1198
-1142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1198
-1142
lines changed

.cargo/config

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# NOTE: if you make changes here, remember to also update:
2+
# scripts/test-linux.sh
3+
# scripts/build-linux.sh
4+
# scripts/build-windows.sh
5+
6+
# Using 'cfg` is broken, see https://github.com/rust-lang/cargo/issues/6858
7+
#[target.'cfg(target_arch = "x86_64")']
8+
#rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"]
9+
10+
# …so instead we list all target triples (Tier 1 64-bit platforms)
11+
[target.x86_64-unknown-linux-gnu]
12+
# Enables the aes-ni instructions for RustCrypto dependency.
13+
rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"]
14+
15+
[target.x86_64-pc-windows-gnu]
16+
# Enables the aes-ni instructions for RustCrypto dependency.
17+
rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"]
18+
119
[target.x86_64-pc-windows-msvc]
20+
# Enables the aes-ni instructions for RustCrypto dependency.
221
# Link the C runtime statically ; https://github.com/paritytech/parity-ethereum/issues/6643
3-
rustflags = ["-Ctarget-feature=+crt-static"]
22+
rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3", "-Ctarget-feature=+crt-static"]
23+
24+
[target.x86_64-apple-darwin]
25+
# Enables the aes-ni instructions for RustCrypto dependency.
26+
rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"]
27+

Cargo.lock

Lines changed: 6 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ethcore/benches/builtin.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use criterion::{Criterion, Bencher};
2929
use bytes::BytesRef;
3030
use ethcore::builtin::Builtin;
3131
use ethcore::machine::EthereumMachine;
32-
use ethereum_types::U256;
32+
use ethereum_types::H160;
3333
use ethcore::ethereum::new_byzantium_test_machine;
3434
use rustc_hex::FromHex;
3535

@@ -46,8 +46,9 @@ struct BuiltinBenchmark<'a> {
4646
impl<'a> BuiltinBenchmark<'a> {
4747
fn new(builtin_address: &'static str, input: &str, expected: &str) -> BuiltinBenchmark<'a> {
4848
let builtins = BYZANTIUM_MACHINE.builtins();
49-
50-
let builtin = builtins.get(&builtin_address.into()).unwrap().clone();
49+
use std::str::FromStr;
50+
let addr = H160::from_str(builtin_address).unwrap();
51+
let builtin = builtins.get(&addr).unwrap().clone();
5152
let input = FromHex::from_hex(input).unwrap();
5253
let expected = FromHex::from_hex(expected).unwrap();
5354

@@ -56,10 +57,6 @@ impl<'a> BuiltinBenchmark<'a> {
5657
}
5758
}
5859

59-
fn gas_cost(&self) -> U256 {
60-
self.builtin.cost(&self.input)
61-
}
62-
6360
fn run(&self, b: &mut Bencher) {
6461
let mut output = vec![0; self.expected.len()];
6562

ethcore/blockchain/src/blockchain.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use crate::{CacheSize, ImportRoute, Config};
5757
/// Database backing `BlockChain`.
5858
pub trait BlockChainDB: Send + Sync {
5959
/// Generic key value store.
60-
fn key_value(&self) -> &Arc<KeyValueDB>;
60+
fn key_value(&self) -> &Arc<dyn KeyValueDB>;
6161

6262
/// Header blooms database.
6363
fn blooms(&self) -> &blooms_db::Database;
@@ -85,7 +85,7 @@ pub trait BlockChainDB: Send + Sync {
8585
/// predefined config.
8686
pub trait BlockChainDBHandler: Send + Sync {
8787
/// Open the predefined key-value database.
88-
fn open(&self, path: &Path) -> io::Result<Arc<BlockChainDB>>;
88+
fn open(&self, path: &Path) -> io::Result<Arc<dyn BlockChainDB>>;
8989
}
9090

9191
/// Interface for querying blocks by hash and by number.
@@ -228,7 +228,7 @@ pub struct BlockChain {
228228
transaction_addresses: RwLock<HashMap<H256, TransactionAddress>>,
229229
block_receipts: RwLock<HashMap<H256, BlockReceipts>>,
230230

231-
db: Arc<BlockChainDB>,
231+
db: Arc<dyn BlockChainDB>,
232232

233233
cache_man: Mutex<CacheManager<CacheId>>,
234234

@@ -481,7 +481,7 @@ impl<'a> Iterator for AncestryWithMetadataIter<'a> {
481481
/// Returns epoch transitions.
482482
pub struct EpochTransitionIter<'a> {
483483
chain: &'a BlockChain,
484-
prefix_iter: Box<Iterator<Item=(Box<[u8]>, Box<[u8]>)> + 'a>,
484+
prefix_iter: Box<dyn Iterator<Item=(Box<[u8]>, Box<[u8]>)> + 'a>,
485485
}
486486

487487
impl<'a> Iterator for EpochTransitionIter<'a> {
@@ -521,7 +521,7 @@ impl<'a> Iterator for EpochTransitionIter<'a> {
521521

522522
impl BlockChain {
523523
/// Create new instance of blockchain from given Genesis.
524-
pub fn new(config: Config, genesis: &[u8], db: Arc<BlockChainDB>) -> BlockChain {
524+
pub fn new(config: Config, genesis: &[u8], db: Arc<dyn BlockChainDB>) -> BlockChain {
525525
// 400 is the average size of the key
526526
let cache_man = CacheManager::new(config.pref_cache_size, config.max_cache_size, 400);
527527

@@ -1592,11 +1592,11 @@ mod tests {
15921592
_trace_blooms_dir: TempDir,
15931593
blooms: blooms_db::Database,
15941594
trace_blooms: blooms_db::Database,
1595-
key_value: Arc<KeyValueDB>,
1595+
key_value: Arc<dyn KeyValueDB>,
15961596
}
15971597

15981598
impl BlockChainDB for TestBlockChainDB {
1599-
fn key_value(&self) -> &Arc<KeyValueDB> {
1599+
fn key_value(&self) -> &Arc<dyn KeyValueDB> {
16001600
&self.key_value
16011601
}
16021602

@@ -1610,7 +1610,7 @@ mod tests {
16101610
}
16111611

16121612
/// Creates new test instance of `BlockChainDB`
1613-
pub fn new_db() -> Arc<BlockChainDB> {
1613+
pub fn new_db() -> Arc<dyn BlockChainDB> {
16141614
let blooms_dir = TempDir::new("").unwrap();
16151615
let trace_blooms_dir = TempDir::new("").unwrap();
16161616

@@ -1625,15 +1625,15 @@ mod tests {
16251625
Arc::new(db)
16261626
}
16271627

1628-
fn new_chain(genesis: encoded::Block, db: Arc<BlockChainDB>) -> BlockChain {
1628+
fn new_chain(genesis: encoded::Block, db: Arc<dyn BlockChainDB>) -> BlockChain {
16291629
BlockChain::new(Config::default(), genesis.raw(), db)
16301630
}
16311631

1632-
fn insert_block(db: &Arc<BlockChainDB>, bc: &BlockChain, block: encoded::Block, receipts: Vec<Receipt>) -> ImportRoute {
1632+
fn insert_block(db: &Arc<dyn BlockChainDB>, bc: &BlockChain, block: encoded::Block, receipts: Vec<Receipt>) -> ImportRoute {
16331633
insert_block_commit(db, bc, block, receipts, true)
16341634
}
16351635

1636-
fn insert_block_commit(db: &Arc<BlockChainDB>, bc: &BlockChain, block: encoded::Block, receipts: Vec<Receipt>, commit: bool) -> ImportRoute {
1636+
fn insert_block_commit(db: &Arc<dyn BlockChainDB>, bc: &BlockChain, block: encoded::Block, receipts: Vec<Receipt>, commit: bool) -> ImportRoute {
16371637
let mut batch = db.key_value().transaction();
16381638
let res = insert_block_batch(&mut batch, bc, block, receipts);
16391639
db.key_value().write(batch).unwrap();

ethcore/light/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
1010
log = "0.4"
1111
parity-bytes = "0.1"
1212
common-types = { path = "../types" }
13+
derive_more = "0.14.0"
1314
ethcore = { path = ".."}
1415
ethcore-db = { path = "../db" }
1516
ethcore-blockchain = { path = "../blockchain" }

ethcore/light/src/client/header_chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl HeaderChain {
260260
let best_block = {
261261
let era = match candidates.get(&curr.best_num) {
262262
Some(era) => era,
263-
None => bail!("Database corrupt: highest block referenced but no data."),
263+
None => return Err("Database corrupt: highest block referenced but no data.".into()),
264264
};
265265

266266
let best = &era.candidates[0];
@@ -582,7 +582,7 @@ impl HeaderChain {
582582
} else {
583583
let msg = format!("header of block #{} not found in DB ; database in an \
584584
inconsistent state", h_num);
585-
bail!(msg);
585+
return Err(msg.into());
586586
};
587587

588588
let decoded = header.decode().expect("decoding db value failed");

ethcore/light/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ extern crate keccak_hash as hash;
8686
extern crate triehash_ethereum as triehash;
8787
extern crate kvdb;
8888
extern crate memory_cache;
89-
#[macro_use]
90-
extern crate error_chain;
89+
extern crate derive_more;
9190

9291
#[cfg(test)]
9392
extern crate kvdb_memorydb;

ethcore/light/src/on_demand/mod.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,31 @@ pub const DEFAULT_NUM_CONSECUTIVE_FAILED_REQUESTS: usize = 1;
6666

6767
/// OnDemand related errors
6868
pub mod error {
69-
// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting`
70-
// https://github.com/paritytech/parity-ethereum/issues/10302
71-
#![allow(deprecated)]
72-
7369
use futures::sync::oneshot::Canceled;
7470

75-
error_chain! {
76-
77-
foreign_links {
78-
ChannelCanceled(Canceled) #[doc = "Canceled oneshot channel"];
79-
}
80-
81-
errors {
82-
#[doc = "Timeout bad response"]
83-
BadResponse(err: String) {
84-
description("Max response evaluation time exceeded")
85-
display("{}", err)
86-
}
71+
/// OnDemand Error
72+
#[derive(Debug, derive_more::Display, derive_more::From)]
73+
pub enum Error {
74+
/// Canceled oneshot channel
75+
ChannelCanceled(Canceled),
76+
/// Timeout bad response
77+
BadResponse(String),
78+
/// OnDemand requests limit exceeded
79+
#[display(fmt = "OnDemand request maximum backoff iterations exceeded")]
80+
RequestLimit,
81+
}
8782

88-
#[doc = "OnDemand requests limit exceeded"]
89-
RequestLimit {
90-
description("OnDemand request maximum backoff iterations exceeded")
91-
display("OnDemand request maximum backoff iterations exceeded")
83+
impl std::error::Error for Error {
84+
fn source(&self) -> Option<&(std::error::Error + 'static)> {
85+
match self {
86+
Error::ChannelCanceled(err) => Some(err),
87+
_ => None,
9288
}
9389
}
9490
}
91+
92+
/// OnDemand Result
93+
pub type Result<T> = std::result::Result<T, Error>;
9594
}
9695

9796
/// Public interface for performing network requests `OnDemand`
@@ -272,15 +271,15 @@ impl Pending {
272271
response_err
273272
);
274273

275-
let err = self::error::ErrorKind::BadResponse(err);
274+
let err = self::error::Error::BadResponse(err);
276275
if self.sender.send(Err(err.into())).is_err() {
277276
debug!(target: "on_demand", "Dropped oneshot channel receiver on no response");
278277
}
279278
}
280279

281280
// returning a peer discovery timeout during query attempts
282281
fn request_limit_reached(self) {
283-
let err = self::error::ErrorKind::RequestLimit;
282+
let err = self::error::Error::RequestLimit;
284283
if self.sender.send(Err(err.into())).is_err() {
285284
debug!(target: "on_demand", "Dropped oneshot channel receiver on time out");
286285
}

ethcore/private-tx/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
//! Private transactions module.
1818
19-
// Recursion limit required because of
20-
// error_chain foreign_links.
21-
#![recursion_limit="256"]
22-
2319
mod encryptor;
2420
mod key_server_keys;
2521
mod private_transactions;

0 commit comments

Comments
 (0)