Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Simulation Failure / Bug Report
about: Report a deterministic simulation failure or invariant violation
title: "[DST] "
labels: ["bug", "dst"]
---

## Reproducer Command

```bash
cargo run --release -p rustfs-dst-cli -- repro --scenario <SCENARIO> --topology <4x4|3x2|4x2> --seed <SEED>
```

## Violated Invariant

Describe which invariant failed (linearizability, bit-exact integrity, crash atomicity, lock fencing, heal convergence).

## Expected Behavior

## Actual Output / Trace Digest
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/simulation_scenario.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: New Simulation Scenario
about: Propose a new deterministic simulation scenario or fault injector
title: "feat(sim): "
labels: ["enhancement", "dst"]
---

## Target RustFS Subsystem

(e.g., `ecstore`, `lock`, `heal`, `scanner`, `replication`, `multipart`)

## Fault Model & Invariants

## Proposed Deterministic Properties (`always` / `sometimes` / `reachable`)
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Summary

Describe the changes and the RustFS invariants or simulation capabilities added.

## Related Issues

Closes #

## Verification

- [ ] `cargo fmt --all -- --check`
- [ ] `cargo clippy --workspace --all-targets -- -D warnings`
- [ ] `cargo test --workspace`
- [ ] `cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 4x4 --seed 2026`
- [ ] `cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x4 --seeds 50`
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: DST CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
check-and-test:
name: Format, Clippy, Unit & DST Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --workspace --all-targets -- -D warnings

- name: Run workspace test suite
run: cargo test --workspace

- name: Verify bit-exact determinism (4x4 & 3x2)
run: |
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 4x4 --seed 2026
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 3x2 --seed 2026

- name: Run 50-seed multi-topology DST campaign
run: |
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x4 --seeds 50
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 3x2 --seeds 50
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x2 --seeds 25
37 changes: 37 additions & 0 deletions .github/workflows/nightly-dst.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Nightly DST Campaign

on:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
inputs:
seeds:
description: "Seeds per scenario per topology"
required: false
default: "500"

permissions:
contents: read

jobs:
nightly-sweep:
name: Nightly Sweep (${{ matrix.topology }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
topology: ["4x4", "3x2", "4x2"]
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Run multi-seed DST campaign
run: |
SEEDS="${{ github.event.inputs.seeds || '500' }}"
cargo run --release -p rustfs-dst-cli -- run \
--scenario all \
--topology "${{ matrix.topology }}" \
--seeds "$SEEDS"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/target
Cargo.lock
**/*.rs.bk
.DS_Store
*.log
antithesis-output/
dst-artifacts/
61 changes: 61 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2026 RustFS Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[workspace]
resolver = "3"
members = [
"crates/rustfs-dst-runtime",
"crates/rustfs-dst-faults",
"crates/rustfs-dst-sim",
"crates/rustfs-dst-cli",
]

[workspace.package]
version = "0.1.0"
edition = "2024"
license = "Apache-2.0"
repository = "https://github.com/rustfs/DST"
homepage = "https://rustfs.com"
authors = ["RustFS Team <hello@rustfs.com>"]
rust-version = "1.88.0"

[workspace.dependencies]
rustfs-dst-runtime = { path = "crates/rustfs-dst-runtime", version = "0.1.0" }
rustfs-dst-faults = { path = "crates/rustfs-dst-faults", version = "0.1.0" }
rustfs-dst-sim = { path = "crates/rustfs-dst-sim", version = "0.1.0" }

async-trait = "0.1"
bytes = { version = "1", features = ["serde"] }
clap = { version = "4", features = ["derive"] }
rand = "0.9"
rand_chacha = "0.9"
rayon = "1.10"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"
thiserror = "2"
tokio = { version = "1", features = ["full", "test-util"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
turmoil = "0.7"
uuid = { version = "1", features = ["v4", "serde"] }

[workspace.lints.rust]
unsafe_code = "forbid"

[workspace.lints.clippy]
all = { level = "warn", priority = -1 }
dbg_macro = "warn"
todo = "warn"
unimplemented = "warn"
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: test lint fmt determinism run-4x4 run-3x2 run-4x2

fmt:
cargo fmt --all -- --check

lint:
cargo clippy --workspace --all-targets -- -D warnings

test:
cargo test --workspace

determinism:
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 4x4 --seed 2026
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 3x2 --seed 2026

run-4x4:
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x4 --seeds 100

run-3x2:
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 3x2 --seeds 100

run-4x2:
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x2 --seeds 100
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# RustFS DST — Deterministic Simulation Testing

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)

**RustFS DST** is the official Deterministic Simulation Testing (DST) framework, runtime trait abstraction layer, virtual fault simulator, and multi-seed correctness verifier for [RustFS](https://github.com/rustfs/rustfs).

Inspired by FoundationDB's Flow simulator, Tokio [`turmoil`](https://github.com/tokio-rs/turmoil), [`madsim`](https://github.com/madsim-rs/madsim), and [Antithesis](https://antithesis.com/), RustFS DST abstracts every source of non-determinism in a distributed storage engine behind clean Rust traits so complex multi-node failure modes execute deterministically inside a single process and reproduce bit-for-bit from a single `u64` seed.

## Core Architecture

```
┌──────────────────────────────────────────────┐
│ RustFS Storage Engine Subsystems │
│ (ECStore · Distributed Lock · Heal · GC) │
└──────────────────────┬───────────────────────┘
│
Unified Determinism Traits
(`rustfs-dst-runtime`)
┌────────────────────┬───────────────┴──────────────┬────────────────────┐
▼ ▼ ▼ ▼
trait Clock trait RngSource trait Network trait DiskIo
├─ RealClock ├─ RealRng ├─ SimNetwork ├─ RealDiskIo
└─ SimClock └─ SimRng (ChaCha8 + fork) │ (Swizzle-Clog, └─ SimDiskIo
(skew, drift, │ asymmetric cuts, (volatile vs
virtual time) │ reply drops) durable fsync,
└─ turmoil::net power loss,
(virtual TCP) bitrot, ENOSPC)
```

## Workspace Crates

| Crate | Purpose |
|---|---|
| [`rustfs-dst-runtime`](crates/rustfs-dst-runtime) | Unified traits (`Clock`, `RngSource`, `Network`, `DiskIo`, `RuntimeEnv`) with production, in-memory deterministic simulator, Tokio `turmoil` virtual TCP adapter, and `madsim` compatibility layer. |
| [`rustfs-dst-faults`](crates/rustfs-dst-faults) | Two-stage deterministic `Buggify` injector, `CodeProbe` coverage tracker with Antithesis-compatible JSONL assertion emission, RustFS commit `CrashPoint` registry, and `SwizzleClogScheduler`. |
| [`rustfs-dst-sim`](crates/rustfs-dst-sim) | Simulated RustFS distributed erasure-coded storage engine (`SimECStore`) with GF(2^8) Cauchy Reed-Solomon, `xl.meta` atomic two-phase commit, quorum locking, online healing, real `turmoil` TCP cluster tests, and a 6-invariant `ConsistencyOracle`. |
| [`rustfs-dst-cli`](crates/rustfs-dst-cli) | Joshua-style parallel multi-seed runner (`rustfs-dst run`), single-seed bit-exact reproducer (`rustfs-dst repro`), and determinism prover (`rustfs-dst verify-determinism`). |

## Verified Invariants

1. **Linearizability & Monotonic Read-After-Write**: Readers never observe a generation older than an acknowledged write or delete, even across degraded quorums (`W + R > N`).
2. **Bit-Exact Data Integrity**: Every readable object matches the exact SHA-256 of a submitted payload; silent bitrot up to the parity limit is detected and reconstructed transparently.
3. **Crash Atomicity (Old-or-New-Never-Mixed)**: Abrupt power loss (`SimDiskIo::crash_and_reboot`) at any RustFS `xl.meta` commit window drops un-fsynced page-cache state without corrupting previously committed versions.
4. **Quorum Safety**: Writes fail closed on minority partitions and roll back partial drive writes cleanly; reply drops after remote apply are modeled as indeterminate outcomes.
5. **Distributed Lock Mutual Exclusion & Monotonic Fencing**: Monotonic-clock quorum leases remain immune to wall-clock skew jumps and issue strictly increasing fencing epochs.
6. **Heal Convergence & Zero Orphan Leaks**: Post-heal, every drive in `4x4` (16 drives, EC:4), `3x2` (6 drives, EC:3), and `4x2` (8 drives, EC:4) converges to the identical generation with zero leaked `.rustfs.sys/tmp/` artifacts.

## Quickstart

```bash
# Run the full unit and integration test suite
cargo test --workspace

# Prove bit-for-bit determinism across every scenario
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 4x4 --seed 2026

# Run a 100-seed parallel DST campaign on 4x4 and 3x2 topologies
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x4 --seeds 100
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 3x2 --seeds 100

# Replay a single failing seed deterministically
cargo run --release -p rustfs-dst-cli -- repro --scenario swizzle-clog-chaos --topology 4x4 --seed 42
```

## Supported Topologies

| Topology | Nodes × Drives | Total Drives | Parity (`m`) | Data (`k`) | Read Quorum (`R`) | Write Quorum (`W`) |
|---|---:|---:|---:|---:|---:|---:|
| `4x4` | 4 × 4 | 16 | 4 | 12 | 12 | 12 |
| `3x2` | 3 × 2 | 6 | 3 | 3 | 3 | 4 |
| `4x2` | 4 × 2 | 8 | 4 | 4 | 4 | 5 |

## Documentation

- [Architecture & Upstream Trait Adoption Blueprint (`rustfs/rustfs`)](docs/architecture.md)
- [Simulation Backends: In-Process, Turmoil, Madsim & Antithesis](docs/antithesis.md)
- [Jepsen Distributed Verification Companion (`rustfs/Jepsen`)](https://github.com/rustfs/Jepsen)

## License

Licensed under the [Apache License, Version 2.0](LICENSE).
15 changes: 15 additions & 0 deletions antithesis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2026 RustFS Team
# Licensed under the Apache License, Version 2.0

FROM rust:1.88-slim-bookworm AS builder
WORKDIR /src
COPY . .
RUN cargo build --release -p rustfs-dst-cli

FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /src/target/release/rustfs-dst /usr/local/bin/rustfs-dst
ENV ANTITHESIS_OUTPUT_DIR=/tmp/antithesis
RUN mkdir -p /tmp/antithesis
ENTRYPOINT ["/usr/local/bin/rustfs-dst"]
CMD ["run", "--scenario", "all", "--topology", "4x4", "--seeds", "100"]
19 changes: 19 additions & 0 deletions antithesis/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Antithesis composer manifest for RustFS DST workload execution.
services:
dst-workload-4x4:
build:
context: ..
dockerfile: antithesis/Dockerfile
environment:
ANTITHESIS_OUTPUT_DIR: /tmp/antithesis
RUST_LOG: info
command: ["run", "--scenario", "all", "--topology", "4x4", "--seeds", "250"]

dst-workload-3x2:
build:
context: ..
dockerfile: antithesis/Dockerfile
environment:
ANTITHESIS_OUTPUT_DIR: /tmp/antithesis
RUST_LOG: info
command: ["run", "--scenario", "all", "--topology", "3x2", "--seeds", "250"]
22 changes: 22 additions & 0 deletions crates/rustfs-dst-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "rustfs-dst-cli"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
description = "Joshua-style multi-seed deterministic simulation runner and reproducer CLI for RustFS."

[[bin]]
name = "rustfs-dst"
path = "src/main.rs"

[lints]
workspace = true

[dependencies]
clap.workspace = true
rayon.workspace = true
rustfs-dst-faults.workspace = true
rustfs-dst-sim.workspace = true
serde_json.workspace = true
Loading
Loading