Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Remove public node settings from cli #8758

Merged
merged 5 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,6 @@ usage! {
{
// Global flags and arguments
["Operating Options"]
FLAG flag_public_node: (bool) = false, or |c: &Config| c.parity.as_ref()?.public_node.clone(),
"--public-node",
"Start Parity as a public web server. Account storage and transaction signing will be delegated to the UI.",

FLAG flag_no_download: (bool) = false, or |c: &Config| c.parity.as_ref()?.no_download.clone(),
"--no-download",
"Normally new releases will be downloaded ready for updating. This disables it. Not recommended.",
Expand Down Expand Up @@ -948,6 +944,10 @@ usage! {
"--rpc",
"Does nothing; JSON-RPC is on by default now.",

FLAG flag_public_node: (bool) = false, or |_| None,
"--public-node",
"Does nothing; Public node is removed from Parity.",

ARG arg_dapps_port: (Option<u16>) = None, or |c: &Config| c.dapps.as_ref()?.port.clone(),
"--dapps-port=[PORT]",
"Dapps server is merged with RPC server. Use --jsonrpc-port.",
Expand Down Expand Up @@ -1070,7 +1070,6 @@ struct Operating {
auto_update_delay: Option<u16>,
auto_update_check_frequency: Option<u16>,
release_track: Option<String>,
public_node: Option<bool>,
no_download: Option<bool>,
no_consensus: Option<bool>,
chain: Option<String>,
Expand All @@ -1081,6 +1080,9 @@ struct Operating {
light: Option<bool>,
no_persistent_txqueue: Option<bool>,
no_hardcoded_sync: Option<bool>,

#[serde(rename="public_node")]
_legacy_public_node: Option<bool>,
}

#[derive(Default, Debug, PartialEq, Deserialize)]
Expand Down Expand Up @@ -1797,7 +1799,6 @@ mod tests {
auto_update_delay: None,
auto_update_check_frequency: None,
release_track: None,
public_node: None,
no_download: None,
no_consensus: None,
chain: Some("./chain.json".into()),
Expand All @@ -1808,6 +1809,7 @@ mod tests {
light: None,
no_hardcoded_sync: None,
no_persistent_txqueue: None,
_legacy_public_node: None,
}),
account: Some(Account {
unlock: Some(vec!["0x1".into(), "0x2".into(), "0x3".into()]),
Expand Down
16 changes: 4 additions & 12 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use ethcore::verification::queue::VerifierSettings;
use miner::pool;

use rpc::{IpcConfiguration, HttpConfiguration, WsConfiguration, UiConfiguration};
use rpc_apis::ApiSet;
use parity_rpc::NetworkSettings;
use cache::CacheConfig;
use helpers::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_price, geth_ipc_path, parity_ipc_path, to_bootnodes, to_addresses, to_address, to_queue_strategy, to_queue_penalization, passwords_from_files};
Expand Down Expand Up @@ -138,7 +137,6 @@ impl Configuration {
let fat_db = self.args.arg_fat_db.parse()?;
let compaction = self.args.arg_db_compaction.parse()?;
let wal = !self.args.flag_fast_and_loose;
let public_node = self.args.flag_public_node;
let warp_sync = !self.args.flag_no_warp;
let geth_compatibility = self.args.flag_geth;
let dapps_conf = self.dapps_config();
Expand Down Expand Up @@ -379,7 +377,6 @@ impl Configuration {
vm_type: vm_type,
warp_sync: warp_sync,
warp_barrier: self.args.arg_warp_barrier,
public_node: public_node,
geth_compatibility: geth_compatibility,
net_settings: self.network_settings()?,
dapps_conf: dapps_conf,
Expand Down Expand Up @@ -914,10 +911,7 @@ impl Configuration {
enabled: self.rpc_enabled(),
interface: self.rpc_interface(),
port: self.args.arg_ports_shift + self.args.arg_rpcport.unwrap_or(self.args.arg_jsonrpc_port),
apis: match self.args.flag_public_node {
false => self.rpc_apis().parse()?,
true => self.rpc_apis().parse::<ApiSet>()?.retain(ApiSet::PublicContext),
},
apis: self.rpc_apis().parse()?,
hosts: self.rpc_hosts(),
cors: self.rpc_cors(),
server_threads: match self.args.arg_jsonrpc_server_threads {
Expand All @@ -935,10 +929,8 @@ impl Configuration {
let http = self.http_config()?;

let support_token_api =
// never enabled for public node
!self.args.flag_public_node
// enabled when not unlocking unless the ui is forced
&& (self.args.arg_unlock.is_none() || ui.enabled);
// enabled when not unlocking
self.args.arg_unlock.is_none();

let conf = WsConfiguration {
enabled: self.ws_enabled(),
Expand Down Expand Up @@ -1263,6 +1255,7 @@ mod tests {
use params::SpecType;
use presale::ImportWallet;
use rpc::{WsConfiguration, UiConfiguration};
use rpc_apis::ApiSet;
use run::RunCmd;

use network::{AllowIP, IpFilter};
Expand Down Expand Up @@ -1499,7 +1492,6 @@ mod tests {
ipc_conf: Default::default(),
net_conf: default_network_config(),
network_id: None,
public_node: false,
warp_sync: true,
warp_barrier: None,
acc_conf: Default::default(),
Expand Down
23 changes: 8 additions & 15 deletions parity/rpc_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ pub enum ApiSet {
SafeContext,
// Unsafe context (like jsonrpc over http)
UnsafeContext,
// Public context (like public jsonrpc over http)
PublicContext,
// All possible APIs
All,
// Local "unsafe" context and accounts access
Expand Down Expand Up @@ -219,7 +217,7 @@ pub struct FullDependencies {
pub snapshot: Arc<SnapshotService>,
pub sync: Arc<SyncProvider>,
pub net: Arc<ManageNetwork>,
pub secret_store: Option<Arc<AccountProvider>>,
pub secret_store: Arc<AccountProvider>,
pub private_tx_service: Option<Arc<PrivateTxService>>,
pub miner: Arc<Miner>,
pub external_miner: Arc<ExternalMiner>,
Expand Down Expand Up @@ -316,7 +314,7 @@ impl FullDependencies {
}
},
Api::Personal => {
handler.extend_with(PersonalClient::new(self.secret_store.clone(), dispatcher.clone(), self.geth_compatibility).to_delegate());
handler.extend_with(PersonalClient::new(&self.secret_store, dispatcher.clone(), self.geth_compatibility).to_delegate());
},
Api::Signer => {
handler.extend_with(SignerClient::new(&self.secret_store, dispatcher.clone(), &self.signer_service, self.remote.clone()).to_delegate());
Expand Down Expand Up @@ -475,7 +473,7 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
{
let deps = &$deps;
let dispatcher = dispatcher.clone();
let secret_store = Some(deps.secret_store.clone());
let secret_store = deps.secret_store.clone();
if deps.signer_service.is_enabled() {
$handler.extend_with($namespace::to_delegate(
SigningQueueClient::new(&deps.signer_service, dispatcher, deps.remote.clone(), &secret_store)
Expand Down Expand Up @@ -533,12 +531,10 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
handler.extend_with(EthPubSub::to_delegate(client));
},
Api::Personal => {
let secret_store = Some(self.secret_store.clone());
handler.extend_with(PersonalClient::new(secret_store, dispatcher.clone(), self.geth_compatibility).to_delegate());
handler.extend_with(PersonalClient::new(&self.secret_store, dispatcher.clone(), self.geth_compatibility).to_delegate());
},
Api::Signer => {
let secret_store = Some(self.secret_store.clone());
handler.extend_with(SignerClient::new(&secret_store, dispatcher.clone(), &self.signer_service, self.remote.clone()).to_delegate());
handler.extend_with(SignerClient::new(&self.secret_store, dispatcher.clone(), &self.signer_service, self.remote.clone()).to_delegate());
},
Api::Parity => {
let signer = match self.signer_service.is_enabled() {
Expand Down Expand Up @@ -571,8 +567,7 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
}
},
Api::ParityAccounts => {
let secret_store = Some(self.secret_store.clone());
handler.extend_with(ParityAccountsClient::new(&secret_store).to_delegate());
handler.extend_with(ParityAccountsClient::new(&self.secret_store).to_delegate());
},
Api::ParitySet => {
handler.extend_with(light::ParitySetClient::new(
Expand All @@ -590,8 +585,7 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
handler.extend_with(RpcClient::new(modules).to_delegate());
},
Api::SecretStore => {
let secret_store = Some(self.secret_store.clone());
handler.extend_with(SecretStoreClient::new(&secret_store).to_delegate());
handler.extend_with(SecretStoreClient::new(&self.secret_store).to_delegate());
},
Api::Whisper => {
if let Some(ref whisper_rpc) = self.whisper_rpc {
Expand Down Expand Up @@ -637,7 +631,7 @@ impl ApiSet {
}

pub fn list_apis(&self) -> HashSet<Api> {
let mut public_list = [
let mut public_list: HashSet<Api> = [
Api::Web3,
Api::Net,
Api::Eth,
Expand All @@ -651,7 +645,6 @@ impl ApiSet {

match *self {
ApiSet::List(ref apis) => apis.clone(),
ApiSet::PublicContext => public_list,
ApiSet::UnsafeContext => {
public_list.insert(Api::Traces);
public_list.insert(Api::ParityPubSub);
Expand Down
7 changes: 1 addition & 6 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ pub struct RunCmd {
pub network_id: Option<u64>,
pub warp_sync: bool,
pub warp_barrier: Option<u64>,
pub public_node: bool,
pub acc_conf: AccountsConfig,
pub gas_pricer_conf: GasPricerConfig,
pub miner_extras: MinerExtras,
Expand Down Expand Up @@ -721,11 +720,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:

// set up dependencies for rpc servers
let rpc_stats = Arc::new(informant::RpcStats::default());
let secret_store = match cmd.public_node {
true => None,
false => Some(account_provider.clone())
};

let secret_store = account_provider.clone();
let signer_service = Arc::new(signer::new_service(&cmd.ws_conf, &cmd.logger_config));

// the dapps server
Expand Down
27 changes: 0 additions & 27 deletions rpc/src/v1/helpers/accounts.rs

This file was deleted.

8 changes: 0 additions & 8 deletions rpc/src/v1/helpers/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ pub fn light_unimplemented(details: Option<String>) -> Error {
}
}

pub fn public_unsupported(details: Option<String>) -> Error {
Error {
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
message: "Method disallowed when running parity as a public node.".into(),
data: details.map(Value::String),
}
}

pub fn unsupported<T: Into<String>>(msg: T, details: Option<T>) -> Error {
Error {
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
Expand Down
1 change: 0 additions & 1 deletion rpc/src/v1/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#[macro_use]
pub mod errors;

pub mod accounts;
pub mod block_import;
pub mod dapps;
pub mod dispatch;
Expand Down
7 changes: 3 additions & 4 deletions rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ use jsonrpc_macros::Trailing;
use v1::helpers::{errors, limit_logs, fake_sign};
use v1::helpers::dispatch::{FullDispatcher, default_gas_price};
use v1::helpers::block_import::is_major_importing;
use v1::helpers::accounts::unwrap_provider;
use v1::traits::Eth;
use v1::types::{
RichBlock, Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo,
Expand Down Expand Up @@ -100,7 +99,7 @@ pub struct EthClient<C, SN: ?Sized, S: ?Sized, M, EM> where
client: Arc<C>,
snapshot: Arc<SN>,
sync: Arc<S>,
accounts: Option<Arc<AccountProvider>>,
accounts: Arc<AccountProvider>,
miner: Arc<M>,
external_miner: Arc<EM>,
seed_compute: Mutex<SeedHashCompute>,
Expand Down Expand Up @@ -152,7 +151,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S
client: &Arc<C>,
snapshot: &Arc<SN>,
sync: &Arc<S>,
accounts: &Option<Arc<AccountProvider>>,
accounts: &Arc<AccountProvider>,
miner: &Arc<M>,
em: &Arc<EM>,
options: EthClientOptions
Expand All @@ -173,7 +172,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S
/// Attempt to get the `Arc<AccountProvider>`, errors if provider was not
/// set.
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
unwrap_provider(&self.accounts)
Ok(self.accounts.clone())
}

fn rich_block(&self, id: BlockNumberOrId, include_txs: bool) -> Result<Option<RichBlock>> {
Expand Down
19 changes: 4 additions & 15 deletions rpc/src/v1/impls/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_core::futures::{future, Future};
use jsonrpc_macros::Trailing;
use v1::helpers::{self, errors, fake_sign, ipfs, SigningQueue, SignerService, NetworkSettings};
use v1::helpers::accounts::unwrap_provider;
use v1::metadata::Metadata;
use v1::traits::Parity;
use v1::types::{
Expand All @@ -62,7 +61,7 @@ pub struct ParityClient<C, M, U> {
sync: Arc<SyncProvider>,
net: Arc<ManageNetwork>,
health: NodeHealth,
accounts: Option<Arc<AccountProvider>>,
accounts: Arc<AccountProvider>,
logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>,
signer: Option<Arc<SignerService>>,
Expand All @@ -82,7 +81,7 @@ impl<C, M, U> ParityClient<C, M, U> where
updater: Arc<U>,
net: Arc<ManageNetwork>,
health: NodeHealth,
accounts: Option<Arc<AccountProvider>>,
accounts: Arc<AccountProvider>,
logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>,
signer: Option<Arc<SignerService>>,
Expand Down Expand Up @@ -110,7 +109,7 @@ impl<C, M, U> ParityClient<C, M, U> where
/// Attempt to get the `Arc<AccountProvider>`, errors if provider was not
/// set.
fn account_provider(&self) -> Result<Arc<AccountProvider>> {
unwrap_provider(&self.accounts)
Ok(self.accounts.clone())
}
}

Expand Down Expand Up @@ -348,11 +347,6 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
}

fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>> {
// Return nothing if accounts are disabled (running as public node)
if self.accounts.is_none() {
return Ok(BTreeMap::new());
}

let transactions = self.miner.local_transactions();
let block_number = self.client.chain_info().best_block_number;
Ok(transactions
Expand Down Expand Up @@ -417,13 +411,8 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
fn node_kind(&self) -> Result<::v1::types::NodeKind> {
use ::v1::types::{NodeKind, Availability, Capability};

let availability = match self.accounts {
Some(_) => Availability::Personal,
None => Availability::Public
};

Ok(NodeKind {
availability: availability,
availability: Availability::Personal,
capability: Capability::Full,
})
}
Expand Down
Loading