Thank you for your interest in contributing to the EpicChain C++ blockchain node implementation! This document provides guidelines and information for contributors.
We welcome contributions of all kinds:
- Bug Reports: Help us identify and fix issues
- Feature Requests: Suggest new functionality
- Code Contributions: Implement features, fix bugs, improve performance
- Documentation: Improve guides, API docs, and examples
- Testing: Add test cases, improve test coverage
- Performance: Optimize existing code and algorithms
Before contributing, ensure you have:
- C++20 compatible compiler (GCC 10+, Clang 12+, MSVC 2019+)
- CMake 3.20+
- Git
- vcpkg (for dependency management)
- Understanding of EpicChain blockchain concepts
-
Fork the Repository
# Fork the repo on GitHub, then clone your fork git clone https://github.com/your-username/epicchain-core-cpp.git cd epicchain-core-cpp
-
Set Up Upstream Remote
git remote add upstream https://github.com/epicchainlabs/epicchain-core-cpp.git
-
Initialize Dependencies
# Initialize vcpkg git submodule update --init --recursive ./vcpkg/bootstrap-vcpkg.sh # or .bat on Windows
-
Build the Project
mkdir build && cd build cmake .. -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake cmake --build . --config Debug
-
Run Tests
ctest --output-on-failure
# Update your main branch
git checkout main
git pull upstream main
# Create a new feature branch
git checkout -b feature/your-feature-name- Write clean, well-documented code
- Follow the project's coding standards
- Add tests for new functionality
- Update documentation as needed
# Run all tests
ctest
# Run specific test categories
ctest -L unit
ctest -L integration
# Check for memory leaks (Linux)
valgrind --leak-check=full ./your-test
# Static analysis
make lint# Stage your changes
git add .
# Commit with a descriptive message
git commit -m "feat: add new consensus mechanism feature
- Implement new dBFT optimization
- Add comprehensive unit tests
- Update documentation
- Improve performance by 15%"# Push to your fork
git push origin feature/your-feature-name
# Create a pull request on GitHub- Standard: Follow C++20 best practices
- Naming Conventions:
- Classes:
PascalCase(e.g.,BlockChain,Transaction) - Functions/Methods:
PascalCase(e.g.,ProcessBlock(),ValidateTransaction()) - Variables:
camelCase(e.g.,blockHeight,transactionHash) - Member variables:
camelCase_(e.g.,blockHeight_,isRunning_) - Constants:
UPPER_SNAKE_CASE(e.g.,MAX_BLOCK_SIZE)
- Classes:
- Headers: Use
#pragma onceinstead of include guards - Memory Management: Use smart pointers (
std::shared_ptr,std::unique_ptr) - Error Handling: Use exceptions for error conditions
- Threading: Use standard library threading primitives
// Example header file structure
#pragma once
#include <memory>
#include <string>
#include <vector>
namespace epicchain::ledger {
/**
* @brief Represents a blockchain transaction
*
* This class encapsulates all the data and functionality
* required for EpicChain transactions.
*/
class Transaction {
public:
Transaction() = default;
~Transaction() = default;
// Copy and move semantics
Transaction(const Transaction&) = default;
Transaction& operator=(const Transaction&) = default;
Transaction(Transaction&&) = default;
Transaction& operator=(Transaction&&) = default;
/**
* @brief Validates the transaction
* @return true if valid, false otherwise
*/
bool Validate() const;
private:
std::string hash_;
std::vector<uint8_t> script_;
uint64_t networkFee_;
uint64_t systemFee_;
};
} // namespace epicchain::ledger- Use Doxygen-style comments for all public APIs
- Include parameter descriptions and return value information
- Provide usage examples for complex functions
- Document thread safety guarantees
- Explain algorithmic complexity where relevant
We follow the Conventional Commits specification for commit messages:
<type>(<scope>): <description>
[optional body]
[optional footer]
Where type is one of:
feat: A new featurefix: A bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or modifying testschore: Changes to the build process or tools
feature/feature-name: For new featuresbugfix/bug-name: For bug fixesrefactor/refactor-name: For code refactoringdocs/docs-name: For documentation changestest/test-name: For test changes
We use Google Test for unit testing. All new code should have corresponding unit tests. Significant changes should also include integration tests.
To run the tests:
cd build
cmake --build . --target testWe use Doxygen for API documentation. All public APIs should be documented using Doxygen-style comments.
To generate the documentation:
cd build
cmake --build . --target docsWe use GitHub issues to track public bugs. Report a bug by opening a new issue; it's that easy!
## Bug Description
A clear and concise description of what the bug is.
## Steps to Reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Expected Behavior
A clear and concise description of what you expected to happen.
## Actual Behavior
A clear and concise description of what actually happened.
## Screenshots
If applicable, add screenshots to help explain your problem.
## Environment
- OS: [e.g. Ubuntu 20.04]
- Compiler: [e.g. GCC 9.3.0]
- Version: [e.g. 0.1.0]
## Additional Context
Add any other context about the problem here.
We use GitHub issues to track feature requests. Request a feature by opening a new issue with the "feature request" template.
## Feature Description
A clear and concise description of the feature you're requesting.
## Problem Statement
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
## Proposed Solution
A clear and concise description of what you want to happen.
## Alternative Solutions
A clear and concise description of any alternative solutions or features you've considered.
## Additional Context
Add any other context or screenshots about the feature request here.
By contributing, you agree that your contributions will be licensed under the project's MIT License.
This document was adapted from the open-source contribution guidelines for Facebook's Draft.