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:
@@ -16,7 +16,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use types::ids::BlockId;
|
||||
use ethcore::client::{TestBlockChainClient, BlockChainClient, EachBlockWith, ChainInfo};
|
||||
use client_traits::{BlockChainClient, ChainInfo};
|
||||
use ethcore::client::{TestBlockChainClient, EachBlockWith};
|
||||
use client_traits::BlockInfo;
|
||||
use chain::SyncState;
|
||||
use super::helpers::*;
|
||||
|
||||
@@ -18,8 +18,9 @@ use std::sync::Arc;
|
||||
use hash::keccak;
|
||||
use ethereum_types::{U256, Address};
|
||||
use io::{IoHandler, IoChannel};
|
||||
use ethcore::client::{ChainInfo, ClientIoMessage};
|
||||
use ethcore::engines;
|
||||
use client_traits::ChainInfo;
|
||||
use engine::signer;
|
||||
use ethcore::client::{ClientIoMessage};
|
||||
use ethcore::spec;
|
||||
use ethcore::miner::{self, MinerService};
|
||||
use ethkey::{KeyPair, Secret};
|
||||
@@ -49,8 +50,8 @@ fn authority_round() {
|
||||
let io_handler0: Arc<dyn IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(0).chain.clone()));
|
||||
let io_handler1: Arc<dyn IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(1).chain.clone()));
|
||||
// Push transaction to both clients. Only one of them gets lucky to produce a block.
|
||||
net.peer(0).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s0.clone())));
|
||||
net.peer(1).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s1.clone())));
|
||||
net.peer(0).miner.set_author(miner::Author::Sealer(signer::from_keypair(s0.clone())));
|
||||
net.peer(1).miner.set_author(miner::Author::Sealer(signer::from_keypair(s1.clone())));
|
||||
net.peer(0).chain.engine().register_client(Arc::downgrade(&net.peer(0).chain) as _);
|
||||
net.peer(1).chain.engine().register_client(Arc::downgrade(&net.peer(1).chain) as _);
|
||||
net.peer(0).chain.set_io_channel(IoChannel::to_handler(Arc::downgrade(&io_handler1)));
|
||||
|
||||
@@ -22,7 +22,8 @@ use bytes::Bytes;
|
||||
use network::{self, PeerId, ProtocolId, PacketId, SessionInfo};
|
||||
use network::client_version::ClientVersion;
|
||||
use tests::snapshot::*;
|
||||
use ethcore::client::{TestBlockChainClient, BlockChainClient, Client as EthcoreClient,
|
||||
use client_traits::BlockChainClient;
|
||||
use ethcore::client::{TestBlockChainClient, Client as EthcoreClient,
|
||||
ClientConfig, ChainNotify, NewBlocks, ChainMessageType, ClientIoMessage};
|
||||
use ethcore::snapshot::SnapshotService;
|
||||
use ethcore::spec::{self, Spec};
|
||||
|
||||
@@ -19,10 +19,11 @@ use hash::keccak;
|
||||
use io::{IoHandler, IoChannel};
|
||||
use types::transaction::{Transaction, Action};
|
||||
use types::ids::BlockId;
|
||||
use client_traits::BlockChainClient;
|
||||
use engine::signer;
|
||||
use ethcore::{
|
||||
CreateContractAddress,
|
||||
client::{ClientIoMessage, BlockChainClient},
|
||||
engines,
|
||||
client::ClientIoMessage,
|
||||
miner::{self, MinerService},
|
||||
spec::Spec,
|
||||
test_helpers::push_block_with_transactions,
|
||||
@@ -54,8 +55,8 @@ fn send_private_transaction() {
|
||||
let io_handler0: Arc<dyn IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(0).chain.clone()));
|
||||
let io_handler1: Arc<dyn IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(1).chain.clone()));
|
||||
|
||||
net.peer(0).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s0.clone())));
|
||||
net.peer(1).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s1.clone())));
|
||||
net.peer(0).miner.set_author(miner::Author::Sealer(signer::from_keypair(s0.clone())));
|
||||
net.peer(1).miner.set_author(miner::Author::Sealer(signer::from_keypair(s1.clone())));
|
||||
net.peer(0).chain.engine().register_client(Arc::downgrade(&net.peer(0).chain) as _);
|
||||
net.peer(1).chain.engine().register_client(Arc::downgrade(&net.peer(1).chain) as _);
|
||||
net.peer(0).chain.set_io_channel(IoChannel::to_handler(Arc::downgrade(&io_handler0)));
|
||||
|
||||
Reference in New Issue
Block a user