Contributing to Clementine
Thank you for your interest in contributing to Clementine! This guide will help you get started with contributing to the project.Getting Started
Prerequisites
Before you begin contributing, make sure you have:- Rust toolchain installed via rustup.rs
-
RISC Zero (version 2.1.0):
-
System dependencies:
- macOS: Xcode Command Line Tools (
xcode-select --install) - Ubuntu:
sudo apt install build-essential libssl-dev pkg-config
- macOS: Xcode Command Line Tools (
-
Development tools:
- PostgreSQL (for testing)
- Bitcoin Core v29.0 or later
- Git
Setting Up Your Development Environment
-
Fork and clone the repository:
-
Set up PostgreSQL for testing:
-
Set required environment variables:
-
Generate test certificates:
-
Download BitVM cache (optional but recommended):
Development Workflow
Making Changes
-
Create a new branch for your changes:
- Make your changes following the code style guidelines
- Write or update tests for your changes
-
Run the test suite to ensure everything passes:
-
Generate documentation if you’ve changed public APIs:
Testing Your Changes
Clementine uses separate test commands for unit and integration tests.
Unit Tests
Unit tests run quickly and don’t require external dependencies:Integration Tests
Integration tests require PostgreSQL and may require Bitcoin Core:--test-threads 7) to avoid database conflicts.
Writing Tests
When adding new features or fixing bugs:- Add unit tests in the same file as your code or in the appropriate
testmodule - Add integration tests in
core/src/test/if testing cross-component functionality - Follow existing test patterns - see
core/src/test/for examples - Test both success and error cases
Code Style
-
Format your code with rustfmt:
-
Check for common issues with clippy:
-
Follow Rust naming conventions:
snake_casefor functions, variables, and modulesPascalCasefor types and traitsSCREAMING_SNAKE_CASEfor constants
-
Write clear, descriptive comments:
- Document public APIs with
///doc comments - Explain complex logic with inline comments
- Reference related issues or RFCs when relevant
- Document public APIs with
- Keep functions focused: Each function should do one thing well
-
Handle errors properly: Use
Resultand propagate errors with?where appropriate
Submitting Changes
Pull Request Process
-
Commit your changes with clear, descriptive commit messages:
-
Push to your fork:
-
Open a Pull Request on GitHub with:
- Clear title describing the change
- Description of what changed and why
- Linked issues (use “Closes #123” to auto-close issues)
- Testing details - how you tested the changes
- Documentation updates - if you changed documented interfaces
Pull Request Template
When you create a PR, fill out the template with:Commit Message Guidelines
Use conventional commit messages:feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Adding or updating testsrefactor:- Code refactoringperf:- Performance improvementschore:- Maintenance tasks
Code Review Process
What to Expect
- Code owners review: PRs are reviewed by @chainwayxyz/clementine-bdfl
- CI/CD checks: Automated tests and linting must pass
- Infrastructure changes: Changes to
.github/**,.gitsecret/**, ordevops/**require review from @chainwayxyz/ops-bdfl
Review Guidelines
Reviewers will check for:- Code quality: Is the code clear, maintainable, and well-structured?
- Tests: Are there sufficient tests? Do they cover edge cases?
- Documentation: Are public APIs documented? Are changes reflected in docs?
- Security: Are there any security implications?
- Performance: Are there any performance concerns?
- Breaking changes: Are breaking changes justified and well-documented?
Types of Contributions
Bug Reports
Found a bug? Help us fix it!- Search existing issues to avoid duplicates
- Create a new issue with:
- Clear, descriptive title
- Steps to reproduce
- Expected vs actual behavior
- Environment details (OS, Rust version, Clementine version)
- Error messages and logs
- Minimal reproduction case if possible
Feature Requests
Have an idea for a new feature?- Check existing issues to see if it’s already proposed
- Open a discussion or issue describing:
- The problem you’re trying to solve
- Your proposed solution
- Alternative approaches considered
- Potential impact on existing functionality
Documentation Improvements
Documentation is always welcome!- Fix typos or clarify confusing sections
- Add examples for common use cases
- Improve API documentation
- Translate documentation (if applicable)
Code Contributions
Contributions can include:- Bug fixes
- New features
- Performance improvements
- Code refactoring
- Test coverage improvements
Security Reporting
If you discover a security vulnerability:-
Email the security team at:
security@citrea.xyz -
Encrypt sensitive reports using the GPG key:
Full GPG key is available in the SECURITY.md file.
-
Include in your report:
- Description of the vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (if you have one)
- Wait for response before public disclosure
Helper Scripts
Thescripts/ directory contains helpful utilities:
generate_certs.sh- Generate TLS certificates for testingdocker/- Docker and docker-compose configurations- Various testing and setup scripts
Each script includes comments explaining its purpose. Check individual scripts for usage details.
Building for Production
When building for production deployment:automation feature enables:
- State Manager - Automatic duty fulfillment
- Transaction Sender - Automatic transaction management
Resources
- Source Code: github.com/chainwayxyz/clementine
- Issue Tracker: GitHub Issues
- API Docs: chainwayxyz.github.io/clementine/clementine_core
- Whitepaper: citrea.xyz/clementine_whitepaper.pdf
- Discord: discord.gg/citrea
Questions?
If you have questions about contributing:- Check the FAQ and Troubleshooting guides
- Search existing issues
- Ask in the Citrea Discord
- Open a GitHub Discussion