diff --git a/Cargo.lock b/Cargo.lock index 83b7b4d522..cce0b90646 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -561,6 +561,7 @@ dependencies = [ "ckb-logger-service", "ckb-memory-tracker", "ckb-metrics-service", + "ckb-migrate", "ckb-miner", "ckb-network", "ckb-resource", @@ -876,15 +877,13 @@ dependencies = [ "ckb-chain-spec", "ckb-channel", "ckb-db", - "ckb-db-migration", "ckb-db-schema", "ckb-error", "ckb-freezer", - "ckb-hash", "ckb-jsonrpc-types", "ckb-light-client-protocol-server", "ckb-logger", - "ckb-migration-template", + "ckb-migrate", "ckb-network", "ckb-network-alert", "ckb-notify", @@ -895,12 +894,10 @@ dependencies = [ "ckb-snapshot", "ckb-store", "ckb-sync", - "ckb-systemtime", "ckb-tx-pool", "ckb-types", "ckb-verification", "ckb-verification-traits", - "num_cpus", "once_cell", "tempfile", ] @@ -1028,6 +1025,25 @@ dependencies = [ "prometheus", ] +[[package]] +name = "ckb-migrate" +version = "0.113.0-pre" +dependencies = [ + "ckb-app-config", + "ckb-chain-spec", + "ckb-db", + "ckb-db-migration", + "ckb-db-schema", + "ckb-error", + "ckb-hash", + "ckb-migration-template", + "ckb-store", + "ckb-systemtime", + "ckb-types", + "num_cpus", + "tempfile", +] + [[package]] name = "ckb-migration-template" version = "0.113.0-pre" diff --git a/Cargo.toml b/Cargo.toml index e4311d6b6e..c7711140c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,8 @@ members = [ "sync", "util/instrument", "rpc", - "util/launcher/migration-template", + "util/migrate/migration-template", + "util/migrate", "util/light-client-protocol-server", "util/launcher", "ckb-bin" diff --git a/ckb-bin/Cargo.toml b/ckb-bin/Cargo.toml index 0be49f7966..ab9f8e1a47 100644 --- a/ckb-bin/Cargo.toml +++ b/ckb-bin/Cargo.toml @@ -36,6 +36,7 @@ ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.113.0-pre ckb-chain-iter = { path = "../util/chain-iter", version = "= 0.113.0-pre" } ckb-verification-traits = { path = "../verification/traits", version = "= 0.113.0-pre" } ckb-async-runtime = { path = "../util/runtime", version = "= 0.113.0-pre" } +ckb-migrate = { path = "../util/migrate", version = "= 0.113.0-pre" } ckb-launcher = { path = "../util/launcher", version = "= 0.113.0-pre" } base64 = "0.21.0" tempfile.workspace = true diff --git a/ckb-bin/src/subcommand/migrate.rs b/ckb-bin/src/subcommand/migrate.rs index 3be1aef0cf..1dde58ce6f 100644 --- a/ckb-bin/src/subcommand/migrate.rs +++ b/ckb-bin/src/subcommand/migrate.rs @@ -1,5 +1,5 @@ use ckb_app_config::{ExitCode, MigrateArgs}; -use ckb_launcher::migrate::Migrate; +use ckb_migrate::migrate::Migrate; use is_terminal::IsTerminal; use std::cmp::Ordering; diff --git a/util/launcher/Cargo.toml b/util/launcher/Cargo.toml index d82e3d9f01..055c3609d8 100644 --- a/util/launcher/Cargo.toml +++ b/util/launcher/Cargo.toml @@ -14,9 +14,7 @@ repository = "https://github.com/nervosnetwork/ckb" ckb-types = { path = "../types", version = "= 0.113.0-pre" } ckb-store = { path = "../../store", version = "= 0.113.0-pre" } ckb-db = { path = "../../db", version = "= 0.113.0-pre" } -ckb-migration-template = { path = "migration-template", version = "= 0.113.0-pre" } ckb-app-config = { path = "../app-config", version = "= 0.113.0-pre" } -ckb-db-migration = { path = "../../db-migration", version = "= 0.113.0-pre" } ckb-logger = { path = "../logger", version = "= 0.113.0-pre" } ckb-db-schema = { path = "../../db-schema", version = "= 0.113.0-pre" } ckb-error = { path = "../../error", version = "= 0.113.0-pre" } @@ -41,15 +39,11 @@ ckb-snapshot = { path = "../snapshot", version = "= 0.113.0-pre" } ckb-tx-pool = { path = "../../tx-pool", version = "= 0.113.0-pre" } ckb-light-client-protocol-server = { path = "../light-client-protocol-server", version = "= 0.113.0-pre" } ckb-block-filter = { path = "../../block-filter", version = "= 0.113.0-pre" } -ckb-hash = { path = "../hash", version = "= 0.113.0-pre" } -num_cpus = "1.10" +ckb-migrate = { path = "../migrate", version = "= 0.113.0-pre" } once_cell = "1.8.0" tempfile.workspace = true -[dev-dependencies] -ckb-systemtime = {path = "../systemtime", version = "= 0.113.0-pre", features = ["enable_faketime"] } - [features] with_sentry = [ "ckb-sync/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry" ] -portable = ["ckb-db/portable", "ckb-db-migration/portable"] -march-native = ["ckb-db/march-native", "ckb-db-migration/march-native"] +portable = ["ckb-db/portable", "ckb-migrate/portable"] +march-native = ["ckb-db/march-native", "ckb-migrate/march-native"] diff --git a/util/launcher/src/lib.rs b/util/launcher/src/lib.rs index ad56947f35..bc4d1bf517 100644 --- a/util/launcher/src/lib.rs +++ b/util/launcher/src/lib.rs @@ -2,14 +2,7 @@ //! //! ckb launcher is helps to launch ckb node. -// declare here for mute ./devtools/ci/check-cargotoml.sh error -extern crate num_cpus; - -pub mod migrate; -mod migrations; mod shared_builder; -#[cfg(test)] -mod tests; use ckb_app_config::{ BlockAssemblerConfig, ExitCode, RpcConfig, RpcModule, RunArgs, SupportProtocol, diff --git a/util/launcher/src/shared_builder.rs b/util/launcher/src/shared_builder.rs index e1ad368a24..e6cb904c76 100644 --- a/util/launcher/src/shared_builder.rs +++ b/util/launcher/src/shared_builder.rs @@ -2,7 +2,6 @@ //! //! which can be used in order to configure the properties of a new shared. -use crate::migrate::Migrate; use ckb_app_config::ExitCode; use ckb_app_config::{BlockAssemblerConfig, DBConfig, NotifyConfig, StoreConfig, TxPoolConfig}; use ckb_async_runtime::{new_background_runtime, Handle}; @@ -14,6 +13,7 @@ use ckb_db_schema::COLUMNS; use ckb_error::{Error, InternalErrorKind}; use ckb_freezer::Freezer; use ckb_logger::{error, info}; +use ckb_migrate::migrate::Migrate; use ckb_notify::{NotifyController, NotifyService, PoolTransactionEntry}; use ckb_proposal_table::ProposalTable; use ckb_proposal_table::ProposalView; diff --git a/util/migrate/Cargo.toml b/util/migrate/Cargo.toml new file mode 100644 index 0000000000..151d6db6d4 --- /dev/null +++ b/util/migrate/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "ckb-migrate" +version = "0.113.0-pre" +license = "MIT" +authors = ["Nervos Core Dev "] +edition = "2021" +description = "TODO(doc): @eval-exec crate description" +homepage = "https://github.com/nervosnetwork/ckb" +repository = "https://github.com/nervosnetwork/ckb" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ckb-migration-template = { path = "migration-template", version = "= 0.113.0-pre" } +ckb-db = { path = "../../db", version = "= 0.113.0-pre" } +ckb-error = { path = "../../error", version = "= 0.113.0-pre" } +ckb-db-schema = { path = "../../db-schema", version = "= 0.113.0-pre" } +ckb-db-migration = { path = "../../db-migration", version = "= 0.113.0-pre" } +ckb-app-config = { path = "../app-config", version = "= 0.113.0-pre" } +ckb-types = { path = "../types", version = "= 0.113.0-pre" } +ckb-store = { path = "../../store", version = "= 0.113.0-pre" } +ckb-chain-spec = { path = "../../spec", version = "= 0.113.0-pre" } +ckb-hash = { path = "../hash", version = "= 0.113.0-pre" } +tempfile.workspace = true +num_cpus = "1.10" + +[dev-dependencies] +ckb-systemtime = {path = "../systemtime", version = "= 0.113.0-pre", features = ["enable_faketime"] } + +[features] +portable = ["ckb-db/portable", "ckb-db-migration/portable"] +march-native = ["ckb-db/march-native", "ckb-db-migration/march-native"] diff --git a/util/launcher/migration-template/Cargo.toml b/util/migrate/migration-template/Cargo.toml similarity index 100% rename from util/launcher/migration-template/Cargo.toml rename to util/migrate/migration-template/Cargo.toml diff --git a/util/launcher/migration-template/src/lib.rs b/util/migrate/migration-template/src/lib.rs similarity index 100% rename from util/launcher/migration-template/src/lib.rs rename to util/migrate/migration-template/src/lib.rs diff --git a/util/migrate/src/lib.rs b/util/migrate/src/lib.rs new file mode 100644 index 0000000000..1abc638f5a --- /dev/null +++ b/util/migrate/src/lib.rs @@ -0,0 +1,11 @@ +//! CKB migrate. +//! +//! ckb migrate help to migrate CKB's data on schema change. + +// declare here for mute ./devtools/ci/check-cargotoml.sh error +extern crate num_cpus; + +pub mod migrate; +mod migrations; +#[cfg(test)] +mod tests; diff --git a/util/launcher/src/migrate.rs b/util/migrate/src/migrate.rs similarity index 100% rename from util/launcher/src/migrate.rs rename to util/migrate/src/migrate.rs diff --git a/util/launcher/src/migrations/add_block_extension_cf.rs b/util/migrate/src/migrations/add_block_extension_cf.rs similarity index 100% rename from util/launcher/src/migrations/add_block_extension_cf.rs rename to util/migrate/src/migrations/add_block_extension_cf.rs diff --git a/util/launcher/src/migrations/add_block_filter.rs b/util/migrate/src/migrations/add_block_filter.rs similarity index 100% rename from util/launcher/src/migrations/add_block_filter.rs rename to util/migrate/src/migrations/add_block_filter.rs diff --git a/util/launcher/src/migrations/add_block_filter_hash.rs b/util/migrate/src/migrations/add_block_filter_hash.rs similarity index 100% rename from util/launcher/src/migrations/add_block_filter_hash.rs rename to util/migrate/src/migrations/add_block_filter_hash.rs diff --git a/util/launcher/src/migrations/add_chain_root_mmr.rs b/util/migrate/src/migrations/add_chain_root_mmr.rs similarity index 100% rename from util/launcher/src/migrations/add_chain_root_mmr.rs rename to util/migrate/src/migrations/add_chain_root_mmr.rs diff --git a/util/launcher/src/migrations/add_extra_data_hash.rs b/util/migrate/src/migrations/add_extra_data_hash.rs similarity index 100% rename from util/launcher/src/migrations/add_extra_data_hash.rs rename to util/migrate/src/migrations/add_extra_data_hash.rs diff --git a/util/launcher/src/migrations/add_number_hash_mapping.rs b/util/migrate/src/migrations/add_number_hash_mapping.rs similarity index 100% rename from util/launcher/src/migrations/add_number_hash_mapping.rs rename to util/migrate/src/migrations/add_number_hash_mapping.rs diff --git a/util/launcher/src/migrations/cell.rs b/util/migrate/src/migrations/cell.rs similarity index 100% rename from util/launcher/src/migrations/cell.rs rename to util/migrate/src/migrations/cell.rs diff --git a/util/launcher/src/migrations/mod.rs b/util/migrate/src/migrations/mod.rs similarity index 100% rename from util/launcher/src/migrations/mod.rs rename to util/migrate/src/migrations/mod.rs diff --git a/util/launcher/src/migrations/table_to_struct.rs b/util/migrate/src/migrations/table_to_struct.rs similarity index 100% rename from util/launcher/src/migrations/table_to_struct.rs rename to util/migrate/src/migrations/table_to_struct.rs diff --git a/util/launcher/src/tests.rs b/util/migrate/src/tests.rs similarity index 100% rename from util/launcher/src/tests.rs rename to util/migrate/src/tests.rs