Skip to content

Refactor/split common#531

Merged
illuque merged 2 commits into
mainfrom
refactor/split-common
Jun 11, 2026
Merged

Refactor/split common#531
illuque merged 2 commits into
mainfrom
refactor/split-common

Conversation

@illuque

@illuque illuque commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

🧱 Refactor: split the common crate into focused crates

common had become a grab-bag — every service pulled the whole thing (alloy WS provider, BitVMX emulator, broker transport, test fixtures) even when it only needed a couple of types. I broke it into focused crates under crates/common/:

  • common-core — shared types & constants
  • common-runtime — config, logging, shutdown/runtime helpers
  • common-rsk — Rootstock provider (alloy)
  • common-broker — broker transport (BitVMX channel behind a feature)
  • common-bitvmx — BitVMX message types
  • common-dev — test fixtures (dev-only)

Benefits:

  • Each service now depends only on what it actually uses → leaner dependency graphs
  • transaction-dispatcher drops the broker stack; user-api + indexers no longer compile the BitVMX emulator → smaller binaries & faster per-crate builds
  • Clearer ownership/boundaries; no more accidental coupling through a god-crate

No behavior changes — pure refactor. Imports stay common_core::… etc. ✅ clippy, full tests, and cargo doc all green.

Description

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (code improvement without changing existing functionality)

@illuque illuque force-pushed the refactor/split-common branch from 8e6a8a5 to bf869bd Compare June 10, 2026 14:52
Comment thread crates/common/broker/src/broker.rs Dismissed
@illuque illuque force-pushed the refactor/split-common branch from bf869bd to 0d4dfe5 Compare June 10, 2026 15:41
@illuque illuque marked this pull request as ready for review June 10, 2026 15:58
Copilot AI review requested due to automatic review settings June 10, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the former common crate into multiple focused crates (common-core, common-runtime, common-rsk, common-broker, common-bitvmx, common-dev) and updates all consumers (services, tests, docs, and build config) to depend on the minimal subset they actually use.

Changes:

  • Replaced the monolithic crates/common with multiple crates/common/* crates and updated workspace membership/lockfile accordingly.
  • Updated imports and Cargo dependencies across coordinator, transaction-dispatcher, block-indexer, log-indexer, and user-api to target the new crates (including feature-gating BitVMX broker support).
  • Moved shared dev/test generators into common-dev and updated docs/build-time logging defaults to match new crate names.

Reviewed changes

Copilot reviewed 98 out of 112 changed files in this pull request and generated no comments.

Show a summary per file
File Description
docs/LOGGING.md Update documentation links/paths to common-runtime logging module.
docs/LOCAL_SETUP.md Update git-hook installation instructions to use common-dev.
docker/build/Dockerfile Update default RUST_LOG directives to new crate names.
crates/user-api/src/sync_contracts_gateway.rs Switch Address import to common-core.
crates/user-api/src/server.rs Switch broker/types/runtime imports to new common-* crates.
crates/user-api/src/main.rs Switch broker/runtime imports to new common-* crates.
crates/user-api/src/config.rs Switch config/errors/logging types to common-runtime.
crates/user-api/Cargo.toml Replace common dependency with common-broker/core/runtime.
crates/transaction-dispatcher/tests/runtime_sync_integration_test.rs Switch RuntimeSync import to common-runtime.
crates/transaction-dispatcher/src/types.rs Switch BitVMX/core types imports to common-bitvmx/common-core.
crates/transaction-dispatcher/src/rsk_gateway.rs Switch core types imports to common-core.
crates/transaction-dispatcher/src/lib.rs Switch Address/RuntimeSync imports to common-core/common-runtime.
crates/transaction-dispatcher/src/contracts/types.rs Switch BitVMX type import to common-bitvmx.
crates/transaction-dispatcher/src/contracts/native_bridge.rs Switch core types imports to common-core (and tests).
crates/transaction-dispatcher/src/contracts/interactions/deposit_aggregated_key.rs Switch CommitteeId import to common-core in tests.
crates/transaction-dispatcher/src/contracts/interactions/apply_to_stream.rs Switch BitVMX type import to common-bitvmx in tests.
crates/transaction-dispatcher/src/contracts/interactions/add_operator_take_tx_hash.rs Switch TxIdParser import to common-core.
crates/transaction-dispatcher/src/contracts/committee_registry.rs Switch CommitteeId import to common-core.
crates/transaction-dispatcher/src/config.rs Switch config/errors/logging types to common-runtime and core types to common-core.
crates/transaction-dispatcher/Cargo.toml Replace common dependency with common-bitvmx/core/runtime.
crates/log-indexer/tests/integration_tests.rs Switch types to common-core, provider/indexer to common-rsk, fixtures to common-dev, config/shutdown to common-runtime.
crates/log-indexer/src/store.rs Switch core types imports to common-core and fixtures to common-dev.
crates/log-indexer/src/notifier.rs Switch broker/types/constants/shutdown/types to new common-* crates (and tests).
crates/log-indexer/src/main.rs Switch broker/types/provider/indexer/shutdown imports to new common-* crates.
crates/log-indexer/src/indexer.rs Switch provider/indexer/config/shutdown/types to new common-* crates; use resolve_initial_block helper from common-rsk.
crates/log-indexer/src/config.rs Switch config/errors/types/logging imports to common-runtime/common-core.
crates/log-indexer/Cargo.toml Replace common dependency with common-broker/core/rsk/runtime; add common-dev dev-dep.
crates/coordinator/src/user_requests.rs Switch BitVMX/core types imports to common-bitvmx/common-core.
crates/coordinator/src/types.rs Switch BitVMX/core types imports to common-bitvmx/common-core; fixtures to common-dev.
crates/coordinator/src/store.rs Switch BitVMX/core types imports to common-bitvmx/common-core.
crates/coordinator/src/monitor.rs Switch BitVMX/broker/core/runtime imports to new common-* crates; fixtures to common-dev.
crates/coordinator/src/main.rs Switch broker/config/runtime/logging/shutdown imports to common-broker/common-runtime.
crates/coordinator/src/flows/pegout/pegout_processor.rs Switch BitVMX/broker/core/runtime imports to new common-* crates; update test helpers.
crates/coordinator/src/flows/pegout/pegout_flow.rs Switch BitVMX/broker/core/runtime imports to new common-* crates; update TxIdParser paths.
crates/coordinator/src/flows/pegin/pegin_processor.rs Switch BitVMX/broker/core/runtime imports to new common-* crates; update test helpers.
crates/coordinator/src/flows/pegin/pegin_flow.rs Switch BitVMX/broker/core/runtime imports to new common-* crates.
crates/coordinator/src/flows/operator_take/types.rs Switch BitVMX/core types imports to common-bitvmx/common-core.
crates/coordinator/src/flows/operator_take/operator_take_processor.rs Switch BitVMX/broker/core/runtime imports and trait bounds to common-broker; update core type paths.
crates/coordinator/src/flows/operator_take/operator_take_flow.rs Switch BitVMX/broker/core/runtime imports to new common-* crates.
crates/coordinator/src/flows/funding_info_flow.rs Switch BitVMX/broker types imports to common-bitvmx/common-broker.
crates/coordinator/src/flows/common/native_bridge_verifier.rs Switch BitVMX/core/runtime imports to new common-* crates; update core type paths.
crates/coordinator/src/flows/common/context.rs Switch BitVMX/core types imports to common-bitvmx/common-core.
crates/coordinator/src/flows/committee/setup_committee_processor.rs Switch BitVMX/broker/core/runtime imports to new common-* crates; update test helpers.
crates/coordinator/src/flows/committee/setup_committee_flow.rs Switch BitVMX/broker/core/runtime imports to new common-* crates; update type paths.
crates/coordinator/src/flows/committee/full_penalization_setup.rs Switch BitVMX/broker imports to common-bitvmx/common-broker.
crates/coordinator/src/flows/committee/dispute_core_setup.rs Switch BitVMX/broker/core imports to new common-* crates.
crates/coordinator/src/flows/committee/dispute_channel_setup.rs Switch BitVMX config/types/broker/core imports to new common-* crates.
crates/coordinator/src/flows/committee/common.rs Switch BitVMX/broker/core imports to new common-* crates.
crates/coordinator/src/flows/btc_signature/btc_signature_subflow.rs Switch core/runtime imports to common-core/common-runtime; fixtures to common-dev.
crates/coordinator/src/flows/btc_signature/btc_signature_lifecycle.rs Switch core/runtime imports to common-core/common-runtime; fixtures to common-dev.
crates/coordinator/src/event_processor.rs Switch BitVMX/core type imports to common-bitvmx/common-core.
crates/coordinator/src/coordinator.rs Switch BitVMX/broker/core/runtime imports to new common-* crates; update test fixtures.
crates/coordinator/src/config.rs Switch config/errors/logging/types imports to common-runtime/common-core.
crates/coordinator/src/blockchain_tracker.rs Switch core types imports to common-core; fixtures to common-dev.
crates/coordinator/Cargo.toml Replace common with common-bitvmx/broker/core/runtime; add common-dev dev-dep.
crates/common/src/msg_broker/mod.rs Remove legacy common::msg_broker module (crate split).
crates/common/src/lib.rs Remove legacy common crate root module declarations (crate split).
crates/common/runtime/src/shutdown_flag.rs New ShutdownFlag implementation under common-runtime.
crates/common/runtime/src/runtime_sync.rs New RuntimeSync wrapper under common-runtime (with tests).
crates/common/runtime/src/logging.rs New logging/subscriber setup under common-runtime (with tests).
crates/common/runtime/src/lib.rs New common-runtime crate root.
crates/common/runtime/src/errors.rs New common-runtime config error type.
crates/common/runtime/src/config.rs Move config loading into common-runtime; adjust project-root resolution.
crates/common/runtime/LICENSE Add license file for common-runtime.
crates/common/runtime/Cargo.toml Add manifest for common-runtime.
crates/common/rsk/tests/resources/log_response.json Add test fixture data for common-rsk provider tests.
crates/common/rsk/tests/resources/block_response.json Add test fixture data for common-rsk provider tests.
crates/common/rsk/src/rsk_provider.rs Move provider traits/types to common-rsk; add resolve_initial_block.
crates/common/rsk/src/rsk_indexer.rs Add RskIndexer trait to common-rsk.
crates/common/rsk/src/lib.rs New common-rsk crate root.
crates/common/rsk/src/alloy_rsk_provider/sub.rs Update alloy subscription code to use common-core types.
crates/common/rsk/src/alloy_rsk_provider/rpc.rs Update alloy RPC provider to use common-core types and common-runtime runtime/shutdown.
crates/common/rsk/src/alloy_rsk_provider/mod.rs New module declaration for common-rsk alloy provider.
crates/common/rsk/LICENSE Add license file for common-rsk.
crates/common/rsk/Cargo.toml Add manifest for common-rsk.
crates/common/dev/src/rsk_utils.rs Move RSK test utilities to common-dev using common-core types; update doc examples.
crates/common/dev/src/rsk_log_generator.rs Move log generator to common-dev using common-core types; update doc examples.
crates/common/dev/src/rsk_block_generator.rs Move block generator to common-dev using common-core types; update doc examples.
crates/common/dev/src/mock_rsk_provider_handler.rs Move provider mock handler to common-dev behind provider-mock feature.
crates/common/dev/src/lib.rs New common-dev crate root with feature-gated mock module.
crates/common/dev/LICENSE Add license file for common-dev.
crates/common/dev/Cargo.toml Add manifest for common-dev (incl. cargo-husky dev-dep).
crates/common/core/src/types.rs Update doc examples and adjust tests (duplicate fixtures to avoid common-dev dependency).
crates/common/core/src/lib.rs New common-core crate root.
crates/common/core/src/constants.rs Add shared constants (e.g., notifier period) to common-core.
crates/common/core/src/anvil_mocks.rs Add anvil-only helpers under common-core feature.
crates/common/core/LICENSE Add license file for common-core.
crates/common/core/Cargo.toml Add manifest for common-core.
crates/common/Cargo.toml Remove legacy common crate manifest (crate split).
crates/common/broker/src/types.rs Update broker message types to use common-core types.
crates/common/broker/src/lib.rs New common-broker crate root.
crates/common/broker/src/broker.rs Feature-gate BitVMX channel behind bitvmx feature; keep Union channel available by default.
crates/common/broker/LICENSE Add license file for common-broker.
crates/common/broker/Cargo.toml Add manifest for common-broker.
crates/common/bitvmx/src/lib.rs New common-bitvmx crate root.
crates/common/bitvmx/src/config.rs Update module pathing for BitVMX config types.
crates/common/bitvmx/src/bitvmx_types.rs Introduce BitVMX protocol message/types module (moved from legacy common).
crates/common/bitvmx/LICENSE Add license file for common-bitvmx.
crates/common/bitvmx/Cargo.toml Add manifest for common-bitvmx.
crates/block-indexer/tests/integration_tests.rs Update tests to use new common-* crates and local cache module.
crates/block-indexer/src/store.rs Switch types to common-core and cache to new local cache module.
crates/block-indexer/src/notifier.rs Switch broker/constants/shutdown/types to new common-* crates (and tests).
crates/block-indexer/src/main.rs Switch broker/types/provider/indexer/shutdown imports to new common-* crates.
crates/block-indexer/src/lib.rs Export new cache module.
crates/block-indexer/src/indexer.rs Switch provider/indexer/config/shutdown/types to new common-* crates; use resolve_initial_block helper.
crates/block-indexer/src/config.rs Switch config/errors/logging imports to common-runtime.
crates/block-indexer/src/cache.rs New in-crate LRU cache implementation replacing legacy common::cache.
crates/block-indexer/Cargo.toml Replace common dependency with common-broker/core/rsk/runtime; add lru and common-dev dev-dep.
CONTRIBUTING.md Update crate tier list and TxIdParser reference to common-core.
cli/run/src/main.rs Update documentation comment paths for moved anvil shims.
Cargo.toml Update workspace members list to new common-* crates.
Cargo.lock Update lockfile to reflect new crate graph and dependencies.
Comments suppressed due to low confidence (1)

crates/common/rsk/src/rsk_provider.rs:107

  • The docstring claims this function panics when initial_block_hash is missing/invalid, but the implementation returns an error via context/with_context instead. Please update the docs to match behavior (and/or remove the # Panics section).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@illuque illuque added this pull request to the merge queue Jun 11, 2026
Merged via the queue into main with commit 6d60fae Jun 11, 2026
11 checks passed
@illuque illuque deleted the refactor/split-common branch June 11, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants