How input-output-hk/mithril works
Project type and purpose
• This is a multi-service, full-stack, microservice-style system implementing the Mithril threshold multisignature protocol on top of the Cardano network.
• The main runtime nodes are: Mithril Signer (produces individual signatures), Mithril Aggregator (collects and aggregates signatures into certified artifacts), Mithril Relay (peer-to-peer message forwarder), and Clients (CLI, WASM, library). There is also an Explorer frontend, internal shared libraries, an end-to-end test lab, and Terraform-based cloud infrastructure.
High-level file structure signals
• Top-level Rust crates:
• mithril-aggregator
• mithril-signer
• mithril-relay
• mithril-client, mithril-client-cli, mithril-client-wasm
• mithril-common, mithril-stm
• Frontend: mithril-explorer (Next.js/React)
• Infra: mithril-infra (Terraform + Docker-Compose + scripts)
• Test suites & demos under demo/ and mithril-test-lab/
Key runtime components
A. Cardano Network
– Source of chain data, state snapshots, and stake distribution.
B. Mithril Signers
– Connect to Cardano node, compute partial signatures, expose HTTP or P2P endpoints to send signatures.
C. Mithril Relay
– Optional P2P overlay that forwards signature messages between signers and aggregator.
D. Mithril Aggregator
– HTTP server (src/http_server) exposing artifact and proof APIs.
– Services layer (src/services) builds, certifies, and snapshot artifacts.
– Persistence (internal/mithril-persistence, SQLite) for open messages, certificates, epoch settings.
– File uploader (GCP, local) to store artifacts in cloud or local storage.
E. Clients
– CLI (Rust) and WASM/JS clients fetch artifacts via HTTP, verify proofs using mithril-stm and mithril-common.
F. Explorer
– Next.js frontend consuming Aggregator HTTP API, displaying certificates and artifacts.
G. Infrastructure
– Terraform modules and Docker-Compose files to deploy Cardano nodes, signers, aggregators, relays, reverse proxy (Traefik), monitoring (Prometheus, Loki), and VMs.
H. Test Lab
– Private devnet (Docker scripts), end-to-end scenarios, stress tests to validate protocol.
Component interactions
• Cardano → Signers and Aggregator: fetch chain data & current stake.
• Signers → Relay (optional) → Aggregator: send individual signature messages.
• Aggregator → Persistence: store messages and certificates in SQLite.
• Aggregator → FileUploader → Cloud Storage: store certified snapshots (JSON, tarballs).
• Clients & Explorer → Aggregator HTTP API: retrieve snapshot lists, proofs, statistics.
• Clients (Rust/WASM) → mithril-stm & mithril-common: verify multi-signature proofs.
• Infrastructure (Terraform) → Deploy: all services and supporting Cardano nodes.
• Test Lab → Spins up full network stack → runs automated tests.
Architectural patterns & design principles
• Hexagonal architecture / Clean architecture in each Rust service:
• Commands → Services → Repositories → Database / FileStorage
• Dependency Injection (builder & containers modules)
• Event sourcing for Aggregator’s internal state machine (event_store module)
• CI/CD with GitHub Actions for building crates, Docker images, publishing NPM/Cargo packages
• Infrastructure as Code (Terraform, Nix) for reproducible environments