diff --git a/Cargo.lock b/Cargo.lock index cce0b90646..d517d8d08d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -526,7 +526,6 @@ dependencies = [ "ckb-dao-utils", "ckb-hash", "ckb-jsonrpc-types", - "ckb-launcher", "ckb-network", "ckb-resource", "ckb-shared", @@ -611,7 +610,6 @@ dependencies = [ "ckb-dao-utils", "ckb-error", "ckb-jsonrpc-types", - "ckb-launcher", "ckb-logger", "ckb-merkle-mountain-range", "ckb-metrics", @@ -874,32 +872,22 @@ dependencies = [ "ckb-block-filter", "ckb-build-info", "ckb-chain", - "ckb-chain-spec", "ckb-channel", - "ckb-db", - "ckb-db-schema", - "ckb-error", - "ckb-freezer", "ckb-jsonrpc-types", "ckb-light-client-protocol-server", "ckb-logger", - "ckb-migrate", "ckb-network", "ckb-network-alert", - "ckb-notify", "ckb-proposal-table", "ckb-resource", "ckb-rpc", "ckb-shared", - "ckb-snapshot", "ckb-store", "ckb-sync", "ckb-tx-pool", "ckb-types", "ckb-verification", "ckb-verification-traits", - "once_cell", - "tempfile", ] [[package]] @@ -925,7 +913,6 @@ dependencies = [ "ckb-chain-spec", "ckb-dao-utils", "ckb-jsonrpc-types", - "ckb-launcher", "ckb-logger", "ckb-merkle-mountain-range", "ckb-network", @@ -1272,7 +1259,6 @@ dependencies = [ "ckb-error", "ckb-indexer", "ckb-jsonrpc-types", - "ckb-launcher", "ckb-logger", "ckb-logger-service", "ckb-memory-tracker", @@ -1345,13 +1331,16 @@ name = "ckb-shared" version = "0.113.0-pre" dependencies = [ "arc-swap", + "ckb-app-config", "ckb-async-runtime", "ckb-chain-spec", + "ckb-channel", "ckb-constant", "ckb-db", "ckb-db-schema", "ckb-error", "ckb-logger", + "ckb-migrate", "ckb-notify", "ckb-proposal-table", "ckb-snapshot", @@ -1361,6 +1350,8 @@ dependencies = [ "ckb-tx-pool", "ckb-types", "ckb-verification", + "once_cell", + "tempfile", ] [[package]] @@ -1431,7 +1422,6 @@ dependencies = [ "ckb-dao", "ckb-dao-utils", "ckb-error", - "ckb-launcher", "ckb-logger", "ckb-metrics", "ckb-network", @@ -1607,7 +1597,6 @@ dependencies = [ "ckb-dao", "ckb-dao-utils", "ckb-error", - "ckb-launcher", "ckb-logger", "ckb-merkle-mountain-range", "ckb-reward-calculator", diff --git a/Cargo.toml b/Cargo.toml index c7711140c3..5a20572a33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ members = [ "error", "util/multisig", "util/gen-types", + "util/migrate/migration-template", "util/types", "util/jsonrpc-types", "freezer", @@ -76,6 +77,7 @@ members = [ "util/dao", "util/reward-calculator", "util/snapshot", + "util/migrate", "verification/traits", "verification", "verification/contextual", @@ -86,8 +88,6 @@ members = [ "sync", "util/instrument", "rpc", - "util/migrate/migration-template", - "util/migrate", "util/light-client-protocol-server", "util/launcher", "ckb-bin" diff --git a/benches/Cargo.toml b/benches/Cargo.toml index b09e42db2e..91b5925e09 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -32,7 +32,6 @@ ckb-verification-traits = { path = "../verification/traits", version = "= 0.113. ckb-app-config = { path = "../util/app-config", version = "= 0.113.0-pre" } ckb-resource = { path = "../resource", version = "= 0.113.0-pre" } ckb-network = { path = "../network", version = "= 0.113.0-pre" } -ckb-launcher = { path = "../util/launcher", version = "= 0.113.0-pre" } tempfile.workspace = true [[bench]] diff --git a/benches/benches/benchmarks/overall.rs b/benches/benches/benchmarks/overall.rs index 15a76de599..74bf84b953 100644 --- a/benches/benches/benchmarks/overall.rs +++ b/benches/benches/benchmarks/overall.rs @@ -5,9 +5,8 @@ use ckb_chain::chain::{ChainController, ChainService}; use ckb_chain_spec::consensus::{ConsensusBuilder, ProposalWindow}; use ckb_dao_utils::genesis_dao_data; use ckb_jsonrpc_types::JsonBytes; -use ckb_launcher::SharedBuilder; use ckb_network::{Flags, NetworkController, NetworkService, NetworkState}; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::ChainStore; use ckb_types::{ bytes::Bytes, diff --git a/benches/benches/benchmarks/resolve.rs b/benches/benches/benchmarks/resolve.rs index 2d3545126e..ebc278351b 100644 --- a/benches/benches/benchmarks/resolve.rs +++ b/benches/benches/benchmarks/resolve.rs @@ -3,9 +3,8 @@ use ckb_app_config::{BlockAssemblerConfig, TxPoolConfig}; use ckb_chain::chain::{ChainController, ChainService}; use ckb_chain_spec::{ChainSpec, IssuedCell}; use ckb_jsonrpc_types::JsonBytes; -use ckb_launcher::SharedBuilder; use ckb_resource::Resource; -use ckb_shared::{Shared, Snapshot}; +use ckb_shared::{Shared, SharedBuilder, Snapshot}; use ckb_types::{ bytes::Bytes, core::{ diff --git a/benches/benches/benchmarks/util.rs b/benches/benches/benchmarks/util.rs index 52ac98b071..8c21dddc3b 100644 --- a/benches/benches/benchmarks/util.rs +++ b/benches/benches/benchmarks/util.rs @@ -3,8 +3,7 @@ use ckb_chain_spec::consensus::{ConsensusBuilder, ProposalWindow}; use ckb_crypto::secp::Privkey; use ckb_dao::DaoCalculator; use ckb_dao_utils::genesis_dao_data; -use ckb_launcher::SharedBuilder; -use ckb_shared::{Shared, Snapshot}; +use ckb_shared::{Shared, SharedBuilder, Snapshot}; use ckb_store::ChainStore; use ckb_system_scripts::BUNDLED_CELL; use ckb_test_chain_utils::always_success_cell; diff --git a/chain/Cargo.toml b/chain/Cargo.toml index 976925c719..6e7326e322 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -36,7 +36,6 @@ ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.113 ckb-tx-pool = { path = "../tx-pool", version = "= 0.113.0-pre", features = ["internal"] } ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.113.0-pre" } ckb-network = { path = "../network", version = "= 0.113.0-pre" } -ckb-launcher = { path = "../util/launcher", version = "= 0.113.0-pre" } lazy_static = "1.4" tempfile.workspace = true ckb-systemtime = { path = "../util/systemtime", version = "= 0.113.0-pre" ,features = ["enable_faketime"]} diff --git a/chain/src/tests/block_assembler.rs b/chain/src/tests/block_assembler.rs index c8d9bcbe4c..6f5c5e2193 100644 --- a/chain/src/tests/block_assembler.rs +++ b/chain/src/tests/block_assembler.rs @@ -4,9 +4,7 @@ use ckb_app_config::BlockAssemblerConfig; use ckb_chain_spec::consensus::Consensus; use ckb_dao_utils::genesis_dao_data; use ckb_jsonrpc_types::ScriptHashType; -use ckb_launcher::SharedBuilder; -use ckb_shared::Shared; -use ckb_shared::Snapshot; +use ckb_shared::{Shared, SharedBuilder, Snapshot}; use ckb_store::ChainStore; use ckb_tx_pool::{block_assembler::CandidateUncles, PlugTarget, TxEntry}; use ckb_types::{ diff --git a/chain/src/tests/find_fork.rs b/chain/src/tests/find_fork.rs index 3e1d4bb6ac..78cdc665fa 100644 --- a/chain/src/tests/find_fork.rs +++ b/chain/src/tests/find_fork.rs @@ -1,7 +1,7 @@ use crate::chain::{ChainService, ForkChanges}; use crate::tests::util::{MockChain, MockStore}; use ckb_chain_spec::consensus::{Consensus, ProposalWindow}; -use ckb_launcher::SharedBuilder; +use ckb_shared::SharedBuilder; use ckb_store::ChainStore; use ckb_systemtime::unix_time_as_millis; use ckb_types::{ diff --git a/chain/src/tests/truncate.rs b/chain/src/tests/truncate.rs index c149756e8a..3ad0865e28 100644 --- a/chain/src/tests/truncate.rs +++ b/chain/src/tests/truncate.rs @@ -1,7 +1,7 @@ use crate::chain::ChainService; use crate::tests::util::{MockChain, MockStore}; use ckb_chain_spec::consensus::Consensus; -use ckb_launcher::SharedBuilder; +use ckb_shared::SharedBuilder; use ckb_store::ChainStore; use ckb_verification_traits::Switch; use std::sync::Arc; diff --git a/chain/src/tests/uncle.rs b/chain/src/tests/uncle.rs index c42f0e4d92..3f59352471 100644 --- a/chain/src/tests/uncle.rs +++ b/chain/src/tests/uncle.rs @@ -1,7 +1,7 @@ use crate::chain::ChainService; use crate::tests::util::{MockChain, MockStore}; use ckb_chain_spec::consensus::Consensus; -use ckb_launcher::SharedBuilder; +use ckb_shared::SharedBuilder; use ckb_store::ChainStore; use ckb_verification_traits::Switch; use std::sync::Arc; diff --git a/chain/src/tests/util.rs b/chain/src/tests/util.rs index 7ade19bc53..d3f1e7da65 100644 --- a/chain/src/tests/util.rs +++ b/chain/src/tests/util.rs @@ -5,9 +5,8 @@ use ckb_chain_spec::consensus::{Consensus, ConsensusBuilder}; use ckb_dao::DaoCalculator; use ckb_dao_utils::genesis_dao_data; use ckb_jsonrpc_types::ScriptHashType; -use ckb_launcher::SharedBuilder; use ckb_network::{Flags, NetworkController, NetworkService, NetworkState}; -use ckb_shared::shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::ChainStore; pub use ckb_test_chain_utils::MockStore; use ckb_test_chain_utils::{ diff --git a/ckb-bin/src/subcommand/export.rs b/ckb-bin/src/subcommand/export.rs index 4ec13245be..04459d3f67 100644 --- a/ckb-bin/src/subcommand/export.rs +++ b/ckb-bin/src/subcommand/export.rs @@ -1,7 +1,7 @@ use ckb_app_config::{ExitCode, ExportArgs}; use ckb_async_runtime::Handle; use ckb_instrument::Export; -use ckb_launcher::SharedBuilder; +use ckb_shared::SharedBuilder; pub fn export(args: ExportArgs, async_handle: Handle) -> Result<(), ExitCode> { let builder = SharedBuilder::new( diff --git a/ckb-bin/src/subcommand/import.rs b/ckb-bin/src/subcommand/import.rs index 574da91d49..8c03cfd7f9 100644 --- a/ckb-bin/src/subcommand/import.rs +++ b/ckb-bin/src/subcommand/import.rs @@ -2,7 +2,7 @@ use ckb_app_config::{ExitCode, ImportArgs}; use ckb_async_runtime::Handle; use ckb_chain::chain::ChainService; use ckb_instrument::Import; -use ckb_launcher::SharedBuilder; +use ckb_shared::SharedBuilder; pub fn import(args: ImportArgs, async_handle: Handle) -> Result<(), ExitCode> { let builder = SharedBuilder::new( diff --git a/ckb-bin/src/subcommand/replay.rs b/ckb-bin/src/subcommand/replay.rs index 592924dd73..ea84479cf0 100644 --- a/ckb-bin/src/subcommand/replay.rs +++ b/ckb-bin/src/subcommand/replay.rs @@ -3,8 +3,7 @@ use ckb_async_runtime::Handle; use ckb_chain::chain::ChainService; use ckb_chain_iter::ChainIterator; use ckb_instrument::{ProgressBar, ProgressStyle}; -use ckb_launcher::SharedBuilder; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::ChainStore; use ckb_verification_traits::Switch; use std::sync::Arc; diff --git a/ckb-bin/src/subcommand/stats.rs b/ckb-bin/src/subcommand/stats.rs index 50583f742a..e0edc73fc1 100644 --- a/ckb-bin/src/subcommand/stats.rs +++ b/ckb-bin/src/subcommand/stats.rs @@ -1,7 +1,6 @@ use ckb_app_config::{ExitCode, StatsArgs}; use ckb_async_runtime::Handle; -use ckb_launcher::SharedBuilder; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::ChainStore; use ckb_types::{ core::{BlockNumber, ScriptHashType}, diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index b7fe1adbc6..eaf36a7eed 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -49,7 +49,7 @@ tokio = "1" [dev-dependencies] reqwest = { version = "=0.11.20", features = ["blocking", "json"] } serde = { version = "1.0", features = ["derive"] } -ckb-launcher = { path = "../util/launcher", version = "= 0.113.0-pre" } +ckb-shared = { path = "../shared", version = "= 0.113.0-pre" } ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.113.0-pre" } tempfile.workspace = true pretty_assertions = "1.3.0" diff --git a/rpc/src/tests/examples.rs b/rpc/src/tests/examples.rs index ef03381e54..4be46c567d 100644 --- a/rpc/src/tests/examples.rs +++ b/rpc/src/tests/examples.rs @@ -9,10 +9,10 @@ use ckb_chain::chain::ChainService; use ckb_chain_spec::consensus::{Consensus, ConsensusBuilder}; use ckb_chain_spec::versionbits::{ActiveMode, Deployment, DeploymentPos}; use ckb_dao_utils::genesis_dao_data; -use ckb_launcher::SharedBuilder; use ckb_network::{Flags, NetworkService, NetworkState}; use ckb_network_alert::alert_relayer::AlertRelayer; use ckb_notify::NotifyService; +use ckb_shared::SharedBuilder; use ckb_sync::SyncShared; use ckb_test_chain_utils::always_success_cell; use ckb_types::{ diff --git a/rpc/src/tests/mod.rs b/rpc/src/tests/mod.rs index 78ead1f75b..8551cd706a 100644 --- a/rpc/src/tests/mod.rs +++ b/rpc/src/tests/mod.rs @@ -4,10 +4,9 @@ use ckb_chain::chain::{ChainController, ChainService}; use ckb_chain_spec::consensus::Consensus; use ckb_dao::DaoCalculator; use ckb_jsonrpc_types::ScriptHashType; -use ckb_launcher::SharedBuilder; use ckb_network::{Flags, NetworkService, NetworkState}; use ckb_reward_calculator::RewardCalculator; -use ckb_shared::{Shared, Snapshot}; +use ckb_shared::{Shared, SharedBuilder, Snapshot}; use ckb_store::ChainStore; use ckb_test_chain_utils::{always_success_cell, always_success_cellbase}; use ckb_types::{ diff --git a/shared/Cargo.toml b/shared/Cargo.toml index cabcc598e6..ac19a4b885 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -26,10 +26,16 @@ ckb-async-runtime = { path = "../util/runtime", version = "= 0.113.0-pre" } ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.113.0-pre" } ckb-constant = { path = "../util/constant", version = "= 0.113.0-pre" } ckb-systemtime = { path = "../util/systemtime", version = "= 0.113.0-pre" } +ckb-channel = { path = "../util/channel", version = "= 0.113.0-pre" } +ckb-app-config = {path = "../util/app-config", version = "= 0.113.0-pre"} +ckb-migrate = { path = "../util/migrate", version = "= 0.113.0-pre" } +once_cell = "1.8.0" +tempfile.workspace = true + [dev-dependencies] ckb-systemtime = { path = "../util/systemtime", version = "= 0.113.0-pre", features = ["enable_faketime"] } [features] -portable = ["ckb-db/portable", "ckb-store/portable", "ckb-tx-pool/portable"] -march-native = ["ckb-db/march-native", "ckb-store/march-native", "ckb-tx-pool/march-native"] +portable = ["ckb-db/portable", "ckb-store/portable", "ckb-tx-pool/portable", "ckb-migrate/portable"] +march-native = ["ckb-db/march-native", "ckb-store/march-native", "ckb-tx-pool/march-native", "ckb-migrate/march-native"] diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 91d80fecd0..63bfa56a35 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -2,6 +2,8 @@ // num_cpus is used in proc_macro pub mod shared; +pub mod shared_builder; pub use ckb_snapshot::{Snapshot, SnapshotMgr}; pub use shared::Shared; +pub use shared_builder::{SharedBuilder, SharedPackage}; diff --git a/util/launcher/src/shared_builder.rs b/shared/src/shared_builder.rs similarity index 96% rename from util/launcher/src/shared_builder.rs rename to shared/src/shared_builder.rs index e6cb904c76..e8bb9f9773 100644 --- a/util/launcher/src/shared_builder.rs +++ b/shared/src/shared_builder.rs @@ -1,35 +1,33 @@ -//! Shared factory -//! -//! which can be used in order to configure the properties of a new shared. +//! shared_builder provide SharedBuilder and SharedPacakge +use ckb_channel::Receiver; +use ckb_proposal_table::ProposalTable; +use ckb_tx_pool::service::TxVerificationResult; +use ckb_tx_pool::{TokioRwLock, TxEntry, TxPool, TxPoolServiceBuilder}; +use std::cmp::Ordering; -use ckb_app_config::ExitCode; -use ckb_app_config::{BlockAssemblerConfig, DBConfig, NotifyConfig, StoreConfig, TxPoolConfig}; -use ckb_async_runtime::{new_background_runtime, Handle}; use ckb_chain_spec::consensus::Consensus; use ckb_chain_spec::SpecError; -use ckb_channel::Receiver; + +use crate::Shared; +use ckb_proposal_table::ProposalView; +use ckb_snapshot::{Snapshot, SnapshotMgr}; + +use ckb_app_config::{ + BlockAssemblerConfig, DBConfig, ExitCode, NotifyConfig, StoreConfig, TxPoolConfig, +}; +use ckb_async_runtime::{new_background_runtime, Handle}; use ckb_db::RocksDB; 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; -use ckb_shared::Shared; -use ckb_snapshot::{Snapshot, SnapshotMgr}; - -use ckb_store::ChainDB; -use ckb_store::ChainStore; -use ckb_tx_pool::{ - error::Reject, service::TxVerificationResult, TokioRwLock, TxEntry, TxPool, - TxPoolServiceBuilder, -}; +use ckb_notify::{NotifyController, NotifyService}; +use ckb_store::{ChainDB, ChainStore, Freezer}; +use ckb_types::core::service::PoolTransactionEntry; +use ckb_types::core::tx_pool::Reject; use ckb_types::core::EpochExt; use ckb_types::core::HeaderView; use ckb_verification::cache::init_cache; -use std::cmp::Ordering; use std::collections::HashSet; use std::path::{Path, PathBuf}; use std::sync::atomic::AtomicBool; @@ -48,6 +46,7 @@ pub struct SharedBuilder { async_handle: Handle, } +/// Open or create a rocksdb pub fn open_or_create_db( bin_name: &str, root_dir: &Path, @@ -372,51 +371,6 @@ impl SharedBuilder { } } -/// SharedBuilder build returning the shared/package halves -/// The package structs used for init other component -pub struct SharedPackage { - table: Option, - tx_pool_builder: Option, - relay_tx_receiver: Option>, -} - -impl SharedPackage { - /// Takes the proposal_table out of the package, leaving a None in its place. - pub fn take_proposal_table(&mut self) -> ProposalTable { - self.table.take().expect("take proposal_table") - } - - /// Takes the tx_pool_builder out of the package, leaving a None in its place. - pub fn take_tx_pool_builder(&mut self) -> TxPoolServiceBuilder { - self.tx_pool_builder.take().expect("take tx_pool_builder") - } - - /// Takes the relay_tx_receiver out of the package, leaving a None in its place. - pub fn take_relay_tx_receiver(&mut self) -> Receiver { - self.relay_tx_receiver - .take() - .expect("take relay_tx_receiver") - } -} - -fn start_notify_service(notify_config: NotifyConfig, handle: Handle) -> NotifyController { - NotifyService::new(notify_config, handle).start() -} - -fn build_store( - db: RocksDB, - store_config: StoreConfig, - ancient_path: Option, -) -> Result { - let store = if store_config.freezer_enable && ancient_path.is_some() { - let freezer = Freezer::open(ancient_path.expect("exist checked"))?; - ChainDB::new_with_freezer(db, freezer, store_config) - } else { - ChainDB::new(db, store_config) - }; - Ok(store) -} - fn register_tx_pool_callback(tx_pool_builder: &mut TxPoolServiceBuilder, notify: NotifyController) { let notify_pending = notify.clone(); @@ -483,3 +437,48 @@ fn register_tx_pool_callback(tx_pool_builder: &mut TxPoolServiceBuilder, notify: }, )); } + +fn start_notify_service(notify_config: NotifyConfig, handle: Handle) -> NotifyController { + NotifyService::new(notify_config, handle).start() +} + +fn build_store( + db: RocksDB, + store_config: StoreConfig, + ancient_path: Option, +) -> Result { + let store = if store_config.freezer_enable && ancient_path.is_some() { + let freezer = Freezer::open(ancient_path.expect("exist checked"))?; + ChainDB::new_with_freezer(db, freezer, store_config) + } else { + ChainDB::new(db, store_config) + }; + Ok(store) +} + +/// SharedBuilder build returning the shared/package halves +/// The package structs used for init other component +pub struct SharedPackage { + table: Option, + tx_pool_builder: Option, + relay_tx_receiver: Option>, +} + +impl SharedPackage { + /// Takes the proposal_table out of the package, leaving a None in its place. + pub fn take_proposal_table(&mut self) -> ProposalTable { + self.table.take().expect("take proposal_table") + } + + /// Takes the tx_pool_builder out of the package, leaving a None in its place. + pub fn take_tx_pool_builder(&mut self) -> TxPoolServiceBuilder { + self.tx_pool_builder.take().expect("take tx_pool_builder") + } + + /// Takes the relay_tx_receiver out of the package, leaving a None in its place. + pub fn take_relay_tx_receiver(&mut self) -> Receiver { + self.relay_tx_receiver + .take() + .expect("take relay_tx_receiver") + } +} diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 79c1d1e5c7..9b81f0a99b 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -48,7 +48,6 @@ ckb-dao = { path = "../util/dao", version = "= 0.113.0-pre" } ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.113.0-pre" } ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.113.0-pre" } ckb-chain = { path = "../chain", version = "= 0.113.0-pre", features = ["mock"] } -ckb-launcher = { path = "../util/launcher", version = "= 0.113.0-pre" } faux = "^0.1" once_cell = "1.8.0" ckb-systemtime = { path = "../util/systemtime", version = "= 0.113.0-pre" , features = ["enable_faketime"]} diff --git a/sync/src/relayer/tests/helper.rs b/sync/src/relayer/tests/helper.rs index eb6b3c0a08..0531c302a6 100644 --- a/sync/src/relayer/tests/helper.rs +++ b/sync/src/relayer/tests/helper.rs @@ -2,13 +2,12 @@ use crate::{Relayer, SyncShared}; use ckb_app_config::NetworkConfig; use ckb_chain::chain::ChainService; use ckb_chain_spec::consensus::{build_genesis_epoch_ext, ConsensusBuilder}; -use ckb_launcher::SharedBuilder; use ckb_network::{ async_trait, bytes::Bytes as P2pBytes, Behaviour, CKBProtocolContext, Error, Flags, NetworkController, NetworkService, NetworkState, Peer, PeerIndex, ProtocolId, SupportProtocols, TargetSession, }; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::ChainStore; use ckb_systemtime::{self, unix_time_as_millis}; use ckb_test_chain_utils::always_success_cell; diff --git a/sync/src/tests/sync_shared.rs b/sync/src/tests/sync_shared.rs index 0543d4bf69..9955ef84b7 100644 --- a/sync/src/tests/sync_shared.rs +++ b/sync/src/tests/sync_shared.rs @@ -2,7 +2,7 @@ use crate::block_status::BlockStatus; use crate::tests::util::{build_chain, inherit_block}; use crate::SyncShared; use ckb_chain::chain::ChainService; -use ckb_launcher::SharedBuilder; +use ckb_shared::SharedBuilder; use ckb_store::{self, ChainStore}; use ckb_test_chain_utils::always_success_cellbase; use ckb_types::core::{BlockBuilder, BlockView, Capacity}; diff --git a/sync/src/tests/synchronizer/basic_sync.rs b/sync/src/tests/synchronizer/basic_sync.rs index 01796ee363..9c5c1977b6 100644 --- a/sync/src/tests/synchronizer/basic_sync.rs +++ b/sync/src/tests/synchronizer/basic_sync.rs @@ -9,10 +9,9 @@ use ckb_chain_spec::consensus::ConsensusBuilder; use ckb_channel::bounded; use ckb_dao::DaoCalculator; use ckb_dao_utils::genesis_dao_data; -use ckb_launcher::SharedBuilder; use ckb_network::SupportProtocols; use ckb_reward_calculator::RewardCalculator; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::ChainStore; use ckb_systemtime::{self, unix_time_as_millis}; use ckb_test_chain_utils::always_success_cell; diff --git a/sync/src/tests/synchronizer/functions.rs b/sync/src/tests/synchronizer/functions.rs index 2064589ab6..8b71178d0c 100644 --- a/sync/src/tests/synchronizer/functions.rs +++ b/sync/src/tests/synchronizer/functions.rs @@ -3,13 +3,12 @@ use ckb_chain_spec::consensus::{Consensus, ConsensusBuilder}; use ckb_constant::sync::{CHAIN_SYNC_TIMEOUT, EVICTION_HEADERS_RESPONSE_TIME, MAX_TIP_AGE}; use ckb_dao::DaoCalculator; use ckb_error::InternalErrorKind; -use ckb_launcher::SharedBuilder; use ckb_network::{ async_trait, bytes::Bytes, Behaviour, CKBProtocolContext, Peer, PeerId, PeerIndex, ProtocolId, SessionType, TargetSession, }; use ckb_reward_calculator::RewardCalculator; -use ckb_shared::{Shared, Snapshot}; +use ckb_shared::{Shared, SharedBuilder, Snapshot}; use ckb_store::ChainStore; use ckb_systemtime::unix_time_as_millis; use ckb_types::{ diff --git a/sync/src/tests/util.rs b/sync/src/tests/util.rs index 092981eaaf..0ccf5ba2e8 100644 --- a/sync/src/tests/util.rs +++ b/sync/src/tests/util.rs @@ -1,9 +1,8 @@ use crate::SyncShared; use ckb_chain::chain::{ChainController, ChainService}; use ckb_dao::DaoCalculator; -use ckb_launcher::SharedBuilder; use ckb_reward_calculator::RewardCalculator; -use ckb_shared::{Shared, Snapshot}; +use ckb_shared::{Shared, SharedBuilder, Snapshot}; use ckb_store::ChainStore; use ckb_test_chain_utils::{always_success_cellbase, always_success_consensus}; use ckb_types::prelude::*; diff --git a/util/launcher/Cargo.toml b/util/launcher/Cargo.toml index 055c3609d8..2c4d2b7dba 100644 --- a/util/launcher/Cargo.toml +++ b/util/launcher/Cargo.toml @@ -13,11 +13,8 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] 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-app-config = { path = "../app-config", 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" } ckb-build-info = { path = "../build-info", version = "= 0.113.0-pre" } ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.113.0-pre" } ckb-chain = { path = "../../chain", version = "= 0.113.0-pre" } @@ -32,18 +29,11 @@ ckb-verification-traits = { path = "../../verification/traits", version = "= 0.1 ckb-async-runtime = { path = "../runtime", version = "= 0.113.0-pre" } ckb-proposal-table = { path = "../proposal-table", version = "= 0.113.0-pre" } ckb-channel = { path = "../channel", version = "= 0.113.0-pre" } -ckb-chain-spec = { path = "../../spec", version = "= 0.113.0-pre" } -ckb-freezer = { path = "../../freezer", version = "= 0.113.0-pre" } -ckb-notify = { path = "../../notify", version = "= 0.113.0-pre" } -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-migrate = { path = "../migrate", version = "= 0.113.0-pre" } -once_cell = "1.8.0" -tempfile.workspace = true [features] with_sentry = [ "ckb-sync/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry" ] -portable = ["ckb-db/portable", "ckb-migrate/portable"] -march-native = ["ckb-db/march-native", "ckb-migrate/march-native"] +portable = ["ckb-shared/portable"] +march-native = ["ckb-shared/march-native"] diff --git a/util/launcher/src/lib.rs b/util/launcher/src/lib.rs index bc4d1bf517..3c14a139df 100644 --- a/util/launcher/src/lib.rs +++ b/util/launcher/src/lib.rs @@ -2,8 +2,6 @@ //! //! ckb launcher is helps to launch ckb node. -mod shared_builder; - use ckb_app_config::{ BlockAssemblerConfig, ExitCode, RpcConfig, RpcModule, RunArgs, SupportProtocol, }; @@ -25,6 +23,7 @@ use ckb_resource::Resource; use ckb_rpc::{RpcServer, ServiceBuilder}; use ckb_shared::Shared; +use ckb_shared::shared_builder::{SharedBuilder, SharedPackage}; use ckb_store::{ChainDB, ChainStore}; use ckb_sync::{BlockFilter, NetTimeProtocol, Relayer, SyncShared, Synchronizer}; use ckb_tx_pool::service::TxVerificationResult; @@ -33,8 +32,6 @@ use ckb_verification::GenesisVerifier; use ckb_verification_traits::Verifier; use std::sync::Arc; -pub use crate::shared_builder::{SharedBuilder, SharedPackage}; - const SECP256K1_BLAKE160_SIGHASH_ALL_ARG_LEN: usize = 20; /// Ckb launcher is helps to launch ckb node. diff --git a/util/light-client-protocol-server/Cargo.toml b/util/light-client-protocol-server/Cargo.toml index c55c9727ee..979c634f12 100644 --- a/util/light-client-protocol-server/Cargo.toml +++ b/util/light-client-protocol-server/Cargo.toml @@ -21,7 +21,6 @@ ckb-systemtime = {path = "../systemtime", version = "= 0.113.0-pre"} ckb-chain = { path = "../../chain", version = "= 0.113.0-pre" } ckb-chain-spec = { path = "../../spec", version = "= 0.113.0-pre" } ckb-tx-pool = { path = "../../tx-pool", version = "= 0.113.0-pre" } -ckb-launcher = { path = "../launcher", version = "= 0.113.0-pre" } ckb-app-config = { path = "../app-config", version = "= 0.113.0-pre" } ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.113.0-pre" } ckb-dao-utils = { path = "../dao/utils", version = "= 0.113.0-pre" } diff --git a/util/light-client-protocol-server/src/tests/utils/chain.rs b/util/light-client-protocol-server/src/tests/utils/chain.rs index fcfd483a86..177d4c9bee 100644 --- a/util/light-client-protocol-server/src/tests/utils/chain.rs +++ b/util/light-client-protocol-server/src/tests/utils/chain.rs @@ -8,9 +8,8 @@ use ckb_chain::chain::{ChainController, ChainService}; use ckb_chain_spec::consensus::{build_genesis_epoch_ext, ConsensusBuilder}; use ckb_dao_utils::genesis_dao_data; use ckb_jsonrpc_types::ScriptHashType; -use ckb_launcher::SharedBuilder; use ckb_network::{Flags, NetworkController, NetworkService, NetworkState}; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_systemtime::unix_time_as_millis; use ckb_test_chain_utils::always_success_cell; use ckb_tx_pool::TxPoolController; diff --git a/verification/contextual/Cargo.toml b/verification/contextual/Cargo.toml index 26953c8657..09f5316fa2 100644 --- a/verification/contextual/Cargo.toml +++ b/verification/contextual/Cargo.toml @@ -29,7 +29,6 @@ ckb-merkle-mountain-range = "0.5.2" [dev-dependencies] ckb-chain = { path = "../../chain", version = "= 0.113.0-pre" } ckb-shared = { path = "../../shared", version = "= 0.113.0-pre" } -ckb-launcher = { path = "../../util/launcher", version = "= 0.113.0-pre" } ckb-test-chain-utils = { path = "../../util/test-chain-utils", version = "= 0.113.0-pre" } ckb-systemtime = { path = "../../util/systemtime", version = "= 0.113.0-pre", features = ["enable_faketime"]} rand = "0.7" diff --git a/verification/contextual/src/tests/contextual_block_verifier.rs b/verification/contextual/src/tests/contextual_block_verifier.rs index 06e4ed79f6..a53b1146ba 100644 --- a/verification/contextual/src/tests/contextual_block_verifier.rs +++ b/verification/contextual/src/tests/contextual_block_verifier.rs @@ -3,8 +3,7 @@ use crate::contextual_block_verifier::{RewardVerifier, VerifyContext}; use ckb_chain::chain::{ChainController, ChainService}; use ckb_chain_spec::consensus::{Consensus, ConsensusBuilder}; use ckb_error::assert_error_eq; -use ckb_launcher::SharedBuilder; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::{ChainDB, ChainStore}; use ckb_test_chain_utils::always_success_cell; use ckb_types::{ diff --git a/verification/contextual/src/tests/uncle_verifier.rs b/verification/contextual/src/tests/uncle_verifier.rs index 1e89a86117..af12732084 100644 --- a/verification/contextual/src/tests/uncle_verifier.rs +++ b/verification/contextual/src/tests/uncle_verifier.rs @@ -5,8 +5,7 @@ use crate::uncles_verifier::UnclesVerifier; use ckb_chain::chain::{ChainController, ChainService}; use ckb_chain_spec::consensus::Consensus; use ckb_error::assert_error_eq; -use ckb_launcher::SharedBuilder; -use ckb_shared::Shared; +use ckb_shared::{Shared, SharedBuilder}; use ckb_store::{ChainDB, ChainStore}; use ckb_types::{ core::{