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
111 changes: 111 additions & 0 deletions .github/workflows/build_msrv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: MSRV (1.85)

on:
push:
branches: [develop]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-24.04

steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.85.0

- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: 24

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version-file: pyproject.toml

- name: Install Python dependencies
run: pip install ".[dev]"

- name: Install CodeQL
id: setup-codeql
uses: github/codeql-action/setup-codeql@v4.36.2
with:
tools: linked

- name: Setup CodeQL
run: echo "$(dirname '${{ steps.setup-codeql.outputs.codeql-path }}')" >> "$GITHUB_PATH"

- name: Restore cargo registry
uses: actions/cache/restore@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-

- name: Restore CodeQL caches
id: codeql-cache
uses: actions/cache/restore@v5
with:
path: |
contrib/codeql/.cache
~/.codeql
key: codeql-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pkgs/**/*.rs', 'contrib/codeql/**/*.ql', 'contrib/codeql/**/*.qll', 'Cargo.lock') }}

- name: Run linters
run: python3 contrib/lint/all_lint.py

- name: Save CodeQL caches
if: success() && steps.codeql-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
contrib/codeql/.cache
~/.codeql
key: codeql-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pkgs/**/*.rs', 'contrib/codeql/**/*.ql', 'contrib/codeql/**/*.qll', 'Cargo.lock') }}

- name: Check PR commit messages
if: github.event_name == 'pull_request'
run: >
python3 contrib/lint/lint_unconv.py
-r "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"

build:
name: Build and test
runs-on: ubuntu-24.04

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.85.0

- name: Restore cargo registry
uses: actions/cache/restore@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-

- name: Build workspace
run: cargo build --workspace --features full,_internal

- name: Test workspace
run: cargo test --workspace --features full,_internal
6 changes: 3 additions & 3 deletions .github/workflows/build_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-deps-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-${{ runner.os }}-${{ runner.arch }}-
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-

- name: Restore build artifacts
uses: actions/cache@v5
Expand Down Expand Up @@ -96,4 +96,4 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-deps-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock') }}
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
36 changes: 4 additions & 32 deletions .github/workflows/build_stable.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build on MSRV and stable
name: Build on stable

on:
workflow_call:
Expand All @@ -21,34 +21,6 @@ permissions:
contents: read

jobs:
msrv:
name: ubuntu-24.04-arm (MSRV)
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.85.0

- name: Restore cargo registry
uses: actions/cache/restore@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-deps-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-${{ runner.os }}-${{ runner.arch }}-

- name: Build package
run: cargo build -p ${{ inputs.package }} --features ${{ inputs.features }}

- name: Test package
run: cargo test -p ${{ inputs.package }} --features ${{ inputs.features }}

stable:
strategy:
fail-fast: false
Expand Down Expand Up @@ -79,8 +51,8 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-deps-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-${{ runner.os }}-${{ runner.arch }}-
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-

- name: Restore build artifacts
uses: actions/cache@v5
Expand All @@ -103,4 +75,4 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-deps-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock') }}
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
46 changes: 0 additions & 46 deletions .github/workflows/lint_all.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/pr_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Comment on PRs

on:
push:
branches: [develop]
pull_request_target:
types: [synchronize, opened, reopened, closed]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Tag PRs

on:
push:
branches: [develop]
pull_request_target:
types: [synchronize, opened, reopened]
schedule:
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The full guide is at [`docs/guide_rust.md`](./docs/guide_rust.md). Key points:
- **Naming**: `UpperCamelCase` for types/traits/enum variants, `snake_case` for functions/variables/modules,
`SCREAMING_SNAKE_CASE` for constants. Acronyms as words (`TxId` not `TXID`). Getters omit `get_` prefix.
- **Type safety**: newtypes over primitives when semantics differ, enums over booleans, make invalid states
unrepresentable. Derive `Clone`, `Debug`, `PartialEq`, `Eq`, `Hash`, `Default` eagerly.
unrepresentable. Derive `Clone`, `Debug`, `PartialEq`, `Eq`, `Hash` eagerly.

@coderabbitai coderabbitai Bot Jun 5, 2026

Copy link
Copy Markdown

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:

#!/bin/bash
# Description: Find all derive attributes that include Default

rg -nP --type=rust 'derive\([^)]*\bDefault\b[^)]*\)' pkgs/

Repository: dashpay/base-sdk

Length of output: 886


Fix mismatch between CLAUDE.md “eager traits” guidance and the repo’s Default derives

The current guideline snippet shows eagerly deriving Clone, Debug, PartialEq, Eq, Hash (no Default), but there are many existing Default derives across pkgs/:

  • pkgs/types/src/uint.rs:34
  • pkgs/primitives/src/validation.rs:59
  • pkgs/primitives/src/script.rs:19
  • pkgs/primitives/src/block_header.rs:17
  • pkgs/script/src/key_id.rs:14
  • pkgs/p2p_core/src/primitives/service_flags.rs:15
  • pkgs/num/src/compact.rs:16,20
  • pkgs/num/src/arith256.rs:22

Align the intended policy: either remove Default derives where appropriate in this PR/follow-up, or update CLAUDE.md to reflect whether Default is meant to be eagerly derived (and list any explicit exceptions).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CLAUDE.md` at line 12, The CLAUDE.md "eager traits" guidance currently omits
Default but the codebase eagerly derives Default on several types (e.g.
types::uint, primitives::validation, primitives::script,
primitives::block_header, script::key_id, p2p_core::service_flags, num::compact,
num::arith256); fix by choosing one of two actions and applying it consistently:
either (A) update CLAUDE.md to explicitly include Default as an eagerly-derived
trait and list any intentional exceptions, or (B) remove the unnecessary
#[derive(Default)] from the noted types (or their structs/enums) so the docs and
code match; ensure the change references the specific types above and update the
CLAUDE.md wording to reflect the decided policy and any exceptions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We don't prohibit deriving Default, we just don't enforce it in linting.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@kwvg, understood — Default derivation is permitted but not mandated by the linter, so the CLAUDE.md guidance correctly reflects only what is enforced. I've noted this for future reviews.


✏️ Learnings added
Learnt from: kwvg
Repo: dashpay/base-sdk PR: 5
File: CLAUDE.md:12-12
Timestamp: 2026-06-06T06:09:25.351Z
Learning: In `dashpay/base-sdk`, deriving `Default` on types is allowed but not enforced by linting. The "eager derives" list in `CLAUDE.md` (Clone, Debug, PartialEq, Eq, Hash) reflects only what the linter *requires*, not what is *prohibited*. Types may still derive `Default` at the developer's discretion without violating project policy.

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.

- **Error handling**: never `.unwrap()` or `.expect()` in library code. Propagate with `?`. Domain error enums implement
`Display`. Lowercase messages without trailing punctuation. Use `#[expect]` over `#[allow]`.
- **Ownership**: prefer borrowing over cloning, accept `&str` over `&String`, `&[T]` over `&Vec<T>`. Let the caller
Expand Down
14 changes: 14 additions & 0 deletions contrib/codeql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CodeQL related
.codeql
.cache
*.testproj/
*.actual

# Generated source-line data
lib/source_lines.qll

# Test files / folders
test.ql
test-*.ql
**/testing/**
**/*.testproj/*
58 changes: 58 additions & 0 deletions contrib/codeql/attrib.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright (c) 2026-present, The Dash Core developers
* SPDX-License-Identifier: MIT
* See the accompanying file LICENSE or https://opensource.org/license/MIT
*
* @name Attribute and derivation rules
* @description Enforcement of required traits per feasible type.
* @kind problem
* @problem.severity warning
* @id base-sdk/attrib-rules
* @tags style
* @precision high
*/

import lib.filters
import lib.fmt
import lib.policy
import lib.traits
import rust

/** Gets a comma-separated list of missing required traits for `t`. */
string missingTraits(TypeItem t) {
isCheckableType(t) and
result =
concat(string trait |
trait = requiredTrait() and
not implementsTrait(t, trait) and
not isSuppressed(t, trait)
|
trait, ", " order by trait
) and
result != ""
}

from TypeItem t, string message
where
isCheckableType(t) and
(
exists(string missing |
missing = missingTraits(t) and
message = fmt("missing required derivations: {0}", missing)
)
or
// Serde: every non-exempt type must derive Serialize + Deserialize.
not isSerdeExempt(t) and
exists(string missing |
missing =
concat(string trait |
trait = requiredSerdeTrait() and
not implementsSerdeTrait(t, trait)
|
trait, ", " order by trait
) and
missing != "" and
message = fmt("missing serde derivations: {0}", missing)
)
)
select t, message
28 changes: 28 additions & 0 deletions contrib/codeql/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
lockVersion: 1.0.0
dependencies:
codeql/concepts:
version: 0.0.25
codeql/controlflow:
version: 2.0.35
codeql/dataflow:
version: 2.1.7
codeql/mad:
version: 1.0.51
codeql/regex:
version: 1.0.51
codeql/rust-all:
version: 0.2.15
codeql/ssa:
version: 2.0.27
codeql/threat-models:
version: 1.0.51
codeql/tutorial:
version: 1.0.51
codeql/typeinference:
version: 0.0.32
codeql/typetracking:
version: 2.0.35
codeql/util:
version: 2.0.38
compiled: false
Loading
Loading