Remove whisper (#10855)

This commit is contained in:
Artem Vorotnikov
2020-08-12 13:00:28 +03:00
parent 3f42b6178f
commit 54afb33333
31 changed files with 8 additions and 4520 deletions

View File

@@ -483,9 +483,9 @@ usage! {
"--jsonrpc-interface=[IP]",
"Specify the hostname portion of the HTTP JSON-RPC API server, IP should be an interface's IP address, or all (all interfaces) or local.",
ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,private,parity_pubsub,traces,shh,shh_pubsub", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,private,parity_pubsub,traces", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--jsonrpc-apis=[APIS]",
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore, shh, shh_pubsub. 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, shh, shh_pubsub",
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, 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",
ARG arg_jsonrpc_hosts: (String) = "none", or |c: &Config| c.rpc.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")),
"--jsonrpc-hosts=[HOSTS]",
@@ -524,9 +524,9 @@ usage! {
"--ws-interface=[IP]",
"Specify the hostname portion of the WebSockets JSON-RPC server, IP should be an interface's IP address, or all (all interfaces) or local.",
ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,private,traces,shh,shh_pubsub", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,private,traces", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--ws-apis=[APIS]",
"Specify the JSON-RPC APIs available through the WebSockets interface 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, shh, shh_pubsub. 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, shh, shh_pubsub",
"Specify the JSON-RPC APIs available through the WebSockets interface 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",
ARG arg_ws_origins: (String) = "parity://*,chrome-extension://*,moz-extension://*", or |c: &Config| c.websockets.as_ref()?.origins.as_ref().map(|vec| vec.join(",")),
"--ws-origins=[URL]",
@@ -549,9 +549,9 @@ usage! {
"--ipc-path=[PATH]",
"Specify custom path for JSON-RPC over IPC service.",
ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,private,traces,shh,shh_pubsub", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,private,traces", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--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, shh, shh_pubsub. 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, shh, shh_pubsub",
"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(),
@@ -905,15 +905,6 @@ usage! {
ARG arg_snapshot_threads: (Option<usize>) = None, or |c: &Config| c.snapshots.as_ref()?.processing_threads,
"--snapshot-threads=[NUM]",
"Enables multiple threads for snapshots creation.",
["Whisper Options"]
FLAG flag_whisper: (bool) = false, or |c: &Config| c.whisper.as_ref()?.enabled,
"--whisper",
"Enable the Whisper network.",
ARG arg_whisper_pool_size: (usize) = 10usize, or |c: &Config| c.whisper.as_ref()?.pool_size.clone(),
"--whisper-pool-size=[MB]",
"Target size of the whisper message pool in megabytes.",
}
}
@@ -935,7 +926,6 @@ struct Config {
snapshots: Option<Snapshots>,
misc: Option<Misc>,
stratum: Option<Stratum>,
whisper: Option<Whisper>,
light: Option<Light>,
}
@@ -1164,13 +1154,6 @@ struct Misc {
unsafe_expose: Option<bool>,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
struct Whisper {
enabled: Option<bool>,
pool_size: Option<usize>,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
struct Light {
@@ -1185,7 +1168,7 @@ struct Light {
mod tests {
use super::{
Account, Args, ArgsError, Config, Footprint, Ipc, Ipfs, Light, Mining, Misc, Network,
Operating, Rpc, SecretStore, Snapshots, Whisper, Ws,
Operating, Rpc, SecretStore, Snapshots, Ws,
};
use clap::ErrorKind as ClapErrorKind;
use toml;
@@ -1606,10 +1589,6 @@ mod tests {
arg_on_demand_request_backoff_rounds_max: Some(100),
arg_on_demand_request_consecutive_failures: Some(1),
// -- Whisper options.
flag_whisper: false,
arg_whisper_pool_size: 20,
// -- Internal Options
flag_can_restart: false,
@@ -1826,10 +1805,6 @@ mod tests {
ports_shift: Some(0),
unsafe_expose: Some(false),
}),
whisper: Some(Whisper {
enabled: Some(true),
pool_size: Some(50),
}),
stratum: None,
}
);

View File

@@ -156,7 +156,3 @@ disable_periodic = false
logging = "own_tx=trace"
log_file = "/var/log/parity.log"
color = true
[whisper]
enabled = false
pool_size = 20

View File

@@ -78,7 +78,3 @@ log_file = "/var/log/parity.log"
color = true
ports_shift = 0
unsafe_expose = false
[whisper]
enabled = true
pool_size = 50

View File

@@ -398,7 +398,6 @@ impl Configuration {
};
let verifier_settings = self.verifier_settings();
let whisper_config = self.whisper_config();
let (private_provider_conf, private_enc_conf, private_tx_enabled) =
self.private_provider_config()?;
@@ -448,7 +447,6 @@ impl Configuration {
serve_light: !self.args.flag_no_serve_light,
light: self.args.flag_light,
no_persistent_txqueue: self.args.flag_no_persistent_txqueue,
whisper: whisper_config,
no_hardcoded_sync: self.args.flag_no_hardcoded_sync,
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
on_demand_response_time_window: self.args.arg_on_demand_response_time_window,
@@ -1332,13 +1330,6 @@ impl Configuration {
settings
}
fn whisper_config(&self) -> ::whisper::Config {
::whisper::Config {
enabled: self.args.flag_whisper,
target_message_pool_size: self.args.arg_whisper_pool_size * 1024 * 1024,
}
}
}
fn into_secretstore_service_contract_address(
@@ -1687,7 +1678,6 @@ mod tests {
light: false,
no_hardcoded_sync: false,
no_persistent_txqueue: false,
whisper: Default::default(),
max_round_blocks_to_import: 12,
on_demand_response_time_window: None,
on_demand_request_backoff_start: None,

View File

@@ -69,7 +69,6 @@ extern crate parity_rpc;
extern crate parity_runtime;
extern crate parity_updater as updater;
extern crate parity_version;
extern crate parity_whisper;
extern crate registrar;
#[macro_use]
@@ -115,7 +114,6 @@ mod signer;
mod snapshot;
mod upgrade;
mod user_defaults;
mod whisper;
use std::{fs::File, io::BufReader, sync::Arc};

View File

@@ -18,7 +18,7 @@ use std::sync::{mpsc, Arc};
use ethcore::{client::BlockChainClient, snapshot::SnapshotService};
use light::Provider;
use sync::{self, AttachedProtocol, ConnectionFilter, NetworkConfiguration, Params, SyncConfig};
use sync::{self, ConnectionFilter, NetworkConfiguration, Params, SyncConfig};
pub use ethcore::client::ChainNotify;
use ethcore_logger::Config as LogConfig;
@@ -39,7 +39,6 @@ pub fn sync(
private_tx_handler: Option<Arc<dyn PrivateTxHandler>>,
provider: Arc<dyn Provider>,
_log_settings: &LogConfig,
attached_protos: Vec<AttachedProtocol>,
connection_filter: Option<Arc<dyn ConnectionFilter>>,
) -> Result<SyncModules, sync::Error> {
let eth_sync = EthSync::new(
@@ -50,7 +49,6 @@ pub fn sync(
snapshot_service,
private_tx_handler,
network_config,
attached_protos,
},
connection_filter,
)?;

View File

@@ -64,12 +64,6 @@ pub enum Api {
Traces,
/// Private transaction manager (Safe)
Private,
/// Whisper (Safe)
// TODO: _if_ someone guesses someone else's key or filter IDs they can remove
// BUT these are all ephemeral so it seems fine.
Whisper,
/// Whisper Pub-Sub (Safe but same concerns as above).
WhisperPubSub,
/// Parity PubSub - Generic Publish-Subscriber (Safety depends on other APIs exposed).
ParityPubSub,
/// Parity Accounts extensions (UNSAFE: Passwords, Side Effects (new account))
@@ -101,8 +95,6 @@ impl FromStr for Api {
"private" => Ok(Private),
"pubsub" => Ok(EthPubSub),
"secretstore" => Ok(SecretStore),
"shh" => Ok(Whisper),
"shh_pubsub" => Ok(WhisperPubSub),
"signer" => Ok(Signer),
"traces" => Ok(Traces),
"web3" => Ok(Web3),
@@ -220,7 +212,6 @@ pub struct FullDependencies {
pub ws_address: Option<Host>,
pub fetch: FetchClient,
pub executor: Executor,
pub whisper_rpc: Option<::whisper::RpcFactory>,
pub gas_price_percentile: usize,
pub poll_lifetime: u32,
pub allow_missing_blocks: bool,
@@ -407,22 +398,6 @@ impl FullDependencies {
#[cfg(feature = "accounts")]
handler.extend_with(SecretStoreClient::new(&self.accounts).to_delegate());
}
Api::Whisper => {
if let Some(ref whisper_rpc) = self.whisper_rpc {
let whisper = whisper_rpc.make_handler(self.net.clone());
handler.extend_with(::parity_whisper::rpc::Whisper::to_delegate(whisper));
}
}
Api::WhisperPubSub => {
if !for_generic_pubsub {
if let Some(ref whisper_rpc) = self.whisper_rpc {
let whisper = whisper_rpc.make_handler(self.net.clone());
handler.extend_with(::parity_whisper::rpc::WhisperPubSub::to_delegate(
whisper,
));
}
}
}
Api::Private => {
handler.extend_with(
PrivateClient::new(self.private_tx_service.as_ref().map(|p| p.provider()))
@@ -474,7 +449,6 @@ pub struct LightDependencies<T> {
pub fetch: FetchClient,
pub experimental_rpcs: bool,
pub executor: Executor,
pub whisper_rpc: Option<::whisper::RpcFactory>,
pub private_tx_service: Option<Arc<PrivateTransactionManager>>,
pub gas_price_percentile: usize,
pub poll_lifetime: u32,
@@ -640,20 +614,6 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
#[cfg(feature = "accounts")]
handler.extend_with(SecretStoreClient::new(&self.accounts).to_delegate());
}
Api::Whisper => {
if let Some(ref whisper_rpc) = self.whisper_rpc {
let whisper = whisper_rpc.make_handler(self.net.clone());
handler.extend_with(::parity_whisper::rpc::Whisper::to_delegate(whisper));
}
}
Api::WhisperPubSub => {
if let Some(ref whisper_rpc) = self.whisper_rpc {
let whisper = whisper_rpc.make_handler(self.net.clone());
handler.extend_with(::parity_whisper::rpc::WhisperPubSub::to_delegate(
whisper,
));
}
}
Api::Private => {
if let Some(ref tx_manager) = self.private_tx_service {
let private_tx_service = Some(tx_manager.clone());
@@ -693,8 +653,6 @@ impl ApiSet {
Api::Eth,
Api::EthPubSub,
Api::Parity,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
]
.iter()
@@ -758,8 +716,6 @@ mod test {
assert_eq!(Api::Traces, "traces".parse().unwrap());
assert_eq!(Api::SecretStore, "secretstore".parse().unwrap());
assert_eq!(Api::Private, "private".parse().unwrap());
assert_eq!(Api::Whisper, "shh".parse().unwrap());
assert_eq!(Api::WhisperPubSub, "shh_pubsub".parse().unwrap());
assert!("rp".parse::<Api>().is_err());
}
@@ -787,8 +743,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
]
.into_iter()
@@ -807,8 +761,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
// semi-safe
Api::ParityAccounts,
@@ -832,8 +784,6 @@ mod test {
Api::ParityPubSub,
Api::Traces,
Api::SecretStore,
Api::Whisper,
Api::WhisperPubSub,
Api::ParityAccounts,
Api::ParitySet,
Api::Signer,
@@ -861,8 +811,6 @@ mod test {
Api::ParityPubSub,
Api::Traces,
Api::SecretStore,
Api::Whisper,
Api::WhisperPubSub,
Api::ParityAccounts,
Api::ParitySet,
Api::Signer,
@@ -888,8 +836,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
]
.into_iter()

View File

@@ -135,7 +135,6 @@ pub struct RunCmd {
pub serve_light: bool,
pub light: bool,
pub no_persistent_txqueue: bool,
pub whisper: ::whisper::Config,
pub no_hardcoded_sync: bool,
pub max_round_blocks_to_import: usize,
pub on_demand_response_time_window: Option<u64>,
@@ -309,16 +308,6 @@ where
net_conf.boot_nodes = spec.nodes.clone();
}
let mut attached_protos = Vec::new();
let whisper_factory = if cmd.whisper.enabled {
let whisper_factory =
::whisper::setup(cmd.whisper.target_message_pool_size, &mut attached_protos)
.map_err(|e| format!("Failed to initialize whisper: {}", e))?;
whisper_factory
} else {
None
};
// set network path.
net_conf.net_config_path = Some(db_dirs.network_path().to_string_lossy().into_owned());
let sync_params = LightSyncParams {
@@ -329,7 +318,6 @@ where
network_id: cmd.network_id.unwrap_or(spec.network_id()),
subprotocol_name: sync::LIGHT_PROTOCOL,
handlers: vec![on_demand.clone()],
attached_protos: attached_protos,
};
let light_sync =
LightSync::new(sync_params).map_err(|e| format!("Error starting network: {}", e))?;
@@ -376,7 +364,6 @@ where
fetch: fetch,
experimental_rpcs: cmd.experimental_rpcs,
executor: runtime.executor(),
whisper_rpc: whisper_factory,
private_tx_service: None, //TODO: add this to client.
gas_price_percentile: cmd.gas_price_percentile,
poll_lifetime: cmd.poll_lifetime,
@@ -748,18 +735,6 @@ where
.map_err(|e| format!("Stratum start error: {:?}", e))?;
}
let mut attached_protos = Vec::new();
let whisper_factory = if cmd.whisper.enabled {
let whisper_factory =
::whisper::setup(cmd.whisper.target_message_pool_size, &mut attached_protos)
.map_err(|e| format!("Failed to initialize whisper: {}", e))?;
whisper_factory
} else {
None
};
let private_tx_sync: Option<Arc<dyn PrivateTxHandler>> = match cmd.private_tx_enabled {
true => Some(private_tx_service.clone() as Arc<dyn PrivateTxHandler>),
false => None,
@@ -774,7 +749,6 @@ where
private_tx_sync,
client.clone(),
&cmd.logger_config,
attached_protos,
connection_filter
.clone()
.map(|f| f as Arc<dyn crate::sync::ConnectionFilter + 'static>),
@@ -867,7 +841,6 @@ where
ws_address: cmd.ws_conf.address(),
fetch: fetch.clone(),
executor: runtime.executor(),
whisper_rpc: whisper_factory,
private_tx_service: Some(private_tx_service.clone()),
gas_price_percentile: cmd.gas_price_percentile,
poll_lifetime: cmd.poll_lifetime,

View File

@@ -1,127 +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 <http://www.gnu.org/licenses/>.
use std::{io, sync::Arc};
use parity_rpc::Metadata;
use parity_whisper::{
message::Message,
net::{self as whisper_net, Network as WhisperNetwork},
rpc::{FilterManager, PoolHandle, WhisperClient},
};
use sync::{AttachedProtocol, ManageNetwork};
/// Whisper config.
#[derive(Debug, PartialEq, Eq)]
pub struct Config {
pub enabled: bool,
pub target_message_pool_size: usize,
}
impl Default for Config {
fn default() -> Self {
Config {
enabled: false,
target_message_pool_size: 10 * 1024 * 1024,
}
}
}
/// Standard pool handle.
pub struct NetPoolHandle {
/// Pool handle.
handle: Arc<WhisperNetwork<Arc<FilterManager>>>,
/// Network manager.
net: Arc<dyn ManageNetwork>,
}
impl PoolHandle for NetPoolHandle {
fn relay(&self, message: Message) -> bool {
let mut res = false;
let mut message = Some(message);
self.net
.with_proto_context(whisper_net::PROTOCOL_ID, &mut |ctx| {
if let Some(message) = message.take() {
res = self.handle.post_message(message, ctx);
}
});
res
}
fn pool_status(&self) -> whisper_net::PoolStatus {
self.handle.pool_status()
}
}
/// Factory for standard whisper RPC.
pub struct RpcFactory {
net: Arc<WhisperNetwork<Arc<FilterManager>>>,
manager: Arc<FilterManager>,
}
impl RpcFactory {
pub fn make_handler(
&self,
net: Arc<dyn ManageNetwork>,
) -> WhisperClient<NetPoolHandle, Metadata> {
let handle = NetPoolHandle {
handle: self.net.clone(),
net: net,
};
WhisperClient::new(handle, self.manager.clone())
}
}
/// Sets up whisper protocol and RPC handler.
///
/// Will target the given pool size.
#[cfg(not(feature = "ipc"))]
pub fn setup(
target_pool_size: usize,
protos: &mut Vec<AttachedProtocol>,
) -> io::Result<Option<RpcFactory>> {
let manager = Arc::new(FilterManager::new()?);
let net = Arc::new(WhisperNetwork::new(target_pool_size, manager.clone()));
protos.push(AttachedProtocol {
handler: net.clone() as Arc<_>,
versions: whisper_net::SUPPORTED_VERSIONS,
protocol_id: whisper_net::PROTOCOL_ID,
});
// parity-only extensions to whisper.
protos.push(AttachedProtocol {
handler: Arc::new(whisper_net::ParityExtensions),
versions: whisper_net::SUPPORTED_VERSIONS,
protocol_id: whisper_net::PARITY_PROTOCOL_ID,
});
let factory = RpcFactory {
net: net,
manager: manager,
};
Ok(Some(factory))
}
// TODO: make it possible to attach generic protocols in IPC.
#[cfg(feature = "ipc")]
pub fn setup(
_target_pool_size: usize,
_protos: &mut Vec<AttachedProtocol>,
) -> io::Result<Option<RpcFactory>> {
Ok(None)
}