From f2ddc90a5493b03364b7f0f0198e9b48b915babc Mon Sep 17 00:00:00 2001 From: Pedro Fontana Date: Fri, 9 Feb 2024 17:31:56 -0300 Subject: [PATCH] Update Rust version to 1.74.1 (#1605) * Update rust version to 1.74.1 * cargo fmt -all * Update Makefile * cargo clippy --fix * fix cargo clippy * restore fuzzer/Cargo.lock --------- Co-authored-by: Pedro Fontana --- .github/workflows/bench.yml | 2 +- .github/workflows/cairo_1_programs.yml | 2 +- .github/workflows/fresh_run.yml | 2 +- .github/workflows/hint_accountant.yml | 2 +- .github/workflows/hyperfine.yml | 2 +- .github/workflows/iai_main.yml | 2 +- .github/workflows/iai_pr.yml | 4 ++-- .github/workflows/publish.yml | 2 +- .github/workflows/rust.yml | 8 ++++---- Makefile | 2 +- README.md | 2 +- cairo1-run/src/cairo_run.rs | 4 +++- rust-toolchain | 2 +- .../builtin_hint_processor/find_element_hint.rs | 2 +- .../cairo_1_hint_processor/hint_processor.rs | 2 +- vm/src/serde/deserialize_utils.rs | 2 +- vm/src/tests/mod.rs | 14 +++++++------- vm/src/vm/runners/builtin_runner/bitwise.rs | 3 ++- vm/src/vm/runners/cairo_pie.rs | 1 + 19 files changed, 32 insertions(+), 28 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index f3443d5f68..cf4a54a96d 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 with: components: rustfmt, clippy - uses: actions/checkout@v3 diff --git a/.github/workflows/cairo_1_programs.yml b/.github/workflows/cairo_1_programs.yml index d8a4c1f3f4..c2872a03b4 100644 --- a/.github/workflows/cairo_1_programs.yml +++ b/.github/workflows/cairo_1_programs.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Set up Cargo cache uses: Swatinem/rust-cache@v2 - name: Checkout diff --git a/.github/workflows/fresh_run.yml b/.github/workflows/fresh_run.yml index f733076e77..fd523f7c75 100644 --- a/.github/workflows/fresh_run.yml +++ b/.github/workflows/fresh_run.yml @@ -38,7 +38,7 @@ jobs: uses: actions/checkout@v3 - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Install Pyenv uses: "gabrielfalcao/pyenv-action@v13" diff --git a/.github/workflows/hint_accountant.yml b/.github/workflows/hint_accountant.yml index 4a3a1e023f..3bd9ca4ff0 100644 --- a/.github/workflows/hint_accountant.yml +++ b/.github/workflows/hint_accountant.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Set up Cargo cache uses: Swatinem/rust-cache@v2 - name: Checkout diff --git a/.github/workflows/hyperfine.yml b/.github/workflows/hyperfine.yml index 87bf26f3e3..6fb098b6a6 100644 --- a/.github/workflows/hyperfine.yml +++ b/.github/workflows/hyperfine.yml @@ -74,7 +74,7 @@ jobs: - name: Install Rust if: ${{ steps.cache.outputs.cache-hit != 'true' }} - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Checkout if: ${{ steps.cache.outputs.cache-hit != 'true' }} diff --git a/.github/workflows/iai_main.yml b/.github/workflows/iai_main.yml index e1217085ba..f61eef7e3e 100644 --- a/.github/workflows/iai_main.yml +++ b/.github/workflows/iai_main.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - name: Python3 Build diff --git a/.github/workflows/iai_pr.yml b/.github/workflows/iai_pr.yml index db446adeb9..afb9e3a97c 100644 --- a/.github/workflows/iai_pr.yml +++ b/.github/workflows/iai_pr.yml @@ -23,7 +23,7 @@ jobs: - name: Install Rust if: ${{ steps.cache-iai-results.outputs.cache-hit != 'true' }} - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Set up cargo cache if: ${{ steps.cache-iai-results.outputs.cache-hit != 'true' }} uses: Swatinem/rust-cache@v2 @@ -51,7 +51,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - name: Python3 Build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f4ea9e2193..a06efe8806 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - name: Install stable toolchain - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Publish crate cairo-vm env: CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a6a7a38f43..98a1cfdaf1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -135,7 +135,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 with: components: rustfmt, clippy - name: Set up cargo cache @@ -165,7 +165,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 with: targets: wasm32-unknown-unknown @@ -220,7 +220,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 with: components: llvm-tools-preview - name: Set up cargo cache @@ -281,7 +281,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install Rust - uses: dtolnay/rust-toolchain@1.70.0 + uses: dtolnay/rust-toolchain@1.74.1 - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - name: Checkout diff --git a/Makefile b/Makefile index 17dc6a8d35..94841fa1f1 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ ifndef PROPTEST_CASES endif .PHONY: build-cairo-1-compiler build-cairo-1-compiler-macos build-cairo-2-compiler build-cairo-2-compiler-macos \ - deps deps-macos cargo-deps build run check test clippy coverage benchmark \ + deps deps-macos cargo-deps build run check test clippy coverage benchmark flamegraph\ compare_benchmarks_deps compare_benchmarks docs clean \ compare_trace_memory compare_trace compare_memory compare_pie compare_all_no_proof \ compare_trace_memory_proof compare_all_proof compare_trace_proof compare_memory_proof compare_air_public_input compare_air_private_input\ diff --git a/README.md b/README.md index 75a5bd79a6..c0061ae46d 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ It's Turing-complete and it was created by [Starkware](https://starkware.co/) as These are needed in order to compile and use the project. -- [Rust 1.70.0 or newer](https://www.rust-lang.org/tools/install) +- [Rust 1.74.1 or newer](https://www.rust-lang.org/tools/install) - Cargo #### Optional diff --git a/cairo1-run/src/cairo_run.rs b/cairo1-run/src/cairo_run.rs index 975d124fab..5dbda6c672 100644 --- a/cairo1-run/src/cairo_run.rs +++ b/cairo1-run/src/cairo_run.rs @@ -354,7 +354,9 @@ fn create_entry_code( let mut array_args_data = vec![]; let mut ap_offset: i16 = 0; for arg in args { - let FuncArg::Array(values) = arg else { continue }; + let FuncArg::Array(values) = arg else { + continue; + }; array_args_data.push(ap_offset); casm_extend! {ctx, %{ memory[ap + 0] = segments.add() %} diff --git a/rust-toolchain b/rust-toolchain index 2d24a1e077..4da0ec7b8e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.74.1" components = ["rustfmt", "clippy"] profile = "minimal" diff --git a/vm/src/hint_processor/builtin_hint_processor/find_element_hint.rs b/vm/src/hint_processor/builtin_hint_processor/find_element_hint.rs index 7837a7ea91..ea00247250 100644 --- a/vm/src/hint_processor/builtin_hint_processor/find_element_hint.rs +++ b/vm/src/hint_processor/builtin_hint_processor/find_element_hint.rs @@ -167,7 +167,7 @@ mod tests { vm.segments.add(); } - let addresses = vec![ + let addresses = [ Relocatable::from((1, 0)), Relocatable::from((1, 1)), Relocatable::from((1, 2)), diff --git a/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs b/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs index 577c467724..018338b0ad 100644 --- a/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs +++ b/vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs @@ -307,7 +307,7 @@ impl Cairo1HintProcessor { ) -> Result<(), HintError> { let a_val = res_operand_get_val(vm, a)?; let b_val = res_operand_get_val(vm, b)?; - let mut lengths_and_indices = vec![ + let mut lengths_and_indices = [ (a_val, 0), (b_val - a_val, 1), (Felt252::from(-1) - b_val, 2), diff --git a/vm/src/serde/deserialize_utils.rs b/vm/src/serde/deserialize_utils.rs index d66e48e1c7..7462a53cb6 100644 --- a/vm/src/serde/deserialize_utils.rs +++ b/vm/src/serde/deserialize_utils.rs @@ -233,7 +233,7 @@ fn take_until_unbalanced( .ok_or_else(|| Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil)))? .chars(); match it.next().unwrap_or_default() { - c if c == '\\' => { + '\\' => { // Skip the escape char `\`. index += '\\'.len_utf8(); // Skip also the following char. diff --git a/vm/src/tests/mod.rs b/vm/src/tests/mod.rs index e30a01214d..bb80958789 100644 --- a/vm/src/tests/mod.rs +++ b/vm/src/tests/mod.rs @@ -47,24 +47,24 @@ mod skip_instruction_test; //For simple programs that should just succeed and have no special needs. //Checks memory holes == 0 -pub(self) fn run_program_simple(data: &[u8]) { +fn run_program_simple(data: &[u8]) { run_program(data, Some("all_cairo"), None, None) } //For simple programs that should just succeed but using small layout. -pub(self) fn run_program_small(data: &[u8]) { +fn run_program_small(data: &[u8]) { run_program(data, Some("small"), None, None) } -pub(self) fn run_program_with_trace(data: &[u8], trace: &[(usize, usize, usize)]) { +fn run_program_with_trace(data: &[u8], trace: &[(usize, usize, usize)]) { run_program(data, Some("all_cairo"), Some(trace), None) } -pub(self) fn run_program_with_error(data: &[u8], error: &str) { +fn run_program_with_error(data: &[u8], error: &str) { run_program(data, Some("all_cairo"), None, Some(error)) } -pub(self) fn run_program( +fn run_program( data: &[u8], layout: Option<&str>, trace: Option<&[(usize, usize, usize)]>, @@ -101,7 +101,7 @@ pub(self) fn run_program( #[cfg(feature = "cairo-1-hints")] // Runs a contract entrypoint with given arguments and checks its return values // Doesn't use a syscall_handler -pub(self) fn run_cairo_1_entrypoint( +fn run_cairo_1_entrypoint( program_content: &[u8], entrypoint_offset: usize, args: &[MaybeRelocatable], @@ -207,7 +207,7 @@ pub(self) fn run_cairo_1_entrypoint( #[cfg(feature = "cairo-1-hints")] /// Equals to fn run_cairo_1_entrypoint /// But with run_resources as an input -pub(self) fn run_cairo_1_entrypoint_with_run_resources( +fn run_cairo_1_entrypoint_with_run_resources( contract_class: CasmContractClass, entrypoint_offset: usize, hint_processor: &mut Cairo1HintProcessor, diff --git a/vm/src/vm/runners/builtin_runner/bitwise.rs b/vm/src/vm/runners/builtin_runner/bitwise.rs index e83bad24f1..ca9e1e01cc 100644 --- a/vm/src/vm/runners/builtin_runner/bitwise.rs +++ b/vm/src/vm/runners/builtin_runner/bitwise.rs @@ -77,7 +77,8 @@ impl BitwiseBuiltinRunner { let x_addr = (address - index)?; let y_addr = (x_addr + 1_usize)?; - let (Ok(num_x), Ok(num_y)) = (memory.get_integer(x_addr), memory.get_integer(y_addr)) else { + let (Ok(num_x), Ok(num_y)) = (memory.get_integer(x_addr), memory.get_integer(y_addr)) + else { return Ok(None); }; diff --git a/vm/src/vm/runners/cairo_pie.rs b/vm/src/vm/runners/cairo_pie.rs index a768893d02..5e3aba9571 100644 --- a/vm/src/vm/runners/cairo_pie.rs +++ b/vm/src/vm/runners/cairo_pie.rs @@ -186,6 +186,7 @@ mod serde_impl { seq_serializer.end() } + #[allow(clippy::format_collect)] pub fn serialize_memory( values: &[((usize, usize), MaybeRelocatable)], serializer: S,