From a73a7ce2cdd70ab7443a83b3eed11379f284d093 Mon Sep 17 00:00:00 2001 From: Avi Cohen Date: Mon, 30 Dec 2024 19:59:59 +0200 Subject: [PATCH] chore(cairo_native): add compiler file path configs --- Cargo.lock | 265 +++++++++--------- config/sequencer/default_config.json | 49 +++- crates/bin/starknet-native-compile/Cargo.lock | 38 +-- crates/blockifier/Cargo.toml | 2 +- crates/blockifier/src/blockifier/config.rs | 9 +- .../src/state/contract_class_manager.rs | 4 +- crates/native_blockifier/Cargo.toml | 7 +- crates/native_blockifier/src/py_objects.rs | 42 ++- crates/starknet_gateway/src/compilation.rs | 4 +- .../starknet_gateway/src/compilation_test.rs | 12 +- crates/starknet_gateway/src/gateway.rs | 4 +- crates/starknet_gateway/src/gateway_test.rs | 4 +- .../src/config/node_config.rs | 4 +- crates/starknet_sierra_compile/Cargo.toml | 1 + .../src/command_line_compiler.rs | 41 ++- .../src/compile_test.rs | 9 +- crates/starknet_sierra_compile/src/config.rs | 50 +++- 17 files changed, 343 insertions(+), 202 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 780ab3c967..021cb06ab5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,9 +138,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41056bde53ae10ffbbf11618efbe1e0290859e5eab0fe9ef82ebdb62f12a866f" +checksum = "b0d2ea4d7f220a19c1f8c98822026d1d26a4b75a72e1a7308d02bab1f77c9a00" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -150,7 +150,7 @@ dependencies = [ "itoa", "serde", "serde_json", - "winnow 0.6.20", + "winnow 0.6.21", ] [[package]] @@ -195,9 +195,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c357da577dfb56998d01f574d81ad7a1958d248740a7981b205d69d65a7da404" +checksum = "e79c6b4bcc1067a7394b5b2aec7da1bd829c8c476b796c73eb14da34392a07a7" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -254,9 +254,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6259a506ab13e1d658796c31e6e39d2e2ee89243bcc505ddc613b35732e0a430" +checksum = "0540fd0355d400b59633c27bd4b42173e59943f28e9d3376b77a24771d432d04" dependencies = [ "alloy-rlp", "bytes", @@ -305,7 +305,7 @@ dependencies = [ "futures-utils-wasm", "lru", "pin-project", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde", "serde_json", "thiserror 1.0.69", @@ -333,7 +333,7 @@ checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -347,7 +347,7 @@ dependencies = [ "alloy-transport-http", "futures", "pin-project", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde", "serde_json", "tokio", @@ -405,23 +405,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d64f851d95619233f74b310f12bcf16e0cbc27ee3762b6115c14a84809280a" +checksum = "c6d1a14b4a9f6078ad9132775a2ebb465b06b387d60f7413ddc86d7bf7453408" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf7ed1574b699f48bf17caab4e6e54c6d12bc3c006ab33d58b1e227c1c3559f" +checksum = "4436b4b96d265eb17daea26eb31525c3076d024d10901e446790afbd2f7eeaf5" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -431,16 +431,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c02997ccef5f34f9c099277d4145f183b422938ed5322dc57a089fe9b9ad9ee" +checksum = "e5f58698a18b96faa8513519de112b79a96010b4ff84264ce54a217c52a8e98b" dependencies = [ "alloy-json-abi", "const-hex", @@ -449,25 +449,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.91", + "syn 2.0.94", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce13ff37285b0870d0a0746992a4ae48efaf34b766ae4c2640fa15e5305f8e73" +checksum = "1f3d6d2c490f650c5abd65a9a583b09a8c8931c265d3a55b18a8e349dd6d9d84" dependencies = [ "serde", - "winnow 0.6.20", + "winnow 0.6.21", ] [[package]] name = "alloy-sol-types" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1174cafd6c6d810711b4e00383037bdb458efc4fe3dbafafa16567e0320c54d8" +checksum = "c766e4979fc19d70057150befe8e3ea3f0c4cbc6839b8eaaa250803451692305" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -503,7 +503,7 @@ checksum = "a944f5310c690b62bbb3e7e5ce34527cbd36b2d18532a797af123271ce595a49" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde_json", "tower 0.5.2", "tracing", @@ -597,7 +597,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -839,7 +839,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "synstructure", ] @@ -851,7 +851,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1042,7 +1042,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1108,7 +1108,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1125,7 +1125,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1190,7 +1190,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1361,7 +1361,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1383,7 +1383,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.91", + "syn 2.0.94", "which", ] @@ -1404,7 +1404,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1578,9 +1578,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.3.1" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61030e4aaccae9727cc388843dcc7ad1fb9e1ccdef5571e3e8393976b49b74ce" +checksum = "fe7acc34ff59877422326db7d6f2d845a582b16396b6b08194942bf34c6528ab" dependencies = [ "bon-macros", "rustversion", @@ -1588,9 +1588,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.3.1" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67d5d25cc9bd33120702000acc60836db15f06eabc4466230bf79dc80bd0a6ee" +checksum = "4159dd617a7fbc9be6a692fe69dc2954f8e6bb6bb5e4d7578467441390d77fd0" dependencies = [ "darling 0.20.10", "ident_case", @@ -1598,7 +1598,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -1929,7 +1929,7 @@ checksum = "b3c4a161868276ce022c44ac500afbfa0d7d8371106feb40dfca34ea7be97503" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -2410,11 +2410,10 @@ dependencies = [ [[package]] name = "caseless" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" +checksum = "8b6fd507454086c8edfd769ca6ada439193cdb209c7681712ef6275cccbfe5d8" dependencies = [ - "regex", "unicode-normalization", ] @@ -2426,9 +2425,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.5" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" +checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" dependencies = [ "jobserver", "libc", @@ -2575,7 +2574,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3007,7 +3006,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3055,7 +3054,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3077,7 +3076,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3192,7 +3191,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3212,7 +3211,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "unicode-xid", ] @@ -3308,7 +3307,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3389,7 +3388,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3474,7 +3473,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3485,7 +3484,7 @@ checksum = "4f4b100e337b021ae69f3e7dd82e230452c54ff833958446c4a3854c66dc9326" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3505,7 +3504,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3525,7 +3524,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3701,7 +3700,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.91", + "syn 2.0.94", "toml", "walkdir", ] @@ -3719,7 +3718,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -3745,7 +3744,7 @@ dependencies = [ "serde", "serde_json", "strum 0.26.3", - "syn 2.0.91", + "syn 2.0.94", "tempfile", "thiserror 1.0.69", "tiny-keccak", @@ -4220,7 +4219,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -4319,7 +4318,7 @@ checksum = "43eaff6bbc0b3a878361aced5ec6a2818ee7c541c5b33b5880dfa9a86c23e9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -4364,9 +4363,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "globset" @@ -4441,9 +4440,9 @@ dependencies = [ [[package]] name = "good_lp" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97630e1e456d7081c524488a87d8f8f7ed0fd3100ba10c55e3cfa7add5ce05c6" +checksum = "10efcd6c7d6f84cb5b4f9155248e0675deab9cfb92d0edbcb25cb81490b65ae7" dependencies = [ "fnv", "microlp", @@ -4461,7 +4460,7 @@ dependencies = [ "google-cloud-token", "home", "jsonwebtoken 9.3.0", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde", "serde_json", "thiserror 1.0.69", @@ -4477,7 +4476,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04f945a208886a13d07636f38fb978da371d0abc3e34bad338124b9f8c135a8f" dependencies = [ - "reqwest 0.12.9", + "reqwest 0.12.12", "thiserror 1.0.69", "tokio", ] @@ -4502,7 +4501,7 @@ dependencies = [ "percent-encoding", "pkcs8", "regex", - "reqwest 0.12.9", + "reqwest 0.12.12", "reqwest-middleware", "ring 0.17.8", "serde", @@ -5142,7 +5141,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -5309,7 +5308,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -6256,7 +6255,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -6540,7 +6539,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.91", + "syn 2.0.94", "tblgen-alt", "unindent 0.2.3", ] @@ -6638,7 +6637,7 @@ checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -6756,7 +6755,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -6908,6 +6907,7 @@ dependencies = [ "serde_json", "starknet-types-core", "starknet_api", + "starknet_sierra_compile", "tempfile", "thiserror 1.0.69", ] @@ -7262,7 +7262,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -7358,7 +7358,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -7743,7 +7743,7 @@ dependencies = [ "papyrus_test_utils", "prometheus-parse", "quote", - "syn 2.0.91", + "syn 2.0.94", "tracing", ] @@ -8148,7 +8148,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -8192,7 +8192,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -8393,7 +8393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -8472,7 +8472,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -8527,7 +8527,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -8589,7 +8589,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.91", + "syn 2.0.94", "tempfile", ] @@ -8603,7 +8603,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -8835,9 +8835,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -9192,9 +9192,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ "base64 0.22.1", "bytes", @@ -9224,6 +9224,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-util", + "tower 0.5.2", "tower-service", "url", "wasm-bindgen", @@ -9242,7 +9243,7 @@ dependencies = [ "anyhow", "async-trait", "http 1.2.0", - "reqwest 0.12.9", + "reqwest 0.12.12", "serde", "thiserror 1.0.69", "tower-service", @@ -9456,7 +9457,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -9636,9 +9637,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "rusty-fork" @@ -9708,7 +9709,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -9742,7 +9743,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -9851,22 +9852,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -9877,7 +9878,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -9921,7 +9922,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -9969,7 +9970,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -10353,7 +10354,7 @@ checksum = "bbc159a1934c7be9761c237333a57febe060ace2bc9e3b337a59a37af206d19f" dependencies = [ "starknet-curve 0.4.2", "starknet-ff", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -10912,6 +10913,7 @@ dependencies = [ "cairo-lang-utils", "cairo-native", "infra_utils", + "itertools 0.12.1", "mempool_test_utils", "papyrus_config", "rlimit", @@ -11041,7 +11043,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11054,7 +11056,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11096,9 +11098,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.91" +version = "2.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" +checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" dependencies = [ "proc-macro2", "quote", @@ -11107,14 +11109,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219389c1ebe89f8333df8bdfb871f6631c552ff399c23cac02480b6088aad8f0" +checksum = "c74af950d86ec0f5b2ae2d7f1590bbfbcf4603a0a15742d8f98132ac4fe3efd4" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11140,7 +11142,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11277,7 +11279,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11288,7 +11290,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "test-case-core", ] @@ -11311,7 +11313,7 @@ checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11340,7 +11342,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11351,7 +11353,7 @@ checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11516,7 +11518,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11646,7 +11648,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.20", + "winnow 0.6.21", ] [[package]] @@ -11680,6 +11682,7 @@ dependencies = [ "futures-util", "pin-project-lite", "sync_wrapper 1.0.2", + "tokio", "tower-layer", "tower-service", ] @@ -11716,7 +11719,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -11799,7 +11802,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -12181,7 +12184,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "wasm-bindgen-shared", ] @@ -12216,7 +12219,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -12637,9 +12640,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68" dependencies = [ "memchr", ] @@ -12844,7 +12847,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "synstructure", ] @@ -12866,7 +12869,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -12886,7 +12889,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", "synstructure", ] @@ -12907,7 +12910,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] @@ -12929,7 +12932,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.94", ] [[package]] diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index 3b84ffeac1..8cbe7c7b5b 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -134,6 +134,31 @@ "privacy": "Public", "value": 1000 }, + "batcher_config.contract_class_manager_config.compiler_config.libcairo_native_runtime_path": { + "description": "The path to the Cairo native runtime library file.", + "privacy": "Public", + "value": "" + }, + "batcher_config.contract_class_manager_config.compiler_config.libcairo_native_runtime_path.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "batcher_config.contract_class_manager_config.compiler_config.max_casm_bytecode_size": { + "description": "Limitation of compiled casm bytecode size.", + "privacy": "Public", + "value": 81920 + }, + "batcher_config.contract_class_manager_config.compiler_config.sierra_to_native_compiler_path": { + "description": "The path to the Sierra-to-Native compiler binary.", + "privacy": "Public", + "value": "" + }, + "batcher_config.contract_class_manager_config.compiler_config.sierra_to_native_compiler_path.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, "batcher_config.contract_class_manager_config.contract_cache_size": { "description": "The size of the global contract cache.", "privacy": "Public", @@ -219,11 +244,31 @@ "param_type": "String", "privacy": "TemporaryValue" }, - "compiler_config.max_bytecode_size": { - "description": "Limitation of contract bytecode size.", + "compiler_config.libcairo_native_runtime_path": { + "description": "The path to the Cairo native runtime library file.", + "privacy": "Public", + "value": "" + }, + "compiler_config.libcairo_native_runtime_path.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "compiler_config.max_casm_bytecode_size": { + "description": "Limitation of compiled casm bytecode size.", "privacy": "Public", "value": 81920 }, + "compiler_config.sierra_to_native_compiler_path": { + "description": "The path to the Sierra-to-Native compiler binary.", + "privacy": "Public", + "value": "" + }, + "compiler_config.sierra_to_native_compiler_path.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, "components.batcher.execution_mode": { "description": "The component execution mode.", "privacy": "Public", diff --git a/crates/bin/starknet-native-compile/Cargo.lock b/crates/bin/starknet-native-compile/Cargo.lock index b0e5f2319c..72f0711c12 100644 --- a/crates/bin/starknet-native-compile/Cargo.lock +++ b/crates/bin/starknet-native-compile/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -421,9 +421,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e0dcdb6358bb639dd729546611bd99bada94c86e3f262c3637855abea9a972" +checksum = "3929a38c1d586e35e19dbdf7798b146fba3627b308417a6d373fea8939535b6b" dependencies = [ "cairo-lang-utils", "indoc", @@ -499,9 +499,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723d244465309d5409e297b5486d62cbec06f2c47b05044414bb640e3f14caab" +checksum = "d778ec864e92c82293370a512195715b12775b05981e14065d85eb5dd3dd96b6" dependencies = [ "cairo-lang-utils", "good_lp", @@ -691,9 +691,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8118f55ca7d567bfc60960b445d388564d04bf48335c983b1595cb35f67a01c5" +checksum = "075c6457642ada82b32cf657d871a8545ae7a9d61c78dd5588a794c8c905abdc" dependencies = [ "anyhow", "cairo-lang-utils", @@ -718,9 +718,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2716ef8d4ce0fb700f83ed3281f3656436570e60249d41c65c79dc1ca27be002" +checksum = "b69172fe8354b1dd564bba318ccb5233aa78f70d57145b8c92a0b1cf009fa0fc" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -734,9 +734,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a44da87a35845470c4f4c648225232a15e0875fe809045b6088464491f838b" +checksum = "42b571b73d9b02103f780aeee05dbf9a71d68d8a16341a04aa1dd581d0db3ad6" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -774,9 +774,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18b7616f1a3c41c4646094b5abf774e558428e9c1eda5d78d7b0638ec5c264e5" +checksum = "add264b156dfb01f18292282a6037070c078acca3bccde05787da1e1c997b78c" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -795,9 +795,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871077dbc08df5d134dc3975538171c14b266ba405d1298085afdb227216f0a3" +checksum = "7bda5388ef862bc26388e999ac7ad62dd8ab3064720c3483b81fd761b051e627" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -835,9 +835,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2496bccd68fa0286b35b72c98439316a3a872ef7ec6d881f0dac90b17997490" +checksum = "fe691200b431e51e3d6cfa84f256a3dd2e8405f44d182843fbe124f803d085ff" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -924,9 +924,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.9.0-dev.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35df943ebcf8e1db11ee9f4f46f843dde5b71639ca79ea0d8caa7973f91d8b12" +checksum = "ff5d7609abc99c15de7d7f90b8441b27e2bd52e930a3014c95a9b620e5d3211a" dependencies = [ "hashbrown 0.14.5", "indexmap 2.6.0", diff --git a/crates/blockifier/Cargo.toml b/crates/blockifier/Cargo.toml index 66b5470e51..bbaa121ce9 100644 --- a/crates/blockifier/Cargo.toml +++ b/crates/blockifier/Cargo.toml @@ -53,7 +53,7 @@ sha2.workspace = true stacker = { workspace = true, optional = true } starknet-types-core.workspace = true starknet_api.workspace = true -starknet_sierra_compile = { workspace = true, optional = true } +starknet_sierra_compile.workspace = true strum.workspace = true strum_macros.workspace = true tempfile.workspace = true diff --git a/crates/blockifier/src/blockifier/config.rs b/crates/blockifier/src/blockifier/config.rs index e49fb7fbac..e8e6250bbd 100644 --- a/crates/blockifier/src/blockifier/config.rs +++ b/crates/blockifier/src/blockifier/config.rs @@ -3,6 +3,7 @@ use std::collections::BTreeMap; use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; +use starknet_sierra_compile::config::SierraCompilationConfig; use crate::state::contract_class_manager::DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE; use crate::state::global_cache::GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST; @@ -71,6 +72,7 @@ pub struct ContractClassManagerConfig { pub wait_on_native_compilation: bool, pub contract_cache_size: usize, pub channel_size: usize, + pub compiler_config: SierraCompilationConfig, } impl Default for ContractClassManagerConfig { @@ -80,13 +82,14 @@ impl Default for ContractClassManagerConfig { wait_on_native_compilation: false, contract_cache_size: GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST, channel_size: DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE, + compiler_config: SierraCompilationConfig::default(), } } } impl SerializeConfig for ContractClassManagerConfig { fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ + let mut dump = BTreeMap::from_iter([ ser_param( "run_cairo_native", &self.run_cairo_native, @@ -111,6 +114,8 @@ impl SerializeConfig for ContractClassManagerConfig { "The size of the compilation request channel.", ParamPrivacyInput::Public, ), - ]) + ]); + dump.append(&mut append_sub_config_name(self.compiler_config.dump(), "compiler_config")); + dump } } diff --git a/crates/blockifier/src/state/contract_class_manager.rs b/crates/blockifier/src/state/contract_class_manager.rs index 8f73e2a335..593dba06f3 100644 --- a/crates/blockifier/src/state/contract_class_manager.rs +++ b/crates/blockifier/src/state/contract_class_manager.rs @@ -13,8 +13,6 @@ use starknet_api::state::SierraContractClass; #[cfg(feature = "cairo_native")] use starknet_sierra_compile::command_line_compiler::CommandLineCompiler; #[cfg(feature = "cairo_native")] -use starknet_sierra_compile::config::SierraToCasmCompilationConfig; -#[cfg(feature = "cairo_native")] use starknet_sierra_compile::utils::into_contract_class_for_compilation; #[cfg(feature = "cairo_native")] use starknet_sierra_compile::SierraToNativeCompiler; @@ -81,7 +79,7 @@ impl ContractClassManager { }; } - let compiler_config = SierraToCasmCompilationConfig::default(); + let compiler_config = config.compiler_config.clone(); let compiler = Arc::new(CommandLineCompiler::new(compiler_config)); if config.wait_on_native_compilation { // Compilation requests are processed synchronously. No need to start the worker. diff --git a/crates/native_blockifier/Cargo.toml b/crates/native_blockifier/Cargo.toml index e423eea5e8..a96697ff1d 100644 --- a/crates/native_blockifier/Cargo.toml +++ b/crates/native_blockifier/Cargo.toml @@ -7,7 +7,11 @@ license-file.workspace = true description = "A Bridge between the Rust blockifier crate and Python." [features] -cairo_native = ["blockifier/cairo_native", "papyrus_state_reader/cairo_native"] +cairo_native = [ + "blockifier/cairo_native", + "papyrus_state_reader/cairo_native", + "starknet_sierra_compile/cairo_native", +] # Required for `cargo test` to work with Pyo3. # On Python, make sure to compile this with the extension-module feature enabled. # https://pyo3.rs/v0.19.1/faq#i-cant-run-cargo-test-or-i-cant-build-in-a-cargo-workspace-im-having-linker-issues-like-symbol-not-found-or-undefined-reference-to-_pyexc_systemerror @@ -42,6 +46,7 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, features = ["arbitrary_precision"] } starknet-types-core.workspace = true starknet_api.workspace = true +starknet_sierra_compile.workspace = true thiserror.workspace = true [dev-dependencies] diff --git a/crates/native_blockifier/src/py_objects.rs b/crates/native_blockifier/src/py_objects.rs index 9cc2eb109d..23f6d4fc1b 100644 --- a/crates/native_blockifier/src/py_objects.rs +++ b/crates/native_blockifier/src/py_objects.rs @@ -1,6 +1,7 @@ #![allow(non_local_definitions)] use std::collections::HashMap; +use std::path::PathBuf; use blockifier::abi::constants; use blockifier::blockifier::config::{ConcurrencyConfig, ContractClassManagerConfig}; @@ -12,6 +13,7 @@ use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use pyo3::prelude::*; use starknet_api::execution_resources::GasAmount; +use starknet_sierra_compile::config::SierraCompilationConfig; use crate::errors::{ InvalidNativeBlockifierInputError, @@ -160,13 +162,49 @@ impl From for ConcurrencyConfig { } } } +#[derive(Debug, Clone, FromPyObject)] +pub struct PySierraCompilationConfig { + pub sierra_to_native_compiler_path: String, + pub libcairo_native_runtime_path: String, +} + +impl Default for PySierraCompilationConfig { + fn default() -> Self { + Self { sierra_to_native_compiler_path: "".into(), libcairo_native_runtime_path: "".into() } + } +} + +impl From for SierraCompilationConfig { + fn from(py_sierra_compilation_config: PySierraCompilationConfig) -> Self { + SierraCompilationConfig { + sierra_to_native_compiler_path: if py_sierra_compilation_config + .sierra_to_native_compiler_path + .is_empty() + { + None + } else { + Some(PathBuf::from(py_sierra_compilation_config.sierra_to_native_compiler_path)) + }, + libcairo_native_runtime_path: if py_sierra_compilation_config + .libcairo_native_runtime_path + .is_empty() + { + None + } else { + Some(PathBuf::from(py_sierra_compilation_config.libcairo_native_runtime_path)) + }, + ..Default::default() + } + } +} -#[derive(Debug, Clone, Copy, FromPyObject)] +#[derive(Debug, Clone, FromPyObject)] pub struct PyContractClassManagerConfig { pub run_cairo_native: bool, pub wait_on_native_compilation: bool, pub contract_cache_size: usize, pub channel_size: usize, + pub compiler_config: PySierraCompilationConfig, } impl Default for PyContractClassManagerConfig { @@ -176,6 +214,7 @@ impl Default for PyContractClassManagerConfig { wait_on_native_compilation: false, contract_cache_size: GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST, channel_size: DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE, + compiler_config: PySierraCompilationConfig::default(), } } } @@ -187,6 +226,7 @@ impl From for ContractClassManagerConfig { wait_on_native_compilation: py_contract_class_manager_config.wait_on_native_compilation, contract_cache_size: py_contract_class_manager_config.contract_cache_size, channel_size: py_contract_class_manager_config.channel_size, + compiler_config: py_contract_class_manager_config.compiler_config.into(), } } } diff --git a/crates/starknet_gateway/src/compilation.rs b/crates/starknet_gateway/src/compilation.rs index 741068df8d..b4b6cdd4f4 100644 --- a/crates/starknet_gateway/src/compilation.rs +++ b/crates/starknet_gateway/src/compilation.rs @@ -6,7 +6,7 @@ use starknet_api::contract_class::{ClassInfo, ContractClass, SierraVersion}; use starknet_api::rpc_transaction::RpcDeclareTransaction; use starknet_gateway_types::errors::GatewaySpecError; use starknet_sierra_compile::command_line_compiler::CommandLineCompiler; -use starknet_sierra_compile::config::SierraToCasmCompilationConfig; +use starknet_sierra_compile::config::SierraCompilationConfig; use starknet_sierra_compile::utils::into_contract_class_for_compilation; use starknet_sierra_compile::SierraToCasmCompiler; use tracing::{debug, error}; @@ -24,7 +24,7 @@ pub struct GatewayCompiler { } impl GatewayCompiler { - pub fn new_command_line_compiler(config: SierraToCasmCompilationConfig) -> Self { + pub fn new_command_line_compiler(config: SierraCompilationConfig) -> Self { Self { sierra_to_casm_compiler: Arc::new(CommandLineCompiler::new(config)) } } diff --git a/crates/starknet_gateway/src/compilation_test.rs b/crates/starknet_gateway/src/compilation_test.rs index 0958884ee6..b82096644e 100644 --- a/crates/starknet_gateway/src/compilation_test.rs +++ b/crates/starknet_gateway/src/compilation_test.rs @@ -10,7 +10,7 @@ use starknet_api::rpc_transaction::{ RpcTransaction, }; use starknet_gateway_types::errors::GatewaySpecError; -use starknet_sierra_compile::config::SierraToCasmCompilationConfig; +use starknet_sierra_compile::config::SierraCompilationConfig; use starknet_sierra_compile::errors::CompilationUtilError; use tracing_test::traced_test; @@ -18,7 +18,7 @@ use crate::compilation::GatewayCompiler; #[fixture] fn gateway_compiler() -> GatewayCompiler { - GatewayCompiler::new_command_line_compiler(SierraToCasmCompilationConfig::default()) + GatewayCompiler::new_command_line_compiler(SierraCompilationConfig::default()) } #[fixture] @@ -33,10 +33,10 @@ fn declare_tx_v3() -> RpcDeclareTransactionV3 { #[traced_test] #[rstest] fn test_compile_contract_class_bytecode_size_validation(declare_tx_v3: RpcDeclareTransactionV3) { - let gateway_compiler = - GatewayCompiler::new_command_line_compiler(SierraToCasmCompilationConfig { - max_bytecode_size: 1, - }); + let gateway_compiler = GatewayCompiler::new_command_line_compiler(SierraCompilationConfig { + max_casm_bytecode_size: 1, + ..SierraCompilationConfig::default() + }); let result = gateway_compiler.process_declare_tx(&RpcDeclareTransaction::V3(declare_tx_v3)); assert_matches!(result.unwrap_err(), GatewaySpecError::CompilationFailed); diff --git a/crates/starknet_gateway/src/gateway.rs b/crates/starknet_gateway/src/gateway.rs index 102e2cf0b6..af71c985c3 100644 --- a/crates/starknet_gateway/src/gateway.rs +++ b/crates/starknet_gateway/src/gateway.rs @@ -10,7 +10,7 @@ use starknet_gateway_types::errors::GatewaySpecError; use starknet_mempool_types::communication::{AddTransactionArgsWrapper, SharedMempoolClient}; use starknet_mempool_types::mempool_types::{AccountState, AddTransactionArgs}; use starknet_sequencer_infra::component_definitions::ComponentStarter; -use starknet_sierra_compile::config::SierraToCasmCompilationConfig; +use starknet_sierra_compile::config::SierraCompilationConfig; use tracing::{error, info, instrument, Span}; use crate::compilation::GatewayCompiler; @@ -149,7 +149,7 @@ impl ProcessTxBlockingTask { pub fn create_gateway( config: GatewayConfig, rpc_state_reader_config: RpcStateReaderConfig, - compiler_config: SierraToCasmCompilationConfig, + compiler_config: SierraCompilationConfig, mempool_client: SharedMempoolClient, ) -> Gateway { let state_reader_factory = Arc::new(RpcStateReaderFactory { config: rpc_state_reader_config }); diff --git a/crates/starknet_gateway/src/gateway_test.rs b/crates/starknet_gateway/src/gateway_test.rs index e8502f43ae..21a023739f 100644 --- a/crates/starknet_gateway/src/gateway_test.rs +++ b/crates/starknet_gateway/src/gateway_test.rs @@ -14,7 +14,7 @@ use starknet_api::rpc_transaction::{RpcDeclareTransaction, RpcTransaction}; use starknet_gateway_types::errors::GatewaySpecError; use starknet_mempool_types::communication::{AddTransactionArgsWrapper, MockMempoolClient}; use starknet_mempool_types::mempool_types::{AccountState, AddTransactionArgs}; -use starknet_sierra_compile::config::SierraToCasmCompilationConfig; +use starknet_sierra_compile::config::SierraCompilationConfig; use crate::compilation::GatewayCompiler; use crate::config::{ @@ -36,7 +36,7 @@ fn config() -> GatewayConfig { #[fixture] fn compiler() -> GatewayCompiler { - GatewayCompiler::new_command_line_compiler(SierraToCasmCompilationConfig::default()) + GatewayCompiler::new_command_line_compiler(SierraCompilationConfig::default()) } #[fixture] diff --git a/crates/starknet_sequencer_node/src/config/node_config.rs b/crates/starknet_sequencer_node/src/config/node_config.rs index d8a289ad80..a491c29a2f 100644 --- a/crates/starknet_sequencer_node/src/config/node_config.rs +++ b/crates/starknet_sequencer_node/src/config/node_config.rs @@ -26,7 +26,7 @@ use starknet_http_server::config::HttpServerConfig; use starknet_l1_provider::L1ProviderConfig; use starknet_mempool_p2p::config::MempoolP2pConfig; use starknet_monitoring_endpoint::config::MonitoringEndpointConfig; -use starknet_sierra_compile::config::SierraToCasmCompilationConfig; +use starknet_sierra_compile::config::SierraCompilationConfig; use starknet_state_sync::config::StateSyncConfig; use validator::Validate; @@ -122,7 +122,7 @@ pub struct SequencerNodeConfig { #[validate] pub rpc_state_reader_config: RpcStateReaderConfig, #[validate] - pub compiler_config: SierraToCasmCompilationConfig, + pub compiler_config: SierraCompilationConfig, #[validate] pub l1_provider_config: L1ProviderConfig, #[validate] diff --git a/crates/starknet_sierra_compile/Cargo.toml b/crates/starknet_sierra_compile/Cargo.toml index e071b53ae4..495e01ae46 100644 --- a/crates/starknet_sierra_compile/Cargo.toml +++ b/crates/starknet_sierra_compile/Cargo.toml @@ -16,6 +16,7 @@ cairo-lang-sierra.workspace = true cairo-lang-starknet-classes.workspace = true cairo-lang-utils.workspace = true cairo-native = { workspace = true, optional = true } +itertools.workspace = true papyrus_config.workspace = true rlimit.workspace = true serde.workspace = true diff --git a/crates/starknet_sierra_compile/src/command_line_compiler.rs b/crates/starknet_sierra_compile/src/command_line_compiler.rs index ce324b49f5..8587385699 100644 --- a/crates/starknet_sierra_compile/src/command_line_compiler.rs +++ b/crates/starknet_sierra_compile/src/command_line_compiler.rs @@ -8,7 +8,7 @@ use cairo_lang_starknet_classes::contract_class::ContractClass; use cairo_native::executor::AotContractExecutor; use tempfile::NamedTempFile; -use crate::config::SierraToCasmCompilationConfig; +use crate::config::SierraCompilationConfig; use crate::constants::CAIRO_LANG_BINARY_NAME; #[cfg(feature = "cairo_native")] use crate::constants::CAIRO_NATIVE_BINARY_NAME; @@ -20,22 +20,25 @@ use crate::SierraToNativeCompiler; #[derive(Clone)] pub struct CommandLineCompiler { - pub config: SierraToCasmCompilationConfig, + pub config: SierraCompilationConfig, path_to_starknet_sierra_compile_binary: PathBuf, #[cfg(feature = "cairo_native")] path_to_starknet_native_compile_binary: PathBuf, } impl CommandLineCompiler { - pub fn new(config: SierraToCasmCompilationConfig) -> Self { + pub fn new(config: SierraCompilationConfig) -> Self { + let path_to_starknet_sierra_compile_binary = binary_path(out_dir(), CAIRO_LANG_BINARY_NAME); + #[cfg(feature = "cairo_native")] + let path_to_starknet_native_compile_binary = match &config.sierra_to_native_compiler_path { + Some(path) => path.clone(), + None => binary_path(out_dir(), CAIRO_NATIVE_BINARY_NAME), + }; Self { config, - path_to_starknet_sierra_compile_binary: binary_path(out_dir(), CAIRO_LANG_BINARY_NAME), + path_to_starknet_sierra_compile_binary, #[cfg(feature = "cairo_native")] - path_to_starknet_native_compile_binary: binary_path( - out_dir(), - CAIRO_NATIVE_BINARY_NAME, - ), + path_to_starknet_native_compile_binary, } } } @@ -46,13 +49,15 @@ impl SierraToCasmCompiler for CommandLineCompiler { contract_class: ContractClass, ) -> Result { let compiler_binary_path = &self.path_to_starknet_sierra_compile_binary; - let additional_args = [ + let additional_args = &[ "--add-pythonic-hints", "--max-bytecode-size", - &self.config.max_bytecode_size.to_string(), + &self.config.max_casm_bytecode_size.to_string(), ]; + let env_vars = vec![]; - let stdout = compile_with_args(compiler_binary_path, contract_class, &additional_args)?; + let stdout = + compile_with_args(compiler_binary_path, contract_class, additional_args, env_vars)?; Ok(serde_json::from_slice::(&stdout)?) } } @@ -69,9 +74,15 @@ impl SierraToNativeCompiler for CommandLineCompiler { let output_file_path = output_file.path().to_str().ok_or( CompilationUtilError::UnexpectedError("Failed to get output file path".to_owned()), )?; - let additional_args = [output_file_path]; + let additional_args = &[output_file_path]; - let _stdout = compile_with_args(compiler_binary_path, contract_class, &additional_args)?; + let mut env_vars = vec![]; + if let Some(path) = &self.config.libcairo_native_runtime_path { + env_vars.push(("CAIRO_NATIVE_RUNTIME_LIBRARY", path.to_str().unwrap())); + }; + + let _stdout = + compile_with_args(compiler_binary_path, contract_class, additional_args, env_vars)?; Ok(AotContractExecutor::load(Path::new(&output_file_path))?) } @@ -81,6 +92,7 @@ fn compile_with_args( compiler_binary_path: &Path, contract_class: ContractClass, additional_args: &[&str], + env_vars: Vec<(&str, &str)>, ) -> Result, CompilationUtilError> { // Create a temporary file to store the Sierra contract class. let serialized_contract_class = serde_json::to_string(&contract_class)?; @@ -95,6 +107,9 @@ fn compile_with_args( // TODO(Arni, Avi): Setup the ulimit for the process. let mut command = Command::new(compiler_binary_path.as_os_str()); command.arg(temp_file_path).args(additional_args); + for (name, value) in env_vars { + command.env(name, value); + } // Run the compile process. let compile_output = command.output()?; diff --git a/crates/starknet_sierra_compile/src/compile_test.rs b/crates/starknet_sierra_compile/src/compile_test.rs index 642cd4e4b9..f1768baa2a 100644 --- a/crates/starknet_sierra_compile/src/compile_test.rs +++ b/crates/starknet_sierra_compile/src/compile_test.rs @@ -8,15 +8,18 @@ use mempool_test_utils::{FAULTY_ACCOUNT_CLASS_FILE, TEST_FILES_FOLDER}; use rstest::rstest; use crate::command_line_compiler::CommandLineCompiler; -use crate::config::SierraToCasmCompilationConfig; +use crate::config::{SierraCompilationConfig, DEFAULT_MAX_CASM_BYTECODE_SIZE}; use crate::errors::CompilationUtilError; use crate::test_utils::contract_class_from_file; use crate::SierraToCasmCompiler; #[cfg(feature = "cairo_native")] use crate::SierraToNativeCompiler; -const SIERRA_TO_CASM_COMPILATION_CONFIG: SierraToCasmCompilationConfig = - SierraToCasmCompilationConfig { max_bytecode_size: 81920 }; +const SIERRA_TO_CASM_COMPILATION_CONFIG: SierraCompilationConfig = SierraCompilationConfig { + max_casm_bytecode_size: DEFAULT_MAX_CASM_BYTECODE_SIZE, + sierra_to_native_compiler_path: None, + libcairo_native_runtime_path: None, +}; fn command_line_compiler() -> CommandLineCompiler { CommandLineCompiler::new(SIERRA_TO_CASM_COMPILATION_CONFIG) diff --git a/crates/starknet_sierra_compile/src/config.rs b/crates/starknet_sierra_compile/src/config.rs index e3601b6f8e..7fd1f92463 100644 --- a/crates/starknet_sierra_compile/src/config.rs +++ b/crates/starknet_sierra_compile/src/config.rs @@ -1,29 +1,55 @@ use std::collections::BTreeMap; +use std::path::PathBuf; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{ser_optional_param, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; +pub const DEFAULT_MAX_CASM_BYTECODE_SIZE: usize = 81920; + #[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] -pub struct SierraToCasmCompilationConfig { - /// CASM bytecode size limit. - pub max_bytecode_size: usize, +pub struct SierraCompilationConfig { + /// Bytecode size limit. + pub max_casm_bytecode_size: usize, + /// Sierra-to-Native compiler binary path. + pub sierra_to_native_compiler_path: Option, + /// Path to Cairo native runtime library file. + pub libcairo_native_runtime_path: Option, } -impl Default for SierraToCasmCompilationConfig { +impl Default for SierraCompilationConfig { fn default() -> Self { - Self { max_bytecode_size: 81920 } + Self { + max_casm_bytecode_size: DEFAULT_MAX_CASM_BYTECODE_SIZE, + sierra_to_native_compiler_path: None, + libcairo_native_runtime_path: None, + } } } -impl SerializeConfig for SierraToCasmCompilationConfig { +impl SerializeConfig for SierraCompilationConfig { fn dump(&self) -> BTreeMap { - BTreeMap::from_iter([ser_param( - "max_bytecode_size", - &self.max_bytecode_size, - "Limitation of contract bytecode size.", + let mut dump = BTreeMap::from_iter([ser_param( + "max_casm_bytecode_size", + &self.max_casm_bytecode_size, + "Limitation of compiled casm bytecode size.", + ParamPrivacyInput::Public, + )]); + dump.extend(ser_optional_param( + &self.sierra_to_native_compiler_path, + "".into(), + "sierra_to_native_compiler_path", + "The path to the Sierra-to-Native compiler binary.", + ParamPrivacyInput::Public, + )); + dump.extend(ser_optional_param( + &self.libcairo_native_runtime_path, + "".into(), + "libcairo_native_runtime_path", + "The path to the Cairo native runtime library file.", ParamPrivacyInput::Public, - )]) + )); + dump } }