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.
This commit is contained in:
@@ -393,6 +393,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.",
|
||||
@@ -1044,6 +1048,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>,
|
||||
@@ -1625,6 +1630,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,
|
||||
@@ -1730,6 +1736,7 @@ mod tests {
|
||||
}),
|
||||
network: Some(Network {
|
||||
warp: Some(false),
|
||||
warp_barrier: None,
|
||||
port: None,
|
||||
min_peers: Some(10),
|
||||
max_peers: Some(20),
|
||||
|
||||
@@ -368,6 +368,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()?,
|
||||
@@ -1401,6 +1402,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(),
|
||||
|
||||
@@ -101,6 +101,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,
|
||||
@@ -513,7 +514,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 {
|
||||
@@ -527,7 +528,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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user