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

Commit

Permalink
Merge branch 'master' into dp/fix/abort-snapshots-hangs-shutdown
Browse files Browse the repository at this point in the history
* master:
  Fix deprectation warnings on nightly (#10746)
  fix docker tags for publishing (#10741)
  • Loading branch information
dvdplm committed Jun 17, 2019
2 parents b83ab98 + dbdb57a commit 902ab9f
Show file tree
Hide file tree
Showing 55 changed files with 306 additions and 295 deletions.
11 changes: 4 additions & 7 deletions ethcore/benches/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use criterion::{Criterion, Bencher};
use bytes::BytesRef;
use ethcore::builtin::Builtin;
use ethcore::machine::EthereumMachine;
use ethereum_types::U256;
use ethereum_types::H160;
use ethcore::ethereum::new_byzantium_test_machine;
use rustc_hex::FromHex;

Expand All @@ -46,8 +46,9 @@ struct BuiltinBenchmark<'a> {
impl<'a> BuiltinBenchmark<'a> {
fn new(builtin_address: &'static str, input: &str, expected: &str) -> BuiltinBenchmark<'a> {
let builtins = BYZANTIUM_MACHINE.builtins();

let builtin = builtins.get(&builtin_address.into()).unwrap().clone();
use std::str::FromStr;
let addr = H160::from_str(builtin_address).unwrap();
let builtin = builtins.get(&addr).unwrap().clone();
let input = FromHex::from_hex(input).unwrap();
let expected = FromHex::from_hex(expected).unwrap();

Expand All @@ -56,10 +57,6 @@ impl<'a> BuiltinBenchmark<'a> {
}
}

fn gas_cost(&self) -> U256 {
self.builtin.cost(&self.input)
}

fn run(&self, b: &mut Bencher) {
let mut output = vec![0; self.expected.len()];

Expand Down
22 changes: 11 additions & 11 deletions ethcore/blockchain/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use crate::{CacheSize, ImportRoute, Config};
/// Database backing `BlockChain`.
pub trait BlockChainDB: Send + Sync {
/// Generic key value store.
fn key_value(&self) -> &Arc<KeyValueDB>;
fn key_value(&self) -> &Arc<dyn KeyValueDB>;

/// Header blooms database.
fn blooms(&self) -> &blooms_db::Database;
Expand Down Expand Up @@ -85,7 +85,7 @@ pub trait BlockChainDB: Send + Sync {
/// predefined config.
pub trait BlockChainDBHandler: Send + Sync {
/// Open the predefined key-value database.
fn open(&self, path: &Path) -> io::Result<Arc<BlockChainDB>>;
fn open(&self, path: &Path) -> io::Result<Arc<dyn BlockChainDB>>;
}

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

db: Arc<BlockChainDB>,
db: Arc<dyn BlockChainDB>,

cache_man: Mutex<CacheManager<CacheId>>,

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

impl<'a> Iterator for EpochTransitionIter<'a> {
Expand Down Expand Up @@ -521,7 +521,7 @@ impl<'a> Iterator for EpochTransitionIter<'a> {

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

Expand Down Expand Up @@ -1592,11 +1592,11 @@ mod tests {
_trace_blooms_dir: TempDir,
blooms: blooms_db::Database,
trace_blooms: blooms_db::Database,
key_value: Arc<KeyValueDB>,
key_value: Arc<dyn KeyValueDB>,
}

impl BlockChainDB for TestBlockChainDB {
fn key_value(&self) -> &Arc<KeyValueDB> {
fn key_value(&self) -> &Arc<dyn KeyValueDB> {
&self.key_value
}

Expand All @@ -1610,7 +1610,7 @@ mod tests {
}

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

Expand All @@ -1625,15 +1625,15 @@ mod tests {
Arc::new(db)
}

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

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

fn insert_block_commit(db: &Arc<BlockChainDB>, bc: &BlockChain, block: encoded::Block, receipts: Vec<Receipt>, commit: bool) -> ImportRoute {
fn insert_block_commit(db: &Arc<dyn BlockChainDB>, bc: &BlockChain, block: encoded::Block, receipts: Vec<Receipt>, commit: bool) -> ImportRoute {
let mut batch = db.key_value().transaction();
let res = insert_block_batch(&mut batch, bc, block, receipts);
db.key_value().write(batch).unwrap();
Expand Down
36 changes: 18 additions & 18 deletions ethcore/src/account_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ impl Default for Factory {
impl Factory {
/// Create a read-only accountdb.
/// This will panic when write operations are called.
pub fn readonly<'db>(&self, db: &'db HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Box<HashDB<KeccakHasher, DBValue> + 'db> {
pub fn readonly<'db>(&self, db: &'db dyn HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Box<dyn HashDB<KeccakHasher, DBValue> + 'db> {
match *self {
Factory::Mangled => Box::new(AccountDB::from_hash(db, address_hash)),
Factory::Plain => Box::new(Wrapping(db)),
}
}

/// Create a new mutable hashdb.
pub fn create<'db>(&self, db: &'db mut HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Box<HashDB<KeccakHasher, DBValue> + 'db> {
pub fn create<'db>(&self, db: &'db mut dyn HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Box<dyn HashDB<KeccakHasher, DBValue> + 'db> {
match *self {
Factory::Mangled => Box::new(AccountDBMut::from_hash(db, address_hash)),
Factory::Plain => Box::new(WrappingMut(db)),
Expand All @@ -77,19 +77,19 @@ impl Factory {
/// DB backend wrapper for Account trie
/// Transforms trie node keys for the database
pub struct AccountDB<'db> {
db: &'db HashDB<KeccakHasher, DBValue>,
db: &'db dyn HashDB<KeccakHasher, DBValue>,
address_hash: H256,
}

impl<'db> AccountDB<'db> {
/// Create a new AccountDB from an address.
#[cfg(test)]
pub fn new(db: &'db HashDB<KeccakHasher, DBValue>, address: &Address) -> Self {
pub fn new(db: &'db dyn HashDB<KeccakHasher, DBValue>, address: &Address) -> Self {
Self::from_hash(db, keccak(address))
}

/// Create a new AcountDB from an address' hash.
pub fn from_hash(db: &'db HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Self {
pub fn from_hash(db: &'db dyn HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Self {
AccountDB {
db: db,
address_hash: address_hash,
Expand All @@ -98,8 +98,8 @@ impl<'db> AccountDB<'db> {
}

impl<'db> AsHashDB<KeccakHasher, DBValue> for AccountDB<'db> {
fn as_hash_db(&self) -> &HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> { self }
}

impl<'db> HashDB<KeccakHasher, DBValue> for AccountDB<'db> {
Expand Down Expand Up @@ -132,19 +132,19 @@ impl<'db> HashDB<KeccakHasher, DBValue> for AccountDB<'db> {

/// DB backend wrapper for Account trie
pub struct AccountDBMut<'db> {
db: &'db mut HashDB<KeccakHasher, DBValue>,
db: &'db mut dyn HashDB<KeccakHasher, DBValue>,
address_hash: H256,
}

impl<'db> AccountDBMut<'db> {
/// Create a new AccountDB from an address.
#[cfg(test)]
pub fn new(db: &'db mut HashDB<KeccakHasher, DBValue>, address: &Address) -> Self {
pub fn new(db: &'db mut dyn HashDB<KeccakHasher, DBValue>, address: &Address) -> Self {
Self::from_hash(db, keccak(address))
}

/// Create a new AcountDB from an address' hash.
pub fn from_hash(db: &'db mut HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Self {
pub fn from_hash(db: &'db mut dyn HashDB<KeccakHasher, DBValue>, address_hash: H256) -> Self {
AccountDBMut {
db: db,
address_hash: address_hash,
Expand Down Expand Up @@ -200,15 +200,15 @@ impl<'db> HashDB<KeccakHasher, DBValue> for AccountDBMut<'db>{
}

impl<'db> AsHashDB<KeccakHasher, DBValue> for AccountDBMut<'db> {
fn as_hash_db(&self) -> &HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> { self }
}

struct Wrapping<'db>(&'db HashDB<KeccakHasher, DBValue>);
struct Wrapping<'db>(&'db dyn HashDB<KeccakHasher, DBValue>);

impl<'db> AsHashDB<KeccakHasher, DBValue> for Wrapping<'db> {
fn as_hash_db(&self) -> &HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> { self }
}

impl<'db> HashDB<KeccakHasher, DBValue> for Wrapping<'db> {
Expand Down Expand Up @@ -239,10 +239,10 @@ impl<'db> HashDB<KeccakHasher, DBValue> for Wrapping<'db> {
}
}

struct WrappingMut<'db>(&'db mut HashDB<KeccakHasher, DBValue>);
struct WrappingMut<'db>(&'db mut dyn HashDB<KeccakHasher, DBValue>);
impl<'db> AsHashDB<KeccakHasher, DBValue> for WrappingMut<'db> {
fn as_hash_db(&self) -> &HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> { self }
}

impl<'db> HashDB<KeccakHasher, DBValue> for WrappingMut<'db>{
Expand Down
22 changes: 11 additions & 11 deletions ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use types::receipt::{Receipt, TransactionOutcome};
/// maintain the system `state()`. We also archive execution receipts in preparation for later block creation.
pub struct OpenBlock<'x> {
block: ExecutedBlock,
engine: &'x EthEngine,
engine: &'x dyn EthEngine,
}

/// Just like `OpenBlock`, except that we've applied `Engine::on_close_block`, finished up the non-seal header fields,
Expand Down Expand Up @@ -163,7 +163,7 @@ pub trait Drain {
impl<'x> OpenBlock<'x> {
/// Create a new `OpenBlock` ready for transaction pushing.
pub fn new<'a, I: IntoIterator<Item = ExtendedHeader>>(
engine: &'x EthEngine,
engine: &'x dyn EthEngine,
factories: Factories,
tracing: bool,
db: StateDB,
Expand Down Expand Up @@ -374,7 +374,7 @@ impl ClosedBlock {
}

/// Given an engine reference, reopen the `ClosedBlock` into an `OpenBlock`.
pub fn reopen(self, engine: &EthEngine) -> OpenBlock {
pub fn reopen(self, engine: &dyn EthEngine) -> OpenBlock {
// revert rewards (i.e. set state back at last transaction's state).
let mut block = self.block;
block.state = self.unclosed_state;
Expand Down Expand Up @@ -404,7 +404,7 @@ impl LockedBlock {
/// Provide a valid seal in order to turn this into a `SealedBlock`.
///
/// NOTE: This does not check the validity of `seal` with the engine.
pub fn seal(self, engine: &EthEngine, seal: Vec<Bytes>) -> Result<SealedBlock, Error> {
pub fn seal(self, engine: &dyn EthEngine, seal: Vec<Bytes>) -> Result<SealedBlock, Error> {
let expected_seal_fields = engine.seal_fields(&self.header);
let mut s = self;
if seal.len() != expected_seal_fields {
Expand All @@ -429,7 +429,7 @@ impl LockedBlock {
/// TODO(https://github.com/paritytech/parity-ethereum/issues/10407): This is currently only used in POW chain call paths, we should really merge it with seal() above.
pub fn try_seal(
self,
engine: &EthEngine,
engine: &dyn EthEngine,
seal: Vec<Bytes>,
) -> Result<SealedBlock, Error> {
let mut s = self;
Expand Down Expand Up @@ -472,14 +472,14 @@ pub(crate) fn enact(
header: Header,
transactions: Vec<SignedTransaction>,
uncles: Vec<Header>,
engine: &EthEngine,
engine: &dyn EthEngine,
tracing: bool,
db: StateDB,
parent: &Header,
last_hashes: Arc<LastHashes>,
factories: Factories,
is_epoch_begin: bool,
ancestry: &mut Iterator<Item=ExtendedHeader>,
ancestry: &mut dyn Iterator<Item=ExtendedHeader>,
) -> Result<LockedBlock, Error> {
// For trace log
let trace_state = if log_enabled!(target: "enact", ::log::Level::Trace) {
Expand Down Expand Up @@ -525,14 +525,14 @@ pub(crate) fn enact(
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
pub fn enact_verified(
block: PreverifiedBlock,
engine: &EthEngine,
engine: &dyn EthEngine,
tracing: bool,
db: StateDB,
parent: &Header,
last_hashes: Arc<LastHashes>,
factories: Factories,
is_epoch_begin: bool,
ancestry: &mut Iterator<Item=ExtendedHeader>,
ancestry: &mut dyn Iterator<Item=ExtendedHeader>,
) -> Result<LockedBlock, Error> {

enact(
Expand Down Expand Up @@ -570,7 +570,7 @@ mod tests {
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
fn enact_bytes(
block_bytes: Vec<u8>,
engine: &EthEngine,
engine: &dyn EthEngine,
tracing: bool,
db: StateDB,
parent: &Header,
Expand Down Expand Up @@ -623,7 +623,7 @@ mod tests {
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards
fn enact_and_seal(
block_bytes: Vec<u8>,
engine: &EthEngine,
engine: &dyn EthEngine,
tracing: bool,
db: StateDB,
parent: &Header,
Expand Down
28 changes: 14 additions & 14 deletions ethcore/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ impl ModexpPricer {
///
/// Unless `is_active` is true,
pub struct Builtin {
pricer: Box<Pricer>,
native: Box<Impl>,
pricer: Box<dyn Pricer>,
native: Box<dyn Impl>,
activate_at: u64,
}

Expand All @@ -177,7 +177,7 @@ impl Builtin {

impl From<ethjson::spec::Builtin> for Builtin {
fn from(b: ethjson::spec::Builtin) -> Self {
let pricer: Box<Pricer> = match b.pricing {
let pricer: Box<dyn Pricer> = match b.pricing {
ethjson::spec::Pricing::Linear(linear) => {
Box::new(Linear {
base: linear.base,
Expand Down Expand Up @@ -211,16 +211,16 @@ impl From<ethjson::spec::Builtin> for Builtin {
}

/// Ethereum built-in factory.
pub fn ethereum_builtin(name: &str) -> Box<Impl> {
pub fn ethereum_builtin(name: &str) -> Box<dyn Impl> {
match name {
"identity" => Box::new(Identity) as Box<Impl>,
"ecrecover" => Box::new(EcRecover) as Box<Impl>,
"sha256" => Box::new(Sha256) as Box<Impl>,
"ripemd160" => Box::new(Ripemd160) as Box<Impl>,
"modexp" => Box::new(ModexpImpl) as Box<Impl>,
"alt_bn128_add" => Box::new(Bn128AddImpl) as Box<Impl>,
"alt_bn128_mul" => Box::new(Bn128MulImpl) as Box<Impl>,
"alt_bn128_pairing" => Box::new(Bn128PairingImpl) as Box<Impl>,
"identity" => Box::new(Identity) as Box<dyn Impl>,
"ecrecover" => Box::new(EcRecover) as Box<dyn Impl>,
"sha256" => Box::new(Sha256) as Box<dyn Impl>,
"ripemd160" => Box::new(Ripemd160) as Box<dyn Impl>,
"modexp" => Box::new(ModexpImpl) as Box<dyn Impl>,
"alt_bn128_add" => Box::new(Bn128AddImpl) as Box<dyn Impl>,
"alt_bn128_mul" => Box::new(Bn128MulImpl) as Box<dyn Impl>,
"alt_bn128_pairing" => Box::new(Bn128PairingImpl) as Box<dyn Impl>,
_ => panic!("invalid builtin name: {}", name),
}
}
Expand Down Expand Up @@ -1008,7 +1008,7 @@ mod tests {
fn is_active() {
let pricer = Box::new(Linear { base: 10, word: 20} );
let b = Builtin {
pricer: pricer as Box<Pricer>,
pricer: pricer as Box<dyn Pricer>,
native: ethereum_builtin("identity"),
activate_at: 100_000,
};
Expand All @@ -1022,7 +1022,7 @@ mod tests {
fn from_named_linear() {
let pricer = Box::new(Linear { base: 10, word: 20 });
let b = Builtin {
pricer: pricer as Box<Pricer>,
pricer: pricer as Box<dyn Pricer>,
native: ethereum_builtin("identity"),
activate_at: 1,
};
Expand Down
Loading

0 comments on commit 902ab9f

Please sign in to comment.