Extract the Engine trait (#10958)

* Add client-traits crate
Move the BlockInfo trait to new crate

* New crate `machine`
Contains code extracted from ethcore that defines `Machine`, `Externalities` and other execution related code.

* Use new machine and client-traits crates in ethcore

* Use new crates machine and client-traits instead of ethcore where appropriate

* Fix tests

* Don't re-export so many types from ethcore::client

* Fixing more fallout from removing re-export

* fix test

* More fallout from not re-exporting types

* Add some docs

* cleanup

* import the macro edition style

* Tweak docs

* Add missing import

* remove unused ethabi_derive imports

* Use latest ethabi-contract

* Move many traits from ethcore/client/traits to client-traits crate
Initial version of extracted Engine trait

* Move snapshot related traits to the engine crate (eew)

* Move a few snapshot related types to common_types
Cleanup Executed as exported from machine crate

* fix warning

* Gradually introduce new engine crate: snapshot

* ethcore typechecks with new engine crate

* Sort out types outside ethcore

* Add an EpochVerifier to ethash and use that in Engine.epoch_verifier()
Cleanup

* Document pub members

* Sort out tests
Sort out default impls for EpochVerifier

* Add test-helpers feature and move EngineSigner impl to the right place

* Sort out tests

* Sort out tests and refactor verification types

* Fix missing traits

* More missing traits
Fix Histogram

* Fix tests and cleanup

* cleanup

* Put back needed logger import

* Don't rexport common_types from ethcore/src/client
Don't export ethcore::client::*

* Remove files no longer used
Use types from the engine crate
Explicit exports from engine::engine

* Get rid of itertools

* Move a few more traits from ethcore to client-traits: BlockChainReset, ScheduleInfo, StateClient

* Move ProvingBlockChainClient to client-traits

* Don't re-export ForkChoice and Transition from ethcore

* Address grumbles: sort imports, remove commented out code

* Fix merge resolution error

* merge failure
This commit is contained in:
David
2019-08-15 17:59:22 +02:00
committed by GitHub
parent 1ba4df08f9
commit 6a9de9b11e
142 changed files with 1853 additions and 1484 deletions

View File

@@ -133,7 +133,7 @@ mod accounts {
}
pub fn miner_author(spec: &SpecType, dirs: &Directories, account_provider: &Arc<AccountProvider>, engine_signer: Address, passwords: &[Password]) -> Result<Option<::ethcore::miner::Author>, String> {
use ethcore::engines::EngineSigner;
use engine::signer::EngineSigner;
// Check if engine signer exists
if !account_provider.has_account(engine_signer) {

View File

@@ -26,13 +26,12 @@ use hash::{keccak, KECCAK_NULL_RLP};
use ethereum_types::{U256, H256, Address};
use bytes::ToPretty;
use rlp::PayloadInfo;
use client_traits::BlockInfo;
use ethcore::client::{
Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, ImportBlock, BlockChainReset
use client_traits::{BlockInfo, BlockChainReset, Nonce, Balance, BlockChainClient, ImportBlock};
use ethcore::{
client::{DatabaseCompactionProfile, VMType},
miner::Miner,
verification::queue::VerifierSettings,
};
use ethcore::miner::Miner;
use ethcore::verification::queue::VerifierSettings;
use ethcore::verification::queue::kind::blocks::Unverified;
use ethcore_service::ClientService;
use cache::CacheConfig;
use informant::{Informant, FullNodeInformantData, MillisecondDuration};
@@ -45,7 +44,9 @@ use db;
use ansi_term::Colour;
use types::{
ids::BlockId,
errors::{ImportError, EthcoreError}
errors::{ImportError, EthcoreError},
client_types::Mode,
verification::Unverified,
};
#[derive(Debug, PartialEq)]

View File

@@ -21,7 +21,7 @@ use std::fs::File;
use std::collections::HashSet;
use ethereum_types::{U256, Address};
use journaldb::Algorithm;
use ethcore::client::{Mode, VMType, DatabaseCompactionProfile, ClientConfig, VerifierType};
use ethcore::client::{VMType, DatabaseCompactionProfile, ClientConfig, VerifierType};
use ethcore::miner::{PendingSet, Penalization};
use miner::pool::PrioritizationStrategy;
use cache::CacheConfig;
@@ -32,7 +32,10 @@ use sync::{validate_node_url, self};
use db::migrate;
use path;
use ethkey::Password;
use types::ids::BlockId;
use types::{
ids::BlockId,
client_types::Mode,
};
pub fn to_duration(s: &str) -> Result<Duration, String> {
to_seconds(s).map(Duration::from_secs)
@@ -348,10 +351,12 @@ mod tests {
use std::collections::HashSet;
use tempdir::TempDir;
use ethereum_types::U256;
use ethcore::client::Mode;
use ethcore::miner::PendingSet;
use ethkey::Password;
use types::ids::BlockId;
use types::{
ids::BlockId,
client_types::Mode,
};
use super::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_address, to_addresses, to_price, geth_ipc_path, to_bootnodes, join_set, password_from_file};
#[test]

View File

@@ -24,13 +24,14 @@ use std::time::{Instant, Duration};
use atty;
use ethcore::client::{
ChainInfo, BlockChainInfo, BlockChainClient,
BlockQueueInfo, ChainNotify, NewBlocks, ClientReport, Client, ClientIoMessage
ChainNotify, NewBlocks, ClientReport, Client, ClientIoMessage
};
use client_traits::BlockInfo;
use client_traits::{BlockInfo, ChainInfo, BlockChainClient};
use types::{
BlockNumber,
ids::BlockId,
blockchain_info::BlockChainInfo,
verification::VerificationQueueInfo as BlockQueueInfo,
};
use ethcore::snapshot::{RestorationStatus, SnapshotService as SS};
use ethcore::snapshot::service::Service as SnapshotService;

View File

@@ -17,7 +17,7 @@
use std::sync::Arc;
use parity_ipfs_api::{self, AccessControlAllowOrigin, Host, Listening};
use parity_ipfs_api::error::ServerError;
use ethcore::client::BlockChainClient;
use client_traits::BlockChainClient;
#[derive(Debug, PartialEq, Clone)]
pub struct Configuration {

View File

@@ -44,6 +44,7 @@ extern crate cli_signer;
extern crate client_traits;
extern crate common_types as types;
extern crate engine;
extern crate ethcore;
extern crate ethcore_call_contract as call_contract;
extern crate ethcore_db;

View File

@@ -16,11 +16,13 @@
use std::sync::{Arc, Weak};
use ethcore::engines::{Engine, StateDependentProof};
use engine::{Engine, StateDependentProof};
use sync::{LightSync, LightNetworkDispatcher};
use types::encoded;
use types::header::Header;
use types::receipt::Receipt;
use types::{
header::Header,
encoded,
receipt::Receipt,
};
use futures::{future, Future};
use futures::future::Either;

View File

@@ -16,7 +16,7 @@
use std::sync::{Arc, mpsc};
use ethcore::client::BlockChainClient;
use client_traits::BlockChainClient;
use sync::{self, SyncConfig, NetworkConfiguration, Params, ConnectionFilter};
use ethcore::snapshot::SnapshotService;
use light::Provider;

View File

@@ -18,7 +18,6 @@ use std::collections::HashSet;
use std::time::Duration;
use std::{str, fs, fmt};
use ethcore::client::Mode;
use ethcore::spec::{Spec, SpecParams, self};
use ethereum_types::{U256, Address};
use parity_runtime::Executor;
@@ -28,6 +27,7 @@ use miner::gas_pricer::GasPricer;
use miner::gas_price_calibrator::{GasPriceCalibratorOptions, GasPriceCalibrator};
use parity_version::version_data;
use user_defaults::UserDefaults;
use types::client_types::Mode;
#[derive(Debug, PartialEq)]
pub enum SpecType {

View File

@@ -25,7 +25,7 @@ use account_utils::{self, AccountProvider};
use ethcore::client::Client;
use ethcore::miner::Miner;
use ethcore::snapshot::SnapshotService;
use ethcore::client::BlockChainClient;
use client_traits::BlockChainClient;
use sync::SyncState;
use ethcore_logger::RotatingLogger;
use ethcore_private_tx::Provider as PrivateTransactionManager;

View File

@@ -22,8 +22,8 @@ use std::thread;
use ansi_term::Colour;
use bytes::Bytes;
use call_contract::CallContract;
use client_traits::BlockInfo;
use ethcore::client::{Client, Mode, DatabaseCompactionProfile, VMType, BlockChainClient};
use client_traits::{BlockInfo, BlockChainClient};
use ethcore::client::{Client, DatabaseCompactionProfile, VMType};
use ethcore::miner::{self, stratum, Miner, MinerService, MinerOptions};
use ethcore::snapshot::{self, SnapshotConfiguration};
use ethcore::spec::{SpecParams, OptimizeFor};
@@ -41,7 +41,10 @@ use miner::work_notify::WorkPoster;
use node_filter::NodeFilter;
use parity_runtime::Runtime;
use sync::{self, SyncConfig, PrivateTxHandler};
use types::ids::BlockId;
use types::{
client_types::Mode,
ids::BlockId,
};
use parity_rpc::{
Origin, Metadata, NetworkSettings, informant, PubSubSession, FutureResult, FutureResponse, FutureOutput
};

View File

@@ -21,13 +21,17 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
use hash::keccak;
use ethcore::snapshot::{Progress, RestorationStatus, SnapshotConfiguration, SnapshotService as SS};
use ethcore::snapshot::{RestorationStatus, SnapshotConfiguration, SnapshotService as SS};
use ethcore::snapshot::io::{SnapshotReader, PackedReader, PackedWriter};
use ethcore::snapshot::service::Service as SnapshotService;
use ethcore::client::{Mode, DatabaseCompactionProfile, VMType};
use ethcore::client::{DatabaseCompactionProfile, VMType};
use ethcore::miner::Miner;
use ethcore_service::ClientService;
use types::ids::BlockId;
use types::{
ids::BlockId,
snapshot::Progress,
client_types::Mode,
};
use cache::CacheConfig;
use params::{SpecType, Pruning, Switch, tracing_switch_to_bool, fatdb_switch_to_bool};

View File

@@ -22,7 +22,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::de::from_reader;
use serde_json::ser::to_string;
use journaldb::Algorithm;
use ethcore::client::{Mode as ClientMode};
use types::client_types::Mode as ClientMode;
#[derive(Clone)]
pub struct Seconds(Duration);