Skip to content

Commit fb14759

Browse files
feat: add repository guidelines and update contribution instructions
1 parent c61a8b8 commit fb14759

File tree

3 files changed

+95
-171
lines changed

3 files changed

+95
-171
lines changed

AGENTS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- Workspace with crates: `dash`, `hashes`, `internals`, `dash-network`, `dash-spv`, `key-wallet`, `rpc-*`, utilities (`fuzz`, `test-utils`), and FFI crates (`*-ffi`).
5+
- Each crate keeps sources in `src/`; unit tests live alongside code with `#[cfg(test)]`. Integration tests use `tests/` (e.g., `rpc-integration-test`).
6+
- Mobile SDK lives in `swift-dash-core-sdk/`; FFI bindings are in `*-ffi`. Shared helpers in `internals/` and `test-utils/`.
7+
8+
## Build, Test, and Development Commands
9+
- MSRV: 1.89. Build all: `cargo build --workspace --all-features`
10+
- Test all: `cargo test --workspace --all-features` or `./contrib/test.sh` (set `DO_COV=true`, `DO_LINT=true`, `DO_FMT=true` as needed)
11+
- Targeted tests: `cargo test -p dash-spv --all-features`
12+
- Integration RPC: `cd dash-spv && DASH_SPV_IP=<node-ip> cargo test --test integration_real_node_test -- --nocapture`
13+
- FFI iOS builds: `cd key-wallet-ffi && ./build-ios.sh` or `cd swift-dash-core-sdk && ./build-ios.sh`
14+
- Lint/format: `cargo clippy --workspace --all-targets -- -D warnings` and `cargo fmt --all`
15+
- Docs: `cargo doc --workspace` (add `--open` locally)
16+
17+
## Coding Style & Naming Conventions
18+
- Mixed editions (2021/2024); follow crate idioms. Prefer async via `tokio` where applicable.
19+
- Format with `rustfmt` (see `rustfmt.toml`); run `cargo fmt --all` before commits.
20+
- Lint with `clippy`; some crates deny warnings in CI. Avoid `unwrap()/expect()` in library code; use error types (e.g., `thiserror`).
21+
- Naming: `snake_case` (funcs/vars), `UpperCamelCase` (types/traits), `SCREAMING_SNAKE_CASE` (consts). Keep modules focused.
22+
23+
## Testing Guidelines
24+
- Unit tests near code; integration tests under `tests/`. Use descriptive names (e.g., `test_parse_address_mainnet`).
25+
- Run targeted suites: `cargo test -p key-wallet --all-features`. Network‑dependent or long tests may be `#[ignore]`; run with `-- --ignored`.
26+
- Cover critical parsing, networking, SPV, and wallet flows. Add regression tests for fixes; consider property tests (e.g., `proptest`) where valuable.
27+
28+
## Commit & Pull Request Guidelines
29+
- Prefer Conventional Commits: `feat:`, `fix:`, `refactor:`, `chore:`, `docs:`. Keep subject ≤72 chars with clear scope and rationale.
30+
- Target branches: feature work to `v**-dev` (development), hotfixes/docs to `master` unless directed otherwise.
31+
- Pre‑PR checks: `cargo fmt`, `cargo clippy`, `cargo test` (workspace). Update docs/CHANGELOG if user-facing.
32+
- Include in PRs: description, linked issues, test evidence (commands/output), and notes on features/FFI impacts.
33+
34+
## Security & Configuration Tips
35+
- Not for consensus‑critical validation; do not rely on exact Dash Core consensus behavior.
36+
- Never commit secrets or real keys; avoid logging sensitive data. Keep test vectors deterministic.
37+
- Mirror strict CI locally if helpful: `export RUSTFLAGS="-D warnings"`.
38+
39+
## References
40+
- General workflow lives in `CONTRIBUTING.md`. For workspace specifics and current tooling, prefer this guide and `CLAUDE.md` when they differ.

CONTRIBUTING.md

Lines changed: 45 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Contributing to rust-dashcore
22

3-
**Heads up about upcoming edition change**
3+
**Branching model (important)**
44

5-
We're currently preparing to bump MSRV and **change the edition to 2018**.
6-
To minimize the churn we recommend you to submit your local WIP changes ASAP.
7-
There will be a lot of rebasing after the edition change.
5+
Feature work targets the active `v**-dev` branch (development). Submit hotfixes and documentation-only changes to `master` unless maintainers direct otherwise.
86

97
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
108

@@ -35,154 +33,78 @@ changes to this document in a pull request.
3533

3634
## General
3735

38-
The Rust Dash Core project operates an open contributor model where anyone is
39-
welcome to contribute towards development in the form of peer review,
40-
documentation, testing and patches.
36+
We welcome contributions of all kinds: bug fixes, features, tests, docs, and reviews. This codebase powers Dash protocol libraries (networking, SPV, wallet, FFI). Changes must be reviewed with security and backward‑compatibility in mind.
4137

42-
Anyone is invited to contribute without regard to technical experience,
43-
"expertise", OSS experience, age, or other concern. However, the development of
44-
standards & reference implementations demands a high-level of rigor, adversarial
45-
thinking, thorough testing and risk-minimization. Any bug may cost users real
46-
money. That being said, we deeply welcome people contributing for the first time
47-
to an open source project or pick up Rust while contributing. Don't be shy,
48-
you'll learn.
4938

39+
## Communication
5040

51-
## Communication channels
52-
53-
Communication about Rust Bitcoin happens primarily in
54-
[#bitcoin-rust](https://web.libera.chat/?channel=#bitcoin-rust) IRC chat on
55-
[Libera](https://libera.chat/) with the logs available at
56-
<https://gnusha.org/bitcoin-rust/> (starting from Jun 2021 and now on) and
57-
<https://gnusha.org/rust-bitcoin/> (historical archive before Jun 2021).
58-
59-
Discussion about code base improvements happens in GitHub issues and on pull
60-
requests.
61-
62-
Major projects are tracked [here](https://github.com/orgs/rust-bitcoin/projects).
63-
Major milestones are tracked [here](https://github.com/rust-bitcoin/rust-bitcoin/milestones).
41+
- Use GitHub Issues for bugs and feature requests.
42+
- Use Pull Requests for code changes and design discussions.
43+
- If enabled, GitHub Discussions can host broader design topics.
6444

6545

6646
## Asking questions
6747

68-
> **Note:** Please don't file an issue to ask a question. You'll get faster
69-
> results by using the resources below.
70-
71-
We have a dedicated developer channel on IRC, #bitcoin-rust@libera.chat where
72-
you may get helpful advice if you have questions.
48+
Prefer opening a GitHub Discussion (if enabled) or a clearly labeled issue. Provide context, reproduction steps, and what you’ve tried.
7349

7450

7551
## Contribution workflow
7652

77-
The codebase is maintained using the "contributor workflow" where everyone
78-
without exception contributes patch proposals using "pull requests". This
79-
facilitates social contribution, easy testing and peer review.
80-
81-
To contribute a patch, the workflow is a as follows:
82-
83-
1. Fork Repository
84-
2. Create topic branch
85-
3. Commit patches
86-
87-
Please keep commits should atomic and diffs easy to read. For this reason
88-
do not mix any formatting fixes or code moves with actual code changes.
89-
Further, each commit, individually, should compile and pass tests, in order to
90-
ensure git bisect and other automated tools function properly.
91-
92-
Please cover every new feature with unit tests.
93-
94-
When refactoring, structure your PR to make it easy to review and don't hesitate
95-
to split it into multiple small, focused PRs.
53+
We use the standard fork-and-PR model:
9654

97-
Commits should cover both the issue fixed and the solution's rationale.
98-
Please keep these [guidelines](https://chris.beams.io/posts/git-commit/) in mind.
55+
1. Fork the repository and create a topic branch.
56+
2. Make focused commits; keep diffs minimal and self‑contained.
57+
3. Ensure each commit builds and tests pass to keep `git bisect` meaningful.
58+
4. Cover new functionality with tests and docs where applicable.
59+
5. Open a PR early for feedback; keep the description clear and scoped.
9960

100-
To facilitate communication with other contributors, the project is making use
101-
of GitHub's "assignee" field. First check that no one is assigned and then
102-
comment suggesting that you're working on it. If someone is already assigned,
103-
don't hesitate to ask if the assigned party or previous commenters are still
104-
working on it if it has been awhile.
61+
Commits should explain the why and the what. Conventional Commits are encouraged.
10562

10663

10764
## Preparing PRs
10865

109-
The main library development happens in the `master` branch. This branch must
110-
always compile without errors (using GitHub CI). All external contributions are
111-
made within PRs into this branch.
66+
Active development happens on `v**-dev` branches. Feature work should target the current `v**-dev`. The `master` branch is kept stable; submit hotfixes and documentation changes to `master` unless directed otherwise. All PRs must compile without errors (verified by GitHub CI).
11267

11368
Prerequisites that a PR must satisfy for merging into the `master` branch:
114-
* each commit within a PR must compile and pass unit tests with no errors, with
115-
every feature combination (including compiling the fuzztests) on some
116-
reasonably recent compiler (this is partially automated with CI, so the rule
117-
is that we will not accept commits which do not pass GitHub CI);
69+
* each commit within a PR should compile and pass unit tests with no errors, with
70+
relevant feature combinations (including building fuzz tests where applicable);
11871
* the tip of any PR branch must also compile and pass tests with no errors on
119-
MSRV (check [README.md] on current MSRV requirements) and pass fuzz tests on
120-
nightly rust;
72+
MSRV (see README for current MSRV) and run fuzz tests where applicable;
12173
* contain all necessary tests for the introduced functional (either as a part of
12274
commits, or, more preferably, as separate commits, so that it's easy to
12375
reorder them during review and check that the new tests fail without the new
12476
code);
125-
* contain all inline docs for newly introduced API and pass doc tests;
126-
* be based on the recent `master` tip from the original repository at
127-
<https://github.com/rust-bitcoin/rust-bitcoin>.
128-
129-
NB: reviewers may run more complex test/CI scripts, thus, satisfying all the
130-
requirements above is just a preliminary, but not necessary sufficient step for
131-
getting the PR accepted as a valid candidate PR for the `master` branch.
132-
133-
PR authors may also find it useful to run the following script locally in order
134-
to check that each of the commits within the PR satisfies the requirements
135-
above, before submitting the PR to review:
136-
```shell script
137-
BITCOIN_MSRV=1.29.0 ./contrib/test.sh
138-
```
139-
Please replace the value in `BITCOIN_MSRV=1.29.0` with the current MSRV from
140-
[README.md].
77+
* include inline docs for newly introduced APIs and pass doc tests;
78+
* be based on the recent tip of the target branch in this repository.
79+
80+
Reviewers may run additional scripts; passing CI is necessary but may not be sufficient for merge. To mirror CI locally:
81+
```bash
82+
# Full suite with optional knobs
83+
DO_COV=true DO_LINT=true DO_FMT=true ./contrib/test.sh
14184

142-
NB: Please keep in mind that the script above replaces `Cargo.lock` file, which
143-
is necessary to support current MSRV, incompatible with `stable` and newer cargo
144-
versions.
85+
# Or workspace-wide checks
86+
cargo fmt --all && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace --all-features
87+
```
14588

14689
### Peer review
14790

148-
Anyone may participate in peer review which is expressed by comments in the pull
149-
request. Typically, reviewers will review the code for obvious errors, as well as
150-
test out the patch set and opine on the technical merits of the patch. Please,
151-
first review PR on the conceptual level before focusing on code style or
152-
grammar fixes.
91+
Anyone may review PRs. Start with design and correctness, then style. Maintain respectful, constructive feedback.
15392

15493
### Repository maintainers
15594

15695
Pull request merge requirements:
157-
- all CI test should pass,
158-
- at least two "accepts"/ACKs from the repository maintainers
159-
- no reasonable "rejects"/NACKs from anybody who reviewed the code.
160-
161-
Current list of the project maintainers:
162-
163-
- [Andrew Poelstra](https://github.com/apoelstra)
164-
- [Steven Roose](https://github.com/stevenroose)
165-
- [Maxim Orlovsky](https://github.com/dr-orlovsky)
166-
- [Matt Corallo](https://github.com/TheBlueMatt)
167-
- [Elichai Turkel](https://github.com/elichai)
168-
- [Sanket Kanjalkar](https://github.com/sanket1729)
169-
- [Martin Habovštiak](https://github.com/Kixunil)
170-
- [Riccardo Casatta](https://github.com/RCasatta)
171-
- [Tobin Harding](https://github.com/tcharding)
96+
- All CI checks pass.
97+
- At least one maintainer approval (more may be required for risky changes).
98+
- No unresolved blocking reviews.
17299

173100

174101
## Coding conventions
175102

176-
Library reflects Bitcoin Core approach whenever possible.
177-
178-
### Formatting
103+
Follow idiomatic Rust and crate‑local patterns.
179104

180-
The repository currently does not use `rustfmt`.
105+
### Formatting & Linting
181106

182-
New changes may format the code with `rustfmt`, but they should not re-format
183-
any existing code for maintaining diff size small, keeping `git blame` intact and
184-
reduce review time. Repository maintainers may not review PRs introducing large
185-
blocks of re-formatted code.
107+
Run `cargo fmt --all` before submitting PRs. Use `cargo clippy --workspace --all-targets -- -D warnings` to catch issues early. Avoid large, unrelated reformatting to keep diffs focused and `git blame` useful.
186108

187109
You may check the [discussion on the formatting](https://github.com/rust-bitcoin/rust-bitcoin/issues/172)
188110
and [how it is planned to coordinate it with crate refactoring](https://github.com/rust-bitcoin/rust-bitcoin/pull/525)
@@ -192,55 +114,30 @@ avoid any end-line space characters.
192114

193115
### MSRV
194116

195-
The Minimal Supported Rust Version (MSRV) is 1.29; it is enforced by our CI.
196-
Later we plan to increase MSRV to support Rust 2018 and you are welcome to check
197-
the [tracking issue](https://github.com/rust-bitcoin/rust-bitcoin/issues/510).
117+
The Minimal Supported Rust Version (MSRV) is 1.89; it is enforced by CI. Crates use mixed editions (2021/2024); consult `Cargo.toml` and README for details.
198118

199119
### Naming conventions
200120

201-
Naming of data structures/enums and their fields/variants must follow names used
202-
in Bitcoin Core, with the following exceptions:
203-
- the case should follow Rust standards (i.e. PascalCase for types and
204-
snake_case for fields and variants);
205-
- omit `C`-prefixes.
121+
Use Rust standards: `UpperCamelCase` for types/traits, `snake_case` for modules/functions/variables, `SCREAMING_SNAKE_CASE` for constants. Prefer descriptive names matching Dash domain concepts.
206122

207123
### Unsafe code
208124

209-
Use of `unsafe` code is prohibited unless there is a unanimous decision among
210-
library maintainers on the exclusion from this rule. In such cases there is a
211-
requirement to test unsafe code with sanitizers including Miri.
125+
Minimize `unsafe`. When required (especially across FFI boundaries), encapsulate it, document invariants, add tests, and consider Miri/sanitizers.
212126

213127

214128
## Security
215129

216-
Security is the primary focus for this library; disclosure of security
217-
vulnerabilities helps prevent user loss of funds. If you believe a vulnerability
218-
may affect other implementations, please disclose this information according to
219-
the [security guidelines](./SECURITY.md), work on which is currently in progress.
220-
Before it is completed, feel free to send disclosure to Andrew Poelstra,
221-
apoelstra@wpsoftware.net, encrypted with his public key from
222-
<https://www.wpsoftware.net/andrew/andrew.gpg>.
130+
This library is NOT suitable for consensus‑critical validation. Always validate inputs from untrusted sources and never log or store private keys. Report vulnerabilities privately via GitHub Security Advisories or by contacting the maintainers through a private channel.
223131

224132

225133
## Testing
226134

227-
Related to the security aspect, rust bitcoin developers take testing very
228-
seriously. Due to the modular nature of the project, writing new test cases is
229-
easy and good test coverage of the codebase is an important goal. Refactoring
230-
the project to enable fine-grained unit testing is also an ongoing effort.
231-
232-
Fuzzing is heavily encouraged: feel free to add related material under `fuzz/`
233-
234-
Mutation testing is planned; any contributions helping with that are highly
235-
welcome!
135+
Testing is a priority. Keep unit tests close to code and use `tests/` for integration. Add fuzz targets under `fuzz/` when appropriate. Use deterministic test vectors and avoid network dependencies unless explicitly required (mark such tests `#[ignore]`).
236136

237137

238-
## Going further
138+
## References
239139

240-
You may be interested in the guide by Jon Atack on
241-
[How to review Bitcoin Core PRs](https://github.com/jonatack/bitcoin-development/blob/master/how-to-review-bitcoin-core-prs.md)
242-
and [How to make Bitcoin Core PRs](https://github.com/jonatack/bitcoin-development/blob/master/how-to-make-bitcoin-core-prs.md).
243-
While there are differences between the projects in terms of context and
244-
maturity, many of the suggestions offered apply to this project.
140+
- See README for workspace overview and MSRV.
141+
- See CLAUDE.md and AGENTS.md for repo‑specific commands and workflows.
245142

246-
Overall, have fun :)
143+
Overall, have fun and build safely.

0 commit comments

Comments
 (0)