From 3875e4334a28f56ac9e292e47ce3c3476e25917b Mon Sep 17 00:00:00 2001 From: Shramee Srivastav Date: Mon, 18 Mar 2024 13:57:43 +0530 Subject: [PATCH] Cairo v2.6.3 (#200) cairo v2.6.3 --- Cargo.lock | 885 ++++++------------- Cargo.toml | 12 +- corelib/Scarb.lock | 6 - corelib/Scarb.toml | 3 +- corelib/cairo_project.toml | 1 + corelib/src/array.cairo | 6 +- corelib/src/byte_array.cairo | 11 +- corelib/src/bytes_31.cairo | 57 +- corelib/src/cmp.cairo | 37 +- corelib/src/ec.cairo | 44 +- corelib/src/ecdsa.cairo | 43 +- corelib/src/integer.cairo | 310 ++++++- corelib/src/lib.cairo | 12 +- corelib/src/num/traits.cairo | 4 + corelib/src/num/traits/ops.cairo | 2 + corelib/src/num/traits/ops/overflowing.cairo | 23 + corelib/src/num/traits/ops/wrapping.cairo | 49 + corelib/src/starknet/secp256_trait.cairo | 2 +- corelib/src/test.cairo | 3 + corelib/src/test/array_test.cairo | 8 + corelib/src/test/cmp_test.cairo | 16 +- corelib/src/test/const_test.cairo | 134 +++ corelib/src/test/coupon_test.cairo | 26 + corelib/src/test/integer_test.cairo | 11 + corelib/src/test/math_test.cairo | 85 +- corelib/src/test/num_test.cairo | 220 +++++ corelib/src/test/testing_test.cairo | 44 + corelib/src/test/while_test.cairo | 27 + exercises/enums/enums3.cairo | 16 +- src/scarb.rs | 10 +- 30 files changed, 1332 insertions(+), 775 deletions(-) delete mode 100644 corelib/Scarb.lock create mode 100644 corelib/src/num/traits/ops.cairo create mode 100644 corelib/src/num/traits/ops/overflowing.cairo create mode 100644 corelib/src/num/traits/ops/wrapping.cairo create mode 100644 corelib/src/test/const_test.cairo create mode 100644 corelib/src/test/coupon_test.cairo create mode 100644 corelib/src/test/while_test.cairo diff --git a/Cargo.lock b/Cargo.lock index a0ae5f9d3..184e177c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -541,24 +541,11 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc54b38b6784e2a050c725802d4b5a5634bad32119f8a0a67fccf98e8d5a9f7b" +checksum = "10d9c31baeb6b52586b5adc88f01e90f86389d63d94363c562de5c79352e545b" dependencies = [ - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indoc", - "num-bigint", - "num-traits 0.2.16", - "parity-scale-codec", - "serde", -] - -[[package]] -name = "cairo-lang-casm" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-utils", "indoc", "num-bigint", "num-traits 0.2.16", @@ -568,43 +555,22 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816a6e69bcb48f40513592cebfe5ee80472c93d3dfd4793eaa09d8e2c4dd5489" -dependencies = [ - "anyhow", - "cairo-lang-defs 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-lowering 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-parser 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-project 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-semantic 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-generator 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "salsa", - "thiserror", -] - -[[package]] -name = "cairo-lang-compiler" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "7148cb2d72a3db24a6d2ef2b2602102cc5099cb9f6b913e5047fb009cb3a22a1" dependencies = [ "anyhow", - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-lowering 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-parser 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-project 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-semantic 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-generator 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-parser", + "cairo-lang-project", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-generator", + "cairo-lang-syntax", + "cairo-lang-utils", "salsa", "smol_str", "thiserror", @@ -612,49 +578,25 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee329295640812932a5ca71552d97cfe2057e2d2ef23a6328393c312c7f5367" +checksum = "5a761eb8e31ea65a2dd45f729c74f1770315f97124dad93d1f6853a10d460c6b" dependencies = [ - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cairo-lang-debug" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08a77ba3c274593f4cfe375b7ecde1353c8489fd8257daf2df85a459126c59a" +checksum = "f6d60bc5d72fe7a95ba34e041dcbdf1cf3bfccb87008a515514b74913fa8ff05" dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-parser 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.11.0", - "salsa", - "smol_str", -] - -[[package]] -name = "cairo-lang-defs" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-parser 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-debug", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-parser", + "cairo-lang-syntax", + "cairo-lang-utils", "itertools 0.11.0", "salsa", "smol_str", @@ -662,67 +604,34 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d9db9eff39d5a91ec1d681d6e52012e5374270120ee55c222211440508e2234" +checksum = "356089e1b0a0ba9e115566191745613b3806a20259ad76764df82ab534d5412a" dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.11.0", -] - -[[package]] -name = "cairo-lang-diagnostics" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-debug", + "cairo-lang-filesystem", + "cairo-lang-utils", "itertools 0.11.0", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "674eb82142b08aea2bca9d711393baea265b64c8a8cbe3a5ae570d84882a4b31" +checksum = "fc43246cc2e5afd5a028bcdd63876ac3f8b1f4fb3ff785daaa0f0fbb51c9d906" dependencies = [ - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "good_lp", -] - -[[package]] -name = "cairo-lang-eq-solver" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-utils", "good_lp", ] [[package]] name = "cairo-lang-filesystem" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb697f1d097eeb18ea28fc576c32ad867beade0b47ac2f95ca84026cec025808" -dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "path-clean", - "salsa", - "serde", - "smol_str", -] - -[[package]] -name = "cairo-lang-filesystem" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "6bcb9a4a40e53fa099774bd08bbcc3430f51213cc7fb1b50c2e9d01155731798" dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-debug", + "cairo-lang-utils", "path-clean", "salsa", "serde", @@ -731,15 +640,16 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5626f853bef87ba54d3ba8cb3fe28d9e30b5465cd13ca640fe431f666ccce6ac" dependencies = [ "anyhow", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-parser 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-parser", + "cairo-lang-syntax", + "cairo-lang-utils", "diffy", "ignore", "itertools 0.11.0", @@ -751,19 +661,19 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8306cb070322918f9cc18163eb9a847b437cfb2dbf37da5a04dbd41f26f9347e" -dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-defs 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-parser 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-proc-macros 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-semantic 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba60e1e2477aa0f610ccf29189097d580464607c94b51741e1c18e64d6cee5f" +dependencies = [ + "cairo-lang-debug", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-parser", + "cairo-lang-proc-macros", + "cairo-lang-semantic", + "cairo-lang-syntax", + "cairo-lang-utils", "id-arena", "itertools 0.11.0", "log", @@ -775,59 +685,42 @@ dependencies = [ ] [[package]] -name = "cairo-lang-lowering" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-parser 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-proc-macros 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-semantic 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "id-arena", - "itertools 0.11.0", - "log", - "num-bigint", - "num-traits 0.2.16", - "once_cell", - "salsa", - "smol_str", +name = "cairo-lang-macro" +version = "0.0.1" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" +dependencies = [ + "anyhow", + "cairo-lang-macro-attributes", + "cairo-lang-macro-stable", + "serde", + "serde_json", ] [[package]] -name = "cairo-lang-parser" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "813b3fcfb3db7c137150fb135dc5fb5e8b2b0fcf1343c911e8f282ef6be4896c" +name = "cairo-lang-macro-attributes" +version = "0.0.1" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" dependencies = [ - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax-codegen 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "colored", - "itertools 0.11.0", - "num-bigint", - "num-traits 0.2.16", - "salsa", - "smol_str", - "unescaper", + "quote", + "syn 2.0.43", ] +[[package]] +name = "cairo-lang-macro-stable" +version = "1.0.0" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" + [[package]] name = "cairo-lang-parser" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax-codegen 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f16ba1535e0cc5e79c2eff6592859bbdac03dc53d4dcdd26dbdbc04a77c3f5c" +dependencies = [ + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-syntax", + "cairo-lang-syntax-codegen", + "cairo-lang-utils", "colored", "itertools 0.11.0", "num-bigint", @@ -839,34 +732,16 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e301ea0102f57dd6df3365b44b28397efb68aba069cd218de4e0944bd9a5ff" +checksum = "81c8cf6e0ee3d6b19429cc1663738b22f1ecea7d51bf7452e8e1086f08798baf" dependencies = [ - "cairo-lang-defs 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-parser 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indent", - "indoc", - "itertools 0.11.0", - "salsa", - "smol_str", -] - -[[package]] -name = "cairo-lang-plugins" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-parser 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-parser", + "cairo-lang-syntax", + "cairo-lang-utils", "indent", "indoc", "itertools 0.11.0", @@ -876,46 +751,23 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85aa42c1206b5848bb9ea7e77885ab5196bddcabe55332cc584ced6af9dd459e" +checksum = "67f9da66325ce7ed6c002360f26106fe79deb9f8a2fca30abdbb8d388da7bb46" dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote", - "syn 2.0.43", -] - -[[package]] -name = "cairo-lang-proc-macros" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-debug", "quote", "syn 2.0.43", ] [[package]] name = "cairo-lang-project" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15cc3bfe213c0fd569e7ba2a82200d1d49b1c9677fd4f9426967070bb83489a0" +checksum = "e198af1ab3d05c7fb8b6a9a7a2e9bce245a6c855df5f770b751d29874a23b152" dependencies = [ - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde", - "smol_str", - "thiserror", - "toml 0.8.10", -] - -[[package]] -name = "cairo-lang-project" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-filesystem", + "cairo-lang-utils", "serde", "smol_str", "thiserror", @@ -924,23 +776,24 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa31a3ecabb2ecf900c4337e26e3d534ff4f0170183d96be3f72fcfb679ac3e" +checksum = "0bf211f5431e2a6f4802b1b6483bf8e998e506a3be5369ed54a8807aae6e4dbf" dependencies = [ "ark-ff", "ark-secp256k1", "ark-secp256r1", "ark-std 0.4.0", "cairo-felt 0.9.1", - "cairo-lang-casm 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-ap-change 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-generator 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-to-casm 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-type-size 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-starknet 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-casm", + "cairo-lang-lowering", + "cairo-lang-sierra", + "cairo-lang-sierra-ap-change", + "cairo-lang-sierra-generator", + "cairo-lang-sierra-to-casm", + "cairo-lang-sierra-type-size", + "cairo-lang-starknet", + "cairo-lang-utils", "cairo-vm", "itertools 0.11.0", "keccak", @@ -954,43 +807,19 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926f9fa06acd2fceb74f5471ca9c0954acd15c74eaf7f162722748013de0aa7e" -dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-defs 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-parser 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-plugins 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-proc-macros 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "id-arena", - "indoc", - "itertools 0.11.0", - "num-bigint", - "num-traits 0.2.16", - "once_cell", - "salsa", - "smol_str", -] - -[[package]] -name = "cairo-lang-semantic" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-parser 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-plugins 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-proc-macros 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7df81521c2125e3e95b683cc99374db1aebd7ddb317c5ca3dd92a235a9eb13" +dependencies = [ + "cairo-lang-debug", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-parser", + "cairo-lang-plugins", + "cairo-lang-proc-macros", + "cairo-lang-syntax", + "cairo-lang-utils", "id-arena", "indoc", "itertools 0.11.0", @@ -1003,38 +832,13 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3af31e751df35f8be2be2d692ac027c9d08e91a0aa2c2aff702480535643ef7" -dependencies = [ - "anyhow", - "cairo-felt 0.9.1", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "const-fnv1a-hash", - "convert_case", - "derivative", - "itertools 0.11.0", - "lalrpop", - "lalrpop-util", - "num-bigint", - "num-traits 0.2.16", - "regex", - "salsa", - "serde", - "serde_json", - "sha3", - "smol_str", - "thiserror", -] - -[[package]] -name = "cairo-lang-sierra" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "07da3ca1434c62a7cc7cd77d2941ef47a1c23b37325781b59407b78d8c61d863" dependencies = [ "anyhow", "cairo-felt 0.9.1", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-utils", "const-fnv1a-hash", "convert_case", "derivative", @@ -1054,28 +858,14 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e5d3e18db52e0c2d104bce9d4888c9bb5a0fc5cd87673151941219aaad2d9ce" +checksum = "122c9055eb609a511178e3dce577de061819fd4c4c6b7452804557f76ca43bbf" dependencies = [ - "cairo-lang-eq-solver 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-type-size 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.11.0", - "num-traits 0.2.16", - "thiserror", -] - -[[package]] -name = "cairo-lang-sierra-ap-change" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-eq-solver 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-type-size 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-eq-solver", + "cairo-lang-sierra", + "cairo-lang-sierra-type-size", + "cairo-lang-utils", "itertools 0.11.0", "num-traits 0.2.16", "thiserror", @@ -1083,28 +873,14 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bc79b2bf4bd56b273ea64125f45dca5dc8583d56bbf8fd4741551f611d4dc7f" -dependencies = [ - "cairo-lang-eq-solver 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-type-size 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.11.0", - "num-traits 0.2.16", - "thiserror", -] - -[[package]] -name = "cairo-lang-sierra-gas" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "cf049d9aea65c6e38da219a3700c72f78795d11449d9adcec28047ef8d63bd23" dependencies = [ - "cairo-lang-eq-solver 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-type-size 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-eq-solver", + "cairo-lang-sierra", + "cairo-lang-sierra-type-size", + "cairo-lang-utils", "itertools 0.11.0", "num-traits 0.2.16", "thiserror", @@ -1112,44 +888,22 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d9ac96139db603c6f351f84a9473e49b6b8bd4036a5fd9179fe8ebcee98a886" -dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-defs 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-lowering 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-parser 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-semantic 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e1d75e0830279ca1bd0189e3326720d6e081225f7d81ed060bbd22c6b37e980" +dependencies = [ + "cairo-lang-debug", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-parser", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-syntax", + "cairo-lang-utils", "itertools 0.11.0", - "num-bigint", - "once_cell", - "salsa", - "smol_str", -] - -[[package]] -name = "cairo-lang-sierra-generator" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-lowering 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-parser 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-semantic 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "itertools 0.11.0", - "num-bigint", + "num-traits 0.2.16", "once_cell", "salsa", "smol_str", @@ -1157,38 +911,18 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1952c5738d20715d11716ce63ce3e022fdf8563548e4fa84c8dd0379860ca675" +checksum = "6a3c3be88c8562fbf93b0803c186e7282f6daad93576c07f61b04a591fde468f" dependencies = [ "assert_matches", "cairo-felt 0.9.1", - "cairo-lang-casm 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-ap-change 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-gas 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-type-size 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indoc", - "itertools 0.11.0", - "num-bigint", - "num-traits 0.2.16", - "thiserror", -] - -[[package]] -name = "cairo-lang-sierra-to-casm" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "assert_matches", - "cairo-felt 0.9.1", - "cairo-lang-casm 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-ap-change 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-gas 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-type-size 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "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 0.11.0", "num-bigint", @@ -1198,80 +932,34 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a404f3acbca36d70ac380098f738c217ef768b4089a5aaa1d3d9fa4e3ef0dfca" -dependencies = [ - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cairo-lang-sierra-type-size" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "a38da6f98c6b16945c89d2ae351c82d636ed38d3e6eb02f7c8679e3e03a63988" dependencies = [ - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-sierra", + "cairo-lang-utils", ] [[package]] name = "cairo-lang-starknet" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e7a618278918fc83da465ea6c85028009dc386b91ce8ccdcd08c3045255b7ae" -dependencies = [ - "anyhow", - "cairo-felt 0.9.1", - "cairo-lang-casm 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-compiler 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-defs 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-lowering 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-plugins 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-semantic 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-generator 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-to-casm 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "const_format", - "convert_case", - "indent", - "indoc", - "itertools 0.11.0", - "num-bigint", - "num-integer", - "num-traits 0.2.16", - "once_cell", - "serde", - "serde_json", - "sha3", - "smol_str", - "starknet-crypto", - "thiserror", -] - -[[package]] -name = "cairo-lang-starknet" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "2c9ffa8b3b8c47138c36b1907cebb5047dfc4de29ec10ece5bd6d6853243ec50" dependencies = [ "anyhow", "cairo-felt 0.9.1", - "cairo-lang-compiler 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-lowering 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-plugins 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-semantic 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-generator 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-plugins", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-generator", "cairo-lang-starknet-classes", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-syntax", + "cairo-lang-utils", "const_format", "indent", "indoc", @@ -1285,14 +973,15 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c64ae2bb00173e3a88760128bf72de356fa80eb19fa47602479063648b4003" dependencies = [ "cairo-felt 0.9.1", - "cairo-lang-casm 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-to-casm 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-casm", + "cairo-lang-sierra", + "cairo-lang-sierra-to-casm", + "cairo-lang-utils", "convert_case", "itertools 0.11.0", "num-bigint", @@ -1309,28 +998,13 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08063b53ae8bc5c2d30b2a32a1abf807ffc082fe5f297a61370e4e540857d1a" +checksum = "8262c426a57e1e5ec297db24278464841500613445e2cb1c43d5f71ad91ee8d6" dependencies = [ - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-bigint", - "num-traits 0.2.16", - "salsa", - "smol_str", - "unescaper", -] - -[[package]] -name = "cairo-lang-syntax" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-debug", + "cairo-lang-filesystem", + "cairo-lang-utils", "num-bigint", "num-traits 0.2.16", "salsa", @@ -1340,18 +1014,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dc563a3457190f1f9d371fbfbb67e7f99675c54dcf9cb2f260e5aecb5ed3a73" -dependencies = [ - "genco", - "xshell", -] - -[[package]] -name = "cairo-lang-syntax-codegen" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "70e2d692eae4bb4179a4a1148fd5eb738a91653d86750c813658ffad4a99fa97" dependencies = [ "genco", "xshell", @@ -1359,51 +1024,25 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "889e2324b7969757e512e09f44eaecb94d9b3cc5892cd2b5649d81de9d750493" +checksum = "29c2d77976328ac79509b9c33e4380d15aeff7c8ee07fbaea6b41dd469084738" dependencies = [ "anyhow", "cairo-felt 0.9.1", - "cairo-lang-compiler 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-debug 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-defs 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-diagnostics 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-lowering 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-semantic 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-generator 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-starknet 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-syntax 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indoc", - "itertools 0.11.0", - "num-bigint", - "num-traits 0.2.16", - "serde", -] - -[[package]] -name = "cairo-lang-test-plugin" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" -dependencies = [ - "anyhow", - "cairo-felt 0.9.1", - "cairo-lang-compiler 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-debug 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-lowering 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-semantic 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-generator 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-starknet 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-compiler", + "cairo-lang-debug", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", "cairo-lang-starknet-classes", - "cairo-lang-syntax 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-syntax", + "cairo-lang-utils", "indoc", "itertools 0.11.0", "num-bigint", @@ -1413,20 +1052,21 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "987cd7b124ef3adb30467c96c39365ef4b95736c6315e55e6abaa3c5596acf48" +checksum = "ed27173110729dcc69958b364053bcd0442fd0b19d1a5bd91b929a8030558191" dependencies = [ "anyhow", "cairo-felt 0.9.1", - "cairo-lang-compiler 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-filesystem 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-compiler", + "cairo-lang-filesystem", "cairo-lang-runner", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-to-casm 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-starknet 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-test-plugin 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra", + "cairo-lang-sierra-generator", + "cairo-lang-sierra-to-casm", + "cairo-lang-starknet", + "cairo-lang-test-plugin", + "cairo-lang-utils", "colored", "itertools 0.11.0", "num-traits 0.2.16", @@ -1435,23 +1075,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.5.3" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f3de16afa605c6cc491661bc2dab71da10b379af0fdb7176f4f27e08d6286e" -dependencies = [ - "hashbrown 0.14.3", - "indexmap 2.2.2", - "itertools 0.11.0", - "num-bigint", - "num-traits 0.2.16", - "schemars", - "serde", -] - -[[package]] -name = "cairo-lang-utils" -version = "2.5.3" -source = "git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31#7bf91178ad4a775943da53f1dab94068e5d70e31" +checksum = "bf733a7cdc4166d0baf0ed8a98d9ada827daee6653b37d9326e334e53481c6d3" dependencies = [ "env_logger", "hashbrown 0.14.3", @@ -1708,7 +1334,7 @@ dependencies = [ [[package]] name = "create-output-dir" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb#5189ae09e2be80e5ed70c0f927b0bcd297454b5d" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" dependencies = [ "anyhow", "core-foundation", @@ -3728,6 +3354,16 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if 1.0.0", + "windows-targets 0.48.5", +] + [[package]] name = "libmimalloc-sys" version = "0.1.35" @@ -4811,23 +4447,26 @@ dependencies = [ [[package]] name = "scarb" -version = "2.5.3" -source = "git+https://github.com/software-mansion/scarb#5189ae09e2be80e5ed70c0f927b0bcd297454b5d" +version = "2.6.3" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" dependencies = [ "anyhow", "async-trait", - "cairo-lang-compiler 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-defs 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-diagnostics 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-filesystem 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", "cairo-lang-formatter", - "cairo-lang-semantic 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-sierra-to-casm 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-starknet 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-macro", + "cairo-lang-macro-stable", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-to-casm", + "cairo-lang-starknet", "cairo-lang-starknet-classes", - "cairo-lang-test-plugin 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", - "cairo-lang-utils 2.5.3 (git+https://github.com/starkware-libs/cairo?rev=7bf91178ad4a775943da53f1dab94068e5d70e31)", + "cairo-lang-syntax", + "cairo-lang-test-plugin", + "cairo-lang-utils", "camino", "clap", "clap-verbosity-flag", @@ -4846,6 +4485,7 @@ dependencies = [ "include_dir", "indoc", "itertools 0.12.1", + "libloading", "once_cell", "pathdiff", "petgraph", @@ -4867,7 +4507,7 @@ dependencies = [ "thiserror", "tokio", "toml 0.8.10", - "toml_edit 0.21.1", + "toml_edit 0.22.4", "tracing", "tracing-log 0.2.0", "tracing-subscriber", @@ -4883,8 +4523,8 @@ dependencies = [ [[package]] name = "scarb-build-metadata" -version = "2.5.3" -source = "git+https://github.com/software-mansion/scarb#5189ae09e2be80e5ed70c0f927b0bcd297454b5d" +version = "2.6.3" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" dependencies = [ "cargo_metadata", ] @@ -4892,7 +4532,7 @@ dependencies = [ [[package]] name = "scarb-metadata" version = "1.11.1" -source = "git+https://github.com/software-mansion/scarb#5189ae09e2be80e5ed70c0f927b0bcd297454b5d" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" dependencies = [ "camino", "derive_builder", @@ -4905,7 +4545,7 @@ dependencies = [ [[package]] name = "scarb-ui" version = "0.1.3" -source = "git+https://github.com/software-mansion/scarb#5189ae09e2be80e5ed70c0f927b0bcd297454b5d" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921dfd238e1d96c9087eabe5161e446753907" dependencies = [ "anyhow", "camino", @@ -5263,8 +4903,8 @@ dependencies = [ "assert_cmd", "cairo-felt 0.8.7", "cairo-lang-runner", - "cairo-lang-sierra 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-test-plugin 2.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra", + "cairo-lang-test-plugin", "cairo-lang-test-runner", "camino", "clap", @@ -5681,19 +5321,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.2", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.22.4" diff --git a/Cargo.toml b/Cargo.toml index 15589458e..12ba3e631 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,12 +24,12 @@ glob = "0.3.0" cairo-felt = "0.8.2" # Cairo runner dependencies -cairo-lang-test-runner = "2.5.3" -cairo-lang-test-plugin = "2.5.3" -cairo-lang-runner = "2.5.3" -cairo-lang-sierra = "2.5.3" -scarb = { git = "https://github.com/software-mansion/scarb", version = "2.5.3" } -scarb-ui = { git = "https://github.com/software-mansion/scarb", version = "0.1.3" } +cairo-lang-test-runner = "2.6.3" +cairo-lang-test-plugin = "2.6.3" +cairo-lang-runner = "2.6.3" +cairo-lang-sierra = "2.6.3" +scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.6.3" } +scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.6.3" } anyhow = "1.0.66" ark-ff = "0.4.0-alpha.7" diff --git a/corelib/Scarb.lock b/corelib/Scarb.lock deleted file mode 100644 index 18d39df00..000000000 --- a/corelib/Scarb.lock +++ /dev/null @@ -1,6 +0,0 @@ -# Code generated by scarb DO NOT EDIT. -version = 1 - -[[package]] -name = "core" -version = "2.5.3" diff --git a/corelib/Scarb.toml b/corelib/Scarb.toml index 3982c2ed8..903aa842c 100644 --- a/corelib/Scarb.toml +++ b/corelib/Scarb.toml @@ -1,7 +1,8 @@ [package] name = "core" -version = "2.5.3" +version = "2.6.3" edition = "2023_11" +experimental-features = ["coupons", "negative_impls"] # NOTE: This is non-public, unstable Scarb's field, which instructs resolver that this package does not # depend on `core`, which is only true for this particular package. Nobody else should use it. diff --git a/corelib/cairo_project.toml b/corelib/cairo_project.toml index 40985b4d1..8d5e456cf 100644 --- a/corelib/cairo_project.toml +++ b/corelib/cairo_project.toml @@ -6,3 +6,4 @@ edition = "2023_11" [config.global.experimental_features] negative_impls = true +coupons = true diff --git a/corelib/src/array.cairo b/corelib/src/array.cairo index 30164a447..4924fb2ba 100644 --- a/corelib/src/array.cairo +++ b/corelib/src/array.cairo @@ -13,7 +13,7 @@ extern fn array_new() -> Array nopanic; extern fn array_append(ref arr: Array, value: T) nopanic; extern fn array_pop_front(ref arr: Array) -> Option> nopanic; extern fn array_pop_front_consume(arr: Array) -> Option<(Array, Box)> nopanic; -extern fn array_snapshot_pop_front(ref arr: @Array) -> Option> nopanic; +pub(crate) extern fn array_snapshot_pop_front(ref arr: @Array) -> Option> nopanic; extern fn array_snapshot_pop_back(ref arr: @Array) -> Option> nopanic; #[panic_with('Index out of bounds', array_at)] extern fn array_get( @@ -27,7 +27,7 @@ extern fn array_len(arr: @Array) -> usize nopanic; #[generate_trait] pub impl ArrayImpl of ArrayTrait { #[inline(always)] - fn new() -> Array { + fn new() -> Array nopanic { array_new() } #[inline(always)] @@ -132,7 +132,7 @@ fn deserialize_array_helper, +Drop>( // Span. pub struct Span { - snapshot: @Array + pub(crate) snapshot: @Array } impl SpanCopy of Copy>; diff --git a/corelib/src/byte_array.cairo b/corelib/src/byte_array.cairo index ce6df4cfd..43379f157 100644 --- a/corelib/src/byte_array.cairo +++ b/corelib/src/byte_array.cairo @@ -17,8 +17,7 @@ use core::zeroable::NonZeroIntoImpl; pub(crate) const BYTE_ARRAY_MAGIC: felt252 = 0x46a6158a16a947e5916b2a2ca68501a45e93d7110e81aa2d6438b1c57c879a3; const BYTES_IN_U128: usize = 16; -// TODO(yuval): change to `BYTES_IN_BYTES31 - 1` once consteval_int supports non-literals. -const BYTES_IN_BYTES31_MINUS_ONE: usize = consteval_int!(31 - 1); +const BYTES_IN_BYTES31_MINUS_ONE: usize = BYTES_IN_BYTES31 - 1; // TODO(yuval): don't allow creation of invalid ByteArray? #[derive(Drop, Clone, PartialEq, Serde, Default)] @@ -224,7 +223,7 @@ pub impl ByteArrayImpl of ByteArrayTrait { fn append_word_rev(ref self: ByteArray, word: felt252, len: usize) { let mut index = 0; - let u256{low, high } = word.into(); + let u256 { low, high } = word.into(); let low_part_limit = min(len, BYTES_IN_U128); loop { if index == low_part_limit { @@ -280,7 +279,7 @@ pub impl ByteArrayImpl of ByteArrayTrait { // responsibility. #[inline] fn append_split_index_lt_16(ref self: ByteArray, word: felt252, split_index: usize) { - let u256{low, high } = word.into(); + let u256 { low, high } = word.into(); let (low_quotient, low_remainder) = u128_safe_divmod( low, one_shift_left_bytes_u128(split_index).try_into().unwrap() @@ -301,7 +300,7 @@ pub impl ByteArrayImpl of ByteArrayTrait { // responsibility. #[inline] fn append_split_index_16(ref self: ByteArray, word: felt252) { - let u256{low, high } = word.into(); + let u256 { low, high } = word.into(); self.append_split(high.into(), low.into()); } @@ -314,7 +313,7 @@ pub impl ByteArrayImpl of ByteArrayTrait { // responsibility. #[inline] fn append_split_index_gt_16(ref self: ByteArray, word: felt252, split_index: usize) { - let u256{low, high } = word.into(); + let u256 { low, high } = word.into(); let (high_quotient, high_remainder) = u128_safe_divmod( high, one_shift_left_bytes_u128(split_index - BYTES_IN_U128).try_into().unwrap() diff --git a/corelib/src/bytes_31.cairo b/corelib/src/bytes_31.cairo index a5763c051..840282d07 100644 --- a/corelib/src/bytes_31.cairo +++ b/corelib/src/bytes_31.cairo @@ -19,7 +19,7 @@ pub impl Bytes31Impl of Bytes31Trait { // Gets the byte at the given index (LSB's index is 0), assuming that // `index < BYTES_IN_BYTES31`. If the assumption is not met, the behavior is undefined. fn at(self: @bytes31, index: usize) -> u8 { - let u256{low, high } = (*self).into(); + let u256 { low, high } = (*self).into(); let res_u128 = if index < BYTES_IN_U128 { (low / one_shift_left_bytes_u128(index)) % POW_2_8 } else { @@ -104,7 +104,7 @@ pub(crate) fn split_bytes31(word: felt252, len: usize, index: usize) -> (felt252 return (word, 0); } - let u256{low, high } = word.into(); + let u256 { low, high } = word.into(); if index == BYTES_IN_U128 { return (low.into(), high.into()); @@ -153,41 +153,24 @@ pub(crate) fn one_shift_left_bytes_felt252(n_bytes: usize) -> felt252 { // // Panics if `n_bytes >= BYTES_IN_U128`. pub(crate) fn one_shift_left_bytes_u128(n_bytes: usize) -> u128 { - // TODO(yuval): change to match once it's supported for integers. - if n_bytes == 0 { - 0x1_u128 - } else if n_bytes == 1 { - 0x100_u128 - } else if n_bytes == 2 { - 0x10000_u128 - } else if n_bytes == 3 { - 0x1000000_u128 - } else if n_bytes == 4 { - 0x100000000_u128 - } else if n_bytes == 5 { - 0x10000000000_u128 - } else if n_bytes == 6 { - 0x1000000000000_u128 - } else if n_bytes == 7 { - 0x100000000000000_u128 - } else if n_bytes == 8 { - 0x10000000000000000_u128 - } else if n_bytes == 9 { - 0x1000000000000000000_u128 - } else if n_bytes == 10 { - 0x100000000000000000000_u128 - } else if n_bytes == 11 { - 0x10000000000000000000000_u128 - } else if n_bytes == 12 { - 0x1000000000000000000000000_u128 - } else if n_bytes == 13 { - 0x100000000000000000000000000_u128 - } else if n_bytes == 14 { - 0x10000000000000000000000000000_u128 - } else if n_bytes == 15 { - 0x1000000000000000000000000000000_u128 - } else { - core::panic_with_felt252('n_bytes too big') + match n_bytes { + 0 => 0x1, + 1 => 0x100, + 2 => 0x10000, + 3 => 0x1000000, + 4 => 0x100000000, + 5 => 0x10000000000, + 6 => 0x1000000000000, + 7 => 0x100000000000000, + 8 => 0x10000000000000000, + 9 => 0x1000000000000000000, + 10 => 0x100000000000000000000, + 11 => 0x10000000000000000000000, + 12 => 0x1000000000000000000000000, + 13 => 0x100000000000000000000000000, + 14 => 0x10000000000000000000000000000, + 15 => 0x1000000000000000000000000000000, + _ => core::panic_with_felt252('n_bytes too big'), } } diff --git a/corelib/src/cmp.cairo b/corelib/src/cmp.cairo index a45857099..649933fec 100644 --- a/corelib/src/cmp.cairo +++ b/corelib/src/cmp.cairo @@ -1,15 +1,44 @@ +/// Minimum of the two values. +/// # Arguments +/// * `a` - first comparable value +/// * `b` - Second comparable value +/// # Returns +/// * `result` - The smallest of the two values #[must_use] pub fn min, +Drop, +Copy>(a: T, b: T) -> T { if a > b { - return b; + b + } else { + a } - a } +/// Maximum of the two values. +/// # Arguments +/// * `a` - first comparable value +/// * `b` - Second comparable value +/// # Returns +/// * `result` - The greatest of the two values #[must_use] pub fn max, +Drop, +Copy>(a: T, b: T) -> T { if a > b { - return a; + a + } else { + b + } +} + +/// Minimum and maximum of the two values. +/// # Arguments +/// * `a` - first comparable value +/// * `b` - Second comparable value +/// # Returns +/// * `result` - The two values sorted in ascending order +#[must_use] +pub fn minmax, +Drop, +Copy>(a: T, b: T) -> (T, T) { + if a > b { + (b, a) + } else { + (a, b) } - b } diff --git a/corelib/src/ec.cairo b/corelib/src/ec.cairo index 91123fecd..7a64fc31a 100644 --- a/corelib/src/ec.cairo +++ b/corelib/src/ec.cairo @@ -50,11 +50,20 @@ impl EcPointTryIntoNonZero of TryInto { } // EC state. - -// TODO(lior): Allow explicit clone() for EcState, since we don't allow implicit dup (Copy). #[derive(Drop)] pub extern type EcState; +mod internal { + impl EcStateCopy of Copy; + pub impl EcStateClone of Clone { + #[inline(always)] + fn clone(self: @super::EcState) -> super::EcState { + *self + } + } +} +impl EcStateClone = internal::EcStateClone; + /// Initializes an EC computation with the zero point. extern fn ec_state_init() -> EcState nopanic; @@ -72,23 +81,32 @@ extern fn ec_state_try_finalize_nz(s: EcState) -> Option nopanic pub impl EcStateImpl of EcStateTrait { /// Initializes an EC computation with the zero point. #[must_use] - fn init() -> EcState { + fn init() -> EcState nopanic { ec_state_init() } /// Adds a point to the computation. #[inline(always)] - fn add(ref self: EcState, p: NonZeroEcPoint) { + fn add(ref self: EcState, p: NonZeroEcPoint) nopanic { ec_state_add(ref self, :p); } + /// Subs a point to the computation. + #[inline(always)] + fn sub(ref self: EcState, p: NonZeroEcPoint) { + // TODO(orizi): Have a `ec_neg` for NonZeroEcPoint as well, or a `ec_state_sub`. + let p: EcPoint = p.into(); + let p_neg = ec_neg(p); + let p_neg_nz = p_neg.try_into().unwrap(); + ec_state_add(ref self, p_neg_nz); + } /// Adds the product p * scalar to the state. #[inline(always)] - fn add_mul(ref self: EcState, scalar: felt252, p: NonZeroEcPoint) { + fn add_mul(ref self: EcState, scalar: felt252, p: NonZeroEcPoint) nopanic { ec_state_add_mul(ref self, :scalar, :p); } /// Finalizes the EC computation and returns the result (returns `None` if the result is the /// zero point). #[inline(always)] - fn finalize_nz(self: EcState) -> Option { + fn finalize_nz(self: EcState) -> Option nopanic { ec_state_try_finalize_nz(self) } /// Finalizes the EC computation and returns the result. @@ -106,12 +124,22 @@ pub impl EcPointImpl of EcPointTrait { /// Creates a new EC point from its (x, y) coordinates. #[inline(always)] fn new(x: felt252, y: felt252) -> Option { - Option::Some(ec_point_try_new_nz(:x, :y)?.into()) + Option::Some(EcPointTrait::new_nz(:x, :y)?.into()) + } + /// Creates a new NonZero EC point from its (x, y) coordinates. + #[inline(always)] + fn new_nz(x: felt252, y: felt252) -> Option { + ec_point_try_new_nz(:x, :y) } /// Creates a new EC point from its x coordinate. #[inline(always)] fn new_from_x(x: felt252) -> Option { - Option::Some(ec_point_from_x_nz(:x)?.into()) + Option::Some(EcPointTrait::new_nz_from_x(:x)?.into()) + } + /// Creates a new NonZero EC point from its x coordinate. + #[inline(always)] + fn new_nz_from_x(x: felt252) -> Option { + ec_point_from_x_nz(:x) } /// Returns the coordinates of the EC point. #[inline(always)] diff --git a/corelib/src/ecdsa.cairo b/corelib/src/ecdsa.cairo index 450e58641..032acc9f9 100644 --- a/corelib/src/ecdsa.cairo +++ b/corelib/src/ecdsa.cairo @@ -1,4 +1,4 @@ -use core::{ec, ec::{EcPoint, EcPointTrait}}; +use core::{ec, ec::{EcPoint, EcPointTrait, EcStateTrait}}; use core::option::OptionTrait; use core::math; use core::traits::{Into, TryInto}; @@ -38,24 +38,27 @@ pub fn check_ecdsa_signature( } // Check that the public key is the x coordinate of a point on the curve and get such a point. - let public_key_point = match EcPointTrait::new_from_x(public_key) { + let public_key_point = match EcPointTrait::new_nz_from_x(public_key) { Option::Some(point) => point, Option::None => { return false; }, }; // Check that `r` is the x coordinate of a point on the curve and get such a point. // Note that this ensures that `r != 0`. - let signature_r_point = match EcPointTrait::new_from_x(signature_r) { + let signature_r_point = match EcPointTrait::new_nz_from_x(signature_r) { Option::Some(point) => point, Option::None => { return false; }, }; // Retrieve the generator point. - let gen_point = match EcPointTrait::new(ec::stark_curve::GEN_X, ec::stark_curve::GEN_Y) { + let gen_point = match EcPointTrait::new_nz(ec::stark_curve::GEN_X, ec::stark_curve::GEN_Y) { Option::Some(point) => point, Option::None => { return false; }, }; + // Initialize an EC state. + let init_ec = EcStateTrait::init(); + // To verify ECDSA, obtain: // zG = z * G, where z is the message and G is a generator of the EC. // rQ = r * Q, where Q.x = public_key. @@ -63,8 +66,11 @@ pub fn check_ecdsa_signature( // and check that: // zG +/- rQ = +/- sR, or more efficiently that: // (zG +/- rQ).x = sR.x. - let sR: EcPoint = signature_r_point.mul(signature_s); - let sR_x = match sR.try_into() { + + // Calculate `sR.x`. + let mut sR_state = init_ec.clone(); + sR_state.add_mul(signature_s, signature_r_point); + let sR_x = match sR_state.finalize_nz() { Option::Some(pt) => { let (x, _) = ec::ec_point_unwrap(pt); x @@ -72,9 +78,23 @@ pub fn check_ecdsa_signature( Option::None => { return false; }, }; - let zG: EcPoint = gen_point.mul(message_hash); - let rQ: EcPoint = public_key_point.mul(signature_r); - match (zG + rQ).try_into() { + // Calculate a state with `z * G`. + let mut zG_state = init_ec.clone(); + zG_state.add_mul(message_hash, gen_point); + + // Calculate the point `r * Q`. + let mut rQ_state = init_ec; + rQ_state.add_mul(signature_r, public_key_point); + let rQ = match rQ_state.finalize_nz() { + Option::Some(pt) => pt, + // The zero case is not actually possible, as `signature_r` isn't 0. + Option::None => { return false; }, + }; + + // Check the `(zG + rQ).x = sR.x` case. + let mut zG_plus_eQ_state = zG_state.clone(); + zG_plus_eQ_state.add(rQ); + match zG_plus_eQ_state.finalize_nz() { Option::Some(pt) => { let (x, _) = ec::ec_point_unwrap(pt); if (x == sR_x) { @@ -84,7 +104,10 @@ pub fn check_ecdsa_signature( Option::None => {}, }; - match (zG - rQ).try_into() { + // Check the `(zG - rQ).x = sR.x` case. + let mut zG_minus_eQ_state = zG_state; + zG_minus_eQ_state.sub(rQ); + match zG_minus_eQ_state.finalize_nz() { Option::Some(pt) => { let (x, _) = ec::ec_point_unwrap(pt); if (x == sR_x) { diff --git a/corelib/src/integer.cairo b/corelib/src/integer.cairo index 9e65b11c0..bd395bea9 100644 --- a/corelib/src/integer.cairo +++ b/corelib/src/integer.cairo @@ -9,6 +9,8 @@ use core::array::SpanTrait; pub trait NumericLiteral; impl NumericLiteralfelt252 of NumericLiteral; +impl NumericLiteralNonZero> of NumericLiteral>; + #[derive(Copy, Drop)] pub extern type u128; impl NumericLiteralu128 of NumericLiteral; @@ -230,6 +232,7 @@ impl U128PartialOrd of PartialOrd { } pub extern type Bitwise; +/// Returns the bitwise operations (AND, XOR, OR) between `lhs` and `rhs`. extern fn bitwise(lhs: u128, rhs: u128) -> (u128, u128, u128) implicits(Bitwise) nopanic; impl U128BitAnd of BitAnd { #[inline(always)] @@ -1373,6 +1376,16 @@ extern fn u512_safe_divmod_by_u256( U128MulGuarantee ) implicits(RangeCheck) nopanic; +impl U512TryIntoU256 of TryInto { + fn try_into(self: u512) -> Option { + if self.limb2 != 0 || self.limb3 != 0 { + Option::None + } else { + Option::Some(u256 { low: self.limb0, high: self.limb1 }) + } + } +} + /// Bounded pub trait BoundedInt { #[must_use] @@ -1784,7 +1797,7 @@ impl U8IntoU256 of Into { impl U256TryIntoU8 of TryInto { fn try_into(self: u256) -> Option { - let u256{low: low, high: high } = self; + let u256 { low, high } = self; if high != 0 { return Option::None; @@ -1802,7 +1815,7 @@ impl U16IntoU256 of Into { impl U256TryIntoU16 of TryInto { fn try_into(self: u256) -> Option { - let u256{low: low, high: high } = self; + let u256 { low, high } = self; if high != 0 { return Option::None; @@ -1820,7 +1833,7 @@ impl U32IntoU256 of Into { impl U256TryIntoU32 of TryInto { fn try_into(self: u256) -> Option { - let u256{low: low, high: high } = self; + let u256 { low, high } = self; if high != 0 { return Option::None; @@ -1838,7 +1851,7 @@ impl U64IntoU256 of Into { impl U256TryIntoU64 of TryInto { fn try_into(self: u256) -> Option { - let u256{low: low, high: high } = self; + let u256 { low, high } = self; if high != 0 { return Option::None; @@ -1856,7 +1869,7 @@ impl U128IntoU256 of Into { impl U256TryIntoU128 of TryInto { fn try_into(self: u256) -> Option { - let u256{low: low, high: high } = self; + let u256 { low, high } = self; if high != 0 { return Option::None; @@ -2744,3 +2757,290 @@ impl I128One of core::num::traits::One { !self.is_one() } } + +// OverflowingAdd implementations +impl U8OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: u8, v: u8) -> (u8, bool) { + match u8_overflowing_add(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U16OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: u16, v: u16) -> (u16, bool) { + match u16_overflowing_add(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U32OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: u32, v: u32) -> (u32, bool) { + match u32_overflowing_add(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U64OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: u64, v: u64) -> (u64, bool) { + match u64_overflowing_add(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U128OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: u128, v: u128) -> (u128, bool) { + match u128_overflowing_add(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U256OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: u256, v: u256) -> (u256, bool) { + u256_overflowing_add(self, v) + } +} + +impl I8OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: i8, v: i8) -> (i8, bool) { + match i8_overflowing_add_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I16OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: i16, v: i16) -> (i16, bool) { + match i16_overflowing_add_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I32OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: i32, v: i32) -> (i32, bool) { + match i32_overflowing_add_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I64OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: i64, v: i64) -> (i64, bool) { + match i64_overflowing_add_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I128OverflowingAdd of core::num::traits::OverflowingAdd { + fn overflowing_add(self: i128, v: i128) -> (i128, bool) { + match i128_overflowing_add_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +// OverflowingSub implementations +impl U8OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: u8, v: u8) -> (u8, bool) { + match u8_overflowing_sub(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U16OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: u16, v: u16) -> (u16, bool) { + match u16_overflowing_sub(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U32OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: u32, v: u32) -> (u32, bool) { + match u32_overflowing_sub(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U64OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: u64, v: u64) -> (u64, bool) { + match u64_overflowing_sub(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U128OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: u128, v: u128) -> (u128, bool) { + match u128_overflowing_sub(self, v) { + Result::Ok(x) => (x, false), + Result::Err(x) => (x, true) + } + } +} + +impl U256OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: u256, v: u256) -> (u256, bool) { + u256_overflow_sub(self, v) + } +} + +impl I8OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: i8, v: i8) -> (i8, bool) { + match i8_overflowing_sub_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I16OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: i16, v: i16) -> (i16, bool) { + match i16_overflowing_sub_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I32OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: i32, v: i32) -> (i32, bool) { + match i32_overflowing_sub_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I64OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: i64, v: i64) -> (i64, bool) { + match i64_overflowing_sub_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +impl I128OverflowingSub of core::num::traits::OverflowingSub { + fn overflowing_sub(self: i128, v: i128) -> (i128, bool) { + match i128_overflowing_sub_impl(self, v) { + SignedIntegerResult::InRange(x) => (x, false), + SignedIntegerResult::Underflow(x) => (x, true), + SignedIntegerResult::Overflow(x) => (x, true), + } + } +} + +// OverflowingMul implementations +impl U8OverflowingMul of core::num::traits::OverflowingMul { + fn overflowing_mul(self: u8, v: u8) -> (u8, bool) { + let wide_result = u8_wide_mul(self, v); + let MASK: u16 = BoundedInt::::max().into(); + let (v_low, _, v_with_low_masked) = u16_bitwise(wide_result, MASK); + (v_low.try_into().unwrap(), v_with_low_masked != MASK) + } +} + +impl U16OverflowingMul of core::num::traits::OverflowingMul { + fn overflowing_mul(self: u16, v: u16) -> (u16, bool) { + let wide_result = u16_wide_mul(self, v); + let MASK: u32 = BoundedInt::::max().into(); + let (v_low, _, v_with_low_masked) = u32_bitwise(wide_result, MASK); + (v_low.try_into().unwrap(), v_with_low_masked != MASK) + } +} + +impl U32OverflowingMul of core::num::traits::OverflowingMul { + fn overflowing_mul(self: u32, v: u32) -> (u32, bool) { + let wide_result = u32_wide_mul(self, v); + let MASK: u64 = BoundedInt::::max().into(); + let (v_low, _, v_with_low_masked) = u64_bitwise(wide_result, MASK); + (v_low.try_into().unwrap(), v_with_low_masked != MASK) + } +} + +impl U64OverflowingMul of core::num::traits::OverflowingMul { + fn overflowing_mul(self: u64, v: u64) -> (u64, bool) { + let wide_result = u64_wide_mul(self, v); + let MASK: u128 = BoundedInt::::max().into(); + let (v_low, _, v_with_low_masked) = bitwise(wide_result, MASK); + (v_low.try_into().unwrap(), v_with_low_masked != MASK) + } +} + +impl U128OverflowingMul of core::num::traits::OverflowingMul { + fn overflowing_mul(self: u128, v: u128) -> (u128, bool) { + u128_overflowing_mul(self, v) + } +} + +impl U256OverflowingMul of core::num::traits::OverflowingMul { + fn overflowing_mul(self: u256, v: u256) -> (u256, bool) { + u256_overflow_mul(self, v) + } +} + +/// WrappingAdd implementations +impl U8WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U16WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U32WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U64WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U128WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U256WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I8WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I16WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I32WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I64WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I128WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; + +/// WrappingSub implementations +impl U8WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U16WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U32WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U64WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U128WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U256WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I8WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I16WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I32WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I64WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I128WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; + +/// WrappingMul implementations +impl U8WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U16WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U32WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U64WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U128WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U256WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; diff --git a/corelib/src/lib.cairo b/corelib/src/lib.cairo index 677f93114..777f45d2a 100644 --- a/corelib/src/lib.cairo +++ b/corelib/src/lib.cairo @@ -116,7 +116,17 @@ impl Felt252Serde of Serde { output.append(*self); } fn deserialize(ref serialized: Span) -> Option { - Option::Some(*serialized.pop_front()?) + let mut snapshot = serialized.snapshot; + match core::array::array_snapshot_pop_front(ref snapshot) { + Option::Some(x) => { + serialized = Span { snapshot }; + Option::Some(*x.unbox()) + }, + Option::None => { + serialized = Span { snapshot }; + Option::None + }, + } } } diff --git a/corelib/src/num/traits.cairo b/corelib/src/num/traits.cairo index 75f57a4e3..1dcb2ed03 100644 --- a/corelib/src/num/traits.cairo +++ b/corelib/src/num/traits.cairo @@ -6,3 +6,7 @@ pub use one::One; pub mod bit_size; pub use bit_size::BitSize; + +pub mod ops; +pub use ops::overflowing::{OverflowingAdd, OverflowingSub, OverflowingMul}; +pub use ops::wrapping::{WrappingAdd, WrappingSub, WrappingMul}; diff --git a/corelib/src/num/traits/ops.cairo b/corelib/src/num/traits/ops.cairo new file mode 100644 index 000000000..7dba1d5a1 --- /dev/null +++ b/corelib/src/num/traits/ops.cairo @@ -0,0 +1,2 @@ +pub mod overflowing; +pub mod wrapping; diff --git a/corelib/src/num/traits/ops/overflowing.cairo b/corelib/src/num/traits/ops/overflowing.cairo new file mode 100644 index 000000000..02768b0a7 --- /dev/null +++ b/corelib/src/num/traits/ops/overflowing.cairo @@ -0,0 +1,23 @@ +/// Performs addition with a flag for overflow. +pub trait OverflowingAdd { + /// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow + /// would occur. + /// If an overflow would have occurred then the wrapped value is returned. + fn overflowing_add(self: T, v: T) -> (T, bool); +} + +/// Performs subtraction with a flag for overflow. +pub trait OverflowingSub { + /// Returns a tuple of the difference along with a boolean indicating whether an arithmetic + /// overflow would occur. + /// If an overflow would have occurred then the wrapped value is returned. + fn overflowing_sub(self: T, v: T) -> (T, bool); +} + +/// Performs multiplication with a flag for overflow. +pub trait OverflowingMul { + /// Returns a tuple of the product along with a boolean indicating whether an arithmetic + /// overflow would occur. + /// If an overflow would have occurred then the wrapped value is returned. + fn overflowing_mul(self: T, v: T) -> (T, bool); +} diff --git a/corelib/src/num/traits/ops/wrapping.cairo b/corelib/src/num/traits/ops/wrapping.cairo new file mode 100644 index 000000000..0295d4a01 --- /dev/null +++ b/corelib/src/num/traits/ops/wrapping.cairo @@ -0,0 +1,49 @@ +/// Performs addition that wraps around on overflow. +pub trait WrappingAdd { + /// Wrapping (modular) addition. Computes `self + other`, wrapping around at the boundary of the + /// type. + fn wrapping_add(self: T, v: T) -> T; +} + +/// Performs subtraction that wraps around on overflow. +pub trait WrappingSub { + /// Wrapping (modular) subtraction. Computes `self - other`, wrapping around at the boundary of + /// the type. + fn wrapping_sub(self: T, v: T) -> T; +} + +/// Performs multiplication that wraps around on overflow. +pub trait WrappingMul { + /// Wrapping (modular) multiplication. Computes `self * other`, wrapping around at the boundary + /// of the type. + fn wrapping_mul(self: T, v: T) -> T; +} + +pub(crate) mod overflow_based { + pub(crate) impl TWrappingAdd< + T, +core::num::traits::OverflowingAdd + > of core::num::traits::WrappingAdd { + fn wrapping_add(self: T, v: T) -> T { + let (result, _) = self.overflowing_add(v); + result + } + } + + pub(crate) impl TWrappingSub< + T, +core::num::traits::OverflowingSub + > of core::num::traits::WrappingSub { + fn wrapping_sub(self: T, v: T) -> T { + let (result, _) = self.overflowing_sub(v); + result + } + } + + pub(crate) impl TWrappingMul< + T, +core::num::traits::OverflowingMul + > of core::num::traits::WrappingMul { + fn wrapping_mul(self: T, v: T) -> T { + let (result, _) = self.overflowing_mul(v); + result + } + } +} diff --git a/corelib/src/starknet/secp256_trait.cairo b/corelib/src/starknet/secp256_trait.cairo index 1fda813d6..eba4722c3 100644 --- a/corelib/src/starknet/secp256_trait.cairo +++ b/corelib/src/starknet/secp256_trait.cairo @@ -88,7 +88,7 @@ pub fn recover_public_key< >( msg_hash: u256, signature: Signature ) -> Option { - let Signature{r, s, y_parity } = signature; + let Signature { r, s, y_parity } = signature; let r_point = Secp256Impl::secp256_ec_get_point_from_x_syscall(x: r, :y_parity) .unwrap_syscall()?; let generator_point = Secp256Impl::get_generator_point(); diff --git a/corelib/src/test.cairo b/corelib/src/test.cairo index 84931a97b..d227ed15d 100644 --- a/corelib/src/test.cairo +++ b/corelib/src/test.cairo @@ -4,6 +4,8 @@ mod box_test; mod byte_array_test; mod bytes31_test; mod cmp_test; +mod const_test; +mod coupon_test; mod dict_test; mod ec_test; mod felt_test; @@ -23,3 +25,4 @@ mod secp256r1_test; mod test_utils; mod testing_test; mod to_byte_array_test; +mod while_test; diff --git a/corelib/src/test/array_test.cairo b/corelib/src/test/array_test.cairo index 111aa6515..3f002c2e4 100644 --- a/corelib/src/test/array_test.cairo +++ b/corelib/src/test/array_test.cairo @@ -144,3 +144,11 @@ fn test_tuple_span_from_tuple() { assert!(*span[2] == (70, 80, 90)); } +#[test] +fn test_fixed_size_array() { + let arr = [10, 11, 12]; + let [x, y, z] = arr; + assert_eq!(x, 10); + assert_eq!(y, 11); + assert_eq!(z, 12); +} diff --git a/corelib/src/test/cmp_test.cairo b/corelib/src/test/cmp_test.cairo index 2b21155fd..f2890c590 100644 --- a/corelib/src/test/cmp_test.cairo +++ b/corelib/src/test/cmp_test.cairo @@ -1,4 +1,4 @@ -use core::cmp::{max, min}; +use core::cmp::{max, min, minmax}; use core::test::test_utils::{assert_eq, assert_ne}; // Integer tests @@ -31,6 +31,20 @@ fn test_max_u8() { assert_eq(@max(200_u8, 150_u8), @200_u8, '200 > 150'); } +#[test] +fn test_minmax_u8() { + assert!(minmax(0_u8, 1_u8) == (0_u8, 1_u8), "1 > 0"); + assert!(minmax(5_u8, 7_u8) == (5_u8, 7_u8), "7 > 5"); + assert!(minmax(255_u8, 128_u8) == (128_u8, 255_u8), "255 > 128"); + assert!(minmax(10_u8, 10_u8) == (10_u8, 10_u8), "10 == 10"); + assert!(minmax(0_u8, 0_u8) == (0_u8, 0_u8), "0 == 0"); + assert!(minmax(255_u8, 255_u8) == (255_u8, 255_u8), "255 == 255"); + assert!(minmax(100_u8, 200_u8) == (100_u8, 200_u8), "200 > 100"); + assert!(minmax(1_u8, 2_u8) == (1_u8, 2_u8), "2 > 1"); + assert!(minmax(120_u8, 130_u8) == (120_u8, 130_u8), "130 > 120"); + assert!(minmax(200_u8, 150_u8) == (150_u8, 200_u8), "200 > 150"); +} + #[test] fn test_min_u16() { assert_eq(@min(0_u16, 1_u16), @0_u16, '0 < 1'); diff --git a/corelib/src/test/const_test.cairo b/corelib/src/test/const_test.cairo new file mode 100644 index 000000000..f03654113 --- /dev/null +++ b/corelib/src/test/const_test.cairo @@ -0,0 +1,134 @@ +use core::box::BoxTrait; + +mod enum_value { + pub extern type Const; +} +mod value { + pub extern type Const; +} +mod struct0 { + pub extern type Const; +} +mod struct2 { + pub extern type Const; +} + +mod const_bool { + pub extern fn const_as_box() -> Box nopanic; +} + +#[test] +fn test_const_bool() { + assert!( + !const_bool::const_as_box::>, 0>().unbox() + ); + assert!( + const_bool::const_as_box::>, 0>().unbox() + ); +} + +mod const_felt252 { + pub extern fn const_as_box() -> Box nopanic; +} + +#[test] +fn test_const_felt252() { + assert!(const_felt252::const_as_box::, 1>().unbox() == 0); + assert!(const_felt252::const_as_box::, 2>().unbox() == -1); +} + +mod const_u8 { + pub extern fn const_as_box() -> Box nopanic; +} + +#[test] +fn test_const_u8() { + assert!(const_u8::const_as_box::, 0>().unbox() == 0); + assert!(const_u8::const_as_box::, 1>().unbox() == 255); +} + +mod const_u256 { + pub extern fn const_as_box() -> Box nopanic; +} + +#[test] +fn test_const_u256() { + assert!( + const_u256::const_as_box::< + struct2::Const, value::Const>, 0 + >() + .unbox() == 0x10 + ); + assert!( + const_u256::const_as_box::< + struct2::Const, value::Const>, 0 + >() + .unbox() == 0x1000000000000000000000000000000000 + ); +} + +#[derive(Copy, Drop, PartialEq, Debug)] +enum ThreeOptions { + A: felt252, + B: u256, + C, +} + +mod const_three_options { + pub extern fn const_as_box() -> Box nopanic; +} + +#[test] +fn test_complex_enum() { + assert!( + const_three_options::const_as_box::< + enum_value::Const>, 0 + >() + .unbox() == ThreeOptions::A(-1), + ); + assert!( + const_three_options::const_as_box::< + enum_value::Const< + ThreeOptions, + 1, + struct2::Const, value::Const,>, + >, + 1 + >() + .unbox() == ThreeOptions::B(0x2000000000000000000000000000000010) + ); + assert!( + const_three_options::const_as_box::< + enum_value::Const>, 1 + >() + .unbox() == ThreeOptions::C + ); +} + +#[derive(Copy, Drop, PartialEq, Debug)] +enum ThreeOptions2 { + A: felt252, + B: (u256, u256), + C, +} + +mod const_tuple_three_options { + pub extern fn const_as_box() -> Box< + (super::ThreeOptions2, super::ThreeOptions2) + > nopanic; +} + +#[test] +fn test_two_complex_enums() { + assert!( + const_tuple_three_options::const_as_box::< + struct2::Const< + (ThreeOptions2, ThreeOptions2), + enum_value::Const>, + enum_value::Const>, + >, + 0 + >() + .unbox() == (ThreeOptions2::A(1337), ThreeOptions2::C), + ); +} diff --git a/corelib/src/test/coupon_test.cairo b/corelib/src/test/coupon_test.cairo new file mode 100644 index 000000000..9311986ae --- /dev/null +++ b/corelib/src/test/coupon_test.cairo @@ -0,0 +1,26 @@ +use core::test::test_utils::assert_eq; + +extern fn coupon_buy() -> T nopanic; + +fn arr_sum(arr: Array<(u128, arr_sum::Coupon)>) -> u128 nopanic { + match arr.pop_front_consume() { + Option::Some(( + rem, (elm, coupon) + )) => core::integer::u128_wrapping_add(elm, arr_sum(rem, __coupon__: coupon)), + Option::None => 0, + } +} + +#[test] +fn test_arr_sum() { + let mut arr: Array::<(u128, arr_sum::Coupon)> = array![]; + arr.append((3, coupon_buy())); + arr.append((4, coupon_buy())); + arr.append((5, coupon_buy())); + + let available_gas = core::testing::get_available_gas(); + let res = arr_sum(arr); + // Check that arr_sum did not consume any gas. + assert_eq(@core::testing::get_available_gas(), @available_gas, 'Gas was consumed by arr_sum'); + assert_eq(@res, @12, 'Wrong array sum.'); +} diff --git a/corelib/src/test/integer_test.cairo b/corelib/src/test/integer_test.cairo index 14633854e..1a7d4dc38 100644 --- a/corelib/src/test/integer_test.cairo +++ b/corelib/src/test/integer_test.cairo @@ -795,6 +795,17 @@ fn test_u512_safe_div_rem_by_u256() { assert(r == 0x1e0eb905027d0150d2618bbd71844d50, 'large rem failed'); } +#[test] +fn test_u512_try_into_u256() { + assert!( + u512 { limb0: 1, limb1: 2, limb2: 0, limb3: 0 } + .try_into() == Option::Some(0x200000000000000000000000000000001_u256) + ); + assert!(u512 { limb0: 1, limb1: 2, limb2: 3, limb3: 0 }.try_into() == Option::::None); + assert!(u512 { limb0: 1, limb1: 2, limb2: 0, limb3: 4 }.try_into() == Option::::None); + assert!(u512 { limb0: 1, limb1: 2, limb2: 3, limb3: 4 }.try_into() == Option::::None); +} + #[test] fn test_min() { let min_u8: u8 = BoundedInt::min(); diff --git a/corelib/src/test/math_test.cairo b/corelib/src/test/math_test.cairo index bfe492a21..741131c6b 100644 --- a/corelib/src/test/math_test.cairo +++ b/corelib/src/test/math_test.cairo @@ -1,42 +1,37 @@ use core::option::OptionTrait; use core::math; -/// Helper for making a non-zero value. -fn nz>>(n: N) -> NonZero { - n.try_into().unwrap() -} - #[test] fn test_egcd() { - let (g, s, t, sub_direction) = math::egcd(nz(68_u8), nz(16_u8)); + let (g, s, t, sub_direction) = math::egcd::(68, 16); assert(g == 4, 'g != 4'); assert(s == 1, 's != 1'); assert(t == 4, 't != 4'); assert(sub_direction, 'sub_direction is wrong'); assert(1 * 68 - 4 * 16 == 4, 'Sanity check failed'); - let (g, s, t, sub_direction) = math::egcd(nz(240_u256), nz(46_u256)); + let (g, s, t, sub_direction) = math::egcd::(240, 46); assert(g == 2, 'g != 2'); assert(s == 9, 's != 9'); assert(t == 47, 't != 47'); assert(!sub_direction, 'sub_direction is wrong'); assert(47 * 46 - 9 * 240 == 2, 'Sanity check failed'); - let (g, s, t, sub_direction) = math::egcd(nz(50_u128), nz(17_u128)); + let (g, s, t, sub_direction) = math::egcd::(50, 17); assert(g == 1, 'g != 1'); assert(s == 1, 's != 1'); assert(t == 3, 't != 3'); assert(!sub_direction, 'sub_direction is wrong'); assert(3 * 17 - 1 * 50 == 1, 'Sanity check failed'); - let (g, s, t, sub_direction) = math::egcd(nz(5_u128), nz(15_u128)); + let (g, s, t, sub_direction) = math::egcd::(5, 15); assert(g == 5, 'g != 5'); assert(s == 1, 's != 1'); assert(t == 0, 't != 0'); assert(sub_direction, 'sub_direction is wrong'); assert(1 * 5 - 0 * 15 == 5, 'Sanity check failed'); - let (g, s, t, sub_direction) = math::egcd(nz(1_u128), nz(1_u128)); + let (g, s, t, sub_direction) = math::egcd::(1, 1); assert(g == 1, 'g != 1'); assert(s == 0, 's != 0'); assert(t == 1, 't != 1'); @@ -46,30 +41,30 @@ fn test_egcd() { #[test] fn test_inv_mod() { - assert(math::inv_mod(nz(5), nz(24)) == Option::Some(5_u256), 'inv_mov(5, 24) != 5'); - assert(math::inv_mod(nz(29), nz(24)) == Option::Some(5_u128), 'inv_mov(29, 24) != 5'); - assert(math::inv_mod(nz(1), nz(24)) == Option::Some(1_u16), 'inv_mov(1, 24) != 1'); - assert(math::inv_mod(nz(1), nz(5)) == Option::Some(1_u32), 'inv_mov(1, 5) != 1'); - assert(math::inv_mod(nz(8_usize), nz(24_usize)).is_none(), 'inv_mov(8, 24) != None'); - assert(math::inv_mod(nz(1), nz(1)) == Option::Some(0_usize), 'inv_mov(1, 1) != 0'); - assert(math::inv_mod(nz(7), nz(1)) == Option::Some(0_usize), 'inv_mov(7, 1) != 0'); + assert(math::inv_mod(5, 24) == Option::Some(5_u256), 'inv_mov(5, 24) != 5'); + assert(math::inv_mod(29, 24) == Option::Some(5_u128), 'inv_mov(29, 24) != 5'); + assert(math::inv_mod(1, 24) == Option::Some(1_u16), 'inv_mov(1, 24) != 1'); + assert(math::inv_mod(1, 5) == Option::Some(1_u32), 'inv_mov(1, 5) != 1'); + assert(math::inv_mod(8, 24) == Option::::None, 'inv_mov(8, 24) != None'); + assert(math::inv_mod(1, 1) == Option::Some(0_usize), 'inv_mov(1, 1) != 0'); + assert(math::inv_mod(7, 1) == Option::Some(0_usize), 'inv_mov(7, 1) != 0'); } #[test] fn test_u256_div_mod_n() { - assert(math::u256_div_mod_n(6, 2, nz(7)) == Option::Some(3), '6 / 2 != 3 (7)'); - assert(math::u256_div_mod_n(5, 1, nz(7)) == Option::Some(5), '5 / 1 != 5 (7)'); - assert(math::u256_div_mod_n(1, 1, nz(7)) == Option::Some(1), '1 / 1 != 1 (7)'); - assert(math::u256_div_mod_n(7, 2, nz(13)) == Option::Some(10), '7 / 2 != 10 (13)'); - assert(math::u256_div_mod_n(0, 3, nz(13)) == Option::Some(0), '0 / 3 != 0 (13)'); - assert(math::u256_div_mod_n(4, 3, nz(6)).is_none(), '4 / 3 == None (6)'); - assert(math::u256_div_mod_n(5, 4, nz(6)).is_none(), '5 / 4 == None (6)'); - assert(math::u256_div_mod_n(2, 8, nz(4)).is_none(), '2 / 8 == None (4)'); + assert(math::u256_div_mod_n(6, 2, 7) == Option::Some(3), '6 / 2 != 3 (7)'); + assert(math::u256_div_mod_n(5, 1, 7) == Option::Some(5), '5 / 1 != 5 (7)'); + assert(math::u256_div_mod_n(1, 1, 7) == Option::Some(1), '1 / 1 != 1 (7)'); + assert(math::u256_div_mod_n(7, 2, 13) == Option::Some(10), '7 / 2 != 10 (13)'); + assert(math::u256_div_mod_n(0, 3, 13) == Option::Some(0), '0 / 3 != 0 (13)'); + assert(math::u256_div_mod_n(4, 3, 6).is_none(), '4 / 3 == None (6)'); + assert(math::u256_div_mod_n(5, 4, 6).is_none(), '5 / 4 == None (6)'); + assert(math::u256_div_mod_n(2, 8, 4).is_none(), '2 / 8 == None (4)'); assert( math::u256_div_mod_n( 0xfa855081cc80656250605b2ecd7958ba4f0aa6799053da0d68bf76f2484decc6, 0xe8e94a59a951af1b4c8cbd45fb8d01c1dd946de2533e3ad18845f9dbb6d12f4f, - nz(0xa3db605888ac3cd19e70c5b52220ad693566b996ef078e907578fec7758dabc9) + 0xa3db605888ac3cd19e70c5b52220ad693566b996ef078e907578fec7758dabc9 ) == Option::Some(0x8e70aea916ee4b782a0da9c18083ed9d867148a703615a2a88d0e7fddd4c900d), 'Random large values 1' ); @@ -77,7 +72,7 @@ fn test_u256_div_mod_n() { math::u256_div_mod_n( 0x759426f1c0ba213b6378196b5091f5fa48f49f1d0cecfb00a7d59a51be35f609, 0x57ff2c2e0900fce82331e396a71787a837783cca8145538eb32cb4b52104a3be, - nz(0xcb514e4d4672d8f1d952c0312afb5baae86121aa5817030d8439ce759295a029) + 0xcb514e4d4672d8f1d952c0312afb5baae86121aa5817030d8439ce759295a029 ) == Option::Some(0x7c9d22b40f98075c0bfd674d546bc77d775dcf021d30b88afb099834dffa951b), 'Random large values 2' ); @@ -85,22 +80,22 @@ fn test_u256_div_mod_n() { #[test] fn test_u256_inv_mod() { - assert(math::u256_inv_mod(5, nz(24)).unwrap().into() == 5_u256, 'inv_mov(5, 24) != 5'); - assert(math::u256_inv_mod(29, nz(24)).unwrap().into() == 5_u256, 'inv_mov(29, 24) != 5'); - assert(math::u256_inv_mod(1, nz(24)).unwrap().into() == 1_u256, 'inv_mov(1, 24) != 1'); - assert(math::u256_inv_mod(1, nz(5)).unwrap().into() == 1_u256, 'inv_mov(1, 5) != 1'); - assert(math::u256_inv_mod(8, nz(24)).is_none(), 'inv_mov(8, 24) != None'); - assert(math::u256_inv_mod(1, nz(1)).is_none(), 'inv_mov(1, 1) != None'); - assert(math::u256_inv_mod(7, nz(1)).is_none(), 'inv_mov(7, 1) != None'); - assert(math::u256_inv_mod(0, nz(1)).is_none(), 'inv_mov(0, 1) != None'); - assert(math::u256_inv_mod(0, nz(7)).is_none(), 'inv_mov(0, 7) != None'); - assert(math::u256_inv_mod(3, nz(6)).is_none(), 'inv_mod(3, 6) != None'); - assert(math::u256_inv_mod(4, nz(6)).is_none(), 'inv_mod(4, 6) != None'); - assert(math::u256_inv_mod(8, nz(4)).is_none(), 'inv_mod(8, 4) != None'); + assert(math::u256_inv_mod(5, 24).unwrap().into() == 5_u256, 'inv_mov(5, 24) != 5'); + assert(math::u256_inv_mod(29, 24).unwrap().into() == 5_u256, 'inv_mov(29, 24) != 5'); + assert(math::u256_inv_mod(1, 24).unwrap().into() == 1_u256, 'inv_mov(1, 24) != 1'); + assert(math::u256_inv_mod(1, 5).unwrap().into() == 1_u256, 'inv_mov(1, 5) != 1'); + assert(math::u256_inv_mod(8, 24).is_none(), 'inv_mov(8, 24) != None'); + assert(math::u256_inv_mod(1, 1).is_none(), 'inv_mov(1, 1) != None'); + assert(math::u256_inv_mod(7, 1).is_none(), 'inv_mov(7, 1) != None'); + assert(math::u256_inv_mod(0, 1).is_none(), 'inv_mov(0, 1) != None'); + assert(math::u256_inv_mod(0, 7).is_none(), 'inv_mov(0, 7) != None'); + assert(math::u256_inv_mod(3, 6).is_none(), 'inv_mod(3, 6) != None'); + assert(math::u256_inv_mod(4, 6).is_none(), 'inv_mod(4, 6) != None'); + assert(math::u256_inv_mod(8, 4).is_none(), 'inv_mod(8, 4) != None'); assert( math::u256_inv_mod( 0xea9195982bd472e30e5146ad7cb0acd954cbc75032a298ac73234b6b05e28cc1, - nz(0x4075f980fab77a3fde536dbaae600f5ea1540e01837dcec64c1f379613aa4d18) + 0x4075f980fab77a3fde536dbaae600f5ea1540e01837dcec64c1f379613aa4d18 ) .is_none(), 'Random 1' @@ -108,7 +103,7 @@ fn test_u256_inv_mod() { assert( math::u256_inv_mod( 0x85ef555d7a0aa34019c138defc40a1d3683dc1caa505bff286dd8069a28a2e4c, - nz(0xd71e5a5f4a4d1af45e703f9e13d1305ce149313037956247ad5edfe3e81d6353) + 0xd71e5a5f4a4d1af45e703f9e13d1305ce149313037956247ad5edfe3e81d6353 ) .is_none(), 'Random 2' @@ -116,11 +111,13 @@ fn test_u256_inv_mod() { let large_gcd = 0x63f7a7326f84cfca7738923db2b6d6c1b1b; assert( math::u256_inv_mod( - large_gcd * 0x51e28b744cc00edfb6bbbe6a9, nz(large_gcd * 0xc09497df4aa02be7fd25f10d3) + large_gcd * 0x51e28b744cc00edfb6bbbe6a9, + (large_gcd * 0xc09497df4aa02be7fd25f10d3).try_into().unwrap() ) .is_none(), 'gcd ~ 2**140' ); - let very_large_gcd = 0x74c5ef92be07ee4ad43ae8ca337390e4a5dfdbf4f1a5f09cdf412ab7ce343503; - assert(math::u256_inv_mod(very_large_gcd, nz(very_large_gcd)).is_none(), 'gcd ~ 2**256'); + let very_large_gcd: NonZero<_> = + 0x74c5ef92be07ee4ad43ae8ca337390e4a5dfdbf4f1a5f09cdf412ab7ce343503; + assert(math::u256_inv_mod(very_large_gcd.into(), very_large_gcd).is_none(), 'gcd ~ 2**256'); } diff --git a/corelib/src/test/num_test.cairo b/corelib/src/test/num_test.cairo index bdd435791..c332cda14 100644 --- a/corelib/src/test/num_test.cairo +++ b/corelib/src/test/num_test.cairo @@ -1,4 +1,9 @@ use core::num::traits::BitSize; +use core::num::traits::{ + OverflowingAdd, OverflowingSub, OverflowingMul, WrappingAdd, WrappingSub, WrappingMul +}; +use core::integer::BoundedInt; + #[test] fn test_bit_size() { @@ -15,3 +20,218 @@ fn test_bit_size() { assert!(BitSize::::bits() == 128); assert!(BitSize::::bits() == 248); } + +// Overflowing tests + +#[test] +fn tests_overflowing_add_unsigned_integers() { + assert_eq!(1_u8.overflowing_add(2), (3, false)); + assert_eq!(BoundedInt::::max().overflowing_add(1), (0, true)); + assert_eq!(1_u16.overflowing_add(2), (3, false)); + assert_eq!(BoundedInt::::max().overflowing_add(1), (0, true)); + assert_eq!(1_u32.overflowing_add(2), (3, false)); + assert_eq!(BoundedInt::::max().overflowing_add(1), (0, true)); + assert_eq!(1_u64.overflowing_add(2), (3, false)); + assert_eq!(BoundedInt::::max().overflowing_add(1), (0, true)); + assert_eq!(1_u128.overflowing_add(2), (3, false)); + assert_eq!(BoundedInt::::max().overflowing_add(1), (0, true)); + assert_eq!(1_u256.overflowing_add(2), (3, false)); + assert_eq!(BoundedInt::::max().overflowing_add(1), (0, true)); +} + +#[test] +fn test_overflowing_add_positive_signed_integers() { + assert!(1_i8.overflowing_add(2) == (3, false)); + assert!(BoundedInt::::max().overflowing_add(1) == (-0x80, true)); + assert!(1_i16.overflowing_add(2) == (3, false)); + assert!(BoundedInt::::max().overflowing_add(1) == (-0x8000, true)); + assert!(1_i32.overflowing_add(2) == (3, false)); + assert!(BoundedInt::::max().overflowing_add(1) == (-0x80000000, true)); + assert!(1_i64.overflowing_add(2) == (3, false)); + assert!(BoundedInt::::max().overflowing_add(1) == (-0x8000000000000000, true)); + assert!(1_i128.overflowing_add(2) == (3, false)); + assert!( + BoundedInt::::max().overflowing_add(1) == (-0x80000000000000000000000000000000, true) + ); +} + +#[test] +fn test_overflowing_add_negative_signed_integers() { + assert!((-1_i8).overflowing_add(-2) == (-3, false)); + assert!(BoundedInt::::min().overflowing_add(-1) == (0x7f, true)); + assert!((-1_i16).overflowing_add(-2) == (-3, false)); + assert!(BoundedInt::::min().overflowing_add(-1) == (0x7fff, true)); + assert!((-1_i32).overflowing_add(-2) == (-3, false)); + assert!(BoundedInt::::min().overflowing_add(-1) == (0x7fffffff, true)); + assert!((-1_i64).overflowing_add(-2) == (-3, false)); + assert!(BoundedInt::::min().overflowing_add(-1) == (0x7fffffffffffffff, true)); + assert!((-1_i128).overflowing_add(-2) == (-3, false)); + assert!( + BoundedInt::::min().overflowing_add(-1) == (0x7fffffffffffffffffffffffffffffff, true) + ); +} + +fn test_overflowing_sub_unsigned_integers() { + assert_eq!(3_u8.overflowing_sub(2), (1, false)); + assert_eq!(0_u8.overflowing_sub(1), (BoundedInt::::max(), true)); + assert_eq!(3_u16.overflowing_sub(2), (1, false)); + assert_eq!(0_u16.overflowing_sub(1), (BoundedInt::::max(), true)); + assert_eq!(3_u32.overflowing_sub(2), (1, false)); + assert_eq!(0_u32.overflowing_sub(1), (BoundedInt::::max(), true)); + assert_eq!(3_u64.overflowing_sub(2), (1, false)); + assert_eq!(0_u64.overflowing_sub(1), (BoundedInt::::max(), true)); + assert_eq!(3_u128.overflowing_sub(2), (1, false)); + assert_eq!(0_u128.overflowing_sub(1), (BoundedInt::::max(), true)); + assert_eq!(3_u256.overflowing_sub(2), (1, false)); + assert_eq!(0_u256.overflowing_sub(1), (BoundedInt::::max(), true)); +} + +#[test] +fn test_overflowing_sub_positive_signed_integers() { + assert!(3_i8.overflowing_sub(2) == (1, false)); + assert!(BoundedInt::::min().overflowing_sub(1) == (BoundedInt::::max(), true)); + assert!(3_i16.overflowing_sub(2) == (1, false)); + assert!(BoundedInt::::min().overflowing_sub(1) == (BoundedInt::::max(), true)); + assert!(3_i32.overflowing_sub(2) == (1, false)); + assert!(BoundedInt::::min().overflowing_sub(1) == (BoundedInt::::max(), true)); + assert!(3_i64.overflowing_sub(2) == (1, false)); + assert!(BoundedInt::::min().overflowing_sub(1) == (BoundedInt::::max(), true)); + assert!(3_i128.overflowing_sub(2) == (1, false)); + assert!(BoundedInt::::min().overflowing_sub(1) == (BoundedInt::::max(), true)); +} + +#[test] +fn test_overflowing_sub_negative_signed_integers() { + assert!((-3_i8).overflowing_sub(-2) == (-1, false)); + assert!(BoundedInt::::max().overflowing_sub(-1) == (BoundedInt::::min(), true)); + assert!((-3_i16).overflowing_sub(-2) == (-1, false)); + assert!(BoundedInt::::max().overflowing_sub(-1) == (BoundedInt::::min(), true)); + assert!((-3_i32).overflowing_sub(-2) == (-1, false)); + assert!(BoundedInt::::max().overflowing_sub(-1) == (BoundedInt::::min(), true)); + assert!((-3_i64).overflowing_sub(-2) == (-1, false)); + assert!(BoundedInt::::max().overflowing_sub(-1) == (BoundedInt::::min(), true)); + assert!((-3_i128).overflowing_sub(-2) == (-1, false)); + assert!(BoundedInt::::max().overflowing_sub(-1) == (BoundedInt::::min(), true)); +} + +#[test] +fn test_overflowing_mul_unsigned_integers() { + assert_eq!(2_u8.overflowing_mul(3), (6, false)); + assert_eq!(BoundedInt::::max().overflowing_mul(2), (BoundedInt::::max() - 1, true)); + assert_eq!(2_u16.overflowing_mul(3), (6, false)); + assert_eq!(BoundedInt::::max().overflowing_mul(2), (BoundedInt::::max() - 1, true)); + assert_eq!(2_u32.overflowing_mul(3), (6, false)); + assert_eq!(BoundedInt::::max().overflowing_mul(2), (BoundedInt::::max() - 1, true)); + assert_eq!(2_u64.overflowing_mul(3), (6, false)); + assert_eq!(BoundedInt::::max().overflowing_mul(2), (BoundedInt::::max() - 1, true)); + assert_eq!(2_u128.overflowing_mul(3), (6, false)); + assert_eq!(BoundedInt::::max().overflowing_mul(2), (BoundedInt::::max() - 1, true)); + assert_eq!(2_u256.overflowing_mul(3), (6, false)); + assert_eq!(BoundedInt::::max().overflowing_mul(2), (BoundedInt::::max() - 1, true)); +} + +// Wrapping tests + +#[test] +fn tests_wrapping_add_unsigned_integers() { + assert_eq!(1_u8.wrapping_add(2), 3); + assert_eq!(BoundedInt::::max().wrapping_add(1), 0); + assert_eq!(1_u16.wrapping_add(2), 3); + assert_eq!(BoundedInt::::max().wrapping_add(1), 0); + assert_eq!(1_u32.wrapping_add(2), 3); + assert_eq!(BoundedInt::::max().wrapping_add(1), 0); + assert_eq!(1_u64.wrapping_add(2), 3); + assert_eq!(BoundedInt::::max().wrapping_add(1), 0); + assert_eq!(1_u128.wrapping_add(2), 3); + assert_eq!(BoundedInt::::max().wrapping_add(1), 0); + assert_eq!(1_u256.wrapping_add(2), 3); + assert_eq!(BoundedInt::::max().wrapping_add(1), 0); +} + +#[test] +fn test_wrapping_add_positive_signed_integers() { + assert!(1_i8.wrapping_add(2) == 3); + assert!(BoundedInt::::max().wrapping_add(1) == -0x80); + assert!(1_i16.wrapping_add(2) == 3); + assert!(BoundedInt::::max().wrapping_add(1) == -0x8000); + assert!(1_i32.wrapping_add(2) == 3); + assert!(BoundedInt::::max().wrapping_add(1) == -0x80000000); + assert!(1_i64.wrapping_add(2) == 3); + assert!(BoundedInt::::max().wrapping_add(1) == -0x8000000000000000); + assert!(1_i128.wrapping_add(2) == 3); + assert!(BoundedInt::::max().wrapping_add(1) == -0x80000000000000000000000000000000); +} + +#[test] +fn test_wrapping_add_negative_signed_integers() { + assert!((-1_i8).wrapping_add(-2) == -3); + assert!(BoundedInt::::min().wrapping_add(-1) == 0x7f); + assert!((-1_i16).wrapping_add(-2) == -3); + assert!(BoundedInt::::min().wrapping_add(-1) == 0x7fff); + assert!((-1_i32).wrapping_add(-2) == -3); + assert!(BoundedInt::::min().wrapping_add(-1) == 0x7fffffff); + assert!((-1_i64).wrapping_add(-2) == -3); + assert!(BoundedInt::::min().wrapping_add(-1) == 0x7fffffffffffffff); + assert!((-1_i128).wrapping_add(-2) == -3); + assert!(BoundedInt::::min().wrapping_add(-1) == 0x7fffffffffffffffffffffffffffffff); +} + +#[test] +fn test_wrapping_sub_unsigned_integers() { + assert_eq!(3_u8.wrapping_sub(2), 1); + assert_eq!(0_u8.wrapping_sub(1), BoundedInt::::max()); + assert_eq!(3_u16.wrapping_sub(2), 1); + assert_eq!(0_u16.wrapping_sub(1), BoundedInt::::max()); + assert_eq!(3_u32.wrapping_sub(2), 1); + assert_eq!(0_u32.wrapping_sub(1), BoundedInt::::max()); + assert_eq!(3_u64.wrapping_sub(2), 1); + assert_eq!(0_u64.wrapping_sub(1), BoundedInt::::max()); + assert_eq!(3_u128.wrapping_sub(2), 1); + assert_eq!(0_u128.wrapping_sub(1), BoundedInt::::max()); + assert_eq!(3_u256.wrapping_sub(2), 1); + assert_eq!(0_u256.wrapping_sub(1), BoundedInt::::max()); +} + +#[test] +fn test_wrapping_sub_positive_signed_integers() { + assert!(3_i8.wrapping_sub(2) == 1); + assert!(BoundedInt::::min().wrapping_sub(1) == BoundedInt::::max()); + assert!(3_i16.wrapping_sub(2) == 1); + assert!(BoundedInt::::min().wrapping_sub(1) == BoundedInt::::max()); + assert!(3_i32.wrapping_sub(2) == 1); + assert!(BoundedInt::::min().wrapping_sub(1) == BoundedInt::::max()); + assert!(3_i64.wrapping_sub(2) == 1); + assert!(BoundedInt::::min().wrapping_sub(1) == BoundedInt::::max()); + assert!(3_i128.wrapping_sub(2) == 1); + assert!(BoundedInt::::min().wrapping_sub(1) == BoundedInt::::max()); +} + +#[test] +fn test_wrapping_sub_negative_signed_integers() { + assert!((-3_i8).wrapping_sub(-2) == -1); + assert!(BoundedInt::::max().wrapping_sub(-1) == BoundedInt::::min()); + assert!((-3_i16).wrapping_sub(-2) == -1); + assert!(BoundedInt::::max().wrapping_sub(-1) == BoundedInt::::min()); + assert!((-3_i32).wrapping_sub(-2) == -1); + assert!(BoundedInt::::max().wrapping_sub(-1) == BoundedInt::::min()); + assert!((-3_i64).wrapping_sub(-2) == -1); + assert!(BoundedInt::::max().wrapping_sub(-1) == BoundedInt::::min()); + assert!((-3_i128).wrapping_sub(-2) == -1); + assert!(BoundedInt::::max().wrapping_sub(-1) == BoundedInt::::min()); +} + +#[test] +fn test_wrapping_mul_unsigned_integers() { + assert_eq!(2_u8.wrapping_mul(3), 6); + assert_eq!(BoundedInt::::max().wrapping_mul(2), BoundedInt::::max() - 1); + assert_eq!(2_u16.wrapping_mul(3), 6); + assert_eq!(BoundedInt::::max().wrapping_mul(2), BoundedInt::::max() - 1); + assert_eq!(2_u32.wrapping_mul(3), 6); + assert_eq!(BoundedInt::::max().wrapping_mul(2), BoundedInt::::max() - 1); + assert_eq!(2_u64.wrapping_mul(3), 6); + assert_eq!(BoundedInt::::max().wrapping_mul(2), BoundedInt::::max() - 1); + assert_eq!(2_u128.wrapping_mul(3), 6); + assert_eq!(BoundedInt::::max().wrapping_mul(2), BoundedInt::::max() - 1); + assert_eq!(2_u256.wrapping_mul(3), 6); + assert_eq!(BoundedInt::::max().wrapping_mul(2), BoundedInt::::max() - 1); +} diff --git a/corelib/src/test/testing_test.cairo b/corelib/src/test/testing_test.cairo index 6e5e56444..917f2106c 100644 --- a/corelib/src/test/testing_test.cairo +++ b/corelib/src/test/testing_test.cairo @@ -39,6 +39,50 @@ fn test_assert_ne_no_description() { assert_ne!(1, 2); } +#[test] +fn test_assert_lt_with_description() { + assert_lt!(1_u8, 2_u8, "Description"); +} + +#[test] +fn test_assert_lt_no_description() { + assert_lt!(1_u8, 2_u8); +} + +#[test] +fn test_assert_le_with_description() { + assert_le!(1_u8, 2_u8, "Description"); + assert_le!(1_u8, 1_u8, "Description"); +} + +#[test] +fn test_assert_le_no_description() { + assert_le!(1_u8, 2_u8); + assert_le!(1_u8, 1_u8); +} + +#[test] +fn test_assert_gt_with_description() { + assert_gt!(2_u8, 1_u8, "Description"); +} + +#[test] +fn test_assert_gt_no_description() { + assert_gt!(2_u8, 1_u8); +} + +#[test] +fn test_assert_ge_with_description() { + assert_ge!(2_u8, 1_u8, "Description"); + assert_ge!(2_u8, 2_u8, "Description"); +} + +#[test] +fn test_assert_ge_no_description() { + assert_ge!(2_u8, 1_u8); + assert_ge!(2_u8, 2_u8); +} + #[test] #[should_panic(expected: "assertion failed: `false`.")] fn test_assert_macro_no_input() { diff --git a/corelib/src/test/while_test.cairo b/corelib/src/test/while_test.cairo new file mode 100644 index 000000000..8283f4895 --- /dev/null +++ b/corelib/src/test/while_test.cairo @@ -0,0 +1,27 @@ +use core::test::test_utils::{assert_eq, assert_ne}; + +fn array_sum(mut arr: Array) -> felt252 { + let mut sum = 0; + while let Option::Some(x) = arr.pop_front() { + sum += x; + }; + sum +} + +#[test] +fn test_while_let() { + assert_eq!(array_sum(array![1, 2, 3, 4]), 10); + assert_eq!(array_sum(array![]), 0); +} + +#[test] +fn test_outer_loop_break() { + let mut i = 0; + while let true = i != 10 { + while true { + break; + }; + i += 1; + }; + assert_eq!(i, 10); +} diff --git a/exercises/enums/enums3.cairo b/exercises/enums/enums3.cairo index 385161a0d..784721ca9 100644 --- a/exercises/enums/enums3.cairo +++ b/exercises/enums/enums3.cairo @@ -32,12 +32,12 @@ trait StateTrait { } impl StateImpl of StateTrait { fn change_color(ref self: State, new_color: (u8, u8, u8)) { - let State{color: _, position, quit, } = self; - self = State { color: new_color, position: position, quit: quit, }; + let State { color: _, position, quit, } = self; + self = State { color: new_color, position: position, quit: quit, }; } fn quit(ref self: State) { - let State{color, position, quit: _, } = self; - self = State { color: color, position: position, quit: true, }; + let State { color, position, quit: _, } = self; + self = State { color: color, position: position, quit: true, }; } fn echo(ref self: State, s: felt252) { @@ -45,8 +45,8 @@ impl StateImpl of StateTrait { } fn move_position(ref self: State, p: Point) { - let State{color, position: _, quit, } = self; - self = State { color: color, position: p, quit: quit, }; + let State { color, position: _, quit, } = self; + self = State { color: color, position: p, quit: quit, }; } fn process( @@ -58,7 +58,7 @@ impl StateImpl of StateTrait { #[test] fn test_match_message_call() { - let mut state = State { quit: false, position: Point { x: 0, y: 0 }, color: (0, 0, 0), }; + let mut state = State { quit: false, position: Point { x: 0, y: 0 }, color: (0, 0, 0), }; state.process(Message::ChangeColor((255, 0, 255))); state.process(Message::Echo('hello world')); state.process(Message::Move(Point { x: 10, y: 15 })); @@ -68,4 +68,4 @@ fn test_match_message_call() { assert(state.position.x == 10, 'wrong x position'); assert(state.position.y == 15, 'wrong y position'); assert(state.quit == true, 'quit should be true'); -} \ No newline at end of file +} diff --git a/src/scarb.rs b/src/scarb.rs index 153bc788a..20a0bdfa6 100644 --- a/src/scarb.rs +++ b/src/scarb.rs @@ -2,7 +2,7 @@ use anyhow::Context; use cairo_lang_runner::{RunResultValue, SierraCasmRunner, StarknetState}; use cairo_lang_sierra::program::VersionedProgram; use cairo_lang_test_plugin::TestCompilation; -use cairo_lang_test_runner::{CompiledTestRunner, TestRunConfig}; +use cairo_lang_test_runner::{CompiledTestRunner, RunProfilerConfig, TestRunConfig}; use camino::Utf8PathBuf; use console::style; use std::{env::current_dir, fs, path::PathBuf}; @@ -110,7 +110,7 @@ pub fn scarb_run(file_path: &PathBuf) -> anyhow::Result { sierra_program.program, Some(Default::default()), Default::default(), - false, + None, )?; let result = runner @@ -166,7 +166,7 @@ pub fn scarb_test(file_path: &PathBuf) -> anyhow::Result { // Loop through packages, but only process 'exercise_crate' // Largely same as this - // https://github.com/software-mansion/scarb/blob/v2.5.3/extensions/scarb-cairo-test/src/main.rs#L54 + // https://github.com/software-mansion/scarb/blob/v2.6.2/extensions/scarb-cairo-test/src/main.rs#L54 for package in metadata.packages.iter() { if package.name != "exercise_crate" { continue; @@ -187,10 +187,10 @@ pub fn scarb_test(file_path: &PathBuf) -> anyhow::Result { filter: "".into(), include_ignored: false, ignored: false, - run_profiler: false, + run_profiler: RunProfilerConfig::None, }; let runner = CompiledTestRunner::new(test_compilation, config); - runner.run()?; + runner.run(None)?; println!(); } }