diff --git a/Cargo.lock b/Cargo.lock index f929f20..7ca3b89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -418,6 +418,19 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-lang-casm" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "cairo-lang-utils 2.8.2", + "indoc", + "num-bigint", + "num-traits 0.2.19", + "parity-scale-codec", + "serde", +] + [[package]] name = "cairo-lang-eq-solver" version = "2.6.4" @@ -436,6 +449,15 @@ dependencies = [ "good_lp", ] +[[package]] +name = "cairo-lang-eq-solver" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "cairo-lang-utils 2.8.2", + "good_lp", +] + [[package]] name = "cairo-lang-sierra" version = "2.6.4" @@ -488,6 +510,32 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-sierra" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "anyhow", + "cairo-lang-utils 2.8.2", + "const-fnv1a-hash", + "convert_case", + "derivative", + "itertools 0.12.1", + "lalrpop", + "lalrpop-util", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "regex", + "rust-analyzer-salsa", + "serde", + "serde_json", + "sha3", + "smol_str", + "starknet-types-core", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-ap-change" version = "2.6.4" @@ -517,6 +565,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-sierra-ap-change" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "cairo-lang-eq-solver 2.8.2", + "cairo-lang-sierra 2.8.2", + "cairo-lang-sierra-type-size 2.8.2", + "cairo-lang-utils 2.8.2", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-gas" version = "2.6.4" @@ -546,6 +609,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-sierra-gas" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "cairo-lang-eq-solver 2.8.2", + "cairo-lang-sierra 2.8.2", + "cairo-lang-sierra-type-size 2.8.2", + "cairo-lang-utils 2.8.2", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-to-casm" version = "2.6.4" @@ -586,6 +664,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-sierra-to-casm" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "assert_matches", + "cairo-lang-casm 2.8.2", + "cairo-lang-sierra 2.8.2", + "cairo-lang-sierra-ap-change 2.8.2", + "cairo-lang-sierra-gas 2.8.2", + "cairo-lang-sierra-type-size 2.8.2", + "cairo-lang-utils 2.8.2", + "indoc", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", + "starknet-types-core", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-type-size" version = "2.6.4" @@ -604,6 +702,15 @@ dependencies = [ "cairo-lang-utils 2.7.1", ] +[[package]] +name = "cairo-lang-sierra-type-size" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "cairo-lang-sierra 2.8.2", + "cairo-lang-utils 2.8.2", +] + [[package]] name = "cairo-lang-starknet-classes" version = "2.6.4" @@ -651,6 +758,28 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-starknet-classes" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "cairo-lang-casm 2.8.2", + "cairo-lang-sierra 2.8.2", + "cairo-lang-sierra-to-casm 2.8.2", + "cairo-lang-utils 2.8.2", + "convert_case", + "itertools 0.12.1", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "serde", + "serde_json", + "sha3", + "smol_str", + "starknet-types-core", + "thiserror", +] + [[package]] name = "cairo-lang-utils" version = "2.6.4" @@ -679,6 +808,20 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-lang-utils" +version = "2.8.2" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.8.2#14b1d8c1566b3346545eb7e65724e3d0cbb80a81" +dependencies = [ + "hashbrown 0.14.5", + "indexmap 2.3.0", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", + "schemars", + "serde", +] + [[package]] name = "cc" version = "1.0.82" @@ -2698,6 +2841,35 @@ dependencies = [ "libusb1-sys", ] +[[package]] +name = "rust-analyzer-salsa" +version = "0.17.0-pre.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719825638c59fd26a55412a24561c7c5bcf54364c88b9a7a04ba08a6eafaba8d" +dependencies = [ + "indexmap 2.3.0", + "lock_api", + "oorandom", + "parking_lot 0.12.1", + "rust-analyzer-salsa-macros", + "rustc-hash", + "smallvec", + "tracing", + "triomphe", +] + +[[package]] +name = "rust-analyzer-salsa-macros" +version = "0.17.0-pre.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d96498e9684848c6676c399032ebc37c52da95ecbefa83d71ccc53b9f8a4a8e" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.68", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -3113,6 +3285,12 @@ dependencies = [ "num-traits 0.1.43", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "starkli" version = "0.3.4" @@ -3123,6 +3301,7 @@ dependencies = [ "bigdecimal", "cairo-lang-starknet-classes 2.6.4", "cairo-lang-starknet-classes 2.7.1", + "cairo-lang-starknet-classes 2.8.2", "chrono", "clap", "clap_complete", @@ -3685,6 +3864,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "triomphe" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "try-lock" version = "0.2.4" diff --git a/Cargo.toml b/Cargo.toml index 19f3ae9..9b82376 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ auto_impl = "1.1.0" bigdecimal = "0.4.1" cairo-starknet-2-6-4 = { package = "cairo-lang-starknet-classes", git = "https://github.com/starkware-libs/cairo", tag = "v2.6.4" } cairo-starknet-2-7-1 = { package = "cairo-lang-starknet-classes", git = "https://github.com/starkware-libs/cairo", tag = "v2.7.1" } +cairo-starknet-2-8-2 = { package = "cairo-lang-starknet-classes", git = "https://github.com/starkware-libs/cairo", tag = "v2.8.2" } chrono = "0.4.26" clap = { version = "4.3.8", features = ["derive", "env", "string"] } clap_complete = "4.3.1" diff --git a/src/casm.rs b/src/casm.rs index 5772d4a..0b51f92 100644 --- a/src/casm.rs +++ b/src/casm.rs @@ -72,10 +72,9 @@ impl CasmArgs { match network { Some(network) => { let auto_version = match network { - Network::Sepolia | Network::SepoliaIntegration => { - CompilerVersion::V2_7_1 + Network::Sepolia | Network::SepoliaIntegration | Network::Mainnet => { + CompilerVersion::V2_8_2 } - Network::Mainnet => CompilerVersion::V2_6_4, }; eprintln!( diff --git a/src/compiler.rs b/src/compiler.rs index 36c91f2..b7843d5 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -14,6 +14,10 @@ use cairo_starknet_2_7_1::{ casm_contract_class::CasmContractClass as Cairo271CasmClass, contract_class::ContractClass as Cairo271Class, }; +use cairo_starknet_2_8_2::{ + casm_contract_class::CasmContractClass as Cairo282CasmClass, + contract_class::ContractClass as Cairo282Class, +}; use clap::{builder::PossibleValue, ValueEnum}; use starknet::core::types::{ contract::{CompiledClass, SierraClass}, @@ -37,6 +41,7 @@ pub struct CompilerBinary { pub enum CompilerVersion { V2_6_4, V2_7_1, + V2_8_2, } impl BuiltInCompiler { @@ -69,6 +74,20 @@ impl BuiltInCompiler { serde_json::to_string(&casm_contract)? } CompilerVersion::V2_7_1 => { + // TODO: directly convert type without going through JSON + let contract_class: Cairo282Class = serde_json::from_str(&sierra_class_json)?; + + // TODO: implement the `validate_compatible_sierra_version` call + + let casm_contract = Cairo282CasmClass::from_contract_class( + contract_class, + false, + MAX_BYTECODE_SIZE, + )?; + + serde_json::to_string(&casm_contract)? + } + CompilerVersion::V2_8_2 => { // TODO: directly convert type without going through JSON let contract_class: Cairo271Class = serde_json::from_str(&sierra_class_json)?; @@ -142,7 +161,7 @@ impl Default for CompilerVersion { impl ValueEnum for CompilerVersion { fn value_variants<'a>() -> &'a [Self] { - &[Self::V2_6_4, Self::V2_7_1] + &[Self::V2_6_4, Self::V2_7_1, Self::V2_8_2] } fn to_possible_value(&self) -> Option { @@ -159,6 +178,12 @@ impl ValueEnum for CompilerVersion { .alias("2.7") .alias("v2.7"), ), + Self::V2_8_2 => Some( + PossibleValue::new("2.8.2") + .alias("v2.8.2") + .alias("2.8") + .alias("v2.8"), + ), } } } @@ -170,6 +195,7 @@ impl FromStr for CompilerVersion { match s { "2.6.4" | "v2.6.4" | "2.6" | "v2.6" => Ok(Self::V2_6_4), "2.7.1" | "v2.7.1" | "2.7" | "v2.7" => Ok(Self::V2_7_1), + "2.8.2" | "v2.8.2" | "2.8" | "v2.8" => Ok(Self::V2_8_2), _ => Err(anyhow::anyhow!("unknown version: {}", s)), } } @@ -180,6 +206,7 @@ impl Display for CompilerVersion { match self { CompilerVersion::V2_6_4 => write!(f, "2.6.4"), CompilerVersion::V2_7_1 => write!(f, "2.7.1"), + CompilerVersion::V2_8_2 => write!(f, "2.8.2"), } } }