Skip to content

Conversation

@ZocoLini
Copy link
Collaborator

@ZocoLini ZocoLini commented Dec 18, 2025

Was working on removing headers from ChainState bcs we should use the DiskStorageManager for that and found this ChainStorage being part of the code where those headers where being used. It turns out that the method where ChainState.headers and ChainStorage where being used was only tested so I drop the hole thing and related code that become unused after that so I can continue working on the ChainState fields removal

Summary by CodeRabbit

  • Refactor
    • Removed automatic fork detection functionality and related API surface.
    • Removed chain reorganization manager and its orchestration APIs.
    • Removed in-memory synchronous storage implementation and the synchronous storage interface.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

Removed fork detection, reorganization management, the synchronous in-memory ChainStorage implementation, and their associated tests and public exports across the chain and storage modules. Multiple structs, traits, methods, and test files were deleted.

Changes

Cohort / File(s) Summary
Fork detection removed
dash-spv/src/chain/fork_detector.rs, dash-spv/src/chain/fork_detector_test.rs
Entire fork detection module and its tests deleted: ForkDetector, ForkDetectionResult, all methods (constructors, check_header, add_fork, accessors, removals, utilities), and unit tests were removed.
Reorg manager removed
dash-spv/src/chain/reorg.rs, dash-spv/src/chain/reorg_test.rs
ReorgManager, ReorgData, and their implementations (constructors, should_reorganize, is_chain_locked, validate_reorg, async phases, helpers) and reorg tests were deleted. ReorgEvent references noted in summary are no longer accompanied by manager logic.
Chain module exports updated
dash-spv/src/chain/mod.rs
Public module exports and re-exports for fork detection and reorg were removed (pub mod fork_detector;, pub mod reorg;, and related pub use lines). Test module references for the removed tests were deleted. The public Fork construct and its fields were removed.
Synchronous storage trait & memory impl removed
dash-spv/src/storage/mod.rs, dash-spv/src/storage/sync_storage.rs
Deleted ChainStorage trait (public synchronous storage interface), removed sync_storage module export and MemoryStorage re-export, and removed the entire in-memory MemoryStorage implementation (struct, new/Default, and all trait method impls).
Header sync manager cleanup
dash-spv/src/sync/headers/manager.rs
Removed fork_detector field and its initialization/reset logic from HeaderSyncManager; imports updated to drop ForkDetector. No other sync logic changes shown.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120+ minutes

  • Deletions affect core public APIs (storage trait, reorg, fork detection) and many callers; ensure downstream/consumer compatibility.
  • Verify build breaks where removed types/methods were referenced (imports, trait bounds, generics).
  • Confirm replacement or migration plans for storage/chain/reorg responsibilities.
  • Review any public API semantic/versioning implications (breaking changes).
  • Audit tests and CI to restore coverage or add new tests for remaining flows.

Poem

🐇 I hopped through code at break of dawn,

Old forks and reorgs are now withdrawn.
Memory burrows cleared and bright,
Less clutter in the tunnel light.
A twitching nose says: onward, right?

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'ChainState fiedls removal' contains a typo ('fiedls' instead of 'fields') and is misleading—the PR primarily removes ChainStorage and fork detection, not just ChainState fields. Correct the typo and revise the title to accurately reflect the main changes, such as 'Remove ChainStorage trait and fork detection infrastructure' or 'Remove sync storage and fork detector modules'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-chain-storage

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e85243 and 461905a.

📒 Files selected for processing (4)
  • dash-spv/src/chain/fork_detector.rs (0 hunks)
  • dash-spv/src/chain/mod.rs (0 hunks)
  • dash-spv/src/chain/reorg.rs (0 hunks)
  • dash-spv/src/sync/headers/manager.rs (1 hunks)
💤 Files with no reviewable changes (3)
  • dash-spv/src/chain/reorg.rs
  • dash-spv/src/chain/mod.rs
  • dash-spv/src/chain/fork_detector.rs
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types with thiserror crate and propagate errors appropriately in Rust code
Use tokio runtime for async operations in Rust code
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format Rust code with cargo fmt before committing
Ensure clippy passes with all warnings as errors on all Rust code

**/*.rs: Each crate keeps sources in src/; unit tests live alongside code with #[cfg(test)]
Maintain MSRV of 1.89 for Rust code
Format Rust code with rustfmt (see rustfmt.toml); run cargo fmt --all before commits
Lint Rust code with clippy; avoid unwrap()/expect() in library code; use error types (e.g., thiserror)
Use snake_case for function and variable names in Rust
Use UpperCamelCase for types and traits in Rust
Use SCREAMING_SNAKE_CASE for constants in Rust
Follow mixed editions (2021/2024) and crate-specific idioms; prefer async via tokio where applicable
Unit tests should be placed near code with descriptive names (e.g., test_parse_address_mainnet)
Use #[ignore] for network-dependent or long-running tests; run with -- --ignored flag
Never commit secrets or real keys; avoid logging sensitive data in Rust code
Keep test vectors deterministic in Rust test code

Files:

  • dash-spv/src/sync/headers/manager.rs
dash-spv/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

dash-spv/**/*.rs: Use async/await throughout the codebase, built on tokio runtime
Use Arc for trait objects to enable runtime polymorphism for NetworkManager and StorageManager
Use Tokio channels for inter-component message passing between async tasks
Maintain minimum Rust version (MSRV) of 1.89 and use only compatible syntax and features

Files:

  • dash-spv/src/sync/headers/manager.rs
dash-spv/src/sync/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks

Files:

  • dash-spv/src/sync/headers/manager.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/sync/**/*.rs : Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
📚 Learning: 2025-12-01T08:01:18.174Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-01T08:01:18.174Z
Learning: Organize workspace with crates: `dash`, `hashes`, `internals`, `dash-network`, `dash-spv`, `key-wallet`, `rpc-*`, utilities (`fuzz`, `test-utils`), and FFI crates (`*-ffi`)

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/client/**/*.rs : Use the DashSpvClient high-level API with proper configuration via ClientConfig for client initialization

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Pre-commit (ubuntu-latest)
  • GitHub Check: Pre-commit (macos-latest)
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: SPV Components Tests
  • GitHub Check: Core Components Tests
🔇 Additional comments (2)
dash-spv/src/sync/headers/manager.rs (2)

838-844: LGTM!

The reset_pending_requests method correctly no longer resets any ForkDetector state, which is consistent with its removal from the struct.


10-10: Verify ForkDetector removal doesn't break dependent code.

The import change correctly removes ForkDetector from the chain module imports. Ensure that no other parts of the codebase depend on ForkDetector being available through HeaderSyncManager.

Run the following script to verify that ForkDetector is not referenced elsewhere in the codebase:

#!/bin/bash
# Description: Search for any remaining references to ForkDetector in the codebase

# Search for ForkDetector usage (excluding removed files mentioned in PR)
rg -nP '\bForkDetector\b' \
  -g '!dash-spv/src/chain/fork_detector.rs' \
  -g '!dash-spv/src/chain/fork_detector_test.rs' \
  -C3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
dash-spv/src/chain/fork_detector.rs (3)

1-4: Module documentation is stale.

The docstring states this module "detects when incoming headers create a fork," but the detection logic (check_header) has been removed. Update the documentation to reflect that this is now a fork storage/query utility rather than a detection module.

🔎 Suggested documentation update
-//! Fork detection logic for identifying blockchain forks
+//! Fork storage and query utilities for blockchain forks
 //!
-//! This module detects when incoming headers create a fork in the blockchain
-//! rather than extending the current chain tip.
+//! This module provides storage and query operations for known blockchain forks.

57-68: Remove unused ForkDetectionResult enum.

This enum is defined and publicly exported but no method in ForkDetector returns it, and it is not used anywhere in the codebase. Remove it if no external code depends on it.


17-24: Remove unused max_forks parameter or implement fork limit enforcement.

The max_forks parameter is validated but never stored or used. The struct contains only a forks HashMap with no corresponding max_forks field. Either remove the parameter entirely if fork limits are not needed, or store the limit and enforce it when adding forks.

Additionally, ForkDetectionResult enum is defined but never used anywhere in the codebase and should be removed unless future implementations require it.

🧹 Nitpick comments (2)
dash-spv/src/chain/mod.rs (1)

1-8: Consider updating module documentation to reflect simplified functionality.

The module docstring describes comprehensive chain management features (fork detection, reorganization, etc.), but with the removal of ReorgManager and simplification of ForkDetector, some of these capabilities have been reduced. Consider revising the documentation to match current functionality.

dash-spv/src/chain/fork_detector.rs (1)

74-79: Test validates unused functionality.

This test verifies the max_forks == 0 error, but since max_forks is never stored or enforced, this validation has no practical effect. If the parameter is removed per the earlier suggestion, this test should also be removed.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72ac033 and 2e85243.

📒 Files selected for processing (7)
  • dash-spv/src/chain/fork_detector.rs (1 hunks)
  • dash-spv/src/chain/fork_detector_test.rs (0 hunks)
  • dash-spv/src/chain/mod.rs (1 hunks)
  • dash-spv/src/chain/reorg.rs (0 hunks)
  • dash-spv/src/chain/reorg_test.rs (0 hunks)
  • dash-spv/src/storage/mod.rs (0 hunks)
  • dash-spv/src/storage/sync_storage.rs (0 hunks)
💤 Files with no reviewable changes (5)
  • dash-spv/src/storage/mod.rs
  • dash-spv/src/chain/fork_detector_test.rs
  • dash-spv/src/chain/reorg_test.rs
  • dash-spv/src/storage/sync_storage.rs
  • dash-spv/src/chain/reorg.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types with thiserror crate and propagate errors appropriately in Rust code
Use tokio runtime for async operations in Rust code
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format Rust code with cargo fmt before committing
Ensure clippy passes with all warnings as errors on all Rust code

**/*.rs: Each crate keeps sources in src/; unit tests live alongside code with #[cfg(test)]
Maintain MSRV of 1.89 for Rust code
Format Rust code with rustfmt (see rustfmt.toml); run cargo fmt --all before commits
Lint Rust code with clippy; avoid unwrap()/expect() in library code; use error types (e.g., thiserror)
Use snake_case for function and variable names in Rust
Use UpperCamelCase for types and traits in Rust
Use SCREAMING_SNAKE_CASE for constants in Rust
Follow mixed editions (2021/2024) and crate-specific idioms; prefer async via tokio where applicable
Unit tests should be placed near code with descriptive names (e.g., test_parse_address_mainnet)
Use #[ignore] for network-dependent or long-running tests; run with -- --ignored flag
Never commit secrets or real keys; avoid logging sensitive data in Rust code
Keep test vectors deterministic in Rust test code

Files:

  • dash-spv/src/chain/mod.rs
  • dash-spv/src/chain/fork_detector.rs
dash-spv/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

dash-spv/**/*.rs: Use async/await throughout the codebase, built on tokio runtime
Use Arc for trait objects to enable runtime polymorphism for NetworkManager and StorageManager
Use Tokio channels for inter-component message passing between async tasks
Maintain minimum Rust version (MSRV) of 1.89 and use only compatible syntax and features

Files:

  • dash-spv/src/chain/mod.rs
  • dash-spv/src/chain/fork_detector.rs
🧠 Learnings (16)
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/tests/**/*.rs : Organize tests into unit tests (in-module), integration tests (tests/ directory), real network tests (with live Dash Core nodes), and performance benchmarks

Applied to files:

  • dash-spv/src/chain/mod.rs
  • dash-spv/src/chain/fork_detector.rs
📚 Learning: 2025-12-01T08:00:50.618Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:50.618Z
Learning: Applies to swift-dash-core-sdk/**/*.rs : Implement new FFI functions in Rust with `#[no_mangle] extern "C"` annotation in dash-spv-ffi

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/sync/**/*.rs : Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks

Applied to files:

  • dash-spv/src/chain/mod.rs
  • dash-spv/src/chain/fork_detector.rs
📚 Learning: 2025-12-01T08:01:18.174Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-01T08:01:18.174Z
Learning: Organize workspace with crates: `dash`, `hashes`, `internals`, `dash-network`, `dash-spv`, `key-wallet`, `rpc-*`, utilities (`fuzz`, `test-utils`), and FFI crates (`*-ffi`)

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-01T08:00:50.618Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:50.618Z
Learning: When making changes to Rust FFI in dash-spv-ffi, rebuild with `cargo build --release` and run Swift tests to verify integration

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Maintain minimum Rust version (MSRV) of 1.89 and use only compatible syntax and features

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Use async/await throughout the codebase, built on tokio runtime

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-01T08:01:00.652Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:01:00.652Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/*.swift : Use DashSDK's public methods, not direct SPVClient access, when accessing SPV functionality in Swift code

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Use `#[no_mangle] extern "C"` attribute when implementing new FFI functions in Rust

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/validation/**/*.rs : Implement three validation modes: ValidationMode::None (no validation), ValidationMode::Basic (structure and timestamp validation), and ValidationMode::Full (complete PoW and chain validation)

Applied to files:

  • dash-spv/src/chain/mod.rs
📚 Learning: 2025-12-01T07:59:46.015Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:46.015Z
Learning: Applies to **/tests/**/*.rs : Test both mainnet and testnet configurations

Applied to files:

  • dash-spv/src/chain/mod.rs
  • dash-spv/src/chain/fork_detector.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory

Applied to files:

  • dash-spv/src/chain/fork_detector.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/tests/**/*.rs : Integration tests should gracefully handle unavailable Dash Core nodes at 127.0.0.1:9999 without failing the test suite

Applied to files:

  • dash-spv/src/chain/fork_detector.rs
📚 Learning: 2025-12-01T08:00:37.919Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-01T08:00:37.919Z
Learning: Keep test vectors updated with Dash Core, monitor for new DIPs affecting wallet structure, maintain backward compatibility for serialized wallets, and update derivation paths for Platform features

Applied to files:

  • dash-spv/src/chain/fork_detector.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/tests/unit/**/*.rs : Add corresponding unit tests in `tests/unit/` for each new FFI function

Applied to files:

  • dash-spv/src/chain/fork_detector.rs
📚 Learning: 2025-12-01T07:59:46.015Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:46.015Z
Learning: Applies to **/tests/**/*.rs : Write integration tests for network operations in Rust

Applied to files:

  • dash-spv/src/chain/fork_detector.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: fuzz (hashes_sha512)
  • GitHub Check: fuzz (hashes_sha1)
  • GitHub Check: fuzz (hashes_ripemd160)
  • GitHub Check: fuzz (dash_deserialize_script)
  • GitHub Check: fuzz (hashes_json)
  • GitHub Check: fuzz (hashes_cbor)
  • GitHub Check: fuzz (dash_deserialize_amount)
  • GitHub Check: fuzz (dash_deserialize_block)
  • GitHub Check: fuzz (hashes_sha512_256)
  • GitHub Check: fuzz (dash_outpoint_string)
  • GitHub Check: fuzz (dash_deserialize_address)
  • GitHub Check: fuzz (hashes_sha256)
  • GitHub Check: fuzz (dash_deser_net_msg)
  • GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
  • GitHub Check: Pre-commit (macos-latest)
  • GitHub Check: Core Components Tests
  • GitHub Check: Key Wallet Components Tests
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: SPV Components Tests
🔇 Additional comments (1)
dash-spv/src/chain/mod.rs (1)

29-29: LGTM - API surface reduction is consistent with PR objectives.

The removal of ReorgManager from public exports aligns with the stated goal of removing ChainStorage and related code. ReorgEvent remains available for external consumers who need to react to reorganization events.

@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Dec 19, 2025
@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@ZocoLini ZocoLini changed the title removed chain storage an related code ChainState fiedls removal Dec 19, 2025
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Dec 20, 2025
@ZocoLini ZocoLini marked this pull request as ready for review December 20, 2025 19:47
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
dash-spv/src/sync/headers/manager.rs (2)

1-1: Update file documentation to reflect fork detection removal.

The file header comment mentions "fork detection and reorganization handling," but the ForkDetector has been removed from this module as part of this PR. Update the documentation to accurately reflect the current functionality.

🔎 Proposed fix
-//! Header synchronization with fork detection and reorganization handling.
+//! Header synchronization with reorganization handling.

284-286: Remove outdated comment about fork detection.

This comment suggests that fork detection is "temporarily disabled" and needs to be implemented in production. However, per the PR objectives, fork detection has been permanently removed from the codebase. This comment should be removed to avoid confusing future maintainers.

🔎 Proposed fix
-        // Note: Fork detection is temporarily disabled for batch processing
-        // In a production implementation, we would need to handle fork detection
-        // at the batch level or in a separate phase
-
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e85243 and 461905a.

📒 Files selected for processing (4)
  • dash-spv/src/chain/fork_detector.rs (0 hunks)
  • dash-spv/src/chain/mod.rs (0 hunks)
  • dash-spv/src/chain/reorg.rs (0 hunks)
  • dash-spv/src/sync/headers/manager.rs (1 hunks)
💤 Files with no reviewable changes (3)
  • dash-spv/src/chain/reorg.rs
  • dash-spv/src/chain/mod.rs
  • dash-spv/src/chain/fork_detector.rs
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types with thiserror crate and propagate errors appropriately in Rust code
Use tokio runtime for async operations in Rust code
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format Rust code with cargo fmt before committing
Ensure clippy passes with all warnings as errors on all Rust code

**/*.rs: Each crate keeps sources in src/; unit tests live alongside code with #[cfg(test)]
Maintain MSRV of 1.89 for Rust code
Format Rust code with rustfmt (see rustfmt.toml); run cargo fmt --all before commits
Lint Rust code with clippy; avoid unwrap()/expect() in library code; use error types (e.g., thiserror)
Use snake_case for function and variable names in Rust
Use UpperCamelCase for types and traits in Rust
Use SCREAMING_SNAKE_CASE for constants in Rust
Follow mixed editions (2021/2024) and crate-specific idioms; prefer async via tokio where applicable
Unit tests should be placed near code with descriptive names (e.g., test_parse_address_mainnet)
Use #[ignore] for network-dependent or long-running tests; run with -- --ignored flag
Never commit secrets or real keys; avoid logging sensitive data in Rust code
Keep test vectors deterministic in Rust test code

Files:

  • dash-spv/src/sync/headers/manager.rs
dash-spv/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

dash-spv/**/*.rs: Use async/await throughout the codebase, built on tokio runtime
Use Arc for trait objects to enable runtime polymorphism for NetworkManager and StorageManager
Use Tokio channels for inter-component message passing between async tasks
Maintain minimum Rust version (MSRV) of 1.89 and use only compatible syntax and features

Files:

  • dash-spv/src/sync/headers/manager.rs
dash-spv/src/sync/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks

Files:

  • dash-spv/src/sync/headers/manager.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/sync/**/*.rs : Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
📚 Learning: 2025-12-01T08:01:18.174Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-01T08:01:18.174Z
Learning: Organize workspace with crates: `dash`, `hashes`, `internals`, `dash-network`, `dash-spv`, `key-wallet`, `rpc-*`, utilities (`fuzz`, `test-utils`), and FFI crates (`*-ffi`)

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/client/**/*.rs : Use the DashSpvClient high-level API with proper configuration via ClientConfig for client initialization

Applied to files:

  • dash-spv/src/sync/headers/manager.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Pre-commit (ubuntu-latest)
  • GitHub Check: Pre-commit (macos-latest)
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: SPV Components Tests
  • GitHub Check: Core Components Tests
🔇 Additional comments (2)
dash-spv/src/sync/headers/manager.rs (2)

838-844: LGTM!

The reset_pending_requests method correctly no longer resets any ForkDetector state, which is consistent with its removal from the struct.


10-10: Verify ForkDetector removal doesn't break dependent code.

The import change correctly removes ForkDetector from the chain module imports. Ensure that no other parts of the codebase depend on ForkDetector being available through HeaderSyncManager.

Run the following script to verify that ForkDetector is not referenced elsewhere in the codebase:

#!/bin/bash
# Description: Search for any remaining references to ForkDetector in the codebase

# Search for ForkDetector usage (excluding removed files mentioned in PR)
rg -nP '\bForkDetector\b' \
  -g '!dash-spv/src/chain/fork_detector.rs' \
  -g '!dash-spv/src/chain/fork_detector_test.rs' \
  -C3

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.

2 participants