System Maintenance & Architecture Guide¶
This document outlines the architectural map, internal directory structure, testing procedures, and technical boundaries for the Crucible testbed. It serves as the authoritative reference for maintaining and extending the core system.
1. Project Overview¶
Crucible is a modular EVM bridge security research testbed designed for deterministic exploit reproduction and rigorous artifact collection. Its primary capabilities include:
- EVM State Forking: Forking any EVM chain at any historical block via Foundry/Anvil.
- Deterministic Replay: Executing historical bridge exploits in a controlled, isolated environment.
- Structured Artifact Collection: Emitting canonical JSONL logs, state diffs, and gas profiles.
- Rapid Environment Reset: Utilizing a 3-tier state reset (soft, medium, hard) for rapid iteration.
- Baseline Verification: Capturing and verifying golden baseline fingerprints to prevent environmental drift.
Architecture at a Glance¶
CLI (crucible/cli.py → crucible/commands/*.py)
│
├── Chain Manager — Orchestrates Anvil subprocesses and node lifecycle
├── Scenario Engine — Parses and executes discrete scenario steps
├── Experiment Runner — Manages formal research runs and baseline enforcement
├── Plugin Registry — Discovers, loads, and validates plugins
├── Baseline System — Captures golden baselines and verifies environment integrity
├── Structured Logger — Streams 5 distinct JSONL research artifacts
└── Dashboard (Streamlit) — Provides a graphical interface for orchestration
Key Subsystems¶
| File / Module | Responsibility |
|---|---|
crucible/cli.py |
Command-line interface entry point. |
crucible/config.py |
Strict YAML configuration parsing via Pydantic. |
crucible/chain_manager.py |
Local blockchain (Anvil) process and state lifecycle management. |
crucible/rpc.py |
Resilient JSON-RPC client featuring provider failover and rate limiting. |
crucible/baseline.py |
Baseline capture, fingerprint computation, and state restoration. |
crucible/scenario.py |
Scenario YAML parsing and discrete step execution. |
crucible/experiment.py |
Formal experiment orchestration, matrix running, and checkpoint resumption. |
crucible/logging.py |
JSONL emitter for deterministic artifact generation. |
crucible/plugin.py |
Dynamic plugin discovery and schema validation. |
crucible/sdk.py |
Plugin interface definitions (AttackPlugin, BridgePlugin, etc.). |
crucible/diff.py |
Canonicalized comparison of experiment runs. |
2. Directory Structure¶
The repository is organized into distinct domains separating core execution logic from research artifacts and operational configurations.
Root Directory¶
| Directory / File | Purpose |
|---|---|
crucible/ |
Core Python package containing orchestration, execution, and instrumentation logic. |
dashboard/ |
Streamlit browser application and UI panels. |
docs/ |
Formal project documentation and design specifications. |
attacks/ |
Concrete attack plugins and exploit reproductions. |
scenarios/ |
Scenario definitions (setup and pre-exploit state configurations). |
experiments/ |
Formal experiment YAML files linking topologies, scenarios, and attacks. |
topologies/ |
Network topology profiles (e.g., single-chain, dual-chain, multi-chain bridge). |
abis/ |
Contract ABIs organized by protocol. |
bridges/ |
Infrastructure plugins modeling cross-chain message passing (e.g., Nomad, Wormhole). |
tests/ |
Unit and integration test suites. |
scripts/ |
Shell utilities for artifact evaluation and cross-provider reproduction. |
datasets/ |
Exported publication bundles and verifiable artifact archives (gitignored). |
logs/ |
Ephemeral experiment run logs and traces (gitignored). |
states/ |
Serialized Anvil state files for baseline management (gitignored except golden baselines). |
.fork_cache/ |
Local RPC response caching to minimize external provider load (gitignored). |
bootstrap.py |
Custom state preparation and deterministic seeding logic. |
3. Testing Procedures¶
The testbed includes comprehensive unit testing to ensure deterministic behavior and core system integrity.
# Execute standard unit test suite
pytest tests/unit/ -q
# Execute with verbose output
pytest tests/unit/ -v
# Execute specific subsystems
pytest tests/unit/test_config.py -v
# Execute with coverage reporting
pytest tests/unit/ --cov=crucible
# Validate internal documentation link integrity
pytest tests/unit/test_docs_links.py -v
Note on Integration Testing: Integration and scenario tests housed in
tests/integration/require a live Anvil instance and valid RPC provider configuration. They are deliberately segregated from the fast unit test suite.
4. Extension and Authoring¶
The testbed is designed for extensibility. Refer to the specific guides for step-by-step authoring procedures:
- Adding Attack Packs: Refer to the
Attack Pack Guideand use thecrucible attack extract <tx_hash>utility. - Adding Plugins: Refer to the
Plugin Development Guidefor implementing theAttackPluginorBridgePlugininterfaces. - Adding Topologies: Define new
.yamlprofiles in thetopologies/directory. - CLI Usage: Refer to the
CLI Referencefor operational commands.
5. System Constraints & Technical Boundaries¶
Transparency regarding the testbed's limitations is a critical requirement for rigorous research.
Infrastructure Limitations¶
- EVM-Only Execution: The Crucible testbed explicitly models the Ethereum Virtual Machine. Attacks involving non-EVM execution environments (e.g., Solana, Harmony) are restricted to modeling the EVM-side consequences (e.g., forged VAA acceptance).
- Archive Node Depth: Free-tier archive RPC providers strictly limit historical block depth. Simulating deep historical exploits on high-throughput chains (e.g., BSC, Polygon) necessitates paid provider tiers.
- Provider Rate Limits: Standard multi-chain setups will quickly encounter HTTP 429 errors on free-tier providers. The testbed's
crucible.rpcsubsystem employs exponential backoff, but dedicated API keys are recommended for complex matrix runs.
Operational Boundaries¶
- Publication Workflows: Ensuring full reproducibility requires formal baseline verification. Utilizing
--no-baselineinvalidates the deterministic guarantee and should only be used during local development. - Cross-Platform Compatibility: While the
cruciblePython CLI is cross-platform, certain artifact evaluation workflows housed inscripts/utilize Bash and necessitate a POSIX-compliant environment (Linux, macOS, or WSL).