Design Decisions¶
Audience: Developers, contributors, and advanced researchers who want to understand why Crucible works the way it does.
1. CLI-First, UI as Wrapper¶
Decision¶
Every action is available via crucible <command>. The Streamlit dashboard is a separate read-only viewer.
Rationale¶
- Scriptability — experiments can be automated, CI-ified, and chained
- Docker-friendly — no GUI dependencies in the container
- Reproducibility — the exact command is recorded in the experiment history
- Composability —
crucible fork && crucible experiment run ...can be piped and scripted
Tradeoff¶
The CLI has a learning curve. New users must learn command names and flags before they can be productive. The tutorial and user guide exist to mitigate this. A future web UI could be built as a wrapper around the CLI — the CLI remains the source of truth.
2. Topology-Driven Chain Composition¶
Decision¶
Topology YAML files declare which chains to fork. The same attack can run on different topologies without modification.
Rationale¶
- Reusability — a single attack plugin works against any topology
- Separation of concerns — topology is orthogonal to attack logic and scenario setup
- Extensibility — adding a new chain config (e.g., Avalanche) doesn't affect existing experiments
Tradeoff¶
This introduces indirection — a researcher must understand how topology, scenario, and attack plugins compose. The configuration is declarative YAML, which is easier to reason about than imperative orchestration code.
3. Transparent Instrumentation via RPC Proxy¶
Decision¶
An HTTP proxy sits between the attack plugin and Anvil, automatically capturing artifacts from every transaction.
Rationale¶
- Zero instrumentation code — attack plugins never need to add logging
- Language-agnostic — works with Python,
forge script,cast send, or any JSON-RPC client - Universal coverage — every transaction is captured, not just the ones the researcher remembered to log
- Consistent format — all artifacts use the same JSONL schema, regardless of attack type
Tradeoff¶
- Proxies add latency — each transaction waits for the proxy to forward + receipt polling + trace
- Proxy is a single point of failure — if it crashes, artifacts are lost
- debug_traceTransaction dependency — storage diffs and balance changes depend on Anvil's
prestateTracer. If it fails (known Anvil nightly-build issue), only gas + events are captured
The latency tradeoff is acceptable because experiments are not performance-sensitive — we care about correctness, not throughput. The proxy failure mode is handled by graceful fallback (gas + events still captured) and prominent warning logging.
4. Determinism by Default (Opt-Out)¶
Decision¶
All deterministic flags (gas_price: 0, order: fifo, timestamp: fork_block, auto_mine: True) are defaults. Researchers must explicitly opt out.
Rationale¶
- Reproducibility is the primary goal — non-deterministic experiments are hard to debug and impossible to publish
- Opt-out, not opt-in, changes the default behavior — if a researcher does nothing, their experiment is deterministic
- Explicit opt-out documents the non-determinism — the config file shows exactly which flags were changed
Tradeoff¶
Some real-world exploits depend on non-deterministic behavior (e.g., MEV, frontrunning, timestamp dependencies). Researchers studying these must disable determinism and document why. This is a feature, not a bug — it forces explicit documentation of non-deterministic assumptions.
5. Plugin Architecture for Capabilities¶
Decision¶
New functionality arrives as plugins (attack, bridge, agent), not core rewrites.
Rationale¶
- Separation of concerns — the framework handles chain management, instrumentation, and artifacts; plugins handle domain logic
- Independent development — plugins can be developed, tested, and versioned independently
- Plugin registry —
PluginRegistry.discover()auto-finds plugins by scanningattacks/,bridges/,plugins/directories
Tradeoff¶
- Plugin API stability — changes to the
ExperimentContextor plugin ABCs can break existing plugins - Discovery conventions — plugins must follow directory naming conventions (name/name.py + plugin.yaml + evidence.yaml)
- No dynamic loading — plugins are loaded at experiment time, not hot-loaded during a running experiment
The API stability tradeoff is mitigated by versioned plugin manifests (plugin.yaml includes a version field).
6. Separation of Scenario and Experiment¶
Decision¶
Scenarios define environments (chain state, setup). Experiments pair a scenario + attack plugin for formal runs.
Rationale¶
- Reusability — the same scenario can be used with different attacks
- Testing — scenarios can be tested independently of attacks
- Composability — a single experiment YAML wires together topology + scenario + attack
Tradeoff¶
More files to manage: each attack needs a scenario YAML, an experiment YAML, and the plugin code. This is mitigated by the crucible attack init command which scaffolds all three at once.
7. Fidelity Levels Are Runtime-Enforced¶
Decision¶
The L0–L4 fidelity system is enforced by runtime checks (FidelityEnforcer) and pre-run gates (PublicationGate), not just documentation.
Rationale¶
- Prevents accidental overclaiming — a researcher cannot claim L3 without actually replaying an exploit transaction
- Self-validating — every experiment produces a fidelity check result in its manifest
- Trustworthy — reviewers can trust the declared fidelity level because it's verified programmatically
Tradeoff¶
- L4 enforcement is limited — we can check topology and bridge plugin, but we can't verify that the bridge plugin correctly simulates the real protocol
- False negatives — a fidelity check failure doesn't mean the reproduction is wrong, just that it doesn't meet the declared level
8. Archive RPC Independence (Blank Fork Mode)¶
Decision¶
When fork_block: null, Anvil starts as a standalone local EVM with zero remote dependencies.
Rationale¶
- Offline operation — researchers can work without archive RPC access
- CI-friendly — hermetic tests don't need remote infrastructure
- Instant startup — blank forks start in <1s vs 30s–5min for archive forks
Tradeoff¶
Blank forks have no historical state — they start from a genesis-like state. This means:
- Cannot reproduce historical exploits (requires archive fork)
- Cannot verify contract addresses via eth_getCode (no contracts deployed)
- Best suited for L4 validation experiments and development iteration
9. Per-Chain Proxy Isolation¶
Decision¶
Each chain in a topology gets its own RpcProxy instance with its own handler class (created via _make_handler() closure).
Rationale¶
- No shared state — each proxy forwards to its own Anvil, has its own
LogEmitter, its own thread pool - Independent failure — one proxy failing doesn't affect others
- Clear ownership — each chain's artifacts are in their own
chain_<name>/directory
Tradeoff¶
- More resource usage — N chains = N HTTP servers + N thread pools
- More ports — each proxy binds to a random port (mitigated by OS port management)
10. Python as the Plugin Language¶
Decision¶
Attack, bridge, and agent plugins are written in Python.
Rationale¶
- Rich ecosystem —
web3.py,eth-account, cryptographic libraries available - Accessible — Python is the most common language in blockchain security research
- Fast iteration — no compile step, dynamic imports via
importlib - Integration — easy to call Foundry's
forgefrom Python subprocess, easy to parse JSON-RPC responses
Tradeoff¶
- Performance — Python is slower than Rust or Go for compute-heavy operations
- Type safety — Python is dynamically typed (mitigated by Pydantic models and type hints)
- Deployment — Python environment must be managed (mitigated by Docker +
uv)
11. JSONL for Artifact Storage¶
Decision¶
Artifacts are stored as JSONL (JSON Lines) — one JSON object per line, gzip-friendly.
Rationale¶
- Append-friendly — new lines can be appended without parsing the entire file
- Streamable — can be processed line-by-line without loading into memory
- Diffable — easy to compare two artifact sets line-by-line (used by
diff.py) - Portable — every language can parse JSONL; no special tools needed
- Versionable — SHA-256 hashes are per-file, so integrity verification is straightforward
Tradeoff¶
- No schema enforcement — any component can write malformed JSONL (mitigated by
schema.pyvalidation) - No indexing — querying artifacts requires full scan (acceptable for research-scale data)
- Storage size — JSONL is not as compact as binary formats (mitigated by gzip for export bundles)
12. Lazy Imports in Public API¶
Decision¶
Heavy modules (web3, urllib, agent system) are lazy-loaded via __getattr__ in __init__.py.
Rationale¶
- Fast CLI startup —
crucible --helpshould respond instantly, not wait forweb3to import - Minimal dependency chain — importing
crucibledoesn't trigger heavy transitive imports - Graceful degradation — agent system imports fail only when agent functionality is actually used
Tradeoff¶
- Import-time errors become runtime errors — a broken agent module won't be discovered until someone runs an agent experiment
- Type checking complexity — lazy imports require
TYPE_CHECKINGguards
13. Fork Cache Fingerprinting¶
Decision¶
Fork caches are fingerprinted with provenance data (provider identity, block number, chain ID, Foundry version, config hash) and managed by a policy-controlled CacheManager.
Rationale¶
- Auditability —
crucible cache inspectshows exactly how each cache entry was created - Stale detection —
CacheManager.verify_manifest()detects provider changes, block changes, version drift - Policy control —
strictpolicy invalidates on any mismatch;permissivepolicy warns but continues
Tradeoff¶
- Cache misses on version changes — every Foundry nightly update invalidates the cache
- Storage overhead — cache manifests consume minimal space but the cache directory can grow large (mitigated by
invalidate_all())
14. Agent Privilege Levels¶
Decision¶
LLM agents have configurable privilege levels (low/medium/high) that gate tool access.
Rationale¶
- Safety — restricts what an autonomous agent can do on a forked chain
- Progressive disclosure — researchers can start agents at low privilege and increase as they gain confidence
- Auditability — all agent actions are logged with privilege level
Tradeoff¶
- LOW privilege is very limited — read-only queries only, which may not be enough for complex exploits
- HIGH privilege is dangerous — full access including time manipulation; must be used carefully
15. No CI/CD Pipeline¶
Decision¶
The project runs locally without CI. Tests are run on-device.
Rationale¶
- Docker dependency — tests need Anvil, which needs x86 architecture and Foundry
- Offline development — researchers work on air-gapped machines, lab workstations
- Simplicity — no CI configuration to maintain, no provider lock-in
Tradeoff¶
- No automated regression testing — all testing is manual or scripted
- No coverage enforcement — researchers must run tests themselves
- Golden fixture tests deferred — checked-in state fixtures were removed because they provide no local benefit
See Also¶
| Doc | What It Covers |
|---|---|
| Technical Overview | System philosophy and architecture at a glance |
| Architecture Deep Dive | Complete component map with code structure |
| Plugin Development Guide | Writing attack, bridge, and agent plugins (in website/) |
| Capabilities & Limitations | What the testbed can and cannot do |