Skip to content

refactor(dash-network): move Network struct inside the dashcore crate#497

Open
ZocoLini wants to merge 1 commit intov0.42-devfrom
refactor/dash-network
Open

refactor(dash-network): move Network struct inside the dashcore crate#497
ZocoLini wants to merge 1 commit intov0.42-devfrom
refactor/dash-network

Conversation

@ZocoLini
Copy link
Collaborator

@ZocoLini ZocoLini commented Mar 5, 2026

  • Moved Network struct from dash-network into dashcore
  • Removed dash-network and dash-network-ffi crates
  • Merged core_v20_activation_height and v20_activation_height methods into one fixing a little inconsistency

Summary by CodeRabbit

  • Refactor
    • Network type definitions consolidated into the main core library; external network crate removed.
    • FFI bindings and related foreign interfaces for network functionality removed.
    • Internal imports updated to use the consolidated core Network type.
  • Chores
    • Workspace, CI matrices, and coverage listings updated to remove the removed network crates.
    • Documentation and README entries for the removed crates deleted.

@ZocoLini ZocoLini requested a review from xdustinface March 5, 2026 22:39
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

This PR removes the dash-network and dash-network-ffi crates from the workspace and consolidates the Network type and its logic into the main dash crate at dash/src/network/constants.rs. CI, workspace manifests, docs, imports, and FFI artifacts were updated or deleted accordingly.

Changes

Cohort / File(s) Summary
CI & Coverage
.codecov.yml, .github/ci-groups.yml, .github/ci-no-std.yml, .github/workflows/sanitizer.yml
Removed dash-network and dash-network-ffi entries from coverage flags, CI groupings, no-std matrix, and sanitizer workflow; adjusted ASAN test matrix and cargo test invocations to exclude the FFI crate.
Workspace Manifests & Features
Cargo.toml, dash/Cargo.toml, key-wallet/Cargo.toml, key-wallet-ffi/Cargo.toml
Removed workspace members and dependencies referencing dash-network/dash-network-ffi; removed feature hooks (serde/bincode/std/no-std) tied to those crates.
Deleted crate: dash-network
dash-network/Cargo.toml, dash-network/README.md, dash-network/src/lib.rs
Entire crate manifest, documentation, and Network implementation (enum, methods, trait impls, tests) removed.
Deleted crate: dash-network-ffi
dash-network-ffi/Cargo.toml, dash-network-ffi/README.md, dash-network-ffi/build.rs, dash-network-ffi/src/lib.rs, dash-network-ffi/src/dash_network_ffiFFI.modulemap
Entire FFI crate removed: manifest, README, build script, FFI bindings, modulemap and tests/docs deleted.
Network consolidation (dash crate)
dash/src/network/constants.rs, dash/src/lib.rs
Introduced new public Network enum and inherent API (from_magic, magic, known_genesis_block_hash, core_v20_activation_height, Display, FromStr); removed NetworkExt trait and re-exported Network from dash.
Import & Callsite updates (dash)
dash/src/address.rs, dash/src/blockdata/..., dash/src/consensus/params.rs, dash/src/crypto/..., dash/src/sml/..., dash/src/test_utils/address.rs, ...
Replaced imports from dash_network::Network with crate::Network/crate::network::constants::Network; removed catch-all match arms and updated calls to use core_v20_activation_height and inherent APIs.
Import & API origin updates (key-wallet & ffis)
key-wallet/src/*, key-wallet/src/lib.rs, key-wallet-ffi/src/derivation.rs, key-wallet/IMPLEMENTATION_SUMMARY.md
Switched Network imports/re-exports to dashcore::Network and removed dash-network dependency references and docs mentions.
Docs & Listings
AGENTS.md, CLAUDE.md, README.md
Removed crate entries for dash-network/dash-network-ffi and updated coverage/per-crate listings and section headers.
Minor cleanup
dash-spv/src/client/lifecycle.rs, dash-spv/src/sync/masternodes/manager.rs
Removed now-unused NetworkExt imports.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 I hopped through crates, one by one,

Merged the Network where dawn meets sun,
FFI whispers folded away,
Dashcore now holds the enum's sway,
A cheerful twitch — the burrow's done!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving the Network struct from the dash-network crate into dashcore, which is the primary refactoring objective reflected throughout the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/dash-network

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

🧹 Nitpick comments (1)
dash/src/sml/quorum_entry/quorum_modifier_type.rs (1)

101-113: Return contract is now misleading.

After Line 108, new_quorum_modifier_type has no Err path but still returns Result and documents QuorumValidationError. Please either (a) simplify the return type in a breaking-change window, or (b) keep Result but explicitly document it as compatibility-only and remove the stale error-case docs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash/src/sml/quorum_entry/quorum_modifier_type.rs` around lines 101 - 113,
The function new_quorum_modifier_type currently always returns Ok(...) but its
signature returns Result<LLMQModifierType, QuorumValidationError>, which is
misleading; either (A) make it a simple non-fallible constructor by changing the
signature to return LLMQModifierType and remove any QuorumValidationError
references and stale docs (update callers of new_quorum_modifier_type
accordingly), or (B) preserve the Result for compatibility but change the
doc/comments on new_quorum_modifier_type to explicitly state the Err branch is
compatibility-only (remove stale error-case docs) and keep the implementation
as-is; locate the function and related symbols LLMQModifierType,
QuorumValidationError, work_block_height, and network.core_v20_activation_height
to make the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dash/src/network/constants.rs`:
- Around line 176-186: The FromStr impl for Network must be no-std safe: replace
impl std::str::FromStr for Network with impl core::str::FromStr for Network and
change the associated error type to a new ParseNetworkError enum (e.g., pub enum
ParseNetworkError { UnknownNetwork(&'static str) }) instead of String;
derive/implement Error/Display using thiserror (#[derive(thiserror::Error,
Debug)] with a #[error("Unknown network type: {0}")] variant) or implement
core::fmt::Display manually, then update the impl to return
Err(ParseNetworkError::UnknownNetwork(s)) on the default arm and set type Err =
ParseNetworkError; ensure all references to FromStr import core::str::FromStr
where needed and avoid any heap allocation types so builds work with no-std.

---

Nitpick comments:
In `@dash/src/sml/quorum_entry/quorum_modifier_type.rs`:
- Around line 101-113: The function new_quorum_modifier_type currently always
returns Ok(...) but its signature returns Result<LLMQModifierType,
QuorumValidationError>, which is misleading; either (A) make it a simple
non-fallible constructor by changing the signature to return LLMQModifierType
and remove any QuorumValidationError references and stale docs (update callers
of new_quorum_modifier_type accordingly), or (B) preserve the Result for
compatibility but change the doc/comments on new_quorum_modifier_type to
explicitly state the Err branch is compatibility-only (remove stale error-case
docs) and keep the implementation as-is; locate the function and related symbols
LLMQModifierType, QuorumValidationError, work_block_height, and
network.core_v20_activation_height to make the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4a783cd-72a8-41df-8a32-fe085ed87513

📥 Commits

Reviewing files that changed from the base of the PR and between f74c43e and 2c609ec.

📒 Files selected for processing (43)
  • .codecov.yml
  • .github/ci-groups.yml
  • .github/ci-no-std.yml
  • .github/workflows/sanitizer.yml
  • AGENTS.md
  • CLAUDE.md
  • Cargo.toml
  • README.md
  • dash-network-ffi/Cargo.toml
  • dash-network-ffi/README.md
  • dash-network-ffi/build.rs
  • dash-network-ffi/src/dash_network_ffiFFI.modulemap
  • dash-network-ffi/src/lib.rs
  • dash-network/Cargo.toml
  • dash-network/README.md
  • dash-network/src/lib.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/sync/masternodes/manager.rs
  • dash/Cargo.toml
  • dash/src/address.rs
  • dash/src/blockdata/constants.rs
  • dash/src/blockdata/transaction/mod.rs
  • dash/src/consensus/params.rs
  • dash/src/crypto/key.rs
  • dash/src/crypto/sighash.rs
  • dash/src/lib.rs
  • dash/src/network/constants.rs
  • dash/src/sml/llmq_type/mod.rs
  • dash/src/sml/llmq_type/network.rs
  • dash/src/sml/masternode_list/apply_diff.rs
  • dash/src/sml/masternode_list/from_diff.rs
  • dash/src/sml/masternode_list_engine/mod.rs
  • dash/src/sml/quorum_entry/quorum_modifier_type.rs
  • dash/src/test_utils/address.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/derivation.rs
  • key-wallet/Cargo.toml
  • key-wallet/IMPLEMENTATION_SUMMARY.md
  • key-wallet/src/bip32.rs
  • key-wallet/src/derivation_bls_bip32.rs
  • key-wallet/src/derivation_slip10.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/lib.rs
💤 Files with no reviewable changes (15)
  • .codecov.yml
  • .github/ci-no-std.yml
  • dash-network-ffi/build.rs
  • key-wallet/IMPLEMENTATION_SUMMARY.md
  • dash-network-ffi/README.md
  • dash-spv/src/client/lifecycle.rs
  • .github/ci-groups.yml
  • dash-network-ffi/Cargo.toml
  • dash-network/src/lib.rs
  • dash-spv/src/sync/masternodes/manager.rs
  • key-wallet-ffi/Cargo.toml
  • dash-network-ffi/src/lib.rs
  • dash-network/Cargo.toml
  • dash-network/README.md
  • dash-network-ffi/src/dash_network_ffiFFI.modulemap

Comment on lines +176 to +186
impl std::str::FromStr for Network {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"dash" | "mainnet" => Ok(Network::Dash),
"testnet" | "test" => Ok(Network::Testnet),
"devnet" | "dev" => Ok(Network::Devnet),
"regtest" => Ok(Network::Regtest),
_ => Err(format!("Unknown network type: {}", s)),
}
Copy link
Contributor

@coderabbitai coderabbitai bot Mar 5, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Check for no_std support in lib.rs and project structure
cd dash 2>/dev/null || cd . 
git ls-files | grep -E '(lib\.rs|Cargo\.toml)' | head -20

Repository: dashpay/rust-dashcore

Length of output: 106


🏁 Script executed:

# Verify no-std configuration and check current FromStr implementation
rg -n 'no_std|no-std' --type rust dash/src/lib.rs | head -20

Repository: dashpay/rust-dashcore

Length of output: 353


🏁 Script executed:

# Check the actual FromStr implementation
rg -n -A10 'impl.*FromStr.*for.*Network' dash/src/network/constants.rs

Repository: dashpay/rust-dashcore

Length of output: 546


🏁 Script executed:

# Check if thiserror is already a dependency
rg -n 'thiserror' dash/Cargo.toml

Repository: dashpay/rust-dashcore

Length of output: 83


🏁 Script executed:

# Check the full Network enum definition
rg -n -B5 'enum Network' dash/src/network/constants.rs | head -30

Repository: dashpay/rust-dashcore

Length of output: 329


🏁 Script executed:

# Check how constants.rs is included in the module tree
rg -n 'mod network|mod constants' dash/src/lib.rs

Repository: dashpay/rust-dashcore

Length of output: 85


🏁 Script executed:

# Check if the FromStr impl or Network enum has any cfg guards
rg -n -B10 'impl.*FromStr.*for.*Network' dash/src/network/constants.rs | grep -E 'cfg|impl'

Repository: dashpay/rust-dashcore

Length of output: 105


🏁 Script executed:

# Check if String is used elsewhere in the codebase and if it's guarded
rg -n 'Result.*String' dash/src/network/constants.rs

Repository: dashpay/rust-dashcore

Length of output: 47


🏁 Script executed:

# Verify: does std::str::FromStr actually resolve in no-std?
# Search for any existing use of core::str::FromStr in the codebase
rg -n 'core::str::FromStr|from_str' dash/src/ | head -20

Repository: dashpay/rust-dashcore

Length of output: 1931


🏁 Script executed:

# Check the Cargo.toml to understand feature flags better
cat dash/Cargo.toml | grep -A20 '^\[features\]'

Repository: dashpay/rust-dashcore

Length of output: 900


🏁 Script executed:

# Check if network module or constants have any cfg guards that might prevent compilation
rg -n -B5 'mod network' dash/src/lib.rs

Repository: dashpay/rust-dashcore

Length of output: 173


🏁 Script executed:

# Check network/mod.rs for conditional compilation
cat dash/src/network/mod.rs | head -30

Repository: dashpay/rust-dashcore

Length of output: 899


🏁 Script executed:

# Specifically check if FromStr impl is guarded by cfg
rg -n -B20 'impl std::str::FromStr for Network' dash/src/network/constants.rs | head -30

Repository: dashpay/rust-dashcore

Length of output: 724


🏁 Script executed:

# Verify the issue: try to understand what happens when no_std is enabled
# Check if there's any std::str usage elsewhere that's guarded
rg -n 'std::str::FromStr' dash/src/

Repository: dashpay/rust-dashcore

Length of output: 778


Replace std::str::FromStr with core::str::FromStr and use a typed error enum for no-std compatibility.

The crate supports no-std (feature at line 46 of src/lib.rs), but the Network::FromStr implementation at line 176 uses std::str::FromStr, which is unavailable when std is disabled. Additionally, using String as the error type breaks no-std builds since it requires std allocation. The codebase already uses core::str::FromStr elsewhere (e.g., sign_message.rs:213), and thiserror is available as a dependency.

Create a ParseNetworkError enum and implement core::str::FromStr instead:

Proposed fix
+#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
+pub enum ParseNetworkError {
+    #[error("unknown network type: {0}")]
+    UnknownNetwork(String),
+}
+
+impl core::str::FromStr for Network {
+    type Err = ParseNetworkError;
-impl std::str::FromStr for Network {
-    type Err = String;

     fn from_str(s: &str) -> Result<Self, Self::Err> {
         match s.to_lowercase().as_str() {
             "dash" | "mainnet" => Ok(Network::Dash),
             "testnet" | "test" => Ok(Network::Testnet),
             "devnet" | "dev" => Ok(Network::Devnet),
             "regtest" => Ok(Network::Regtest),
-            _ => Err(format!("Unknown network type: {}", s)),
+            _ => Err(ParseNetworkError::UnknownNetwork(s.to_owned())),
         }
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash/src/network/constants.rs` around lines 176 - 186, The FromStr impl for
Network must be no-std safe: replace impl std::str::FromStr for Network with
impl core::str::FromStr for Network and change the associated error type to a
new ParseNetworkError enum (e.g., pub enum ParseNetworkError {
UnknownNetwork(&'static str) }) instead of String; derive/implement
Error/Display using thiserror (#[derive(thiserror::Error, Debug)] with a
#[error("Unknown network type: {0}")] variant) or implement core::fmt::Display
manually, then update the impl to return
Err(ParseNetworkError::UnknownNetwork(s)) on the default arm and set type Err =
ParseNetworkError; ensure all references to FromStr import core::str::FromStr
where needed and avoid any heap allocation types so builds work with no-std.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

since this is a refactor where i only move code from one crate into another, I dont think we should address this now. A PR standardizing the Error system following Rust standards with thiserror would be more appropriate

Copy link
Contributor

Choose a reason for hiding this comment

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

@ZocoLini, understood — since this is a direct code migration, deferring error system improvements to a dedicated PR makes sense. Would you like me to open a follow-up GitHub issue to track the ParseNetworkError / core::str::FromStr no-std compatibility work for Network in dash/src/network/constants.rs?


✏️ Learnings added
Learnt from: ZocoLini
Repo: dashpay/rust-dashcore PR: 497
File: dash/src/network/constants.rs:176-186
Timestamp: 2026-03-06T17:20:25.174Z
Learning: In the dashpay/rust-dashcore repository, the `FromStr` implementation for `Network` in `dash/src/network/constants.rs` currently uses `std::str::FromStr` with `String` as the error type, which is not no-std compatible. The PR author (ZocoLini) has intentionally deferred fixing this to a separate PR that will standardize the error system using `thiserror` and `core::str::FromStr` across the codebase. Do not flag this as a critical issue in the current refactor PR.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 98.59155% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.99%. Comparing base (f74c43e) to head (1ac4908).

Files with missing lines Patch % Lines
dash/src/network/constants.rs 98.43% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #497      +/-   ##
=============================================
+ Coverage      63.05%   63.99%   +0.94%     
=============================================
  Files            313      313              
  Lines          64878    64914      +36     
=============================================
+ Hits           40907    41540     +633     
+ Misses         23971    23374     -597     
Flag Coverage Δ *Carryforward flag
core 74.93% <98.59%> (+0.03%) ⬆️
dash-network 74.91% <ø> (+0.01%) ⬆️ Carriedforward from f74c43e
dash-network-ffi 34.74% <ø> (ø) Carriedforward from f74c43e
dash-spv 68.18% <ø> (ø) Carriedforward from f74c43e
dash-spv-ffi 34.74% <ø> (ø) Carriedforward from f74c43e
dashcore 74.91% <ø> (+0.01%) ⬆️ Carriedforward from f74c43e
dashcore-private 74.91% <ø> (+0.01%) ⬆️ Carriedforward from f74c43e
dashcore-rpc 19.92% <ø> (ø) Carriedforward from f74c43e
dashcore-rpc-json 19.92% <ø> (ø) Carriedforward from f74c43e
dashcore_hashes 74.91% <ø> (+0.01%) ⬆️ Carriedforward from f74c43e
ffi 33.53% <ø> (-1.22%) ⬇️
key-wallet 65.58% <ø> (ø) Carriedforward from f74c43e
key-wallet-ffi 34.74% <ø> (ø) Carriedforward from f74c43e
key-wallet-manager 65.58% <ø> (ø) Carriedforward from f74c43e
rpc 19.92% <ø> (ø)
spv 68.18% <ø> (ø)
wallet 65.58% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
dash-spv/src/client/lifecycle.rs 55.28% <ø> (ø)
dash-spv/src/sync/masternodes/manager.rs 41.04% <ø> (ø)
dash/src/address.rs 52.95% <ø> (+0.21%) ⬆️
dash/src/blockdata/constants.rs 100.00% <ø> (+0.64%) ⬆️
dash/src/blockdata/transaction/mod.rs 86.15% <ø> (ø)
dash/src/consensus/params.rs 0.00% <ø> (ø)
dash/src/crypto/key.rs 76.33% <ø> (+0.13%) ⬆️
dash/src/crypto/sighash.rs 65.27% <ø> (ø)
dash/src/sml/llmq_type/mod.rs 62.38% <ø> (ø)
dash/src/sml/llmq_type/network.rs 70.29% <ø> (+3.31%) ⬆️
... and 10 more

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@xdustinface xdustinface left a comment

Choose a reason for hiding this comment

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

Makes sense, just few things i noticed. The coverage badge in the readme should be addressed and the renaming can be reverted i guess? Also, left few suggestions for comment changes of the network entries while you move them around.

}

fn v20_activation_height(&self) -> u32 {
pub fn core_v20_activation_height(&self) -> u32 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this renamed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the method was implemented in two places, in daschore was called v20_activation_height and in dash-network was called core_v20_activation_height so I had to pick one. To avoid possible future confusions with platform versions (since it looks like at any moment platform stuff can be added to rust-dashcore) i decided to use the one that make it clear that this v20 activation height method is only meant for core related logic

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this will be relevant for platform. If ever there would probably be a separate network structure for platform in here but i doubt. Especially now that it's in the core crate.

@ZocoLini ZocoLini force-pushed the refactor/dash-network branch from 2c609ec to 1ac4908 Compare March 6, 2026 17:21
@ZocoLini ZocoLini requested a review from xdustinface March 6, 2026 17:21
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.

🧹 Nitpick comments (2)
dash/src/network/constants.rs (2)

155-160: Spell out Network::Devnet | Network::Regtest instead of _.

_ => 0 means any future internal Network variant will silently inherit an activation height of zero. For metadata like this, forcing an explicit arm is safer and keeps new variants from slipping through unnoticed.

♻️ Suggested diff
     pub fn core_v20_activation_height(&self) -> u32 {
         match self {
             Network::Dash => 1_987_776,
             Network::Testnet => 905_100,
             // Devnet and regtest activate V20 immediately
-            _ => 0,
+            Network::Devnet | Network::Regtest => 0,
         }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash/src/network/constants.rs` around lines 155 - 160, Replace the wildcard
match arm in core_v20_activation_height so new Network variants can't silently
get zero; explicitly match Network::Devnet and Network::Regtest instead of using
`_`. Update the match in the core_v20_activation_height method on the Network
enum to use the explicit arm `Network::Devnet | Network::Regtest => 0` (keeping
the existing Dash and Testnet arms) so any future variants will cause a compiler
error until handled.

128-150: Make known_genesis_block_hash static instead of decoding hex on every call.

This path allocates, reverses bytes, and hits expect() twice for fixed network constants. Storing the hashes as fixed [u8; 32] values (or sharing constants with dash/src/blockdata/constants.rs) would keep the method panic-free and remove an easy source of metadata drift.
As per coding guidelines "Avoid unwrap() and expect() in library code; use explicit error types (e.g., thiserror)."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash/src/network/constants.rs` around lines 128 - 150,
known_genesis_block_hash currently decodes hex, reverses and calls expect() on
every invocation causing allocations and panics; instead define static fixed
[u8; 32] constants (already reversed to match internal endianness) for each
network (or reuse the shared constants in dash/src/blockdata/constants.rs) and
have known_genesis_block_hash return Option<BlockHash> constructed from those
arrays without any hex decoding or expect() calls; update the function to
reference these constants (e.g., NETWORK_DASH_GENESIS, NETWORK_TESTNET_GENESIS,
NETWORK_REGTEST_GENESIS) and construct the BlockHash via a non-panicking
constructor or by converting the array directly so the method is allocation-free
and panic-free.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@dash/src/network/constants.rs`:
- Around line 155-160: Replace the wildcard match arm in
core_v20_activation_height so new Network variants can't silently get zero;
explicitly match Network::Devnet and Network::Regtest instead of using `_`.
Update the match in the core_v20_activation_height method on the Network enum to
use the explicit arm `Network::Devnet | Network::Regtest => 0` (keeping the
existing Dash and Testnet arms) so any future variants will cause a compiler
error until handled.
- Around line 128-150: known_genesis_block_hash currently decodes hex, reverses
and calls expect() on every invocation causing allocations and panics; instead
define static fixed [u8; 32] constants (already reversed to match internal
endianness) for each network (or reuse the shared constants in
dash/src/blockdata/constants.rs) and have known_genesis_block_hash return
Option<BlockHash> constructed from those arrays without any hex decoding or
expect() calls; update the function to reference these constants (e.g.,
NETWORK_DASH_GENESIS, NETWORK_TESTNET_GENESIS, NETWORK_REGTEST_GENESIS) and
construct the BlockHash via a non-panicking constructor or by converting the
array directly so the method is allocation-free and panic-free.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c75912c0-fd39-4007-a78c-402053a7ee99

📥 Commits

Reviewing files that changed from the base of the PR and between 2c609ec and 1ac4908.

📒 Files selected for processing (43)
  • .codecov.yml
  • .github/ci-groups.yml
  • .github/ci-no-std.yml
  • .github/workflows/sanitizer.yml
  • AGENTS.md
  • CLAUDE.md
  • Cargo.toml
  • README.md
  • dash-network-ffi/Cargo.toml
  • dash-network-ffi/README.md
  • dash-network-ffi/build.rs
  • dash-network-ffi/src/dash_network_ffiFFI.modulemap
  • dash-network-ffi/src/lib.rs
  • dash-network/Cargo.toml
  • dash-network/README.md
  • dash-network/src/lib.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/sync/masternodes/manager.rs
  • dash/Cargo.toml
  • dash/src/address.rs
  • dash/src/blockdata/constants.rs
  • dash/src/blockdata/transaction/mod.rs
  • dash/src/consensus/params.rs
  • dash/src/crypto/key.rs
  • dash/src/crypto/sighash.rs
  • dash/src/lib.rs
  • dash/src/network/constants.rs
  • dash/src/sml/llmq_type/mod.rs
  • dash/src/sml/llmq_type/network.rs
  • dash/src/sml/masternode_list/apply_diff.rs
  • dash/src/sml/masternode_list/from_diff.rs
  • dash/src/sml/masternode_list_engine/mod.rs
  • dash/src/sml/quorum_entry/quorum_modifier_type.rs
  • dash/src/test_utils/address.rs
  • key-wallet-ffi/Cargo.toml
  • key-wallet-ffi/src/derivation.rs
  • key-wallet/Cargo.toml
  • key-wallet/IMPLEMENTATION_SUMMARY.md
  • key-wallet/src/bip32.rs
  • key-wallet/src/derivation_bls_bip32.rs
  • key-wallet/src/derivation_slip10.rs
  • key-wallet/src/dip9.rs
  • key-wallet/src/lib.rs
💤 Files with no reviewable changes (15)
  • dash-spv/src/sync/masternodes/manager.rs
  • dash-network-ffi/README.md
  • key-wallet/IMPLEMENTATION_SUMMARY.md
  • dash-network-ffi/build.rs
  • .github/ci-no-std.yml
  • dash-network-ffi/src/lib.rs
  • key-wallet-ffi/Cargo.toml
  • .github/ci-groups.yml
  • dash-spv/src/client/lifecycle.rs
  • dash-network-ffi/src/dash_network_ffiFFI.modulemap
  • .codecov.yml
  • dash-network/Cargo.toml
  • dash-network/src/lib.rs
  • dash-network-ffi/Cargo.toml
  • dash-network/README.md
✅ Files skipped from review due to trivial changes (1)
  • AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (14)
  • key-wallet/src/bip32.rs
  • dash/src/sml/masternode_list/apply_diff.rs
  • dash/src/sml/quorum_entry/quorum_modifier_type.rs
  • dash/src/blockdata/transaction/mod.rs
  • dash/Cargo.toml
  • dash/src/crypto/key.rs
  • dash/src/sml/masternode_list_engine/mod.rs
  • .github/workflows/sanitizer.yml
  • key-wallet/src/derivation_slip10.rs
  • dash/src/sml/llmq_type/mod.rs
  • dash/src/sml/llmq_type/network.rs
  • dash/src/test_utils/address.rs
  • dash/src/consensus/params.rs
  • README.md

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