Skip to content

Conversation

@QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Aug 29, 2025

Summary by CodeRabbit

  • Chores
    • Updated project metadata to use Rust 2021 edition. No impact on functionality or public APIs.
  • Style
    • Reordered imports and applied minor formatting cleanups across the codebase for consistency. No behavioral changes.
  • Tests
    • Adjusted import ordering in test modules for consistency. No changes to test logic or coverage.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 29, 2025

Walkthrough

The PR adjusts Cargo metadata (Rust edition) and reorders/imports across multiple files, plus a minor macro formatting change and a schemars path update. No functional logic, control flow, or public API changes are introduced. Most edits are cosmetic in imports and tests.

Changes

Cohort / File(s) Summary of changes
Cargo metadata
hashes/Cargo.toml
Edition set from 2024 to 2021 in [package]; no code or dependency changes.
Benchmark imports reorg
hashes/benches/hashes.rs
Reordered criterion imports; split dashcore_hashes imports into algorithm set and traits set; no logic changes.
Runtime imports/order and minor path tweaks
hashes/src/hash_x11.rs, hashes/src/sha256.rs, hashes/src/sha256d.rs, hashes/src/sha256t.rs, hashes/src/sha512_256.rs, hashes/src/serde_macros.rs, hashes/src/util.rs
Reordered use items; serde import reordered to {de, Deserializer, Serializer}; schemars path updated schemars::r#gen::SchemaGeneratorschemars::gen::SchemaGenerator. No behavior change. Tests in some of these files have import order updates.
Macro formatting
hashes/src/siphash24.rs
Reformatted compress! macro expansion into a multi-line block; no semantic changes.
Tests-only import reorders
hashes/src/hash160.rs, hashes/src/hmac.rs, hashes/src/impls.rs, hashes/src/lib.rs, hashes/src/ripemd160.rs, hashes/src/sha1.rs, hashes/src/sha512.rs
Reordered crate and serde_test imports in test modules; no functional changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • ogabrielides

Poem

I twitched my ears at lines in rows,
Shuffled imports—neat repose.
A macro stretched to breathe a bit,
Editions swapped to neatly fit.
No hashes harmed, no bytes astray—
Just tidy trails for code to play. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/coreComponentTests

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (2)
hashes/src/siphash24.rs (1)

48-50: Avoid multiple evaluation of $state in the macro.

Using $state:expr expands the expression 4x (v0..v3). Restrict to an identifier to prevent side effects and keep intent explicit.

-macro_rules! compress {
-    ($state:expr) => {{
-        compress!($state.v0, $state.v1, $state.v2, $state.v3)
-    }};
+macro_rules! compress {
+    ($state:ident) => {
+        compress!($state.v0, $state.v1, $state.v2, $state.v3)
+    };
hashes/src/hmac.rs (1)

52-54: Typo in doc comment (“underyling” → “underlying”).

Minor polish for docs.

Apply:

-/// Pair of underyling hash engines, used for the inner and outer hash of HMAC.
+/// Pair of underlying hash engines, used for the inner and outer hash of HMAC.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3b035d8 and a15ed5b.

📒 Files selected for processing (17)
  • hashes/Cargo.toml (1 hunks)
  • hashes/benches/hashes.rs (1 hunks)
  • hashes/src/hash160.rs (3 hunks)
  • hashes/src/hash_x11.rs (1 hunks)
  • hashes/src/hmac.rs (2 hunks)
  • hashes/src/impls.rs (2 hunks)
  • hashes/src/lib.rs (1 hunks)
  • hashes/src/ripemd160.rs (2 hunks)
  • hashes/src/serde_macros.rs (1 hunks)
  • hashes/src/sha1.rs (2 hunks)
  • hashes/src/sha256.rs (3 hunks)
  • hashes/src/sha256d.rs (3 hunks)
  • hashes/src/sha256t.rs (1 hunks)
  • hashes/src/sha512.rs (2 hunks)
  • hashes/src/sha512_256.rs (2 hunks)
  • hashes/src/siphash24.rs (1 hunks)
  • hashes/src/util.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)

Files:

  • hashes/src/lib.rs
  • hashes/src/sha256.rs
  • hashes/src/impls.rs
  • hashes/src/hash160.rs
  • hashes/src/ripemd160.rs
  • hashes/src/sha256d.rs
  • hashes/src/sha512.rs
  • hashes/src/sha256t.rs
  • hashes/src/serde_macros.rs
  • hashes/src/hash_x11.rs
  • hashes/src/hmac.rs
  • hashes/src/siphash24.rs
  • hashes/src/util.rs
  • hashes/src/sha1.rs
  • hashes/src/sha512_256.rs
  • hashes/benches/hashes.rs
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Keep test vectors in sync with Dash Core releases
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/bip32_tests.rs : Organize unit tests so key-derivation correctness lives in tests/bip32_tests.rs

Applied to files:

  • hashes/src/lib.rs
  • hashes/src/impls.rs
📚 Learning: 2025-02-25T06:13:52.858Z
Learnt from: QuantumExplorer
PR: dashpay/rust-dashcore#51
File: dash/src/sml/masternode_list/scores_for_quorum.rs:50-73
Timestamp: 2025-02-25T06:13:52.858Z
Learning: ScoreHash is a cryptographic hash in the rust-dashcore library, and therefore does not need collision handling when used as a key in collections like BTreeMap due to the extremely low probability of collisions.

Applied to files:

  • hashes/src/sha256.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Use deterministic testing with known vectors (fixed seeds) in Rust tests

Applied to files:

  • hashes/src/impls.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Use property-based tests for complex invariants where suitable

Applied to files:

  • hashes/src/impls.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/address_tests.rs : Place address generation and validation tests in tests/address_tests.rs

Applied to files:

  • hashes/src/impls.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Include integration tests that cover full wallet workflows

Applied to files:

  • hashes/src/impls.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/**/Cargo.toml : Set MSRV via rust-version = "1.89" in Cargo.toml

Applied to files:

  • hashes/Cargo.toml
🧬 Code graph analysis (2)
hashes/src/hash_x11.rs (1)
dash/src/merkle_tree/block.rs (2)
  • hex (707-707)
  • hex (741-741)
hashes/benches/hashes.rs (1)
hashes/src/impls.rs (1)
  • hmac (166-187)
⏰ 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_sha512_256)
  • GitHub Check: fuzz (hashes_sha1)
  • GitHub Check: fuzz (hashes_sha256)
  • GitHub Check: fuzz (hashes_ripemd160)
  • GitHub Check: fuzz (dash_deserialize_script)
  • GitHub Check: fuzz (hashes_json)
  • GitHub Check: fuzz (dash_deserialize_witness)
  • GitHub Check: fuzz (dash_deser_net_msg)
  • GitHub Check: fuzz (dash_deserialize_amount)
  • GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
  • GitHub Check: fuzz (dash_deserialize_block)
  • GitHub Check: fuzz (dash_outpoint_string)
  • GitHub Check: fuzz (dash_deserialize_address)
  • GitHub Check: Clippy (Non-strict)
  • GitHub Check: Strict Warnings and Clippy Checks
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: Core Components Tests
  • GitHub Check: SPV Components Tests
🔇 Additional comments (32)
hashes/Cargo.toml (1)

12-12: Lock MSRV to 1.89 and fix description typo

 [package]
 name = "dashcore_hashes"
 version = { workspace = true}
 authors = ["Samuel Westrich <sam@dash.org>"]
 license = "CC0-1.0"
 repository = "https://github.com/rust-dashcore/dash_hashes/"
 documentation = "https://docs.rs/dash_hashes/"
-description = "Hash functions used by the rust-dash eccosystem"
+description = "Hash functions used by the rust-dash ecosystem"
 categories = ["algorithms"]
 keywords = [ "crypto", "dash", "hash", "digest" ]
 readme = "README.md"
 edition = "2021"
+rust-version = "1.89"
 exclude = ["tests", "contrib"]
hashes/src/util.rs (1)

586-589: Approve schemars import updates

No deprecated schemars import paths remain.

hashes/src/ripemd160.rs (1)

412-412: Import reorders in tests look good.

Purely cosmetic; no behavioral impact.

Also applies to: 505-505, 508-508

hashes/src/serde_macros.rs (1)

27-27: Serde import reshuffle is correct.

Bringing serde::de into scope as de while keeping Serializer/Deserializer is idiomatic and maintains behavior.

hashes/src/hash160.rs (3)

27-27: LGTM! Import reordering improves consistency.

This alphabetical reordering of imports aligns with Rust conventions and maintains consistency across the codebase.


54-54: LGTM! Import reordering improves consistency.

The alphabetical ordering of imports is consistent with the pattern applied across other files in this PR.


108-110: LGTM! Import reordering improves consistency.

The test imports are now properly ordered alphabetically, maintaining consistency with the broader refactoring effort.

hashes/src/lib.rs (1)

239-239: LGTM! Import reordering improves consistency.

The alphabetical ordering of test imports aligns with the broader import organization effort across the codebase.

hashes/src/hash_x11.rs (1)

34-34: LGTM! Import reordering improves consistency.

The alphabetical reordering of crate imports maintains consistency with the broader import organization effort across the hashes crate.

hashes/src/impls.rs (2)

26-26: LGTM! Import reordering improves consistency.

Moving HashEngine to the end of the import list follows alphabetical ordering conventions and aligns with the broader refactoring effort.


97-97: LGTM! Import reordering improves consistency.

The alphabetical ordering of test imports maintains consistency with the import organization pattern applied throughout this PR.

hashes/src/sha256t.rs (1)

23-23: LGTM! Import reordering improves consistency.

The alphabetical reordering of imports (sha256 before Error) aligns with Rust conventions and the broader import organization effort across the hashes crate.

hashes/src/sha512_256.rs (2)

32-32: Import reordering is fine.

No functional impact; consistent with the PR’s cosmetic cleanup.


93-93: Test import reordering is fine.

Purely cosmetic; no behavior change.

hashes/src/sha512.rs (3)

276-276: Test import reordering is fine.

No behavioral changes.


354-354: serde_test import order tweak is fine.

No effect on test behavior.


356-356: Crate import reordering is fine.

Matches the PR’s consistent style change.

hashes/src/sha1.rs (3)

149-149: Test import reordering is fine.

No functional change.


217-217: serde_test import order tweak is fine.

No effect on tests.


219-219: Crate import reordering is fine.

Cosmetic only; OK.

hashes/src/sha256.rs (3)

23-23: Top-level import reordering is fine.

No logic changes; retains trait import for HashEngine methods.


520-520: Test import reordering is fine.

Purely cosmetic.


698-698: serde_test import order tweak is fine.

No behavior change.

hashes/benches/hashes.rs (2)

1-1: criterion import reordering is fine.

No impact on benchmarks.


3-3: Manually verify Clippy on MSRV after trimming unused imports
After applying in hashes/benches/hashes.rs:

-use dashcore_hashes::{hmac, siphash24, Hash, HashEngine};
+use dashcore_hashes::{hmac, siphash24};

Manually run:

rustup toolchain install 1.89.0 --quiet
rustup override set 1.89.0
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings

and confirm no unused-import warnings remain.

hashes/src/hmac.rs (3)

375-375: Reordered serde_test imports look good.

No functional impact; maintains assert_tokens/Configure/Token availability.


377-377: Crate import reorder in serde test is fine.

Keeps sha512 in scope where required; no behavior change.


249-249: Import reorder in tests is cosmetic; local verification required
Reordering imports is purely aesthetic and keeps sha256 in scope. The sandbox couldn’t run cargo fmt, Clippy, or tests due to environment restrictions—please confirm on your machine that

cargo fmt --all -- --check  
RUSTFLAGS="-Dwarnings" cargo +1.89.0 clippy --all-targets --all-features -D warnings  
cargo +1.89.0 test -p hashes --features alloc,serde  

all pass without warnings or failures.

hashes/src/sha256d.rs (4)

22-22: Top-level import reorder is OK.

Cosmetic only; keeps module and type imports available.


49-49: Test import reorder is OK.

No semantic change; matches style used elsewhere in the PR.


100-100: serde_test import reorder is OK.

Purely stylistic; asserts remain unchanged.


102-102: Crate import reorder in serde test is OK.

No behavioral impact.

@QuantumExplorer QuantumExplorer changed the title fix: core component tests fix: core component tests and clippy warnings Aug 29, 2025
@QuantumExplorer QuantumExplorer changed the title fix: core component tests and clippy warnings fix: core component tests Aug 29, 2025
@QuantumExplorer QuantumExplorer merged commit b5f53cd into v0.40-dev Aug 29, 2025
21 of 26 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 29, 2025
@QuantumExplorer QuantumExplorer deleted the fix/coreComponentTests branch October 20, 2025 08:23
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