Monorepo Overview
The repository follows a well-organized structure with clear separation of concerns:Core Directories
rs/ - Rust Implementation
The rs/ directory contains all the replica’s Rust code, organized into 60+ subdirectories representing different components of the Internet Computer Protocol.
Key Components
Key Components
- consensus/ - Consensus protocol implementation including DKG, IDKG, and certification
- execution_environment/ - Canister execution and WebAssembly runtime
- crypto/ - Cryptographic primitives (threshold signatures, multi-signatures, TLS)
- messaging/ - Cross-canister and cross-subnet messaging
- bitcoin/ - Bitcoin integration (adapter, consensus, ckBTC minter)
- ethereum/ - Ethereum integration and ckETH support
- boundary_node/ - Boundary node services (rate limiting, routing)
- http_endpoints/ - Public API and HTTP gateway
- replica/ - Main replica binary
- tests/ - System-level integration and end-to-end tests
Building the Replica
To build the core replica binary:packages/ - Published Packages
The packages/ directory contains Rust crates intended for external publication on crates.io:
- pocket-ic/ - Local canister testing library
- ic-signature-verification/ - Signature verification utilities
- icrc-ledger-types/ - ICRC ledger type definitions
- ic-error-types/ - Error handling types
- Cryptographic packages (ic-ed25519, ic-secp256k1, ic-secp256r1)
Packages can depend on one another and other published code, but not on internal code in the
rs/ directory.ic-os/ - Operating System Images
IC-OS is an umbrella term for all operating systems within the IC ecosystem:
SetupOS
Responsible for booting a new replica node and installing HostOS and GuestOS
HostOS
Runs on the host machine and launches GuestOS in a virtual machine
GuestOS
Executes the core IC protocol inside a virtual machine
- prod - Production images (no console access)
- dev - Development images (console access, default credentials: root/root)
- Additional variants for GuestOS: dev-malicious, recovery
Building IC-OS Images
Build specific images using Bazel:bazel-bin/ic-os/{setupos,hostos,guestos}/envs/<TARGET>/ and top-level artifacts/ directory.
Build Systems
Cargo Workspace
The repository uses a Cargo workspace for Rust dependency management. The workspace configuration is defined in the rootCargo.toml:
Bazel Build System
The Internet Computer uses Bazel as its primary build system for reproducible, hermetic builds.Key Bazel Files
- WORKSPACE.bazel - Legacy workspace configuration
- MODULE.bazel - Modern Bazel modules and dependencies
- BUILD.bazel - Build targets (600+ files throughout the repo)
- bazel/ - Build rules, macros, and toolchain configuration
Common Bazel Commands
Bazel Configuration
Key configuration files:.bazelrc- Bazel runtime configuration.bazelversion- Pinned Bazel version for reproducibilitybazel/defs.bzl- Custom build macros and rules
Additional Directories
ci/ - Continuous Integration
CI/CD infrastructure including:
- container/ - Docker containers for build environments
- scripts/ - Automated testing and linting scripts
- GitHub Actions workflows (
.github/workflows/)
bin/ - Utility Scripts
Helper scripts for development and operations.
third_party/ - External Dependencies
Vendored third-party code and tools.
Development Environment
System Requirements
- Architecture: x86-64
- Memory: Minimum 16 GB RAM/SWAP
- Disk: 100 GB available space
- OS: Ubuntu 22.04 or newer
- Container Runtime: Podman
Dev Container
Use the provided dev container for consistent build environment:Configuration Files
Code Quality
- rustfmt.toml - Rust code formatting rules
- clippy.toml - Clippy linter configuration
- .editorconfig - Editor configuration for consistent style
- deny.toml - Cargo-deny configuration for dependency auditing
Pre-commit Hooks
- .pre-commit-config.yaml - Pre-commit hook configuration
- pre-commit/ - Custom pre-commit scripts
Navigation Tips
Find Components
Use the
rs/ directory structure to locate protocol components. Each major feature has its own subdirectory.Explore Tests
Check
rs/tests/ for system-level tests and individual component directories for unit tests.Related Resources
Testing Guide
Learn about the testing infrastructure and frameworks
Contributing
Guidelines for submitting contributions