Skip to content

Commit

Permalink
Merge pull request #4236 from eval-exec/exec/break-ckb-launcher-cycle…
Browse files Browse the repository at this point in the history
…-deps

Break `ckb-launcher` and `ckb-chain`'s cycle  dependency by moving `SharedPackage` and `SharedBuilder` from `ckb-launcher` to `ckb-shared`
  • Loading branch information
quake authored Nov 21, 2023
2 parents 08ab5c4 + 480f1b1 commit 49e6325
Show file tree
Hide file tree
Showing 35 changed files with 108 additions and 146 deletions.
21 changes: 5 additions & 16 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ members = [
"error",
"util/multisig",
"util/gen-types",
"util/migrate/migration-template",
"util/types",
"util/jsonrpc-types",
"freezer",
Expand All @@ -76,6 +77,7 @@ members = [
"util/dao",
"util/reward-calculator",
"util/snapshot",
"util/migrate",
"verification/traits",
"verification",
"verification/contextual",
Expand All @@ -86,8 +88,6 @@ members = [
"sync",
"util/instrument",
"rpc",
"util/migrate/migration-template",
"util/migrate",
"util/light-client-protocol-server",
"util/launcher",
"ckb-bin"
Expand Down
1 change: 0 additions & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
3 changes: 1 addition & 2 deletions benches/benches/benchmarks/overall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions benches/benches/benchmarks/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 1 addition & 2 deletions benches/benches/benchmarks/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
4 changes: 1 addition & 3 deletions chain/src/tests/block_assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion chain/src/tests/find_fork.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion chain/src/tests/truncate.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion chain/src/tests/uncle.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions chain/src/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/src/subcommand/export.rs
Original file line number Diff line number Diff line change
@@ -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(
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 @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions ckb-bin/src/subcommand/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions ckb-bin/src/subcommand/stats.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/tests/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 1 addition & 2 deletions rpc/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
10 changes: 8 additions & 2 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 2 additions & 0 deletions shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Loading

0 comments on commit 49e6325

Please sign in to comment.