Skip to content

Commit 547b356

Browse files
refactor: clean dash core and hashes for warnings and clippy (#109)
* clean up * fixed warnings * more fixes * fixed clippy warnings * last warnings * added dashcore and dashcore hashes to strict checking * fixes * fixes * fixes * fixes * more cleanup * cleanup * more work * more work * more work * work
1 parent 45b5272 commit 547b356

File tree

92 files changed

+832
-3431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+832
-3431
lines changed

.github/strict-checks.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"strict_check_crates": [
33
"key-wallet",
44
"key-wallet-manager",
5-
"key-wallet-ffi"
5+
"key-wallet-ffi",
6+
"dash",
7+
"hashes"
68
],
79
"excluded_crates": [
8-
"dash",
910
"dash-network",
1011
"dash-network-ffi",
11-
"hashes",
1212
"internals",
1313
"fuzz",
1414
"rpc-client",

.github/workflows/rust.yml

Lines changed: 103 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
on: [push, pull_request]
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- 'v**-dev'
6+
pull_request:
27

38
name: Continuous integration
49

@@ -10,65 +15,58 @@ concurrency:
1015
cancel-in-progress: true
1116

1217
jobs:
13-
Tests:
14-
name: Tests
18+
spv_tests:
19+
name: SPV Components Tests
1520
runs-on: ubuntu-latest
16-
strategy:
17-
fail-fast: false
18-
matrix:
19-
include:
20-
- rust: stable
21-
env:
22-
DO_COV: true
23-
AS_DEPENDENCY: true
24-
DO_NO_STD: false
25-
- rust: beta
26-
env:
27-
AS_DEPENDENCY: true
28-
DO_NO_STD: false
29-
- rust: nightly
30-
env:
31-
# TODO: running with DO_BENCH: true causes the test to fail
32-
# DO_BENCH: true
33-
AS_DEPENDENCY: true
34-
DO_NO_STD: false
35-
DO_DOCS: true
36-
- rust: 1.89.0
37-
env:
38-
AS_DEPENDENCY: true
3921
steps:
4022
- name: Checkout Crate
4123
uses: actions/checkout@v4
4224
- name: Setup Rust toolchain
4325
uses: dtolnay/rust-toolchain@stable
44-
with:
45-
toolchain: ${{ matrix.rust }}
46-
- name: Running test script
47-
env: ${{ matrix.env }}
48-
run: ./contrib/test.sh
26+
- name: Cache cargo dependencies
27+
uses: Swatinem/rust-cache@v2
28+
- name: Test dash-spv crate
29+
run: cargo test -p dash-spv --all-features
30+
- name: Test dash-spv-ffi crate
31+
run: cargo test -p dash-spv-ffi --all-features
4932

50-
workspace-tests:
51-
name: Workspace Tests
33+
key_wallet_tests:
34+
name: Key Wallet Components Tests
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout Crate
38+
uses: actions/checkout@v4
39+
- name: Setup Rust toolchain
40+
uses: dtolnay/rust-toolchain@stable
41+
- name: Cache cargo dependencies
42+
uses: Swatinem/rust-cache@v2
43+
- name: Test key-wallet crate
44+
run: cargo test -p key-wallet --all-features
45+
- name: Test key-wallet-manager crate
46+
run: cargo test -p key-wallet-manager --all-features
47+
- name: Test key-wallet-ffi crate
48+
run: cargo test -p key-wallet-ffi --all-features
49+
50+
core_components_tests:
51+
name: Core Components Tests
5252
runs-on: ubuntu-latest
53-
strategy:
54-
fail-fast: false
55-
matrix:
56-
rust: [stable, beta, nightly, 1.89.0]
5753
steps:
5854
- name: Checkout Crate
5955
uses: actions/checkout@v4
6056
- name: Setup Rust toolchain
6157
uses: dtolnay/rust-toolchain@stable
62-
with:
63-
toolchain: ${{ matrix.rust }}
6458
- name: Cache cargo dependencies
6559
uses: Swatinem/rust-cache@v2
66-
- name: Run workspace tests
67-
run: cargo test --workspace --all-features
68-
- name: Run workspace tests (no default features)
69-
run: cargo test --workspace --no-default-features
70-
- name: Build workspace (release mode)
71-
run: cargo build --workspace --release
60+
- name: Test dashcore crate
61+
run: cargo test -p dashcore --all-features
62+
- name: Test dashcore_hashes crate
63+
run: cargo test -p dashcore_hashes --all-features
64+
- name: Test dash-network crate
65+
run: cargo test -p dash-network --all-features
66+
- name: Test internals crate
67+
run: cargo test -p dashcore-private --all-features
68+
- name: Run script-based tests
69+
run: ./contrib/test.sh
7270

7371
clippy:
7472
name: Clippy (Non-strict)
@@ -79,19 +77,18 @@ jobs:
7977
- name: Setup Rust toolchain
8078
uses: dtolnay/rust-toolchain@stable
8179
with:
82-
toolchain: stable
8380
components: clippy
8481
- name: Run clippy (excluding strict-checked crates)
8582
run: |
8683
# Auto-discover all workspace crates and exclude strict-checked ones
87-
STRICT_CRATES=("key-wallet" "key-wallet-manager" "key-wallet-ffi")
84+
STRICT_CRATES=("key-wallet" "key-wallet-manager" "key-wallet-ffi" "dashcore_hashes" "dashcore")
8885
mapfile -t ALL_CRATES < <(cargo metadata --no-deps --format-version=1 | jq -r '.packages[].name' | sort -u)
8986
for crate in "${ALL_CRATES[@]}"; do
9087
if printf '%s\n' "${STRICT_CRATES[@]}" | grep -qx "$crate"; then
9188
continue
9289
fi
93-
echo "Checking $crate (warnings allowed)..."
94-
cargo clippy -p "$crate" --all-features --all-targets || true
90+
echo "Checking $crate (warnings allowed, errors will fail)..."
91+
cargo clippy -p "$crate" --all-features --all-targets -- -W warnings
9592
done
9693
9794
strict-checks:
@@ -103,7 +100,6 @@ jobs:
103100
- name: Setup Rust toolchain
104101
uses: dtolnay/rust-toolchain@stable
105102
with:
106-
toolchain: stable
107103
components: clippy
108104
- name: Cache cargo dependencies
109105
uses: Swatinem/rust-cache@v2
@@ -143,6 +139,30 @@ jobs:
143139
144140
- name: Clippy key-wallet-ffi (deny all warnings)
145141
run: cargo clippy -p key-wallet-ffi --all-features --lib --bins --tests -- -D warnings
142+
143+
# Check dashcore with strict warnings
144+
- name: Check dashcore (deny warnings)
145+
env:
146+
RUSTFLAGS: "-D warnings"
147+
run: |
148+
cargo check -p dashcore --all-features --lib --bins --tests
149+
cargo build -p dashcore --all-features --lib --bins
150+
cargo test -p dashcore --all-features --lib --bins
151+
152+
- name: Clippy dashcore (deny all warnings)
153+
run: cargo clippy -p dashcore --all-features --lib --bins --tests -- -D warnings
154+
155+
# Check dashcore_hashes with strict warnings
156+
- name: Check dashcore_hashes (deny warnings)
157+
env:
158+
RUSTFLAGS: "-D warnings"
159+
run: |
160+
cargo check -p dashcore_hashes --all-features --lib --bins --tests
161+
cargo build -p dashcore_hashes --all-features --lib --bins
162+
cargo test -p dashcore_hashes --all-features --lib --bins
163+
164+
- name: Clippy dashcore_hashes (deny all warnings)
165+
run: cargo clippy -p dashcore_hashes --all-features --lib --bins --tests -- -D warnings
146166

147167
fmt:
148168
name: Format
@@ -153,106 +173,41 @@ jobs:
153173
- name: Setup Rust toolchain
154174
uses: dtolnay/rust-toolchain@stable
155175
with:
156-
toolchain: stable
157176
components: rustfmt
158177
- name: Check formatting
159178
run: cargo fmt --all -- --check
160179

161-
# TODO: need to support compiling rust-x11-hash under s390x
162-
# Cross:
163-
# name: Cross testing
164-
# if: ${{ !github.event.act }}
165-
# runs-on: ubuntu-latest
166-
# steps:
167-
# - name: Checkout Crate
168-
# uses: actions/checkout@v4
169-
# - name: Checkout Toolchain
170-
# uses: dtolnay/rust-toolchain@stable
171-
# with:
172-
# profile: minimal
173-
# toolchain: stable
174-
# override: true
175-
# - name: Install target
176-
# run: rustup target add s390x-unknown-linux-gnu
177-
# - name: install cross
178-
# run: cargo install cross
179-
# - name: run cross test
180-
# run: cross test --target s390x-unknown-linux-gnu
181-
182-
# TODO: need to fix the ability to run the embedded tests
183-
# Embedded:
184-
# runs-on: ubuntu-latest
185-
# env:
186-
# RUSTFLAGS: "-C link-arg=-Tlink.x"
187-
# CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER: "qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel"
188-
# steps:
189-
# - name: Checkout
190-
# uses: actions/checkout@v3
191-
# - name: Set up QEMU
192-
# run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi
193-
# - name: Checkout Toolchain
194-
# uses: dtolnay/rust-toolchain@nightly
195-
# with:
196-
# targets: thumbv7m-none-eabi
197-
# - name: Install src
198-
# run: rustup component add rust-src
199-
# - name: Run dash/embedded
200-
# run: cd dash/embedded && cargo run --target thumbv7m-none-eabi
201-
# - name: Run hashes/embedded no alloc
202-
# run: cd hashes/embedded && cargo run --target thumbv7m-none-eabi
203-
# - name: Run hashes/embedded with alloc
204-
# run: cd hashes/embedded && cargo run --target thumbv7m-none-eabi --features=alloc
205-
206-
rpc-tests:
207-
name: RPC Tests
208-
runs-on: ubuntu-latest
209-
strategy:
210-
matrix:
211-
include:
212-
- rust: stable
213-
env:
214-
RUSTFMTCHK: true
215-
- rust: nightly
216-
env:
217-
RUSTFMTCHK: false
218-
- rust: 1.89.0
219-
env:
220-
PIN_VERSIONS: true
221-
steps:
222-
- name: Checkout Crate
223-
uses: actions/checkout@v4
224-
- name: Setup Rust toolchain
225-
uses: dtolnay/rust-toolchain@stable
226-
with:
227-
toolchain: ${{ matrix.rust }}
228-
- name: Running test script
229-
env: ${{ matrix.env }}
230-
run: ./contrib/test.sh
180+
rpc_tests:
181+
name: RPC Tests
182+
runs-on: ubuntu-latest
183+
strategy:
184+
matrix:
185+
include:
186+
- rust: stable
187+
env:
188+
PIN_VERSIONS: true
189+
steps:
190+
- name: Checkout Crate
191+
uses: actions/checkout@v4
192+
- name: Setup Rust toolchain
193+
uses: dtolnay/rust-toolchain@stable
194+
- name: Running test script
195+
env: ${{ matrix.env }}
196+
run: ./contrib/test.sh
231197

232-
integrations-tests:
233-
name: Integration Tests
234-
runs-on: ubuntu-latest
235-
strategy:
236-
matrix:
237-
rust: [stable]
238-
bitcoinversion:
239-
[
240-
"0.18.0",
241-
"0.18.1",
242-
"0.19.0.1",
243-
"0.19.1",
244-
"0.20.0",
245-
"0.20.1",
246-
"0.21.0",
247-
]
248-
steps:
249-
- name: Checkout Crate
250-
uses: actions/checkout@v4
251-
- name: Setup Rust toolchain
252-
uses: dtolnay/rust-toolchain@stable
253-
with:
254-
toolchain: ${{ matrix.rust }}
255-
- name: Running test script
256-
env:
257-
BITCOINVERSION: ${{ matrix.bitcoinversion }}
258-
run: ./contrib/test-rpc.sh
198+
integrations_tests:
199+
name: Integration Tests
200+
runs-on: ubuntu-latest
201+
strategy:
202+
matrix:
203+
rust: [stable]
204+
dashversion: ["22.0.0", "22.1.3"]
205+
steps:
206+
- name: Checkout Crate
207+
uses: actions/checkout@v4
208+
- name: Setup Rust toolchain
209+
uses: dtolnay/rust-toolchain@stable
210+
- name: Running test script
211+
env:
212+
DASHVERSION: ${{ matrix.dashversion }}
213+
run: ./contrib/test-rpc.sh

Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ resolver = "2"
55
[workspace.package]
66
version = "0.39.6"
77

8-
[patch.crates-io.dashcore_hashes]
9-
path = "hashes"
8+
[patch.crates-io]
9+
dashcore_hashes = { path = "hashes" }
10+
# Use fixed version of elliptic-curve-tools with DefaultIsZeroes trait bound
11+
elliptic-curve-tools = { git = "https://github.com/QuantumExplorer/elliptic-curve-tools", branch = "fix/DefaultIsZeroesToSumOfProducts" }
12+
13+
[profile.release]
14+
# Default to unwinding for most crates
15+
16+
[profile.dev]
17+
# Default to unwinding for most crates
1018

0 commit comments

Comments
 (0)