Thank you for your interest in contributing to ADIC Core! This document provides guidelines and information for contributing to the implementation of the ADIC-DAG protocol.
- Project Overview
- Development Setup
- Code Organization
- How to Contribute
- Development Workflow
- Testing Guidelines
- Code Style & Conventions
- Documentation
- Security
- Community
ADIC Core implements the ADIC-DAG protocol, a feeless distributed ledger based on p-adic ultrametric mathematics. Before contributing, we recommend:
- Reading the whitepaper to understand the mathematical foundations
- Reviewing the README for implementation status
- Understanding the core concepts:
- P-adic number theory and ultrametric spaces
- Higher-dimensional directed acyclic hypergraphs (d-simplices)
- Reputation-weighted consensus mechanisms
- K-core and persistent homology finality tests
- Rust 1.70+: Install via rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Git: Version control system
Different operating systems require different packages for building native dependencies (RocksDB, libp2p, etc.):
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install build-essential pkg-config libssl-dev libclang-dev protobuf-compiler cmakemacOS:
# Install Xcode Command Line Tools if not already installed
xcode-select --install
# Install dependencies via Homebrew
brew install cmake pkg-config protobufFedora/RHEL/CentOS:
sudo dnf install gcc gcc-c++ pkgconfig openssl-devel clang-devel protobuf-compiler cmakeArch Linux:
sudo pacman -S base-devel pkg-config openssl clang protobuf cmake- Docker: For containerized development and testing
- Python 3.8+: Required for running network simulations
- cargo-tarpaulin: For test coverage reports
cargo install cargo-tarpaulin
- cargo-watch: For automatic rebuilds during development
cargo install cargo-watch
# Clone the repository
git clone https://github.com/IguanAI/adic-core.git
cd adic-core
# Build in release mode
cargo build --release
# Run all tests
cargo test --all
# Run the node with verbose output
RUST_LOG=info ./target/release/adic startThe fastest way to get started is using our Docker-based development environment, which includes:
- 2 ADIC nodes running in devnet mode
- PostgreSQL for state queries
- Prometheus for metrics collection
- Grafana for visualization
Prerequisites:
- Docker and Docker Compose installed
- At least 4GB of free RAM
Quick Start:
# Start the complete development environment
./scripts/dev-start.sh
# View logs from all services
./scripts/dev-logs.sh
# View logs from a specific service
./scripts/dev-logs.sh adic-node-1
# Stop the environment (preserves data)
./scripts/dev-stop.sh
# Reset everything (removes all data)
./scripts/dev-reset.shAvailable Services:
| Service | URL | Credentials |
|---|---|---|
| Node 1 API | http://localhost:8080 | - |
| Node 1 Swagger UI | http://localhost:8080/api/docs | - |
| Node 2 API | http://localhost:18081 | - |
| Node 2 Swagger UI | http://localhost:18081/api/docs | - |
| Grafana | http://localhost:3000 | admin/admin |
| Prometheus | http://localhost:9090 | - |
| PostgreSQL | localhost:15432 | adic/adic_dev_password |
Testing Multi-Node Communication:
# Submit a message to node 1
curl -X POST http://localhost:8080/v1/messages \
-H "Content-Type: application/json" \
-d '{"payload": "test message"}'
# Check if node 2 received it
curl http://localhost:18081/v1/messages | jqEnvironment Variables:
You can customize the dev environment by setting variables in .env:
# Example: Change Grafana password
GRAFANA_ADMIN_PASSWORD=my_secure_password ./scripts/dev-start.sh
# Example: Adjust Prometheus retention
PROMETHEUS_RETENTION=30d ./scripts/dev-start.shMonitoring & Debugging:
- Grafana Dashboards: Pre-configured dashboards show message flow, finality, and performance
- Prometheus Metrics: Raw metrics available at each node's
/metricsendpoint - Container Logs: Use
docker logs adic-node-1for detailed debugging
RocksDB compilation fails:
- Ensure you have
libclang-devinstalled - On macOS, make sure Xcode Command Line Tools are up to date
"error: linker cc not found":
- Install build-essential (Ubuntu) or base-devel (Arch)
- On macOS, install Xcode Command Line Tools
Protocol buffer errors:
- Install
protobuf-compilerpackage - Verify with:
protoc --version
make build # Build the project
make test # Run all tests
make clean # Clean build artifacts
make docker-build # Build Docker imageThe project uses a Rust workspace with 12 specialized crates:
adic-types- Core type definitions and protocol parametersadic-math- P-adic arithmetic, valuations, and ultrametric operationsadic-crypto- Cryptographic primitives and experimental p-adic crypto
adic-consensus- C1-C3 constraint validation and admissibility checkingadic-finality- F1 (K-core) and F2 (homology) finality testsadic-mrw- Multi-axis random walk for tip selection
adic-storage- RocksDB-based persistence layeradic-network- P2P networking with QUIC/TCP transportsadic-economics- Token accounting and balance managementadic-node- Main node implementation and API server
adic-bench- Performance benchmarkssimulation/- Python-based network simulator
We welcome various types of contributions:
-
Code Improvements
- Bug fixes
- Performance optimizations
- New features aligned with the protocol
- Test coverage improvements
-
Mathematical Validation
- Verification of p-adic calculations
- Homology computation improvements
- Energy descent proofs
-
Documentation
- Code documentation
- Mathematical explanations
- API documentation
- Tutorial creation
-
Research
- Cryptographic improvements
- Network optimization
- Consensus mechanism enhancements
- Find an Issue: Check existing issues or create a new one
- Discuss: For significant changes, open an issue for discussion first
- Fork & Branch: Create a feature branch from
develop - Implement: Make your changes following our guidelines
- Test: Ensure all tests pass and add new ones as needed
- Submit: Create a pull request with a clear description
main- Stable releases onlydevelop- Active development branchfeature/*- New featuresfix/*- Bug fixesresearch/*- Experimental work
- Target Branch: PRs should target
developunless fixing a critical bug - Description: Provide a clear description of changes
- Testing: Include test results and coverage reports
- Review: Address reviewer feedback promptly
- Squash: Consider squashing commits for cleaner history
Follow the Conventional Commits specification:
type(scope): brief description
Longer explanation if needed
Fixes #issue_number
Types: feat, fix, docs, style, refactor, test, chore
# Run all tests
cargo test --all
# Run specific crate tests
cargo test --package adic-consensus
# Run with coverage
cargo tarpaulin --all --out Html
# Run integration tests
cargo test --test '*'
# Run benchmarks
cargo bench- Unit Tests: In-module tests for individual functions
- Integration Tests: Cross-crate functionality (
tests/directories) - Property-Based Tests: Using
proptestfor mathematical properties - Network Tests: Multi-peer scenarios and failure modes
- Benchmarks: Performance regression tests
- Aim for >70% code coverage
- Critical paths (consensus, finality) should have >90% coverage
- New features must include comprehensive tests
- Follow standard Rust conventions (use
cargo fmtandcargo clippy) - Prefer explicit error handling over
unwrap() - Use
async/awaitfor asynchronous operations - Document public APIs with doc comments
// GOOD: Clear, explicit error handling
pub async fn validate_message(msg: &AdicMessage) -> Result<ValidationResult> {
let features = msg.features.clone();
let validation = self.check_constraints(&features).await?;
Ok(validation)
}
// AVOID: Unnecessary comments and unwraps
pub async fn validate_message(msg: &AdicMessage) -> ValidationResult {
// Get the features from the message
let features = msg.features.clone();
// Check the constraints
let validation = self.check_constraints(&features).await.unwrap();
validation // Return the validation
}- P-adic operations use
QpDigitstype consistently - Network messages use protobuf serialization
- Async operations use
tokioruntime - Storage operations return
Result<T, AdicError>
- Document all public APIs
- Include mathematical formulas where relevant
- Add examples for complex functions
/// Calculates the p-adic valuation difference between two numbers.
///
/// For p-adic numbers x and y, returns v_p(x - y) where v_p is the p-adic valuation.
///
/// # Mathematical Background
///
/// The p-adic valuation v_p(n) is the highest power of p that divides n.
///
/// # Example
///
/// ```
/// let x = QpDigits::from_u64(9, 3, 5);
/// let y = QpDigits::from_u64(3, 3, 5);
/// let diff = vp_diff(&x, &y);
/// assert_eq!(diff, 1); // Since 9 - 3 = 6 = 2 * 3^1
/// ```
pub fn vp_diff(x: &QpDigits, y: &QpDigits) -> i32 {
// Implementation
}- Update README.md for significant features
- Add entries to CHANGELOG.md following Keep a Changelog format
- Create examples in
examples/for new functionality
Security issues should be reported privately:
- Email: ADICL1@proton.me with subject "SECURITY: [description]"
- GitHub Security Advisories: Use private vulnerability reporting
- See SECURITY.md for detailed guidelines
- Never commit private keys or sensitive data
- Be cautious with cryptographic implementations
- Validate all external inputs
- Follow the principle of least privilege
- Consider timing attacks in consensus code
- Issues: Bug reports and feature requests
- Discussions: GitHub Discussions for general topics
- Email: ADICL1@proton.me for private communications
We are committed to providing a welcoming and inclusive environment. Please:
- Be respectful and constructive
- Focus on technical merit
- Help others learn and grow
- Report inappropriate behavior
Contributors will be recognized in:
- Release notes
- CONTRIBUTORS file
- Project documentation
If you need help:
- Check existing documentation
- Search closed issues
- Ask in GitHub Discussions
- Contact the maintainers
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to ADIC Core! Your efforts help advance the implementation of novel distributed ledger technology based on p-adic mathematics.