diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c35a509ed..8a707245d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@nextest - name: nextest archive - run: cargo nextest archive --workspace --all-features --cargo-profile ci --archive-file 'nextest-archive-${{ matrix.platform.os }}.tar.zst' + run: cargo nextest archive --workspace --all-features --cargo-profile ci --archive-file 'nextest-archive-${{ matrix.platform.os }}.tar.zst' --exclude scarb-prove - uses: actions/upload-artifact@v4 with: name: nextest-archive-${{ matrix.platform.os }} @@ -82,6 +82,32 @@ jobs: - name: run tests run: cargo test -p scarb-metadata + test-scarb-prove: + name: test scarb-prove ${{ matrix.platform.name }} + runs-on: ${{ matrix.platform.os }} + env: + # TODO(#1915): Use stable toolchain once stwo is stable. + RUST_TOOLCHAIN: "nightly-2025-01-02" + strategy: + fail-fast: false + matrix: + platform: + - name: linux x86-64 + os: ubuntu-latest + - name: windows x86-64 + os: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: Swatinem/rust-cache@v2 + - name: Build + run: cargo +stable build --workspace --all-features --exclude scarb-prove + - name: Run scarb-prove tests + run: cargo +${{ env.RUST_TOOLCHAIN }} test -p scarb-prove + test-prebuilt-plugins: name: test prebuilt plugins ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.os }} @@ -113,15 +139,38 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - run: cargo fmt --check - - run: cargo clippy --all-targets --all-features -- --no-deps + # TODO(#1915): Build all crates with stable toolchain once stwo is stable. + - run: cargo clippy --all-targets --all-features --workspace --exclude scarb-prove -- --no-deps env: # Make sure CI fails on all warnings, including Clippy lints. RUSTFLAGS: "-Dwarnings" - - run: cargo doc --all-features --no-deps + - run: cargo doc --all-features --no-deps --workspace --exclude scarb-prove env: # Make sure CI fails on all warnings, including Clippy lints. RUSTDOCFLAGS: "-Dwarnings" + check-rust-scarb-prove: + name: check-rust (scarb-prove) + runs-on: ubuntu-latest + env: + # TODO(#1915): Use stable toolchain once stwo is stable. + RUST_TOOLCHAIN: "nightly-2025-01-02" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo +${{ env.RUST_TOOLCHAIN }} clippy --all-targets --all-features -p scarb-prove -- --no-deps + env: + # Make sure CI fails on all warnings, including Clippy lints. + RUSTFLAGS: "-Dwarnings" + - run: cargo +${{ env.RUST_TOOLCHAIN }} doc --all-features --no-deps -p scarb-prove + env: + # Make sure CI fails on all warnings, including Clippy lints. + RUSTDOCFLAGS: "-Dwarnings" + check-website: runs-on: ubuntu-latest defaults: diff --git a/Cargo.lock b/Cargo.lock index 8b306ea58..b009b1f19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,6 +56,17 @@ dependencies = [ "memchr", ] +[[package]] +name = "air_structs_derive" +version = "0.1.0" +source = "git+https://github.com/starkware-libs/stwo-cairo?rev=a27287c21e8b7e677b07cc40988c8c145533c55d#a27287c21e8b7e677b07cc40988c8c145533c55d" +dependencies = [ + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "alloc-no-stdlib" version = "2.0.4" @@ -77,6 +88,16 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "alloy-rlp" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6c1d995bff8d011f7cd6c81820d51825e6e06d6db73914c1630ecf544d83d6" +dependencies = [ + "arrayvec", + "bytes", +] + [[package]] name = "annotate-snippets" version = "0.11.5" @@ -154,10 +175,10 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ - "ark-ff", + "ark-ff 0.4.2", "ark-poly", - "ark-serialize", - "ark-std", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "derivative", "hashbrown 0.13.2", "itertools 0.10.5", @@ -165,26 +186,54 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits 0.2.19", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + [[package]] name = "ark-ff" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" dependencies = [ - "ark-ff-asm", - "ark-ff-macros", - "ark-serialize", - "ark-std", + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "derivative", - "digest", + "digest 0.10.7", "itertools 0.10.5", "num-bigint", "num-traits 0.2.19", "paste", - "rustc_version", + "rustc_version 0.4.0", "zeroize", ] +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "ark-ff-asm" version = "0.4.2" @@ -195,6 +244,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits 0.2.19", + "quote", + "syn 1.0.109", +] + [[package]] name = "ark-ff-macros" version = "0.4.2" @@ -214,9 +275,9 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", + "ark-ff 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "derivative", "hashbrown 0.13.2", ] @@ -228,8 +289,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c02e954eaeb4ddb29613fee20840c2bbc85ca4396d53e33837e11905363c5f2" dependencies = [ "ark-ec", - "ark-ff", - "ark-std", + "ark-ff 0.4.2", + "ark-std 0.4.0", ] [[package]] @@ -239,8 +300,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3975a01b0a6e3eae0f72ec7ca8598a6620fc72fa5981f6f5cca33b7cd788f633" dependencies = [ "ark-ec", - "ark-ff", - "ark-std", + "ark-ff 0.4.2", + "ark-std 0.4.0", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", ] [[package]] @@ -250,8 +321,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-serialize-derive", - "ark-std", - "digest", + "ark-std 0.4.0", + "digest 0.10.7", "num-bigint", ] @@ -266,6 +337,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits 0.2.19", + "rand", +] + [[package]] name = "ark-std" version = "0.4.0" @@ -276,6 +357,12 @@ dependencies = [ "rand", ] +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + [[package]] name = "arrayvec" version = "0.7.4" @@ -337,6 +424,17 @@ dependencies = [ "syn 2.0.95", ] +[[package]] +name = "auto_impl" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -419,6 +517,18 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bigdecimal" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "serde", +] + [[package]] name = "bincode" version = "2.0.0-rc.3" @@ -477,6 +587,28 @@ dependencies = [ "wyz", ] +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "blake3" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq 0.3.1", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -541,6 +673,26 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" +[[package]] +name = "bytemuck" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "byteorder" version = "1.5.0" @@ -613,7 +765,7 @@ dependencies = [ "indoc", "rayon", "rust-analyzer-salsa", - "semver", + "semver 1.0.24", "smol_str", "thiserror 1.0.69", ] @@ -701,7 +853,7 @@ dependencies = [ "cairo-lang-sierra-to-casm", "cairo-lang-syntax", "cairo-lang-utils", - "cairo-vm", + "cairo-vm 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "indoc", "itertools 0.12.1", "serde", @@ -716,7 +868,7 @@ dependencies = [ "cairo-lang-utils", "path-clean", "rust-analyzer-salsa", - "semver", + "semver 1.0.24", "serde", "smol_str", "toml", @@ -893,7 +1045,7 @@ dependencies = [ "cairo-lang-sierra-to-casm", "cairo-lang-sierra-type-size", "cairo-lang-utils", - "cairo-vm", + "cairo-vm 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.12.1", "thiserror 1.0.69", ] @@ -903,7 +1055,7 @@ name = "cairo-lang-runner" version = "2.9.2" source = "git+https://github.com/starkware-libs/cairo?rev=1510dbf57cbb2117069c83832f615f0447d0ec12#1510dbf57cbb2117069c83832f615f0447d0ec12" dependencies = [ - "ark-ff", + "ark-ff 0.4.2", "ark-secp256k1", "ark-secp256r1", "cairo-lang-casm", @@ -914,7 +1066,7 @@ dependencies = [ "cairo-lang-sierra-to-casm", "cairo-lang-starknet", "cairo-lang-utils", - "cairo-vm", + "cairo-vm 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.12.1", "keccak", "num-bigint", @@ -1290,7 +1442,7 @@ checksum = "20cb651f2fb6b882fd224f144e450a8d8b12c1a4f85af8c28c5bfbb391ddea5b" dependencies = [ "anyhow", "clap", - "semver", + "semver 1.0.24", "toml_edit 0.22.22", "xshell", ] @@ -1326,6 +1478,37 @@ dependencies = [ "zip", ] +[[package]] +name = "cairo-vm" +version = "1.0.1" +source = "git+https://github.com/lambdaclass/cairo-vm?rev=3fb0344c#3fb0344ce038b3a68cae897c403d1f561cfe8da7" +dependencies = [ + "anyhow", + "bincode", + "bitvec", + "generic-array", + "hashbrown 0.14.5", + "hex", + "keccak", + "lazy_static", + "nom", + "num-bigint", + "num-integer", + "num-prime", + "num-traits 0.2.19", + "rand", + "rust_decimal", + "serde", + "serde_json", + "sha2", + "sha3", + "starknet-crypto", + "starknet-types-core", + "thiserror-no-std", + "wasm-bindgen", + "zip", +] + [[package]] name = "camino" version = "1.1.9" @@ -1352,21 +1535,21 @@ checksum = "8769706aad5d996120af43197bf46ef6ad0fda35216b4505f926a365a232d924" dependencies = [ "camino", "cargo-platform", - "semver", + "semver 1.0.24", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] name = "cc" -version = "1.0.98" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ "jobserver", "libc", - "once_cell", + "shlex", ] [[package]] @@ -1498,6 +1681,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + [[package]] name = "content_inspector" version = "0.2.4" @@ -1721,7 +1910,7 @@ dependencies = [ "nix", "os_pipe", "path-dedot", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "windows-sys 0.59.0", ] @@ -1811,6 +2000,15 @@ dependencies = [ "nu-ansi-term", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "digest" version = "0.10.7" @@ -1899,6 +2097,18 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +[[package]] +name = "educe" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "either" version = "1.12.0" @@ -1929,6 +2139,26 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "env_filter" version = "0.1.2" @@ -2009,6 +2239,40 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +[[package]] +name = "fastrlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + +[[package]] +name = "fastrlp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8dba4714ef14b8274c371879b175aa55b16b30f269663f19d576f380018dc4" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + +[[package]] +name = "faststr" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9154486833a83cb5d99de8c4d831314b8ae810dd4ef18d89ceb7a9c7c728dd74" +dependencies = [ + "bytes", + "rkyv", + "serde", + "simdutf8", +] + [[package]] name = "filetime" version = "0.2.23" @@ -2021,6 +2285,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -2313,7 +2589,7 @@ dependencies = [ "regex", "signal-hook", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2326,7 +2602,7 @@ dependencies = [ "gix-date", "gix-utils", "itoa", - "thiserror 2.0.9", + "thiserror 2.0.11", "winnow 0.6.18", ] @@ -2341,7 +2617,7 @@ dependencies = [ "gix-object", "gix-worktree-stream", "jiff", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2357,7 +2633,7 @@ dependencies = [ "gix-trace", "kstring", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", "unicode-bom", ] @@ -2367,7 +2643,7 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d48b897b4bbc881aea994b4a5bbb340a04979d7be9089791304e04a9fbc66b53" dependencies = [ - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2376,7 +2652,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6ffbeb3a5c0b8b84c3fe4133a6f8c82fa962f4caefe8d0762eced025d3eb4f7" dependencies = [ - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2402,7 +2678,7 @@ dependencies = [ "gix-features", "gix-hash", "memmap2", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2421,7 +2697,7 @@ dependencies = [ "memchr", "once_cell", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", "unicode-bom", "winnow 0.6.18", ] @@ -2436,7 +2712,7 @@ dependencies = [ "bstr 1.9.1", "gix-path", "libc", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2453,7 +2729,7 @@ dependencies = [ "gix-sec", "gix-trace", "gix-url", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2465,7 +2741,7 @@ dependencies = [ "bstr 1.9.1", "itoa", "jiff", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2486,7 +2762,7 @@ dependencies = [ "gix-traverse", "gix-worktree", "imara-diff", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2506,7 +2782,7 @@ dependencies = [ "gix-trace", "gix-utils", "gix-worktree", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2522,7 +2798,7 @@ dependencies = [ "gix-path", "gix-ref", "gix-sec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2544,7 +2820,7 @@ dependencies = [ "parking_lot", "prodash", "sha1_smol", - "thiserror 2.0.9", + "thiserror 2.0.11", "walkdir", ] @@ -2566,7 +2842,7 @@ dependencies = [ "gix-trace", "gix-utils", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2599,7 +2875,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b5eccc17194ed0e67d49285e4853307e4147e95407f91c1c3e4a13ba9f4e4ce" dependencies = [ "faster-hex", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2651,7 +2927,7 @@ dependencies = [ "memmap2", "rustix", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2662,7 +2938,7 @@ checksum = "1cd3ab68a452db63d9f3ebdacb10f30dba1fa0d31ac64f4203d395ed1102d940" dependencies = [ "gix-tempfile", "gix-utils", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2674,7 +2950,7 @@ dependencies = [ "bstr 1.9.1", "gix-actor", "gix-date", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2690,7 +2966,7 @@ dependencies = [ "gix-object", "gix-revwalk", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2710,7 +2986,7 @@ dependencies = [ "gix-validate", "itoa", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", "winnow 0.6.18", ] @@ -2732,7 +3008,7 @@ dependencies = [ "gix-quote", "parking_lot", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2750,7 +3026,7 @@ dependencies = [ "gix-path", "memmap2", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", "uluru", ] @@ -2763,7 +3039,7 @@ dependencies = [ "bstr 1.9.1", "faster-hex", "gix-trace", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2775,7 +3051,7 @@ dependencies = [ "bstr 1.9.1", "faster-hex", "gix-trace", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2788,7 +3064,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2803,7 +3079,7 @@ dependencies = [ "gix-config-value", "gix-glob", "gix-path", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2816,7 +3092,7 @@ dependencies = [ "gix-config-value", "parking_lot", "rustix", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2834,7 +3110,7 @@ dependencies = [ "gix-transport", "gix-utils", "maybe-async", - "thiserror 2.0.9", + "thiserror 2.0.11", "winnow 0.6.18", ] @@ -2846,7 +3122,7 @@ checksum = "64a1e282216ec2ab2816cd57e6ed88f8009e634aec47562883c05ac8a7009a63" dependencies = [ "bstr 1.9.1", "gix-utils", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2866,7 +3142,7 @@ dependencies = [ "gix-utils", "gix-validate", "memmap2", - "thiserror 2.0.9", + "thiserror 2.0.11", "winnow 0.6.18", ] @@ -2881,7 +3157,7 @@ dependencies = [ "gix-revision", "gix-validate", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2899,7 +3175,7 @@ dependencies = [ "gix-object", "gix-revwalk", "gix-trace", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2914,7 +3190,7 @@ dependencies = [ "gix-hashtable", "gix-object", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2938,7 +3214,7 @@ dependencies = [ "bstr 1.9.1", "gix-hash", "gix-lock", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2961,7 +3237,7 @@ dependencies = [ "gix-pathspec", "gix-worktree", "portable-atomic", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -2976,7 +3252,7 @@ dependencies = [ "gix-pathspec", "gix-refspec", "gix-url", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -3014,7 +3290,7 @@ dependencies = [ "gix-quote", "gix-sec", "gix-url", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -3031,7 +3307,7 @@ dependencies = [ "gix-object", "gix-revwalk", "smallvec", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -3044,7 +3320,7 @@ dependencies = [ "gix-features", "gix-path", "percent-encoding", - "thiserror 2.0.9", + "thiserror 2.0.11", "url", ] @@ -3066,7 +3342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr 1.9.1", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -3105,7 +3381,7 @@ dependencies = [ "gix-path", "gix-worktree", "io-close", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -3123,7 +3399,7 @@ dependencies = [ "gix-path", "gix-traverse", "parking_lot", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -3266,7 +3542,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] @@ -3564,6 +3840,15 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -3705,6 +3990,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -3865,6 +4159,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "libm" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" + [[package]] name = "libredox" version = "0.1.3" @@ -4087,6 +4387,26 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b52c1b33ff98142aecea13138bd399b68aa7ab5d9546c300988c345004001eea" +[[package]] +name = "munge" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64142d38c84badf60abf06ff9bd80ad2174306a5b11bd4706535090a30a419df" +dependencies = [ + "munge_macro", +] + +[[package]] +name = "munge_macro" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb5c1d8184f13f7d0ccbeeca0def2f9a181bce2624302793005f5ca8aa62e5e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "native-tls" version = "0.2.12" @@ -4286,6 +4606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -4504,7 +4825,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest", + "digest 0.10.7", "hmac", "password-hash", "sha2", @@ -4516,6 +4837,17 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" +dependencies = [ + "memchr", + "thiserror 2.0.11", + "ucd-trie", +] + [[package]] name = "petgraph" version = "0.6.5" @@ -4643,6 +4975,17 @@ dependencies = [ "yansi", ] +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "uint", +] + [[package]] name = "priority-queue" version = "2.1.1" @@ -4684,6 +5027,58 @@ dependencies = [ "parking_lot", ] +[[package]] +name = "proptest" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" +dependencies = [ + "bitflags 2.5.0", + "lazy_static", + "num-traits 0.2.19", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax 0.8.5", + "unarray", +] + +[[package]] +name = "prover_types" +version = "0.1.0" +source = "git+https://github.com/starkware-libs/stwo-cairo?rev=a27287c21e8b7e677b07cc40988c8c145533c55d#a27287c21e8b7e677b07cc40988c8c145533c55d" +dependencies = [ + "bytemuck", + "itertools 0.12.1", + "num-traits 0.2.19", + "ruint", + "serde", + "starknet-ff", + "stwo-cairo-serialize", + "stwo-prover", + "stwo_cairo_utils", +] + +[[package]] +name = "ptr_meta" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9e76f66d3f9606f44e45598d155cb13ecf09f4a28199e48daf8c8fc937ea90" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "pubgrub" version = "0.2.1" @@ -4756,6 +5151,15 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rancor" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947" +dependencies = [ + "ptr_meta", +] + [[package]] name = "rand" version = "0.8.5" @@ -4786,6 +5190,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + [[package]] name = "raw-cpuid" version = "11.2.0" @@ -4859,6 +5272,26 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "regex" version = "1.11.0" @@ -4909,6 +5342,12 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" +[[package]] +name = "rend" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a35e8a6bf28cd121053a66aa2e6a2e3eaffad4a60012179f0e864aa5ffeff215" + [[package]] name = "reqwest" version = "0.11.27" @@ -4982,6 +5421,77 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rkyv" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e147371c75553e1e2fcdb483944a8540b8438c31426279553b9a8182a9b7b65" +dependencies = [ + "bytes", + "hashbrown 0.15.2", + "indexmap 2.7.0", + "munge", + "ptr_meta", + "rancor", + "rend", + "rkyv_derive", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246b40ac189af6c675d124b802e8ef6d5246c53e17367ce9501f8f66a81abb7a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "ruint" +version = "1.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5ef8fb1dd8de3870cb8400d51b4c2023854bbafd5431a3ac7e7317243e22d2f" +dependencies = [ + "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp 0.3.1", + "fastrlp 0.4.0", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "parity-scale-codec", + "primitive-types", + "proptest", + "rand", + "rlp", + "ruint-macro", + "serde", + "valuable", + "zeroize", +] + +[[package]] +name = "ruint-macro" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" + [[package]] name = "rust-analyzer-salsa" version = "0.17.0-pre.6" @@ -5033,13 +5543,28 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.24", ] [[package]] @@ -5188,7 +5713,7 @@ dependencies = [ "scarb-stable-hash 1.0.0", "scarb-test-support", "scarb-ui", - "semver", + "semver 1.0.24", "semver-pubgrub", "serde", "serde-untagged", @@ -5205,7 +5730,7 @@ dependencies = [ "target-triple", "test-case", "test-for-each-example", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tokio-stream", "toml", @@ -5226,7 +5751,7 @@ name = "scarb-build-metadata" version = "2.9.2" dependencies = [ "cargo_metadata", - "semver", + "semver 1.0.24", ] [[package]] @@ -5260,7 +5785,7 @@ dependencies = [ "serde_json", "snapbox", "starknet-types-core", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -5312,7 +5837,7 @@ dependencies = [ "serde", "serde_json", "smol_str", - "thiserror 2.0.9", + "thiserror 2.0.11", "walkdir", ] @@ -5326,7 +5851,7 @@ dependencies = [ "cairo-lang-executable", "cairo-lang-runner", "cairo-lang-utils", - "cairo-vm", + "cairo-vm 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "camino", "clap", "create-output-dir", @@ -5350,11 +5875,11 @@ dependencies = [ "cairo-lang-filesystem", "camino", "derive_builder", - "semver", + "semver 1.0.24", "serde", "serde_json", "snapbox", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -5364,7 +5889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a8b71f63999dbb6d269fbc6fd61310016ab3a160fb13e52a6511a2b904359f0" dependencies = [ "camino", - "semver", + "semver 1.0.24", "serde", "serde_json", "thiserror 1.0.69", @@ -5390,6 +5915,28 @@ dependencies = [ "serde_json", ] +[[package]] +name = "scarb-prove" +version = "2.9.2" +dependencies = [ + "anyhow", + "assert_fs", + "camino", + "clap", + "create-output-dir", + "indoc", + "predicates", + "scarb-execute", + "scarb-metadata 1.13.0", + "scarb-test-support", + "scarb-ui", + "serde", + "serde_json", + "snapbox", + "stwo-prover", + "stwo_cairo_prover", +] + [[package]] name = "scarb-stable-hash" version = "1.0.0" @@ -5427,7 +5974,7 @@ dependencies = [ "scarb-build-metadata", "scarb-proc-macro-server-types 0.1.0", "scarb-ui", - "semver", + "semver 1.0.24", "serde", "serde_json", "sha2", @@ -5527,6 +6074,15 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.24" @@ -5536,13 +6092,22 @@ dependencies = [ "serde", ] +[[package]] +name = "semver-parser" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9900206b54a3527fdc7b8a938bffd94a568bac4f4aa8113b209df75a09c0dec2" +dependencies = [ + "pest", +] + [[package]] name = "semver-pubgrub" version = "0.1.0" source = "git+https://github.com/software-mansion-labs/semver-pubgrub.git#6c78141d940cda6d8e69aea794c2bf30cc3402df" dependencies = [ "pubgrub", - "semver", + "semver 1.0.24", ] [[package]] @@ -5668,7 +6233,7 @@ checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", ] [[package]] @@ -5685,7 +6250,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", ] [[package]] @@ -5694,7 +6259,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest", + "digest 0.10.7", "keccak", ] @@ -5713,6 +6278,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" @@ -5732,6 +6303,12 @@ dependencies = [ "libc", ] +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "similar" version = "2.5.0" @@ -5824,6 +6401,44 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "sonic-number" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a74044c092f4f43ca7a6cfd62854cf9fb5ac8502b131347c990bf22bef1dfe" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "sonic-rs" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0275f9f2f07d47556fe60c2759da8bc4be6083b047b491b2d476aa0bfa558eb1" +dependencies = [ + "bumpalo", + "bytes", + "cfg-if", + "faststr", + "itoa", + "ref-cast", + "ryu", + "serde", + "simdutf8", + "sonic-number", + "sonic-simd", + "thiserror 2.0.11", +] + +[[package]] +name = "sonic-simd" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940a24e82c9a97483ef66cef06b92160a8fa5cd74042c57c10b24d99d169d2fc" +dependencies = [ + "cfg-if", +] + [[package]] name = "spin" version = "0.5.2" @@ -5908,10 +6523,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abf1b44ec5b18d87c1ae5f54590ca9d0699ef4dd5b2ffa66fc97f24613ec585" dependencies = [ - "ark-ff", + "ark-ff 0.4.2", + "bigdecimal", "crypto-bigint", "getrandom", "hex", + "serde", ] [[package]] @@ -5954,6 +6571,112 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "stwo-air-utils" +version = "0.1.1" +source = "git+https://github.com/starkware-libs/stwo?rev=af5475cb#af5475cb946a29de7d04dfa8c77a17034f888df4" +dependencies = [ + "bytemuck", + "itertools 0.12.1", + "rayon", + "stwo-air-utils-derive", + "stwo-prover", +] + +[[package]] +name = "stwo-air-utils-derive" +version = "0.1.0" +source = "git+https://github.com/starkware-libs/stwo?rev=af5475cb#af5475cb946a29de7d04dfa8c77a17034f888df4" +dependencies = [ + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.95", +] + +[[package]] +name = "stwo-cairo-serialize" +version = "0.1.0" +source = "git+https://github.com/starkware-libs/stwo-cairo?rev=a27287c21e8b7e677b07cc40988c8c145533c55d#a27287c21e8b7e677b07cc40988c8c145533c55d" +dependencies = [ + "starknet-ff", + "stwo-cairo-serialize-derive", + "stwo-prover", +] + +[[package]] +name = "stwo-cairo-serialize-derive" +version = "0.1.0" +source = "git+https://github.com/starkware-libs/stwo-cairo?rev=a27287c21e8b7e677b07cc40988c8c145533c55d#a27287c21e8b7e677b07cc40988c8c145533c55d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.95", +] + +[[package]] +name = "stwo-prover" +version = "0.1.1" +source = "git+https://github.com/starkware-libs/stwo?rev=af5475cb#af5475cb946a29de7d04dfa8c77a17034f888df4" +dependencies = [ + "blake2", + "blake3", + "bytemuck", + "cfg-if", + "educe", + "hex", + "itertools 0.12.1", + "num-traits 0.2.19", + "rand", + "rayon", + "serde", + "starknet-crypto", + "starknet-ff", + "thiserror 1.0.69", + "tracing", +] + +[[package]] +name = "stwo_cairo_prover" +version = "0.1.0" +source = "git+https://github.com/starkware-libs/stwo-cairo?rev=a27287c21e8b7e677b07cc40988c8c145533c55d#a27287c21e8b7e677b07cc40988c8c145533c55d" +dependencies = [ + "air_structs_derive", + "bytemuck", + "cairo-lang-casm", + "cairo-vm 1.0.1 (git+https://github.com/lambdaclass/cairo-vm?rev=3fb0344c)", + "hex", + "itertools 0.12.1", + "num-traits 0.2.19", + "paste", + "prover_types", + "rayon", + "serde", + "sonic-rs", + "starknet-ff", + "stwo-air-utils", + "stwo-air-utils-derive", + "stwo-cairo-serialize", + "stwo-prover", + "stwo_cairo_utils", + "thiserror 1.0.69", + "tracing", +] + +[[package]] +name = "stwo_cairo_utils" +version = "0.1.0" +source = "git+https://github.com/starkware-libs/stwo-cairo?rev=a27287c21e8b7e677b07cc40988c8c145533c55d#a27287c21e8b7e677b07cc40988c8c145533c55d" +dependencies = [ + "cairo-vm 1.0.1 (git+https://github.com/lambdaclass/cairo-vm?rev=3fb0344c)", + "clap", + "env_logger", + "log", + "thiserror 1.0.69", + "tracing", + "tracing-subscriber", +] + [[package]] name = "subtle" version = "2.5.0" @@ -6128,11 +6851,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.9", + "thiserror-impl 2.0.11", ] [[package]] @@ -6148,9 +6871,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", @@ -6545,6 +7268,24 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "uluru" version = "3.1.0" @@ -6554,6 +7295,12 @@ dependencies = [ "arrayvec", ] +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unescaper" version = "0.1.4" @@ -6653,6 +7400,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" + [[package]] name = "valuable" version = "0.1.0" @@ -7097,7 +7850,7 @@ dependencies = [ "anyhow", "cairo-toolchain-xtasks", "clap", - "semver", + "semver 1.0.24", "serde_json", "time", "walkdir", @@ -7232,7 +7985,7 @@ dependencies = [ "aes", "byteorder", "bzip2", - "constant_time_eq", + "constant_time_eq 0.1.5", "crc32fast", "crossbeam-utils", "flate2", diff --git a/Cargo.toml b/Cargo.toml index 330e26942..857061669 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "scarb-metadata", "extensions/scarb-doc", "extensions/scarb-execute", + "extensions/scarb-prove", "extensions/scarb-cairo-language-server", "extensions/scarb-cairo-run", "extensions/scarb-cairo-test", diff --git a/extensions/scarb-execute/src/args.rs b/extensions/scarb-execute/src/args.rs index 2c0747f09..838e18e7c 100644 --- a/extensions/scarb-execute/src/args.rs +++ b/extensions/scarb-execute/src/args.rs @@ -16,12 +16,8 @@ pub struct Args { #[command(flatten)] pub packages_filter: PackagesFilter, - /// Do not rebuild the package. - #[arg(long, default_value_t = false)] - pub no_build: bool, - - #[clap(flatten)] - pub run: ExecutionArgs, + #[command(flatten)] + pub execution: ExecutionArgs, /// Logging verbosity. #[command(flatten)] @@ -30,6 +26,16 @@ pub struct Args { #[derive(Parser, Clone, Debug)] pub struct ExecutionArgs { + /// Do not rebuild the package. + #[arg(long, default_value_t = false)] + pub no_build: bool, + + #[command(flatten)] + pub run: RunArgs, +} + +#[derive(Parser, Clone, Debug)] +pub struct RunArgs { #[command(flatten)] pub arguments: ProgramArguments, diff --git a/extensions/scarb-execute/src/lib.rs b/extensions/scarb-execute/src/lib.rs index 3fbf325e2..54d78b4d9 100644 --- a/extensions/scarb-execute/src/lib.rs +++ b/extensions/scarb-execute/src/lib.rs @@ -12,27 +12,33 @@ use cairo_vm::{cairo_run, Felt252}; use camino::{Utf8Path, Utf8PathBuf}; use create_output_dir::create_output_dir; use indoc::formatdoc; -use scarb_metadata::{Metadata, MetadataCommand, ScarbCommand}; +use scarb_metadata::{Metadata, MetadataCommand, PackageMetadata, ScarbCommand}; use scarb_ui::args::PackagesFilter; use scarb_ui::components::Status; use scarb_ui::Ui; use std::env; use std::fs; -use std::fs::OpenOptions; use std::io::{self, Write}; pub mod args; const MAX_ITERATION_COUNT: usize = 10000; -pub fn main_inner(args: args::Args, ui: Ui) -> Result<(), anyhow::Error> { +pub fn main_inner(args: args::Args, ui: Ui) -> Result { + let metadata = MetadataCommand::new().inherit_stderr().exec()?; + let package = args.packages_filter.match_one(&metadata)?; + execute(&package, &args.execution, &ui) +} + +pub fn execute( + package: &PackageMetadata, + args: &args::ExecutionArgs, + ui: &Ui, +) -> Result { ensure!( !(args.run.output.is_cairo_pie() && args.run.target.is_standalone()), "Cairo pie output format is not supported for standalone execution target" ); - let metadata = MetadataCommand::new().inherit_stderr().exec()?; - let package = args.packages_filter.match_one(&metadata)?; - if !args.no_build { let filter = PackagesFilter::generate_for::(vec![package.clone()].iter()); ScarbCommand::new() @@ -98,7 +104,9 @@ pub fn main_inner(args: args::Args, ui: Ui) -> Result<(), anyhow::Error> { let mut hint_processor = CairoHintProcessor { runner: None, - user_args: vec![vec![Arg::Array(args.run.arguments.read_arguments()?)]], + user_args: vec![vec![Arg::Array( + args.run.arguments.clone().read_arguments()?, + )]], string_to_hint, starknet_state: Default::default(), run_resources: Default::default(), @@ -137,19 +145,20 @@ pub fn main_inner(args: args::Args, ui: Ui) -> Result<(), anyhow::Error> { } } - let output_dir = scarb_target_dir.join("execute"); + let output_dir = scarb_target_dir.join("execute").join(&package.name); create_output_dir(output_dir.as_std_path())?; + let (execution_output_dir, execution_id) = incremental_create_output_dir(&output_dir)?; + if args.run.output.is_cairo_pie() { let output_value = runner.get_cairo_pie()?; - let output_file_path = incremental_create_output_file(&output_dir, package.name, ".zip")?; + let output_file_path = execution_output_dir.join("cairo_pie.zip"); ui.print(Status::new( "Saving output to:", &display_path(&scarb_target_dir, &output_file_path), )); output_value.write_zip_file(output_file_path.as_std_path())?; } else { - let execution_output_dir = incremental_create_output_dir(&output_dir, package.name)?; ui.print(Status::new( "Saving output to:", &display_path(&scarb_target_dir, &execution_output_dir), @@ -186,7 +195,7 @@ pub fn main_inner(args: args::Args, ui: Ui) -> Result<(), anyhow::Error> { fs::write(air_private_input_path, output_value)?; } - Ok(()) + Ok(execution_id) } fn display_path(scarb_target_dir: &Utf8Path, output_path: &Utf8Path) -> String { @@ -214,52 +223,10 @@ fn load_prebuilt_executable(path: &Utf8Path, filename: String) -> Result, -) -> Result { - incremental_attempt_io_creation( - path, - name, - extension, - "failed to create output directory", - |p| { - OpenOptions::new() - .write(true) - .create_new(true) - .open(p) - .map(|_| ()) - }, - ) -} - -fn incremental_create_output_dir(path: &Utf8Path, name: String) -> anyhow::Result { - incremental_attempt_io_creation(path, name, "", "failed to create output directory", |p| { - fs::create_dir(p) - }) -} - -fn incremental_attempt_io_creation( - path: &Utf8Path, - name: impl AsRef, - extension: impl AsRef, - final_error_message: impl AsRef, - attempt: impl Fn(&Utf8Path) -> io::Result<()>, -) -> anyhow::Result { - for i in 0..MAX_ITERATION_COUNT { - let number_string = if i == 0 { - "".to_string() - } else { - format!("_{}", i) - }; - let filepath = path.join(format!( - "{}{}{}", - name.as_ref(), - number_string, - extension.as_ref() - )); - let result = attempt(&filepath); +fn incremental_create_output_dir(path: &Utf8Path) -> Result<(Utf8PathBuf, usize)> { + for i in 1..=MAX_ITERATION_COUNT { + let filepath = path.join(format!("execution{}", i)); + let result = fs::create_dir(&filepath); return match result { Err(e) => { if e.kind() == io::ErrorKind::AlreadyExists { @@ -267,10 +234,10 @@ fn incremental_attempt_io_creation( } Err(e.into()) } - Ok(_) => Ok(filepath), + Ok(_) => Ok((filepath, i)), }; } - bail!(final_error_message.as_ref().to_string()); + bail!("failed to create output directory") } /// Writer implementation for a file. diff --git a/extensions/scarb-execute/src/main.rs b/extensions/scarb-execute/src/main.rs index 925bb2b63..a8726715d 100644 --- a/extensions/scarb-execute/src/main.rs +++ b/extensions/scarb-execute/src/main.rs @@ -9,7 +9,7 @@ fn main() -> ExitCode { let ui = Ui::new(args.verbose.clone().into(), scarb_ui::OutputFormat::Text); match main_inner(args, ui.clone()) { - Ok(()) => ExitCode::SUCCESS, + Ok(_execution_id) => ExitCode::SUCCESS, Err(error) => { ui.error(format!("{error:#}")); ExitCode::FAILURE diff --git a/extensions/scarb-execute/tests/arguments.rs b/extensions/scarb-execute/tests/arguments.rs index db5e06331..44293322f 100644 --- a/extensions/scarb-execute/tests/arguments.rs +++ b/extensions/scarb-execute/tests/arguments.rs @@ -41,7 +41,7 @@ fn can_take_big_number_as_arg() { Program output: 0 1129815197211541481934112806673325772687763881719835256646064516195041515616 - Saving output to: target/execute/hello + Saving output to: target/execute/hello/execution1 "#}); } @@ -85,6 +85,6 @@ fn can_read_arguments_from_file() { Program output: 0 1129815197211541481934112806673325772687763881719835256646064516195041515616 - Saving output to: target/execute/hello + Saving output to: target/execute/hello/execution1 "#}); } diff --git a/extensions/scarb-execute/tests/build.rs b/extensions/scarb-execute/tests/build.rs index 2b399c032..e9f34b0ff 100644 --- a/extensions/scarb-execute/tests/build.rs +++ b/extensions/scarb-execute/tests/build.rs @@ -46,16 +46,16 @@ fn can_execute_default_main_function_from_executable() { [..]Compiling hello v0.1.0 ([..]Scarb.toml) [..]Finished `dev` profile target(s) in [..] [..]Executing hello - Saving output to: target/execute/hello + Saving output to: target/execute/hello/execution1 "#}); - t.child("target/execute/hello/air_private_input.json") + t.child("target/execute/hello/execution1/air_private_input.json") .assert_is_json::(); - t.child("target/execute/hello/air_public_input.json") + t.child("target/execute/hello/execution1/air_public_input.json") .assert_is_json::(); - t.child("target/execute/hello/memory.bin") + t.child("target/execute/hello/execution1/memory.bin") .assert(predicates::path::exists().and(is_file_empty().not())); - t.child("target/execute/hello/trace.bin") + t.child("target/execute/hello/execution1/trace.bin") .assert(predicates::path::exists().and(is_file_empty().not())); } @@ -71,16 +71,16 @@ fn can_execute_prebuilt_executable() { .success() .stdout_matches(indoc! {r#" [..]Executing hello - Saving output to: target/execute/hello + Saving output to: target/execute/hello/execution1 "#}); - t.child("target/execute/hello/air_private_input.json") + t.child("target/execute/hello/execution1/air_private_input.json") .assert_is_json::(); - t.child("target/execute/hello/air_public_input.json") + t.child("target/execute/hello/execution1/air_public_input.json") .assert_is_json::(); - t.child("target/execute/hello/memory.bin") + t.child("target/execute/hello/execution1/memory.bin") .assert(predicates::path::exists().and(is_file_empty().not())); - t.child("target/execute/hello/trace.bin") + t.child("target/execute/hello/execution1/trace.bin") .assert(predicates::path::exists().and(is_file_empty().not())); } @@ -97,16 +97,16 @@ fn can_execute_bootloader_target() { [..]Compiling hello v0.1.0 ([..]Scarb.toml) [..]Finished `dev` profile target(s) in [..] [..]Executing hello - Saving output to: target/execute/hello + Saving output to: target/execute/hello/execution1 "#}); - t.child("target/execute/hello/air_private_input.json") + t.child("target/execute/hello/execution1/air_private_input.json") .assert_is_json::(); - t.child("target/execute/hello/air_public_input.json") + t.child("target/execute/hello/execution1/air_public_input.json") .assert_is_json::(); - t.child("target/execute/hello/memory.bin") + t.child("target/execute/hello/execution1/memory.bin") .assert(predicates::path::exists().and(is_file_empty().not())); - t.child("target/execute/hello/trace.bin") + t.child("target/execute/hello/execution1/trace.bin") .assert(predicates::path::exists().and(is_file_empty().not())); } @@ -124,10 +124,10 @@ fn can_produce_cairo_pie_output() { [..]Compiling hello v0.1.0 ([..]Scarb.toml) [..]Finished `dev` profile target(s) in [..] [..]Executing hello - Saving output to: target/execute/hello.zip + Saving output to: target/execute/hello/execution1/cairo_pie.zip "#}); - t.child("target/execute/hello.zip") + t.child("target/execute/hello/execution1/cairo_pie.zip") .assert(predicates::path::exists()); } @@ -206,15 +206,15 @@ fn can_print_panic_reason() { Program output: 1 Panicked with "abcd". - Saving output to: target/execute/hello + Saving output to: target/execute/hello/execution1 "#}); - t.child("target/execute/hello/air_private_input.json") + t.child("target/execute/hello/execution1/air_private_input.json") .assert_is_json::(); - t.child("target/execute/hello/air_public_input.json") + t.child("target/execute/hello/execution1/air_public_input.json") .assert_is_json::(); - t.child("target/execute/hello/memory.bin") + t.child("target/execute/hello/execution1/memory.bin") .assert(predicates::path::exists().and(is_file_empty().not())); - t.child("target/execute/hello/trace.bin") + t.child("target/execute/hello/execution1/trace.bin") .assert(predicates::path::exists().and(is_file_empty().not())); } diff --git a/extensions/scarb-prove/Cargo.toml b/extensions/scarb-prove/Cargo.toml new file mode 100644 index 000000000..564d35164 --- /dev/null +++ b/extensions/scarb-prove/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "scarb-prove" +publish = false + +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +version.workspace = true + +[dependencies] +anyhow.workspace = true +indoc.workspace = true +scarb-metadata = { path = "../../scarb-metadata" } +scarb-ui = { path = "../../utils/scarb-ui" } +clap.workspace = true +serde.workspace = true +camino.workspace = true +serde_json.workspace = true +create-output-dir = { path = "../../utils/create-output-dir" } +stwo_cairo_prover = { git = "https://github.com/starkware-libs/stwo-cairo", rev = "a27287c21e8b7e677b07cc40988c8c145533c55d" } +stwo-prover = { git = "https://github.com/starkware-libs/stwo", rev = "af5475cb", features = [ + "parallel", +] } +scarb-execute = { path = "../scarb-execute" } + +[dev-dependencies] +assert_fs.workspace = true +scarb-test-support = { path = "../../utils/scarb-test-support" } +snapbox.workspace = true +predicates.workspace = true + diff --git a/extensions/scarb-prove/src/main.rs b/extensions/scarb-prove/src/main.rs new file mode 100644 index 000000000..be97a0854 --- /dev/null +++ b/extensions/scarb-prove/src/main.rs @@ -0,0 +1,191 @@ +use anyhow::{ensure, Context, Result}; +use camino::{Utf8Path, Utf8PathBuf}; +use clap::Parser; +use create_output_dir::create_output_dir; +use indoc::{formatdoc, indoc}; +use scarb_execute::args::ExecutionArgs; +use scarb_metadata::MetadataCommand; +use scarb_ui::args::{PackagesFilter, VerbositySpec}; +use scarb_ui::components::Status; +use scarb_ui::{OutputFormat, Ui}; +use std::env; +use std::fs; +use std::process::ExitCode; +use stwo_cairo_prover::cairo_air::{prove_cairo, ProverConfig}; +use stwo_cairo_prover::input::vm_import::adapt_vm_output; +use stwo_prover::core::vcs::blake2_merkle::Blake2sMerkleChannel; + +/// Proves `scarb execute` output using Stwo prover. +#[derive(Parser, Clone, Debug)] +#[clap(version, verbatim_doc_comment)] +struct Args { + /// Name of the package. + #[command(flatten)] + packages_filter: PackagesFilter, + + /// ID of `scarb execute` *standard* output for given package, for which to generate proof. + #[arg( + long, + conflicts_with_all = [ + "execute", + "no_build", + "arguments", + "arguments_file", + "output", + "target", + "print_program_output" + ] + )] + execution_id: Option, + + /// Execute the program before proving. + #[arg( + long, + default_value_t = false, + required_unless_present = "execution_id" + )] + execute: bool, + + #[command(flatten)] + execute_args: ExecutionArgs, + + #[command(flatten)] + prover: ProverArgs, + + /// Logging verbosity. + #[command(flatten)] + pub verbose: VerbositySpec, +} + +#[derive(Parser, Clone, Debug)] +struct ProverArgs { + /// Track relations during proving. + #[arg(long, default_value = "false")] + track_relations: bool, + + /// Display components during proving. + #[arg(long, default_value = "false")] + display_components: bool, +} + +fn main() -> ExitCode { + let args = Args::parse(); + let ui = Ui::new(args.verbose.clone().into(), OutputFormat::Text); + + match main_inner(args, ui.clone()) { + Ok(()) => ExitCode::SUCCESS, + Err(error) => { + ui.error(format!("{error:#}")); + ExitCode::FAILURE + } + } +} + +fn main_inner(args: Args, ui: Ui) -> Result<()> { + ensure!( + !cfg!(windows), + indoc! {r#" + `scarb prove` is not supported on Windows + help: use WSL or a Linux/macOS machine instead + "# + } + ); + + let scarb_target_dir = Utf8PathBuf::from(env::var("SCARB_TARGET_DIR")?); + + let metadata = MetadataCommand::new().inherit_stderr().exec()?; + let package = args.packages_filter.match_one(&metadata)?; + + let execution_id = match args.execution_id { + Some(id) => id, + None => { + assert!(args.execute); + scarb_execute::execute(&package, &args.execute_args, &ui)? + } + }; + ui.print(Status::new("Proving", &package.name)); + ui.warn("soundness of proof is not yet guaranteed by Stwo, use at your own risk"); + + let (pub_input_path, priv_input_path, proof_path) = + resolve_paths_from_package(&scarb_target_dir, &package.name, execution_id)?; + + let prover_input = adapt_vm_output( + pub_input_path.as_std_path(), + priv_input_path.as_std_path(), + false, + ) + .context("failed to adapt VM output")?; + + let config = ProverConfig::builder() + .track_relations(args.prover.track_relations) + .display_components(args.prover.display_components) + .build(); + + let proof = prove_cairo::(prover_input, config) + .context("failed to generate proof")?; + + ui.print(Status::new( + "Saving proof to:", + &display_path(&scarb_target_dir, &proof_path), + )); + + fs::write(proof_path.as_std_path(), serde_json::to_string(&proof)?)?; + + Ok(()) +} + +fn resolve_paths_from_package( + scarb_target_dir: &Utf8PathBuf, + package_name: &str, + execution_id: usize, +) -> Result<(Utf8PathBuf, Utf8PathBuf, Utf8PathBuf)> { + let execution_dir = scarb_target_dir + .join("execute") + .join(package_name) + .join(format!("execution{}", execution_id)); + + ensure!( + execution_dir.exists(), + formatdoc! {r#" + execution directory not found: {} + help: make sure to run `scarb execute` first + and then run `scarb prove` with correct execution ID + "#, execution_dir} + ); + + let cairo_pie_path = execution_dir.join("cairo_pie.zip"); + ensure!( + !cairo_pie_path.exists(), + formatdoc! {r#" + proving cairo pie output is not supported: {} + help: run `scarb execute --output=standard` first + and then run `scarb prove` with correct execution ID + "#, cairo_pie_path} + ); + + // Get input files from execution directory + let pub_input_path = execution_dir.join("air_public_input.json"); + let priv_input_path = execution_dir.join("air_private_input.json"); + ensure!( + pub_input_path.exists(), + format!("public input file does not exist at path: {pub_input_path}") + ); + ensure!( + priv_input_path.exists(), + format!("private input file does not exist at path: {priv_input_path}") + ); + + // Create proof directory under this execution folder + let proof_dir = execution_dir.join("proof"); + create_output_dir(proof_dir.as_std_path()).context("failed to create proof directory")?; + let proof_path = proof_dir.join("proof.json"); + + Ok((pub_input_path, priv_input_path, proof_path)) +} + +fn display_path(scarb_target_dir: &Utf8Path, output_path: &Utf8Path) -> String { + match output_path.strip_prefix(scarb_target_dir) { + Ok(stripped) => Utf8PathBuf::from("target").join(stripped).to_string(), + Err(_) => output_path.to_string(), + } +} diff --git a/extensions/scarb-prove/tests/build.rs b/extensions/scarb-prove/tests/build.rs new file mode 100644 index 000000000..191e432f4 --- /dev/null +++ b/extensions/scarb-prove/tests/build.rs @@ -0,0 +1,229 @@ +use assert_fs::assert::PathAssert; +use assert_fs::fixture::PathChild; +use assert_fs::TempDir; +use indoc::indoc; +use scarb_test_support::command::Scarb; +use scarb_test_support::project_builder::ProjectBuilder; +use snapbox::cmd::OutputAssert; + +fn build_executable_project() -> TempDir { + let t = TempDir::new().unwrap(); + ProjectBuilder::start() + .name("hello") + .version("0.1.0") + .dep_cairo_execute() + .manifest_extra(indoc! {r#" + [executable] + + [cairo] + enable-gas = false + "#}) + .lib_cairo(indoc! {r#" + #[executable] + fn main() -> felt252 { + 42 + } + "#}) + .build(&t); + t +} + +#[test] +#[cfg(not(windows))] +fn prove_from_execution_output() { + let t = build_executable_project(); + + Scarb::quick_snapbox() + .arg("execute") + .current_dir(&t) + .assert() + .success(); + + Scarb::quick_snapbox() + .arg("prove") + .arg("--execution-id=1") + .current_dir(&t) + .assert() + .success() + .stdout_matches(indoc! {r#" + [..]Proving hello + warn: soundness of proof is not yet guaranteed by Stwo, use at your own risk + Saving proof to: target/execute/hello/execution1/proof/proof.json + "#}); + + t.child("target/execute/hello/execution1/proof/proof.json") + .assert(predicates::path::exists()); +} + +#[test] +#[cfg(not(windows))] +fn prove_with_track_relations() { + let t = build_executable_project(); + + Scarb::quick_snapbox() + .arg("execute") + .current_dir(&t) + .assert() + .success(); + + let cmd = Scarb::quick_snapbox() + .arg("prove") + .arg("--execution-id=1") + .arg("--track-relations") + .current_dir(&t) + .assert() + .success(); + let output = cmd.get_output().stdout.clone(); + let stdout = String::from_utf8(output).unwrap(); + + assert!(stdout.contains("Proving hello")); + assert!(stdout.contains("Relations summary:")); + assert!(stdout.contains("Saving proof to: target/execute/hello/execution1/proof/proof.json")); + + t.child("target/execute/hello/execution1/proof/proof.json") + .assert(predicates::path::exists()); +} + +#[test] +#[cfg(not(windows))] +fn prove_with_display_components() { + let t = build_executable_project(); + + Scarb::quick_snapbox() + .arg("execute") + .current_dir(&t) + .assert() + .success(); + + let cmd = Scarb::quick_snapbox() + .arg("prove") + .arg("--execution-id=1") + .arg("--display-components") + .current_dir(&t) + .assert() + .success(); + + let output = cmd.get_output().stdout.clone(); + let stdout = String::from_utf8(output).unwrap(); + + assert!(stdout.contains("Proving hello")); + assert!(stdout.contains("CairoComponents")); + assert!(stdout.contains("Saving proof to: target/execute/hello/execution1/proof/proof.json")); + + t.child("target/execute/hello/execution1/proof/proof.json") + .assert(predicates::path::exists()); +} + +#[test] +#[cfg(not(windows))] +fn prove_fails_when_execution_output_not_found() { + let t = build_executable_project(); + + output_assert( + Scarb::quick_snapbox() + .arg("prove") + .arg("--execution-id=1") + .current_dir(&t) + .assert() + .failure(), + indoc! {r#" + [..]Proving hello + warn: soundness of proof is not yet guaranteed by Stwo, use at your own risk + error: execution directory not found: [..]/target/execute/hello/execution1 + help: make sure to run `scarb execute` first + and then run `scarb prove` with correct execution ID + + "#}, + ) +} + +#[test] +#[cfg(not(windows))] +fn prove_fails_when_cairo_pie_output() { + let t = build_executable_project(); + + // First create a cairo pie output + Scarb::quick_snapbox() + .arg("execute") + .arg("--target=bootloader") + .arg("--output=cairo-pie") + .current_dir(&t) + .assert() + .success(); + + t.child("target/execute/hello/execution1/cairo_pie.zip") + .assert(predicates::path::exists()); + + // Then try to prove it + output_assert( + Scarb::quick_snapbox() + .arg("prove") + .arg("--execution-id=1") + .current_dir(&t) + .assert() + .failure(), + indoc! {r#" + [..]Proving hello + warn: soundness of proof is not yet guaranteed by Stwo, use at your own risk + error: proving cairo pie output is not supported: [..]/target/execute/hello/execution1/cairo_pie.zip + help: run `scarb execute --output=standard` first + and then run `scarb prove` with correct execution ID + + "#}, + ); +} + +#[test] +#[cfg(not(windows))] +fn prove_with_execute() { + let t = build_executable_project(); + + Scarb::quick_snapbox() + .arg("prove") + .arg("--execute") + .arg("--target=standalone") + .current_dir(&t) + .assert() + .success() + .stdout_matches(indoc! {r#" + [..]Compiling hello v0.1.0 ([..]) + [..]Finished `dev` profile target(s) in [..] + [..]Executing hello + Saving output to: target/execute/hello/execution1 + [..]Proving hello + warn: soundness of proof is not yet guaranteed by Stwo, use at your own risk + Saving proof to: target/execute/hello/execution1/proof/proof.json + "#}); + + t.child("target/execute/hello/execution1/proof/proof.json") + .assert(predicates::path::exists()); +} + +#[test] +#[cfg(windows)] +fn prove_fails_on_windows() { + let t = build_executable_project(); + + output_assert( + Scarb::quick_snapbox() + .arg("prove") + .arg("--execute") + .current_dir(&t) + .assert() + .failure(), + indoc! {r#" + error: `scarb prove` is not supported on Windows + help: use WSL or a Linux/macOS machine instead + + "#}, + ) +} + +fn output_assert(output: OutputAssert, expected: &str) { + #[cfg(windows)] + output.stdout_matches(format!( + "{expected}error: process did not exit successfully: exit code: 1\n" + )); + #[cfg(not(windows))] + output.stdout_matches(expected); +}