Squashed: Public Node

This commit is contained in:
maciejhirsz
2017-03-29 17:07:58 +02:00
parent 858c974440
commit 9bd3f10f41
45 changed files with 9060 additions and 89 deletions

View File

@@ -4,6 +4,7 @@ mode_timeout = 300
mode_alarm = 3600
auto_update = "none"
release_track = "current"
public_node = false
no_download = false
no_consensus = false

View File

@@ -88,6 +88,7 @@ usage! {
flag_mode_alarm: u64 = 3600u64, or |c: &Config| otry!(c.parity).mode_alarm.clone(),
flag_auto_update: String = "critical", or |c: &Config| otry!(c.parity).auto_update.clone(),
flag_release_track: String = "current", or |c: &Config| otry!(c.parity).release_track.clone(),
flag_public_node: bool = false, or |c: &Config| otry!(c.parity).public_node.clone(),
flag_no_download: bool = false, or |c: &Config| otry!(c.parity).no_download.clone(),
flag_no_consensus: bool = false, or |c: &Config| otry!(c.parity).no_consensus.clone(),
flag_chain: String = "foundation", or |c: &Config| otry!(c.parity).chain.clone(),
@@ -365,6 +366,7 @@ struct Operating {
mode_alarm: Option<u64>,
auto_update: Option<String>,
release_track: Option<String>,
public_node: Option<bool>,
no_download: Option<bool>,
no_consensus: Option<bool>,
chain: Option<String>,
@@ -623,6 +625,7 @@ mod tests {
flag_mode_alarm: 3600u64,
flag_auto_update: "none".into(),
flag_release_track: "current".into(),
flag_public_node: false,
flag_no_download: false,
flag_no_consensus: false,
flag_chain: "xyz".into(),
@@ -825,6 +828,7 @@ mod tests {
mode_alarm: Some(10u64),
auto_update: None,
release_track: None,
public_node: None,
no_download: None,
no_consensus: None,
chain: Some("./chain.json".into()),

View File

@@ -48,6 +48,9 @@ Operating Options:
testing - Testing releases (do not use).
current - Whatever track this executable was
released on (default: {flag_release_track}).
--public-node Start Parity as a public web server. Account storage
and transaction signing will be delegated to the UI.
(default: {flag_public_node}).
--no-download Normally new releases will be downloaded ready for
updating. This disables it. Not recommended.
(default: {flag_no_download}).

View File

@@ -128,6 +128,7 @@ impl Configuration {
Some(true) if pruning == Pruning::Specific(Algorithm::Archive) => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because pruning mode is set to archive").expect("Error writing to stderr"),
_ => {},
};
let public_node = self.args.flag_public_node;
let warp_sync = !self.args.flag_no_warp && fat_db != Switch::On && tracing != Switch::On && pruning != Pruning::Specific(Algorithm::Archive);
let geth_compatibility = self.args.flag_geth;
let ui_address = self.ui_port().map(|port| (self.ui_interface(), port));
@@ -360,6 +361,7 @@ impl Configuration {
wal: wal,
vm_type: vm_type,
warp_sync: warp_sync,
public_node: public_node,
geth_compatibility: geth_compatibility,
ui_address: ui_address,
net_settings: self.network_settings(),
@@ -709,14 +711,26 @@ impl Configuration {
}
fn rpc_apis(&self) -> String {
let mut apis = self.args.flag_rpcapi.clone().unwrap_or(self.args.flag_jsonrpc_apis.clone());
let mut apis: Vec<&str> = self.args.flag_rpcapi
.as_ref()
.unwrap_or(&self.args.flag_jsonrpc_apis)
.split(",")
.collect();
if self.args.flag_geth {
if !apis.is_empty() {
apis.push_str(",");
}
apis.push_str("personal");
apis.push("personal");
}
apis
if self.args.flag_public_node {
apis.retain(|api| {
match *api {
"eth" | "net" | "parity" | "rpc" | "web3" => true,
_ => false
}
});
}
apis.join(",")
}
fn cors(cors: Option<&String>) -> Option<Vec<String>> {
@@ -1167,6 +1181,7 @@ mod tests {
ipc_conf: Default::default(),
net_conf: default_network_config(),
network_id: None,
public_node: false,
warp_sync: true,
acc_conf: Default::default(),
gas_pricer: Default::default(),

View File

@@ -118,7 +118,7 @@ pub struct Dependencies {
pub snapshot: Arc<SnapshotService>,
pub sync: Arc<SyncProvider>,
pub net: Arc<ManageNetwork>,
pub secret_store: Arc<AccountProvider>,
pub secret_store: Option<Arc<AccountProvider>>,
pub miner: Arc<Miner>,
pub external_miner: Arc<ExternalMiner>,
pub logger: Arc<RotatingLogger>,

View File

@@ -81,6 +81,7 @@ pub struct RunCmd {
pub net_conf: NetworkConfiguration,
pub network_id: Option<u64>,
pub warp_sync: bool,
pub public_node: bool,
pub acc_conf: AccountsConfig,
pub gas_pricer: GasPricerConfig,
pub miner_extras: MinerExtras,
@@ -407,6 +408,10 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
// set up dependencies for rpc servers
let rpc_stats = Arc::new(informant::RpcStats::default());
let signer_path = cmd.signer_conf.signer_path.clone();
let secret_store = match cmd.public_node {
true => None,
false => Some(account_provider.clone())
};
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
signer_service: Arc::new(rpc_apis::SignerService::new(move || {
signer::generate_new_token(signer_path.clone()).map_err(|e| format!("{:?}", e))
@@ -415,7 +420,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
client: client.clone(),
sync: sync_provider.clone(),
net: manage_network.clone(),
secret_store: account_provider.clone(),
secret_store: secret_store,
miner: miner.clone(),
external_miner: external_miner.clone(),
logger: logger.clone(),