diff --git a/Cargo.lock b/Cargo.lock index 3cbfb0638..b6590f784 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -259,12 +259,6 @@ dependencies = [ "libc", ] -[[package]] -name = "base-x" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cda5d0f5584d129112ad8bf4775b9fd2b9f1e30738c7b1a25314ba2244d6a51" - [[package]] name = "base64" version = "0.9.3" @@ -367,16 +361,6 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" -[[package]] -name = "block-buffer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" -dependencies = [ - "arrayref", - "byte-tools 0.2.0", -] - [[package]] name = "block-buffer" version = "0.7.3" @@ -384,9 +368,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ "block-padding", - "byte-tools 0.3.1", + "byte-tools", "byteorder", - "generic-array 0.12.0", + "generic-array", ] [[package]] @@ -395,7 +379,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" dependencies = [ - "generic-array 0.12.0", + "generic-array", ] [[package]] @@ -429,7 +413,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" dependencies = [ - "byte-tools 0.3.1", + "byte-tools", ] [[package]] @@ -501,12 +485,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6209f3b2c1edea170002e016d5ead6903d3bb0a846477f53bbeb614967a52a9" -[[package]] -name = "byte-tools" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" - [[package]] name = "byte-tools" version = "0.3.1" @@ -588,17 +566,6 @@ dependencies = [ "time", ] -[[package]] -name = "cid" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0e37fba0087d9f3f4e269827a55dc511abf3e440cc097a0c154ff4e6584f988" -dependencies = [ - "integer-encoding", - "multibase", - "multihash", -] - [[package]] name = "clang-sys" version = "0.28.1" @@ -914,7 +881,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array 0.12.0", + "generic-array", "subtle 1.0.0", ] @@ -986,22 +953,13 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" -[[package]] -name = "digest" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" -dependencies = [ - "generic-array 0.9.0", -] - [[package]] name = "digest" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" dependencies = [ - "generic-array 0.12.0", + "generic-array", ] [[package]] @@ -2044,15 +2002,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "generic-array" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.12.0" @@ -2185,7 +2134,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" dependencies = [ "crypto-mac", - "digest 0.8.0", + "digest", ] [[package]] @@ -2372,12 +2321,6 @@ dependencies = [ "trace", ] -[[package]] -name = "integer-encoding" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26746cbc2e680af687e88d717f20ff90079bd10fc984ad57d277cd0e37309fa5" - [[package]] name = "interleaved-ordered" version = "0.1.1" @@ -2711,7 +2654,7 @@ checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" dependencies = [ "arrayref", "crunchy 0.2.2", - "digest 0.8.0", + "digest", "rand 0.7.2", "subtle 2.2.2", ] @@ -3012,26 +2955,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "multibase" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" -dependencies = [ - "base-x", -] - -[[package]] -name = "multihash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62469025f45dee2464ef9fc845f4683c543993792c1993e7d903c17a4546b74" -dependencies = [ - "sha1", - "sha2 0.7.1", - "tiny-keccak 1.5.0", -] - [[package]] name = "nan-preserving-float" version = "0.1.0" @@ -3264,7 +3187,7 @@ dependencies = [ "aes", "aes-ctr", "block-modes", - "digest 0.8.0", + "digest", "ethereum-types", "hmac", "lazy_static", @@ -3274,7 +3197,7 @@ dependencies = [ "rustc-hex 2.1.0", "scrypt", "secp256k1", - "sha2 0.8.0", + "sha2", "subtle 2.2.2", "tiny-keccak 2.0.1", "zeroize", @@ -3344,7 +3267,6 @@ dependencies = [ "parity-crypto", "parity-daemonize", "parity-hash-fetch", - "parity-ipfs-api", "parity-local-store", "parity-path", "parity-rpc", @@ -3400,23 +3322,6 @@ dependencies = [ "rustc-hex 2.1.0", ] -[[package]] -name = "parity-ipfs-api" -version = "1.12.0" -dependencies = [ - "cid", - "client-traits", - "common-types", - "ethcore", - "ethereum-types", - "jsonrpc-core", - "jsonrpc-http-server", - "multihash", - "parity-bytes", - "rlp", - "unicase", -] - [[package]] name = "parity-local-store" version = "0.1.0" @@ -3446,7 +3351,6 @@ version = "1.12.0" dependencies = [ "account-state", "ansi_term", - "cid", "client-traits", "common-types", "eip-712", @@ -3480,7 +3384,6 @@ dependencies = [ "log", "machine", "maplit", - "multihash", "order-stat", "parity-bytes", "parity-crypto", @@ -3790,7 +3693,7 @@ dependencies = [ "crypto-mac", "hmac", "rand 0.5.5", - "sha2 0.8.0", + "sha2", "subtle 1.0.0", ] @@ -4350,8 +4253,8 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.0", + "block-buffer", + "digest", "opaque-debug", ] @@ -4519,11 +4422,11 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "656c79d0e90d0ab28ac86bf3c3d10bfbbac91450d3f190113b4e76d9fec3cfdd" dependencies = [ - "byte-tools 0.3.1", + "byte-tools", "byteorder", "hmac", "pbkdf2", - "sha2 0.8.0", + "sha2", ] [[package]] @@ -4629,38 +4532,20 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.0", + "block-buffer", + "digest", "fake-simd", "opaque-debug", ] -[[package]] -name = "sha1" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171698ce4ec7cbb93babeb3190021b4d72e96ccb98e33d277ae4ea959d6f2d9e" - -[[package]] -name = "sha2" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0" -dependencies = [ - "block-buffer 0.3.3", - "byte-tools 0.2.0", - "digest 0.7.6", - "fake-simd", -] - [[package]] name = "sha2" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.0", + "block-buffer", + "digest", "fake-simd", "opaque-debug", ] @@ -4919,7 +4804,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" dependencies = [ - "generic-array 0.12.0", + "generic-array", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0c773ef40..c9dc4b661 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,6 @@ parity-bytes = "0.1" parity-crypto = { version = "0.5.0", features = ["publickey"] } parity-daemonize = "0.3" parity-hash-fetch = { path = "updater/hash-fetch" } -parity-ipfs-api = { path = "ipfs" } parity-local-store = { path = "miner/local-store" } parity-path = "0.1" parity-rpc = { path = "rpc" } diff --git a/README.md b/README.md index 660ac6ca3..afb433920 100644 --- a/README.md +++ b/README.md @@ -264,10 +264,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 4d35547aa..000000000 --- a/ipfs/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -description = "Parity Ethereum IPFS-compatible API" -name = "parity-ipfs-api" -version = "1.12.0" -license = "GPL-3.0" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -client-traits = { path = "../ethcore/client-traits" } -common-types = { path = "../ethcore/types" } -bytes = { package = "parity-bytes", version = "0.1"} -ethereum-types = "0.8.0" -jsonrpc-core = "14.0.3" -http = { package = "jsonrpc-http-server", version = "14.0.3"} -rlp = "0.4.0" -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 7229ab5ea..000000000 --- a/ipfs/src/error.rs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2015-2020 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 crate::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 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 143d6084e..000000000 --- a/ipfs/src/lib.rs +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2015-2020 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 . - -pub mod error; -mod route; - -use std::thread; -use std::sync::{mpsc, Arc}; -use std::net::{SocketAddr, IpAddr}; - -use jsonrpc_core::futures::future::{self, FutureResult}; -use jsonrpc_core::futures::{self, Future}; -use client_traits::BlockChainClient; -use http::hyper::{self, server, Method, StatusCode, Body, - header::{self, HeaderValue}, -}; - -use error::ServerError; -use route::Out; - -pub use http::{AccessControlAllowOrigin, Host, DomainsValidation}; - -/// 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 724a9d7a8..000000000 --- a/ipfs/src/route.rs +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2015-2020 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 crate::{ - IpfsHandler, - error::{Error, Result}, -}; - -use bytes::Bytes; -use cid::{ToCid, Codec}; -use common_types::ids::{BlockId, TransactionId}; -use ethereum_types::H256; -use multihash::{self, Hash}; -use rlp; - -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::from_slice(&mh.digest); - - 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 std::sync::Arc; - use super::*; - use ethcore::test_helpers::TestBlockChainClient; - - 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 1f303c196..2b1932842 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -321,7 +321,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,dapps,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,dapps,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]", @@ -329,7 +329,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(), @@ -576,27 +576,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, rpc, 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, rpc", - ["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\".", - ["Light Client Options"] ARG arg_on_demand_response_time_window: (Option) = None, or |c: &Config| c.light.as_ref()?.on_demand_response_time_window, "--on-demand-time-window=[S]", @@ -1163,7 +1142,6 @@ struct Config { dapps: Option, secretstore: Option, private_tx: Option, - ipfs: Option, mining: Option, footprint: Option, snapshots: Option, @@ -1344,16 +1322,6 @@ struct SecretStore { cors: 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 { @@ -1458,7 +1426,7 @@ struct Light { mod tests { use super::{ Args, ArgsError, - Config, Operating, Account, Ui, Network, Ws, Rpc, Ipc, Dapps, Ipfs, Mining, Footprint, + Config, Operating, Account, Ui, Network, Ws, Rpc, Ipc, Dapps, Mining, Footprint, Snapshots, Misc, Whisper, SecretStore, Light, }; use toml; @@ -1871,13 +1839,6 @@ mod tests { arg_secretstore_path: "$HOME/.parity/secretstore".into(), arg_secretstore_http_cors: "null".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()), @@ -2151,13 +2112,6 @@ mod tests { cors: 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 e4c2c9f47..087db0a1c 100644 --- a/parity/cli/presets/config.dev-insecure.toml +++ b/parity/cli/presets/config.dev-insecure.toml @@ -10,7 +10,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 18859c9cc..c5ce3845a 100644 --- a/parity/cli/presets/config.insecure.toml +++ b/parity/cli/presets/config.insecure.toml @@ -5,7 +5,3 @@ no_consensus = true 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 a1b5b2904..f58fab3d8 100644 --- a/parity/cli/tests/config.full.toml +++ b/parity/cli/tests/config.full.toml @@ -108,13 +108,6 @@ port = 8083 path = "$HOME/.parity/secretstore" cors = ["null"] -[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 315621e2c..4d032c5d1 100644 --- a/parity/cli/tests/config.toml +++ b/parity/cli/tests/config.toml @@ -45,10 +45,6 @@ pass = "password" 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 f1b5749f7..db65c6189 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -42,7 +42,6 @@ use dir::helpers::{replace_home, replace_home_and_local}; use params::{ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras, SpecType}; use ethcore_logger::Config as LogConfig; use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path}; -use ipfs::Configuration as IpfsConfiguration; use ethcore_private_tx::{ProviderConfig, EncryptorConfig}; use secretstore::{NodeSecretKey, Configuration as SecretStoreConfiguration, ContractAddress as SecretStoreContractAddress}; use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack}; @@ -139,7 +138,6 @@ impl Configuration { let warp_sync = !self.args.flag_no_warp; let geth_compatibility = self.args.flag_geth; let experimental_rpcs = self.args.flag_jsonrpc_experimental; - let ipfs_conf = self.ipfs_config(); let secretstore_conf = self.secretstore_config()?; let format = self.format()?; @@ -396,7 +394,6 @@ impl Configuration { geth_compatibility, experimental_rpcs, net_settings: self.network_settings()?, - ipfs_conf, secretstore_conf, private_provider_conf, private_encryptor_conf: private_enc_conf, @@ -632,16 +629,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; @@ -817,10 +804,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; @@ -859,10 +842,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 { chmod: self.args.arg_ipc_chmod.clone(), @@ -1060,10 +1039,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) } @@ -1456,7 +1431,6 @@ mod tests { geth_compatibility: false, 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(), @@ -1616,38 +1590,6 @@ mod tests { assert_eq!(http_conf.max_payload, 5); } - #[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 @@ -1760,7 +1702,6 @@ mod tests { } // "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts"); assert_eq!(c.http_conf.hosts, None); - assert_eq!(c.ipfs_conf.hosts, None); }, _ => panic!("Should be Cmd::Run"), } @@ -1783,7 +1724,6 @@ mod tests { } // "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts"); assert_eq!(c.http_conf.hosts, None); - assert_eq!(c.ipfs_conf.hosts, None); }, _ => panic!("Should be Cmd::Run"), } @@ -1830,7 +1770,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); @@ -1840,7 +1779,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] @@ -1886,8 +1824,6 @@ mod tests { assert_eq!(conf0.ws_config().unwrap().origins, None); assert_eq!(&conf0.secretstore_config().unwrap().interface, "0.0.0.0"); assert_eq!(&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 5dbc4b615..000000000 --- a/parity/ipfs.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2015-2020 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 std::sync::Arc; -use parity_ipfs_api::{self, AccessControlAllowOrigin, Host, Listening}; -use parity_ipfs_api::error::ServerError; -use client_traits::BlockChainClient; - -#[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 c2e78a5b3..0d793d27c 100644 --- a/parity/lib.rs +++ b/parity/lib.rs @@ -65,7 +65,6 @@ extern crate node_filter; extern crate parity_bytes as bytes; extern crate parity_crypto; extern crate parity_hash_fetch as hash_fetch; -extern crate parity_ipfs_api; extern crate parity_local_store as local_store; extern crate parity_path as path; extern crate parity_rpc; @@ -106,7 +105,6 @@ mod cache; mod cli; mod configuration; mod export_hardcoded_sync; -mod ipfs; mod deprecated; mod helpers; mod informant; diff --git a/parity/run.rs b/parity/run.rs index 67b763c89..5cf7daeb7 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -58,7 +58,6 @@ use helpers::{to_client_config, execute_upgrades, passwords_from_files}; use dir::{Directories, DatabaseDirectories}; use cache::CacheConfig; use user_defaults::UserDefaults; -use ipfs; use jsonrpc_core; use modules; use rpc; @@ -116,7 +115,6 @@ pub struct RunCmd { pub geth_compatibility: bool, 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, @@ -761,9 +759,6 @@ fn execute_impl( }; let secretstore_key_server = secretstore::start(cmd.secretstore_conf.clone(), secretstore_deps, runtime.executor())?; - // the ipfs server - let ipfs_server = ipfs::start_server(cmd.ipfs_conf.clone(), client.clone())?; - // the informant let informant = Arc::new(Informant::new( FullNodeInformantData { @@ -821,7 +816,7 @@ fn execute_impl( informant, client, client_service: Arc::new(service), - keep_alive: Box::new((watcher, updater, ws_server, http_server, ipc_server, secretstore_key_server, ipfs_server, runtime)), + keep_alive: Box::new((watcher, updater, ws_server, http_server, ipc_server, secretstore_key_server, runtime)), } }) } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index dcf0bc702..3aeb5fa68 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -9,10 +9,8 @@ authors = ["Parity Technologies "] [dependencies] ansi_term = "0.11" -cid = "0.3" futures = "0.1.6" log = "0.4" -multihash = "0.8" order-stat = "0.1" rand = "0.7" rand_xorshift = "0.2" diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 126d22926..8f995b72c 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -41,10 +41,8 @@ extern crate futures; extern crate ansi_term; -extern crate cid; extern crate itertools; extern crate machine; -extern crate multihash; extern crate order_stat; extern crate parking_lot; extern crate rand; diff --git a/rpc/src/v1/helpers/ipfs.rs b/rpc/src/v1/helpers/ipfs.rs deleted file mode 100644 index 8ecbd731d..000000000 --- a/rpc/src/v1/helpers/ipfs.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015-2020 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 multihash; -use cid::{Cid, Codec, Version}; -use crypto::digest; -use jsonrpc_core::Error; -use v1::types::Bytes; -use super::errors; - -/// 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 ac517eab7..ff3c60dcf 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 light_fetch; pub mod nonce; #[cfg(any(test, feature = "accounts"))] diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index b478ae746..6c08167e3 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -33,7 +33,7 @@ use ethcore_logger::RotatingLogger; use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::{future, Future}; use light::on_demand::OnDemandRequester; -use v1::helpers::{self, errors, ipfs, NetworkSettings, verify_signature}; +use v1::helpers::{self, errors, NetworkSettings, verify_signature}; use v1::helpers::external_signer::{SignerService, SigningQueue}; use v1::helpers::dispatch::LightDispatcher; use v1::helpers::light_fetch::{LightFetch, light_all_transactions}; @@ -372,10 +372,6 @@ where Box::new(self.fetcher().receipts(id).and_then(|receipts| Ok(receipts.into_iter().map(Into::into).collect()))) } - fn ipfs_cid(&self, content: Bytes) -> Result { - ipfs::cid(content) - } - fn call(&self, _requests: Vec, _block: Option) -> Result> { Err(errors::light_unimplemented(None)) } diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index fe45defc4..505393ffb 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -40,7 +40,7 @@ use types::{ use updater::{Service as UpdateService}; use version::version_data; -use v1::helpers::{self, errors, fake_sign, ipfs, NetworkSettings, verify_signature}; +use v1::helpers::{self, errors, fake_sign, NetworkSettings, verify_signature}; use v1::helpers::external_signer::{SigningQueue, SignerService}; use v1::metadata::Metadata; use v1::traits::Parity; @@ -396,10 +396,6 @@ impl Parity for ParityClient 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 0e906147d..d2c60b41c 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -469,17 +469,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 728dc31e7..27e2a8e6f 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -207,10 +207,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..682edf3fa 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 +# secret +# store ui rpc ws listener discovery # ↓ ↓ ↓ ↓ ↓ ↓ ↓ -EXPOSE 5001 8082 8083 8180 8545 8546 30303/tcp 30303/udp +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