diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d7d8798613..a7f148fbb7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,13 +9,24 @@ on: env: CARGO_TERM_COLOR: always + CAIRO_PROGRAMS_PATH: | + cairo_programs/**/*.casm + cairo_programs/**/*.json + !cairo_programs/manually_compiled/* + examples/wasm-demo/src/array_sum.json jobs: build-programs: strategy: matrix: # NOTE: we build cairo_proof_programs so clippy can check the benchmarks too - program-target: [ cairo_bench_programs, cairo_proof_programs, cairo_test_programs, cairo_1_test_contracts ] + program-target: [ + cairo_bench_programs, + cairo_proof_programs, + cairo_test_programs, + cairo_1_test_contracts, + cairo_2_test_contracts, + ] name: Build Cairo programs runs-on: ubuntu-22.04 steps: @@ -28,11 +39,7 @@ jobs: uses: actions/cache@v3 id: cache-programs with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json + path: ${{ env.CAIRO_PROGRAMS_PATH }} key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} restore-keys: ${{ matrix.program-target }}-cache- @@ -42,77 +49,102 @@ jobs: uses: chetan/git-restore-mtime-action@v1 - name: Python3 Build - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} + if: steps.cache-programs.outputs.cache-hit != 'true' && matrix.program-target != 'cairo_1_test_contracts' uses: actions/setup-python@v4 with: python-version: '3.9' cache: 'pip' + - name: Install cairo-lang and deps - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} + if: | + steps.cache-programs.outputs.cache-hit != 'true' + && matrix.program-target != 'cairo_1_test_contracts' + && matrix.program-target != 'cairo_2_test_contracts' run: pip install -r requirements.txt - + - name: Install cairo 1 compiler - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} + if: steps.cache-programs.outputs.cache-hit != 'true' && matrix.program-target == 'cairo_1_test_contracts' run: make build-cairo-1-compiler + - name: Install cairo 2 compiler + if: steps.cache-programs.outputs.cache-hit != 'true' && matrix.program-target == 'cairo_2_test_contracts' + run: make build-cairo-2-compiler + - name: Build programs - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} + if: steps.cache-programs.outputs.cache-hit != 'true' run: make -j ${{ matrix.program-target }} - - lint: - needs: build-programs - name: Run Lints + # NOTE: used to reduce the amount of cache steps we need in later jobs + # TODO: remove this cache once the workflow finishes + merge-caches: + name: Merge Cairo programs cache runs-on: ubuntu-22.04 + needs: build-programs steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@1.69.0 - with: - components: rustfmt, clippy - - name: Set up cargo cache - uses: Swatinem/rust-cache@v2 - name: Checkout uses: actions/checkout@v3 - - name: Format - run: make check-fmt - - name: Fetch test programs uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json + path: ${{ env.CAIRO_PROGRAMS_PATH }} key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + fail-on-cache-miss: true - name: Fetch proof programs uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json + path: ${{ env.CAIRO_PROGRAMS_PATH }} key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + fail-on-cache-miss: true - name: Fetch bench programs uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json + path: ${{ env.CAIRO_PROGRAMS_PATH }} key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} - - name: Fetch test contracts + fail-on-cache-miss: true + - name: Fetch test contracts (Cairo 1) uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json + path: ${{ env.CAIRO_PROGRAMS_PATH }} key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + fail-on-cache-miss: true + - name: Fetch test contracts (Cairo 2) + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: cairo_2_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + fail-on-cache-miss: true + + - name: Merge caches + uses: actions/cache/save@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + + lint: + needs: build-programs + name: Run Lints + runs-on: ubuntu-22.04 + steps: + - name: Install Rust + uses: dtolnay/rust-toolchain@1.69.0 + with: + components: rustfmt, clippy + - name: Set up cargo cache + uses: Swatinem/rust-cache@v2 + - name: Checkout + uses: actions/checkout@v3 + + - name: Format + run: make check-fmt + + - name: Fetch programs + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + fail-on-cache-miss: true + - name: Run clippy run: make clippy @@ -120,7 +152,7 @@ jobs: # NOTE: the term "smoke test" comes from electronics design: the minimal # expectations anyone has in their device is to not catch fire on boot. smoke: - needs: build-programs + needs: merge-caches name: Make sure all builds work runs-on: ubuntu-22.04 steps: @@ -141,42 +173,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Fetch test programs - uses: actions/cache/restore@v3 - with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json - key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} - - name: Fetch proof programs - uses: actions/cache/restore@v3 - with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json - key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} - - name: Fetch bench programs - uses: actions/cache/restore@v3 - with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json - key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} - - name: Fetch test contracts + - name: Fetch programs uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json - key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + fail-on-cache-miss: true # NOTE: we do this separately because --workspace operates in weird ways - name: Check all features (felt) @@ -206,7 +208,7 @@ jobs: cargo check tests: - needs: build-programs + needs: merge-caches strategy: fail-fast: false matrix: @@ -224,33 +226,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Fetch test programs - uses: actions/cache/restore@v3 - with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json - key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} - - name: Fetch proof programs - uses: actions/cache/restore@v3 - with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json - key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} - - name: Fetch test contracts + - name: Fetch programs uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json - key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} + fail-on-cache-miss: true - name: Install testing tools uses: taiki-e/install-action@v2 @@ -287,7 +268,6 @@ jobs: path: lcov-${{ matrix.target }}-${{ matrix.special_features }}.info key: codecov-cache-${{ matrix.target }}-${{ matrix.special_features }}-${{ github.sha }} - build-release: name: Build release binary for comparisons runs-on: ubuntu-22.04 @@ -307,7 +287,6 @@ jobs: key: cli-bin-rel-${{ github.sha }} path: target/release/cairo-vm-cli - run-cairo-reference: strategy: matrix: @@ -343,29 +322,27 @@ jobs: with: python-version: '3.9' cache: 'pip' + - name: Install cairo-lang and deps if: steps.trace-cache.outputs.cache-hit != 'true' run: pip install -r requirements.txt - name: Fetch programs - if: ${{ steps.trace-cache.outputs.cache-hit != 'true' }} + if: steps.trace-cache.outputs.cache-hit != 'true' uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json + path: ${{ env.CAIRO_PROGRAMS_PATH }} key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} fail-on-cache-miss: true # This is not pretty, but we need `make` to see the compiled programs are # actually newer than the sources, otherwise it will try to rebuild them - name: Restore timestamps + if: steps.trace-cache.outputs.cache-hit != 'true' uses: chetan/git-restore-mtime-action@v1 - name: Generate traces - if: ${{ steps.trace-cache.outputs.cache-hit != 'true' }} + if: steps.trace-cache.outputs.cache-hit != 'true' run: make -j ${{ matrix.nprocs }} ${{ matrix.trace-target }} @@ -396,11 +373,7 @@ jobs: - name: Fetch programs uses: actions/cache/restore@v3 with: - path: | - cairo_programs/**/*.casm - cairo_programs/**/*.json - !cairo_programs/manually_compiled/* - examples/wasm-demo/src/array_sum.json + path: ${{ env.CAIRO_PROGRAMS_PATH }} key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }} fail-on-cache-miss: true diff --git a/.gitignore b/.gitignore index 673820e3c4..40f3341070 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ bench/results .python-version cairo-vm-env/* cairo-vm-pypy-env/* -cairo/ +/cairo1/ +/cairo2/ +*.tar ensure-no_std/Cargo.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index ceb3657bab..c4a38186e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * fix: return error when a parsed hint's PC is invalid [#1340](https://github.com/lambdaclass/cairo-vm/pull/1340) +* chore(deps): bump _cairo-lang_ dependencies to v2.1.0-rc1 [#1339](https://github.com/lambdaclass/cairo-vm/pull/1339) + * chore(examples): remove _wee_alloc_ dependency from _wasm-demo_ example and _ensure-no_std_ dummy crate [#1337](https://github.com/lambdaclass/cairo-vm/pull/1337) * docs: improved crate documentation [#1334](https://github.com/lambdaclass/cairo-vm/pull/1334) diff --git a/Cargo.lock b/Cargo.lock index 31c4aafc09..6afb52d381 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,9 +35,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "anes" @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "arbitrary" @@ -121,7 +121,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits 0.2.15", "paste", @@ -294,37 +294,37 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cairo-felt" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edaee21a254b549dd00ecb5db15399c8d03b663ddb5a659f7c62ea7e16a3ed85" +version = "0.8.2" dependencies = [ + "arbitrary", + "lambdaworks-math", "lazy_static", "num-bigint", "num-integer", "num-traits 0.2.15", + "proptest", + "rstest", "serde", ] [[package]] name = "cairo-felt" version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f8de851723a7d13ed8b0b588a78ffa6b38d8e1f3eb4b6e71a96376510e5504a" dependencies = [ - "arbitrary", - "lambdaworks-math", "lazy_static", "num-bigint", "num-integer", "num-traits 0.2.15", - "proptest", - "rstest", "serde", ] [[package]] name = "cairo-lang-casm" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe86abd9f988018b39e1e41b467608ad9596ff466f141d41ffecc29a483c2f4" +checksum = "e4d77e9377029b9f1bb92a56ac99740be5d57874e34c858cf8e826bdbb70a7be" dependencies = [ "cairo-lang-utils", "indoc", @@ -339,9 +339,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "220a48cb861ea7dac60f50e7aea044d7c0936ea602f64479e9577d4c4bed5c9e" +checksum = "f7e2b6f7bae3f1d4b285c28c7d795500946d6f76e1bf6b5c9c16289e2689e6c5" dependencies = [ "anyhow", "cairo-lang-defs", @@ -364,18 +364,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd06a99f5ac52f466a64fbdd0615baddb078b9e0cb97fdc7575faea916a66b5" +checksum = "602299c1f77073054aa8d37e26081490b3c7fc7b43168db5e84e906d66e4c2f1" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b8512ee5f8b3a2a18c7ffbaa23a815e56d9f8737ba0d3a0d5dcbf9b2fcbe96b" +checksum = "2187d0c4d3d6744ee1025d3811f8967bc4d3c1491ac2b71beb4fb4f2c8600ca8" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -383,41 +383,42 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 1.9.3", - "itertools", + "indexmap 2.0.0", + "itertools 0.11.0", "salsa", "smol_str", ] [[package]] name = "cairo-lang-diagnostics" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a351f6441a55ce70b7ba62814670d0c154b2fdc4a7453387b71027a8440da2" +checksum = "d6e134c69abf3826e923f1198df6caa4316ead032ea90cbd64ae3b5359fcd99b" dependencies = [ + "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", - "itertools", + "itertools 0.11.0", "salsa", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824ee8e225355e09ac57f537a9612049e4367b2bd3934d0591559bf87337cdbe" +checksum = "c943285725a411e133285910f240777348e42ca0de52f8c70b7fafd214b81172" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 1.9.3", - "itertools", + "indexmap 2.0.0", + "itertools 0.11.0", ] [[package]] name = "cairo-lang-filesystem" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1da7ceb69b84fb8b0d6e4d4648c4f2218feddcf0b9929094358b2bd3b2603ef0" +checksum = "a4f7795bc7ec242c2b91a7cc479e4390dfb33571c5f6bdf98f771674c46c0173" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -429,9 +430,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a70fb2960cc39ceee250090109f9df05b26f781dab8c0ba48b6fd6f663858587" +checksum = "106a31061cde4e5075f6c76b4242a05661261df46666865a1ba4cecd47aea277" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -443,8 +444,8 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 1.9.3", - "itertools", + "indexmap 2.0.0", + "itertools 0.11.0", "log", "num-bigint", "num-traits 0.2.15", @@ -454,9 +455,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c44c66f5aeb3d80189f4f2fd0bc6872b4c6f5cc25002402dc6e85561d2cc53" +checksum = "62578dc0409c95148926553cb46bf693fe9ad9f10df10523b39c63ecf5803a57" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -464,7 +465,7 @@ dependencies = [ "cairo-lang-syntax-codegen", "cairo-lang-utils", "colored", - "itertools", + "itertools 0.11.0", "log", "num-bigint", "num-traits 0.2.15", @@ -475,9 +476,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0acfa9aca2811c5df6d72a160c4168fd6cc53eb3c3f966c933e791b0f91ce01" +checksum = "53218b75ba60f049aa5f0993fd0957ebd0c0085bdce8426e4cc65bd6e6665514" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -487,27 +488,28 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "indoc", - "itertools", + "itertools 0.11.0", + "num-bigint", "salsa", "smol_str", ] [[package]] name = "cairo-lang-proc-macros" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e5ce4ad906f6491bc82eaae14eea6a96755d651a8809fc1adb53feb99bcc55a" +checksum = "e12e9a359d2f27dea40eb641ae8ec5c87699ea1a40b7108e19f9c51148c229d9" dependencies = [ "cairo-lang-debug", "quote", - "syn 1.0.109", + "syn 2.0.26", ] [[package]] name = "cairo-lang-project" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f7c638a2a30010071a176396c29bc065701f353f2c3205b96f03463b54721c" +checksum = "2c116822f3cb7f34f13c70a0488bc69b69070975b63b15963dbdc8d8ae5ae074" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -519,9 +521,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb3e68af88e60a1e30776877b0a3a346a21a3d15c54c9f8ace844e0652b1036f" +checksum = "537a741d6c456e7c4576f72a7fb6a533a97f599f92a401f9c997e3fee7ee435f" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -532,7 +534,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "itertools", + "itertools 0.11.0", "log", "num-bigint", "num-traits 0.2.15", @@ -542,15 +544,15 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4ccc934f2d4a063f7f72554d422e724134925c981cd0e592b4defb73ca103a" +checksum = "8ce8f7ffaf6b402a29b7d811a4b15e033833abcb9acb4a4b5b9d0f93b8de350e" dependencies = [ "cairo-lang-utils", "const-fnv1a-hash", "convert_case", "derivative", - "itertools", + "itertools 0.11.0", "lalrpop", "lalrpop-util", "num-bigint", @@ -565,35 +567,37 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad6e742ec576f773c9d6c4f1e4be6fbe9f1e5b470cd374f27f5c82e15c151b85" +checksum = "688d633166460663d6895c3f9d9d0b031c566b8eca34201e24af866847a4548c" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", + "cairo-lang-sierra-type-size", "cairo-lang-utils", - "itertools", + "itertools 0.11.0", "thiserror", ] [[package]] name = "cairo-lang-sierra-gas" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc4e1b3793f639724f59f34eb4007253a91d5179de8b2ab2c511c6c5d56155c" +checksum = "0e37877fd5d19a22fee00ed72d2217b129d7f97f4fdf37afc6e6ff0c3bd2123a" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", + "cairo-lang-sierra-type-size", "cairo-lang-utils", - "itertools", + "itertools 0.11.0", "thiserror", ] [[package]] name = "cairo-lang-sierra-generator" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20c323c6f656398254f9404126c4a60e0a5234214255590288783eb323f6f187" +checksum = "734245388612b7ddf4db9af1fe5bc65af94971c3abb4f8c906d665a8db4fcbf3" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -608,8 +612,8 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 1.9.3", - "itertools", + "indexmap 2.0.0", + "itertools 0.11.0", "num-bigint", "salsa", "smol_str", @@ -617,33 +621,44 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b26fffdbf578f9aaf00d74001ac93cad4a713b510642161a0594f1403a59c543" +checksum = "9332bda0bf18796f6a0451273f3af258a9e5506d827e59513c133142b1a7b799" dependencies = [ "assert_matches", - "cairo-felt 0.6.1", + "cairo-felt 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-lang-casm", "cairo-lang-sierra", "cairo-lang-sierra-ap-change", "cairo-lang-sierra-gas", + "cairo-lang-sierra-type-size", "cairo-lang-utils", "indoc", - "itertools", + "itertools 0.11.0", "log", "num-bigint", "num-traits 0.2.15", "thiserror", ] +[[package]] +name = "cairo-lang-sierra-type-size" +version = "2.1.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05c2286578d70effc2f7c0809423ed3d08ef245d972fce761630fc7cc1bc60c" +dependencies = [ + "cairo-lang-sierra", + "cairo-lang-utils", +] + [[package]] name = "cairo-lang-starknet" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c63e026127221a7bb5b5081b631eeef552a99cbdae76414dced7a224694afeaa" +checksum = "7ce74a95498dee8c6aa90628f19d557a0cbe1f5629dc580f4e0e67c507fe3590" dependencies = [ "anyhow", - "cairo-felt 0.6.1", + "cairo-felt 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-lang-casm", "cairo-lang-compiler", "cairo-lang-defs", @@ -662,8 +677,9 @@ dependencies = [ "cairo-lang-utils", "convert_case", "genco", + "indent", "indoc", - "itertools", + "itertools 0.11.0", "log", "num-bigint", "num-integer", @@ -678,9 +694,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6b48a1c67679bc19165c2ce45b38e7bc7ce5a4fbb004a07f60361f99b618e73" +checksum = "0a4d3c4b254f230e753813577286e8d16adff9394eff157d788b2c05d65fb0d7" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -695,9 +711,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2102b91819a7638f1efb39379351578a296d042de53f7492684eeb47c3a844" +checksum = "ab56670412d34e5e078c19b85475c972c09b37d0e9ab3be1ad15b133a3152a2b" dependencies = [ "genco", "xshell", @@ -705,12 +721,12 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.0.1" +version = "2.1.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25d0873d45a7f6020fa39ebda1386a20d328bf5e448056d5a507641d0bfde0cf" +checksum = "6ea7705809dee18eaff81473292c113e3ca285ffaa907c2055d0a33fcb9dbc77" dependencies = [ - "indexmap 1.9.3", - "itertools", + "indexmap 2.0.0", + "itertools 0.11.0", "num-bigint", "num-integer", "num-traits 0.2.15", @@ -819,9 +835,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.11" +version = "4.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +checksum = "5b0827b011f6f8ab38590295339817b0d26f344aa4932c3ced71b45b0c54b4a9" dependencies = [ "clap_builder", "clap_derive", @@ -830,9 +846,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.11" +version = "4.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +checksum = "9441b403be87be858db6a23edb493e7f694761acdc3343d5a0fcaafd304cbc9e" dependencies = [ "anstream", "anstyle", @@ -842,14 +858,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -921,7 +937,7 @@ dependencies = [ "clap", "criterion-plot", "is-terminal", - "itertools", + "itertools 0.10.5", "num-traits 0.2.15", "once_cell", "oorandom", @@ -942,7 +958,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -1040,7 +1056,7 @@ checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -1083,9 +1099,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" [[package]] name = "either" @@ -1104,9 +1120,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" @@ -1131,12 +1147,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "fixedbitset" @@ -1212,7 +1225,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -1298,9 +1311,9 @@ dependencies = [ [[package]] name = "good_lp" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed4d07599e3cdb52477f1d36bef936c89ce854c452e7026b2ba327b93c86f61" +checksum = "c0833c2bc3cee9906df9969ade12b0b3b8759faa7bc2682b428be767033cdcd4" dependencies = [ "fnv", "minilp", @@ -1422,6 +1435,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indent" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f1a0777d972970f204fdf8ef319f1f4f8459131636d7e3c96c5d59570d0fa6" + [[package]] name = "indexmap" version = "1.9.3" @@ -1441,13 +1460,14 @@ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", "hashbrown 0.14.0", + "serde", ] [[package]] name = "indoc" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "761cde40c27e2a9877f8c928fd248b7eec9dd48623dd514b256858ca593fbba7" +checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" [[package]] name = "instant" @@ -1458,17 +1478,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - [[package]] name = "is-terminal" version = "0.4.9" @@ -1476,7 +1485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.3", + "rustix", "windows-sys", ] @@ -1489,11 +1498,20 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" @@ -1515,20 +1533,21 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.19.12" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" +checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" dependencies = [ "ascii-canvas", "bit-set", "diff", "ena", "is-terminal", - "itertools", + "itertools 0.10.5", "lalrpop-util", "petgraph", + "pico-args", "regex", - "regex-syntax 0.6.29", + "regex-syntax 0.7.4", "string_cache", "term", "tiny-keccak", @@ -1537,9 +1556,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.12" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" +checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" dependencies = [ "regex", ] @@ -1585,12 +1604,6 @@ dependencies = [ "libc", ] -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.3" @@ -1804,9 +1817,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "parity-scale-codec" -version = "3.6.3" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756d439303e94fae44f288ba881ad29670c65b0c4b0e05674ca81061bb65f2c5" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec", "bitvec", @@ -1817,9 +1830,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.3" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d884d78fcf214d70b1e239fcd1c6e5e95aa3be1881918da2e488cc946c7a476" +checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1877,15 +1890,15 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "path-clean" -version = "0.1.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" +checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" [[package]] name = "petgraph" @@ -1906,6 +1919,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project-lite" version = "0.2.10" @@ -1970,9 +1989,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -2005,9 +2024,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.29" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" dependencies = [ "proc-macro2", ] @@ -2123,18 +2142,18 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.7.3", + "regex-syntax 0.7.4", ] [[package]] name = "regex-automata" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" +checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.3", + "regex-syntax 0.7.4", ] [[package]] @@ -2145,9 +2164,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "relative-path" @@ -2208,36 +2227,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys", -] - -[[package]] -name = "rustix" -version = "0.38.3" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" dependencies = [ "bitflags 2.3.3", "errno", "libc", - "linux-raw-sys 0.4.3", + "linux-raw-sys", "windows-sys", ] [[package]] name = "rustversion" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "rusty-fork" @@ -2253,9 +2258,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "salsa" @@ -2328,34 +2333,34 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.171" +version = "1.0.173" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "e91f70896d6720bc714a4a57d22fc91f1db634680e65c8efe13323f1fa38d53f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.173" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "a6250dde8342e0232232be9ca3db7aa40aceb5a3e5dd9bddbc00d99a007cde49" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2371,15 +2376,24 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.100" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" +checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde", +] + [[package]] name = "sha2" version = "0.10.7" @@ -2491,7 +2505,7 @@ checksum = "af6527b845423542c8a16e060ea1bc43f67229848e7cd4c4d80be994a84220ce" dependencies = [ "starknet-curve 0.4.0", "starknet-ff", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2545,9 +2559,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -2562,9 +2576,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.25" +version = "2.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" dependencies = [ "proc-macro2", "quote", @@ -2579,15 +2593,14 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" dependencies = [ - "autocfg", "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.23", + "rustix", "windows-sys", ] @@ -2619,7 +2632,7 @@ checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2663,11 +2676,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.10" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", ] [[package]] @@ -2675,14 +2691,19 @@ name = "toml_datetime" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" -version = "0.19.12" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ "indexmap 2.0.0", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] @@ -2710,9 +2731,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-segmentation" @@ -2790,7 +2811,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", "wasm-bindgen-shared", ] @@ -2824,7 +2845,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2979,9 +3000,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.9" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" +checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7" dependencies = [ "memchr", ] @@ -2997,18 +3018,18 @@ dependencies = [ [[package]] name = "xshell" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "962c039b3a7b16cf4e9a4248397c6585c07547412e7d6a6e035389a802dcfe90" +checksum = "ce2107fe03e558353b4c71ad7626d58ed82efaf56c54134228608893c77023ad" dependencies = [ "xshell-macros", ] [[package]] name = "xshell-macros" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dbabb1cbd15a1d6d12d9ed6b35cc6777d4af87ab3ba155ea37215f20beab80c" +checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" [[package]] name = "zeroize" @@ -3027,5 +3048,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] diff --git a/Cargo.toml b/Cargo.toml index 171c7683cf..55b0167a28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,8 +61,8 @@ thiserror-no-std = { version = "2.0.2", default-features = false } bitvec = { version = "1", default-features = false, features = ["alloc"] } # Dependencies for cairo-1-hints feature -cairo-lang-starknet = { version = "2.0.0", default-features = false } -cairo-lang-casm = { version = "2.0.0", default-features = false } +cairo-lang-starknet = { version = "2.1.0-rc1", default-features = false } +cairo-lang-casm = { version = "2.1.0-rc1", default-features = false } # TODO: check these dependencies for wasm compatibility ark-ff = { version = "0.4.2", default-features = false } diff --git a/Makefile b/Makefile index df23ec3e7e..fc1cef6e1d 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,20 @@ RELBIN:=target/release/cairo-vm-run DBGBIN:=target/debug/cairo-vm-run -STARKNET_COMPILE:=cairo/target/release/starknet-compile -STARKNET_SIERRA_COMPILE:=cairo/target/release/starknet-sierra-compile -.PHONY: build-cairo-1-compiler deps deps-macos cargo-deps build run check test clippy coverage benchmark flamegraph \ +STARKNET_COMPILE_CAIRO_1:=cairo1/bin/starknet-compile +STARKNET_SIERRA_COMPILE_CAIRO_1:=cairo1/bin/starknet-sierra-compile + +STARKNET_COMPILE_CAIRO_2:=cairo2/bin/starknet-compile +STARKNET_SIERRA_COMPILE_CAIRO_2:=cairo2/bin/starknet-sierra-compile + +.PHONY: build-cairo-1-compiler build-cairo-1-compiler-macos build-cairo-2-compiler build-cairo-2-compiler-macos \ + deps deps-macos cargo-deps build run check test clippy coverage benchmark flamegraph \ compare_benchmarks_deps compare_benchmarks docs clean \ compare_vm_output compare_trace_memory compare_trace compare_memory \ compare_trace_memory_proof compare_trace_proof compare_memory_proof \ - cairo_bench_programs cairo_proof_programs cairo_test_programs \ + cairo_bench_programs cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts \ cairo_trace cairo-vm_trace cairo_proof_trace cairo-vm_proof_trace \ - $(RELBIN) $(DBGBIN) $(STARKNET_COMPILE) $(STARKNET_SIERRA_COMPILE) \ - example_programs + $(RELBIN) $(DBGBIN) example_programs # Proof mode consumes too much memory with cairo-lang to execute # two instances at the same time in the CI without getting killed @@ -98,22 +102,74 @@ $(BAD_TEST_DIR)/%.json: $(BAD_TEST_DIR)/%.cairo CAIRO_1_CONTRACTS_TEST_DIR=cairo_programs/cairo-1-contracts CAIRO_1_CONTRACTS_TEST_CAIRO_FILES:=$(wildcard $(CAIRO_1_CONTRACTS_TEST_DIR)/*.cairo) -COMPILED_SIERRA_CONTRACTS:=$(patsubst $(CAIRO_1_CONTRACTS_TEST_DIR)/%.cairo, $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_1_CONTRACTS_TEST_CAIRO_FILES)) -COMPILED_CASM_CONTRACTS:= $(patsubst $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_1_CONTRACTS_TEST_DIR)/%.casm, $(COMPILED_SIERRA_CONTRACTS)) +CAIRO_1_COMPILED_SIERRA_CONTRACTS:=$(patsubst $(CAIRO_1_CONTRACTS_TEST_DIR)/%.cairo, $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_1_CONTRACTS_TEST_CAIRO_FILES)) +CAIRO_1_COMPILED_CASM_CONTRACTS:= $(patsubst $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_1_CONTRACTS_TEST_DIR)/%.casm, $(CAIRO_1_COMPILED_SIERRA_CONTRACTS)) $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra: $(CAIRO_1_CONTRACTS_TEST_DIR)/%.cairo - $(STARKNET_COMPILE) --allowed-libfuncs-list-name experimental_v0.1.0 $< $@ + $(STARKNET_COMPILE_CAIRO_1) --allowed-libfuncs-list-name experimental_v0.1.0 $< $@ $(CAIRO_1_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_1_CONTRACTS_TEST_DIR)/%.sierra - $(STARKNET_SIERRA_COMPILE) --allowed-libfuncs-list-name experimental_v0.1.0 $< $@ + $(STARKNET_SIERRA_COMPILE_CAIRO_1) --allowed-libfuncs-list-name experimental_v0.1.0 $< $@ + +# ====================== +# Setup Cairo 1 Compiler +# ====================== + +cairo-repo-1-dir = cairo1 +cairo-repo-1-dir-macos = cairo1-macos + +build-cairo-1-compiler-macos: | $(cairo-repo-1-dir-macos) + +$(cairo-repo-1-dir-macos): + curl -L -o cairo-1.1.1.tar https://github.com/starkware-libs/cairo/releases/download/v1.1.1/release-aarch64-apple-darwin.tar \ + && tar -xzvf cairo-1.1.1.tar \ + && mv cairo/ cairo1/ + +build-cairo-1-compiler: | $(cairo-repo-1-dir) + +$(cairo-repo-1-dir): + curl -L -o cairo-1.1.1.tar https://github.com/starkware-libs/cairo/releases/download/v1.1.1/release-x86_64-unknown-linux-musl.tar.gz \ + && tar -xzvf cairo-1.1.1.tar \ + && mv cairo/ cairo1/ + +# ====================== +# Test Cairo 2 Contracts +# ====================== + +CAIRO_2_CONTRACTS_TEST_DIR=cairo_programs/cairo-2-contracts +CAIRO_2_CONTRACTS_TEST_CAIRO_FILES:=$(wildcard $(CAIRO_2_CONTRACTS_TEST_DIR)/*.cairo) +CAIRO_2_COMPILED_SIERRA_CONTRACTS:=$(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.cairo, $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_2_CONTRACTS_TEST_CAIRO_FILES)) +CAIRO_2_COMPILED_CASM_CONTRACTS:= $(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm, $(CAIRO_2_COMPILED_SIERRA_CONTRACTS)) + +$(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.cairo + $(STARKNET_COMPILE_CAIRO_2) --single-file $< $@ + +$(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra + $(STARKNET_SIERRA_COMPILE_CAIRO_2) $< $@ + + +# ====================== +# Setup Cairo 2 Compiler +# ====================== + +cairo-repo-2-dir = cairo2 +cairo-repo-2-dir-macos = cairo2-macos + +build-cairo-2-compiler-macos: | $(cairo-repo-2-dir-macos) + +CAIRO_2_VERSION=2.1.0-rc1 -cairo-repo-dir = cairo +$(cairo-repo-2-dir-macos): + curl -L -o cairo-${CAIRO_2_VERSION}.tar https://github.com/starkware-libs/cairo/releases/download/v${CAIRO_2_VERSION}/release-aarch64-apple-darwin.tar \ + && tar -xzvf cairo-${CAIRO_2_VERSION}.tar \ + && mv cairo/ cairo2/ -build-cairo-1-compiler: | $(cairo-repo-dir) +build-cairo-2-compiler: | $(cairo-repo-2-dir) -$(cairo-repo-dir): - git clone --depth 1 -b v1.1.0 https://github.com/starkware-libs/cairo.git - cd cairo; cargo b --release --bin starknet-compile --bin starknet-sierra-compile +$(cairo-repo-2-dir): + curl -L -o cairo-${CAIRO_2_VERSION}.tar https://github.com/starkware-libs/cairo/releases/download/v${CAIRO_2_VERSION}/release-x86_64-unknown-linux-musl.tar.gz \ + && tar -xzvf cairo-${CAIRO_2_VERSION}.tar \ + && mv cairo/ cairo2/ cargo-deps: cargo install --version 0.3.1 iai-callgrind-runner @@ -124,7 +180,7 @@ cargo-deps: cargo install --version 0.5.9 cargo-llvm-cov cargo install --version 0.11.0 wasm-pack -deps: cargo-deps build-cairo-1-compiler +deps: cargo-deps build-cairo-1-compiler build-cairo-2-compiler pyenv install -s pypy3.9-7.3.9 PYENV_VERSION=pypy3.9-7.3.9 python -m venv cairo-vm-pypy-env . cairo-vm-pypy-env/bin/activate ; \ @@ -134,7 +190,7 @@ deps: cargo-deps build-cairo-1-compiler . cairo-vm-env/bin/activate ; \ pip install -r requirements.txt ; \ -deps-macos: cargo-deps build-cairo-1-compiler +deps-macos: cargo-deps build-cairo-1-compiler-macos build-cairo-2-compiler-macos arch -x86_64 pyenv install -s pypy3.9-7.3.9 PYENV_VERSION=pypy3.9-7.3.9 python -m venv cairo-vm-pypy-env . cairo-vm-pypy-env/bin/activate ; \ @@ -164,7 +220,8 @@ example_programs: examples/wasm-demo/src/array_sum.json cairo_test_programs: $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) example_programs cairo_proof_programs: $(COMPILED_PROOF_TESTS) cairo_bench_programs: $(COMPILED_BENCHES) -cairo_1_test_contracts: $(COMPILED_CASM_CONTRACTS) +cairo_1_test_contracts: $(CAIRO_1_COMPILED_CASM_CONTRACTS) +cairo_2_test_contracts: $(CAIRO_2_COMPILED_CASM_CONTRACTS) cairo_proof_trace: $(CAIRO_TRACE_PROOF) $(CAIRO_MEM_PROOF) cairo-vm_proof_trace: $(CAIRO_RS_TRACE_PROOF) $(CAIRO_RS_MEM_PROOF) @@ -172,11 +229,11 @@ cairo-vm_proof_trace: $(CAIRO_RS_TRACE_PROOF) $(CAIRO_RS_MEM_PROOF) cairo_trace: $(CAIRO_TRACE) $(CAIRO_MEM) cairo-vm_trace: $(CAIRO_RS_TRACE) $(CAIRO_RS_MEM) -test: $(COMPILED_PROOF_TESTS) $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) $(COMPILED_CASM_CONTRACTS) +test: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cargo llvm-cov nextest --no-report --workspace --features "test_utils, cairo-1-hints" -test-no_std: $(COMPILED_PROOF_TESTS) $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) +test-no_std: cairo_proof_programs cairo_test_programs cargo llvm-cov nextest --no-report --workspace --features test_utils --no-default-features -test-wasm: $(COMPILED_PROOF_TESTS) $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) +test-wasm: cairo_proof_programs cairo_test_programs # NOTE: release mode is needed to avoid "too many locals" error wasm-pack test --release --node vm --no-default-features @@ -194,20 +251,20 @@ coverage: coverage-clean: cargo llvm-cov clean -benchmark: $(COMPILED_BENCHES) +benchmark: cairo_bench_programs cargo criterion --bench criterion_benchmark @echo 'Report: target/criterion/reports/index.html' -benchmark-action: $(COMPILED_BENCHES) +benchmark-action: cairo_bench_programs cargo bench --bench criterion_benchmark -- --output-format bencher |sed 1d | tee output.txt -iai-benchmark-action: $(COMPILED_BENCHES) +iai-benchmark-action: cairo_bench_programs cargo bench --bench iai_benchmark flamegraph: cargo flamegraph --root --bench criterion_benchmark -- --bench -compare_benchmarks: $(COMPILED_BENCHES) +compare_benchmarks: cairo_bench_programs cd bench && ./run_benchmarks.sh compare_trace_memory: $(CAIRO_RS_TRACE) $(CAIRO_TRACE) $(CAIRO_RS_MEM) $(CAIRO_MEM) diff --git a/cairo_programs/cairo-1-contracts/uint256_div_mod.cairo b/cairo_programs/cairo-1-contracts/uint256_div_mod.cairo deleted file mode 100644 index b94d120458..0000000000 --- a/cairo_programs/cairo-1-contracts/uint256_div_mod.cairo +++ /dev/null @@ -1,42 +0,0 @@ -#[contract] -mod TestUint256DivMod { - use zeroable::IsZeroResult; - use zeroable::NonZeroIntoImpl; - use zeroable::NonZero; - use core::traits::Into; - use traits::TryInto; - use integer::BoundedInt; - - #[external] - fn test_uint256_div_mod_max() { - let a = BoundedInt::max(); - - let b = as_u256(1_u128, 0); - let b = integer::u256_as_non_zero(b); - - let (res, _) = integer::u256_safe_divmod(a, b); - - assert(a==res, 'div failed') - } - - - #[external] - fn test_uint256_div_mod(a:u128, b:u128) -> felt252 { - let a = as_u256(a, 0); - let b = as_u256(b, 0); - - let b = integer::u256_as_non_zero(b); - - let (res, _) = integer::u256_safe_divmod(a, b); - - return res.low.into(); - } - - #[internal] - fn as_u256(a: u128, b: u128) -> u256{ - u256{ - low: a, - high: b - } - } -} \ No newline at end of file diff --git a/cairo_programs/cairo-2-contracts/uint256_div_mod.cairo b/cairo_programs/cairo-2-contracts/uint256_div_mod.cairo new file mode 100644 index 0000000000..e06dec4ed7 --- /dev/null +++ b/cairo_programs/cairo-2-contracts/uint256_div_mod.cairo @@ -0,0 +1,47 @@ +#[starknet::interface] +trait ITestUint256DivMod { + fn test_uint256_div_mod_max(ref self: TContractState); + fn test_uint256_div_mod(ref self: TContractState, a: u128, b: u128) -> felt252; +} + +#[starknet::contract] +mod TestUint256DivMod { + use zeroable::IsZeroResult; + use zeroable::NonZeroIntoImpl; + use zeroable::NonZero; + use core::traits::Into; + use traits::TryInto; + use integer::BoundedInt; + + #[storage] + struct Storage {} + + #[external(v0)] + impl TestUint256DivMod of super::ITestUint256DivMod { + fn test_uint256_div_mod_max(ref self: ContractState) { + let a = BoundedInt::max(); + + let b = as_u256(1_u128, 0); + let b = integer::u256_as_non_zero(b); + + let (div, _, _) = integer::u256_safe_divmod(a, b); + + assert(div == a, 'div failed'); + } + + fn test_uint256_div_mod(ref self: ContractState, a: u128, b: u128) -> felt252 { + let a = as_u256(a, 0); + let b = as_u256(b, 0); + + let b = integer::u256_as_non_zero(b); + + let (div, _, _) = integer::u256_safe_divmod(a, b); + + return div.low.into(); + } + } + + fn as_u256(a: u128, b: u128) -> u256 { + u256 { low: a, high: b } + } +} diff --git a/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs b/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs index 56f4434ec0..8fa775a125 100644 --- a/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs +++ b/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs @@ -27,7 +27,7 @@ use core::ops::Shl; use num_bigint::BigUint; use num_integer::Integer; -use num_traits::{cast::ToPrimitive, Zero}; +use num_traits::cast::ToPrimitive; /// Execution scope for constant memory allocation. struct MemoryExecScope { @@ -124,32 +124,18 @@ impl Cairo1HintProcessor { } Hint::Core(CoreHintBase::Core(CoreHint::Uint256DivMod { - dividend_low, - dividend_high, - divisor_low, - divisor_high, - quotient0, - quotient1, + dividend0, + dividend1, divisor0, divisor1, - extra0, - extra1, - remainder_low, - remainder_high, - })) => self.uint256_div_mod( - vm, - dividend_low, - dividend_high, - divisor_low, - divisor_high, quotient0, quotient1, - divisor0, - divisor1, - extra0, - extra1, - remainder_low, - remainder_high, + + remainder0, + remainder1, + })) => self.uint256_div_mod( + vm, dividend0, dividend1, divisor0, divisor1, quotient0, quotient1, remainder0, + remainder1, ), Hint::Core(CoreHintBase::Deprecated(DeprecatedHint::Felt252DictWrite { dict_ptr, @@ -410,64 +396,42 @@ impl Cairo1HintProcessor { fn uint256_div_mod( &self, vm: &mut VirtualMachine, - dividend_low: &ResOperand, - dividend_high: &ResOperand, - divisor_low: &ResOperand, - divisor_high: &ResOperand, + dividend0: &ResOperand, + dividend1: &ResOperand, + divisor0: &ResOperand, + divisor1: &ResOperand, quotient0: &CellRef, quotient1: &CellRef, - divisor0: &CellRef, - divisor1: &CellRef, - extra0: &CellRef, - extra1: &CellRef, - remainder_low: &CellRef, - remainder_high: &CellRef, + remainder0: &CellRef, + remainder1: &CellRef, ) -> Result<(), HintError> { let pow_2_128 = BigUint::from(u128::MAX) + 1u32; - let pow_2_64 = BigUint::from(u64::MAX) + 1u32; - let dividend_low = res_operand_get_val(vm, dividend_low)?.to_biguint(); - let dividend_high = res_operand_get_val(vm, dividend_high)?.to_biguint(); - let divisor_low = res_operand_get_val(vm, divisor_low)?.to_biguint(); - let divisor_high = res_operand_get_val(vm, divisor_high)?.to_biguint(); - let dividend = dividend_low + dividend_high * &pow_2_128; - let divisor = divisor_low + &divisor_high * &pow_2_128; - let quotient = ÷nd / &divisor; - let remainder = dividend % &divisor; - - // Guess quotient limbs. - let (quotient, limb) = quotient.div_rem(&pow_2_64); - vm.insert_value(cell_ref_to_relocatable(quotient0, vm)?, Felt252::from(limb))?; - let (quotient, limb) = quotient.div_rem(&pow_2_64); - vm.insert_value(cell_ref_to_relocatable(quotient1, vm)?, Felt252::from(limb))?; - let (quotient, limb) = quotient.div_rem(&pow_2_64); - if divisor_high.is_zero() { - vm.insert_value(cell_ref_to_relocatable(extra0, vm)?, Felt252::from(limb))?; - vm.insert_value( - cell_ref_to_relocatable(extra1, vm)?, - Felt252::from(quotient), - )?; - } - - // Guess divisor limbs. - let (divisor, limb) = divisor.div_rem(&pow_2_64); - vm.insert_value(cell_ref_to_relocatable(divisor0, vm)?, Felt252::from(limb))?; - let (divisor, limb) = divisor.div_rem(&pow_2_64); - vm.insert_value(cell_ref_to_relocatable(divisor1, vm)?, Felt252::from(limb))?; - let (divisor, limb) = divisor.div_rem(&pow_2_64); - if !divisor_high.is_zero() { - vm.insert_value(cell_ref_to_relocatable(extra0, vm)?, Felt252::from(limb))?; - vm.insert_value(cell_ref_to_relocatable(extra1, vm)?, Felt252::from(divisor))?; - } - - // Guess remainder limbs. + let dividend0 = get_val(vm, dividend0)?.to_biguint(); + let dividend1 = get_val(vm, dividend1)?.to_biguint(); + let divisor0 = get_val(vm, divisor0)?.to_biguint(); + let divisor1 = get_val(vm, divisor1)?.to_biguint(); + let dividend: BigUint = dividend0 + dividend1.shl(128); + let divisor = divisor0 + divisor1.shl(128); + let (quotient, remainder) = dividend.div_rem(&divisor); + let (limb1, limb0) = quotient.div_rem(&pow_2_128); vm.insert_value( - cell_ref_to_relocatable(remainder_low, vm)?, - Felt252::from(remainder.clone() % pow_2_128.clone()), + cell_ref_to_relocatable(quotient0, vm)?, + Felt252::from(limb0), )?; vm.insert_value( - cell_ref_to_relocatable(remainder_high, vm)?, - Felt252::from(remainder / pow_2_128), + cell_ref_to_relocatable(quotient1, vm)?, + Felt252::from(limb1), + )?; + let (limb1, limb0) = remainder.div_rem(&pow_2_128); + vm.insert_value( + cell_ref_to_relocatable(remainder0, vm)?, + Felt252::from(limb0), + )?; + vm.insert_value( + cell_ref_to_relocatable(remainder1, vm)?, + Felt252::from(limb1), )?; + Ok(()) } diff --git a/vm/src/hint_processor/cairo_1_hint_processor/hint_processor_utils.rs b/vm/src/hint_processor/cairo_1_hint_processor/hint_processor_utils.rs index 82159fffca..615f65ed99 100644 --- a/vm/src/hint_processor/cairo_1_hint_processor/hint_processor_utils.rs +++ b/vm/src/hint_processor/cairo_1_hint_processor/hint_processor_utils.rs @@ -29,6 +29,29 @@ pub(crate) fn extract_buffer(buffer: &ResOperand) -> Result<(&CellRef, Felt252), Ok((cell, base_offset)) } +/// Fetches the value of `res_operand` from the vm. +pub(crate) fn get_val( + vm: &VirtualMachine, + res_operand: &ResOperand, +) -> Result { + match res_operand { + ResOperand::Deref(cell) => get_cell_val(vm, cell), + ResOperand::DoubleDeref(cell, offset) => get_double_deref_val(vm, cell, &(*offset).into()), + ResOperand::Immediate(x) => Ok(Felt252::from(x.value.clone())), + ResOperand::BinOp(op) => { + let a = get_cell_val(vm, &op.a)?; + let b = match &op.b { + DerefOrImmediate::Deref(cell) => get_cell_val(vm, cell)?, + DerefOrImmediate::Immediate(x) => Felt252::from(x.value.clone()), + }; + match op.op { + Operation::Add => Ok(a + b), + Operation::Mul => Ok(a * b), + } + } + } +} + pub(crate) fn cell_ref_to_relocatable( cell_ref: &CellRef, vm: &VirtualMachine, diff --git a/vm/src/tests/cairo_1_run_from_entrypoint_tests.rs b/vm/src/tests/cairo_1_run_from_entrypoint_tests.rs index 70e88dcba8..e64564d298 100644 --- a/vm/src/tests/cairo_1_run_from_entrypoint_tests.rs +++ b/vm/src/tests/cairo_1_run_from_entrypoint_tests.rs @@ -28,7 +28,7 @@ fn dict_hint_test() { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_uint256_div_mod_hint_max_value() { let program_data = - include_bytes!("../../../cairo_programs/cairo-1-contracts/uint256_div_mod.casm"); + include_bytes!("../../../cairo_programs/cairo-2-contracts/uint256_div_mod.casm"); run_cairo_1_entrypoint(program_data.as_slice(), 0, &[], &[]); } @@ -37,11 +37,11 @@ fn test_uint256_div_mod_hint_max_value() { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_uint256_div_mod_hint() { let program_data = - include_bytes!("../../../cairo_programs/cairo-1-contracts/uint256_div_mod.casm"); + include_bytes!("../../../cairo_programs/cairo-2-contracts/uint256_div_mod.casm"); run_cairo_1_entrypoint( program_data.as_slice(), - 118, + 107, &[36_usize.into(), 2_usize.into()], &[Felt252::from(18_usize)], );