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

Commit d2a8df0

Browse files
committed
Merge branch 'master' into dp/chore/update-devp2p-to-edition-2018
* master: 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) Stop breaking out of loop if a non-canonical hash is found (#10729) Refactor Clique stepping (#10691) Use RUSTFLAGS to set the optimization level (#10719) SecretStore: non-blocking wait of session completion (#10303) removed secret_store folder (#10722) SecretStore: expose restore_key_public in HTTP API (#10241) Revert "enable lto for release builds (#10717)" (#10721) enable lto for release builds (#10717) Merge `Notifier` and `TransactionsPoolNotifier` (#10591)
2 parents 3c895da + be5db14 commit d2a8df0

File tree

125 files changed

+2367
-2771
lines changed

Some content is hidden

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

125 files changed

+2367
-2771
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: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ path = "parity/lib.rs"
117117
path = "parity/main.rs"
118118
name = "parity"
119119

120-
[profile.dev]
121-
122120
[profile.release]
123121
debug = false
122+
lto = true
124123

125124
[workspace]
126125
# This should only list projects that are not

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: 30 additions & 16 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

@@ -963,6 +963,7 @@ impl BlockChain {
963963
/// Iterate over all epoch transitions.
964964
/// This will only return transitions within the canonical chain.
965965
pub fn epoch_transitions(&self) -> EpochTransitionIter {
966+
trace!(target: "blockchain", "Iterating over all epoch transitions");
966967
let iter = self.db.key_value().iter_from_prefix(db::COL_EXTRA, &EPOCH_KEY_PREFIX[..]);
967968
EpochTransitionIter {
968969
chain: self,
@@ -988,7 +989,9 @@ impl BlockChain {
988989
pub fn epoch_transition_for(&self, parent_hash: H256) -> Option<EpochTransition> {
989990
// slow path: loop back block by block
990991
for hash in self.ancestry_iter(parent_hash)? {
992+
trace!(target: "blockchain", "Got parent hash {} from ancestry_iter", hash);
991993
let details = self.block_details(&hash)?;
994+
trace!(target: "blockchain", "Block #{}: Got block details", details.number);
992995

993996
// look for transition in database.
994997
if let Some(transition) = self.epoch_transition(details.number, hash) {
@@ -1000,11 +1003,22 @@ impl BlockChain {
10001003
//
10011004
// if `block_hash` is canonical it will only return transitions up to
10021005
// the parent.
1003-
if self.block_hash(details.number)? == hash {
1004-
return self.epoch_transitions()
1005-
.map(|(_, t)| t)
1006-
.take_while(|t| t.block_number <= details.number)
1007-
.last()
1006+
match self.block_hash(details.number) {
1007+
Some(h) if h == hash => {
1008+
return self.epoch_transitions()
1009+
.map(|(_, t)| t)
1010+
.take_while(|t| t.block_number <= details.number)
1011+
.last()
1012+
},
1013+
Some(h) => {
1014+
warn!(target: "blockchain", "Block #{}: Found non-canonical block hash {} (expected {})", details.number, h, hash);
1015+
1016+
trace!(target: "blockchain", "Block #{} Mismatched hashes. Ancestor {} != Own {} – Own block #{}", details.number, hash, h, self.block_number(&h).unwrap_or_default() );
1017+
trace!(target: "blockchain", " Ancestor {}: #{:#?}", hash, self.block_details(&hash));
1018+
trace!(target: "blockchain", " Own {}: #{:#?}", h, self.block_details(&h));
1019+
1020+
},
1021+
None => trace!(target: "blockchain", "Block #{}: hash {} not found in cache or DB", details.number, hash),
10081022
}
10091023
}
10101024

@@ -1578,11 +1592,11 @@ mod tests {
15781592
_trace_blooms_dir: TempDir,
15791593
blooms: blooms_db::Database,
15801594
trace_blooms: blooms_db::Database,
1581-
key_value: Arc<KeyValueDB>,
1595+
key_value: Arc<dyn KeyValueDB>,
15821596
}
15831597

15841598
impl BlockChainDB for TestBlockChainDB {
1585-
fn key_value(&self) -> &Arc<KeyValueDB> {
1599+
fn key_value(&self) -> &Arc<dyn KeyValueDB> {
15861600
&self.key_value
15871601
}
15881602

@@ -1596,7 +1610,7 @@ mod tests {
15961610
}
15971611

15981612
/// Creates new test instance of `BlockChainDB`
1599-
pub fn new_db() -> Arc<BlockChainDB> {
1613+
pub fn new_db() -> Arc<dyn BlockChainDB> {
16001614
let blooms_dir = TempDir::new("").unwrap();
16011615
let trace_blooms_dir = TempDir::new("").unwrap();
16021616

@@ -1611,15 +1625,15 @@ mod tests {
16111625
Arc::new(db)
16121626
}
16131627

1614-
fn new_chain(genesis: encoded::Block, db: Arc<BlockChainDB>) -> BlockChain {
1628+
fn new_chain(genesis: encoded::Block, db: Arc<dyn BlockChainDB>) -> BlockChain {
16151629
BlockChain::new(Config::default(), genesis.raw(), db)
16161630
}
16171631

1618-
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 {
16191633
insert_block_commit(db, bc, block, receipts, true)
16201634
}
16211635

1622-
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 {
16231637
let mut batch = db.key_value().transaction();
16241638
let res = insert_block_batch(&mut batch, bc, block, receipts);
16251639
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
}

0 commit comments

Comments
 (0)