Extract blockchain from ethcore (#10114)

* Split blockchain & db from ethcore.

* Clean up blockchain deps.

* Missing docs.

* Fix blockchain tests.

* Make other crates compile.

* Remove some re-exports.

* Remove types re-export from ethcore.

* Remove EVM dependency from transaction.

* Merge ethcore-transaction with common-types.

* Clean-up ethcore deps a bit.

* remove ethcore from cargo.toml

* Update ethcore/blockchain/src/lib.rs

Co-Authored-By: tomusdrw <tomusdrw@users.noreply.github.com>

* Address review comments.

* Update DB comment.

* Add tracking issue to the TODO and fix typo.

* Common naming for common types.

* Update ethcore/db/src/keys.rs

Co-Authored-By: tomusdrw <tomusdrw@users.noreply.github.com>

* Update ethcore/blockchain/src/generator.rs

Co-Authored-By: tomusdrw <tomusdrw@users.noreply.github.com>

* Try to fix beta tests.
This commit is contained in:
Tomasz Drwięga
2019-01-04 14:05:46 +01:00
committed by Afri Schoedon
parent 3090324366
commit 3650f2d51c
223 changed files with 1428 additions and 1058 deletions

View File

@@ -28,10 +28,10 @@ use network::{NetworkProtocolHandler, NetworkContext, PeerId, ProtocolId,
use types::pruning_info::PruningInfo;
use ethereum_types::{H256, H512, U256};
use io::{TimerToken};
use ethcore::ethstore::ethkey::Secret;
use ethstore::ethkey::Secret;
use ethcore::client::{BlockChainClient, ChainNotify, NewBlocks, ChainMessageType};
use ethcore::snapshot::SnapshotService;
use ethcore::header::BlockNumber;
use types::BlockNumber;
use sync_io::NetSyncIo;
use chain::{ChainSyncApi, SyncStatus as EthSyncStatus};
use std::net::{SocketAddr, AddrParseError};
@@ -48,7 +48,7 @@ use light::net::{
};
use network::IpFilter;
use private_tx::PrivateTxHandler;
use transaction::UnverifiedTransaction;
use types::transaction::UnverifiedTransaction;
/// Parity sync protocol
pub const WARP_SYNC_PROTOCOL_ID: ProtocolId = *b"par";
@@ -594,7 +594,7 @@ impl ChainNotify for EthSync {
struct TxRelay(Arc<BlockChainClient>);
impl LightHandler for TxRelay {
fn on_transactions(&self, ctx: &EventContext, relay: &[::transaction::UnverifiedTransaction]) {
fn on_transactions(&self, ctx: &EventContext, relay: &[::types::transaction::UnverifiedTransaction]) {
trace!(target: "pip", "Relaying {} transactions from peer {}", relay.len(), ctx.peer());
self.0.queue_transactions(relay.iter().map(|tx| ::rlp::encode(tx)).collect(), ctx.peer())
}

View File

@@ -23,7 +23,7 @@ use std::cmp;
use heapsize::HeapSizeOf;
use ethereum_types::H256;
use rlp::{self, Rlp};
use ethcore::header::BlockNumber;
use types::BlockNumber;
use ethcore::client::{BlockStatus, BlockId};
use ethcore::error::{ImportErrorKind, QueueErrorKind, BlockError, Error as EthcoreError, ErrorKind as EthcoreErrorKind};
use sync_io::SyncIo;
@@ -621,7 +621,6 @@ fn all_expected<A, B, F>(values: &[A], expected_values: &[B], is_expected: F) ->
mod tests {
use super::*;
use ethcore::client::TestBlockChainClient;
use ethcore::header::Header as BlockHeader;
use ethcore::spec::Spec;
use ethkey::{Generator,Random};
use hash::keccak;
@@ -629,8 +628,9 @@ mod tests {
use rlp::{encode_list,RlpStream};
use tests::helpers::TestIo;
use tests::snapshot::TestSnapshotService;
use transaction::{Transaction,SignedTransaction};
use types::transaction::{Transaction,SignedTransaction};
use triehash_ethereum::ordered_trie_root;
use types::header::Header as BlockHeader;
fn dummy_header(number: u64, parent_hash: H256) -> BlockHeader {
let mut header = BlockHeader::new();

View File

@@ -22,9 +22,9 @@ use triehash_ethereum::ordered_trie_root;
use bytes::Bytes;
use rlp::{Rlp, RlpStream, DecoderError};
use network;
use ethcore::header::Header as BlockHeader;
use ethcore::verification::queue::kind::blocks::Unverified;
use transaction::UnverifiedTransaction;
use types::transaction::UnverifiedTransaction;
use types::header::Header as BlockHeader;
known_heap_size!(0, HeaderId);
@@ -571,7 +571,7 @@ impl BlockCollection {
mod test {
use super::{BlockCollection, SyncHeader};
use ethcore::client::{TestBlockChainClient, EachBlockWith, BlockId, BlockChainClient};
use ethcore::header::BlockNumber;
use types::BlockNumber;
use ethcore::verification::queue::kind::blocks::Unverified;
use rlp::*;

View File

@@ -17,9 +17,7 @@
use api::WARP_SYNC_PROTOCOL_ID;
use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction};
use bytes::Bytes;
use ethcore::client::{BlockId, BlockStatus};
use ethcore::error::{Error as EthcoreError, ErrorKind as EthcoreErrorKind, ImportErrorKind, BlockError};
use ethcore::header::BlockNumber;
use ethcore::snapshot::{ManifestData, RestorationStatus};
use ethcore::verification::queue::kind::blocks::Unverified;
use ethereum_types::{H256, U256};
@@ -27,10 +25,12 @@ use hash::keccak;
use network::PeerId;
use rlp::Rlp;
use snapshot::ChunkType;
use std::cmp;
use std::mem;
use std::time::Instant;
use std::{mem, cmp};
use sync_io::SyncIo;
use types::BlockNumber;
use types::block_status::BlockStatus;
use types::ids::BlockId;
use super::{
BlockSet,

View File

@@ -104,7 +104,6 @@ use parking_lot::{Mutex, RwLock, RwLockWriteGuard};
use bytes::Bytes;
use rlp::{RlpStream, DecoderError};
use network::{self, PeerId, PacketId};
use ethcore::header::{BlockNumber};
use ethcore::client::{BlockChainClient, BlockStatus, BlockId, BlockChainInfo, BlockQueueInfo};
use ethcore::snapshot::{RestorationStatus};
use sync_io::SyncIo;
@@ -115,7 +114,8 @@ use snapshot::{Snapshot};
use api::{EthProtocolInfo as PeerInfoDigest, WARP_SYNC_PROTOCOL_ID, PriorityTask};
use private_tx::PrivateTxHandler;
use transactions_stats::{TransactionsStats, Stats as TransactionStats};
use transaction::UnverifiedTransaction;
use types::transaction::UnverifiedTransaction;
use types::BlockNumber;
use self::handler::SyncHandler;
use self::propagator::SyncPropagator;
@@ -1339,9 +1339,9 @@ pub mod tests {
use super::*;
use ::SyncConfig;
use super::{PeerInfo, PeerAsking};
use ethcore::header::*;
use ethcore::client::{BlockChainClient, EachBlockWith, TestBlockChainClient, ChainInfo, BlockInfo};
use ethcore::miner::{MinerService, PendingOrdering};
use types::header::Header;
use private_tx::NoopPrivateTxHandler;
pub fn get_dummy_block(order: u32, parent_hash: H256) -> Bytes {

View File

@@ -14,18 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::cmp;
use std::collections::HashSet;
use bytes::Bytes;
use ethereum_types::H256;
use ethcore::client::BlockChainInfo;
use ethcore::header::BlockNumber;
use fastmap::H256FastSet;
use network::{PeerId, PacketId};
use rand::Rng;
use rlp::{Encodable, RlpStream};
use sync_io::SyncIo;
use std::cmp;
use std::collections::HashSet;
use transaction::SignedTransaction;
use types::transaction::SignedTransaction;
use types::BlockNumber;
use types::blockchain_info::BlockChainInfo;
use super::{
random,

View File

@@ -17,12 +17,12 @@
use api::WARP_SYNC_PROTOCOL_ID;
use block_sync::BlockRequest;
use bytes::Bytes;
use ethcore::header::BlockNumber;
use ethereum_types::H256;
use network::{PeerId, PacketId};
use rlp::RlpStream;
use std::time::Instant;
use sync_io::SyncIo;
use types::BlockNumber;
use super::{
BlockSet,

View File

@@ -15,13 +15,13 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use bytes::Bytes;
use ethcore::client::BlockId;
use ethcore::header::BlockNumber;
use ethereum_types::H256;
use network::{self, PeerId};
use parking_lot::RwLock;
use rlp::{Rlp, RlpStream};
use std::cmp;
use types::BlockNumber;
use types::ids::BlockId;
use sync_io::SyncIo;

View File

@@ -22,19 +22,19 @@
//!
extern crate common_types as types;
extern crate env_logger;
extern crate ethcore;
extern crate ethcore_io as io;
extern crate ethcore_network as network;
extern crate ethcore_network_devp2p as devp2p;
extern crate parity_bytes as bytes;
extern crate ethcore_io as io;
extern crate ethcore_transaction as transaction;
extern crate ethcore;
extern crate ethereum_types;
extern crate env_logger;
extern crate ethstore;
extern crate fastmap;
extern crate rand;
extern crate parking_lot;
extern crate rlp;
extern crate keccak_hash as hash;
extern crate parity_bytes as bytes;
extern crate parking_lot;
extern crate rand;
extern crate rlp;
extern crate triehash_ethereum;
extern crate ethcore_light as light;

View File

@@ -38,7 +38,7 @@ use std::ops::Deref;
use std::sync::Arc;
use std::time::{Instant, Duration};
use ethcore::encoded;
use types::encoded;
use light::client::{AsLightClient, LightChainClient};
use light::net::{
PeerStatus, Announcement, Handler, BasicContext,

View File

@@ -16,7 +16,7 @@
//! Helpers for decoding and verifying responses for headers.
use ethcore::{encoded, header::Header};
use types::{encoded, header::Header};
use ethereum_types::H256;
use light::request::{HashOrNumber, CompleteHeadersRequest as HeadersRequest};
use rlp::DecoderError;
@@ -153,8 +153,8 @@ impl Constraint for Max {
#[cfg(test)]
mod tests {
use ethcore::encoded;
use ethcore::header::Header;
use types::encoded;
use types::header::Header;
use light::request::CompleteHeadersRequest as HeadersRequest;
use super::*;

View File

@@ -20,8 +20,8 @@ use std::cmp::Ordering;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use ethcore::encoded;
use ethcore::header::Header;
use types::encoded;
use types::header::Header;
use light::net::ReqId;
use light::request::CompleteHeadersRequest as HeadersRequest;

View File

@@ -18,7 +18,7 @@ use std::collections::HashMap;
use network::{NetworkContext, PeerId, PacketId, Error, SessionInfo, ProtocolId};
use bytes::Bytes;
use ethcore::client::BlockChainClient;
use ethcore::header::BlockNumber;
use types::BlockNumber;
use ethcore::snapshot::SnapshotService;
use parking_lot::RwLock;

View File

@@ -23,7 +23,7 @@ use ethcore::spec::Spec;
use ethcore::miner::MinerService;
use ethcore::account_provider::AccountProvider;
use ethkey::{KeyPair, Secret};
use transaction::{Action, PendingTransaction, Transaction};
use types::transaction::{Action, PendingTransaction, Transaction};
use super::helpers::*;
use SyncConfig;

View File

@@ -23,7 +23,6 @@ use network::{self, PeerId, ProtocolId, PacketId, SessionInfo};
use tests::snapshot::*;
use ethcore::client::{TestBlockChainClient, BlockChainClient, Client as EthcoreClient,
ClientConfig, ChainNotify, NewBlocks, ChainMessageType, ClientIoMessage};
use ethcore::header::BlockNumber;
use ethcore::snapshot::SnapshotService;
use ethcore::spec::Spec;
use ethcore::account_provider::AccountProvider;
@@ -35,6 +34,7 @@ use api::WARP_SYNC_PROTOCOL_ID;
use chain::{ChainSync, ETH_PROTOCOL_VERSION_63, PAR_PROTOCOL_VERSION_3, PRIVATE_TRANSACTION_PACKET, SIGNED_PRIVATE_TRANSACTION_PACKET, SyncSupplier};
use SyncConfig;
use private_tx::SimplePrivateTxHandler;
use types::BlockNumber;
pub trait FlushingBlockChainClient: BlockChainClient {
fn flush(&self) {}

View File

@@ -21,7 +21,7 @@ use ethcore::client::{BlockChainClient, BlockId, ClientIoMessage};
use ethcore::spec::Spec;
use ethcore::miner::MinerService;
use ethcore::CreateContractAddress;
use transaction::{Transaction, Action};
use types::transaction::{Transaction, Action};
use ethcore::executive::{contract_address};
use ethcore::test_helpers::{push_block_with_transactions};
use ethcore_private_tx::{Provider, ProviderConfig, NoopEncryptor, Importer, SignedPrivateTransaction};

View File

@@ -21,8 +21,8 @@ use ethereum_types::H256;
use parking_lot::Mutex;
use bytes::Bytes;
use ethcore::snapshot::{SnapshotService, ManifestData, RestorationStatus};
use ethcore::header::BlockNumber;
use ethcore::client::EachBlockWith;
use types::BlockNumber;
use super::helpers::*;
use {SyncConfig, WarpSync};

View File

@@ -19,9 +19,9 @@ use std::hash::BuildHasher;
use std::collections::{HashSet, HashMap};
use ethereum_types::{H256, H512};
use fastmap::H256FastMap;
use types::BlockNumber;
type NodeId = H512;
type BlockNumber = u64;
#[derive(Debug, PartialEq, Clone)]
pub struct Stats {