Thank you for your interest in contributing to RBFT! This document provides guidelines and best practices for contributing to the project.
- Code of Conduct
- Getting Started
- Development Workflow
- Code Style
- Testing
- Commit Guidelines
- Pull Request Process
- Issue Reporting
We are committed to providing a welcoming and inclusive environment. By participating in this project, you agree to:
- Be respectful and considerate of others
- Accept constructive criticism gracefully
- Focus on what is best for the community
- Show empathy towards other community members
-
Fork the Repository
# Fork on GitHub, then clone your fork git clone https://github.com/YOUR_USERNAME/rbft.git cd rbft
-
Set Up Your Development Environment
# Install Rust (if not already installed) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Install nightly toolchain for formatting rustup toolchain install nightly # Install pre-commit hooks pip install pre-commit pre-commit install
-
Create a Feature Branch
git checkout -b feat/your-feature-name # or git checkout -b fix/your-bug-fix
feat/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Test additions or modificationschore/- Maintenance tasks
Examples:
feat/add-validator-rotationfix/consensus-timeout-issuedocs/update-readme
- Check existing issues and PRs to avoid duplicate work
- For major changes, open an issue first to discuss the approach
- Keep your fork's main branch up to date:
git remote add upstream https://github.com/raylsnetwork/rbft.git git fetch upstream git rebase upstream/main
- Line Length: Maximum 100 characters
- Formatter: Use
cargo +nightly fmt(required for unstable rustfmt features) - Configuration: Settings in
rustfmt.toml
Run before committing:
cargo +nightly fmtRun all checks locally before pushing:
# Format code
cargo +nightly fmt
# Check line lengths
python3 scripts/check_line_length.py
# Run linter
cargo clippy -- -D warnings
# Run tests
cargo test-
Documentation: Add doc comments for public APIs
/// Brief description of the function /// /// # Arguments /// /// * `param` - Description of the parameter /// /// # Returns /// /// Description of the return value /// /// # Examples /// /// ``` /// let result = function(arg); /// ``` pub fn function(param: Type) -> ReturnType { // implementation }
-
Error Handling: Use
Resulttypes and provide meaningful error messages -
Comments: Write clear comments for complex logic
-
Naming: Use descriptive names following Rust conventions
snake_casefor functions and variablesCamelCasefor types and traitsSCREAMING_SNAKE_CASEfor constants
# Run all tests
cargo test
# Run specific test
cargo test test_name
# Run tests for a specific package
cargo test -p rbft-utils
# Run with output
cargo test -- --nocapture- Unit Tests: Add tests for new functionality
- Integration Tests: Test component interactions
- Documentation Tests: Ensure example code works
We aim for high test coverage. When adding new features:
- Write tests for happy paths
- Write tests for error conditions
- Write tests for edge cases
- Add integration tests where appropriate
Example test structure:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_basic_functionality() {
// Test implementation
}
#[test]
#[should_panic(expected = "error message")]
fn test_error_condition() {
// Test that should panic
}
}<type>: <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Test additions or modificationschore: Maintenance tasks
feat: add validator rotation mechanism
Implement automatic validator rotation based on epoch boundaries.
Includes tests for rotation logic and edge cases.
Closes #123
fix: resolve consensus timeout in high-latency networks
Increase timeout values and add exponential backoff for retry logic.
This fixes issues observed in networks with >500ms latency.
Fixes #456
- Keep commits atomic (one logical change per commit)
- Write clear, descriptive commit messages
- Reference related issues in commit messages
- Avoid committing generated files or build artifacts
- Don't commit commented-out code
-
Ensure all tests pass
cargo test -
Run code quality checks
cargo +nightly fmt cargo clippy -- -D warnings python3 scripts/check_line_length.py
-
Update documentation if you've changed APIs or added features
-
Rebase on latest main
git fetch upstream git rebase upstream/main
-
Push your branch
git push origin feat/your-feature-name
-
Open a Pull Request on GitHub
-
Fill out the PR template with:
- Clear description of changes
- Related issue numbers
- Testing performed
- Any breaking changes
- Screenshots (if UI changes)
<type>: <description>
Examples:
feat: Add ERC20 contract testing frameworkfix: Resolve memory leak in consensus moduledocs: Update installation instructions
- PRs require at least one approval from a maintainer
- Address review feedback promptly
- Keep PRs focused and reasonably sized
- Be responsive to questions and suggestions
- CI checks must pass before merge
- Delete your feature branch (GitHub will prompt)
- Update your local repository:
git checkout main git pull upstream main git push origin main
- Search existing issues to avoid duplicates
- Check if it's already fixed in the latest version
- Gather relevant information (logs, environment details)
When creating an issue, include:
Bug Reports:
- Clear description of the problem
- Steps to reproduce
- Expected behavior vs actual behavior
- Environment details (OS, Rust version, etc.)
- Relevant logs or error messages
- Minimal reproduction code if applicable
Feature Requests:
- Clear description of the proposed feature
- Use case and motivation
- Potential implementation approach
- Any alternative solutions considered
Questions:
- What you're trying to accomplish
- What you've already tried
- Relevant code snippets or configurations
We use labels to categorize issues:
bug- Something isn't workingenhancement- New feature or requestdocumentation- Documentation improvementsgood first issue- Good for newcomershelp wanted- Extra attention neededquestion- Further information requested
# Build in release mode
cargo build --release
# Run a specific binary
cargo run --bin rbft-node
# Check without building
cargo check
# Generate documentation
cargo doc --open
# Clean build artifacts
cargo clean
# Run benchmarks
cargo bench# Run with debug output
RUST_LOG=debug cargo run --bin rbft-node
# Run with trace-level logging
RUST_LOG=trace cargo run --bin rbft-node
# Debug specific module
RUST_LOG=rbft::consensus=debug cargo run --bin rbft-node# Build with profiling enabled
cargo build --release --features profiling
# Run with CPU profiling
cargo flamegraph --bin rbft-node- Documentation: Check the docs directory
- Issues: Search or create an issue on GitHub
- Discussions: Use GitHub Discussions for questions and ideas
Contributors will be recognized in:
- Release notes for significant contributions
- The project's contributor list
- Individual PR acknowledgments
Thank you for contributing to RBFT! 🚀