From 32ea4d69a382563973f574fe58cc8bbc5641781a Mon Sep 17 00:00:00 2001 From: Artem Vorotnikov Date: Mon, 17 Aug 2020 13:47:53 +0300 Subject: [PATCH] Remove IPFS integration (#11532) --- Cargo.lock | 67 ----- Cargo.toml | 1 - README.md | 4 - ipfs/Cargo.toml | 20 -- ipfs/src/error.rs | 111 -------- ipfs/src/lib.rs | 226 ---------------- ipfs/src/route.rs | 279 -------------------- parity/cli/mod.rs | 54 +--- parity/cli/presets/config.dev-insecure.toml | 4 - parity/cli/presets/config.insecure.toml | 4 - parity/cli/tests/config.full.toml | 7 - parity/cli/tests/config.toml | 4 - parity/configuration.rs | 77 ------ parity/ipfs.rs | 61 ----- parity/lib.rs | 2 - parity/run.rs | 6 - rpc/Cargo.toml | 2 - rpc/src/lib.rs | 2 - rpc/src/v1/helpers/errors.rs | 8 - rpc/src/v1/helpers/ipfs.rs | 32 --- rpc/src/v1/helpers/mod.rs | 1 - rpc/src/v1/impls/parity.rs | 6 +- rpc/src/v1/tests/mocked/parity.rs | 12 - rpc/src/v1/traits/parity.rs | 4 - scripts/doc.sh | 2 +- scripts/docker/README.md | 8 +- scripts/docker/centos/Dockerfile | 8 +- scripts/hook.sh | 2 +- 28 files changed, 15 insertions(+), 999 deletions(-) delete mode 100644 ipfs/Cargo.toml delete mode 100644 ipfs/src/error.rs delete mode 100644 ipfs/src/lib.rs delete mode 100644 ipfs/src/route.rs delete mode 100644 parity/ipfs.rs delete mode 100644 rpc/src/v1/helpers/ipfs.rs diff --git a/Cargo.lock b/Cargo.lock index 7058fb91e..9f52df9b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,11 +133,6 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base-x" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "base64" version = "0.9.3" @@ -325,16 +320,6 @@ dependencies = [ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "cid" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "integer-encoding 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "clap" version = "2.33.0" @@ -1831,11 +1816,6 @@ dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "integer-encoding" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "interleaved-ordered" version = "0.1.1" @@ -2348,24 +2328,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "multibase" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "multihash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nan-preserving-float" version = "0.1.0" @@ -2631,7 +2593,6 @@ dependencies = [ "panic_hook 0.1.0", "parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-ipfs-api 1.12.0", "parity-local-store 0.1.0", "parity-path 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc 1.12.0", @@ -2656,21 +2617,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parity-ipfs-api" -version = "1.12.0" -dependencies = [ - "cid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore 1.12.0", - "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parity-local-store" version = "0.1.0" @@ -2721,7 +2667,6 @@ name = "parity-rpc" version = "1.12.0" dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "common-types 0.1.0", "eip-712 0.1.0", "ethash 1.12.0", @@ -2750,7 +2695,6 @@ dependencies = [ "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", - "multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3705,11 +3649,6 @@ dependencies = [ "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "sha1" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "sha2" version = "0.7.1" @@ -4712,7 +4651,6 @@ dependencies = [ "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" -"checksum base-x 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c" @@ -4735,7 +4673,6 @@ dependencies = [ "checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum cid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6908948032561f2550467a477f659cdc358320a805237b9b5035c0350c441def" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" @@ -4821,7 +4758,6 @@ dependencies = [ "checksum if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec" "checksum igd 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c8aef7814a769f156ef3a86169a8b04c066e3aebc324f522c159978466e32a1c" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" -"checksum integer-encoding 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1aec89c15e2cfa0f0eae8ca60e03cb10b30d25ea2c0ad7d6be60a95e32729994" "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)" = "70783119ac90828aaba91eae39db32c6c1b8838deea3637e5238efa0130801ab" @@ -4872,8 +4808,6 @@ dependencies = [ "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" -"checksum multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" -"checksum multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c62469025f45dee2464ef9fc845f4683c543993792c1993e7d903c17a4546b74" "checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" @@ -4990,7 +4924,6 @@ dependencies = [ "checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8" "checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" -"checksum sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "171698ce4ec7cbb93babeb3190021b4d72e96ccb98e33d277ae4ea959d6f2d9e" "checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" diff --git a/Cargo.toml b/Cargo.toml index 1e3fbe2b0..0c02293cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,6 @@ node-filter = { path = "ethcore/node-filter" } rlp = { version = "0.3.0", features = ["ethereum"] } cli-signer= { path = "cli-signer" } parity-daemonize = "0.3" -parity-ipfs-api = { path = "ipfs" } parity-local-store = { path = "miner/local-store" } parity-runtime = { path = "util/runtime" } parity-rpc = { path = "rpc" } diff --git a/README.md b/README.md index f2447e131..ca8cd59a6 100644 --- a/README.md +++ b/README.md @@ -276,10 +276,6 @@ Caching, Importing Blocks, and Block Information ```bash evmbin ``` - * Parity Ethereum IPFS-compatible API - ```bash - parity-ipfs-api - ``` * Parity Ethereum JSON Deserialization ```bash ethjson diff --git a/ipfs/Cargo.toml b/ipfs/Cargo.toml deleted file mode 100644 index 67a165c7f..000000000 --- a/ipfs/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -description = "Parity Ethereum IPFS-compatible API" -name = "parity-ipfs-api" -version = "1.12.0" -license = "GPL-3.0" -authors = ["Parity Technologies "] - -[dependencies] -ethcore = { path = "../ethcore" } -parity-bytes = "0.1" -ethereum-types = "0.4" -jsonrpc-core = "14.0.3" -jsonrpc-http-server = "14.0.3" -rlp = { version = "0.3.0", features = ["ethereum"] } -cid = "0.3" -multihash = "0.8" -unicase = "2.0" - -[dev-dependencies] -ethcore = { path = "../ethcore", features = ["test-helpers"] } diff --git a/ipfs/src/error.rs b/ipfs/src/error.rs deleted file mode 100644 index 9af718f46..000000000 --- a/ipfs/src/error.rs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see . - -use cid; -use http; -use multihash; -use route::Out; - -pub type Result = ::std::result::Result; - -/// IPFS server error -#[derive(Debug)] -pub enum ServerError { - /// Wrapped `std::io::Error` - IoError(::std::io::Error), - /// Other `hyper` error - Other(http::hyper::error::Error), - /// Invalid --ipfs-api-interface - InvalidInterface, -} - -/// Handle IO errors (ports taken when starting the server). -impl From<::std::io::Error> for ServerError { - fn from(err: ::std::io::Error) -> ServerError { - ServerError::IoError(err) - } -} - -impl From for ServerError { - fn from(err: http::hyper::error::Error) -> ServerError { - ServerError::Other(err) - } -} - -impl From for String { - fn from(err: ServerError) -> String { - match err { - ServerError::IoError(err) => err.to_string(), - ServerError::Other(err) => err.to_string(), - ServerError::InvalidInterface => "Invalid --ipfs-api-interface parameter".into(), - } - } -} - -impl ::std::fmt::Display for ServerError { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - match self { - ServerError::IoError(err) => write!(f, "Io Error: {}", err), - ServerError::Other(err) => write!(f, "Other error: {}", err), - ServerError::InvalidInterface => write!(f, "Invalid interface"), - } - } -} - -impl ::std::error::Error for ServerError {} - -#[derive(Debug, PartialEq)] -pub enum Error { - CidParsingFailed, - UnsupportedHash, - UnsupportedCid, - BlockNotFound, - TransactionNotFound, - StateRootNotFound, - ContractNotFound, -} - -/// Convert Error into Out, handy when switching from Rust's Result-based -/// error handling to Hyper's request handling. -impl From for Out { - fn from(err: Error) -> Out { - use self::Error::*; - - match err { - UnsupportedHash => Out::Bad("Hash must be Keccak-256"), - UnsupportedCid => Out::Bad("CID codec not supported"), - CidParsingFailed => Out::Bad("CID parsing failed"), - BlockNotFound => Out::NotFound("Block not found"), - TransactionNotFound => Out::NotFound("Transaction not found"), - StateRootNotFound => Out::NotFound("State root not found"), - ContractNotFound => Out::NotFound("Contract not found"), - } - } -} - -/// Convert Content ID errors. -impl From for Error { - fn from(_: cid::Error) -> Error { - Error::CidParsingFailed - } -} - -/// Convert multihash errors (multihash being part of CID). -impl From for Error { - fn from(_: multihash::Error) -> Error { - Error::CidParsingFailed - } -} diff --git a/ipfs/src/lib.rs b/ipfs/src/lib.rs deleted file mode 100644 index 386da9f27..000000000 --- a/ipfs/src/lib.rs +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see . - -extern crate cid; -extern crate multihash; -extern crate unicase; - -extern crate ethcore; -extern crate ethereum_types; -extern crate jsonrpc_core; -extern crate jsonrpc_http_server as http; -extern crate parity_bytes as bytes; -extern crate rlp; - -pub mod error; -mod route; - -use std::{ - net::{IpAddr, SocketAddr}, - sync::{mpsc, Arc}, - thread, -}; - -use ethcore::client::BlockChainClient; -use http::hyper::{ - self, - header::{self, HeaderValue}, - server, Body, Method, StatusCode, -}; -use jsonrpc_core::futures::{ - self, - future::{self, FutureResult}, - Future, -}; - -use error::ServerError; -use route::Out; - -pub use http::{AccessControlAllowOrigin, DomainsValidation, Host}; - -/// Request/response handler -pub struct IpfsHandler { - /// Allowed CORS domains - cors_domains: Option>, - /// Hostnames allowed in the `Host` request header - allowed_hosts: Option>, - /// Reference to the Blockchain Client - client: Arc, -} - -impl IpfsHandler { - pub fn client(&self) -> &dyn BlockChainClient { - &*self.client - } - - pub fn new( - cors: DomainsValidation, - hosts: DomainsValidation, - client: Arc, - ) -> Self { - IpfsHandler { - cors_domains: cors.into(), - allowed_hosts: hosts.into(), - client, - } - } - pub fn on_request(&self, req: hyper::Request) -> (Option, Out) { - match *req.method() { - Method::GET | Method::POST => {} - _ => return (None, Out::Bad("Invalid Request")), - } - - if !http::is_host_allowed(&req, &self.allowed_hosts) { - return (None, Out::Bad("Disallowed Host header")); - } - - let cors_header = http::cors_allow_origin(&req, &self.cors_domains); - if cors_header == http::AllowCors::Invalid { - return (None, Out::Bad("Disallowed Origin header")); - } - - let path = req.uri().path(); - let query = req.uri().query(); - return (cors_header.into(), self.route(path, query)); - } -} - -impl hyper::service::Service for IpfsHandler { - type ReqBody = Body; - type ResBody = Body; - type Error = hyper::Error; - type Future = FutureResult, Self::Error>; - - fn call(&mut self, request: hyper::Request) -> Self::Future { - let (cors_header, out) = self.on_request(request); - - let mut res = match out { - Out::OctetStream(bytes) => hyper::Response::builder() - .status(StatusCode::OK) - .header( - "content-type", - HeaderValue::from_static("application/octet-stream"), - ) - .body(bytes.into()), - Out::NotFound(reason) => hyper::Response::builder() - .status(StatusCode::NOT_FOUND) - .header( - "content-type", - HeaderValue::from_static("text/plain; charset=utf-8"), - ) - .body(reason.into()), - Out::Bad(reason) => hyper::Response::builder() - .status(StatusCode::BAD_REQUEST) - .header( - "content-type", - HeaderValue::from_static("text/plain; charset=utf-8"), - ) - .body(reason.into()), - } - .expect("Response builder: Parsing 'content-type' header name will not fail; qed"); - - if let Some(cors_header) = cors_header { - res.headers_mut() - .append(header::ACCESS_CONTROL_ALLOW_ORIGIN, cors_header); - res.headers_mut() - .append(header::VARY, HeaderValue::from_static("origin")); - } - - future::ok(res) - } -} - -/// Add current interface (default: "127.0.0.1:5001") to list of allowed hosts -fn include_current_interface(mut hosts: Vec, interface: String, port: u16) -> Vec { - hosts.push( - match port { - 80 => interface, - _ => format!("{}:{}", interface, port), - } - .into(), - ); - - hosts -} - -#[derive(Debug)] -pub struct Listening { - close: Option>, - thread: Option>, -} - -impl Drop for Listening { - fn drop(&mut self) { - self.close.take().unwrap().send(()).unwrap(); - let _ = self.thread.take().unwrap().join(); - } -} - -pub fn start_server( - port: u16, - interface: String, - cors: DomainsValidation, - hosts: DomainsValidation, - client: Arc, -) -> Result { - let ip: IpAddr = interface - .parse() - .map_err(|_| ServerError::InvalidInterface)?; - let addr = SocketAddr::new(ip, port); - let hosts: Option> = hosts.into(); - let hosts: DomainsValidation<_> = hosts - .map(move |hosts| include_current_interface(hosts, interface, port)) - .into(); - - let (close, shutdown_signal) = futures::sync::oneshot::channel::<()>(); - let (tx, rx) = mpsc::sync_channel::>(1); - let thread = thread::spawn(move || { - let send = |res| tx.send(res).expect("rx end is never dropped; qed"); - - let server_bldr = match server::Server::try_bind(&addr) { - Ok(s) => s, - Err(err) => { - send(Err(ServerError::from(err))); - return; - } - }; - - let new_service = move || { - Ok::<_, ServerError>(IpfsHandler::new( - cors.clone(), - hosts.clone(), - client.clone(), - )) - }; - - let server = server_bldr - .serve(new_service) - .map_err(|_| ()) - .select(shutdown_signal.map_err(|_| ())) - .then(|_| Ok(())); - - hyper::rt::run(server); - send(Ok(())); - }); - - // Wait for server to start successfuly. - rx.recv().expect("tx end is never dropped; qed")?; - - Ok(Listening { - close: close.into(), - thread: thread.into(), - }) -} diff --git a/ipfs/src/route.rs b/ipfs/src/route.rs deleted file mode 100644 index 981f2de5a..000000000 --- a/ipfs/src/route.rs +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see . - -use cid::{Codec, ToCid}; -use error::{Error, Result}; -use multihash; -use rlp; -use IpfsHandler; - -use bytes::Bytes; -use ethcore::client::{BlockId, TransactionId}; -use ethereum_types::H256; -use multihash::Hash; - -type Reason = &'static str; - -/// Keeps the state of the response to send out -#[derive(Debug, PartialEq)] -pub enum Out { - OctetStream(Bytes), - NotFound(Reason), - Bad(Reason), -} - -impl IpfsHandler { - /// Route path + query string to a specialized method - pub fn route(&self, path: &str, query: Option<&str>) -> Out { - match path { - "/api/v0/block/get" => { - let arg = query.and_then(|q| get_param(q, "arg")).unwrap_or(""); - - self.route_cid(arg).unwrap_or_else(Into::into) - } - - _ => Out::NotFound("Route not found"), - } - } - - /// Attempt to read Content ID from `arg` query parameter, get a hash and - /// route further by the CID's codec. - fn route_cid(&self, cid: &str) -> Result { - let cid = cid.to_cid()?; - - let mh = multihash::decode(&cid.hash)?; - - if mh.alg != Hash::Keccak256 { - return Err(Error::UnsupportedHash); - } - - let hash: H256 = mh.digest.into(); - - match cid.codec { - Codec::EthereumBlock => self.block(hash), - Codec::EthereumBlockList => self.block_list(hash), - Codec::EthereumTx => self.transaction(hash), - Codec::EthereumStateTrie => self.state_trie(hash), - Codec::Raw => self.contract_code(hash), - _ => return Err(Error::UnsupportedCid), - } - } - - /// Get block header by hash as raw binary. - fn block(&self, hash: H256) -> Result { - let block_id = BlockId::Hash(hash); - let block = self - .client() - .block_header(block_id) - .ok_or(Error::BlockNotFound)?; - - Ok(Out::OctetStream(block.into_inner())) - } - - /// Get list of block ommers by hash as raw binary. - fn block_list(&self, hash: H256) -> Result { - let uncles = self - .client() - .find_uncles(&hash) - .ok_or(Error::BlockNotFound)?; - - Ok(Out::OctetStream(rlp::encode_list(&uncles))) - } - - /// Get transaction by hash and return as raw binary. - fn transaction(&self, hash: H256) -> Result { - let tx_id = TransactionId::Hash(hash); - let tx = self - .client() - .transaction(tx_id) - .ok_or(Error::TransactionNotFound)?; - - Ok(Out::OctetStream(rlp::encode(&*tx))) - } - - /// Get state trie node by hash and return as raw binary. - fn state_trie(&self, hash: H256) -> Result { - let data = self - .client() - .state_data(&hash) - .ok_or(Error::StateRootNotFound)?; - - Ok(Out::OctetStream(data)) - } - - /// Get state trie node by hash and return as raw binary. - fn contract_code(&self, hash: H256) -> Result { - let data = self - .client() - .state_data(&hash) - .ok_or(Error::ContractNotFound)?; - - Ok(Out::OctetStream(data)) - } -} - -/// Get a query parameter's value by name. -fn get_param<'a>(query: &'a str, name: &str) -> Option<&'a str> { - query - .split('&') - .find(|part| part.starts_with(name) && part[name.len()..].starts_with("=")) - .map(|part| &part[name.len() + 1..]) -} - -#[cfg(test)] -mod tests { - use super::*; - use ethcore::client::TestBlockChainClient; - use std::sync::Arc; - - fn get_mocked_handler() -> IpfsHandler { - IpfsHandler::new( - None.into(), - None.into(), - Arc::new(TestBlockChainClient::new()), - ) - } - - #[test] - fn test_get_param() { - let query = "foo=100&bar=200&qux=300"; - - assert_eq!(get_param(query, "foo"), Some("100")); - assert_eq!(get_param(query, "bar"), Some("200")); - assert_eq!(get_param(query, "qux"), Some("300")); - assert_eq!(get_param(query, "bar="), None); - assert_eq!(get_param(query, "200"), None); - assert_eq!(get_param("", "foo"), None); - assert_eq!(get_param("foo", "foo"), None); - assert_eq!(get_param("foo&bar", "foo"), None); - assert_eq!(get_param("bar&foo", "foo"), None); - } - - #[test] - fn cid_route_block() { - let handler = get_mocked_handler(); - - // `eth-block` with Keccak-256 - let cid = "z43AaGF5tmkT9SEX6urrhwpEW5ZSaACY73Vw357ZXTsur2fR8BM"; - - assert_eq!(Err(Error::BlockNotFound), handler.route_cid(cid)); - } - - #[test] - fn cid_route_block_list() { - let handler = get_mocked_handler(); - - // `eth-block-list` with Keccak-256 - let cid = "z43c7o7FsNxqdLJW8Ucj19tuCALtnmUb2EkDptj4W6xSkFVTqWs"; - - assert_eq!(Err(Error::BlockNotFound), handler.route_cid(cid)); - } - - #[test] - fn cid_route_tx() { - let handler = get_mocked_handler(); - - // `eth-tx` with Keccak-256 - let cid = "z44VCrqbpbPcb8SUBc8Tba4EaKuoDz2grdEoQXx4TP7WYh9ZGBu"; - - assert_eq!(Err(Error::TransactionNotFound), handler.route_cid(cid)); - } - - #[test] - fn cid_route_state_trie() { - let handler = get_mocked_handler(); - - // `eth-state-trie` with Keccak-256 - let cid = "z45oqTS7kR2n2peRGJQ4VCJEeaG9sorqcCyfmznZPJM7FMdhQCT"; - - assert_eq!(Err(Error::StateRootNotFound), handler.route_cid(&cid)); - } - - #[test] - fn cid_route_contract_code() { - let handler = get_mocked_handler(); - - // `raw` with Keccak-256 - let cid = "zb34WAp1Q5fhtLGZ3w3jhnTWaNbVV5ZZvGq4vuJQzERj6Pu3H"; - - assert_eq!(Err(Error::ContractNotFound), handler.route_cid(&cid)); - } - - #[test] - fn cid_route_invalid_hash() { - let handler = get_mocked_handler(); - - // `eth-block` with SHA3-256 hash - let cid = "z43Aa9gr1MM7TENJh4Em9d9Ttr7p3UcfyMpNei6WLVeCmSEPu8F"; - - assert_eq!(Err(Error::UnsupportedHash), handler.route_cid(cid)); - } - - #[test] - fn cid_route_invalid_codec() { - let handler = get_mocked_handler(); - - // `bitcoin-block` with Keccak-256 - let cid = "z4HFyHvb8CarYARyxz4cCcPaciduXd49TFPCKLhYmvNxf7Auvwu"; - - assert_eq!(Err(Error::UnsupportedCid), handler.route_cid(&cid)); - } - - #[test] - fn route_block() { - let handler = get_mocked_handler(); - - let out = handler.route( - "/api/v0/block/get", - Some("arg=z43AaGF5tmkT9SEX6urrhwpEW5ZSaACY73Vw357ZXTsur2fR8BM"), - ); - - assert_eq!(out, Out::NotFound("Block not found")); - } - - #[test] - fn route_block_missing_query() { - let handler = get_mocked_handler(); - - let out = handler.route("/api/v0/block/get", None); - - assert_eq!(out, Out::Bad("CID parsing failed")); - } - - #[test] - fn route_block_invalid_query() { - let handler = get_mocked_handler(); - - let out = handler.route( - "/api/v0/block/get", - Some("arg=foobarz43AaGF5tmkT9SEX6urrhwpEW5ZSaACY73Vw357ZXTsur2fR8BM"), - ); - - assert_eq!(out, Out::Bad("CID parsing failed")); - } - - #[test] - fn route_invalid_route() { - let handler = get_mocked_handler(); - - let out = handler.route( - "/foo/bar/baz", - Some("arg=z43AaGF5tmkT9SEX6urrhwpEW5ZSaACY73Vw357ZXTsur2fR8BM"), - ); - - assert_eq!(out, Out::NotFound("Route not found")); - } -} diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 07f429413..3c6aa99a7 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -269,7 +269,7 @@ usage! { ["Convenience Options"] FLAG flag_unsafe_expose: (bool) = false, or |c: &Config| c.misc.as_ref()?.unsafe_expose, "--unsafe-expose", - "All servers will listen on external interfaces and will be remotely accessible. It's equivalent with setting the following: --[ws,jsonrpc,ipfs-api,secretstore,stratum,secretstore-http]-interface=all --*-hosts=all This option is UNSAFE and should be used with great care!", + "All servers will listen on external interfaces and will be remotely accessible. It's equivalent with setting the following: --[ws,jsonrpc,secretstore,stratum,secretstore-http]-interface=all --*-hosts=all This option is UNSAFE and should be used with great care!", ARG arg_config: (String) = "$BASE/config.toml", or |_| None, "-c, --config=[CONFIG]", @@ -277,7 +277,7 @@ usage! { ARG arg_ports_shift: (u16) = 0u16, or |c: &Config| c.misc.as_ref()?.ports_shift, "--ports-shift=[SHIFT]", - "Add SHIFT to all port numbers Parity is listening on. Includes network port and all servers (HTTP JSON-RPC, WebSockets JSON-RPC, IPFS, SecretStore).", + "Add SHIFT to all port numbers Parity is listening on. Includes network port and all servers (HTTP JSON-RPC, WebSockets JSON-RPC, SecretStore).", ["Account Options"] FLAG flag_fast_unlock: (bool) = false, or |c: &Config| c.account.as_ref()?.fast_unlock.clone(), @@ -508,27 +508,6 @@ usage! { "--ipc-apis=[APIS]", "Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces", - ["API and Console Options – IPFS"] - FLAG flag_ipfs_api: (bool) = false, or |c: &Config| c.ipfs.as_ref()?.enable.clone(), - "--ipfs-api", - "Enable IPFS-compatible HTTP API.", - - ARG arg_ipfs_api_port: (u16) = 5001u16, or |c: &Config| c.ipfs.as_ref()?.port.clone(), - "--ipfs-api-port=[PORT]", - "Configure on which port the IPFS HTTP API should listen.", - - ARG arg_ipfs_api_interface: (String) = "local", or |c: &Config| c.ipfs.as_ref()?.interface.clone(), - "--ipfs-api-interface=[IP]", - "Specify the hostname portion of the IPFS API server, IP should be an interface's IP address or local.", - - ARG arg_ipfs_api_hosts: (String) = "none", or |c: &Config| c.ipfs.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")), - "--ipfs-api-hosts=[HOSTS]", - "List of allowed Host header values. This option will validate the Host header sent by the browser, it is additional security against some attack vectors. Special options: \"all\", \"none\".", - - ARG arg_ipfs_api_cors: (String) = "none", or |c: &Config| c.ipfs.as_ref()?.cors.as_ref().map(|vec| vec.join(",")), - "--ipfs-api-cors=[URL]", - "Specify CORS header for IPFS API responses. Special options: \"all\", \"none\".", - ["Secret Store Options"] FLAG flag_no_secretstore: (bool) = false, or |c: &Config| c.secretstore.as_ref()?.disable.clone(), "--no-secretstore", @@ -854,7 +833,6 @@ struct Config { ipc: Option, secretstore: Option, private_tx: Option, - ipfs: Option, mining: Option, footprint: Option, snapshots: Option, @@ -986,16 +964,6 @@ struct SecretStore { path: Option, } -#[derive(Default, Debug, PartialEq, Deserialize)] -#[serde(deny_unknown_fields)] -struct Ipfs { - enable: Option, - port: Option, - interface: Option, - cors: Option>, - hosts: Option>, -} - #[derive(Default, Debug, PartialEq, Deserialize)] #[serde(deny_unknown_fields)] struct Mining { @@ -1081,8 +1049,8 @@ struct Misc { #[cfg(test)] mod tests { use super::{ - Account, Args, ArgsError, Config, Footprint, Ipc, Ipfs, Mining, Misc, Network, Operating, - Rpc, SecretStore, Snapshots, Ws, + Account, Args, ArgsError, Config, Footprint, Ipc, Mining, Misc, Network, Operating, Rpc, + SecretStore, Snapshots, Ws, }; use clap::ErrorKind as ClapErrorKind; use toml; @@ -1410,13 +1378,6 @@ mod tests { arg_secretstore_http_port: 8082u16, arg_secretstore_path: "$HOME/.parity/secretstore".into(), - // IPFS - flag_ipfs_api: false, - arg_ipfs_api_port: 5001u16, - arg_ipfs_api_interface: "local".into(), - arg_ipfs_api_cors: "null".into(), - arg_ipfs_api_hosts: "none".into(), - // -- Sealing/Mining Options arg_author: Some("0xdeadbeefcafe0000000000000000000000000001".into()), arg_engine_signer: Some("0xdeadbeefcafe0000000000000000000000000001".into()), @@ -1616,13 +1577,6 @@ mod tests { path: None, }), private_tx: None, - ipfs: Some(Ipfs { - enable: Some(false), - port: Some(5001), - interface: None, - cors: None, - hosts: None, - }), mining: Some(Mining { author: Some("0xdeadbeefcafe0000000000000000000000000001".into()), engine_signer: Some("0xdeadbeefcafe0000000000000000000000000001".into()), diff --git a/parity/cli/presets/config.dev-insecure.toml b/parity/cli/presets/config.dev-insecure.toml index fcefb174e..0f594b8b3 100644 --- a/parity/cli/presets/config.dev-insecure.toml +++ b/parity/cli/presets/config.dev-insecure.toml @@ -9,7 +9,3 @@ min_gas_price = 0 interface = "all" apis = ["all"] hosts = ["all"] - -[ipfs] -enable = false # this is the default -hosts = ["all"] diff --git a/parity/cli/presets/config.insecure.toml b/parity/cli/presets/config.insecure.toml index 15e6e87b5..7481506a4 100644 --- a/parity/cli/presets/config.insecure.toml +++ b/parity/cli/presets/config.insecure.toml @@ -2,7 +2,3 @@ interface = "all" apis = ["all"] hosts = ["all"] - -[ipfs] -enable = false # this is the default -hosts = ["all"] diff --git a/parity/cli/tests/config.full.toml b/parity/cli/tests/config.full.toml index ff7437280..d59dd3553 100644 --- a/parity/cli/tests/config.full.toml +++ b/parity/cli/tests/config.full.toml @@ -82,13 +82,6 @@ interface = "local" port = 8083 path = "$HOME/.parity/secretstore" -[ipfs] -enable = false -port = 5001 -interface = "local" -cors = ["null"] -hosts = ["none"] - [mining] author = "0xdeadbeefcafe0000000000000000000000000001" engine_signer = "0xdeadbeefcafe0000000000000000000000000001" diff --git a/parity/cli/tests/config.toml b/parity/cli/tests/config.toml index 5e2fbe8db..b3d7eb6f0 100644 --- a/parity/cli/tests/config.toml +++ b/parity/cli/tests/config.toml @@ -36,10 +36,6 @@ apis = ["rpc", "eth"] http_port = 8082 port = 8083 -[ipfs] -enable = false -port = 5001 - [mining] author = "0xdeadbeefcafe0000000000000000000000000001" engine_signer = "0xdeadbeefcafe0000000000000000000000000001" diff --git a/parity/configuration.rs b/parity/configuration.rs index c80a4fae0..c1f85570a 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -57,7 +57,6 @@ use helpers::{ parity_ipc_path, to_address, to_addresses, to_block_id, to_bootnodes, to_duration, to_mode, to_pending_set, to_price, to_queue_penalization, to_queue_strategy, to_u256, }; -use ipfs::Configuration as IpfsConfiguration; use network::IpFilter; use params::{AccountsConfig, GasPricerConfig, MinerExtras, ResealPolicy, SpecType}; use parity_rpc::NetworkSettings; @@ -158,7 +157,6 @@ impl Configuration { let compaction = self.args.arg_db_compaction.parse()?; let warp_sync = !self.args.flag_no_warp; let experimental_rpcs = self.args.flag_jsonrpc_experimental; - let ipfs_conf = self.ipfs_config(); let secretstore_conf = self.secretstore_config()?; let format = self.format()?; let keys_iterations = NonZeroU32::new(self.args.arg_keys_iterations) @@ -419,7 +417,6 @@ impl Configuration { warp_barrier: self.args.arg_warp_barrier, experimental_rpcs, net_settings: self.network_settings()?, - ipfs_conf: ipfs_conf, secretstore_conf: secretstore_conf, private_provider_conf: private_provider_conf, private_encryptor_conf: private_enc_conf, @@ -679,16 +676,6 @@ impl Configuration { }) } - fn ipfs_config(&self) -> IpfsConfiguration { - IpfsConfiguration { - enabled: self.args.flag_ipfs_api, - port: self.args.arg_ports_shift + self.args.arg_ipfs_api_port, - interface: self.ipfs_interface(), - cors: self.ipfs_cors(), - hosts: self.ipfs_hosts(), - } - } - fn gas_pricer_config(&self) -> Result { fn wei_per_gas(usd_per_tx: f32, usd_per_eth: f32) -> U256 { let wei_per_usd: f32 = 1.0e18 / usd_per_eth; @@ -881,10 +868,6 @@ impl Configuration { Self::cors(&cors) } - fn ipfs_cors(&self) -> Option> { - Self::cors(self.args.arg_ipfs_api_cors.as_ref()) - } - fn hosts(&self, hosts: &str, interface: &str) -> Option> { if self.args.flag_unsafe_expose { return None; @@ -923,10 +906,6 @@ impl Configuration { Self::parse_hosts(&self.args.arg_ws_origins) } - fn ipfs_hosts(&self) -> Option> { - self.hosts(&self.args.arg_ipfs_api_hosts, &self.ipfs_interface()) - } - fn ipc_config(&self) -> Result { let conf = IpcConfiguration { enabled: !self.args.flag_no_ipc, @@ -1102,10 +1081,6 @@ impl Configuration { self.interface(&self.args.arg_ws_interface) } - fn ipfs_interface(&self) -> String { - self.interface(&self.args.arg_ipfs_api_interface) - } - fn secretstore_interface(&self) -> String { self.interface(&self.args.arg_secretstore_interface) } @@ -1578,7 +1553,6 @@ mod tests { vm_type: Default::default(), experimental_rpcs: false, net_settings: Default::default(), - ipfs_conf: Default::default(), secretstore_conf: Default::default(), private_provider_conf: Default::default(), private_encryptor_conf: Default::default(), @@ -1670,51 +1644,6 @@ mod tests { ); } - #[test] - fn should_parse_ipfs_hosts() { - // given - - // when - let conf0 = parse(&["parity"]); - let conf1 = parse(&["parity", "--ipfs-api-hosts", "none"]); - let conf2 = parse(&["parity", "--ipfs-api-hosts", "all"]); - let conf3 = parse(&["parity", "--ipfs-api-hosts", "parity.io,something.io"]); - - // then - assert_eq!(conf0.ipfs_hosts(), Some(Vec::new())); - assert_eq!(conf1.ipfs_hosts(), Some(Vec::new())); - assert_eq!(conf2.ipfs_hosts(), None); - assert_eq!( - conf3.ipfs_hosts(), - Some(vec!["parity.io".into(), "something.io".into()]) - ); - } - - #[test] - fn should_parse_ipfs_cors() { - // given - - // when - let conf0 = parse(&["parity"]); - let conf1 = parse(&["parity", "--ipfs-api-cors", "*"]); - let conf2 = parse(&[ - "parity", - "--ipfs-api-cors", - "http://parity.io,http://something.io", - ]); - - // then - assert_eq!(conf0.ipfs_cors(), Some(vec![])); - assert_eq!(conf1.ipfs_cors(), None); - assert_eq!( - conf2.ipfs_cors(), - Some(vec![ - "http://parity.io".into(), - "http://something.io".into() - ]) - ); - } - #[test] fn should_parse_ui_configuration() { // given @@ -1815,7 +1744,6 @@ mod tests { } // "web3,eth,net,personal,parity,parity_set,traces,parity_accounts"); assert_eq!(c.http_conf.hosts, None); - assert_eq!(c.ipfs_conf.hosts, None); } _ => panic!("Should be Cmd::Run"), } @@ -1837,7 +1765,6 @@ mod tests { } // "web3,eth,net,personal,parity,parity_set,traces,parity_accounts"); assert_eq!(c.http_conf.hosts, None); - assert_eq!(c.ipfs_conf.hosts, None); } _ => panic!("Should be Cmd::Run"), } @@ -1887,7 +1814,6 @@ mod tests { assert_eq!(conf0.ws_config().unwrap().port, 8547); assert_eq!(conf0.secretstore_config().unwrap().port, 8084); assert_eq!(conf0.secretstore_config().unwrap().http_port, 8083); - assert_eq!(conf0.ipfs_config().port, 5002); assert_eq!(conf0.stratum_options().unwrap().unwrap().port, 8009); assert_eq!(conf1.net_addresses().unwrap().0.port(), 30304); @@ -1897,7 +1823,6 @@ mod tests { assert_eq!(conf1.ws_config().unwrap().port, 8547); assert_eq!(conf1.secretstore_config().unwrap().port, 8084); assert_eq!(conf1.secretstore_config().unwrap().http_port, 8083); - assert_eq!(conf1.ipfs_config().port, 5002); } #[test] @@ -1952,8 +1877,6 @@ mod tests { &conf0.secretstore_config().unwrap().http_interface, "0.0.0.0" ); - assert_eq!(&conf0.ipfs_config().interface, "0.0.0.0"); - assert_eq!(conf0.ipfs_config().hosts, None); } #[test] diff --git a/parity/ipfs.rs b/parity/ipfs.rs deleted file mode 100644 index 4b455c6c0..000000000 --- a/parity/ipfs.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see . - -use ethcore::client::BlockChainClient; -use parity_ipfs_api::{self, error::ServerError, AccessControlAllowOrigin, Host, Listening}; -use std::sync::Arc; - -#[derive(Debug, PartialEq, Clone)] -pub struct Configuration { - pub enabled: bool, - pub port: u16, - pub interface: String, - pub cors: Option>, - pub hosts: Option>, -} - -impl Default for Configuration { - fn default() -> Self { - Configuration { - enabled: false, - port: 5001, - interface: "127.0.0.1".into(), - cors: Some(vec![]), - hosts: Some(vec![]), - } - } -} - -pub fn start_server( - conf: Configuration, - client: Arc, -) -> Result, ServerError> { - if !conf.enabled { - return Ok(None); - } - - let cors = conf.cors.map(|cors| { - cors.into_iter() - .map(AccessControlAllowOrigin::from) - .collect() - }); - let hosts = conf - .hosts - .map(|hosts| hosts.into_iter().map(Host::from).collect()); - - parity_ipfs_api::start_server(conf.port, conf.interface, cors.into(), hosts.into(), client) - .map(Some) -} diff --git a/parity/lib.rs b/parity/lib.rs index e8b9b6466..1a283f03b 100644 --- a/parity/lib.rs +++ b/parity/lib.rs @@ -61,7 +61,6 @@ extern crate keccak_hash as hash; extern crate kvdb; extern crate node_filter; extern crate parity_bytes as bytes; -extern crate parity_ipfs_api; extern crate parity_local_store as local_store; extern crate parity_path as path; extern crate parity_rpc; @@ -98,7 +97,6 @@ mod configuration; mod db; mod helpers; mod informant; -mod ipfs; mod modules; mod params; mod presale; diff --git a/parity/run.rs b/parity/run.rs index 0c2f428c2..0ac85a0e6 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -37,7 +37,6 @@ use ethcore_private_tx::{EncryptorConfig, ProviderConfig, SecretStoreEncryptor}; use ethcore_service::ClientService; use helpers::{execute_upgrades, passwords_from_files, to_client_config}; use informant::{FullNodeInformantData, Informant}; -use ipfs; use journaldb::Algorithm; use jsonrpc_core; use miner::{external::ExternalMiner, work_notify::WorkPoster}; @@ -100,7 +99,6 @@ pub struct RunCmd { pub vm_type: VMType, pub experimental_rpcs: bool, pub net_settings: NetworkSettings, - pub ipfs_conf: ipfs::Configuration, pub secretstore_conf: secretstore::Configuration, pub private_provider_conf: ProviderConfig, pub private_encryptor_conf: EncryptorConfig, @@ -555,9 +553,6 @@ pub fn execute(cmd: RunCmd, logger: Arc) -> Result) -> Result"] [dependencies] ansi_term = "0.10" -cid = "0.3" futures = "0.1.6" log = "0.4" -multihash = "0.8" order-stat = "0.1" parking_lot = "0.7" rand = "0.4" diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 0f06abc03..e4980c13d 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -41,9 +41,7 @@ extern crate futures; extern crate ansi_term; -extern crate cid; extern crate itertools; -extern crate multihash; extern crate order_stat; extern crate parking_lot; extern crate rand; diff --git a/rpc/src/v1/helpers/errors.rs b/rpc/src/v1/helpers/errors.rs index e7ccc01a4..0c5467952 100644 --- a/rpc/src/v1/helpers/errors.rs +++ b/rpc/src/v1/helpers/errors.rs @@ -330,14 +330,6 @@ pub fn encryption(error: T) -> Error { } } -pub fn encoding(error: T) -> Error { - Error { - code: ErrorCode::ServerError(codes::ENCODING_ERROR), - message: "Encoding error.".into(), - data: Some(Value::String(format!("{:?}", error))), - } -} - pub fn database(error: T) -> Error { Error { code: ErrorCode::ServerError(codes::DATABASE_ERROR), diff --git a/rpc/src/v1/helpers/ipfs.rs b/rpc/src/v1/helpers/ipfs.rs deleted file mode 100644 index 34a09a04c..000000000 --- a/rpc/src/v1/helpers/ipfs.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see . - -//! IPFS utility functions - -use super::errors; -use cid::{Cid, Codec, Version}; -use crypto::digest; -use jsonrpc_core::Error; -use multihash; -use v1::types::Bytes; - -/// Compute CIDv0 from protobuf encoded bytes. -pub fn cid(content: Bytes) -> Result { - let hash = digest::sha256(&content.0); - let mh = multihash::encode(multihash::Hash::SHA2256, &*hash).map_err(errors::encoding)?; - let cid = Cid::new(Codec::DagProtobuf, Version::V0, &mh); - Ok(cid.to_string()) -} diff --git a/rpc/src/v1/helpers/mod.rs b/rpc/src/v1/helpers/mod.rs index 62c3abcdb..4af68b5bf 100644 --- a/rpc/src/v1/helpers/mod.rs +++ b/rpc/src/v1/helpers/mod.rs @@ -26,7 +26,6 @@ pub mod eip191; pub mod engine_signer; pub mod external_signer; pub mod fake_sign; -pub mod ipfs; pub mod nonce; #[cfg(any(test, feature = "accounts"))] pub mod secretstore; diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index d99ffe825..0d8f68cf6 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -39,7 +39,7 @@ use v1::{ block_import::is_major_importing, errors, external_signer::{SignerService, SigningQueue}, - fake_sign, ipfs, verify_signature, NetworkSettings, + fake_sign, verify_signature, NetworkSettings, }, metadata::Metadata, traits::Parity, @@ -407,10 +407,6 @@ where Box::new(future::ok(receipts.into_iter().map(Into::into).collect())) } - fn ipfs_cid(&self, content: Bytes) -> Result { - ipfs::cid(content) - } - fn call(&self, requests: Vec, num: Option) -> Result> { let requests = requests .into_iter() diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index f654a0450..c0c6f3814 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -422,18 +422,6 @@ fn rpc_parity_node_kind() { assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } -#[test] -fn rpc_parity_cid() { - let deps = Dependencies::new(); - let io = deps.default_client(); - - let request = r#"{"jsonrpc": "2.0", "method": "parity_cidV0", "params":["0x414243"], "id": 1}"#; - let response = - r#"{"jsonrpc":"2.0","result":"QmSF59MAENc8ZhM4aM1thuAE8w5gDmyfzkAvNoyPea7aDz","id":1}"#; - - assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); -} - #[test] fn rpc_parity_call() { let deps = Dependencies::new(); diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index 65bc8568a..fc73d6770 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -195,10 +195,6 @@ pub trait Parity { #[rpc(name = "parity_getBlockReceipts")] fn block_receipts(&self, _: Option) -> BoxFuture>; - /// Get IPFS CIDv0 given protobuf encoded bytes. - #[rpc(name = "parity_cidV0")] - fn ipfs_cid(&self, _: Bytes) -> Result; - /// Call contract, returning the output data. #[rpc(name = "parity_call")] fn call(&self, _: Vec, _: Option) -> Result>; diff --git a/scripts/doc.sh b/scripts/doc.sh index 44e544c99..18c875cc3 100755 --- a/scripts/doc.sh +++ b/scripts/doc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh # generate documentation only for partiy and ethcore libraries -cargo doc --no-deps --verbose --all --exclude parity-ipfs-api && +cargo doc --no-deps --verbose --all && echo '' > target/doc/index.html diff --git a/scripts/docker/README.md b/scripts/docker/README.md index 1b970699d..25818503e 100644 --- a/scripts/docker/README.md +++ b/scripts/docker/README.md @@ -33,8 +33,8 @@ PARITY_RUNNER_IMAGE_TAG - latest All default ports you might use will be exposed: ``` -# secret -# ipfs store ui rpc ws listener discovery -# ↓ ↓ ↓ ↓ ↓ ↓ ↓ -EXPOSE 5001 8082 8083 8180 8545 8546 30303/tcp 30303/udp +# secret +# store ui rpc ws listener discovery +# ↓ ↓ ↓ ↓ ↓ ↓ +EXPOSE 8082 8083 8180 8545 8546 30303/tcp 30303/udp ``` diff --git a/scripts/docker/centos/Dockerfile b/scripts/docker/centos/Dockerfile index 22a98c003..0b384dafe 100644 --- a/scripts/docker/centos/Dockerfile +++ b/scripts/docker/centos/Dockerfile @@ -10,10 +10,10 @@ WORKDIR /opt/parity/data # exposing default ports # -# secret -# ipfs store ui rpc ws listener discovery -# ↓ ↓ ↓ ↓ ↓ ↓ ↓ -EXPOSE 5001 8082 8083 8180 8545 8546 30303/tcp 30303/udp +# secret +# store ui rpc ws listener discovery +# ↓ ↓ ↓ ↓ ↓ ↓ +EXPOSE 8082 8083 8180 8545 8546 30303/tcp 30303/udp # switch to non-root user USER 1001 diff --git a/scripts/hook.sh b/scripts/hook.sh index ed7e173c5..739b11e7f 100755 --- a/scripts/hook.sh +++ b/scripts/hook.sh @@ -7,6 +7,6 @@ echo "set -e" >> $FILE # Run release build echo "cargo build --features dev" >> $FILE # Build tests -echo "cargo test --no-run --features dev --all --exclude parity-ipfs-api" >> $FILE +echo "cargo test --no-run --features dev --all" >> $FILE echo "" >> $FILE chmod +x $FILE