Architecture
Key Components
- RPC Clients: gRPC connections to all verifiers and operators
- Key Caches: Thread-safe storage for collected public keys
- Database: Stores deposit states and compatibility data
- Bitcoin RPC: Queries blockchain state
Core Responsibilities
1. Key Collection and Caching
The aggregator maintains caches of verifier and operator public keys to avoid repeated network calls:- Check Cache: If all keys are already collected, return immediately
- Parallel Fetch: For missing keys, query entities in parallel
- Validate Uniqueness: Ensure no duplicate keys across entities
- Update Cache: Store successful results for future use
- Error Handling: Return error only if not all keys could be collected
Verifier Key Collection
PUBLIC_KEY_COLLECTION_TIMEOUT
Operator Key Collection
2. Participating Entity Selection
For each deposit, the aggregator identifies which configured entities are participating:Participating Verifiers
clients(): Get RPC clients for all participating verifiersids(): Get identifiers for logging and error messages
3. Key Collection and Distribution
The aggregator orchestrates the complex process of collecting keys from operators and distributing them to verifiers:Workflow
Setup Broadcast Channels
Create channels for operator keys with capacity based on participant counts:
- BitVM assert Winternitz public keys
- Challenge acknowledgment hashes
- Deposit-specific commitments
4. Entity Status Monitoring
The aggregator provides a unified view of all entity statuses:Status Collection
Response Format:5. Compatibility Checking
The aggregator ensures all actors are running compatible software versions:Compatibility Scopes
Compatibility Data Collection
Compatibility Validation
Implemented via theCompatibilityParams trait:
- Protocol version
- Network (mainnet, testnet, regtest, etc.)
- Security council configuration
- Protocol parameters (bridge amount, collateral, etc.)
- BitVM parameters
Background Tasks
Aggregator Metric Publisher
Publishes metrics about aggregator and entity health:- Number of reachable operators
- Number of reachable verifiers
- Average sync status across entities
- Compatibility status
- Recent deposit activity
AGGREGATOR_METRIC_PUBLISHER_POLL_DELAY (typically 30 seconds)
Communication Patterns
Deposit Coordination Flow
Timeout Strategy
The aggregator uses different timeouts for different operations:| Operation | Timeout | Constant |
|---|---|---|
| Public key collection | 30s | PUBLIC_KEY_COLLECTION_TIMEOUT |
| Operator key retrieval | 60s | OPERATOR_GET_KEYS_TIMEOUT |
| Verifier key distribution | 60s | VERIFIER_SEND_KEYS_TIMEOUT |
| Entity status polling | 10s | ENTITY_STATUS_POLL_TIMEOUT |
| Compatibility data | 15s | ENTITY_COMP_DATA_POLL_TIMEOUT |
| Restart background tasks | 30s | RESTART_BACKGROUND_TASKS_TIMEOUT |
Error Handling
Graceful Degradation
The aggregator continues operating even if some entities are unreachable: Key Collection: Returns error only if ALL keys cannot be collectedError Propagation
Errors that DO fail the operation:- Deposit coordination: Any participant failure aborts deposit
- Compatibility check: Any incompatibility fails the check
- Key distribution: Timeout or partial delivery fails the operation
Security Properties
Key Validation
✅ Ensures:- All verifier keys are unique
- All operator keys are unique
- Keys match expected deposit participants
- Stale keys are never used
Deposit Coordination
✅ Prevents:- Partial deposits with missing signatures
- Signature aggregation with wrong nonces
- Distribution of keys to non-participating verifiers
Compatibility Enforcement
✅ Detects:- Version mismatches across actors
- Network configuration differences
- Protocol parameter inconsistencies
Performance Optimizations
Parallel Operations
The aggregator maximizes parallelism:Broadcast Channels
Using broadcast channels for operator key distribution:Key Caching
Public keys are cached to avoid repeated network calls:- First call: Fetch from all entities
- Subsequent calls: Return from cache immediately
- Cache invalidation: Only on error or explicit reset
Related Documentation
Actor Overview
Learn about the actor model architecture
Verifier
See how verifiers work with aggregator
Operator
Understand operator coordination