From b3a217b64e2e14c79132d96b8cb251611f463702 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Fri, 27 Sep 2024 13:45:53 -0600 Subject: [PATCH] Bump cairo-vm (#386) * Bump cairo-vm * Fix compiler warning * Appease clippy * fmt --- Cargo.toml | 10 +++++----- crates/starknet-os-types/src/casm_contract_class.rs | 1 + .../starknet-os-types/src/deprecated_compiled_class.rs | 1 + crates/starknet-os-types/src/sierra_contract_class.rs | 2 +- crates/starknet-os/src/sharp/pie.rs | 6 +++--- .../commitment_tree/merkle_tree/traverse_tree.rs | 2 +- .../commitment_tree/patricia_tree/nodes.rs | 2 ++ .../patricia_tree/patricia_guess_descents.rs | 3 ++- .../src/starkware_utils/commitment_tree/update_tree.rs | 1 + crates/starknet-os/src/storage/composite_storage.rs | 1 + rust-toolchain | 2 +- 11 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5ab27df0e..64afb8663 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,12 +30,12 @@ base64 = "0.21.3" bitvec = { version = "1.0.1", features = ["serde"] } # Point to the latest commit of branch msl/backport-secp-patches-0.8.0-rc.3 blockifier = { git = "https://github.com/Moonsong-Labs/sequencer", rev = "6624e910c57db9a16f1607c1ed26f7d8f1114e73", features = ["testing"] } -cairo-lang-starknet = { version = "=2.7.1" } -cairo-lang-starknet-classes = { version = "=2.7.1" } -cairo-lang-utils = { version = "=2.7.1" } -cairo-lang-casm = { version = "=2.7.1" } +cairo-lang-starknet = { version = "=2.8.2" } +cairo-lang-starknet-classes = { version = "=2.8.2" } +cairo-lang-utils = { version = "=2.8.2" } +cairo-lang-casm = { version = "=2.8.2" } cairo-type-derive = { version = "0.1.0", path = "crates/cairo-type-derive" } -cairo-vm = { git = "https://github.com/Moonsong-Labs/cairo-vm", rev = "56b68b50944ecb3123a168218ea7b8b8e23f9be8", features = ["cairo-1-hints", "extensive_hints", "mod_builtin"] } +cairo-vm = { git = "https://github.com/Moonsong-Labs/cairo-vm", branch = "notlesh/segment-arena-relocation-fix", features = ["cairo-1-hints", "extensive_hints", "mod_builtin"] } clap = { version = "4.5.4", features = ["derive"] } c-kzg = { version = "1.0.3" } env_logger = "0.11.3" diff --git a/crates/starknet-os-types/src/casm_contract_class.rs b/crates/starknet-os-types/src/casm_contract_class.rs index 9acabdc33..2afe7739d 100644 --- a/crates/starknet-os-types/src/casm_contract_class.rs +++ b/crates/starknet-os-types/src/casm_contract_class.rs @@ -11,6 +11,7 @@ pub type BlockifierCasmClass = blockifier::execution::contract_class::ContractCl /// A generic contract class that supports conversion to/from the most commonly used /// contract class types in Starknet and provides utility methods. +/// /// Operations are implemented as lazily as possible, i.e. we only convert /// between different types if strictly necessary. /// Fields are boxed in an RC for cheap cloning. diff --git a/crates/starknet-os-types/src/deprecated_compiled_class.rs b/crates/starknet-os-types/src/deprecated_compiled_class.rs index 499e22627..1aa7a66d0 100644 --- a/crates/starknet-os-types/src/deprecated_compiled_class.rs +++ b/crates/starknet-os-types/src/deprecated_compiled_class.rs @@ -15,6 +15,7 @@ pub type BlockifierDeprecatedClass = blockifier::execution::contract_class::Cont /// A generic contract class that supports conversion to/from the most commonly used /// contract class types in Starknet and provides utility methods. +/// /// Operations are implemented as lazily as possible, i.e. we only convert /// between different types if strictly necessary. /// Fields are boxed in an RC for cheap cloning. diff --git a/crates/starknet-os-types/src/sierra_contract_class.rs b/crates/starknet-os-types/src/sierra_contract_class.rs index ca5b2d0d9..e11569002 100644 --- a/crates/starknet-os-types/src/sierra_contract_class.rs +++ b/crates/starknet-os-types/src/sierra_contract_class.rs @@ -17,6 +17,7 @@ pub type StarknetCoreSierraContractClass = starknet_core::types::FlattenedSierra /// A generic Sierra contract class that supports conversion to/from the most commonly used /// contract class types in Starknet and provides utility methods. +/// /// Operations are implemented as lazily as possible, i.e. we only convert /// between different types if strictly necessary. /// Fields are boxed in an Arc for cheap cloning. @@ -105,7 +106,6 @@ impl GenericSierraContractClass { #[serde_as] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))] pub struct FlattenedSierraClassWithAbi { /// The list of sierra instructions of which the program consists pub sierra_program: Vec, diff --git a/crates/starknet-os/src/sharp/pie.rs b/crates/starknet-os/src/sharp/pie.rs index dfda3cd35..5fba8916a 100644 --- a/crates/starknet-os/src/sharp/pie.rs +++ b/crates/starknet-os/src/sharp/pie.rs @@ -52,10 +52,10 @@ fn write_to_zip(pie: CairoPie, mut zip: ZipWriter) -> Result let pie_mem_bytes = hex::decode(pie_s[file].to_string().trim_matches('"')) .map_err(|e| SnOsError::PieZipping(format!("{e}")))?; - zip.start_file(&format!("{file}.bin"), options).map_err(|e| SnOsError::PieZipping(format!("{e}")))?; + zip.start_file(format!("{file}.bin"), options).map_err(|e| SnOsError::PieZipping(format!("{e}")))?; zip.write_all(&pie_mem_bytes).map_err(|e| SnOsError::PieZipping(format!("{e}")))?; } else { - zip.start_file(&format!("{file}.json"), options).map_err(|e| SnOsError::PieZipping(format!("{e}")))?; + zip.start_file(format!("{file}.json"), options).map_err(|e| SnOsError::PieZipping(format!("{e}")))?; zip.write_all(pie_s[file].to_string().as_bytes()).map_err(|e| SnOsError::PieZipping(format!("{e}")))?; }; } @@ -71,7 +71,7 @@ pub fn decode_base64_to_unzipped(pie_str: &str, dst: &str) -> Result<(), SnOsErr general_purpose::STANDARD.decode(pie_str.as_bytes()).map_err(|e| SnOsError::PieZipping(format!("{e}")))?; ZipArchive::new(Cursor::new(&buffer)) .unwrap() - .extract(&PathBuf::from(dst)) + .extract(PathBuf::from(dst)) .map_err(|e| SnOsError::PieZipping(format!("{e}")))?; Ok(()) } diff --git a/crates/starknet-os/src/starkware_utils/commitment_tree/merkle_tree/traverse_tree.rs b/crates/starknet-os/src/starkware_utils/commitment_tree/merkle_tree/traverse_tree.rs index 663b9b006..2e940ac22 100644 --- a/crates/starknet-os/src/starkware_utils/commitment_tree/merkle_tree/traverse_tree.rs +++ b/crates/starknet-os/src/starkware_utils/commitment_tree/merkle_tree/traverse_tree.rs @@ -17,7 +17,7 @@ where /// Traverses a tree as follows: /// 1. Starts by calling get_children_callback(root). This function should return the children of -/// root in the tree that you want to visit. +/// root in the tree that you want to visit. /// 2. Call get_children_callback() on each of the children to get more nodes, and repeat. /// /// The order of execution is not guaranteed, except that it is more similar to DFS than BFS in diff --git a/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/nodes.rs b/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/nodes.rs index 9a6fa3576..9addd00cc 100644 --- a/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/nodes.rs +++ b/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/nodes.rs @@ -136,8 +136,10 @@ impl Serializable for BinaryNodeFact { } } +#[allow(clippy::too_long_first_doc_paragraph)] /// A node in a Patricia-Merkle tree that represents the edge to a subtree that contains data /// with value != 0. +/// /// Represented by three values embedding this information (elaborated below). /// Note that the bottom_node cannot be an edge node itself (otherwise, they would have both been /// fused to a bigger edge node). diff --git a/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/patricia_guess_descents.rs b/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/patricia_guess_descents.rs index 1faa09d8f..a1cf63533 100644 --- a/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/patricia_guess_descents.rs +++ b/crates/starknet-os/src/starkware_utils/commitment_tree/patricia_tree/patricia_guess_descents.rs @@ -135,7 +135,8 @@ impl<'preimage> Iterator for PreimageNodeIterator<'preimage> { /// The Python implementation returns a generator as follows: /// * if node is a leaf: [0] /// * Otherwise: [left, right] where each child is either None if empty or a generator defined -/// recursively. +/// recursively. +/// /// Note that this does not necessarily traverse the entire tree. The caller may open the branches /// as they wish. fn preimage_tree(height: Height, preimage: &Preimage, node: Triplet) -> PreimageNodeIterator { diff --git a/crates/starknet-os/src/starkware_utils/commitment_tree/update_tree.rs b/crates/starknet-os/src/starkware_utils/commitment_tree/update_tree.rs index b59c0b6b0..f8bbf248c 100644 --- a/crates/starknet-os/src/starkware_utils/commitment_tree/update_tree.rs +++ b/crates/starknet-os/src/starkware_utils/commitment_tree/update_tree.rs @@ -350,6 +350,7 @@ where /// Given a node generated by build_update_tree(), returns which update case it belongs to, /// and both children. This is a utility to make cairo hints shorter. +/// /// Cases: both, if both children are to be updated, and left or right, if only one child is to be /// updated. pub fn decode_node(node: &TreeUpdate) -> Result, TreeError> diff --git a/crates/starknet-os/src/storage/composite_storage.rs b/crates/starknet-os/src/storage/composite_storage.rs index 0577f2e8f..745664fb5 100644 --- a/crates/starknet-os/src/storage/composite_storage.rs +++ b/crates/starknet-os/src/storage/composite_storage.rs @@ -1,6 +1,7 @@ use crate::storage::storage::{Storage, StorageError}; /// A composite storage is a storage object made of one main and one fallback storages. +/// /// It will first attempt to look up the main storage then try the fallback one if it could /// not find any value in the main storage. pub struct CompositeStorage diff --git a/rust-toolchain b/rust-toolchain index e708905f9..44af6faa6 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-05-02" +channel = "nightly-2024-09-05" components = ["rustfmt", "clippy"] profile = "minimal"