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
41 changes: 39 additions & 2 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
- precompile_request_deserialize
- library_deserialize
- package_deserialize
- package_semantic_deserialize
- project_toml_parse
- project_load
- project_assemble
timeout-minutes: 15
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
Expand All @@ -51,9 +55,42 @@ jobs:
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked
- name: Generate fuzz seed corpus
env:
TARGET: ${{ matrix.target }}
GENERATED_CORPUS_TARGETS: >-
mast_forest_deserialize program_deserialize kernel_deserialize
stack_io_deserialize advice_inputs_deserialize operation_deserialize
execution_proof_deserialize precompile_request_deserialize
library_deserialize package_deserialize package_semantic_deserialize
run: |
if [[ " $GENERATED_CORPUS_TARGETS " == *" $TARGET "* ]]; then
make fuzz-seeds
else
echo "No generated seed corpus for $TARGET"
fi
- name: Run fuzz target (smoke test)
env:
TARGET: ${{ matrix.target }}
run: |
FUZZ_TARGET="$(cargo +nightly fuzz build --help | awk '
$0 ~ /^ --target <TRIPLE>/ { in_target = 1; next }
in_target && /\[default:/ {
sub(/^.*\[default: /, "")
sub(/\].*$/, "")
print
exit
}
')"
test -n "$FUZZ_TARGET"
# Build the fuzz target first
cargo +nightly fuzz build --fuzz-dir miden-core-fuzz ${{ matrix.target }}
cargo +nightly fuzz build --target "$FUZZ_TARGET" --fuzz-dir miden-core-fuzz "$TARGET"
# Run directly to avoid cargo-fuzz wrapper SIGPIPE issue
miden-core-fuzz/target/x86_64-unknown-linux-gnu/release/${{ matrix.target }} -max_total_time=60 -runs=10000
FUZZ_BIN="miden-core-fuzz/target/$FUZZ_TARGET/release/$TARGET"
test -x "$FUZZ_BIN"
CORPUS_DIR="miden-core-fuzz/corpus/$TARGET"
if [ -d "$CORPUS_DIR" ]; then
"$FUZZ_BIN" "$CORPUS_DIR" -max_total_time=60 -runs=10000
else
"$FUZZ_BIN" -max_total_time=60 -runs=10000
fi
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Refactor trace generation to row-major format ([#2937](https://github.com/0xMiden/miden-vm/pull/2937)).
- Documented non-overlap requirement for `memcopy_words`, `memcopy_elements`, and AEAD encrypt/decrypt procedures ([#2941](https://github.com/0xMiden/miden-vm/pull/2941)).
- Added chainable `Test` builders for common test setup in `miden-utils-testing` ([#2957](https://github.com/0xMiden/miden-vm/pull/2957)).
- Added fuzz coverage for package semantic deserialization and project parsing, loading, and assembly ([#3015](https://github.com/0xMiden/miden-vm/pull/3015)).
- Speed-up AUX range check trace generation by changing divisors to a flat Vec layout ([#2966](https://github.com/0xMiden/miden-vm/pull/2966)).
- Removed AIR constraint tagging instrumentation, applied a uniform constraint description style across components, and optimized constraint evaluation ([#2856](https://github.com/0xMiden/miden-vm/pull/2856)).

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ fuzz-all: fuzz-seeds ## Run all fuzz targets (in sequence)
-@cargo +nightly fuzz run library_deserialize --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run library_serde_deserialize --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run package_deserialize --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run package_semantic_deserialize --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run package_serde_deserialize --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run project_toml_parse --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run project_load --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run project_assemble --release --fuzz-dir miden-core-fuzz -- -max_total_time=300

.PHONY: fuzz-list
fuzz-list: ## List available fuzz targets
Expand Down
14 changes: 11 additions & 3 deletions crates/mast-package/src/package/seed_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ fn build_library(signature: Option<FunctionType>) -> Arc<Library> {
Arc::new(Library::new(Arc::new(forest), exports).expect("failed to build library"))
}

fn build_package(library: Arc<Library>, signature: FunctionType) -> Package {
fn build_package(library: Arc<Library>, signature: Option<FunctionType>) -> Package {
let path = absolute_path("test::proc");
let node_id = library.get_export_node_id(path.as_ref());
let digest = library.mast_forest()[node_id].digest();

let export = PackageExport::Procedure(PackageProcedureExport {
path: Arc::clone(&path),
digest,
signature: Some(signature),
signature,
attributes: AttributeSet::default(),
});

Expand Down Expand Up @@ -96,8 +96,16 @@ fn generate_fuzz_seeds() {
&library_with_signature.to_bytes(),
);

let package = build_package(library_with_signature, signature);
let package = build_package(Arc::clone(&library), None);
write_seed("package_deserialize", "minimal_package.bin", &package.to_bytes());
write_seed("package_semantic_deserialize", "minimal_package.bin", &package.to_bytes());

let package_with_signature = build_package(library_with_signature, Some(signature));
write_seed(
"package_deserialize",
"package_with_signature.bin",
&package_with_signature.to_bytes(),
);

println!("\nSeed corpus generated in ../../miden-core-fuzz/corpus");
}
44 changes: 44 additions & 0 deletions miden-core-fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,26 @@ features = ["std", "serde"]
path = "../crates/assembly-syntax"
features = ["std", "serde"]

[dependencies.miden-assembly]
path = "../crates/assembly"
features = ["std"]

[dependencies.miden-mast-package]
path = "../crates/mast-package"
features = ["std"]

[dependencies.miden-package-registry]
path = "../crates/package-registry"
features = ["std", "serde", "resolver"]

[dependencies.miden-project]
path = "../crates/project"
features = ["std", "serde"]

[dependencies.toml]
version = "1.0"
features = ["parse", "display", "serde"]

# Fuzz targets - each is a separate binary
[[bin]]
name = "mast_forest_deserialize"
Expand Down Expand Up @@ -175,6 +191,13 @@ test = false
doc = false
bench = false

[[bin]]
name = "package_semantic_deserialize"
path = "fuzz_targets/package_semantic_deserialize.rs"
test = false
doc = false
bench = false

[[bin]]
name = "package_serde_deserialize"
path = "fuzz_targets/package_serde_deserialize.rs"
Expand All @@ -188,3 +211,24 @@ path = "fuzz_targets/mast_forest_serde_deserialize.rs"
test = false
doc = false
bench = false

[[bin]]
name = "project_toml_parse"
path = "fuzz_targets/project_toml_parse.rs"
test = false
doc = false
bench = false

[[bin]]
name = "project_load"
path = "fuzz_targets/project_load.rs"
test = false
doc = false
bench = false

[[bin]]
name = "project_assemble"
path = "fuzz_targets/project_assemble.rs"
test = false
doc = false
bench = false
2 changes: 2 additions & 0 deletions miden-core-fuzz/corpus/project_assemble/debug_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
purpose = "exercise debug-enabled project assembly"
1 change: 1 addition & 0 deletions miden-core-fuzz/corpus/project_assemble/empty_snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# empty snippet
2 changes: 2 additions & 0 deletions miden-core-fuzz/corpus/project_assemble/release_trim_paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[lints]
unused-imports = "allow"
10 changes: 10 additions & 0 deletions miden-core-fuzz/corpus/project_load/inherited_workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "workspace-member"
version.workspace = true
description.workspace = true

[lib]
path = "lib.masm"

[dependencies]
shared-dep.workspace = true
11 changes: 11 additions & 0 deletions miden-core-fuzz/corpus/project_load/kernel_package
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "mykernel"
version = "2.0.0"

[lib]
kind = "kernel"
path = "kernel/mod.masm"

[[bin]]
name = "entry"
path = "bin/entry.masm"
11 changes: 11 additions & 0 deletions miden-core-fuzz/corpus/project_load/package_with_bins
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "myapp"
version = "0.1.0"

[[bin]]
name = "main"
path = "bin/main.masm"

[[bin]]
name = "helper"
path = "bin/helper.masm"
12 changes: 12 additions & 0 deletions miden-core-fuzz/corpus/project_load/package_with_deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "myproject"
version = "0.5.0"

[lib]
path = "lib.masm"

[dependencies]
stdlib = { version = "1.0.0" }
local-dep = { path = "../local-dep", linkage = "static" }
remote-dep = { git = "https://github.com/example/repo", branch = "main" }
workspace-dep.workspace = true
8 changes: 8 additions & 0 deletions miden-core-fuzz/corpus/project_load/package_with_lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "mylib"
version = "1.0.0"
description = "A simple library"

[lib]
namespace = "mylib"
path = "lib.masm"
14 changes: 14 additions & 0 deletions miden-core-fuzz/corpus/project_load/package_with_metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "metadata-example"
version = "0.1.0"
description = "Example with metadata"

[lib]
path = "lib.masm"

[package.metadata.custom]
key = "value"
number = 42

[lints.miden]
unused = "warn"
14 changes: 14 additions & 0 deletions miden-core-fuzz/corpus/project_load/package_with_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "profiled"
version = "0.1.0"

[lib]
path = "lib.masm"

[profile.release]
debug = false
trim-paths = true

[profile.custom]
inherits = "dev"
debug = true
3 changes: 3 additions & 0 deletions miden-core-fuzz/corpus/project_load/simple_package
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "simple"
version = "0.1.0"
10 changes: 10 additions & 0 deletions miden-core-fuzz/corpus/project_load/workspace_manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
members = ["crate-a", "crate-b", "crate-c"]

[workspace.package]
version = "0.1.0"
description = "A workspace example"

[workspace.dependencies]
foo = { path = "crate-a" }
bar = { version = "1.0.0", linkage = "static" }
10 changes: 10 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/inherited_workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "workspace-member"
version.workspace = true
description.workspace = true

[lib]
path = "lib.masm"

[dependencies]
shared-dep.workspace = true
11 changes: 11 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/kernel_package
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "mykernel"
version = "2.0.0"

[lib]
kind = "kernel"
path = "kernel/mod.masm"

[[bin]]
name = "entry"
path = "bin/entry.masm"
11 changes: 11 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/package_with_bins
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "myapp"
version = "0.1.0"

[[bin]]
name = "main"
path = "bin/main.masm"

[[bin]]
name = "helper"
path = "bin/helper.masm"
12 changes: 12 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/package_with_deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "myproject"
version = "0.5.0"

[lib]
path = "lib.masm"

[dependencies]
stdlib = { version = "1.0.0" }
local-dep = { path = "../local-dep", linkage = "static" }
remote-dep = { git = "https://github.com/example/repo", branch = "main" }
workspace-dep.workspace = true
8 changes: 8 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/package_with_lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "mylib"
version = "1.0.0"
description = "A simple library"

[lib]
namespace = "mylib"
path = "lib.masm"
14 changes: 14 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/package_with_metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "metadata-example"
version = "0.1.0"
description = "Example with metadata"

[lib]
path = "lib.masm"

[package.metadata.custom]
key = "value"
number = 42

[lints.miden]
unused = "warn"
14 changes: 14 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/package_with_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "profiled"
version = "0.1.0"

[lib]
path = "lib.masm"

[profile.release]
debug = false
trim-paths = true

[profile.custom]
inherits = "dev"
debug = true
3 changes: 3 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/simple_package
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "simple"
version = "0.1.0"
10 changes: 10 additions & 0 deletions miden-core-fuzz/corpus/project_toml_parse/workspace_manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
members = ["crate-a", "crate-b", "crate-c"]

[workspace.package]
version = "0.1.0"
description = "A workspace example"

[workspace.dependencies]
foo = { path = "crate-a" }
bar = { version = "1.0.0", linkage = "static" }
Loading
Loading