Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce launcher #2613

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 31 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ members = [
"verification",
"verification/contextual",
"tx-pool",
"shared/migration-template",
"shared",
"chain",
"sync",
"util/instrument",
"rpc",
"util/launcher/migration-template",
"util/launcher",
"ckb-bin"
]

Expand Down
7 changes: 2 additions & 5 deletions ckb-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@ ckb-store = { path = "../store", version = "= 0.41.0-pre" }
ckb-chain-spec = {path = "../spec", version = "= 0.41.0-pre"}
ckb-miner = { path = "../miner", version = "= 0.41.0-pre" }
ckb-network = { path = "../network", version = "= 0.41.0-pre"}
ckb-rpc = { path = "../rpc", version = "= 0.41.0-pre"}
ckb-resource = { path = "../resource", version = "= 0.41.0-pre"}
ckb-network-alert = { path = "../util/network-alert", version = "= 0.41.0-pre" }
ctrlc = { version = "3.1", features = ["termination"] }
ckb-sync = { path = "../sync", version = "= 0.41.0-pre"}
ckb-instrument = { path = "../util/instrument", version = "= 0.41.0-pre", features = ["progress_bar"] }
ckb-build-info = { path = "../util/build-info", version = "= 0.41.0-pre" }
ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.41.0-pre" }
ckb-chain-iter = { path = "../util/chain-iter", version = "= 0.41.0-pre" }
ckb-verification = { path = "../verification", version = "= 0.41.0-pre" }
ckb-verification-traits = { path = "../verification/traits", version = "= 0.41.0-pre" }
ckb-async-runtime = { path = "../util/runtime", version = "= 0.41.0-pre" }
ckb-db = { path = "../db", version = "= 0.41.0-pre" }
ckb-launcher = { path = "../util/launcher", version = "= 0.41.0-pre" }
base64 = "0.13.0"
tempfile = "3.0"
rayon = "1.0"
Expand All @@ -49,5 +46,5 @@ atty = "0.2"
[features]
deadlock_detection = ["ckb-util/deadlock_detection"]
profiling = ["ckb-memory-tracker/profiling"]
with_sentry = ["sentry", "ckb-network/with_sentry", "ckb-sync/with_sentry", "ckb-app-config/with_sentry", "ckb-logger-service/with_sentry"]
with_sentry = ["sentry", "ckb-launcher/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry", "ckb-logger-service/with_sentry"]
with_dns_seeding = ["ckb-network/with_dns_seeding"]
3 changes: 1 addition & 2 deletions ckb-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use ckb_async_runtime::new_global_runtime;
use ckb_build_info::Version;
use setup_guard::SetupGuard;

pub(crate) const LOG_TARGET_MAIN: &str = "main";
#[cfg(feature = "with_sentry")]
pub(crate) const LOG_TARGET_SENTRY: &str = "sentry";

Expand Down Expand Up @@ -59,7 +58,7 @@ pub fn run_app(version: Version) -> Result<(), ExitCode> {
(cli::CMD_IMPORT, Some(matches)) => subcommand::import(setup.import(&matches)?, handle),
(cli::CMD_STATS, Some(matches)) => subcommand::stats(setup.stats(&matches)?, handle),
(cli::CMD_RESET_DATA, Some(matches)) => subcommand::reset_data(setup.reset_data(&matches)?),
(cli::CMD_MIGRATE, Some(matches)) => subcommand::migrate(setup.migrate(&matches)?, handle),
(cli::CMD_MIGRATE, Some(matches)) => subcommand::migrate(setup.migrate(&matches)?),
(cli::CMD_DB_REPAIR, Some(matches)) => subcommand::db_repair(setup.db_repair(&matches)?),
_ => unreachable!(),
}
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/src/subcommand/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ckb_instrument::Export;
use ckb_shared::shared::SharedBuilder;

pub fn export(args: ExportArgs, async_handle: Handle) -> Result<(), ExitCode> {
let (shared, _) = SharedBuilder::new(&args.config.db, None, async_handle)
let (shared, _) = SharedBuilder::new(&args.config.db, async_handle)
.consensus(args.consensus)
.build()
.map_err(|err| {
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/src/subcommand/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ckb_instrument::Import;
use ckb_shared::shared::SharedBuilder;

pub fn import(args: ImportArgs, async_handle: Handle) -> Result<(), ExitCode> {
let (shared, table) = SharedBuilder::new(&args.config.db, None, async_handle)
let (shared, table) = SharedBuilder::new(&args.config.db, async_handle)
.consensus(args.consensus)
.build()
.map_err(|err| {
Expand Down
16 changes: 8 additions & 8 deletions ckb-bin/src/subcommand/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
use ckb_app_config::{ExitCode, MigrateArgs};
use ckb_async_runtime::Handle;
use ckb_shared::shared::SharedBuilder;
use ckb_launcher::DatabaseMigration;

use crate::helper::prompt;

pub fn migrate(args: MigrateArgs, async_handle: Handle) -> Result<(), ExitCode> {
let builder = SharedBuilder::new(&args.config.db, None, async_handle);
pub fn migrate(args: MigrateArgs) -> Result<(), ExitCode> {
let migration = DatabaseMigration::new(&args.config.db.path);

if args.check {
if builder.migration_check() {
if migration.migration_check() {
return Ok(());
} else {
return Err(ExitCode::Cli);
}
}

if !builder.migration_check() {
if !migration.migration_check() {
return Ok(());
}

if builder.require_expensive_migrations() && !args.force {
if migration.require_expensive_migrations() && !args.force {
if atty::is(atty::Stream::Stdin) && atty::is(atty::Stream::Stdout) {
let input = prompt("\
\n\
Expand All @@ -41,9 +40,10 @@ pub fn migrate(args: MigrateArgs, async_handle: Handle) -> Result<(), ExitCode>
}
}

let (_shared, _table) = builder.consensus(args.consensus).build().map_err(|err| {
migration.migrate().map_err(|err| {
eprintln!("Run error: {:?}", err);
ExitCode::Failure
})?;

Ok(())
}
4 changes: 2 additions & 2 deletions ckb-bin/src/subcommand/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ckb_verification_traits::Switch;
use std::sync::Arc;

pub fn replay(args: ReplayArgs, async_handle: Handle) -> Result<(), ExitCode> {
let (shared, _table) = SharedBuilder::new(&args.config.db, None, async_handle.clone())
let (shared, _table) = SharedBuilder::new(&args.config.db, async_handle.clone())
.consensus(args.consensus.clone())
.tx_pool_config(args.config.tx_pool)
.build()
Expand All @@ -33,7 +33,7 @@ pub fn replay(args: ReplayArgs, async_handle: Handle) -> Result<(), ExitCode> {
let mut tmp_db_config = args.config.db.clone();
tmp_db_config.path = tmp_db_dir.path().to_path_buf();

let (tmp_shared, table) = SharedBuilder::new(&tmp_db_config, None, async_handle)
let (tmp_shared, table) = SharedBuilder::new(&tmp_db_config, async_handle)
.consensus(args.consensus)
.tx_pool_config(args.config.tx_pool)
.build()
Expand Down
Loading