removed EthEngine alias (#10805)

This commit is contained in:
Marek Kotewicz 2019-06-28 16:18:18 +08:00 committed by Andronik Ordian
parent cff1bc88fa
commit 7f02a08741
28 changed files with 112 additions and 121 deletions

View File

@ -21,7 +21,7 @@ use std::sync::Arc;
use common_types::encoded;
use common_types::header::Header;
use common_types::receipt::Receipt;
use ethcore::engines::{EthEngine, StateDependentProof};
use ethcore::engines::{Engine, StateDependentProof};
use ethereum_types::H256;
use futures::future::IntoFuture;
@ -47,7 +47,7 @@ pub trait ChainDataFetcher: Send + Sync + 'static {
fn epoch_transition(
&self,
_hash: H256,
_engine: Arc<EthEngine>,
_engine: Arc<Engine>,
_checker: Arc<StateDependentProof>
) -> Self::Transition;
}
@ -76,7 +76,7 @@ impl ChainDataFetcher for Unavailable {
fn epoch_transition(
&self,
_hash: H256,
_engine: Arc<EthEngine>,
_engine: Arc<Engine>,
_checker: Arc<StateDependentProof>
) -> Self::Transition {
Err("fetching epoch transition proofs unavailable")

View File

@ -19,7 +19,7 @@
use std::sync::{Weak, Arc};
use ethcore::client::{ClientReport, EnvInfo, ClientIoMessage};
use ethcore::engines::{epoch, EthEngine, EpochChange, EpochTransition, Proof};
use ethcore::engines::{epoch, Engine, EpochChange, EpochTransition, Proof};
use ethcore::error::{Error, EthcoreResult};
use ethcore::verification::queue::{self, HeaderQueue};
use ethcore::spec::{Spec, SpecHardcodedSync};
@ -114,7 +114,7 @@ pub trait LightChainClient: Send + Sync {
fn env_info(&self, id: BlockId) -> Option<EnvInfo>;
/// Get a handle to the consensus engine.
fn engine(&self) -> &Arc<EthEngine>;
fn engine(&self) -> &Arc<Engine>;
/// Query whether a block is known.
fn is_known(&self, hash: &H256) -> bool;
@ -159,7 +159,7 @@ impl<T: LightChainClient> AsLightClient for T {
/// Light client implementation.
pub struct Client<T> {
queue: HeaderQueue,
engine: Arc<EthEngine>,
engine: Arc<Engine>,
chain: HeaderChain,
report: RwLock<ClientReport>,
import_lock: Mutex<()>,
@ -375,7 +375,7 @@ impl<T: ChainDataFetcher> Client<T> {
}
/// Get a handle to the verification engine.
pub fn engine(&self) -> &Arc<EthEngine> {
pub fn engine(&self) -> &Arc<Engine> {
&self.engine
}
@ -578,7 +578,7 @@ impl<T: ChainDataFetcher> LightChainClient for Client<T> {
Client::env_info(self, id)
}
fn engine(&self) -> &Arc<EthEngine> {
fn engine(&self) -> &Arc<Engine> {
Client::engine(self)
}

View File

@ -24,7 +24,7 @@ use common_types::basic_account::BasicAccount;
use common_types::encoded;
use common_types::receipt::Receipt;
use common_types::transaction::SignedTransaction;
use ethcore::engines::{EthEngine, StateDependentProof};
use ethcore::engines::{Engine, StateDependentProof};
use ethcore::state::{self, ProvedExecution};
use ethereum_types::{H256, U256, Address};
use ethtrie::{TrieError, TrieDB};
@ -1037,7 +1037,7 @@ pub struct TransactionProof {
// TODO: it's not really possible to provide this if the header is unknown.
pub env_info: EnvInfo,
/// Consensus engine.
pub engine: Arc<EthEngine>,
pub engine: Arc<Engine>,
}
impl TransactionProof {
@ -1080,7 +1080,7 @@ pub struct Signal {
/// Block hash and number to fetch proof for.
pub hash: H256,
/// Consensus engine, used to check the proof.
pub engine: Arc<EthEngine>,
pub engine: Arc<Engine>,
/// Special checker for the proof.
pub proof_check: Arc<StateDependentProof>,
}

View File

@ -38,7 +38,7 @@ use std::sync::Arc;
use bytes::Bytes;
use ethereum_types::{H256, U256, Address, Bloom};
use engines::EthEngine;
use engines::Engine;
use error::{Error, BlockError};
use factory::Factories;
use state_db::StateDB;
@ -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 dyn EthEngine,
engine: &'x dyn Engine,
}
/// 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<Item = ExtendedHeader>>(
engine: &'x dyn EthEngine,
engine: &'x dyn Engine,
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: &dyn EthEngine) -> OpenBlock {
pub fn reopen(self, engine: &dyn Engine) -> 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: &dyn EthEngine, seal: Vec<Bytes>) -> Result<SealedBlock, Error> {
pub fn seal(self, engine: &dyn Engine, 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 {
@ -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: &dyn EthEngine,
engine: &dyn Engine,
seal: Vec<Bytes>,
) -> Result<SealedBlock, Error> {
let mut s = self;
@ -472,7 +472,7 @@ pub(crate) fn enact(
header: Header,
transactions: Vec<SignedTransaction>,
uncles: Vec<Header>,
engine: &dyn EthEngine,
engine: &dyn Engine,
tracing: bool,
db: StateDB,
parent: &Header,
@ -525,7 +525,7 @@ 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: &dyn EthEngine,
engine: &dyn Engine,
tracing: bool,
db: StateDB,
parent: &Header,
@ -554,7 +554,7 @@ pub fn enact_verified(
mod tests {
use test_helpers::get_temp_state_db;
use super::*;
use engines::EthEngine;
use engines::Engine;
use vm::LastHashes;
use error::Error;
use factory::Factories;
@ -571,7 +571,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: &dyn EthEngine,
engine: &dyn Engine,
tracing: bool,
db: StateDB,
parent: &Header,
@ -624,7 +624,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: &dyn EthEngine,
engine: &dyn Engine,
tracing: bool,
db: StateDB,
parent: &Header,

View File

@ -18,7 +18,7 @@
use std::sync::Arc;
use engines::{EthEngine, EpochVerifier};
use engines::{Engine, EpochVerifier};
use blockchain::BlockChain;
use parking_lot::RwLock;
@ -32,12 +32,12 @@ const HEAVY_VERIFY_RATE: f32 = 0.02;
/// epoch.
pub struct AncientVerifier {
cur_verifier: RwLock<Option<Box<dyn EpochVerifier>>>,
engine: Arc<dyn EthEngine>,
engine: Arc<dyn Engine>,
}
impl AncientVerifier {
/// Create a new ancient block verifier with the given engine.
pub fn new(engine: Arc<dyn EthEngine>) -> Self {
pub fn new(engine: Arc<dyn Engine>) -> Self {
AncientVerifier {
cur_verifier: RwLock::new(None),
engine,

View File

@ -60,7 +60,7 @@ use client::{
IoClient, BadBlocks,
};
use client::bad_blocks;
use engines::{MAX_UNCLE_AGE, EthEngine, EpochTransition, ForkChoice, EngineError, SealingState};
use engines::{MAX_UNCLE_AGE, Engine, EpochTransition, ForkChoice, EngineError, SealingState};
use engines::epoch::PendingTransition;
use error::{
ImportError, ExecutionError, CallError, BlockError,
@ -165,7 +165,7 @@ struct Importer {
pub ancient_verifier: AncientVerifier,
/// Ethereum engine to be used during import
pub engine: Arc<dyn EthEngine>,
pub engine: Arc<dyn Engine>,
/// A lru cache of recently detected bad blocks
pub bad_blocks: bad_blocks::BadBlocks,
@ -187,7 +187,7 @@ pub struct Client {
chain: RwLock<Arc<BlockChain>>,
tracedb: RwLock<TraceDB<BlockChain>>,
engine: Arc<dyn EthEngine>,
engine: Arc<dyn Engine>,
/// Client configuration
config: ClientConfig,
@ -245,7 +245,7 @@ pub struct Client {
impl Importer {
pub fn new(
config: &ClientConfig,
engine: Arc<dyn EthEngine>,
engine: Arc<dyn Engine>,
message_channel: IoChannel<ClientIoMessage>,
miner: Arc<Miner>,
) -> Result<Importer, ::error::Error> {
@ -857,7 +857,7 @@ impl Client {
}
/// Returns engine reference.
pub fn engine(&self) -> &dyn EthEngine {
pub fn engine(&self) -> &dyn Engine {
&*self.engine
}
@ -1661,7 +1661,7 @@ impl Call for Client {
}
impl EngineInfo for Client {
fn engine(&self) -> &dyn EthEngine {
fn engine(&self) -> &dyn Engine {
Client::engine(self)
}
}

View File

@ -59,7 +59,7 @@ use client::{
Call, StateClient, EngineInfo, AccountData, BlockChain, BlockProducer, SealedBlockImporter, IoClient,
BadBlocks
};
use engines::EthEngine;
use engines::Engine;
use error::{Error, EthcoreResult};
use executed::CallError;
use executive::Executed;
@ -627,7 +627,7 @@ impl StateClient for TestBlockChainClient {
}
impl EngineInfo for TestBlockChainClient {
fn engine(&self) -> &dyn EthEngine {
fn engine(&self) -> &dyn Engine {
unimplemented!()
}
}

View File

@ -43,7 +43,7 @@ use vm::LastHashes;
use block::{OpenBlock, SealedBlock, ClosedBlock};
use client::Mode;
use engines::EthEngine;
use engines::Engine;
use error::{Error, EthcoreResult};
use executed::CallError;
use executive::Executed;
@ -184,7 +184,7 @@ pub trait Call {
/// Provides `engine` method
pub trait EngineInfo {
/// Get underlying engine object
fn engine(&self) -> &dyn EthEngine;
fn engine(&self) -> &dyn Engine;
}
/// IO operations that should off-load heavy work to another thread.

View File

@ -1636,7 +1636,7 @@ mod tests {
};
use spec::Spec;
use types::transaction::{Action, Transaction};
use engines::{Seal, Engine, EngineError, EthEngine};
use engines::{Seal, Engine, EngineError};
use engines::validator_set::{TestSet, SimpleList};
use error::Error;
use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score};
@ -1942,14 +1942,14 @@ mod tests {
(spec, tap, accounts)
}
fn empty_step(engine: &dyn EthEngine, step: u64, parent_hash: &H256) -> EmptyStep {
fn empty_step(engine: &dyn Engine, 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: &dyn EthEngine, step: u64, parent_hash: &H256) -> SealedEmptyStep {
fn sealed_empty_step(engine: &dyn Engine, 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 }

View File

@ -475,22 +475,7 @@ pub trait Engine: Sync + Send {
fn executive_author(&self, header: &Header) -> Result<Address, Error> {
Ok(*header.author())
}
}
/// Check whether a given block is the best block based on the default total difficulty rule.
pub fn total_difficulty_fork_choice(new: &ExtendedHeader, best: &ExtendedHeader) -> ForkChoice {
if new.total_score() > best.total_score() {
ForkChoice::New
} else {
ForkChoice::Old
}
}
/// Common type alias for an engine coupled with an Ethereum-like state machine.
// TODO: make this a _trait_ alias when those exist.
// fortunately the effect is largely the same since engines are mostly used
// via trait objects.
pub trait EthEngine: Engine {
/// Get the general parameters of the chain.
fn params(&self) -> &CommonParams {
self.machine().params()
@ -569,8 +554,14 @@ pub trait EthEngine: Engine {
}
}
// convenience wrappers for existing functions.
impl<T> EthEngine for T where T: Engine { }
/// Check whether a given block is the best block based on the default total difficulty rule.
pub fn total_difficulty_fork_choice(new: &ExtendedHeader, best: &ExtendedHeader) -> ForkChoice {
if new.total_score() > best.total_score() {
ForkChoice::New
} else {
ForkChoice::Old
}
}
/// Verifier for all blocks within an epoch with self-contained state.
pub trait EpochVerifier: Send + Sync {

View File

@ -53,7 +53,7 @@ use client::{
BlockChain, ChainInfo, BlockProducer, SealedBlockImporter, Nonce, TransactionInfo, TransactionId
};
use client::{BlockId, ClientIoMessage};
use engines::{EthEngine, Seal, SealingState, EngineSigner};
use engines::{Engine, Seal, SealingState, EngineSigner};
use error::Error;
use executed::ExecutionError;
use executive::contract_address;
@ -245,7 +245,7 @@ pub struct Miner {
options: MinerOptions,
// TODO [ToDr] Arc is only required because of price updater
transaction_queue: Arc<TransactionQueue>,
engine: Arc<dyn EthEngine>,
engine: Arc<dyn Engine>,
accounts: Arc<dyn LocalAccounts>,
io_channel: RwLock<Option<IoChannel<ClientIoMessage>>>,
service_transaction_checker: Option<ServiceTransactionChecker>,

View File

@ -37,7 +37,7 @@ use parking_lot::RwLock;
use call_contract::CallContract;
use client::{TransactionId, BlockInfo, Nonce};
use engines::EthEngine;
use engines::Engine;
use miner;
use transaction_ext::Transaction;
@ -72,7 +72,7 @@ impl NonceCache {
pub struct PoolClient<'a, C: 'a> {
chain: &'a C,
cached_nonces: CachedNonceClient<'a, C>,
engine: &'a dyn EthEngine,
engine: &'a dyn Engine,
accounts: &'a dyn LocalAccounts,
best_block_header: Header,
service_transaction_checker: Option<&'a ServiceTransactionChecker>,
@ -98,7 +98,7 @@ impl<'a, C: 'a> PoolClient<'a, C> where
pub fn new(
chain: &'a C,
cache: &'a NonceCache,
engine: &'a dyn EthEngine,
engine: &'a dyn Engine,
accounts: &'a dyn LocalAccounts,
service_transaction_checker: Option<&'a ServiceTransactionChecker>,
) -> Self {

View File

@ -24,7 +24,7 @@ use super::{SnapshotComponents, Rebuilder, ChunkSink};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use engines::{EthEngine, EpochVerifier, EpochTransition};
use engines::{Engine, EpochVerifier, EpochTransition};
use snapshot::{Error, ManifestData, Progress};
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
@ -184,7 +184,7 @@ impl ChunkRebuilder {
&mut self,
last_verifier: &mut Option<Box<dyn EpochVerifier>>,
transition_rlp: Rlp,
engine: &dyn EthEngine,
engine: &dyn Engine,
) -> Result<Verified, ::error::Error> {
use engines::ConstructedVerifier;
@ -240,7 +240,7 @@ impl Rebuilder for ChunkRebuilder {
fn feed(
&mut self,
chunk: &[u8],
engine: &dyn EthEngine,
engine: &dyn Engine,
abort_flag: &AtomicBool,
) -> Result<(), ::error::Error> {
let rlp = Rlp::new(chunk);
@ -348,7 +348,7 @@ impl Rebuilder for ChunkRebuilder {
Ok(())
}
fn finalize(&mut self, _engine: &dyn EthEngine) -> Result<(), ::error::Error> {
fn finalize(&mut self, _engine: &dyn Engine) -> Result<(), ::error::Error> {
if !self.had_genesis {
return Err(Error::WrongChunkFormat("No genesis transition included.".into()).into());
}

View File

@ -21,7 +21,7 @@ use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use blockchain::{BlockChain, BlockChainDB};
use engines::EthEngine;
use engines::Engine;
use snapshot::{Error, ManifestData, Progress};
use ethereum_types::H256;
@ -83,7 +83,7 @@ pub trait Rebuilder: Send {
fn feed(
&mut self,
chunk: &[u8],
engine: &dyn EthEngine,
engine: &dyn Engine,
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: &dyn EthEngine) -> Result<(), ::error::Error>;
fn finalize(&mut self, engine: &dyn Engine) -> Result<(), ::error::Error>;
}

View File

@ -27,7 +27,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
use engines::EthEngine;
use engines::Engine;
use snapshot::{Error, ManifestData, Progress};
use snapshot::block::AbridgedBlock;
use ethereum_types::H256;
@ -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: &dyn EthEngine, abort_flag: &AtomicBool) -> Result<(), ::error::Error> {
fn feed(&mut self, chunk: &[u8], engine: &dyn Engine, 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, _: &dyn EthEngine) -> Result<(), ::error::Error> {
fn finalize(&mut self, _: &dyn Engine) -> Result<(), ::error::Error> {
let mut batch = self.db.transaction();
for (first_num, first_hash) in self.disconnected.drain(..) {

View File

@ -27,7 +27,7 @@ use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY};
use account_db::{AccountDB, AccountDBMut};
use blockchain::{BlockChain, BlockProvider};
use engines::EthEngine;
use engines::Engine;
use types::header::Header;
use types::ids::BlockId;
@ -578,7 +578,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: &dyn EthEngine, chain: &BlockChain, always: bool) -> Result<(), ::error::Error> {
pub fn verify_old_block(rng: &mut OsRng, header: &Header, engine: &dyn Engine, chain: &BlockChain, always: bool) -> Result<(), ::error::Error> {
engine.verify_block_basic(header)?;
if always || rng.gen::<f32>() <= POW_VERIFY_RATE {

View File

@ -29,7 +29,7 @@ use super::io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter};
use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler};
use client::{BlockInfo, BlockChainClient, Client, ChainInfo, ClientIoMessage};
use engines::EthEngine;
use engines::Engine;
use error::Error;
use snapshot::{Error as SnapshotError};
use hash::keccak;
@ -91,7 +91,7 @@ struct RestorationParams<'a> {
writer: Option<LooseWriter>, // writer for recovered snapshot.
genesis: &'a [u8], // genesis block of the chain.
guard: Guard, // guard for the restoration directory.
engine: &'a dyn EthEngine,
engine: &'a dyn Engine,
}
impl Restoration {
@ -149,7 +149,7 @@ impl Restoration {
}
// feeds a block chunk
fn feed_blocks(&mut self, hash: H256, chunk: &[u8], engine: &dyn EthEngine, flag: &AtomicBool) -> Result<(), Error> {
fn feed_blocks(&mut self, hash: H256, chunk: &[u8], engine: &dyn Engine, 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: &dyn EthEngine) -> Result<(), Error> {
fn finalize(mut self, engine: &dyn Engine) -> Result<(), Error> {
use trie::TrieError;
if !self.is_done() { return Ok(()) }
@ -211,7 +211,7 @@ pub trait SnapshotClient: BlockChainClient + BlockInfo + DatabaseRestore {}
/// Snapshot service parameters.
pub struct ServiceParams {
/// The consensus engine this is built on.
pub engine: Arc<dyn EthEngine>,
pub engine: Arc<dyn Engine>,
/// The chain's genesis block.
pub genesis_block: Bytes,
/// State pruning algorithm.
@ -237,7 +237,7 @@ pub struct Service {
pruning: Algorithm,
status: Mutex<RestorationStatus>,
reader: RwLock<Option<LooseReader>>,
engine: Arc<dyn EthEngine>,
engine: Arc<dyn Engine>,
genesis_block: Bytes,
state_chunks: AtomicUsize,
block_chunks: AtomicUsize,

View File

@ -26,7 +26,7 @@ use account_db::AccountDBMut;
use types::basic_account::BasicAccount;
use blockchain::{BlockChain, BlockChainDB};
use client::{Client, ChainInfo};
use engines::EthEngine;
use engines::Engine;
use snapshot::{StateRebuilder};
use snapshot::io::{SnapshotReader, PackedWriter, PackedReader};
@ -152,7 +152,7 @@ pub fn snap(client: &Client) -> (Box<dyn SnapshotReader>, TempDir) {
/// write into the given database.
pub fn restore(
db: Arc<dyn BlockChainDB>,
engine: &dyn EthEngine,
engine: &dyn Engine,
reader: &dyn SnapshotReader,
genesis: &[u8],
) -> Result<(), ::error::Error> {

View File

@ -35,7 +35,7 @@ use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType};
use builtin::Builtin;
use engines::{
EthEngine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority, Clique,
Engine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority, Clique,
AuthorityRound, DEFAULT_BLOCKHASH_CONTRACT
};
use error::Error;
@ -382,7 +382,7 @@ pub struct Spec {
/// User friendly spec name
pub name: String,
/// What engine are we using for this?
pub engine: Arc<dyn EthEngine>,
pub engine: Arc<dyn Engine>,
/// 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<Address, Builtin>,
) -> Arc<dyn EthEngine> {
) -> Arc<dyn Engine> {
let machine = Self::machine(&engine_spec, params, builtins);
match engine_spec {

View File

@ -18,7 +18,7 @@
use call_contract::CallContract;
use client::BlockInfo;
use engines::EthEngine;
use engines::Engine;
use error::Error;
use types::header::Header;
use super::Verifier;
@ -32,7 +32,7 @@ impl<C: BlockInfo + CallContract> Verifier<C> for CanonVerifier {
&self,
header: &Header,
parent: &Header,
engine: &dyn EthEngine,
engine: &dyn Engine,
do_full: Option<verification::FullFamilyParams<C>>,
) -> Result<(), Error> {
verification::verify_block_family(header, parent, engine, do_full)
@ -42,7 +42,7 @@ impl<C: BlockInfo + CallContract> Verifier<C> for CanonVerifier {
verification::verify_block_final(expected, got)
}
fn verify_block_external(&self, header: &Header, engine: &dyn EthEngine) -> Result<(), Error> {
fn verify_block_external(&self, header: &Header, engine: &dyn Engine) -> Result<(), Error> {
engine.verify_block_external(header)
}
}

View File

@ -18,7 +18,7 @@
use call_contract::CallContract;
use client::BlockInfo;
use engines::EthEngine;
use engines::Engine;
use error::Error;
use types::header::Header;
use super::{verification, Verifier};
@ -32,7 +32,7 @@ impl<C: BlockInfo + CallContract> Verifier<C> for NoopVerifier {
&self,
_: &Header,
_t: &Header,
_: &dyn EthEngine,
_: &dyn Engine,
_: Option<verification::FullFamilyParams<C>>
) -> Result<(), Error> {
Ok(())
@ -42,7 +42,7 @@ impl<C: BlockInfo + CallContract> Verifier<C> for NoopVerifier {
Ok(())
}
fn verify_block_external(&self, _header: &Header, _engine: &dyn EthEngine) -> Result<(), Error> {
fn verify_block_external(&self, _header: &Header, _engine: &dyn Engine) -> Result<(), Error> {
Ok(())
}
}

View File

@ -16,7 +16,7 @@
//! Definition of valid items for the verification queue.
use engines::EthEngine;
use engines::Engine;
use error::Error;
use parity_util_mem::MallocSizeOf;
@ -58,17 +58,17 @@ pub trait Kind: 'static + Sized + Send + Sync {
type Verified: Sized + Send + BlockLike + MallocSizeOf;
/// Attempt to create the `Unverified` item from the input.
fn create(input: Self::Input, engine: &dyn EthEngine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)>;
fn create(input: Self::Input, engine: &dyn Engine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)>;
/// Attempt to verify the `Unverified` item using the given engine.
fn verify(unverified: Self::Unverified, engine: &dyn EthEngine, check_seal: bool) -> Result<Self::Verified, Error>;
fn verify(unverified: Self::Unverified, engine: &dyn Engine, check_seal: bool) -> Result<Self::Verified, Error>;
}
/// The blocks verification module.
pub mod blocks {
use super::{Kind, BlockLike};
use engines::EthEngine;
use engines::Engine;
use error::{Error, BlockError};
use types::header::Header;
use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered};
@ -86,7 +86,7 @@ pub mod blocks {
type Unverified = Unverified;
type Verified = PreverifiedBlock;
fn create(input: Self::Input, engine: &dyn EthEngine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)> {
fn create(input: Self::Input, engine: &dyn Engine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)> {
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: &dyn EthEngine, check_seal: bool) -> Result<Self::Verified, Error> {
fn verify(un: Self::Unverified, engine: &dyn Engine, check_seal: bool) -> Result<Self::Verified, Error> {
let hash = un.hash();
match verify_block_unordered(un, engine, check_seal) {
Ok(verified) => Ok(verified),
@ -179,7 +179,7 @@ pub mod blocks {
pub mod headers {
use super::{Kind, BlockLike};
use engines::EthEngine;
use engines::Engine;
use error::Error;
use types::header::Header;
use verification::verify_header_params;
@ -200,14 +200,14 @@ pub mod headers {
type Unverified = Header;
type Verified = Header;
fn create(input: Self::Input, engine: &dyn EthEngine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)> {
fn create(input: Self::Input, engine: &dyn Engine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)> {
match verify_header_params(&input, engine, true, check_seal) {
Ok(_) => Ok(input),
Err(err) => Err((input, err))
}
}
fn verify(unverified: Self::Unverified, engine: &dyn EthEngine, check_seal: bool) -> Result<Self::Verified, Error> {
fn verify(unverified: Self::Unverified, engine: &dyn Engine, check_seal: bool) -> Result<Self::Verified, Error> {
match check_seal {
true => engine.verify_block_unordered(&unverified,).map(|_| unverified),
false => Ok(unverified),

View File

@ -27,7 +27,7 @@ use ethereum_types::{H256, U256};
use parking_lot::{Condvar, Mutex, RwLock};
use io::*;
use error::{BlockError, ImportError, Error};
use engines::EthEngine;
use engines::Engine;
use client::ClientIoMessage;
use len_caching_lock::LenCachingMutex;
@ -133,7 +133,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<K: Kind> {
engine: Arc<dyn EthEngine>,
engine: Arc<dyn Engine>,
more_to_verify: Arc<Condvar>,
verification: Arc<Verification<K>>,
deleting: Arc<AtomicBool>,
@ -201,7 +201,7 @@ struct Verification<K: Kind> {
impl<K: Kind> VerificationQueue<K> {
/// Creates a new queue instance.
pub fn new(config: Config, engine: Arc<dyn EthEngine>, message_channel: IoChannel<ClientIoMessage>, check_seal: bool) -> Self {
pub fn new(config: Config, engine: Arc<dyn Engine>, message_channel: IoChannel<ClientIoMessage>, check_seal: bool) -> Self {
let verification = Arc::new(Verification {
unverified: LenCachingMutex::new(VecDeque::new()),
verifying: LenCachingMutex::new(VecDeque::new()),
@ -288,7 +288,7 @@ impl<K: Kind> VerificationQueue<K> {
fn verify(
verification: Arc<Verification<K>>,
engine: Arc<dyn EthEngine>,
engine: Arc<dyn Engine>,
wait: Arc<Condvar>,
ready: Arc<QueueSignal>,
empty: Arc<Condvar>,

View File

@ -34,7 +34,7 @@ use unexpected::{Mismatch, OutOfBounds};
use blockchain::*;
use call_contract::CallContract;
use client::BlockInfo;
use engines::{EthEngine, MAX_UNCLE_AGE};
use engines::{Engine, MAX_UNCLE_AGE};
use error::{BlockError, Error};
use types::{BlockNumber, header::Header};
use types::transaction::SignedTransaction;
@ -56,7 +56,7 @@ pub struct 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: &dyn EthEngine, check_seal: bool) -> Result<(), Error> {
pub fn verify_block_basic(block: &Unverified, engine: &dyn Engine, check_seal: bool) -> Result<(), Error> {
verify_header_params(&block.header, engine, true, check_seal)?;
verify_block_integrity(block)?;
@ -81,7 +81,7 @@ pub fn verify_block_basic(block: &Unverified, engine: &dyn EthEngine, check_seal
/// 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: &dyn EthEngine, check_seal: bool) -> Result<PreverifiedBlock, Error> {
pub fn verify_block_unordered(block: Unverified, engine: &dyn Engine, check_seal: bool) -> Result<PreverifiedBlock, Error> {
let header = block.header;
if check_seal {
engine.verify_block_unordered(&header)?;
@ -130,7 +130,7 @@ pub struct FullFamilyParams<'a, C: BlockInfo + CallContract + 'a> {
}
/// Phase 3 verification. Check block information against parent and uncles.
pub fn verify_block_family<C: BlockInfo + CallContract>(header: &Header, parent: &Header, engine: &dyn EthEngine, do_full: Option<FullFamilyParams<C>>) -> Result<(), Error> {
pub fn verify_block_family<C: BlockInfo + CallContract>(header: &Header, parent: &Header, engine: &dyn Engine, do_full: Option<FullFamilyParams<C>>) -> Result<(), Error> {
// TODO: verify timestamp
verify_parent(&header, &parent, engine)?;
engine.verify_block_family(&header, &parent)?;
@ -151,7 +151,7 @@ pub fn verify_block_family<C: BlockInfo + CallContract>(header: &Header, parent:
Ok(())
}
fn verify_uncles(block: &PreverifiedBlock, bc: &dyn BlockProvider, engine: &dyn EthEngine) -> Result<(), Error> {
fn verify_uncles(block: &PreverifiedBlock, bc: &dyn BlockProvider, engine: &dyn Engine) -> Result<(), Error> {
let header = &block.header;
let num_uncles = block.uncles.len();
let max_uncles = engine.maximum_uncle_count(header.number());
@ -259,7 +259,7 @@ pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error>
}
/// Check basic header parameters.
pub fn verify_header_params(header: &Header, engine: &dyn EthEngine, is_full: bool, check_seal: bool) -> Result<(), Error> {
pub fn verify_header_params(header: &Header, engine: &dyn Engine, 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 {
@ -318,7 +318,7 @@ pub fn verify_header_params(header: &Header, engine: &dyn EthEngine, is_full: bo
}
/// Check header parameters agains parent header.
fn verify_parent(header: &Header, parent: &Header, engine: &dyn EthEngine) -> Result<(), Error> {
fn verify_parent(header: &Header, parent: &Header, engine: &dyn Engine) -> Result<(), Error> {
assert!(header.parent_hash().is_zero() || &parent.hash() == header.parent_hash(),
"Parent hash should already have been verified; qed");
@ -381,7 +381,7 @@ mod tests {
use blockchain::{BlockDetails, TransactionAddress, BlockReceipts};
use types::encoded;
use hash::keccak;
use engines::EthEngine;
use engines::Engine;
use error::BlockError::*;
use ethkey::{Random, Generator};
use spec::{CommonParams, Spec};
@ -508,12 +508,12 @@ mod tests {
}
}
fn basic_test(bytes: &[u8], engine: &dyn EthEngine) -> Result<(), Error> {
fn basic_test(bytes: &[u8], engine: &dyn Engine) -> Result<(), Error> {
let unverified = Unverified::from_rlp(bytes.to_vec())?;
verify_block_basic(&unverified, engine, true)
}
fn family_test<BC>(bytes: &[u8], engine: &dyn EthEngine, bc: &BC) -> Result<(), Error> where BC: BlockProvider {
fn family_test<BC>(bytes: &[u8], engine: &dyn Engine, 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
@ -545,7 +545,7 @@ mod tests {
verify_block_family(&block.header, &parent, engine, Some(full_params))
}
fn unordered_test(bytes: &[u8], engine: &dyn EthEngine) -> Result<(), Error> {
fn unordered_test(bytes: &[u8], engine: &dyn Engine) -> Result<(), Error> {
let un = Unverified::from_rlp(bytes.to_vec())?;
verify_block_unordered(un, engine, false)?;
Ok(())

View File

@ -18,7 +18,7 @@
use call_contract::CallContract;
use client::BlockInfo;
use engines::EthEngine;
use engines::Engine;
use error::Error;
use types::header::Header;
use super::verification;
@ -32,12 +32,12 @@ pub trait Verifier<C>: Send + Sync
&self,
header: &Header,
parent: &Header,
engine: &dyn EthEngine,
engine: &dyn Engine,
do_full: Option<verification::FullFamilyParams<C>>
) -> 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: &dyn EthEngine) -> Result<(), Error>;
fn verify_block_external(&self, header: &Header, engine: &dyn Engine) -> Result<(), Error>;
}

View File

@ -16,7 +16,7 @@
use std::sync::{Arc, Weak};
use ethcore::engines::{EthEngine, StateDependentProof};
use ethcore::engines::{Engine, StateDependentProof};
use sync::{LightSync, LightNetworkDispatcher};
use types::encoded;
use types::header::Header;
@ -81,7 +81,7 @@ impl ChainDataFetcher for EpochFetch {
}
/// Fetch epoch transition proof at given header.
fn epoch_transition(&self, hash: H256, engine: Arc<EthEngine>, checker: Arc<StateDependentProof>)
fn epoch_transition(&self, hash: H256, engine: Arc<Engine>, checker: Arc<StateDependentProof>)
-> Self::Transition
{
self.request(request::Signal {

View File

@ -737,7 +737,7 @@ where
tx: EthTransaction,
hdr: encoded::Header,
env_info: ::vm::EnvInfo,
engine: Arc<::ethcore::engines::EthEngine>,
engine: Arc<::ethcore::engines::Engine>,
on_demand: Arc<OD>,
sync: Arc<S>,
}

View File

@ -22,7 +22,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap};
use bytes::Bytes;
use ethcore::block::SealedBlock;
use ethcore::client::{Nonce, PrepareOpenBlock, StateClient, EngineInfo};
use ethcore::engines::{EthEngine, signer::EngineSigner};
use ethcore::engines::{Engine, signer::EngineSigner};
use ethcore::error::Error;
use ethcore::miner::{self, MinerService, AuthoringParams};
use ethereum_types::{H256, U256, Address};
@ -99,7 +99,7 @@ impl StateClient for TestMinerService {
}
impl EngineInfo for TestMinerService {
fn engine(&self) -> &EthEngine {
fn engine(&self) -> &Engine {
unimplemented!()
}
}