Skip to content

Reproducibility Guide

Reproducibility is integral to the Crucible testbed's architectural design. The Technical Overview explains the philosophy behind determinism-by-default, cache fingerprinting, and fidelity enforcement. For the design rationale behind each reproducibility mechanism, see the Design Decisions document.

What Makes A Crucible Run Reproducible

Every crucible experiment run pins the following in run_manifest.json:

Field Source Purpose
git_commit git rev-parse HEAD Code version anchor
git_dirty git status --porcelain Detect uncommitted changes
foundry_version forge --version Anvil/forge binary version
python_version sys.version Python version
platform sys.platform OS identifier
config_fingerprint SHA-256 of testbed.yaml Detect config drift
docker_mode Detected from env Container vs native
cache_mode CacheManager.mode() Cold/warm cache state
cache_fingerprint SHA-256 of all cache manifests Cache identity
experiment_file_hash SHA-256 of experiment YAML Experiment definition pin
evidence_hash SHA-256 of evidence.yaml Attack definition pin
scenario_hash SHA-256 of scenario.yaml Environment definition pin
run_id DS-YYYY-NNNNN format Monotonically increasing, year-resetting counter
timestamps UTC ISO-8601 Chronological anchor

Reproducibility Modes

Mode Description Requirements
Docker (preferred) Containerized environment with pinned dependencies Docker, git
Local Native Python + Foundry Python 3.11+, Foundry, archive RPC
Cached fork Reuses previously fetched RPC cache Docker or local + existing .fork_cache
Artifact replay Inspect exported bundle without re-execution Only the datasets/ export bundle

Provenance Verification

After any experiment run, verify reproducibility by checking:

# 1. Check the run manifest
cat logs/*/<run_id>/run_manifest.json | jq '.provenance'

# 1b. Verify config fingerprint manually
# The config fingerprint is computed via get_config_fingerprint() in crucible.provenance
# It covers testbed.yaml and active topology settings.

# 2. Check log integrity
cat logs/*/<run_id>/log_integrity.json

# 3. Run twice and diff
crucible diff <run_a> <run_b>

# 4. Export and verify bundle
crucible export <run_id>
crucible verify datasets/<run_id>

Cache Policy & Determinism

Cache state impacts execution latency but does not alter deterministic outcomes. A strict policy ensures cache fingerprints align with the current configuration:

# testbed.yaml
fork_cache:
  enabled: true
  cache_policy: strict     # invalidates on provider/block/version mismatch
  # or
  cache_policy: permissive # warns but doesn't invalidate

The cache_mode in run_manifest.json records whether the run used cold cache (first fork), warm cache (subsequent forks), or budget cache (RPC budget-limited mode).

Publishing A Run

# 1. Run with publication gates
crucible experiment run experiments/attack.yaml --publication-mode

# 2. Export the bundle
crucible export <run_id> --format tar-gz

# 3. Verify the export
crucible verify datasets/<run_id>
cat datasets/<run_id>/bundle_hash.txt

The export bundle is entirely self-contained; it may be transferred and verified independently of the original workspace.

Export Bundle Structure

The exported bundle (.tar.gz or uncompressed directory) built by crucible.export.ExportBundle contains: - artifact_bundle_manifest.json: Hashes of every file in the bundle. - run_manifest.json: Full provenance and execution metadata. - evidence.yaml: The attacker's claims and fidelity level. - plugin.yaml: Attack plugin configuration. - scenario.yaml: Environment preconditions. - log_integrity.json: Original runtime hashes for sub-artifacts. - All JSONL streams (events.jsonl, storage_diffs.jsonl, gas_profile.jsonl, run.jsonl, etc.) - (Optional) .protected marker indicating publication status.

Common Reproducibility Pitfalls

When reproducing historical exploits or authoring new attack packs, researchers commonly encounter the following issues that break determinism or fidelity.

Infrastructure & Environment Issues

Pitfall Symptom Solution
Stale meta files in Docker volume anvil_dumpState on wrong port Clean states/*.meta.json before each fork
Daemon Anvil fork block mismatch Experiment uses wrong fork block Use single-container mode instead for precise control
Port TIME_WAIT blocking restart New Anvil can't bind Crucible automatically polls ports before restarting, but manual resets may require waiting 10-30s
Checkpoints snapshotting dead chains anvil_dumpState on stale meta file Crucible filters checkpoints to active topologies

Research Data Errors

The most common cause of reproduction failure is incorrect research data in the evidence.yaml or plugin file.

Pitfall Symptom Solution
Contract address is actually an EOA Contract has no code error during setup Verify the address on a block explorer. It must be a deployed contract, not the attacker's wallet.
Wrong fork block Exploit tx reverts, state doesn't match Fork block must be exactly exploit_block - 1
Precompile/Deployer fails on archive node anvil_setBalance fails on new address Some archive providers don't support setting balances on addresses with no historical state. Wrap bridge deployments in try/except.

Verification Checklist for New Attacks

Before running an experiment: - [ ] Clean stale meta files: rm -f states/*.meta.json (if using Docker) - [ ] Set the correct fork block in testbed.yaml or testbed.local.yaml - [ ] Verify the RPC provider supports archive depth at your fork block - [ ] Run twice and diff: crucible diff <run_a> <run_b> - [ ] Check all 4 metrics (gas, storage, events, balances) are equal

Baseline System

Crucible uses a dual-verification baseline system that ensures reproducibility across runs:

How Baselines Work

  1. Capture — After forking and bootstrapping, crucible baseline capture <scenario>:
  2. Dumps the full EVM state for each chain via anvil_dumpState
  3. Canonicalizes and SHA-256 hashes the state
  4. Captures a live state hash from the running chain
  5. Writes a baseline manifest YAML with both hashes

  6. Verify — Before running an experiment, crucible baseline verify <scenario>:

  7. Re-computes the snapshot file hash and compares it to the manifest
  8. If the chain is running: also compares the live chain state against the captured state hash
  9. This dual check catches both file corruption AND environment drift

  10. Restore — crucible reset --mode soft loads the baseline snapshot back into the running chain via anvil_loadState (<5s)

Baseline Storage

states/baseline/
├── <scenario>.baseline.yaml      # Manifest with hashes and metadata
├── <scenario>.<chain>.json       # Full EVM state snapshot
└── <scenario>.<chain2>.json      # One per chain in topology

When Baselines Go Stale

Situation Detection Fix
Changed RPC provider Live state hash mismatch baseline verify catches it
Changed fork block State completely different baseline verify catches it
Changed topology (different chains) Missing chain snapshots Re-capture with baseline capture
Snapshot file deleted/corrupted File hash mismatch Re-capture with baseline capture
# Capture a new baseline after environment changes
crucible setup --topology single
crucible baseline capture my_scenario --topology single

Cache System & Fingerprinting

Crucible caches fork state from archive RPCs to accelerate repeated execution. The cache subsystem maintains its own provenance tracking:

Cache Policy

Configured in testbed.yaml:

fork_cache:
  enabled: true
  path: ".fork_cache"
  cache_policy: permissive  # or "strict"
  • strict — Invalidates cache on ANY mismatch (provider, foundry version, config fingerprint). Ensures bit-identical forks but may re-fetch frequently.
  • permissive — Warns on mismatch but doesn't invalidate. Faster for development, uses cache even if config changed slightly.

Cache Provenance

Each cache entry has a manifest tracking: - RPC provider URL (fingerprinted, not stored raw) - Fork block number - Chain ID - Foundry version at time of caching - Config fingerprint (SHA-256 of testbed.yaml)

# Inspect cache entries
crucible cache inspect

# Compute aggregate fingerprint (SHA-256 of all manifests)
crucible cache fingerprint

# Verify a specific entry
crucible cache verify --chain ethereum --fork-block 15259100

# Clear stale cache
crucible cache clean --chain ethereum

The cache_mode in run_manifest.json records whether the run used cold (first fork), warm (subsequent), or budget (RPC-limited) cache.

Publication Gates

Publication gates enforce research-quality standards before a run completes. They are optional but recommended for formal publications:

Enabling Publication Gates

crucible experiment run experiments/attack.yaml --publication-mode

Or configure them to always run:

# testbed.yaml
publication:
  enabled: true
  require_foundry_pinned: true        # Foundry version must match testbed.yaml
  require_baseline_verified: true     # Baseline must pass verify() before run
  require_provenance_complete: true   # Git commit, config fingerprint must be available
  fidelity_enforcement: false         # When True, enforces fidelity at runtime (default check-based)

What Each Gate Checks

Gate Checks Fails When
Foundry pinned Installed Foundry version matches testbed.yaml Version mismatch, or required_version not set
Baseline verified Latest baseline passes verify() Missing baseline, hash mismatch, live state drift
Provenance complete Git commit available, config fingerprint computed Dirty working tree, missing .git, config parse failure
Fidelity enforcement Runtime behavior matches declared fidelity level Missing trace artifacts, wrong chain topology, no exploit transactions

Note: Each gate evaluation returns a GateResult object containing passed (bool), reason (str), and fatal (bool).

Run Tiers

Every experiment run is assigned a retention tier that controls cleanup behavior:

Tier Default For Auto-Cleaned Preserved By
scratch All runs (default) After 7 days Nothing
saved --tier saved flag Never Explicit flag
published crucible publish Never .protected marker in dataset
# Run and immediately save
crucible experiment run experiments/attack.yaml --tier saved

# Promote an existing run to published
crucible publish DS-2026-00155

# The run is now protected from all auto-cleanup

Publication Lifecycle

1. Run experiment          → crucible experiment run ... --tier saved
2. Verify artifacts        → crucible verify logs/<experiment>/<run_id>
3. Promote to published    → crucible publish <run_id>
4. Export publication bundle → crucible export <run_id> --format tar-gz
5. Upload to Zenodo/archive → Upload datasets/<run_id>.tar.gz

Pre-Reproduction Workflow

Prior to executing any reproduction, the environment must be initialized:

# 1. Initialize workspace
crucible init

# 2. Validate environment
crucible doctor

# 3. Set up and capture baseline
crucible setup --topology <topology>
crucible baseline capture <scenario> --topology <topology>

# 4. Verify baseline
crucible baseline verify <scenario>

See Also

Doc What It Covers
Technical Overview System architecture, core concepts, data flow, design principles
Design Decisions 15 key architectural decisions with rationale and tradeoffs
Plugin Development Guide Writing attack, bridge, and agent plugins — step-by-step
Benchmark Attack Packs Per-attack fidelity assessment, run results, determinism verification
Capabilities & Limitations Honest assessment of what Crucible can and cannot do
Fidelity Guide Fidelity levels (L0–L4), enforcement rules, --no-fidelity usage

Formal Reproducibility Checklist

  • Workspace initialized with crucible init
  • Environment validated with crucible doctor
  • Baseline captured and verified
  • Git commit pinned in run_manifest.json
  • Foundry version recorded
  • Baseline verified before run
  • Cache mode and fingerprint recorded
  • Log integrity hashes written
  • Experiment run twice with identical diffs
  • Export bundle verified with crucible verify
  • Cross-provider reproduction documented
  • Contract addresses verified on Etherscan (not EOAs)
  • Fork block verified against exploit transaction
  • RPC provider tested for archive depth
  • Stale meta files cleaned before forking
  • Determinism verified via crucible diff