From fa019bd03eec51cb619e1c3300974af062ded8db Mon Sep 17 00:00:00 2001 From: debris Date: Mon, 16 Oct 2017 17:50:25 +0200 Subject: [PATCH] remove ipc codegen from ethcore --- Cargo.lock | 3 - ethcore/Cargo.toml | 6 -- ethcore/build.rs | 23 ------ ethcore/src/client/chain_notify.rs | 4 - ethcore/src/client/mod.rs | 19 +---- ethcore/src/client/traits.rs | 4 - ethcore/src/error.rs | 19 ----- ethcore/src/lib.rs | 3 - ethcore/src/service.rs | 39 +--------- ethcore/src/snapshot/mod.rs | 11 +-- .../{snapshot_service_trait.rs => traits.rs} | 4 - ethcore/src/tests/mod.rs | 4 - ethcore/src/tests/rpc.rs | 78 ------------------- ethcore/types/src/account_diff.rs | 2 - 14 files changed, 4 insertions(+), 215 deletions(-) delete mode 100644 ethcore/build.rs rename ethcore/src/snapshot/{snapshot_service_trait.rs => traits.rs} (95%) delete mode 100644 ethcore/src/tests/rpc.rs diff --git a/Cargo.lock b/Cargo.lock index c64bb06cd..2faf98e44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -525,9 +525,6 @@ dependencies = [ "ethcore-bytes 0.1.0", "ethcore-devtools 1.9.0", "ethcore-io 1.9.0", - "ethcore-ipc 1.9.0", - "ethcore-ipc-codegen 1.9.0", - "ethcore-ipc-nano 1.9.0", "ethcore-logger 1.9.0", "ethcore-stratum 1.9.0", "ethcore-util 1.9.0", diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 7945e3ad5..63fcc8fa1 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -5,10 +5,6 @@ license = "GPL-3.0" name = "ethcore" version = "1.9.0" authors = ["Parity Technologies "] -build = "build.rs" - -[build-dependencies] -"ethcore-ipc-codegen" = { path = "../ipc/codegen" } [dependencies] ansi_term = "0.9" @@ -26,8 +22,6 @@ memorydb = { path = "../util/memorydb" } patricia_trie = { path = "../util/patricia_trie" } ethcore-devtools = { path = "../devtools" } ethcore-io = { path = "../util/io" } -ethcore-ipc = { path = "../ipc/rpc" } -ethcore-ipc-nano = { path = "../ipc/nano" } ethcore-logger = { path = "../logger" } ethcore-stratum = { path = "../stratum" } ethcore-util = { path = "../util" } diff --git a/ethcore/build.rs b/ethcore/build.rs deleted file mode 100644 index 8fe38e757..000000000 --- a/ethcore/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -extern crate ethcore_ipc_codegen; - -fn main() { - ethcore_ipc_codegen::derive_ipc_cond("src/client/traits.rs", cfg!(feature="ipc")).unwrap(); - ethcore_ipc_codegen::derive_ipc_cond("src/snapshot/snapshot_service_trait.rs", cfg!(feature="ipc")).unwrap(); - ethcore_ipc_codegen::derive_ipc_cond("src/client/chain_notify.rs", cfg!(feature="ipc")).unwrap(); -} diff --git a/ethcore/src/client/chain_notify.rs b/ethcore/src/client/chain_notify.rs index 00b744167..5dd2861ae 100644 --- a/ethcore/src/client/chain_notify.rs +++ b/ethcore/src/client/chain_notify.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use ipc::IpcConfig; use bigint::hash::H256; use bytes::Bytes; /// Represents what has to be handled by actor listening to chain events -#[ipc] pub trait ChainNotify : Send + Sync { /// fires when chain has new blocks. fn new_blocks( @@ -57,5 +55,3 @@ pub trait ChainNotify : Send + Sync { // does nothing by default } } - -impl IpcConfig for ChainNotify { } diff --git a/ethcore/src/client/mod.rs b/ethcore/src/client/mod.rs index 9377c2f44..2960f303d 100644 --- a/ethcore/src/client/mod.rs +++ b/ethcore/src/client/mod.rs @@ -45,21 +45,6 @@ pub use vm::{LastHashes, EnvInfo}; pub use error::{BlockImportError, TransactionImportError, TransactionImportResult}; pub use verification::VerifierType; -/// IPC interfaces -#[cfg(feature="ipc")] -pub mod remote { - pub use super::traits::RemoteClient; - pub use super::chain_notify::ChainNotifyClient; -} - -mod traits { - #![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues - include!(concat!(env!("OUT_DIR"), "/traits.rs")); -} - -pub mod chain_notify { - //! Chain notify interface - #![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues - include!(concat!(env!("OUT_DIR"), "/chain_notify.rs")); -} +mod traits; +mod chain_notify; diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index b4fc60f14..3ff60baf9 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -27,7 +27,6 @@ use evm::{Factory as EvmFactory, Schedule}; use executive::Executed; use filter::Filter; use header::{BlockNumber}; -use ipc::IpcConfig; use log_entry::LocalizedLogEntry; use receipt::LocalizedReceipt; use trace::LocalizedTrace; @@ -49,7 +48,6 @@ use types::block_status::BlockStatus; use types::mode::Mode; use types::pruning_info::PruningInfo; -#[ipc(client_ident="RemoteClient")] /// Blockchain database client. Owns and manages a blockchain and a block queue. pub trait BlockChainClient : Sync + Send { @@ -287,8 +285,6 @@ pub trait BlockChainClient : Sync + Send { fn eip86_transition(&self) -> u64; } -impl IpcConfig for BlockChainClient { } - /// Extended client interface used for mining pub trait MiningBlockChainClient: BlockChainClient { /// Returns OpenBlock prepared for closing. diff --git a/ethcore/src/error.rs b/ethcore/src/error.rs index 0146c684a..49b873a47 100644 --- a/ethcore/src/error.rs +++ b/ethcore/src/error.rs @@ -29,7 +29,6 @@ use io::*; use header::BlockNumber; use basic_types::LogBloom; use client::Error as ClientError; -use ipc::binary::{BinaryConvertError, BinaryConvertable}; use snapshot::Error as SnapshotError; use engines::EngineError; use ethkey::Error as EthkeyError; @@ -486,21 +485,3 @@ impl From> for Error where Error: From { Error::from(*err) } } - -binary_fixed_size!(BlockError); -binary_fixed_size!(ImportError); -binary_fixed_size!(TransactionError); - -// TODO: uncomment below once https://github.com/rust-lang/rust/issues/27336 sorted. -/*#![feature(concat_idents)] -macro_rules! assimilate { - ($name:ident) => ( - impl From for Error { - fn from(err: concat_idents!($name, Error)) -> Error { - Error:: $name (err) - } - } - ) -} -assimilate!(FromHex); -assimilate!(BaseData);*/ diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 079c2a34d..ce2b8d346 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -81,7 +81,6 @@ extern crate ethash; extern crate ethcore_bloom_journal as bloom_journal; extern crate ethcore_devtools as devtools; extern crate ethcore_io as io; -extern crate ethcore_ipc_nano as nanoipc; extern crate ethcore_bigint as bigint; extern crate ethcore_bytes as bytes; extern crate ethcore_logger; @@ -139,8 +138,6 @@ extern crate macros; extern crate log; #[macro_use] extern crate lazy_static; -#[macro_use] -extern crate ethcore_ipc as ipc; #[cfg_attr(test, macro_use)] extern crate evm; diff --git a/ethcore/src/service.rs b/ethcore/src/service.rs index 0ceabce84..078f02d46 100644 --- a/ethcore/src/service.rs +++ b/ethcore/src/service.rs @@ -30,12 +30,8 @@ use miner::Miner; use snapshot::{ManifestData, RestorationStatus}; use snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams}; -use std::sync::atomic::AtomicBool; use ansi_term::Colour; -#[cfg(feature="ipc")] -use nanoipc; - /// Message type for external and internal events #[derive(Clone, PartialEq, Eq, Debug)] pub enum ClientIoMessage { @@ -73,7 +69,7 @@ impl ClientService { spec: &Spec, client_path: &Path, snapshot_path: &Path, - ipc_path: &Path, + _ipc_path: &Path, miner: Arc, ) -> Result { @@ -121,7 +117,6 @@ impl ClientService { spec.engine.register_client(Arc::downgrade(&client) as _); let stop_guard = ::devtools::StopGuard::new(); - run_ipc(ipc_path, client.clone(), snapshot.clone(), stop_guard.share()); Ok(ClientService { io_service: Arc::new(io_service), @@ -229,38 +224,6 @@ impl IoHandler for ClientIoHandler { } } -#[cfg(feature="ipc")] -fn run_ipc(base_path: &Path, client: Arc, snapshot_service: Arc, stop: Arc) { - let mut path = base_path.to_owned(); - path.push("parity-chain.ipc"); - let socket_addr = format!("ipc://{}", path.to_string_lossy()); - let s = stop.clone(); - ::std::thread::spawn(move || { - let mut worker = nanoipc::Worker::new(&(client as Arc)); - worker.add_reqrep(&socket_addr).expect("Ipc expected to initialize with no issues"); - - while !s.load(::std::sync::atomic::Ordering::Relaxed) { - worker.poll(); - } - }); - - let mut path = base_path.to_owned(); - path.push("parity-snapshot.ipc"); - let socket_addr = format!("ipc://{}", path.to_string_lossy()); - ::std::thread::spawn(move || { - let mut worker = nanoipc::Worker::new(&(snapshot_service as Arc<::snapshot::SnapshotService>)); - worker.add_reqrep(&socket_addr).expect("Ipc expected to initialize with no issues"); - - while !stop.load(::std::sync::atomic::Ordering::Relaxed) { - worker.poll(); - } - }); -} - -#[cfg(not(feature="ipc"))] -fn run_ipc(_base_path: &Path, _client: Arc, _snapshot_service: Arc, _stop: Arc) { -} - #[cfg(test)] mod tests { use super::*; diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index e33c47e2c..4a3446e6e 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -72,16 +72,7 @@ mod watcher; #[cfg(test)] mod tests; -/// IPC interfaces -#[cfg(feature="ipc")] -pub mod remote { - pub use super::traits::RemoteSnapshotService; -} - -mod traits { - #![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues - include!(concat!(env!("OUT_DIR"), "/snapshot_service_trait.rs")); -} +mod traits; // Try to have chunks be around 4MB (before compression) const PREFERRED_CHUNK_SIZE: usize = 4 * 1024 * 1024; diff --git a/ethcore/src/snapshot/snapshot_service_trait.rs b/ethcore/src/snapshot/traits.rs similarity index 95% rename from ethcore/src/snapshot/snapshot_service_trait.rs rename to ethcore/src/snapshot/traits.rs index 8208400df..632a36afa 100644 --- a/ethcore/src/snapshot/snapshot_service_trait.rs +++ b/ethcore/src/snapshot/traits.rs @@ -17,13 +17,11 @@ use super::{ManifestData, RestorationStatus}; use bigint::hash::H256; use bytes::Bytes; -use ipc::IpcConfig; /// The interface for a snapshot network service. /// This handles: /// - restoration of snapshots to temporary databases. /// - responding to queries for snapshot manifests and chunks -#[ipc(client_ident="RemoteSnapshotService")] pub trait SnapshotService : Sync + Send { /// Query the most recent manifest data. fn manifest(&self) -> Option; @@ -54,5 +52,3 @@ pub trait SnapshotService : Sync + Send { /// no-op if currently restoring. fn restore_block_chunk(&self, hash: H256, chunk: Bytes); } - -impl IpcConfig for SnapshotService { } diff --git a/ethcore/src/tests/mod.rs b/ethcore/src/tests/mod.rs index c86240f33..eec71efaf 100644 --- a/ethcore/src/tests/mod.rs +++ b/ethcore/src/tests/mod.rs @@ -18,7 +18,3 @@ pub mod helpers; mod client; mod evm; mod trace; - -#[cfg(feature="ipc")] -mod rpc; - diff --git a/ethcore/src/tests/rpc.rs b/ethcore/src/tests/rpc.rs deleted file mode 100644 index 6444daa56..000000000 --- a/ethcore/src/tests/rpc.rs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Client RPC tests - -use nanoipc; -use std::sync::Arc; -use std::sync::atomic::{Ordering, AtomicBool}; -use client::{Client, BlockChainClient, ClientConfig, BlockId}; -use client::remote::RemoteClient; -use tests::helpers::*; -use devtools::*; -use miner::Miner; -use crossbeam; -use io::IoChannel; -use util::kvdb::DatabaseConfig; - -pub fn run_test_worker(scope: &crossbeam::Scope, stop: Arc, socket_path: &str) { - let socket_path = socket_path.to_owned(); - scope.spawn(move || { - let temp = RandomTempPath::create_dir(); - let spec = get_test_spec(); - let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); - - let client = Client::new( - ClientConfig::default(), - &spec, - temp.as_path(), - Arc::new(Miner::with_spec(&spec)), - IoChannel::disconnected(), - &db_config - ).unwrap(); - let mut worker = nanoipc::Worker::new(&(client as Arc)); - worker.add_reqrep(&socket_path).unwrap(); - while !stop.load(Ordering::Relaxed) { - worker.poll(); - } - }); -} - -#[test] -fn can_handshake() { - crossbeam::scope(|scope| { - let stop_guard = StopGuard::new(); - let socket_path = "ipc:///tmp/parity-client-rpc-10.ipc"; - run_test_worker(scope, stop_guard.share(), socket_path); - let remote_client = nanoipc::generic_client::>(socket_path).unwrap(); - - assert!(remote_client.handshake().is_ok()); - }) -} - -#[test] -fn can_query_block() { - crossbeam::scope(|scope| { - let stop_guard = StopGuard::new(); - let socket_path = "ipc:///tmp/parity-client-rpc-20.ipc"; - run_test_worker(scope, stop_guard.share(), socket_path); - let remote_client = nanoipc::generic_client::>(socket_path).unwrap(); - - let non_existant_block = remote_client.block_header(BlockId::Number(999)); - - assert!(non_existant_block.is_none()); - }) -} diff --git a/ethcore/types/src/account_diff.rs b/ethcore/types/src/account_diff.rs index c1eb89d92..ae1cf3e98 100644 --- a/ethcore/types/src/account_diff.rs +++ b/ethcore/types/src/account_diff.rs @@ -51,7 +51,6 @@ impl Diff where T: Eq { } #[derive(Debug, PartialEq, Eq, Clone)] -#[cfg_attr(feature = "ipc", binary)] /// Account diff. pub struct AccountDiff { /// Change in balance, allowed to be `Diff::Same`. @@ -65,7 +64,6 @@ pub struct AccountDiff { } #[derive(Debug, PartialEq, Eq, Clone)] -#[cfg_attr(feature = "ipc", binary)] /// Change in existance type. // TODO: include other types of change. pub enum Existance {