[beta] Backports (#8346)
* Warp-only sync with warp-barrier [blocknumber] flag. (#8228) * Warp-only sync with warp-after [blocknumber] flag. * Fix tests. * Fix configuration tests. * Rename to warp barrier. * Allow unsafe js eval on Parity Wallet. (#8204) * Update musicoin spec in line with gmc v2.6.2 (#8242) * Supress TemporaryInvalid verification failures. (#8256) * Include suicided accounts in state diff (#8297) * Include suicided accounts in state diff * Shorten form match -> if let * Test suicide trace diff in State * replace_home for password_files, reserved_peers and log_file (#8324) * replace_home for password_files, reserved_peers and log_file * typo: arg_log_file is Option * Enable UI by default, but only display info page. * Fix test. * Fix naming and remove old todo. * Change "wallet" with "browser UI"
This commit is contained in:
@@ -384,6 +384,10 @@ usage! {
|
||||
"--no-serve-light",
|
||||
"Disable serving of light peers.",
|
||||
|
||||
ARG arg_warp_barrier: (Option<u64>) = None, or |c: &Config| c.network.as_ref()?.warp_barrier.clone(),
|
||||
"--warp-barrier=[NUM]",
|
||||
"When warp enabled never attempt regular sync before warping to block NUM.",
|
||||
|
||||
ARG arg_port: (u16) = 30303u16, or |c: &Config| c.network.as_ref()?.port.clone(),
|
||||
"--port=[PORT]",
|
||||
"Override the port on which the node should listen.",
|
||||
@@ -1034,6 +1038,7 @@ struct Ui {
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Network {
|
||||
warp: Option<bool>,
|
||||
warp_barrier: Option<u64>,
|
||||
port: Option<u16>,
|
||||
min_peers: Option<u16>,
|
||||
max_peers: Option<u16>,
|
||||
@@ -1613,6 +1618,7 @@ mod tests {
|
||||
flag_geth: false,
|
||||
flag_testnet: false,
|
||||
flag_import_geth_keys: false,
|
||||
arg_warp_barrier: None,
|
||||
arg_datadir: None,
|
||||
arg_networkid: None,
|
||||
arg_peers: None,
|
||||
@@ -1717,6 +1723,7 @@ mod tests {
|
||||
}),
|
||||
network: Some(Network {
|
||||
warp: Some(false),
|
||||
warp_barrier: None,
|
||||
port: None,
|
||||
min_peers: Some(10),
|
||||
max_peers: Some(20),
|
||||
|
||||
@@ -143,7 +143,7 @@ impl Configuration {
|
||||
if self.args.cmd_signer_new_token {
|
||||
Cmd::SignerToken(ws_conf, ui_conf, logger_config.clone())
|
||||
} else if self.args.cmd_signer_sign {
|
||||
let pwfile = self.args.arg_password.first().map(|pwfile| {
|
||||
let pwfile = self.accounts_config()?.password_files.first().map(|pwfile| {
|
||||
PathBuf::from(pwfile)
|
||||
});
|
||||
Cmd::SignerSign {
|
||||
@@ -180,7 +180,7 @@ impl Configuration {
|
||||
iterations: self.args.arg_keys_iterations,
|
||||
path: dirs.keys,
|
||||
spec: spec,
|
||||
password_file: self.args.arg_password.first().map(|x| x.to_owned()),
|
||||
password_file: self.accounts_config()?.password_files.first().map(|x| x.to_owned()),
|
||||
};
|
||||
AccountCmd::New(new_acc)
|
||||
} else if self.args.cmd_account_list {
|
||||
@@ -214,8 +214,8 @@ impl Configuration {
|
||||
iterations: self.args.arg_keys_iterations,
|
||||
path: dirs.keys,
|
||||
spec: spec,
|
||||
wallet_path: self.args.arg_wallet_import_path.unwrap().clone(),
|
||||
password_file: self.args.arg_password.first().map(|x| x.to_owned()),
|
||||
wallet_path: self.args.arg_wallet_import_path.clone().unwrap(),
|
||||
password_file: self.accounts_config()?.password_files.first().map(|x| x.to_owned()),
|
||||
};
|
||||
Cmd::ImportPresaleWallet(presale_cmd)
|
||||
} else if self.args.cmd_import {
|
||||
@@ -356,6 +356,7 @@ impl Configuration {
|
||||
wal: wal,
|
||||
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()?,
|
||||
@@ -438,7 +439,7 @@ impl Configuration {
|
||||
LogConfig {
|
||||
mode: self.args.arg_logging.clone(),
|
||||
color: !self.args.flag_no_color && !cfg!(windows),
|
||||
file: self.args.arg_log_file.clone(),
|
||||
file: self.args.arg_log_file.as_ref().map(|log_file| replace_home(&self.directories().base, log_file)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,7 +488,7 @@ impl Configuration {
|
||||
iterations: self.args.arg_keys_iterations,
|
||||
refresh_time: self.args.arg_accounts_refresh,
|
||||
testnet: self.args.flag_testnet,
|
||||
password_files: self.args.arg_password.clone(),
|
||||
password_files: self.args.arg_password.iter().map(|s| replace_home(&self.directories().base, s)).collect(),
|
||||
unlocked_accounts: to_addresses(&self.args.arg_unlock)?,
|
||||
enable_hardware_wallets: !self.args.flag_no_hardware_wallets,
|
||||
enable_fast_unlock: self.args.flag_fast_unlock,
|
||||
@@ -560,11 +561,13 @@ impl Configuration {
|
||||
}
|
||||
|
||||
fn ui_config(&self) -> UiConfiguration {
|
||||
let ui = self.ui_enabled();
|
||||
UiConfiguration {
|
||||
enabled: self.ui_enabled(),
|
||||
enabled: ui.enabled,
|
||||
interface: self.ui_interface(),
|
||||
port: self.ui_port(),
|
||||
hosts: self.ui_hosts(),
|
||||
info_page_only: ui.info_page_only,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,8 +706,10 @@ impl Configuration {
|
||||
|
||||
match self.args.arg_reserved_peers {
|
||||
Some(ref path) => {
|
||||
let path = replace_home(&self.directories().base, path);
|
||||
|
||||
let mut buffer = String::new();
|
||||
let mut node_file = File::open(path).map_err(|e| format!("Error opening reserved nodes file: {}", e))?;
|
||||
let mut node_file = File::open(&path).map_err(|e| format!("Error opening reserved nodes file: {}", e))?;
|
||||
node_file.read_to_string(&mut buffer).map_err(|_| "Error reading reserved node file")?;
|
||||
let lines = buffer.lines().map(|s| s.trim().to_owned()).filter(|s| !s.is_empty() && !s.starts_with("#")).collect::<Vec<_>>();
|
||||
|
||||
@@ -1111,16 +1116,22 @@ impl Configuration {
|
||||
})
|
||||
}
|
||||
|
||||
fn ui_enabled(&self) -> bool {
|
||||
fn ui_enabled(&self) -> UiEnabled {
|
||||
if self.args.flag_force_ui {
|
||||
return true;
|
||||
return UiEnabled {
|
||||
enabled: true,
|
||||
info_page_only: false,
|
||||
};
|
||||
}
|
||||
|
||||
let ui_disabled = self.args.arg_unlock.is_some() ||
|
||||
self.args.flag_geth ||
|
||||
self.args.flag_no_ui;
|
||||
|
||||
self.args.cmd_ui && !ui_disabled && cfg!(feature = "ui-enabled")
|
||||
return UiEnabled {
|
||||
enabled: (self.args.cmd_ui || !ui_disabled) && cfg!(feature = "ui-enabled"),
|
||||
info_page_only: !self.args.cmd_ui,
|
||||
}
|
||||
}
|
||||
|
||||
fn verifier_settings(&self) -> VerifierSettings {
|
||||
@@ -1141,6 +1152,12 @@ impl Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
struct UiEnabled {
|
||||
pub enabled: bool,
|
||||
pub info_page_only: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::Write;
|
||||
@@ -1345,14 +1362,15 @@ mod tests {
|
||||
origins: Some(vec!["parity://*".into(),"chrome-extension://*".into(), "moz-extension://*".into()]),
|
||||
hosts: Some(vec![]),
|
||||
signer_path: expected.into(),
|
||||
ui_address: None,
|
||||
ui_address: Some("127.0.0.1:8180".into()),
|
||||
dapps_address: Some("127.0.0.1:8545".into()),
|
||||
support_token_api: true
|
||||
}, UiConfiguration {
|
||||
enabled: false,
|
||||
enabled: true,
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: true,
|
||||
}, LogConfig {
|
||||
color: true,
|
||||
mode: None,
|
||||
@@ -1388,6 +1406,7 @@ mod tests {
|
||||
network_id: None,
|
||||
public_node: false,
|
||||
warp_sync: true,
|
||||
warp_barrier: None,
|
||||
acc_conf: Default::default(),
|
||||
gas_pricer_conf: Default::default(),
|
||||
miner_extras: Default::default(),
|
||||
@@ -1599,10 +1618,26 @@ mod tests {
|
||||
// when
|
||||
let conf0 = parse(&["parity", "--geth"]);
|
||||
let conf1 = parse(&["parity", "--geth", "--force-ui"]);
|
||||
let conf2 = parse(&["parity", "--geth", "ui"]);
|
||||
let conf3 = parse(&["parity"]);
|
||||
|
||||
// then
|
||||
assert_eq!(conf0.ui_enabled(), false);
|
||||
assert_eq!(conf1.ui_enabled(), true);
|
||||
assert_eq!(conf0.ui_enabled(), UiEnabled {
|
||||
enabled: false,
|
||||
info_page_only: true,
|
||||
});
|
||||
assert_eq!(conf1.ui_enabled(), UiEnabled {
|
||||
enabled: true,
|
||||
info_page_only: false,
|
||||
});
|
||||
assert_eq!(conf2.ui_enabled(), UiEnabled {
|
||||
enabled: true,
|
||||
info_page_only: false,
|
||||
});
|
||||
assert_eq!(conf3.ui_enabled(), UiEnabled {
|
||||
enabled: true,
|
||||
info_page_only: true,
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1613,7 +1648,10 @@ mod tests {
|
||||
let conf0 = parse(&["parity", "--unlock", "0x0"]);
|
||||
|
||||
// then
|
||||
assert_eq!(conf0.ui_enabled(), false);
|
||||
assert_eq!(conf0.ui_enabled(), UiEnabled {
|
||||
enabled: false,
|
||||
info_page_only: true,
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1631,11 +1669,45 @@ mod tests {
|
||||
// then
|
||||
assert_eq!(conf0.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf0.ui_config(), UiConfiguration {
|
||||
enabled: false,
|
||||
enabled: true,
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: true,
|
||||
});
|
||||
|
||||
assert!(conf1.ws_config().unwrap().hosts.is_some());
|
||||
assert_eq!(conf1.ws_config().unwrap().origins, None);
|
||||
assert_eq!(conf1.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf1.ui_config(), UiConfiguration {
|
||||
enabled: true,
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: true,
|
||||
});
|
||||
assert_eq!(conf1.dapps_config().extra_embed_on, vec![("127.0.0.1".to_owned(), 3000)]);
|
||||
|
||||
assert!(conf2.ws_config().unwrap().hosts.is_some());
|
||||
assert_eq!(conf2.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf2.ui_config(), UiConfiguration {
|
||||
enabled: true,
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 3123,
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: true,
|
||||
});
|
||||
|
||||
assert!(conf3.ws_config().unwrap().hosts.is_some());
|
||||
assert_eq!(conf3.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf3.ui_config(), UiConfiguration {
|
||||
enabled: true,
|
||||
interface: "test".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: true,
|
||||
});
|
||||
|
||||
assert!(conf4.ws_config().unwrap().hosts.is_some());
|
||||
assert_eq!(conf4.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf4.ui_config(), UiConfiguration {
|
||||
@@ -1643,8 +1715,9 @@ mod tests {
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: false,
|
||||
});
|
||||
assert!(conf5.ws_config().unwrap().hosts.is_some());
|
||||
|
||||
assert!(conf5.ws_config().unwrap().hosts.is_some());
|
||||
assert_eq!(conf5.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf5.ui_config(), UiConfiguration {
|
||||
@@ -1652,33 +1725,8 @@ mod tests {
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: false,
|
||||
});
|
||||
assert!(conf5.ws_config().unwrap().hosts.is_some());
|
||||
assert_eq!(conf1.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf1.ui_config(), UiConfiguration {
|
||||
enabled: false,
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
});
|
||||
assert_eq!(conf1.dapps_config().extra_embed_on, vec![("127.0.0.1".to_owned(), 3000)]);
|
||||
assert_eq!(conf1.ws_config().unwrap().origins, None);
|
||||
assert_eq!(conf2.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf2.ui_config(), UiConfiguration {
|
||||
enabled: false,
|
||||
interface: "127.0.0.1".into(),
|
||||
port: 3123,
|
||||
hosts: Some(vec![]),
|
||||
});
|
||||
assert!(conf2.ws_config().unwrap().hosts.is_some());
|
||||
assert_eq!(conf3.directories().signer, "signer".to_owned());
|
||||
assert_eq!(conf3.ui_config(), UiConfiguration {
|
||||
enabled: false,
|
||||
interface: "test".into(),
|
||||
port: 8180,
|
||||
hosts: Some(vec![]),
|
||||
});
|
||||
assert!(conf3.ws_config().unwrap().hosts.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -160,6 +160,7 @@ pub struct Dependencies {
|
||||
pub pool: CpuPool,
|
||||
pub signer: Arc<SignerService>,
|
||||
pub ui_address: Option<(String, u16)>,
|
||||
pub info_page_only: bool,
|
||||
}
|
||||
|
||||
pub fn new(configuration: Configuration, deps: Dependencies) -> Result<Option<Middleware>, String> {
|
||||
@@ -277,6 +278,7 @@ mod server {
|
||||
deps.contract_client,
|
||||
deps.sync_status,
|
||||
deps.fetch,
|
||||
deps.info_page_only,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ pub struct UiConfiguration {
|
||||
pub interface: String,
|
||||
pub port: u16,
|
||||
pub hosts: Option<Vec<String>>,
|
||||
pub info_page_only: bool,
|
||||
}
|
||||
|
||||
impl UiConfiguration {
|
||||
@@ -110,10 +111,11 @@ impl From<UiConfiguration> for HttpConfiguration {
|
||||
impl Default for UiConfiguration {
|
||||
fn default() -> Self {
|
||||
UiConfiguration {
|
||||
enabled: false,
|
||||
enabled: cfg!(feature = "ui-enabled"),
|
||||
port: 8180,
|
||||
interface: "127.0.0.1".into(),
|
||||
hosts: Some(vec![]),
|
||||
info_page_only: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,7 +168,7 @@ impl Default for WsConfiguration {
|
||||
hosts: Some(Vec::new()),
|
||||
signer_path: replace_home(&data_dir, "$BASE/signer").into(),
|
||||
support_token_api: true,
|
||||
ui_address: None,
|
||||
ui_address: Some("127.0.0.1:8180".into()),
|
||||
dapps_address: Some("127.0.0.1:8545".into()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ pub struct RunCmd {
|
||||
pub net_conf: ethsync::NetworkConfiguration,
|
||||
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,
|
||||
@@ -342,6 +343,7 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger
|
||||
pool: cpu_pool.clone(),
|
||||
signer: signer_service.clone(),
|
||||
ui_address: cmd.ui_conf.redirection_address(),
|
||||
info_page_only: cmd.ui_conf.info_page_only,
|
||||
})
|
||||
};
|
||||
|
||||
@@ -497,7 +499,7 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
|
||||
}
|
||||
|
||||
sync_config.fork_block = spec.fork_block();
|
||||
let mut warp_sync = cmd.warp_sync;
|
||||
let mut warp_sync = spec.engine.supports_warp() && cmd.warp_sync;
|
||||
if warp_sync {
|
||||
// Logging is not initialized yet, so we print directly to stderr
|
||||
if fat_db {
|
||||
@@ -511,7 +513,11 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
|
||||
warp_sync = false;
|
||||
}
|
||||
}
|
||||
sync_config.warp_sync = spec.engine.supports_warp() && warp_sync;
|
||||
sync_config.warp_sync = match (warp_sync, cmd.warp_barrier) {
|
||||
(true, Some(block)) => ethsync::WarpSync::OnlyAndAfter(block),
|
||||
(true, _) => ethsync::WarpSync::Enabled,
|
||||
_ => ethsync::WarpSync::Disabled,
|
||||
};
|
||||
sync_config.download_old_blocks = cmd.download_old_blocks;
|
||||
sync_config.serve_light = cmd.serve_light;
|
||||
|
||||
@@ -738,6 +744,7 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
|
||||
pool: cpu_pool.clone(),
|
||||
signer: signer_service.clone(),
|
||||
ui_address: cmd.ui_conf.redirection_address(),
|
||||
info_page_only: cmd.ui_conf.info_page_only,
|
||||
})
|
||||
};
|
||||
let dapps_middleware = dapps::new(cmd.dapps_conf.clone(), dapps_deps.clone())?;
|
||||
@@ -878,7 +885,7 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
|
||||
}
|
||||
|
||||
pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> Result<(bool, Option<String>), String> {
|
||||
if cmd.ui_conf.enabled {
|
||||
if cmd.ui_conf.enabled && !cmd.ui_conf.info_page_only {
|
||||
warn!("{}", Style::new().bold().paint("Parity browser interface is deprecated. It's going to be removed in the next version, use standalone Parity UI instead."));
|
||||
warn!("{}", Style::new().bold().paint("Standalone Parity UI: https://github.com/Parity-JS/shell/releases"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user