CLI option to skip seal check when importing (#2842)
This commit is contained in:
committed by
Gav Wood
parent
9500f2b83d
commit
44a560e964
@@ -84,6 +84,7 @@ pub struct ImportBlockchain {
|
||||
pub tracing: Switch,
|
||||
pub fat_db: Switch,
|
||||
pub vm_type: VMType,
|
||||
pub check_seal: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -103,6 +104,7 @@ pub struct ExportBlockchain {
|
||||
pub tracing: Switch,
|
||||
pub from_block: BlockID,
|
||||
pub to_block: BlockID,
|
||||
pub check_seal: bool,
|
||||
}
|
||||
|
||||
pub fn execute(cmd: BlockchainCmd) -> Result<String, String> {
|
||||
@@ -158,7 +160,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<String, String> {
|
||||
try!(execute_upgrades(&db_dirs, algorithm, cmd.compaction.compaction_profile(db_dirs.fork_path().as_path())));
|
||||
|
||||
// prepare client config
|
||||
let client_config = to_client_config(&cmd.cache_config, cmd.mode, tracing, fat_db, cmd.compaction, cmd.wal, cmd.vm_type, "".into(), algorithm, cmd.pruning_history);
|
||||
let client_config = to_client_config(&cmd.cache_config, cmd.mode, tracing, fat_db, cmd.compaction, cmd.wal, cmd.vm_type, "".into(), algorithm, cmd.pruning_history, cmd.check_seal);
|
||||
|
||||
// build client
|
||||
let service = try!(ClientService::start(
|
||||
@@ -309,7 +311,7 @@ fn execute_export(cmd: ExportBlockchain) -> Result<String, String> {
|
||||
try!(execute_upgrades(&db_dirs, algorithm, cmd.compaction.compaction_profile(db_dirs.fork_path().as_path())));
|
||||
|
||||
// prepare client config
|
||||
let client_config = to_client_config(&cmd.cache_config, cmd.mode, tracing, fat_db, cmd.compaction, cmd.wal, VMType::default(), "".into(), algorithm, cmd.pruning_history);
|
||||
let client_config = to_client_config(&cmd.cache_config, cmd.mode, tracing, fat_db, cmd.compaction, cmd.wal, VMType::default(), "".into(), algorithm, cmd.pruning_history, cmd.check_seal);
|
||||
|
||||
let service = try!(ClientService::start(
|
||||
client_config,
|
||||
|
||||
@@ -234,6 +234,7 @@ usage! {
|
||||
flag_from: String = "1", or |_| None,
|
||||
flag_to: String = "latest", or |_| None,
|
||||
flag_format: Option<String> = None, or |_| None,
|
||||
flag_no_seal_check: bool = false, or |_| None,
|
||||
|
||||
// -- Snapshot Optons
|
||||
flag_at: String = "latest", or |_| None,
|
||||
@@ -561,6 +562,7 @@ mod tests {
|
||||
flag_from: "1".into(),
|
||||
flag_to: "latest".into(),
|
||||
flag_format: None,
|
||||
flag_no_seal_check: false,
|
||||
|
||||
// -- Snapshot Optons
|
||||
flag_at: "latest".into(),
|
||||
|
||||
@@ -247,6 +247,7 @@ Import/Export Options:
|
||||
--format FORMAT For import/export in given format. FORMAT must be
|
||||
one of 'hex' and 'binary'.
|
||||
(default: {flag_format:?} = Import: auto, Export: binary)
|
||||
--no-seal-check Skip block seal check. (default: {flag_no_seal_check})
|
||||
|
||||
Snapshot Options:
|
||||
--at BLOCK Take a snapshot at the given block, which may be an
|
||||
|
||||
@@ -154,6 +154,7 @@ impl Configuration {
|
||||
tracing: tracing,
|
||||
fat_db: fat_db,
|
||||
vm_type: vm_type,
|
||||
check_seal: !self.args.flag_no_seal_check,
|
||||
};
|
||||
Cmd::Blockchain(BlockchainCmd::Import(import_cmd))
|
||||
} else if self.args.cmd_export {
|
||||
@@ -173,6 +174,7 @@ impl Configuration {
|
||||
fat_db: fat_db,
|
||||
from_block: try!(to_block_id(&self.args.flag_from)),
|
||||
to_block: try!(to_block_id(&self.args.flag_to)),
|
||||
check_seal: !self.args.flag_no_seal_check,
|
||||
};
|
||||
Cmd::Blockchain(BlockchainCmd::Export(export_cmd))
|
||||
} else if self.args.cmd_snapshot {
|
||||
@@ -251,6 +253,7 @@ impl Configuration {
|
||||
name: self.args.flag_identity,
|
||||
custom_bootnodes: self.args.flag_bootnodes.is_some(),
|
||||
no_periodic_snapshot: self.args.flag_no_periodic_snapshot,
|
||||
check_seal: !self.args.flag_no_seal_check,
|
||||
};
|
||||
Cmd::Run(run_cmd)
|
||||
};
|
||||
@@ -738,6 +741,7 @@ mod tests {
|
||||
tracing: Default::default(),
|
||||
fat_db: Default::default(),
|
||||
vm_type: VMType::Interpreter,
|
||||
check_seal: true,
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -761,6 +765,7 @@ mod tests {
|
||||
fat_db: Default::default(),
|
||||
from_block: BlockID::Number(1),
|
||||
to_block: BlockID::Latest,
|
||||
check_seal: true,
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -784,6 +789,7 @@ mod tests {
|
||||
fat_db: Default::default(),
|
||||
from_block: BlockID::Number(1),
|
||||
to_block: BlockID::Latest,
|
||||
check_seal: true,
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -832,6 +838,7 @@ mod tests {
|
||||
custom_bootnodes: false,
|
||||
fat_db: Default::default(),
|
||||
no_periodic_snapshot: false,
|
||||
check_seal: true,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use std::path::Path;
|
||||
use std::fs::File;
|
||||
use util::{clean_0x, U256, Uint, Address, path, CompactionProfile};
|
||||
use util::journaldb::Algorithm;
|
||||
use ethcore::client::{Mode, BlockID, VMType, DatabaseCompactionProfile, ClientConfig};
|
||||
use ethcore::client::{Mode, BlockID, VMType, DatabaseCompactionProfile, ClientConfig, VerifierType};
|
||||
use ethcore::miner::{PendingSet, GasLimit, PrioritizationStrategy};
|
||||
use cache::CacheConfig;
|
||||
use dir::DatabaseDirectories;
|
||||
@@ -215,6 +215,7 @@ pub fn to_client_config(
|
||||
name: String,
|
||||
pruning: Algorithm,
|
||||
pruning_history: u64,
|
||||
check_seal: bool,
|
||||
) -> ClientConfig {
|
||||
let mut client_config = ClientConfig::default();
|
||||
|
||||
@@ -247,6 +248,7 @@ pub fn to_client_config(
|
||||
client_config.db_wal = wal;
|
||||
client_config.vm_type = vm_type;
|
||||
client_config.name = name;
|
||||
client_config.verifier_type = if check_seal { VerifierType::Canon } else { VerifierType::CanonNoSeal };
|
||||
client_config
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ pub struct RunCmd {
|
||||
pub name: String,
|
||||
pub custom_bootnodes: bool,
|
||||
pub no_periodic_snapshot: bool,
|
||||
pub check_seal: bool,
|
||||
}
|
||||
|
||||
pub fn execute(cmd: RunCmd) -> Result<(), String> {
|
||||
@@ -197,6 +198,7 @@ pub fn execute(cmd: RunCmd) -> Result<(), String> {
|
||||
cmd.name,
|
||||
algorithm,
|
||||
cmd.pruning_history,
|
||||
cmd.check_seal,
|
||||
);
|
||||
|
||||
// set up bootnodes
|
||||
|
||||
@@ -163,7 +163,7 @@ impl SnapshotCommand {
|
||||
try!(execute_upgrades(&db_dirs, algorithm, self.compaction.compaction_profile(db_dirs.fork_path().as_path())));
|
||||
|
||||
// prepare client config
|
||||
let client_config = to_client_config(&self.cache_config, self.mode, tracing, fat_db, self.compaction, self.wal, VMType::default(), "".into(), algorithm, self.pruning_history);
|
||||
let client_config = to_client_config(&self.cache_config, self.mode, tracing, fat_db, self.compaction, self.wal, VMType::default(), "".into(), algorithm, self.pruning_history, true);
|
||||
|
||||
let service = try!(ClientService::start(
|
||||
client_config,
|
||||
|
||||
Reference in New Issue
Block a user