From 78a1d8b7b43064ff2ec353a8fd8bd112bc57a432 Mon Sep 17 00:00:00 2001 From: TriplEight Date: Fri, 14 Jun 2019 13:00:57 +0200 Subject: [PATCH 1/2] fix docker tags for publishing (#10741) --- scripts/docker/hub/publish-docker.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/docker/hub/publish-docker.sh b/scripts/docker/hub/publish-docker.sh index 6602d55c23a..84feedb2817 100755 --- a/scripts/docker/hub/publish-docker.sh +++ b/scripts/docker/hub/publish-docker.sh @@ -3,7 +3,9 @@ set -e # fail on any error VERSION=$(cat ./tools/VERSION) +TRACK=$(cat ./tools/TRACK) echo "Parity Ethereum version = ${VERSION}" +echo "Parity Ethereum track = ${TRACK}" test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" \ || ( echo "no docker credentials provided"; exit 1 ) @@ -44,6 +46,14 @@ case "${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}" in --file tools/Dockerfile .; docker push "parity/parity:${VERSION}-${CI_COMMIT_REF_NAME}"; docker push "parity/parity:stable";; + v[0-9]*.[0-9]*) + echo "Docker TAG - 'parity/parity:${VERSION}-${TRACK}'" + docker build --no-cache \ + --build-arg VCS_REF="${CI_COMMIT_SHA}" \ + --build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \ + --tag "parity/parity:${VERSION}-${TRACK}" \ + --file tools/Dockerfile .; + docker push "parity/parity:${VERSION}-${TRACK}";; *) echo "Docker TAG - 'parity/parity:${VERSION}-${CI_COMMIT_REF_NAME}'" docker build --no-cache \ From dbdb57a8c00148df1018db9e7649b12335c303c2 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 14 Jun 2019 18:48:35 +0200 Subject: [PATCH 2/2] Fix deprectation warnings on nightly (#10746) * Run `cargo fix` on ethcore * Add note about funky import needed-but-not-needed * Fix benches * cargo fix blockchain --- ethcore/benches/builtin.rs | 11 ++--- ethcore/blockchain/src/blockchain.rs | 22 +++++----- ethcore/src/account_db.rs | 36 ++++++++-------- ethcore/src/block.rs | 22 +++++----- ethcore/src/builtin.rs | 28 ++++++------- ethcore/src/client/ancient_import.rs | 8 ++-- ethcore/src/client/client.rs | 34 +++++++-------- ethcore/src/client/io_message.rs | 2 +- ethcore/src/client/test_client.rs | 6 +-- ethcore/src/client/trace.rs | 4 +- ethcore/src/client/traits.rs | 12 +++--- ethcore/src/engines/authority_round/mod.rs | 42 +++++++++---------- ethcore/src/engines/basic_authority.rs | 12 +++--- ethcore/src/engines/clique/mod.rs | 14 +++---- ethcore/src/engines/mod.rs | 24 +++++------ ethcore/src/engines/null_engine.rs | 2 +- ethcore/src/engines/signer.rs | 2 +- ethcore/src/engines/validator_set/contract.rs | 4 +- ethcore/src/engines/validator_set/mod.rs | 4 +- ethcore/src/engines/validator_set/multi.rs | 14 +++---- .../engines/validator_set/safe_contract.rs | 4 +- .../src/engines/validator_set/simple_list.rs | 4 +- ethcore/src/error.rs | 4 +- ethcore/src/ethereum/ethash.rs | 2 +- ethcore/src/executive.rs | 4 +- ethcore/src/factory.rs | 2 +- ethcore/src/lib.rs | 4 ++ ethcore/src/machine/impls.rs | 6 +-- ethcore/src/miner/miner.rs | 6 +-- ethcore/src/miner/pool_client.rs | 8 ++-- ethcore/src/pod_account.rs | 2 +- ethcore/src/snapshot/account.rs | 2 +- ethcore/src/snapshot/consensus/authority.rs | 16 +++---- ethcore/src/snapshot/consensus/mod.rs | 10 ++--- ethcore/src/snapshot/consensus/work.rs | 12 +++--- ethcore/src/snapshot/error.rs | 2 +- ethcore/src/snapshot/mod.rs | 20 ++++----- ethcore/src/snapshot/service.rs | 24 +++++------ ethcore/src/snapshot/tests/helpers.rs | 10 ++--- ethcore/src/snapshot/watcher.rs | 4 +- ethcore/src/spec/spec.rs | 4 +- ethcore/src/state/account.rs | 16 +++---- ethcore/src/state/backend.rs | 26 ++++++------ ethcore/src/state/mod.rs | 4 +- ethcore/src/state_db.rs | 16 +++---- ethcore/src/test_helpers.rs | 16 +++---- ethcore/src/trace/db.rs | 4 +- ethcore/src/verification/canon_verifier.rs | 4 +- ethcore/src/verification/mod.rs | 2 +- ethcore/src/verification/noop_verifier.rs | 4 +- ethcore/src/verification/queue/kind.rs | 12 +++--- ethcore/src/verification/queue/mod.rs | 6 +-- ethcore/src/verification/verification.rs | 22 +++++----- ethcore/src/verification/verifier.rs | 4 +- 54 files changed, 295 insertions(+), 294 deletions(-) diff --git a/ethcore/benches/builtin.rs b/ethcore/benches/builtin.rs index d7ed483dd03..974284bb014 100644 --- a/ethcore/benches/builtin.rs +++ b/ethcore/benches/builtin.rs @@ -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; @@ -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(); @@ -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()]; diff --git a/ethcore/blockchain/src/blockchain.rs b/ethcore/blockchain/src/blockchain.rs index 7cf6b12dd5c..afebacad9b4 100644 --- a/ethcore/blockchain/src/blockchain.rs +++ b/ethcore/blockchain/src/blockchain.rs @@ -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; + fn key_value(&self) -> &Arc; /// Header blooms database. fn blooms(&self) -> &blooms_db::Database; @@ -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>; + fn open(&self, path: &Path) -> io::Result>; } /// Interface for querying blocks by hash and by number. @@ -228,7 +228,7 @@ pub struct BlockChain { transaction_addresses: RwLock>, block_receipts: RwLock>, - db: Arc, + db: Arc, cache_man: Mutex>, @@ -481,7 +481,7 @@ impl<'a> Iterator for AncestryWithMetadataIter<'a> { /// Returns epoch transitions. pub struct EpochTransitionIter<'a> { chain: &'a BlockChain, - prefix_iter: Box, Box<[u8]>)> + 'a>, + prefix_iter: Box, Box<[u8]>)> + 'a>, } impl<'a> Iterator for EpochTransitionIter<'a> { @@ -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) -> BlockChain { + pub fn new(config: Config, genesis: &[u8], db: Arc) -> BlockChain { // 400 is the average size of the key let cache_man = CacheManager::new(config.pref_cache_size, config.max_cache_size, 400); @@ -1592,11 +1592,11 @@ mod tests { _trace_blooms_dir: TempDir, blooms: blooms_db::Database, trace_blooms: blooms_db::Database, - key_value: Arc, + key_value: Arc, } impl BlockChainDB for TestBlockChainDB { - fn key_value(&self) -> &Arc { + fn key_value(&self) -> &Arc { &self.key_value } @@ -1610,7 +1610,7 @@ mod tests { } /// Creates new test instance of `BlockChainDB` - pub fn new_db() -> Arc { + pub fn new_db() -> Arc { let blooms_dir = TempDir::new("").unwrap(); let trace_blooms_dir = TempDir::new("").unwrap(); @@ -1625,15 +1625,15 @@ mod tests { Arc::new(db) } - fn new_chain(genesis: encoded::Block, db: Arc) -> BlockChain { + fn new_chain(genesis: encoded::Block, db: Arc) -> BlockChain { BlockChain::new(Config::default(), genesis.raw(), db) } - fn insert_block(db: &Arc, bc: &BlockChain, block: encoded::Block, receipts: Vec) -> ImportRoute { + fn insert_block(db: &Arc, bc: &BlockChain, block: encoded::Block, receipts: Vec) -> ImportRoute { insert_block_commit(db, bc, block, receipts, true) } - fn insert_block_commit(db: &Arc, bc: &BlockChain, block: encoded::Block, receipts: Vec, commit: bool) -> ImportRoute { + fn insert_block_commit(db: &Arc, bc: &BlockChain, block: encoded::Block, receipts: Vec, 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(); diff --git a/ethcore/src/account_db.rs b/ethcore/src/account_db.rs index fcc6f74c6cd..bf1380908f8 100644 --- a/ethcore/src/account_db.rs +++ b/ethcore/src/account_db.rs @@ -57,7 +57,7 @@ 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, address_hash: H256) -> Box + 'db> { + pub fn readonly<'db>(&self, db: &'db dyn HashDB, address_hash: H256) -> Box + 'db> { match *self { Factory::Mangled => Box::new(AccountDB::from_hash(db, address_hash)), Factory::Plain => Box::new(Wrapping(db)), @@ -65,7 +65,7 @@ impl Factory { } /// Create a new mutable hashdb. - pub fn create<'db>(&self, db: &'db mut HashDB, address_hash: H256) -> Box + 'db> { + pub fn create<'db>(&self, db: &'db mut dyn HashDB, address_hash: H256) -> Box + 'db> { match *self { Factory::Mangled => Box::new(AccountDBMut::from_hash(db, address_hash)), Factory::Plain => Box::new(WrappingMut(db)), @@ -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, + db: &'db dyn HashDB, address_hash: H256, } impl<'db> AccountDB<'db> { /// Create a new AccountDB from an address. #[cfg(test)] - pub fn new(db: &'db HashDB, address: &Address) -> Self { + pub fn new(db: &'db dyn HashDB, address: &Address) -> Self { Self::from_hash(db, keccak(address)) } /// Create a new AcountDB from an address' hash. - pub fn from_hash(db: &'db HashDB, address_hash: H256) -> Self { + pub fn from_hash(db: &'db dyn HashDB, address_hash: H256) -> Self { AccountDB { db: db, address_hash: address_hash, @@ -98,8 +98,8 @@ impl<'db> AccountDB<'db> { } impl<'db> AsHashDB for AccountDB<'db> { - fn as_hash_db(&self) -> &HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } } impl<'db> HashDB for AccountDB<'db> { @@ -132,19 +132,19 @@ impl<'db> HashDB for AccountDB<'db> { /// DB backend wrapper for Account trie pub struct AccountDBMut<'db> { - db: &'db mut HashDB, + db: &'db mut dyn HashDB, address_hash: H256, } impl<'db> AccountDBMut<'db> { /// Create a new AccountDB from an address. #[cfg(test)] - pub fn new(db: &'db mut HashDB, address: &Address) -> Self { + pub fn new(db: &'db mut dyn HashDB, 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, address_hash: H256) -> Self { + pub fn from_hash(db: &'db mut dyn HashDB, address_hash: H256) -> Self { AccountDBMut { db: db, address_hash: address_hash, @@ -200,15 +200,15 @@ impl<'db> HashDB for AccountDBMut<'db>{ } impl<'db> AsHashDB for AccountDBMut<'db> { - fn as_hash_db(&self) -> &HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } } -struct Wrapping<'db>(&'db HashDB); +struct Wrapping<'db>(&'db dyn HashDB); impl<'db> AsHashDB for Wrapping<'db> { - fn as_hash_db(&self) -> &HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } } impl<'db> HashDB for Wrapping<'db> { @@ -239,10 +239,10 @@ impl<'db> HashDB for Wrapping<'db> { } } -struct WrappingMut<'db>(&'db mut HashDB); +struct WrappingMut<'db>(&'db mut dyn HashDB); impl<'db> AsHashDB for WrappingMut<'db> { - fn as_hash_db(&self) -> &HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } } impl<'db> HashDB for WrappingMut<'db>{ diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index fcecc53ab88..4a75034f025 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -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, @@ -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>( - engine: &'x EthEngine, + engine: &'x dyn EthEngine, factories: Factories, tracing: bool, db: StateDB, @@ -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; @@ -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) -> Result { + pub fn seal(self, engine: &dyn EthEngine, seal: Vec) -> Result { let expected_seal_fields = engine.seal_fields(&self.header); let mut s = self; if seal.len() != expected_seal_fields { @@ -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, ) -> Result { let mut s = self; @@ -472,14 +472,14 @@ pub(crate) fn enact( header: Header, transactions: Vec, uncles: Vec
, - engine: &EthEngine, + engine: &dyn EthEngine, tracing: bool, db: StateDB, parent: &Header, last_hashes: Arc, factories: Factories, is_epoch_begin: bool, - ancestry: &mut Iterator, + ancestry: &mut dyn Iterator, ) -> Result { // For trace log let trace_state = if log_enabled!(target: "enact", ::log::Level::Trace) { @@ -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, factories: Factories, is_epoch_begin: bool, - ancestry: &mut Iterator, + ancestry: &mut dyn Iterator, ) -> Result { enact( @@ -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, - engine: &EthEngine, + engine: &dyn EthEngine, tracing: bool, db: StateDB, parent: &Header, @@ -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, - engine: &EthEngine, + engine: &dyn EthEngine, tracing: bool, db: StateDB, parent: &Header, diff --git a/ethcore/src/builtin.rs b/ethcore/src/builtin.rs index b9d79fc3d2b..76d00ba5269 100644 --- a/ethcore/src/builtin.rs +++ b/ethcore/src/builtin.rs @@ -157,8 +157,8 @@ impl ModexpPricer { /// /// Unless `is_active` is true, pub struct Builtin { - pricer: Box, - native: Box, + pricer: Box, + native: Box, activate_at: u64, } @@ -177,7 +177,7 @@ impl Builtin { impl From for Builtin { fn from(b: ethjson::spec::Builtin) -> Self { - let pricer: Box = match b.pricing { + let pricer: Box = match b.pricing { ethjson::spec::Pricing::Linear(linear) => { Box::new(Linear { base: linear.base, @@ -211,16 +211,16 @@ impl From for Builtin { } /// Ethereum built-in factory. -pub fn ethereum_builtin(name: &str) -> Box { +pub fn ethereum_builtin(name: &str) -> Box { match name { - "identity" => Box::new(Identity) as Box, - "ecrecover" => Box::new(EcRecover) as Box, - "sha256" => Box::new(Sha256) as Box, - "ripemd160" => Box::new(Ripemd160) as Box, - "modexp" => Box::new(ModexpImpl) as Box, - "alt_bn128_add" => Box::new(Bn128AddImpl) as Box, - "alt_bn128_mul" => Box::new(Bn128MulImpl) as Box, - "alt_bn128_pairing" => Box::new(Bn128PairingImpl) as Box, + "identity" => Box::new(Identity) as Box, + "ecrecover" => Box::new(EcRecover) as Box, + "sha256" => Box::new(Sha256) as Box, + "ripemd160" => Box::new(Ripemd160) as Box, + "modexp" => Box::new(ModexpImpl) as Box, + "alt_bn128_add" => Box::new(Bn128AddImpl) as Box, + "alt_bn128_mul" => Box::new(Bn128MulImpl) as Box, + "alt_bn128_pairing" => Box::new(Bn128PairingImpl) as Box, _ => panic!("invalid builtin name: {}", name), } } @@ -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 as Box, native: ethereum_builtin("identity"), activate_at: 100_000, }; @@ -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 as Box, native: ethereum_builtin("identity"), activate_at: 1, }; diff --git a/ethcore/src/client/ancient_import.rs b/ethcore/src/client/ancient_import.rs index 2a0a970cd69..46cd519a7aa 100644 --- a/ethcore/src/client/ancient_import.rs +++ b/ethcore/src/client/ancient_import.rs @@ -32,13 +32,13 @@ const HEAVY_VERIFY_RATE: f32 = 0.02; /// Ancient block verifier: import an ancient sequence of blocks in order from a starting /// epoch. pub struct AncientVerifier { - cur_verifier: RwLock>>>, - engine: Arc, + cur_verifier: RwLock>>>, + engine: Arc, } impl AncientVerifier { /// Create a new ancient block verifier with the given engine. - pub fn new(engine: Arc) -> Self { + pub fn new(engine: Arc) -> Self { AncientVerifier { cur_verifier: RwLock::new(None), engine, @@ -87,7 +87,7 @@ impl AncientVerifier { } fn initial_verifier(&self, header: &Header, chain: &BlockChain) - -> Result>, ::error::Error> + -> Result>, ::error::Error> { trace!(target: "client", "Initializing ancient block restoration."); let current_epoch_data = chain.epoch_transitions() diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index d22cff0942d..f0a2cb3e185 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -153,7 +153,7 @@ struct Importer { pub import_lock: Mutex<()>, // FIXME Maybe wrap the whole `Importer` instead? /// Used to verify blocks - pub verifier: Box>, + pub verifier: Box>, /// Queue containing pending blocks pub block_queue: BlockQueue, @@ -165,7 +165,7 @@ struct Importer { pub ancient_verifier: AncientVerifier, /// Ethereum engine to be used during import - pub engine: Arc, + pub engine: Arc, /// A lru cache of recently detected bad blocks pub bad_blocks: bad_blocks::BadBlocks, @@ -187,7 +187,7 @@ pub struct Client { chain: RwLock>, tracedb: RwLock>, - engine: Arc, + engine: Arc, /// Client configuration config: ClientConfig, @@ -196,7 +196,7 @@ pub struct Client { pruning: journaldb::Algorithm, /// Client uses this to store blocks, traces, etc. - db: RwLock>, + db: RwLock>, state_db: RwLock, @@ -210,7 +210,7 @@ pub struct Client { io_channel: RwLock>, /// List of actors to be notified on certain chain events - notify: RwLock>>, + notify: RwLock>>, /// Queued transactions from IO queue_transactions: IoChannelQueue, @@ -232,12 +232,12 @@ pub struct Client { history: u64, /// An action to be done if a mode/spec_name change happens - on_user_defaults_change: Mutex) + 'static + Send>>>, + on_user_defaults_change: Mutex) + 'static + Send>>>, registrar_address: Option
, /// A closure to call when we want to restart the client - exit_handler: Mutex>>, + exit_handler: Mutex>>, importer: Importer, } @@ -245,7 +245,7 @@ pub struct Client { impl Importer { pub fn new( config: &ClientConfig, - engine: Arc, + engine: Arc, message_channel: IoChannel, miner: Arc, ) -> Result { @@ -449,7 +449,7 @@ impl Importer { /// /// The block is guaranteed to be the next best blocks in the /// first block sequence. Does no sealing or transaction validation. - fn import_old_block(&self, unverified: Unverified, receipts_bytes: &[u8], db: &KeyValueDB, chain: &BlockChain) -> EthcoreResult<()> { + fn import_old_block(&self, unverified: Unverified, receipts_bytes: &[u8], db: &dyn KeyValueDB, chain: &BlockChain) -> EthcoreResult<()> { let receipts = ::rlp::decode_list(receipts_bytes); let _import_lock = self.import_lock.lock(); @@ -702,7 +702,7 @@ impl Client { pub fn new( config: ClientConfig, spec: &Spec, - db: Arc, + db: Arc, miner: Arc, message_channel: IoChannel, ) -> Result, ::error::Error> { @@ -844,7 +844,7 @@ impl Client { } /// Adds an actor to be notified on certain events - pub fn add_notify(&self, target: Arc) { + pub fn add_notify(&self, target: Arc) { self.notify.write().push(Arc::downgrade(&target)); } @@ -857,11 +857,11 @@ impl Client { } /// Returns engine reference. - pub fn engine(&self) -> &EthEngine { + pub fn engine(&self) -> &dyn EthEngine { &*self.engine } - fn notify(&self, f: F) where F: Fn(&ChainNotify) { + fn notify(&self, f: F) where F: Fn(&dyn ChainNotify) { for np in &*self.notify.read() { if let Some(n) = np.upgrade() { f(&*n); @@ -1071,7 +1071,7 @@ impl Client { } /// Get a copy of the best block's state. - pub fn state(&self) -> Box { + pub fn state(&self) -> Box { Box::new(self.latest_state()) as Box<_> } @@ -1648,7 +1648,7 @@ impl Call for Client { } impl EngineInfo for Client { - fn engine(&self) -> &EthEngine { + fn engine(&self) -> &dyn EthEngine { Client::engine(self) } } @@ -1668,7 +1668,7 @@ impl BlockChainClient for Client { Ok(self.replay_block_transactions(block, analytics)?.nth(address.index).expect(PROOF).1) } - fn replay_block_transactions(&self, block: BlockId, analytics: CallAnalytics) -> Result>, CallError> { + fn replay_block_transactions(&self, block: BlockId, analytics: CallAnalytics) -> Result>, CallError> { let mut env_info = self.env_info(block).ok_or(CallError::StatePruned)?; let body = self.block_body(block).ok_or(CallError::StatePruned)?; let mut state = self.state_at_beginning(block).ok_or(CallError::StatePruned)?; @@ -2495,7 +2495,7 @@ impl super::traits::EngineClient for Client { self.chain.read().epoch_transition_for(parent_hash) } - fn as_full_client(&self) -> Option<&BlockChainClient> { Some(self) } + fn as_full_client(&self) -> Option<&dyn BlockChainClient> { Some(self) } fn block_number(&self, id: BlockId) -> Option { BlockChainClient::block_number(self, id) diff --git a/ethcore/src/client/io_message.rs b/ethcore/src/client/io_message.rs index 92e2d3e258e..5fcf8f9ff8d 100644 --- a/ethcore/src/client/io_message.rs +++ b/ethcore/src/client/io_message.rs @@ -47,7 +47,7 @@ impl ClientIoMessage { } /// A function to invoke in the client thread. -pub struct Callback(pub Box); +pub struct Callback(pub Box); impl fmt::Debug for Callback { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index c9c81ecb858..1b28ca2cdbd 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -627,7 +627,7 @@ impl StateClient for TestBlockChainClient { } impl EngineInfo for TestBlockChainClient { - fn engine(&self) -> &EthEngine { + fn engine(&self) -> &dyn EthEngine { unimplemented!() } } @@ -661,7 +661,7 @@ impl BlockChainClient for TestBlockChainClient { } } - fn replay_block_transactions(&self, _block: BlockId, _analytics: CallAnalytics) -> Result>, CallError> { + fn replay_block_transactions(&self, _block: BlockId, _analytics: CallAnalytics) -> Result>, CallError> { Ok(Box::new( self.traces .read() @@ -955,7 +955,7 @@ impl super::traits::EngineClient for TestBlockChainClient { None } - fn as_full_client(&self) -> Option<&BlockChainClient> { Some(self) } + fn as_full_client(&self) -> Option<&dyn BlockChainClient> { Some(self) } fn block_number(&self, id: BlockId) -> Option { BlockChainClient::block_number(self, id) diff --git a/ethcore/src/client/trace.rs b/ethcore/src/client/trace.rs index 73563a1d0f6..7be957b33ec 100644 --- a/ethcore/src/client/trace.rs +++ b/ethcore/src/client/trace.rs @@ -23,11 +23,11 @@ use types::BlockNumber; impl TraceDatabaseExtras for BlockChain { fn block_hash(&self, block_number: BlockNumber) -> Option { - (self as &BlockProvider).block_hash(block_number) + (self as &dyn BlockProvider).block_hash(block_number) } fn transaction_hash(&self, block_number: BlockNumber, tx_position: usize) -> Option { - (self as &BlockProvider).block_hash(block_number) + (self as &dyn BlockProvider).block_hash(block_number) .and_then(|block_hash| { let tx_address = TransactionAddress { block_hash: block_hash, diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index bcfa7417c4b..9d0b27fc709 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -55,7 +55,7 @@ use verification::queue::kind::blocks::Unverified; /// State information to be used during client query pub enum StateOrBlock { /// State to be used, may be pending - State(Box), + State(Box), /// Id of an existing block from a chain to get state from Block(BlockId) @@ -67,8 +67,8 @@ impl From for StateOrBlock { } } -impl From> for StateOrBlock { - fn from(info: Box) -> StateOrBlock { +impl From> for StateOrBlock { + fn from(info: Box) -> StateOrBlock { StateOrBlock::State(info) } } @@ -184,7 +184,7 @@ pub trait Call { /// Provides `engine` method pub trait EngineInfo { /// Get underlying engine object - fn engine(&self) -> &EthEngine; + fn engine(&self) -> &dyn EthEngine; } /// IO operations that should off-load heavy work to another thread. @@ -306,7 +306,7 @@ pub trait BlockChainClient : Sync + Send + AccountData + BlockChain + CallContra fn replay(&self, t: TransactionId, analytics: CallAnalytics) -> Result; /// Replays all the transactions in a given block for inspection. - fn replay_block_transactions(&self, block: BlockId, analytics: CallAnalytics) -> Result>, CallError>; + fn replay_block_transactions(&self, block: BlockId, analytics: CallAnalytics) -> Result>, CallError>; /// Returns traces matching given filter. fn filter_traces(&self, filter: TraceFilter) -> Option>; @@ -441,7 +441,7 @@ pub trait EngineClient: Sync + Send + ChainInfo { fn epoch_transition_for(&self, parent_hash: H256) -> Option<::engines::EpochTransition>; /// Attempt to cast the engine client to a full client. - fn as_full_client(&self) -> Option<&BlockChainClient>; + fn as_full_client(&self) -> Option<&dyn BlockChainClient>; /// Get a block number by ID. fn block_number(&self, id: BlockId) -> Option; diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index 8bf838d2dc5..6f2723bba71 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -63,7 +63,7 @@ pub struct AuthorityRoundParams { /// Starting step, pub start_step: Option, /// Valid validators. - pub validators: Box, + pub validators: Box, /// Chain score validation transition block. pub validate_score_transition: u64, /// Monotonic step validation transition block. @@ -222,9 +222,9 @@ impl EpochManager { // Zooms to the epoch after the header with the given hash. Returns true if succeeded, false otherwise. fn zoom_to_after( &mut self, - client: &EngineClient, + client: &dyn EngineClient, machine: &EthereumMachine, - validators: &ValidatorSet, + validators: &dyn ValidatorSet, hash: H256 ) -> bool { let last_was_parent = self.finality_checker.subchain_head() == Some(hash); @@ -324,7 +324,7 @@ impl EmptyStep { EmptyStep { signature, step, parent_hash } } - fn verify(&self, validators: &ValidatorSet) -> Result { + fn verify(&self, validators: &dyn ValidatorSet) -> Result { let message = keccak(empty_step_rlp(self.step, &self.parent_hash)); let correct_proposer = step_proposer(validators, &self.parent_hash, self.step); @@ -419,9 +419,9 @@ struct PermissionedStep { pub struct AuthorityRound { transition_service: IoService<()>, step: Arc, - client: Arc>>>, - signer: RwLock>>, - validators: Box, + client: Arc>>>, + signer: RwLock>>, + validators: Box, validate_score_transition: u64, validate_step_transition: u64, empty_steps: Mutex>, @@ -563,13 +563,13 @@ fn header_empty_steps_signers(header: &Header, empty_steps_transition: u64) -> R } } -fn step_proposer(validators: &ValidatorSet, bh: &H256, step: u64) -> Address { +fn step_proposer(validators: &dyn ValidatorSet, bh: &H256, step: u64) -> Address { let proposer = validators.get(bh, step as usize); trace!(target: "engine", "Fetched proposer for step {}: {}", step, proposer); proposer } -fn is_step_proposer(validators: &ValidatorSet, bh: &H256, step: u64, address: &Address) -> bool { +fn is_step_proposer(validators: &dyn ValidatorSet, bh: &H256, step: u64, address: &Address) -> bool { step_proposer(validators, bh, step) == *address } @@ -597,7 +597,7 @@ fn verify_timestamp(step: &Step, header_step: u64) -> Result<(), BlockError> { } } -fn verify_external(header: &Header, validators: &ValidatorSet, empty_steps_transition: u64) -> Result<(), Error> { +fn verify_external(header: &Header, validators: &dyn ValidatorSet, empty_steps_transition: u64) -> Result<(), Error> { let header_step = header_step(header, empty_steps_transition)?; let proposer_signature = header_signature(header, empty_steps_transition)?; @@ -716,7 +716,7 @@ impl AuthorityRound { // fetch correct validator set for epoch at header, taking into account // finality of previous transitions. - fn epoch_set<'a>(&'a self, header: &Header) -> Result<(CowLike, BlockNumber), Error> { + fn epoch_set<'a>(&'a self, header: &Header) -> Result<(CowLike, BlockNumber), Error> { Ok(if self.immediate_transitions { (CowLike::Borrowed(&*self.validators), header.number()) } else { @@ -802,7 +802,7 @@ impl AuthorityRound { } } - fn report_skipped(&self, header: &Header, current_step: u64, parent_step: u64, validators: &ValidatorSet, set_number: u64) { + fn report_skipped(&self, header: &Header, current_step: u64, parent_step: u64, validators: &dyn ValidatorSet, set_number: u64) { // we're building on top of the genesis block so don't report any skipped steps if header.number() == 1 { return; @@ -825,7 +825,7 @@ impl AuthorityRound { } // Returns the hashes of all ancestor blocks that are finalized by the given `chain_head`. - fn build_finality(&self, chain_head: &Header, ancestry: &mut Iterator) -> Vec { + fn build_finality(&self, chain_head: &Header, ancestry: &mut dyn Iterator) -> Vec { if self.immediate_transitions { return Vec::new() } let client = match self.client.read().as_ref().and_then(|weak| weak.upgrade()) { @@ -894,7 +894,7 @@ fn unix_now() -> Duration { struct TransitionHandler { step: Arc, - client: Arc>>>, + client: Arc>>>, } const ENGINE_TIMEOUT_TOKEN: TimerToken = 23; @@ -1198,7 +1198,7 @@ impl Engine for AuthorityRound { &self, block: &mut ExecutedBlock, epoch_begin: bool, - _ancestry: &mut Iterator, + _ancestry: &mut dyn Iterator, ) -> Result<(), Error> { // with immediate transitions, we don't use the epoch mechanism anyway. // the genesis is always considered an epoch, but we ignore it intentionally. @@ -1555,12 +1555,12 @@ impl Engine for AuthorityRound { } } - fn register_client(&self, client: Weak) { + fn register_client(&self, client: Weak) { *self.client.write() = Some(client.clone()); self.validators.register_client(client); } - fn set_signer(&self, signer: Box) { + fn set_signer(&self, signer: Box) { *self.signer.write() = Some(signer); } @@ -1572,7 +1572,7 @@ impl Engine for AuthorityRound { ) } - fn snapshot_components(&self) -> Option> { + fn snapshot_components(&self) -> Option> { if self.immediate_transitions { None } else { @@ -1584,7 +1584,7 @@ impl Engine for AuthorityRound { super::total_difficulty_fork_choice(new, current) } - fn ancestry_actions(&self, header: &Header, ancestry: &mut Iterator) -> Vec { + fn ancestry_actions(&self, header: &Header, ancestry: &mut dyn Iterator) -> Vec { let finalized = self.build_finality( header, &mut ancestry.take_while(|e| !e.is_finalized).map(|e| e.header), @@ -1908,14 +1908,14 @@ mod tests { (spec, tap, accounts) } - fn empty_step(engine: &EthEngine, step: u64, parent_hash: &H256) -> EmptyStep { + fn empty_step(engine: &dyn EthEngine, step: u64, parent_hash: &H256) -> EmptyStep { let empty_step_rlp = super::empty_step_rlp(step, parent_hash); let signature = engine.sign(keccak(&empty_step_rlp)).unwrap().into(); let parent_hash = parent_hash.clone(); EmptyStep { step, signature, parent_hash } } - fn sealed_empty_step(engine: &EthEngine, step: u64, parent_hash: &H256) -> SealedEmptyStep { + fn sealed_empty_step(engine: &dyn EthEngine, step: u64, parent_hash: &H256) -> SealedEmptyStep { let empty_step_rlp = super::empty_step_rlp(step, parent_hash); let signature = engine.sign(keccak(&empty_step_rlp)).unwrap().into(); SealedEmptyStep { signature, step } diff --git a/ethcore/src/engines/basic_authority.rs b/ethcore/src/engines/basic_authority.rs index 21652f0a12c..098c3f558a1 100644 --- a/ethcore/src/engines/basic_authority.rs +++ b/ethcore/src/engines/basic_authority.rs @@ -55,7 +55,7 @@ impl super::EpochVerifier for EpochVerifier { } } -fn verify_external(header: &Header, validators: &ValidatorSet) -> Result<(), Error> { +fn verify_external(header: &Header, validators: &dyn ValidatorSet) -> Result<(), Error> { use rlp::Rlp; // Check if the signature belongs to a validator, can depend on parent state. @@ -75,8 +75,8 @@ fn verify_external(header: &Header, validators: &ValidatorSet) -> Result<(), Err /// Engine using `BasicAuthority`, trivial proof-of-authority consensus. pub struct BasicAuthority { machine: EthereumMachine, - signer: RwLock>>, - validators: Box, + signer: RwLock>>, + validators: Box, } impl BasicAuthority { @@ -189,11 +189,11 @@ impl Engine for BasicAuthority { } } - fn register_client(&self, client: Weak) { + fn register_client(&self, client: Weak) { self.validators.register_client(client); } - fn set_signer(&self, signer: Box) { + fn set_signer(&self, signer: Box) { *self.signer.write() = Some(signer); } @@ -205,7 +205,7 @@ impl Engine for BasicAuthority { ) } - fn snapshot_components(&self) -> Option> { + fn snapshot_components(&self) -> Option> { None } diff --git a/ethcore/src/engines/clique/mod.rs b/ethcore/src/engines/clique/mod.rs index 5884ab05d3a..052f0a578ce 100644 --- a/ethcore/src/engines/clique/mod.rs +++ b/ethcore/src/engines/clique/mod.rs @@ -162,10 +162,10 @@ pub struct Clique { epoch_length: u64, period: u64, machine: EthereumMachine, - client: RwLock>>, + client: RwLock>>, block_state_by_hash: RwLock>, proposals: RwLock>, - signer: RwLock>>, + signer: RwLock>>, } #[cfg(test)] @@ -174,10 +174,10 @@ pub struct Clique { pub epoch_length: u64, pub period: u64, pub machine: EthereumMachine, - pub client: RwLock>>, + pub client: RwLock>>, pub block_state_by_hash: RwLock>, pub proposals: RwLock>, - pub signer: RwLock>>, + pub signer: RwLock>>, } impl Clique { @@ -370,7 +370,7 @@ impl Engine for Clique { &self, _block: &mut ExecutedBlock, _epoch_begin: bool, - _ancestry: &mut Iterator, + _ancestry: &mut dyn Iterator, ) -> Result<(), Error> { Ok(()) } @@ -736,12 +736,12 @@ impl Engine for Clique { } } - fn set_signer(&self, signer: Box) { + fn set_signer(&self, signer: Box) { trace!(target: "engine", "set_signer: {}", signer.address()); *self.signer.write() = Some(signer); } - fn register_client(&self, client: Weak) { + fn register_client(&self, client: Weak) { *self.client.write() = Some(client.clone()); } diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index d51e31ea17a..e0db2181e9d 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -175,10 +175,10 @@ pub enum SealingState { } /// A system-calling closure. Enacts calls on a block's state from the system address. -pub type SystemCall<'a> = FnMut(Address, Vec) -> Result, String> + 'a; +pub type SystemCall<'a> = dyn FnMut(Address, Vec) -> Result, String> + 'a; /// A system-calling closure. Enacts calls on a block's state with code either from an on-chain contract, or hard-coded EVM or WASM (if enabled on-chain) codes. -pub type SystemOrCodeCall<'a> = FnMut(SystemOrCodeCallKind, Vec) -> Result, String> + 'a; +pub type SystemOrCodeCall<'a> = dyn FnMut(SystemOrCodeCallKind, Vec) -> Result, String> + 'a; /// Kind of SystemOrCodeCall, this is either an on-chain address, or code. #[derive(PartialEq, Debug, Clone)] @@ -220,10 +220,10 @@ pub fn default_system_or_code_call<'a>(machine: &'a ::machine::EthereumMachine, } /// Type alias for a function we can get headers by hash through. -pub type Headers<'a, H> = Fn(H256) -> Option + 'a; +pub type Headers<'a, H> = dyn Fn(H256) -> Option + 'a; /// Type alias for a function we can query pending transitions by block hash through. -pub type PendingTransitionStore<'a> = Fn(H256) -> Option + 'a; +pub type PendingTransitionStore<'a> = dyn Fn(H256) -> Option + 'a; /// Proof dependent on state. pub trait StateDependentProof: Send + Sync { @@ -240,16 +240,16 @@ pub enum Proof { /// Known proof (extracted from signal) Known(Vec), /// State dependent proof. - WithState(Arc>), + WithState(Arc>), } /// Generated epoch verifier. pub enum ConstructedVerifier<'a, M: Machine> { /// Fully trusted verifier. - Trusted(Box>), + Trusted(Box>), /// Verifier unconfirmed. Check whether given finality proof finalizes given hash /// under previous epoch. - Unconfirmed(Box>, &'a [u8], H256), + Unconfirmed(Box>, &'a [u8], H256), /// Error constructing verifier. Err(Error), } @@ -257,7 +257,7 @@ pub enum ConstructedVerifier<'a, M: Machine> { impl<'a, M: Machine> ConstructedVerifier<'a, M> { /// Convert to a result, indicating that any necessary confirmation has been done /// already. - pub fn known_confirmed(self) -> Result>, Error> { + pub fn known_confirmed(self) -> Result>, Error> { match self { ConstructedVerifier::Trusted(v) | ConstructedVerifier::Unconfirmed(v, _, _) => Ok(v), ConstructedVerifier::Err(e) => Err(e), @@ -303,7 +303,7 @@ pub trait Engine: Sync + Send { &self, _block: &mut ExecutedBlock, _epoch_begin: bool, - _ancestry: &mut Iterator, + _ancestry: &mut dyn Iterator, ) -> Result<(), M::Error> { Ok(()) } @@ -426,7 +426,7 @@ pub trait Engine: Sync + Send { fn handle_message(&self, _message: &[u8]) -> Result<(), EngineError> { Err(EngineError::UnexpectedMessage) } /// Register a component which signs consensus messages. - fn set_signer(&self, _signer: Box) {} + fn set_signer(&self, _signer: Box) {} /// Sign using the EngineSigner, to be used for consensus tx signing. fn sign(&self, _hash: H256) -> Result { unimplemented!() } @@ -439,7 +439,7 @@ pub trait Engine: Sync + Send { /// Create a factory for building snapshot chunks and restoring from them. /// Returning `None` indicates that this engine doesn't support snapshot creation. - fn snapshot_components(&self) -> Option> { + fn snapshot_components(&self) -> Option> { None } @@ -463,7 +463,7 @@ pub trait Engine: Sync + Send { /// Gather all ancestry actions. Called at the last stage when a block is committed. The Engine must guarantee that /// the ancestry exists. - fn ancestry_actions(&self, _header: &Header, _ancestry: &mut Iterator) -> Vec { + fn ancestry_actions(&self, _header: &Header, _ancestry: &mut dyn Iterator) -> Vec { Vec::new() } diff --git a/ethcore/src/engines/null_engine.rs b/ethcore/src/engines/null_engine.rs index 27138985ad6..42cb9b5b40e 100644 --- a/ethcore/src/engines/null_engine.rs +++ b/ethcore/src/engines/null_engine.rs @@ -99,7 +99,7 @@ impl Engine for NullEngine { Ok(()) } - fn snapshot_components(&self) -> Option> { + fn snapshot_components(&self) -> Option> { Some(Box::new(::snapshot::PowSnapshot::new(10000, 10000))) } diff --git a/ethcore/src/engines/signer.rs b/ethcore/src/engines/signer.rs index 67066e74d7a..196c535fe76 100644 --- a/ethcore/src/engines/signer.rs +++ b/ethcore/src/engines/signer.rs @@ -29,7 +29,7 @@ pub trait EngineSigner: Send + Sync { } /// Creates a new `EngineSigner` from given key pair. -pub fn from_keypair(keypair: ethkey::KeyPair) -> Box { +pub fn from_keypair(keypair: ethkey::KeyPair) -> Box { Box::new(Signer(keypair)) } diff --git a/ethcore/src/engines/validator_set/contract.rs b/ethcore/src/engines/validator_set/contract.rs index dbf92ce4b59..5560447c447 100644 --- a/ethcore/src/engines/validator_set/contract.rs +++ b/ethcore/src/engines/validator_set/contract.rs @@ -37,7 +37,7 @@ use_contract!(validator_report, "res/contracts/validator_report.json"); pub struct ValidatorContract { contract_address: Address, validators: ValidatorSafeContract, - client: RwLock>>, // TODO [keorn]: remove + client: RwLock>>, // TODO [keorn]: remove } impl ValidatorContract { @@ -125,7 +125,7 @@ impl ValidatorSet for ValidatorContract { } } - fn register_client(&self, client: Weak) { + fn register_client(&self, client: Weak) { self.validators.register_client(client.clone()); *self.client.write() = Some(client); } diff --git a/ethcore/src/engines/validator_set/mod.rs b/ethcore/src/engines/validator_set/mod.rs index 915a3f9a15d..8d31937091a 100644 --- a/ethcore/src/engines/validator_set/mod.rs +++ b/ethcore/src/engines/validator_set/mod.rs @@ -44,7 +44,7 @@ use self::multi::Multi; use super::SystemCall; /// Creates a validator set from spec. -pub fn new_validator_set(spec: ValidatorSpec) -> Box { +pub fn new_validator_set(spec: ValidatorSpec) -> Box { match spec { ValidatorSpec::List(list) => Box::new(SimpleList::new(list.into_iter().map(Into::into).collect())), ValidatorSpec::SafeContract(address) => Box::new(ValidatorSafeContract::new(address.into())), @@ -141,5 +141,5 @@ pub trait ValidatorSet: Send + Sync + 'static { /// Notifies about benign misbehaviour. fn report_benign(&self, _validator: &Address, _set_block: BlockNumber, _block: BlockNumber) {} /// Allows blockchain state access. - fn register_client(&self, _client: Weak) {} + fn register_client(&self, _client: Weak) {} } diff --git a/ethcore/src/engines/validator_set/multi.rs b/ethcore/src/engines/validator_set/multi.rs index b9ef6774784..1d115bf5d33 100644 --- a/ethcore/src/engines/validator_set/multi.rs +++ b/ethcore/src/engines/validator_set/multi.rs @@ -30,15 +30,15 @@ use client::EngineClient; use machine::{AuxiliaryData, Call, EthereumMachine}; use super::{SystemCall, ValidatorSet}; -type BlockNumberLookup = Box Result + Send + Sync + 'static>; +type BlockNumberLookup = Box Result + Send + Sync + 'static>; pub struct Multi { - sets: BTreeMap>, + sets: BTreeMap>, block_number: RwLock, } impl Multi { - pub fn new(set_map: BTreeMap>) -> Self { + pub fn new(set_map: BTreeMap>) -> Self { assert!(set_map.get(&0u64).is_some(), "ValidatorSet has to be specified from block 0."); Multi { sets: set_map, @@ -46,7 +46,7 @@ impl Multi { } } - fn correct_set(&self, id: BlockId) -> Option<&ValidatorSet> { + fn correct_set(&self, id: BlockId) -> Option<&dyn ValidatorSet> { match self.block_number.read()(id).map(|parent_block| self.correct_set_by_number(parent_block)) { Ok((_, set)) => Some(set), Err(e) => { @@ -58,7 +58,7 @@ impl Multi { // get correct set by block number, along with block number at which // this set was activated. - fn correct_set_by_number(&self, parent_block: BlockNumber) -> (BlockNumber, &ValidatorSet) { + fn correct_set_by_number(&self, parent_block: BlockNumber) -> (BlockNumber, &dyn ValidatorSet) { let (block, set) = self.sets.iter() .rev() .find(|&(block, _)| *block <= parent_block + 1) @@ -134,7 +134,7 @@ impl ValidatorSet for Multi { self.correct_set_by_number(set_block).1.report_benign(validator, set_block, block); } - fn register_client(&self, client: Weak) { + fn register_client(&self, client: Weak) { for set in self.sets.values() { set.register_client(client.clone()); } @@ -215,7 +215,7 @@ mod tests { fn transition_to_fixed_list_instant() { use super::super::SimpleList; - let mut map: BTreeMap<_, Box> = BTreeMap::new(); + let mut map: BTreeMap<_, Box> = BTreeMap::new(); let list1: Vec<_> = (0..10).map(|_| Address::random()).collect(); let list2 = { let mut list = list1.clone(); diff --git a/ethcore/src/engines/validator_set/safe_contract.rs b/ethcore/src/engines/validator_set/safe_contract.rs index c210bcc00d6..e8db31423bb 100644 --- a/ethcore/src/engines/validator_set/safe_contract.rs +++ b/ethcore/src/engines/validator_set/safe_contract.rs @@ -75,7 +75,7 @@ impl ::engines::StateDependentProof for StateProof { pub struct ValidatorSafeContract { contract_address: Address, validators: RwLock>, - client: RwLock>>, // TODO [keorn]: remove + client: RwLock>>, // TODO [keorn]: remove } // first proof is just a state proof call of `getValidators` at header's state. @@ -431,7 +431,7 @@ impl ValidatorSet for ValidatorSafeContract { })) } - fn register_client(&self, client: Weak) { + fn register_client(&self, client: Weak) { trace!(target: "engine", "Setting up contract caller."); *self.client.write() = Some(client); } diff --git a/ethcore/src/engines/validator_set/simple_list.rs b/ethcore/src/engines/validator_set/simple_list.rs index 0a0294be966..ea1a1200ea7 100644 --- a/ethcore/src/engines/validator_set/simple_list.rs +++ b/ethcore/src/engines/validator_set/simple_list.rs @@ -105,8 +105,8 @@ impl ValidatorSet for SimpleList { } } -impl AsRef for SimpleList { - fn as_ref(&self) -> &ValidatorSet { +impl AsRef for SimpleList { + fn as_ref(&self) -> &dyn ValidatorSet { self } } diff --git a/ethcore/src/error.rs b/ethcore/src/error.rs index 5e4229a204f..477f67b26b1 100644 --- a/ethcore/src/error.rs +++ b/ethcore/src/error.rs @@ -162,7 +162,7 @@ pub enum QueueError { } impl error::Error for QueueError { - fn source(&self) -> Option<&(error::Error + 'static)> { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { QueueError::Channel(e) => Some(e), _ => None, @@ -264,7 +264,7 @@ pub enum Error { } impl error::Error for Error { - fn source(&self) -> Option<&(error::Error + 'static)> { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { Error::Io(e) => Some(e), Error::StdIo(e) => Some(e), diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index f2f0d000364..4fcf7f098f2 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -377,7 +377,7 @@ impl Engine for Arc { engines::ConstructedVerifier::Trusted(Box::new(self.clone())) } - fn snapshot_components(&self) -> Option> { + fn snapshot_components(&self) -> Option> { Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS))) } diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index 2d96db0705d..e14a43787ec 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -201,8 +201,8 @@ enum CallCreateExecutiveKind { CallBuiltin(ActionParams), ExecCall(ActionParams, Substate), ExecCreate(ActionParams, Substate), - ResumeCall(OriginInfo, Box, Substate), - ResumeCreate(OriginInfo, Box, Substate), + ResumeCall(OriginInfo, Box, Substate), + ResumeCreate(OriginInfo, Box, Substate), } /// Executive for a raw call/create action. diff --git a/ethcore/src/factory.rs b/ethcore/src/factory.rs index 06b77da9aa1..574cbeeb39d 100644 --- a/ethcore/src/factory.rs +++ b/ethcore/src/factory.rs @@ -31,7 +31,7 @@ pub struct VmFactory { } impl VmFactory { - pub fn create(&self, params: ActionParams, schedule: &Schedule, depth: usize) -> Box { + pub fn create(&self, params: ActionParams, schedule: &Schedule, depth: usize) -> Box { if schedule.wasm.is_some() && params.code.as_ref().map_or(false, |code| code.len() > 4 && &code[0..4] == WASM_MAGIC_NUMBER) { Box::new(WasmInterpreter::new(params)) } else { diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 315cd0bb5ed..87a1b4a0b01 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -82,7 +82,11 @@ extern crate journaldb; extern crate keccak_hash as hash; extern crate keccak_hasher; extern crate kvdb; +// Note: in `ethcore` this is only used by tests, so without `#[cfg(test)]` there's a warning. +// However, when building `parity-ethereum` this is needed. So there's something funny going on +// here. extern crate kvdb_memorydb; + extern crate len_caching_lock; extern crate lru_cache; extern crate memory_cache; diff --git a/ethcore/src/machine/impls.rs b/ethcore/src/machine/impls.rs index 4962f1ea25f..ec14f1f95c9 100644 --- a/ethcore/src/machine/impls.rs +++ b/ethcore/src/machine/impls.rs @@ -67,7 +67,7 @@ impl From<::ethjson::spec::EthashParams> for EthashExtensions { } /// Special rules to be applied to the schedule. -pub type ScheduleCreationRules = Fn(&mut Schedule, BlockNumber) + Sync + Send; +pub type ScheduleCreationRules = dyn Fn(&mut Schedule, BlockNumber) + Sync + Send; /// An ethereum-like state machine. pub struct EthereumMachine { @@ -415,7 +415,7 @@ pub struct AuxiliaryData<'a> { /// Type alias for a function we can make calls through synchronously. /// Returns the call result and state proof for each call. -pub type Call<'a> = Fn(Address, Vec) -> Result<(Vec, Vec>), String> + 'a; +pub type Call<'a> = dyn Fn(Address, Vec) -> Result<(Vec, Vec>), String> + 'a; /// Request for auxiliary data of a block. #[derive(Debug, Clone, Copy, PartialEq)] @@ -429,7 +429,7 @@ pub enum AuxiliaryRequest { } impl super::Machine for EthereumMachine { - type EngineClient = ::client::EngineClient; + type EngineClient = dyn (::client::EngineClient); type Error = Error; diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 67ef9e6181c..0bd40d1c8d1 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -203,7 +203,7 @@ pub enum Author { /// Sealing block is external and we only need a reward beneficiary (i.e. PoW) External(Address), /// Sealing is done internally, we need a way to create signatures to seal block (i.e. PoA) - Sealer(Box), + Sealer(Box), } impl Author { @@ -245,8 +245,8 @@ pub struct Miner { options: MinerOptions, // TODO [ToDr] Arc is only required because of price updater transaction_queue: Arc, - engine: Arc, - accounts: Arc, + engine: Arc, + accounts: Arc, io_channel: RwLock>>, service_transaction_checker: Option, } diff --git a/ethcore/src/miner/pool_client.rs b/ethcore/src/miner/pool_client.rs index 60e93dee8ac..98431b45852 100644 --- a/ethcore/src/miner/pool_client.rs +++ b/ethcore/src/miner/pool_client.rs @@ -72,8 +72,8 @@ impl NonceCache { pub struct PoolClient<'a, C: 'a> { chain: &'a C, cached_nonces: CachedNonceClient<'a, C>, - engine: &'a EthEngine, - accounts: &'a LocalAccounts, + engine: &'a dyn EthEngine, + accounts: &'a dyn LocalAccounts, best_block_header: Header, service_transaction_checker: Option<&'a ServiceTransactionChecker>, } @@ -98,8 +98,8 @@ impl<'a, C: 'a> PoolClient<'a, C> where pub fn new( chain: &'a C, cache: &'a NonceCache, - engine: &'a EthEngine, - accounts: &'a LocalAccounts, + engine: &'a dyn EthEngine, + accounts: &'a dyn LocalAccounts, service_transaction_checker: Option<&'a ServiceTransactionChecker>, ) -> Self { let best_block_header = chain.best_block_header(); diff --git a/ethcore/src/pod_account.rs b/ethcore/src/pod_account.rs index c02074f95f9..5bdb05f49d0 100644 --- a/ethcore/src/pod_account.rs +++ b/ethcore/src/pod_account.rs @@ -79,7 +79,7 @@ impl PodAccount { } /// Place additional data into given hash DB. - pub fn insert_additional(&self, db: &mut HashDB, factory: &TrieFactory) { + pub fn insert_additional(&self, db: &mut dyn HashDB, factory: &TrieFactory) { match self.code { Some(ref c) if !c.is_empty() => { db.insert(c); } _ => {} diff --git a/ethcore/src/snapshot/account.rs b/ethcore/src/snapshot/account.rs index d18ecacbc3b..f968705b469 100644 --- a/ethcore/src/snapshot/account.rs +++ b/ethcore/src/snapshot/account.rs @@ -66,7 +66,7 @@ impl CodeState { // account address hash, account properties and the storage. Each item contains at most `max_storage_items` // storage records split according to snapshot format definition. pub fn to_fat_rlps(account_hash: &H256, acc: &BasicAccount, acct_db: &AccountDB, used_code: &mut HashSet, first_chunk_size: usize, max_chunk_size: usize) -> Result, Error> { - let db = &(acct_db as &HashDB<_,_>); + let db = &(acct_db as &dyn HashDB<_,_>); let db = TrieDB::new(db, &acc.storage_root)?; let mut chunks = Vec::new(); let mut db_iter = db.iter()?; diff --git a/ethcore/src/snapshot/consensus/authority.rs b/ethcore/src/snapshot/consensus/authority.rs index 4423e074019..08a1f8afea0 100644 --- a/ethcore/src/snapshot/consensus/authority.rs +++ b/ethcore/src/snapshot/consensus/authority.rs @@ -127,9 +127,9 @@ impl SnapshotComponents for PoaSnapshot { fn rebuilder( &self, chain: BlockChain, - db: Arc, + db: Arc, manifest: &ManifestData, - ) -> Result, ::error::Error> { + ) -> Result, ::error::Error> { Ok(Box::new(ChunkRebuilder { manifest: manifest.clone(), warp_target: None, @@ -164,14 +164,14 @@ struct ChunkRebuilder { manifest: ManifestData, warp_target: Option
, chain: BlockChain, - db: Arc, + db: Arc, had_genesis: bool, // sorted vectors of unverified first blocks in a chunk // and epoch data from last blocks in chunks. // verification for these will be done at the end. unverified_firsts: Vec<(Header, Bytes, H256)>, - last_epochs: Vec<(Header, Box>)>, + last_epochs: Vec<(Header, Box>)>, } // verified data. @@ -183,9 +183,9 @@ struct Verified { impl ChunkRebuilder { fn verify_transition( &mut self, - last_verifier: &mut Option>>, + last_verifier: &mut Option>>, transition_rlp: Rlp, - engine: &EthEngine, + engine: &dyn EthEngine, ) -> Result { use engines::ConstructedVerifier; @@ -241,7 +241,7 @@ impl Rebuilder for ChunkRebuilder { fn feed( &mut self, chunk: &[u8], - engine: &EthEngine, + engine: &dyn EthEngine, abort_flag: &AtomicBool, ) -> Result<(), ::error::Error> { let rlp = Rlp::new(chunk); @@ -349,7 +349,7 @@ impl Rebuilder for ChunkRebuilder { Ok(()) } - fn finalize(&mut self, _engine: &EthEngine) -> Result<(), ::error::Error> { + fn finalize(&mut self, _engine: &dyn EthEngine) -> Result<(), ::error::Error> { if !self.had_genesis { return Err(Error::WrongChunkFormat("No genesis transition included.".into()).into()); } diff --git a/ethcore/src/snapshot/consensus/mod.rs b/ethcore/src/snapshot/consensus/mod.rs index 907e9c520bb..670700c10cf 100644 --- a/ethcore/src/snapshot/consensus/mod.rs +++ b/ethcore/src/snapshot/consensus/mod.rs @@ -33,7 +33,7 @@ pub use self::authority::*; pub use self::work::*; /// A sink for produced chunks. -pub type ChunkSink<'a> = FnMut(&[u8]) -> ::std::io::Result<()> + 'a; +pub type ChunkSink<'a> = dyn FnMut(&[u8]) -> ::std::io::Result<()> + 'a; /// Components necessary for snapshot creation and restoration. pub trait SnapshotComponents: Send { @@ -63,9 +63,9 @@ pub trait SnapshotComponents: Send { fn rebuilder( &self, chain: BlockChain, - db: Arc, + db: Arc, manifest: &ManifestData, - ) -> Result, ::error::Error>; + ) -> Result, ::error::Error>; /// Minimum supported snapshot version number. fn min_supported_version(&self) -> u64; @@ -83,7 +83,7 @@ pub trait Rebuilder: Send { fn feed( &mut self, chunk: &[u8], - engine: &EthEngine, + engine: &dyn EthEngine, abort_flag: &AtomicBool, ) -> Result<(), ::error::Error>; @@ -92,5 +92,5 @@ pub trait Rebuilder: Send { /// /// This should apply the necessary "glue" between chunks, /// and verify against the restored state. - fn finalize(&mut self, engine: &EthEngine) -> Result<(), ::error::Error>; + fn finalize(&mut self, engine: &dyn EthEngine) -> Result<(), ::error::Error>; } diff --git a/ethcore/src/snapshot/consensus/work.rs b/ethcore/src/snapshot/consensus/work.rs index a3d4da1c2ef..201d528d140 100644 --- a/ethcore/src/snapshot/consensus/work.rs +++ b/ethcore/src/snapshot/consensus/work.rs @@ -81,9 +81,9 @@ impl SnapshotComponents for PowSnapshot { fn rebuilder( &self, chain: BlockChain, - db: Arc, + db: Arc, manifest: &ManifestData, - ) -> Result, ::error::Error> { + ) -> Result, ::error::Error> { PowRebuilder::new(chain, db.key_value().clone(), manifest, self.max_restore_blocks).map(|r| Box::new(r) as Box<_>) } @@ -194,7 +194,7 @@ impl<'a> PowWorker<'a> { /// After all chunks have been submitted, we "glue" the chunks together. pub struct PowRebuilder { chain: BlockChain, - db: Arc, + db: Arc, rng: OsRng, disconnected: Vec<(u64, H256)>, best_number: u64, @@ -206,7 +206,7 @@ pub struct PowRebuilder { impl PowRebuilder { /// Create a new PowRebuilder. - fn new(chain: BlockChain, db: Arc, manifest: &ManifestData, snapshot_blocks: u64) -> Result { + fn new(chain: BlockChain, db: Arc, manifest: &ManifestData, snapshot_blocks: u64) -> Result { Ok(PowRebuilder { chain: chain, db: db, @@ -224,7 +224,7 @@ impl PowRebuilder { impl Rebuilder for PowRebuilder { /// Feed the rebuilder an uncompressed block chunk. /// Returns the number of blocks fed or any errors. - fn feed(&mut self, chunk: &[u8], engine: &EthEngine, abort_flag: &AtomicBool) -> Result<(), ::error::Error> { + fn feed(&mut self, chunk: &[u8], engine: &dyn EthEngine, abort_flag: &AtomicBool) -> Result<(), ::error::Error> { use snapshot::verify_old_block; use ethereum_types::U256; use triehash::ordered_trie_root; @@ -298,7 +298,7 @@ impl Rebuilder for PowRebuilder { } /// Glue together any disconnected chunks and check that the chain is complete. - fn finalize(&mut self, _: &EthEngine) -> Result<(), ::error::Error> { + fn finalize(&mut self, _: &dyn EthEngine) -> Result<(), ::error::Error> { let mut batch = self.db.transaction(); for (first_num, first_hash) in self.disconnected.drain(..) { diff --git a/ethcore/src/snapshot/error.rs b/ethcore/src/snapshot/error.rs index 0eba4725569..91b6dc67cc8 100644 --- a/ethcore/src/snapshot/error.rs +++ b/ethcore/src/snapshot/error.rs @@ -71,7 +71,7 @@ pub enum Error { } impl error::Error for Error { - fn source(&self) -> Option<&(error::Error + 'static)> { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { Error::Trie(e) => Some(e), Error::Decoder(e) => Some(e), diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index 155182ed516..84905f580f7 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -148,10 +148,10 @@ impl Progress { } /// Take a snapshot using the given blockchain, starting block hash, and database, writing into the given writer. pub fn take_snapshot( - engine: &EthEngine, + engine: &dyn EthEngine, chain: &BlockChain, block_at: H256, - state_db: &HashDB, + state_db: &dyn HashDB, writer: W, p: &Progress, processing_threads: usize, @@ -228,7 +228,7 @@ pub fn take_snapshot( /// Secondary chunks are engine-specific, but they intend to corroborate the state data /// in the state chunks. /// Returns a list of chunk hashes, with the first having the blocks furthest from the genesis. -pub fn chunk_secondary<'a>(mut chunker: Box, chain: &'a BlockChain, start_hash: H256, writer: &Mutex, progress: &'a Progress) -> Result, Error> { +pub fn chunk_secondary<'a>(mut chunker: Box, chain: &'a BlockChain, start_hash: H256, writer: &Mutex, progress: &'a Progress) -> Result, Error> { let mut chunk_hashes = Vec::new(); let mut snappy_buffer = vec![0; snappy::max_compressed_len(PREFERRED_CHUNK_SIZE)]; @@ -266,7 +266,7 @@ struct StateChunker<'a> { rlps: Vec, cur_size: usize, snappy_buffer: Vec, - writer: &'a Mutex, + writer: &'a Mutex, progress: &'a Progress, } @@ -321,7 +321,7 @@ impl<'a> StateChunker<'a> { /// /// Returns a list of hashes of chunks created, or any error it may /// have encountered. -pub fn chunk_state<'a>(db: &HashDB, root: &H256, writer: &Mutex, progress: &'a Progress, part: Option) -> Result, Error> { +pub fn chunk_state<'a>(db: &dyn HashDB, root: &H256, writer: &Mutex, progress: &'a Progress, part: Option) -> Result, Error> { let account_trie = TrieDB::new(&db, &root)?; let mut chunker = StateChunker { @@ -383,7 +383,7 @@ pub fn chunk_state<'a>(db: &HashDB, root: &H256, writer: /// Used to rebuild the state trie piece by piece. pub struct StateRebuilder { - db: Box, + db: Box, state_root: H256, known_code: HashMap, // code hashes mapped to first account with this code. missing_code: HashMap>, // maps code hashes to lists of accounts missing that code. @@ -393,7 +393,7 @@ pub struct StateRebuilder { impl StateRebuilder { /// Create a new state rebuilder to write into the given backing DB. - pub fn new(db: Arc, pruning: Algorithm) -> Self { + pub fn new(db: Arc, pruning: Algorithm) -> Self { StateRebuilder { db: journaldb::new(db.clone(), pruning, ::db::COL_STATE), state_root: KECCAK_NULL_RLP, @@ -468,7 +468,7 @@ impl StateRebuilder { /// Finalize the restoration. Check for accounts missing code and make a dummy /// journal entry. /// Once all chunks have been fed, there should be nothing missing. - pub fn finalize(mut self, era: u64, id: H256) -> Result, ::error::Error> { + pub fn finalize(mut self, era: u64, id: H256) -> Result, ::error::Error> { let missing = self.missing_code.keys().cloned().collect::>(); if !missing.is_empty() { return Err(Error::MissingCode(missing).into()) } @@ -493,7 +493,7 @@ struct RebuiltStatus { // rebuild a set of accounts and their storage. // returns a status detailing newly-loaded code and accounts missing code. fn rebuild_accounts( - db: &mut HashDB, + db: &mut dyn HashDB, account_fat_rlps: Rlp, out_chunk: &mut [(H256, Bytes)], known_code: &HashMap, @@ -560,7 +560,7 @@ const POW_VERIFY_RATE: f32 = 0.02; /// Verify an old block with the given header, engine, blockchain, body. If `always` is set, it will perform /// the fullest verification possible. If not, it will take a random sample to determine whether it will /// do heavy or light verification. -pub fn verify_old_block(rng: &mut OsRng, header: &Header, engine: &EthEngine, chain: &BlockChain, always: bool) -> Result<(), ::error::Error> { +pub fn verify_old_block(rng: &mut OsRng, header: &Header, engine: &dyn EthEngine, chain: &BlockChain, always: bool) -> Result<(), ::error::Error> { engine.verify_block_basic(header)?; if always || rng.gen::() <= POW_VERIFY_RATE { diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index 8120f47b81f..0c26f095e26 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -76,22 +76,22 @@ struct Restoration { state_chunks_left: HashSet, block_chunks_left: HashSet, state: StateRebuilder, - secondary: Box, + secondary: Box, writer: Option, snappy_buffer: Bytes, final_state_root: H256, guard: Guard, - db: Arc, + db: Arc, } struct RestorationParams<'a> { manifest: ManifestData, // manifest to base restoration on. pruning: Algorithm, // pruning algorithm for the database. - db: Arc, // database + db: Arc, // database writer: Option, // writer for recovered snapshot. genesis: &'a [u8], // genesis block of the chain. guard: Guard, // guard for the restoration directory. - engine: &'a EthEngine, + engine: &'a dyn EthEngine, } impl Restoration { @@ -149,7 +149,7 @@ impl Restoration { } // feeds a block chunk - fn feed_blocks(&mut self, hash: H256, chunk: &[u8], engine: &EthEngine, flag: &AtomicBool) -> Result<(), Error> { + fn feed_blocks(&mut self, hash: H256, chunk: &[u8], engine: &dyn EthEngine, flag: &AtomicBool) -> Result<(), Error> { if self.block_chunks_left.contains(&hash) { let expected_len = snappy::decompressed_len(chunk)?; if expected_len > MAX_CHUNK_SIZE { @@ -170,7 +170,7 @@ impl Restoration { } // finish up restoration. - fn finalize(mut self, engine: &EthEngine) -> Result<(), Error> { + fn finalize(mut self, engine: &dyn EthEngine) -> Result<(), Error> { use trie::TrieError; if !self.is_done() { return Ok(()) } @@ -211,37 +211,37 @@ pub trait SnapshotClient: BlockChainClient + BlockInfo + DatabaseRestore {} /// Snapshot service parameters. pub struct ServiceParams { /// The consensus engine this is built on. - pub engine: Arc, + pub engine: Arc, /// The chain's genesis block. pub genesis_block: Bytes, /// State pruning algorithm. pub pruning: Algorithm, /// Handler for opening a restoration DB. - pub restoration_db_handler: Box, + pub restoration_db_handler: Box, /// Async IO channel for sending messages. pub channel: Channel, /// The directory to put snapshots in. /// Usually "/snapshot" pub snapshot_root: PathBuf, /// A handle for database restoration. - pub client: Arc, + pub client: Arc, } /// `SnapshotService` implementation. /// This controls taking snapshots and restoring from them. pub struct Service { restoration: Mutex>, - restoration_db_handler: Box, + restoration_db_handler: Box, snapshot_root: PathBuf, io_channel: Mutex, pruning: Algorithm, status: Mutex, reader: RwLock>, - engine: Arc, + engine: Arc, genesis_block: Bytes, state_chunks: AtomicUsize, block_chunks: AtomicUsize, - client: Arc, + client: Arc, progress: super::Progress, taking_snapshot: AtomicBool, restoring_snapshot: AtomicBool, diff --git a/ethcore/src/snapshot/tests/helpers.rs b/ethcore/src/snapshot/tests/helpers.rs index a70c7b7e272..96c5c51b023 100644 --- a/ethcore/src/snapshot/tests/helpers.rs +++ b/ethcore/src/snapshot/tests/helpers.rs @@ -62,7 +62,7 @@ impl StateProducer { /// Tick the state producer. This alters the state, writing new data into /// the database. - pub fn tick(&mut self, rng: &mut R, db: &mut HashDB) { + pub fn tick(&mut self, rng: &mut R, db: &mut dyn HashDB) { // modify existing accounts. let mut accounts_to_modify: Vec<_> = { let trie = TrieDB::new(&db, &self.state_root).unwrap(); @@ -132,7 +132,7 @@ pub fn fill_storage(mut db: AccountDBMut, root: &mut H256, seed: &mut H256) { /// Take a snapshot from the given client into a temporary file. /// Return a snapshot reader for it. -pub fn snap(client: &Client) -> (Box, TempDir) { +pub fn snap(client: &Client) -> (Box, TempDir) { use types::ids::BlockId; let tempdir = TempDir::new("").unwrap(); @@ -151,9 +151,9 @@ pub fn snap(client: &Client) -> (Box, TempDir) { /// Restore a snapshot into a given database. This will read chunks from the given reader /// write into the given database. pub fn restore( - db: Arc, - engine: &EthEngine, - reader: &SnapshotReader, + db: Arc, + engine: &dyn EthEngine, + reader: &dyn SnapshotReader, genesis: &[u8], ) -> Result<(), ::error::Error> { use std::sync::atomic::AtomicBool; diff --git a/ethcore/src/snapshot/watcher.rs b/ethcore/src/snapshot/watcher.rs index 9df21c3cd83..06df0c9cc42 100644 --- a/ethcore/src/snapshot/watcher.rs +++ b/ethcore/src/snapshot/watcher.rs @@ -72,8 +72,8 @@ impl Broadcast for Mutex> { /// A `ChainNotify` implementation which will trigger a snapshot event /// at certain block numbers. pub struct Watcher { - oracle: Box, - broadcast: Box, + oracle: Box, + broadcast: Box, period: u64, history: u64, } diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index fd00dd56f08..87822226127 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -382,7 +382,7 @@ pub struct Spec { /// User friendly spec name pub name: String, /// What engine are we using for this? - pub engine: Arc, + pub engine: Arc, /// Name of the subdir inside the main data dir to use for chain data and settings. pub data_dir: String, @@ -601,7 +601,7 @@ impl Spec { engine_spec: ethjson::spec::Engine, params: CommonParams, builtins: BTreeMap, - ) -> Arc { + ) -> Arc { let machine = Self::machine(&engine_spec, params, builtins); match engine_spec { diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 36260ca2cdc..5daaa139839 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -217,7 +217,7 @@ impl Account { /// Get (and cache) the contents of the trie's storage at `key`. /// Takes modified storage into account. - pub fn storage_at(&self, db: &HashDB, key: &H256) -> TrieResult { + pub fn storage_at(&self, db: &dyn HashDB, key: &H256) -> TrieResult { if let Some(value) = self.cached_storage_at(key) { return Ok(value); } @@ -230,7 +230,7 @@ impl Account { /// Get (and cache) the contents of the trie's storage at `key`. /// Does not take modified storage into account. - pub fn original_storage_at(&self, db: &HashDB, key: &H256) -> TrieResult { + pub fn original_storage_at(&self, db: &dyn HashDB, key: &H256) -> TrieResult { if let Some(value) = self.cached_original_storage_at(key) { return Ok(value); } @@ -252,7 +252,7 @@ impl Account { } } - fn get_and_cache_storage(storage_root: &H256, storage_cache: &mut LruCache, db: &HashDB, key: &H256) -> TrieResult { + fn get_and_cache_storage(storage_root: &H256, storage_cache: &mut LruCache, db: &dyn HashDB, key: &H256) -> TrieResult { let db = SecTrieDB::new(&db, storage_root)?; let panicky_decoder = |bytes:&[u8]| ::rlp::decode(&bytes).expect("decoding db value failed"); let item: U256 = db.get_with(key.as_bytes(), panicky_decoder)?.unwrap_or_else(U256::zero); @@ -358,7 +358,7 @@ impl Account { /// Provide a database to get `code_hash`. Should not be called if it is a contract without code. Returns the cached code, if successful. #[must_use] - pub fn cache_code(&mut self, db: &HashDB) -> Option> { + pub fn cache_code(&mut self, db: &dyn HashDB) -> Option> { // TODO: fill out self.code_cache; trace!("Account::cache_code: ic={}; self.code_hash={:?}, self.code_cache={}", self.is_cached(), self.code_hash, self.code_cache.pretty()); @@ -388,7 +388,7 @@ impl Account { /// Provide a database to get `code_size`. Should not be called if it is a contract without code. Returns whether /// the cache succeeds. #[must_use] - pub fn cache_code_size(&mut self, db: &HashDB) -> bool { + pub fn cache_code_size(&mut self, db: &dyn HashDB) -> bool { // TODO: fill out self.code_cache; trace!("Account::cache_code_size: ic={}; self.code_hash={:?}, self.code_cache={}", self.is_cached(), self.code_hash, self.code_cache.pretty()); self.code_size.is_some() || @@ -482,7 +482,7 @@ impl Account { } /// Commit the `storage_changes` to the backing DB and update `storage_root`. - pub fn commit_storage(&mut self, trie_factory: &TrieFactory, db: &mut HashDB) -> TrieResult<()> { + pub fn commit_storage(&mut self, trie_factory: &TrieFactory, db: &mut dyn HashDB) -> TrieResult<()> { let mut t = trie_factory.from_existing(db, &mut self.storage_root)?; for (k, v) in self.storage_changes.drain() { // cast key and value to trait type, @@ -499,7 +499,7 @@ impl Account { } /// Commit any unsaved code. `code_hash` will always return the hash of the `code_cache` after this. - pub fn commit_code(&mut self, db: &mut HashDB) { + pub fn commit_code(&mut self, db: &mut dyn HashDB) { trace!("Commiting code of {:?} - {:?}, {:?}", self, self.code_filth == Filth::Dirty, self.code_cache.is_empty()); match (self.code_filth == Filth::Dirty, self.code_cache.is_empty()) { (true, true) => { @@ -588,7 +588,7 @@ impl Account { /// trie. /// `storage_key` is the hash of the desired storage key, meaning /// this will only work correctly under a secure trie. - pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { + pub fn prove_storage(&self, db: &dyn HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); let trie = TrieDB::new(&db, &self.storage_root)?; diff --git a/ethcore/src/state/backend.rs b/ethcore/src/state/backend.rs index 11e73edb3ab..9d9a2a9b388 100644 --- a/ethcore/src/state/backend.rs +++ b/ethcore/src/state/backend.rs @@ -36,10 +36,10 @@ use journaldb::AsKeyedHashDB; /// State backend. See module docs for more details. pub trait Backend: Send { /// Treat the backend as a read-only hashdb. - fn as_hash_db(&self) -> &HashDB; + fn as_hash_db(&self) -> &dyn HashDB; /// Treat the backend as a writeable hashdb. - fn as_hash_db_mut(&mut self) -> &mut HashDB; + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB; /// Add an account entry to the cache. fn add_to_account_cache(&mut self, addr: Address, data: Option, modified: bool); @@ -114,13 +114,13 @@ impl HashDB for ProofCheck { } impl AsHashDB for ProofCheck { - fn as_hash_db(&self) -> &HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } } impl Backend for ProofCheck { - fn as_hash_db(&self) -> &HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } fn add_to_account_cache(&mut self, _addr: Address, _data: Option, _modified: bool) {} fn cache_code(&self, _hash: H256, _code: Arc>) {} fn get_cached_account(&self, _addr: &Address) -> Option> { None } @@ -146,12 +146,12 @@ pub struct Proving { } impl AsKeyedHashDB for Proving { - fn as_keyed_hash_db(&self) -> &journaldb::KeyedHashDB { self } + fn as_keyed_hash_db(&self) -> &dyn journaldb::KeyedHashDB { self } } impl + Send + Sync> AsHashDB for Proving { - fn as_hash_db(&self) -> &HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } } impl journaldb::KeyedHashDB for Proving { @@ -194,9 +194,9 @@ impl + Send + Sync> HashDB + Send + Sync> Backend for Proving { - fn as_hash_db(&self) -> &HashDB { self } + fn as_hash_db(&self) -> &dyn HashDB { self } - fn as_hash_db_mut(&mut self) -> &mut HashDB { self } + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self } fn add_to_account_cache(&mut self, _: Address, _: Option, _: bool) { } @@ -248,11 +248,11 @@ impl + Clone> Clone for Proving { pub struct Basic(pub H); impl + Send + Sync> Backend for Basic { - fn as_hash_db(&self) -> &HashDB { + fn as_hash_db(&self) -> &dyn HashDB { self.0.as_hash_db() } - fn as_hash_db_mut(&mut self) -> &mut HashDB { + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self.0.as_hash_db_mut() } diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index d0d57287dce..95e31489c84 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -638,7 +638,7 @@ impl State { &self, address: &Address, key: &H256, f_cached_at: FCachedStorageAt, f_at: FStorageAt, ) -> TrieResult where FCachedStorageAt: Fn(&Account, &H256) -> Option, - FStorageAt: Fn(&Account, &HashDB, &H256) -> TrieResult + FStorageAt: Fn(&Account, &dyn HashDB, &H256) -> TrieResult { // Storage key search and update works like this: // 1. If there's an entry for the account in the local cache check for the key and return it if found. @@ -1101,7 +1101,7 @@ impl State { /// Load required account data from the databases. Returns whether the cache succeeds. #[must_use] - fn update_account_cache(require: RequireCache, account: &mut Account, state_db: &B, db: &HashDB) -> bool { + fn update_account_cache(require: RequireCache, account: &mut Account, state_db: &B, db: &dyn HashDB) -> bool { if let RequireCache::None = require { return true; } diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs index 2613411e4e0..132677ab5cf 100644 --- a/ethcore/src/state_db.rs +++ b/ethcore/src/state_db.rs @@ -107,7 +107,7 @@ struct BlockChanges { /// `StateDB` is propagated into the global cache. pub struct StateDB { /// Backing database. - db: Box, + db: Box, /// Shared canonical state cache. account_cache: Arc>, /// DB Code cache. Maps code hashes to shared bytes. @@ -132,7 +132,7 @@ impl StateDB { /// of the LRU cache in bytes. Actual used memory may (read: will) be higher due to bookkeeping. // TODO: make the cache size actually accurate by moving the account storage cache // into the `AccountCache` structure as its own `LruCache<(Address, H256), H256>`. - pub fn new(db: Box, cache_size: usize) -> StateDB { + pub fn new(db: Box, cache_size: usize) -> StateDB { let bloom = Self::load_bloom(&**db.backing()); let acc_cache_size = cache_size * ACCOUNT_CACHE_RATIO / 100; let code_cache_size = cache_size - acc_cache_size; @@ -156,7 +156,7 @@ impl StateDB { /// Loads accounts bloom from the database /// This bloom is used to handle request for the non-existant account fast - pub fn load_bloom(db: &KeyValueDB) -> Bloom { + pub fn load_bloom(db: &dyn KeyValueDB) -> Bloom { let hash_count_entry = db.get(COL_ACCOUNT_BLOOM, ACCOUNT_BLOOM_HASHCOUNT_KEY) .expect("Low-level database error"); @@ -313,12 +313,12 @@ impl StateDB { } /// Conversion method to interpret self as `HashDB` reference - pub fn as_hash_db(&self) -> &HashDB { + pub fn as_hash_db(&self) -> &dyn HashDB { self.db.as_hash_db() } /// Conversion method to interpret self as mutable `HashDB` reference - pub fn as_hash_db_mut(&mut self) -> &mut HashDB { + pub fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self.db.as_hash_db_mut() } @@ -368,7 +368,7 @@ impl StateDB { } /// Returns underlying `JournalDB`. - pub fn journal_db(&self) -> &JournalDB { + pub fn journal_db(&self) -> &dyn JournalDB { &*self.db } @@ -407,9 +407,9 @@ impl StateDB { } impl state::Backend for StateDB { - fn as_hash_db(&self) -> &HashDB { self.db.as_hash_db() } + fn as_hash_db(&self) -> &dyn HashDB { self.db.as_hash_db() } - fn as_hash_db_mut(&mut self) -> &mut HashDB { + fn as_hash_db_mut(&mut self) -> &mut dyn HashDB { self.db.as_hash_db_mut() } diff --git a/ethcore/src/test_helpers.rs b/ethcore/src/test_helpers.rs index e59a41d34b4..6bdaeadf9bd 100644 --- a/ethcore/src/test_helpers.rs +++ b/ethcore/src/test_helpers.rs @@ -267,11 +267,11 @@ struct TestBlockChainDB { _trace_blooms_dir: TempDir, blooms: blooms_db::Database, trace_blooms: blooms_db::Database, - key_value: Arc, + key_value: Arc, } impl BlockChainDB for TestBlockChainDB { - fn key_value(&self) -> &Arc { + fn key_value(&self) -> &Arc { &self.key_value } @@ -285,7 +285,7 @@ impl BlockChainDB for TestBlockChainDB { } /// Creates new test instance of `BlockChainDB` -pub fn new_db() -> Arc { +pub fn new_db() -> Arc { let blooms_dir = TempDir::new("").unwrap(); let trace_blooms_dir = TempDir::new("").unwrap(); @@ -301,7 +301,7 @@ pub fn new_db() -> Arc { } /// Creates a new temporary `BlockChainDB` on FS -pub fn new_temp_db(tempdir: &Path) -> Arc { +pub fn new_temp_db(tempdir: &Path) -> Arc { let blooms_dir = TempDir::new("").unwrap(); let trace_blooms_dir = TempDir::new("").unwrap(); let key_value_dir = tempdir.join("key_value"); @@ -321,7 +321,7 @@ pub fn new_temp_db(tempdir: &Path) -> Arc { } /// Creates new instance of KeyValueDBHandler -pub fn restoration_db_handler(config: kvdb_rocksdb::DatabaseConfig) -> Box { +pub fn restoration_db_handler(config: kvdb_rocksdb::DatabaseConfig) -> Box { struct RestorationDBHandler { config: kvdb_rocksdb::DatabaseConfig, } @@ -329,11 +329,11 @@ pub fn restoration_db_handler(config: kvdb_rocksdb::DatabaseConfig) -> Box, + key_value: Arc, } impl BlockChainDB for RestorationDB { - fn key_value(&self) -> &Arc { + fn key_value(&self) -> &Arc { &self.key_value } @@ -347,7 +347,7 @@ pub fn restoration_db_handler(config: kvdb_rocksdb::DatabaseConfig) -> Box io::Result> { + fn open(&self, db_path: &Path) -> io::Result> { let key_value = Arc::new(kvdb_rocksdb::Database::open(&self.config, &db_path.to_string_lossy())?); let blooms_path = db_path.join("blooms"); let trace_blooms_path = db_path.join("trace_blooms"); diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 2ee521a4ad6..4c8c2cd7f0e 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -64,7 +64,7 @@ pub struct TraceDB where T: DatabaseExtras { /// hashes of cached traces cache_manager: RwLock>, /// db - db: Arc, + db: Arc, /// tracing enabled enabled: bool, /// extras @@ -73,7 +73,7 @@ pub struct TraceDB where T: DatabaseExtras { impl TraceDB where T: DatabaseExtras { /// Creates new instance of `TraceDB`. - pub fn new(config: Config, db: Arc, extras: Arc) -> Self { + pub fn new(config: Config, db: Arc, extras: Arc) -> Self { let mut batch = DBTransaction::new(); let genesis = extras.block_hash(0) .expect("Genesis block is always inserted upon extras db creation qed"); diff --git a/ethcore/src/verification/canon_verifier.rs b/ethcore/src/verification/canon_verifier.rs index 03a1c7155f8..76f37c19df0 100644 --- a/ethcore/src/verification/canon_verifier.rs +++ b/ethcore/src/verification/canon_verifier.rs @@ -32,7 +32,7 @@ impl Verifier for CanonVerifier { &self, header: &Header, parent: &Header, - engine: &EthEngine, + engine: &dyn EthEngine, do_full: Option>, ) -> Result<(), Error> { verification::verify_block_family(header, parent, engine, do_full) @@ -42,7 +42,7 @@ impl Verifier for CanonVerifier { verification::verify_block_final(expected, got) } - fn verify_block_external(&self, header: &Header, engine: &EthEngine) -> Result<(), Error> { + fn verify_block_external(&self, header: &Header, engine: &dyn EthEngine) -> Result<(), Error> { engine.verify_block_external(header) } } diff --git a/ethcore/src/verification/mod.rs b/ethcore/src/verification/mod.rs index 5546bd60c91..37c721ab1b8 100644 --- a/ethcore/src/verification/mod.rs +++ b/ethcore/src/verification/mod.rs @@ -44,7 +44,7 @@ pub enum VerifierType { } /// Create a new verifier based on type. -pub fn new(v: VerifierType) -> Box> { +pub fn new(v: VerifierType) -> Box> { match v { VerifierType::Canon | VerifierType::CanonNoSeal => Box::new(CanonVerifier), VerifierType::Noop => Box::new(NoopVerifier), diff --git a/ethcore/src/verification/noop_verifier.rs b/ethcore/src/verification/noop_verifier.rs index d68f1eb8856..3b646ed9e40 100644 --- a/ethcore/src/verification/noop_verifier.rs +++ b/ethcore/src/verification/noop_verifier.rs @@ -32,7 +32,7 @@ impl Verifier for NoopVerifier { &self, _: &Header, _t: &Header, - _: &EthEngine, + _: &dyn EthEngine, _: Option> ) -> Result<(), Error> { Ok(()) @@ -42,7 +42,7 @@ impl Verifier for NoopVerifier { Ok(()) } - fn verify_block_external(&self, _header: &Header, _engine: &EthEngine) -> Result<(), Error> { + fn verify_block_external(&self, _header: &Header, _engine: &dyn EthEngine) -> Result<(), Error> { Ok(()) } } diff --git a/ethcore/src/verification/queue/kind.rs b/ethcore/src/verification/queue/kind.rs index d8f4dd4034c..ed96ebc9d0e 100644 --- a/ethcore/src/verification/queue/kind.rs +++ b/ethcore/src/verification/queue/kind.rs @@ -58,10 +58,10 @@ pub trait Kind: 'static + Sized + Send + Sync { type Verified: Sized + Send + BlockLike + HeapSizeOf; /// Attempt to create the `Unverified` item from the input. - fn create(input: Self::Input, engine: &EthEngine, check_seal: bool) -> Result; + fn create(input: Self::Input, engine: &dyn EthEngine, check_seal: bool) -> Result; /// Attempt to verify the `Unverified` item using the given engine. - fn verify(unverified: Self::Unverified, engine: &EthEngine, check_seal: bool) -> Result; + fn verify(unverified: Self::Unverified, engine: &dyn EthEngine, check_seal: bool) -> Result; } /// The blocks verification module. @@ -86,7 +86,7 @@ pub mod blocks { type Unverified = Unverified; type Verified = PreverifiedBlock; - fn create(input: Self::Input, engine: &EthEngine, check_seal: bool) -> Result { + fn create(input: Self::Input, engine: &dyn EthEngine, check_seal: bool) -> Result { match verify_block_basic(&input, engine, check_seal) { Ok(()) => Ok(input), Err(Error::Block(BlockError::TemporarilyInvalid(oob))) => { @@ -100,7 +100,7 @@ pub mod blocks { } } - fn verify(un: Self::Unverified, engine: &EthEngine, check_seal: bool) -> Result { + fn verify(un: Self::Unverified, engine: &dyn EthEngine, check_seal: bool) -> Result { let hash = un.hash(); match verify_block_unordered(un, engine, check_seal) { Ok(verified) => Ok(verified), @@ -209,14 +209,14 @@ pub mod headers { type Unverified = Header; type Verified = Header; - fn create(input: Self::Input, engine: &EthEngine, check_seal: bool) -> Result { + fn create(input: Self::Input, engine: &dyn EthEngine, check_seal: bool) -> Result { match verify_header_params(&input, engine, true, check_seal) { Ok(_) => Ok(input), Err(err) => Err((input, err)) } } - fn verify(unverified: Self::Unverified, engine: &EthEngine, check_seal: bool) -> Result { + fn verify(unverified: Self::Unverified, engine: &dyn EthEngine, check_seal: bool) -> Result { match check_seal { true => engine.verify_block_unordered(&unverified,).map(|_| unverified), false => Ok(unverified), diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 79801019d3f..3f3484ddc44 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -138,7 +138,7 @@ struct Sizes { /// A queue of items to be verified. Sits between network or other I/O and the `BlockChain`. /// Keeps them in the same order as inserted, minus invalid items. pub struct VerificationQueue { - engine: Arc, + engine: Arc, more_to_verify: Arc, verification: Arc>, deleting: Arc, @@ -206,7 +206,7 @@ struct Verification { impl VerificationQueue { /// Creates a new queue instance. - pub fn new(config: Config, engine: Arc, message_channel: IoChannel, check_seal: bool) -> Self { + pub fn new(config: Config, engine: Arc, message_channel: IoChannel, check_seal: bool) -> Self { let verification = Arc::new(Verification { unverified: LenCachingMutex::new(VecDeque::new()), verifying: LenCachingMutex::new(VecDeque::new()), @@ -293,7 +293,7 @@ impl VerificationQueue { fn verify( verification: Arc>, - engine: Arc, + engine: Arc, wait: Arc, ready: Arc, empty: Arc, diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index eff7ae406cc..fa458803cd5 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -64,7 +64,7 @@ impl HeapSizeOf for PreverifiedBlock { } /// Phase 1 quick block verification. Only does checks that are cheap. Operates on a single block -pub fn verify_block_basic(block: &Unverified, engine: &EthEngine, check_seal: bool) -> Result<(), Error> { +pub fn verify_block_basic(block: &Unverified, engine: &dyn EthEngine, check_seal: bool) -> Result<(), Error> { verify_header_params(&block.header, engine, true, check_seal)?; verify_block_integrity(block)?; @@ -89,7 +89,7 @@ pub fn verify_block_basic(block: &Unverified, engine: &EthEngine, check_seal: bo /// Phase 2 verification. Perform costly checks such as transaction signatures and block nonce for ethash. /// Still operates on a individual block /// Returns a `PreverifiedBlock` structure populated with transactions -pub fn verify_block_unordered(block: Unverified, engine: &EthEngine, check_seal: bool) -> Result { +pub fn verify_block_unordered(block: Unverified, engine: &dyn EthEngine, check_seal: bool) -> Result { let header = block.header; if check_seal { engine.verify_block_unordered(&header)?; @@ -131,14 +131,14 @@ pub struct FullFamilyParams<'a, C: BlockInfo + CallContract + 'a> { pub block: &'a PreverifiedBlock, /// Block provider to use during verification - pub block_provider: &'a BlockProvider, + pub block_provider: &'a dyn BlockProvider, /// Engine client to use during verification pub client: &'a C, } /// Phase 3 verification. Check block information against parent and uncles. -pub fn verify_block_family(header: &Header, parent: &Header, engine: &EthEngine, do_full: Option>) -> Result<(), Error> { +pub fn verify_block_family(header: &Header, parent: &Header, engine: &dyn EthEngine, do_full: Option>) -> Result<(), Error> { // TODO: verify timestamp verify_parent(&header, &parent, engine)?; engine.verify_block_family(&header, &parent)?; @@ -159,7 +159,7 @@ pub fn verify_block_family(header: &Header, parent: Ok(()) } -fn verify_uncles(block: &PreverifiedBlock, bc: &BlockProvider, engine: &EthEngine) -> Result<(), Error> { +fn verify_uncles(block: &PreverifiedBlock, bc: &dyn BlockProvider, engine: &dyn EthEngine) -> Result<(), Error> { let header = &block.header; let num_uncles = block.uncles.len(); let max_uncles = engine.maximum_uncle_count(header.number()); @@ -267,7 +267,7 @@ pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error> } /// Check basic header parameters. -pub fn verify_header_params(header: &Header, engine: &EthEngine, is_full: bool, check_seal: bool) -> Result<(), Error> { +pub fn verify_header_params(header: &Header, engine: &dyn EthEngine, is_full: bool, check_seal: bool) -> Result<(), Error> { if check_seal { let expected_seal_fields = engine.seal_fields(header); if header.seal().len() != expected_seal_fields { @@ -326,7 +326,7 @@ pub fn verify_header_params(header: &Header, engine: &EthEngine, is_full: bool, } /// Check header parameters agains parent header. -fn verify_parent(header: &Header, parent: &Header, engine: &EthEngine) -> Result<(), Error> { +fn verify_parent(header: &Header, parent: &Header, engine: &dyn EthEngine) -> Result<(), Error> { assert!(header.parent_hash().is_zero() || &parent.hash() == header.parent_hash(), "Parent hash should already have been verified; qed"); @@ -516,12 +516,12 @@ mod tests { } } - fn basic_test(bytes: &[u8], engine: &EthEngine) -> Result<(), Error> { + fn basic_test(bytes: &[u8], engine: &dyn EthEngine) -> Result<(), Error> { let unverified = Unverified::from_rlp(bytes.to_vec())?; verify_block_basic(&unverified, engine, true) } - fn family_test(bytes: &[u8], engine: &EthEngine, bc: &BC) -> Result<(), Error> where BC: BlockProvider { + fn family_test(bytes: &[u8], engine: &dyn EthEngine, bc: &BC) -> Result<(), Error> where BC: BlockProvider { let block = Unverified::from_rlp(bytes.to_vec()).unwrap(); let header = block.header; let transactions: Vec<_> = block.transactions @@ -547,13 +547,13 @@ mod tests { let full_params = FullFamilyParams { block: &block, - block_provider: bc as &BlockProvider, + block_provider: bc as &dyn BlockProvider, client: &client, }; verify_block_family(&block.header, &parent, engine, Some(full_params)) } - fn unordered_test(bytes: &[u8], engine: &EthEngine) -> Result<(), Error> { + fn unordered_test(bytes: &[u8], engine: &dyn EthEngine) -> Result<(), Error> { let un = Unverified::from_rlp(bytes.to_vec())?; verify_block_unordered(un, engine, false)?; Ok(()) diff --git a/ethcore/src/verification/verifier.rs b/ethcore/src/verification/verifier.rs index f7221dae81d..309e596aa78 100644 --- a/ethcore/src/verification/verifier.rs +++ b/ethcore/src/verification/verifier.rs @@ -32,12 +32,12 @@ pub trait Verifier: Send + Sync &self, header: &Header, parent: &Header, - engine: &EthEngine, + engine: &dyn EthEngine, do_full: Option> ) -> Result<(), Error>; /// Do a final verification check for an enacted header vs its expected counterpart. fn verify_block_final(&self, expected: &Header, got: &Header) -> Result<(), Error>; /// Verify a block, inspecting external state. - fn verify_block_external(&self, header: &Header, engine: &EthEngine) -> Result<(), Error>; + fn verify_block_external(&self, header: &Header, engine: &dyn EthEngine) -> Result<(), Error>; }