From 850b9386a2719b86979da7dd15dd58b4f47200e5 Mon Sep 17 00:00:00 2001 From: maciektr Date: Mon, 4 Mar 2024 19:20:03 +0100 Subject: [PATCH] Prepare release `2.6.0` (#1171) --- Cargo.lock | 159 +++++++++++------- Cargo.toml | 46 ++--- examples/starknet_hello_world/Scarb.toml | 2 +- .../starknet_multiple_contracts/Scarb.toml | 2 +- examples/workspaces/Scarb.toml | 2 +- extensions/scarb-cairo-run/tests/examples.rs | 2 +- .../src/metadata.rs | 3 + scarb/src/compiler/compilers/lib.rs | 9 +- .../compiler/compilers/starknet_contract.rs | 6 + scarb/src/compiler/db.rs | 6 +- scarb/src/core/manifest/compiler_config.rs | 6 +- scarb/src/core/manifest/toml_manifest.rs | 5 + scarb/tests/build.rs | 110 ++++++++++-- website/docs/reference/manifest.md | 12 ++ 14 files changed, 263 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e4c57da9..12c0c7fec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -562,8 +562,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed99c41d458d27dd6d42eed29c57c09e8e6d7c70e546b61cb4bfdb9842d0a279" dependencies = [ "cairo-lang-utils", "indoc", @@ -575,8 +576,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "064f1515038f0496a52a3def9c11879491f76b72cb064d28b9fb6d5e4557ba8a" dependencies = [ "anyhow", "cairo-lang-defs", @@ -597,16 +599,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d3179c07c03cb5d9a36f3ed7e7402bdfe16b9d0de5a960a9fd598a356032be0" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a52a7e66818a41ad4332f07fbd7aba09522c2f05e0436dc7ceb2c989067a5e41" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -621,8 +625,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfe5fc09df15dd815f09257ac7fe2cbfce775ea992b699f4d76f475538d402d" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -632,8 +637,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae770ae2d5ae2f4b6202137dc3a4053f89ad635ae0328a8f4807a3c5856f2ae9" dependencies = [ "cairo-lang-utils", "good_lp", @@ -641,8 +647,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee331de8d8dfddcdb015e86be282819d9c93ee2925f3f188d9af41455dda30d" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -654,8 +661,9 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0603b25723fdff3e4fce7b1b19092b7c772a00f9c3503644b31e7743087a234" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -674,8 +682,9 @@ dependencies = [ [[package]] name = "cairo-lang-language-server" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84ef64c565565017635c3e9f04f2861c7e5bb0096aeec44f54492d1a04520264" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -703,8 +712,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c81afe28160958fb6ca0dd0c7fc40972d3664f390a29b63190b2441ef67d59df" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -751,8 +761,9 @@ version = "1.0.0" [[package]] name = "cairo-lang-parser" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1ce7492bbd227138fad2687094af0d1fe0e7ce33f561ab11d6fb0c53bccf01d" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -770,8 +781,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dbe519ef698fe0f295b49031cb35ccb919610338a6a5136e8968e13791864d" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -788,8 +800,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd65bf4d71ebc1efb0181b6c4d27c93e7e01fe5d521a15f2a5695cd7b5d79f36" dependencies = [ "cairo-lang-debug", "quote", @@ -798,8 +811,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81ecab619e54abf610eefa4918d03831e50e54738b1973e37419734cefd73a77" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -811,8 +825,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be60564ec98572096428145342047dddc1bec5c84992f20d38353bd7fbb6c2c4" dependencies = [ "ark-ff", "ark-secp256k1", @@ -841,8 +856,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d2a528f1c547e67631dcea299b6864f96792052e3a7ce27e5cbc23d6fce0fcf" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -865,8 +881,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5774a2d5725d9cd96cfead69ea070ddfc87f912c36ab91086df66efe90e89e7c" dependencies = [ "anyhow", "cairo-felt", @@ -890,8 +907,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237de08219efe89406ce1cd6db8c2c1b8b062b090156ea82fb4f6eb8899d47f0" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -904,8 +922,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b6fcdb1894da323e17c0f8388aab0622d25ace481c8d71eccafb764a2651fe" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -918,8 +937,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9507e0de57e9e3bd973c6b1e341910283d9283649f9c003fe1ed62c94270a447" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -932,7 +952,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.11.0", - "num-bigint", + "num-traits 0.2.18", "once_cell", "salsa", "smol_str", @@ -940,8 +960,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "042ca9969b62580fbd9f257e60c9e441715335a2fe7c79826aa9664ef4e21187" dependencies = [ "assert_matches", "cairo-felt", @@ -960,8 +981,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859e83d8ceeec98b72119c89281468ad08b6a60c9f2d99ddce407df0c6b8377c" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -969,8 +991,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a22e15a9c91f26fe9b8638bddcb8b08282b7a27d1435c8390f5fa6abdef768" dependencies = [ "anyhow", "cairo-felt", @@ -999,8 +1022,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39d9d31715b12f46963373bf0c4eeaa66c1839ee44fb176e39fe49d364aea0cf" dependencies = [ "cairo-felt", "cairo-lang-casm", @@ -1023,8 +1047,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03bca67a21f85098d3185a2c016ef335ffc0b815a8305aad4a117876379c2cb3" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1038,8 +1063,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06841b9eb87842cad1679f3c8534d25bbb5710923fd9e1903ca62e0663d91698" dependencies = [ "genco", "xshell", @@ -1047,8 +1073,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90595eb6d86fc80994f89a425449cf68f11be3aaafa2c43ea37b4654ae24eeb3" dependencies = [ "anyhow", "cairo-felt", @@ -1074,8 +1101,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b207995d4e0a7877e3a290ade2e55f5741b62f16b804d3d214a280c35d0fd35" dependencies = [ "anyhow", "cairo-felt", @@ -1096,8 +1124,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.5.4" -source = "git+https://github.com/starkware-libs/cairo?rev=bd7cca1c3332daddc738682de0fea26da1b1973d#bd7cca1c3332daddc738682de0fea26da1b1973d" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15222608b6afc529e86554f5f8722cb37de9d73f28384ad33d86e6749ab6d13f" dependencies = [ "env_logger", "hashbrown 0.14.3", @@ -4440,7 +4469,7 @@ dependencies = [ [[package]] name = "scarb" -version = "2.5.4" +version = "2.6.0" dependencies = [ "anyhow", "assert_fs", @@ -4527,7 +4556,7 @@ dependencies = [ [[package]] name = "scarb-build-metadata" -version = "2.5.4" +version = "2.6.0" dependencies = [ "cargo_metadata", "semver", @@ -4535,7 +4564,7 @@ dependencies = [ [[package]] name = "scarb-cairo-language-server" -version = "2.5.4" +version = "2.6.0" dependencies = [ "cairo-lang-language-server", "cairo-lang-utils", @@ -4545,7 +4574,7 @@ dependencies = [ [[package]] name = "scarb-cairo-run" -version = "2.5.4" +version = "2.6.0" dependencies = [ "anyhow", "assert_fs", @@ -4567,7 +4596,7 @@ dependencies = [ [[package]] name = "scarb-cairo-test" -version = "2.5.4" +version = "2.6.0" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -4613,7 +4642,7 @@ dependencies = [ [[package]] name = "scarb-snforge-test-collector" -version = "2.5.4" +version = "2.6.0" dependencies = [ "anyhow", "assert_fs", diff --git a/Cargo.toml b/Cargo.toml index 3ce6599c5..0db2e24d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ members = [ "resolver" = "2" [workspace.package] -version = "2.5.4" +version = "2.6.0" edition = "2021" authors = ["Software Mansion "] @@ -34,28 +34,28 @@ assert_fs = "1" async-trait = "0.1" axum = { version = "0.6", features = ["http2"] } cairo-felt = "0.9.1" -cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-language-server = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-project = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-sierra-type-size = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d" } -cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "bd7cca1c3332daddc738682de0fea26da1b1973d", version = "2.5.3", features = ["env_logger"] } +cairo-lang-casm = "2.6.0" +cairo-lang-compiler = "2.6.0" +cairo-lang-debug = "2.6.0" +cairo-lang-defs = "2.6.0" +cairo-lang-diagnostics = "2.6.0" +cairo-lang-filesystem = "2.6.0" +cairo-lang-formatter = "2.6.0" +cairo-lang-language-server = "2.6.0" +cairo-lang-lowering = "2.6.0" +cairo-lang-project = "2.6.0" +cairo-lang-runner = "2.6.0" +cairo-lang-semantic = "2.6.0" +cairo-lang-sierra = "2.6.0" +cairo-lang-sierra-generator = "2.6.0" +cairo-lang-sierra-to-casm = "2.6.0" +cairo-lang-sierra-type-size = "2.6.0" +cairo-lang-starknet = "2.6.0" +cairo-lang-starknet-classes = "2.6.0" +cairo-lang-syntax = "2.6.0" +cairo-lang-test-plugin = "2.6.0" +cairo-lang-test-runner = "2.6.0" +cairo-lang-utils = { version = "2.6.0", features = ["env_logger"] } camino = { version = "1", features = ["serde1"] } cargo_metadata = ">=0.18" clap = { version = "4", features = ["derive", "env", "string"] } diff --git a/examples/starknet_hello_world/Scarb.toml b/examples/starknet_hello_world/Scarb.toml index 0f434cc08..d9b418780 100644 --- a/examples/starknet_hello_world/Scarb.toml +++ b/examples/starknet_hello_world/Scarb.toml @@ -5,6 +5,6 @@ version = "0.1.0" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html [dependencies] -starknet = "2.5.0" +starknet = "2.6.0" [[target.starknet-contract]] diff --git a/examples/starknet_multiple_contracts/Scarb.toml b/examples/starknet_multiple_contracts/Scarb.toml index e062bef38..34a0f2cad 100644 --- a/examples/starknet_multiple_contracts/Scarb.toml +++ b/examples/starknet_multiple_contracts/Scarb.toml @@ -5,6 +5,6 @@ version = "0.1.0" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html [dependencies] -starknet = "2.5.0" +starknet = "2.6.0" [[target.starknet-contract]] diff --git a/examples/workspaces/Scarb.toml b/examples/workspaces/Scarb.toml index 532614c54..0ffdb07c2 100644 --- a/examples/workspaces/Scarb.toml +++ b/examples/workspaces/Scarb.toml @@ -10,7 +10,7 @@ test = "snforge" exit_first = true [workspace.dependencies] -starknet = "2.5.0" +starknet = "2.6.0" [workspace.package] version = "0.1.0" diff --git a/extensions/scarb-cairo-run/tests/examples.rs b/extensions/scarb-cairo-run/tests/examples.rs index 3fd69252d..a3b2b68d5 100644 --- a/extensions/scarb-cairo-run/tests/examples.rs +++ b/extensions/scarb-cairo-run/tests/examples.rs @@ -97,7 +97,7 @@ fn can_limit_gas() { Finished release target(s) in [..] Running hello_world Run completed successfully, returning [987] - Remaining gas: 50760 + Remaining gas: 58060 "#}); } diff --git a/extensions/scarb-snforge-test-collector/src/metadata.rs b/extensions/scarb-snforge-test-collector/src/metadata.rs index a5367427d..a7665fe25 100644 --- a/extensions/scarb-snforge-test-collector/src/metadata.rs +++ b/extensions/scarb-snforge-test-collector/src/metadata.rs @@ -195,6 +195,9 @@ fn get_crate_settings_for_package( negative_impls: package .experimental_features .contains(&String::from("negative_impls")), + coupons: package + .experimental_features + .contains(&String::from("coupons")), }; CrateSettings { diff --git a/scarb/src/compiler/compilers/lib.rs b/scarb/src/compiler/compilers/lib.rs index 3266f179e..248685f46 100644 --- a/scarb/src/compiler/compilers/lib.rs +++ b/scarb/src/compiler/compilers/lib.rs @@ -1,5 +1,6 @@ use anyhow::{Context, Result}; use cairo_lang_compiler::db::RootDatabase; +use cairo_lang_sierra_to_casm::compiler::SierraToCasmConfig; use cairo_lang_sierra_to_casm::metadata::calc_metadata; use serde::{Deserialize, Serialize}; use tracing::trace_span; @@ -87,8 +88,6 @@ impl Compiler for LibCompiler { if props.casm { let program = sierra_program.into_v1().unwrap().program; - let gas_usage_check = true; - let metadata = { let _ = trace_span!("casm_calc_metadata").enter(); calc_metadata(&program, Default::default()) @@ -97,7 +96,11 @@ impl Compiler for LibCompiler { let cairo_program = { let _ = trace_span!("compile_casm").enter(); - cairo_lang_sierra_to_casm::compiler::compile(&program, &metadata, gas_usage_check)? + let sierra_to_casm = SierraToCasmConfig { + gas_usage_check: unit.compiler_config.enable_gas, + max_bytecode_size: usize::MAX, + }; + cairo_lang_sierra_to_casm::compiler::compile(&program, &metadata, sierra_to_casm)? }; write_string( diff --git a/scarb/src/compiler/compilers/starknet_contract.rs b/scarb/src/compiler/compilers/starknet_contract.rs index 2223df3b4..631517bf4 100644 --- a/scarb/src/compiler/compilers/starknet_contract.rs +++ b/scarb/src/compiler/compilers/starknet_contract.rs @@ -211,6 +211,11 @@ impl Compiler for StarknetContractCompiler { ); } + ensure!( + unit.compiler_config.enable_gas, + "the target starknet contract compilation requires gas to be enabled" + ); + if let Some(external_contracts) = props.build_external_contracts.clone() { for path in external_contracts.iter() { ensure!(path.0.matches(GLOB_PATH_SELECTOR).count() <= 1, @@ -254,6 +259,7 @@ impl Compiler for StarknetContractCompiler { let casm_class = CasmContractClass::from_contract_class( class.clone(), props.casm_add_pythonic_hints, + usize::MAX, ) .with_context(|| { format!("{contract_name}: failed to compile Sierra contract to CASM") diff --git a/scarb/src/compiler/db.rs b/scarb/src/compiler/db.rs index 0df4ed91b..06f0f0d79 100644 --- a/scarb/src/compiler/db.rs +++ b/scarb/src/compiler/db.rs @@ -25,6 +25,9 @@ pub(crate) fn build_scarb_root_database( b.with_project_config(build_project_config(unit)?); b.with_cfg(unit.cfg_set.clone()); load_plugins(unit, ws, &mut b)?; + if !unit.compiler_config.enable_gas { + b.skip_auto_withdraw_gas(); + } let mut db = b.build()?; inject_virtual_wrapper_lib(&mut db, unit)?; Ok(db) @@ -108,6 +111,7 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result { .iter() .map(|component| { let experimental_features = component.package.manifest.experimental_features.clone(); + let experimental_features = experimental_features.unwrap_or_default(); ( component.cairo_package_name(), CrateSettings { @@ -116,8 +120,8 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result { // TODO (#1040): replace this with a macro experimental_features: cairo_lang_filesystem::db::ExperimentalFeaturesConfig { negative_impls: experimental_features - .unwrap_or_default() .contains(&SmolStr::new_inline("negative_impls")), + coupons: experimental_features.contains(&SmolStr::new_inline("coupons")), }, }, ) diff --git a/scarb/src/core/manifest/compiler_config.rs b/scarb/src/core/manifest/compiler_config.rs index 1ee2ff229..4cb2609e6 100644 --- a/scarb/src/core/manifest/compiler_config.rs +++ b/scarb/src/core/manifest/compiler_config.rs @@ -17,6 +17,8 @@ pub struct ManifestCompilerConfig { pub sierra_replace_ids: bool, /// Do not exit with error on compiler warnings. pub allow_warnings: bool, + /// Enable auto gas withdrawal and gas usage check. + pub enable_gas: bool, } impl DefaultForProfile for ManifestCompilerConfig { @@ -24,6 +26,7 @@ impl DefaultForProfile for ManifestCompilerConfig { Self { sierra_replace_ids: profile.is_dev(), allow_warnings: true, + enable_gas: true, } } } @@ -32,7 +35,8 @@ impl From for TomlCairo { fn from(config: ManifestCompilerConfig) -> Self { Self { sierra_replace_ids: Some(config.sierra_replace_ids), - allow_warnings: Some(true), + allow_warnings: Some(config.allow_warnings), + enable_gas: Some(config.enable_gas), } } } diff --git a/scarb/src/core/manifest/toml_manifest.rs b/scarb/src/core/manifest/toml_manifest.rs index 4d286f9b0..5b1d60a4d 100644 --- a/scarb/src/core/manifest/toml_manifest.rs +++ b/scarb/src/core/manifest/toml_manifest.rs @@ -311,6 +311,8 @@ pub struct TomlCairo { pub sierra_replace_ids: Option, /// Do not exit with error on compiler warnings. pub allow_warnings: Option, + /// Enable auto gas withdrawal and gas usage check. + pub enable_gas: Option, } #[derive(Debug, Default, Deserialize, Serialize, Clone)] @@ -816,6 +818,9 @@ impl TomlManifest { if let Some(allow_warnings) = cairo.allow_warnings { compiler_config.allow_warnings = allow_warnings; } + if let Some(enable_gas) = cairo.enable_gas { + compiler_config.enable_gas = enable_gas; + } } Ok(compiler_config) } diff --git a/scarb/tests/build.rs b/scarb/tests/build.rs index bb8c9ad46..e5f9e547a 100644 --- a/scarb/tests/build.rs +++ b/scarb/tests/build.rs @@ -8,6 +8,7 @@ use predicates::prelude::*; use scarb_build_metadata::CAIRO_VERSION; use scarb_metadata::Metadata; use scarb_test_support::command::{CommandExt, Scarb}; +use scarb_test_support::contracts::BALANCE_CONTRACT; use scarb_test_support::fsx::ChildPathEx; use scarb_test_support::project_builder::{Dep, DepBuilder, ProjectBuilder}; use scarb_test_support::workspace_builder::WorkspaceBuilder; @@ -534,7 +535,7 @@ fn sierra_replace_ids() { t.child("target/dev/hello.sierra.json").assert( predicates::str::contains(r#""debug_name":"hello::example""#) .and(predicates::str::contains( - r#""debug_name":"felt252_const<42>""#, + r#""debug_name":"Const""#, )) .and(predicates::str::contains( r#""debug_name":"store_temp""#, @@ -625,16 +626,11 @@ fn workspace_as_dep() { ); second_t.child("target/dev/third.sierra.json").assert( predicates::str::contains(r#""debug_name":"third::example""#) - .and(predicates::str::contains(r#""debug_name":"third::hello""#)) - .and(predicates::str::contains( - r#""debug_name":"withdraw_gas_all""#, - )), - ); - second_t.child("target/dev/third.sierra.json").assert( - predicates::str::contains(r#""debug_name":"second::fib""#).and(predicates::str::contains( - r#""debug_name":"get_builtin_costs""#, - )), + .and(predicates::str::contains(r#""debug_name":"third::hello""#)), ); + second_t + .child("target/dev/third.sierra.json") + .assert(predicates::str::contains(r#""debug_name":"second::fib""#)); } #[test] @@ -881,3 +877,97 @@ fn can_compile_no_core_package() { .assert() .success(); } + +#[test] +fn gas_enabled_by_default() { + let t = TempDir::new().unwrap(); + ProjectBuilder::start() + .name("hello") + .lib_cairo(indoc! {r#" + fn main() -> u32 { + fib(16) + } + + fn fib(mut n: u32) -> u32 { + let mut a: u32 = 0; + let mut b: u32 = 1; + while n != 0 { + n = n - 1; + let temp = b; + b = a + b; + a = temp; + }; + a + } + "#}) + .build(&t); + Scarb::quick_snapbox() + .arg("build") + .current_dir(&t) + .assert() + .success(); + t.child("target/dev/hello.sierra.json") + .assert(predicates::str::contains(r#""withdraw_gas""#)); +} + +#[test] +fn can_disable_gas() { + let t = TempDir::new().unwrap(); + ProjectBuilder::start() + .name("hello") + .lib_cairo(indoc! {r#" + fn main() -> u32 { + fib(16) + } + + fn fib(mut n: u32) -> u32 { + let mut a: u32 = 0; + let mut b: u32 = 1; + while n != 0 { + n = n - 1; + let temp = b; + b = a + b; + a = temp; + }; + a + } + "#}) + .manifest_extra(indoc! {r#" + [cairo] + enable-gas = false + "#}) + .build(&t); + Scarb::quick_snapbox() + .arg("build") + .current_dir(&t) + .assert() + .success(); + t.child("target/dev/hello.sierra.json") + .assert(predicates::str::contains(r#""withdraw_gas""#).not()); +} + +#[test] +fn cannot_disable_gas_for_starknet_contract() { + let t = TempDir::new().unwrap(); + ProjectBuilder::start() + .name("hello") + .dep_starknet() + .lib_cairo(BALANCE_CONTRACT) + .manifest_extra(indoc! {r#" + [[target.starknet-contract]] + + [cairo] + enable-gas = false + "#}) + .build(&t); + Scarb::quick_snapbox() + .arg("build") + .current_dir(&t) + .assert() + .failure() + .stdout_matches(indoc! {r#" + [..]Compiling hello v1.0.0 ([..]Scarb.toml) + error: the target starknet contract compilation requires gas to be enabled + error: could not compile `hello` due to previous error + "#}); +} diff --git a/website/docs/reference/manifest.md b/website/docs/reference/manifest.md index e7ad3d820..80c857597 100644 --- a/website/docs/reference/manifest.md +++ b/website/docs/reference/manifest.md @@ -263,6 +263,18 @@ By default, this flag is enabled. allow-warnings = false ``` +### `enable-gas` + +If enabled, during the project compilation Scarb will not add any instructions related to gas usage calculation. +By default, this flag is enabled. + +```toml +[cairo] +enable-gas = false +``` + +This flag cannot be disabled while compiling the `starknet-contract` target. + ## `[profile]` See [Profiles](./profiles) page.