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

Expose config max-round-blocks-to-import #9439

Merged
merged 4 commits into from
Oct 26, 2018
Merged
Changes from 2 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
3 changes: 1 addition & 2 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
@@ -259,13 +259,12 @@ impl Importer {

/// This is triggered by a message coming from a block queue when the block is ready for insertion
pub fn import_verified_blocks(&self, client: &Client) -> usize {

// Shortcut out if we know we're incapable of syncing the chain.
if !client.enabled.load(AtomicOrdering::Relaxed) {
return 0;
}

let max_blocks_to_import = 4;
let max_blocks_to_import = client.config.max_round_blocks_to_import;
let (imported_blocks, import_results, invalid_blocks, imported, proposed_blocks, duration, is_empty) = {
let mut imported_blocks = Vec::with_capacity(max_blocks_to_import);
let mut invalid_blocks = HashSet::new();
3 changes: 3 additions & 0 deletions ethcore/src/client/config.rs
Original file line number Diff line number Diff line change
@@ -120,6 +120,8 @@ pub struct ClientConfig {
pub check_seal: bool,
/// Maximal number of transactions queued for verification in a separate thread.
pub transaction_verification_queue_size: usize,
/// Maximal number of blocks to import at each round.
pub max_round_blocks_to_import: usize,
}

impl Default for ClientConfig {
@@ -144,6 +146,7 @@ impl Default for ClientConfig {
history_mem: 32 * mb,
check_seal: true,
transaction_verification_queue_size: 8192,
max_round_blocks_to_import: 12,
}
}
}
10 changes: 9 additions & 1 deletion parity/blockchain.rs
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ pub struct ImportBlockchain {
pub with_color: bool,
pub verifier_settings: VerifierSettings,
pub light: bool,
pub max_round_blocks_to_import: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need to add this field here and just use the default (12). Same below for Export* structs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--max-round-blocks-to-import is a valid args for ImportBlockchain and Snapshot commands anyway, so I think it would be better to include them there, just in case it caught people in surprise? For example, --max-round-blocks-to-import do have (small) impact because the execution would call import_verified_blocks.

Copy link
Contributor

@andresilva andresilva Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a valid option indeed, I just assumed it wouldn't make much of a difference without networking. I'm OK with keeping it configurable.

}

#[derive(Debug, PartialEq)]
@@ -116,6 +117,7 @@ pub struct ExportBlockchain {
pub from_block: BlockId,
pub to_block: BlockId,
pub check_seal: bool,
pub max_round_blocks_to_import: usize,
}

#[derive(Debug, PartialEq)]
@@ -136,6 +138,7 @@ pub struct ExportState {
pub code: bool,
pub min_balance: Option<U256>,
pub max_balance: Option<U256>,
pub max_round_blocks_to_import: usize,
}

pub fn execute(cmd: BlockchainCmd) -> Result<(), String> {
@@ -354,6 +357,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> {
cmd.pruning_history,
cmd.pruning_memory,
cmd.check_seal,
12,
);

client_config.queue.verifier_settings = cmd.verifier_settings;
@@ -493,6 +497,7 @@ fn start_client(
compaction: DatabaseCompactionProfile,
cache_config: CacheConfig,
require_fat_db: bool,
max_round_blocks_to_import: usize,
) -> Result<ClientService, String> {

// load spec file
@@ -546,6 +551,7 @@ fn start_client(
pruning_history,
pruning_memory,
true,
max_round_blocks_to_import,
);

let restoration_db_handler = db::restoration_db_handler(&client_path, &client_config);
@@ -583,6 +589,7 @@ fn execute_export(cmd: ExportBlockchain) -> Result<(), String> {
cmd.compaction,
cmd.cache_config,
false,
cmd.max_round_blocks_to_import,
)?;
let format = cmd.format.unwrap_or_default();

@@ -626,7 +633,8 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
cmd.fat_db,
cmd.compaction,
cmd.cache_config,
true
true,
cmd.max_round_blocks_to_import,
)?;

let client = service.client();
7 changes: 7 additions & 0 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -776,6 +776,10 @@ usage! {
"--stratum-secret=[STRING]",
"Secret for authorizing Stratum server for peers.",

ARG arg_max_round_blocks_to_import: (usize) = 12usize, or |c: &Config| c.mining.as_ref()?.max_round_blocks_to_import.clone(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it fit more into Performance section?

"--max-round-blocks-to-import=[S]",
"Maximal number of blocks to import for each import round.",

["Internal Options"]
FLAG flag_can_restart: (bool) = false, or |_| None,
"--can-restart",
@@ -1312,6 +1316,7 @@ struct Mining {
notify_work: Option<Vec<String>>,
refuse_service_transactions: Option<bool>,
infinite_pending_block: Option<bool>,
max_round_blocks_to_import: Option<usize>,
}

#[derive(Default, Debug, PartialEq, Deserialize)]
@@ -1736,6 +1741,7 @@ mod tests {
arg_notify_work: Some("http://localhost:3001".into()),
flag_refuse_service_transactions: false,
flag_infinite_pending_block: false,
arg_max_round_blocks_to_import: 12usize,

flag_stratum: false,
arg_stratum_interface: "local".to_owned(),
@@ -2002,6 +2008,7 @@ mod tests {
notify_work: None,
refuse_service_transactions: None,
infinite_pending_block: None,
max_round_blocks_to_import: None,
}),
footprint: Some(Footprint {
tracing: Some("on".into()),
11 changes: 11 additions & 0 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
@@ -240,6 +240,7 @@ impl Configuration {
with_color: logger_config.color,
verifier_settings: self.verifier_settings(),
light: self.args.flag_light,
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
};
Cmd::Blockchain(BlockchainCmd::Import(import_cmd))
} else if self.args.cmd_export {
@@ -259,6 +260,7 @@ impl Configuration {
from_block: to_block_id(&self.args.arg_export_blocks_from)?,
to_block: to_block_id(&self.args.arg_export_blocks_to)?,
check_seal: !self.args.flag_no_seal_check,
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
};
Cmd::Blockchain(BlockchainCmd::Export(export_cmd))
} else if self.args.cmd_export_state {
@@ -279,6 +281,7 @@ impl Configuration {
code: !self.args.flag_export_state_no_code,
min_balance: self.args.arg_export_state_min_balance.and_then(|s| to_u256(&s).ok()),
max_balance: self.args.arg_export_state_max_balance.and_then(|s| to_u256(&s).ok()),
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
};
Cmd::Blockchain(BlockchainCmd::ExportState(export_cmd))
} else {
@@ -298,6 +301,7 @@ impl Configuration {
file_path: self.args.arg_snapshot_file.clone(),
kind: snapshot::Kind::Take,
block_at: to_block_id(&self.args.arg_snapshot_at)?,
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
};
Cmd::Snapshot(snapshot_cmd)
} else if self.args.cmd_restore {
@@ -314,6 +318,7 @@ impl Configuration {
file_path: self.args.arg_restore_file.clone(),
kind: snapshot::Kind::Restore,
block_at: to_block_id("latest")?, // unimportant.
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
};
Cmd::Snapshot(restore_cmd)
} else if self.args.cmd_export_hardcoded_sync {
@@ -383,6 +388,7 @@ impl Configuration {
no_persistent_txqueue: self.args.flag_no_persistent_txqueue,
whisper: whisper_config,
no_hardcoded_sync: self.args.flag_no_hardcoded_sync,
max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import,
};
Cmd::Run(run_cmd)
};
@@ -1244,6 +1250,7 @@ mod tests {
with_color: !cfg!(windows),
verifier_settings: Default::default(),
light: false,
max_round_blocks_to_import: 12,
})));
}

@@ -1266,6 +1273,7 @@ mod tests {
from_block: BlockId::Number(1),
to_block: BlockId::Latest,
check_seal: true,
max_round_blocks_to_import: 12,
})));
}

@@ -1290,6 +1298,7 @@ mod tests {
code: true,
min_balance: None,
max_balance: None,
max_round_blocks_to_import: 12,
})));
}

@@ -1312,6 +1321,7 @@ mod tests {
from_block: BlockId::Number(1),
to_block: BlockId::Latest,
check_seal: true,
max_round_blocks_to_import: 12,
})));
}

@@ -1408,6 +1418,7 @@ mod tests {
no_hardcoded_sync: false,
no_persistent_txqueue: false,
whisper: Default::default(),
max_round_blocks_to_import: 12,
};
expected.secretstore_conf.enabled = cfg!(feature = "secretstore");
expected.secretstore_conf.http_enabled = cfg!(feature = "secretstore");
28 changes: 15 additions & 13 deletions parity/helpers.rs
Original file line number Diff line number Diff line change
@@ -204,19 +204,20 @@ pub fn default_network_config() -> ::sync::NetworkConfiguration {
}

pub fn to_client_config(
cache_config: &CacheConfig,
spec_name: String,
mode: Mode,
tracing: bool,
fat_db: bool,
compaction: DatabaseCompactionProfile,
vm_type: VMType,
name: String,
pruning: Algorithm,
pruning_history: u64,
pruning_memory: usize,
check_seal: bool,
) -> ClientConfig {
cache_config: &CacheConfig,
spec_name: String,
mode: Mode,
tracing: bool,
fat_db: bool,
compaction: DatabaseCompactionProfile,
vm_type: VMType,
name: String,
pruning: Algorithm,
pruning_history: u64,
pruning_memory: usize,
check_seal: bool,
max_round_blocks_to_import: usize,
) -> ClientConfig {
let mut client_config = ClientConfig::default();

let mb = 1024 * 1024;
@@ -249,6 +250,7 @@ pub fn to_client_config(
client_config.name = name;
client_config.verifier_type = if check_seal { VerifierType::Canon } else { VerifierType::CanonNoSeal };
client_config.spec_name = spec_name;
client_config.max_round_blocks_to_import = max_round_blocks_to_import;
client_config
}

2 changes: 2 additions & 0 deletions parity/run.rs
Original file line number Diff line number Diff line change
@@ -128,6 +128,7 @@ pub struct RunCmd {
pub no_persistent_txqueue: bool,
pub whisper: ::whisper::Config,
pub no_hardcoded_sync: bool,
pub max_round_blocks_to_import: usize,
}

// node info fetcher for the local store.
@@ -527,6 +528,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
cmd.pruning_history,
cmd.pruning_memory,
cmd.check_seal,
cmd.max_round_blocks_to_import,
);

client_config.queue.verifier_settings = cmd.verifier_settings;
2 changes: 2 additions & 0 deletions parity/snapshot.rs
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ pub struct SnapshotCommand {
pub file_path: Option<String>,
pub kind: Kind,
pub block_at: BlockId,
pub max_round_blocks_to_import: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, I think we only need to add this for the RunCmd.

}

// helper for reading chunks from arbitrary reader and feeding them into the
@@ -178,6 +179,7 @@ impl SnapshotCommand {
self.pruning_history,
self.pruning_memory,
true,
self.max_round_blocks_to_import,
);

let restoration_db_handler = db::restoration_db_handler(&client_path, &client_config);