Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/strict-checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"strict_check_crates": [
"key-wallet",
"key-wallet-manager",
"key-wallet-ffi"
],
Comment on lines +2 to +6
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify crate names map 1:1 to package.name across the workspace; consider adding a schema_version and sorting lists

  • Action: Validate that "key-wallet", "key-wallet-manager", and "key-wallet-ffi" exactly match the package.name entries in their Cargo.toml files. Hyphens vs underscores can bite here at CI time.
  • Nit: Add a schema_version and keep lists alphabetized to minimize churn in diffs and avoid tooling ambiguity.

Run this script from repo root to verify names and detect overlaps/missing entries:

If you want, I can wire a small CI step to consume this JSON and feed cargo clippy invocations accordingly.

Apply this diff to add a schema_version and alphabetize entries:

 {
+  "schema_version": 1,
   "strict_check_crates": [
-    "key-wallet",
-    "key-wallet-manager",
-    "key-wallet-ffi"
+    "key-wallet",
+    "key-wallet-ffi",
+    "key-wallet-manager"
   ],
   "excluded_crates": [
-    "dash",
-    "dash-network",
-    "dash-network-ffi",
-    "hashes",
-    "internals",
-    "fuzz",
-    "rpc-client",
-    "rpc-json",
-    "rpc-integration-test",
-    "dash-spv",
-    "dash-spv-ffi",
-    "test-utils"
+    "dash",
+    "dash-network",
+    "dash-network-ffi",
+    "dash-spv",
+    "dash-spv-ffi",
+    "fuzz",
+    "hashes",
+    "internals",
+    "rpc-client",
+    "rpc-integration-test",
+    "rpc-json",
+    "test-utils"
   ],
   "comment": "Crates in strict_check_crates will fail CI on any warnings or clippy issues. Add or remove crates as needed."
 }

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
import json, os, sys
import tomllib

with open(".github/strict-checks.json","rb") as f:
    cfg = json.load(f)

strict = set(cfg.get("strict_check_crates", []))
excluded = set(cfg.get("excluded_crates", []))

crate_names = set()
for root, dirs, files in os.walk("."):
    if any(seg in root for seg in (".git", "target")):
        continue
    if "Cargo.toml" in files:
        p = os.path.join(root, "Cargo.toml")
        try:
            with open(p,"rb") as tf:
                data = tomllib.load(tf)
            pkg = data.get("package", {}).get("name")
            if pkg:
                crate_names.add(pkg)
        except Exception as e:
            print(f"WARN: Failed to parse {p}: {e}", file=sys.stderr)

missing_strict = sorted(strict - crate_names)
missing_excl = sorted(excluded - crate_names)
overlap = sorted(strict & excluded)
unlisted = sorted(crate_names - (strict | excluded))

print("Crates discovered:", sorted(crate_names))
print("Missing in workspace (strict):", missing_strict)
print("Missing in workspace (excluded):", missing_excl)
print("Overlap (both strict and excluded):", overlap)
print("Unlisted crates (neither strict nor excluded):", unlisted)

if overlap:
    sys.exit(2)
PY

echo
echo "Searching workflows referencing this config..."
rg -n --glob '.github/workflows/*.yml' 'strict-checks\.json|strict_check_crates|excluded_crates' -C2 || {
  echo "No workflow references found. Ensure CI reads and uses this config." >&2
}

Length of output: 1318


Update .github/strict-checks.json to match actual crates and wire into CI

  • Verified that all entries under strict_check_crates exactly match package.name in their Cargo.toml (no missing crates).
  • The excluded_crates list contains eight names that no longer exist in the workspace and must be removed or renamed:
    • dash
    • fuzz
    • hashes
    • internals
    • rpc-client
    • rpc-integration-test
    • rpc-json
    • test-utils
  • The following crates are present in the repo but not listed under either strict_check_crates or excluded_crates. Decide whether each should be strictly checked or explicitly excluded:
    • dash-fuzz
    • dashcore
    • dashcore-private
    • dashcore-rpc
    • dashcore-rpc-json
    • dashcore-test-utils
    • dashcore_hashes
    • dashcore_hashes-fuzz
    • embedded
    • integration_test
    • schemars
  • No workflows in .github/workflows/*.yml reference this config, so CI will not actually enforce these rules. Add a step to load and use this JSON in your lint/test pipeline.

Proposed patch—adds a schema_version, removes obsolete names, alphabetizes lists, and highlights where to wire into CI:

 .github/strict-checks.json
 {
+  "schema_version": 1,
   "strict_check_crates": [
-    "key-wallet",
-    "key-wallet-ffi",
-    "key-wallet-manager"
+    "key-wallet",
+    "key-wallet-ffi",
+    "key-wallet-manager"
   ],
   "excluded_crates": [
-    "dash",
-    "dash-network",
-    "dash-network-ffi",
-    "dash-spv",
-    "dash-spv-ffi",
-    "fuzz",
-    "hashes",
-    "internals",
-    "rpc-client",
-    "rpc-integration-test",
-    "rpc-json",
-    "test-utils"
+    "dash-network",
+    "dash-network-ffi",
+    "dash-spv",
+    "dash-spv-ffi"
   ],
   "comment": "Crates in strict_check_crates will fail CI on any warnings or clippy issues. Add or remove crates as needed."
 }

• Remove the eight missing/ex-obsolete crate names from excluded_crates.
• Decide and add the eleven “unlisted” crates under the appropriate list.
• Alphabetize both arrays to reduce churn.
• Add a CI job (e.g. in .github/workflows/ci.yml) that reads this JSON and feeds its lists into your cargo clippy/cargo test matrix.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"strict_check_crates": [
"key-wallet",
"key-wallet-manager",
"key-wallet-ffi"
],
.github/strict-checks.json
{
"schema_version": 1,
"strict_check_crates": [
"key-wallet",
"key-wallet-ffi",
"key-wallet-manager"
],
"excluded_crates": [
"dash-network",
"dash-network-ffi",
"dash-spv",
"dash-spv-ffi"
],
"comment": "Crates in strict_check_crates will fail CI on any warnings or clippy issues. Add or remove crates as needed."
}
🤖 Prompt for AI Agents
In .github/strict-checks.json around lines 2-6, remove the eight obsolete crate
names from "excluded_crates", add a "schema_version" field, and update both
arrays to include the unlisted crates: add library/runtime crates to
"strict_check_crates" (dashcore, dashcore-private, dashcore_hashes,
dashcore-rpc, schemars, embedded) and add fuzz/tests/tools/integration crates to
"excluded_crates" (dash-fuzz, dashcore-rpc-json, dashcore-test-utils,
dashcore_hashes-fuzz, dashcore-test-utils, integration_test, dashcore-rpc-json —
ensure no duplicates and use the exact package.name values), alphabetize both
arrays to reduce churn, and finally add a CI job (e.g., in
.github/workflows/ci.yml) that reads this JSON, uses its lists to generate the
cargo clippy/test matrix, and fails if a crate listed under strict_check_crates
violates strict checks.

"excluded_crates": [
"dash",
"dash-network",
"dash-network-ffi",
"hashes",
"internals",
"fuzz",
"rpc-client",
"rpc-json",
"rpc-integration-test",
"dash-spv",
"dash-spv-ffi",
"test-utils"
],
"comment": "Crates in strict_check_crates will fail CI on any warnings or clippy issues. Add or remove crates as needed."
}
24 changes: 13 additions & 11 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ on:
- 'test-ci/**'
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
fuzz:
if: ${{ !github.event.act }}
Expand Down Expand Up @@ -40,19 +47,14 @@ jobs:
- name: Install test dependencies
run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache-fuzz
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
path: |
~/.cargo/bin
fuzz/target
target
key: cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
toolchain: 1.89
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
with:
toolchain: 1.85
override: true
profile: minimal
workspaces: "fuzz -> target"
- name: fuzz
run: cd fuzz && ./fuzz.sh "${{ matrix.fuzz_target }}"
- run: echo "${{ matrix.fuzz_target }}" >executed_${{ matrix.fuzz_target }}
Expand Down
150 changes: 131 additions & 19 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ on: [push, pull_request]

name: Continuous integration

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Tests:
name: Tests
Expand All @@ -26,21 +33,130 @@ jobs:
AS_DEPENDENCY: true
DO_NO_STD: false
DO_DOCS: true
- rust: 1.85.0
- rust: 1.89.0
env:
AS_DEPENDENCY: true
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Running test script
env: ${{ matrix.env }}
run: ./contrib/test.sh

workspace-tests:
name: Workspace Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable, beta, nightly, 1.89.0]
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Run workspace tests
run: cargo test --workspace --all-features
- name: Run workspace tests (no default features)
run: cargo test --workspace --no-default-features
- name: Build workspace (release mode)
run: cargo build --workspace --release

clippy:
name: Clippy (Non-strict)
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Run clippy (excluding strict-checked crates)
run: |
# Auto-discover all workspace crates and exclude strict-checked ones
STRICT_CRATES=("key-wallet" "key-wallet-manager" "key-wallet-ffi")
mapfile -t ALL_CRATES < <(cargo metadata --no-deps --format-version=1 | jq -r '.packages[].name' | sort -u)
for crate in "${ALL_CRATES[@]}"; do
if printf '%s\n' "${STRICT_CRATES[@]}" | grep -qx "$crate"; then
continue
fi
echo "Checking $crate (warnings allowed)..."
cargo clippy -p "$crate" --all-features --all-targets || true
done

strict-checks:
name: Strict Warnings and Clippy Checks
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2

# Check key-wallet with strict warnings
- name: Check key-wallet (deny warnings)
env:
RUSTFLAGS: "-D warnings"
run: |
cargo check -p key-wallet --all-features --lib --bins --tests
cargo build -p key-wallet --all-features --lib --bins
cargo test -p key-wallet --all-features --lib --bins

- name: Clippy key-wallet (deny all warnings)
run: cargo clippy -p key-wallet --all-features --lib --bins --tests -- -D warnings

# Check key-wallet-manager with strict warnings
- name: Check key-wallet-manager (deny warnings)
env:
RUSTFLAGS: "-D warnings"
run: |
cargo check -p key-wallet-manager --all-features --lib --bins --tests
cargo build -p key-wallet-manager --all-features --lib --bins
cargo test -p key-wallet-manager --all-features --lib --bins

- name: Clippy key-wallet-manager (deny all warnings)
run: cargo clippy -p key-wallet-manager --all-features --lib --bins --tests -- -D warnings

# Check key-wallet-ffi with strict warnings
- name: Check key-wallet-ffi (deny warnings)
env:
RUSTFLAGS: "-D warnings"
run: |
cargo check -p key-wallet-ffi --all-features --lib --bins --tests
cargo build -p key-wallet-ffi --all-features --lib --bins
cargo test -p key-wallet-ffi --all-features --lib --bins

- name: Clippy key-wallet-ffi (deny all warnings)
run: cargo clippy -p key-wallet-ffi --all-features --lib --bins --tests -- -D warnings

fmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check

# TODO: need to support compiling rust-x11-hash under s390x
# Cross:
Expand All @@ -49,9 +165,9 @@ jobs:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Crate
# uses: actions/checkout@v2
# uses: actions/checkout@v4
# - name: Checkout Toolchain
# uses: actions-rs/toolchain@v1
# uses: dtolnay/rust-toolchain@stable
# with:
# profile: minimal
# toolchain: stable
Expand Down Expand Up @@ -88,7 +204,7 @@ jobs:
# run: cd hashes/embedded && cargo run --target thumbv7m-none-eabi --features=alloc

rpc-tests:
name: Tests
name: RPC Tests
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -99,18 +215,16 @@ jobs:
- rust: nightly
env:
RUSTFMTCHK: false
- rust: 1.85.0
- rust: 1.89.0
env:
PIN_VERSIONS: true
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Running test script
env: ${{ matrix.env }}
run: ./contrib/test.sh
Expand All @@ -133,13 +247,11 @@ jobs:
]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Running test script
env:
BITCOINVERSION: ${{ matrix.bitcoinversion }}
Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ rust-dashcore is a Rust implementation of the Dash cryptocurrency protocol libra

### Network & SPV
- `dash-network/` - Network protocol abstractions
- `dash-network-ffi/` - Network FFI bindings using UniFFI
- `dash-network-ffi/` - C-compatible FFI bindings for network types
- `dash-spv/` - SPV client implementation
- `dash-spv-ffi/` - C-compatible FFI bindings for SPV client

### Wallet & Keys
- `key-wallet/` - HD wallet implementation
- `key-wallet-ffi/` - FFI bindings for wallet functionality
- `key-wallet-ffi/` - C-compatible FFI bindings for wallet functionality

### RPC & Integration
- `rpc-client/` - JSON-RPC client for Dash Core nodes
Expand Down
7 changes: 0 additions & 7 deletions dash-network-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ readme = "README.md"

[dependencies]
dash-network = { path = "../dash-network", default-features = false }
uniffi = { version = "0.29.3", features = ["cli"] }
thiserror = "2.0.12"

[build-dependencies]
uniffi = { version = "0.29.3", features = ["build"] }

[dev-dependencies]
hex = "0.4"

[lib]
crate-type = ["cdylib", "staticlib"]
name = "dash_network_ffi"

[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
14 changes: 2 additions & 12 deletions dash-network-ffi/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# dash-network-ffi

FFI bindings for the dash-network crate, providing language bindings via UniFFI.
FFI bindings for the dash-network crate, providing C-compatible language bindings.

## Overview

This crate provides Foreign Function Interface (FFI) bindings for the `dash-network` types, allowing them to be used from other programming languages like Swift, Python, Kotlin, and Ruby.

## Features

- UniFFI-based bindings for the Network enum
- C-compatible FFI bindings for the Network enum
- Network information and utilities exposed through FFI
- Support for magic bytes operations
- Core version activation queries
Expand All @@ -21,16 +21,6 @@ This crate provides Foreign Function Interface (FFI) bindings for the `dash-netw
cargo build --release
```

### Generating Bindings

To generate bindings for your target language:

```bash
cargo run --bin uniffi-bindgen generate src/dash_network.udl --language swift
cargo run --bin uniffi-bindgen generate src/dash_network.udl --language python
cargo run --bin uniffi-bindgen generate src/dash_network.udl --language kotlin
```

### Example Usage (Swift)

```swift
Expand Down
3 changes: 2 additions & 1 deletion dash-network-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fn main() {
uniffi::generate_scaffolding("src/dash_network.udl").unwrap();
// Build script for dash-network-ffi
// Standard FFI compilation without uniffi
}
41 changes: 0 additions & 41 deletions dash-network-ffi/src/dash_network.udl

This file was deleted.

Loading
Loading