From d42808904d1dccc19d018898abf570f598e0cc14 Mon Sep 17 00:00:00 2001 From: timofey Date: Tue, 5 Mar 2024 14:32:12 +0100 Subject: [PATCH] Fix maintainability issues (#67) * refactor * cargo fmt --- contract-tests/tests/spectre.rs | 2 +- eth-types/src/lib.rs | 5 +---- lightclient-circuits/src/gadget/crypto/sha256_flex.rs | 6 ++++-- .../src/gadget/crypto/sha256_flex/compression.rs | 1 - lightclient-circuits/src/gadget/crypto/sha256_flex/gate.rs | 1 - lightclient-circuits/src/gadget/crypto/sha256_wide/gate.rs | 1 - lightclient-circuits/src/lib.rs | 5 ----- prover/Cargo.toml | 2 -- prover/src/args.rs | 1 - prover/src/lib.rs | 2 -- prover/src/main.rs | 1 - 11 files changed, 6 insertions(+), 21 deletions(-) diff --git a/contract-tests/tests/spectre.rs b/contract-tests/tests/spectre.rs index 48b2127..a4a316e 100644 --- a/contract-tests/tests/spectre.rs +++ b/contract-tests/tests/spectre.rs @@ -102,7 +102,7 @@ async fn deploy_spectre_mock_verifiers( U256::from(initial_sync_period), initial_sync_committee_poseidon, U256::from(slots_per_period), - U256::from(FINALITY_THRESHOLD) + U256::from(FINALITY_THRESHOLD), ), )? .send() diff --git a/eth-types/src/lib.rs b/eth-types/src/lib.rs index 518fc29..9edcfd6 100644 --- a/eth-types/src/lib.rs +++ b/eth-types/src/lib.rs @@ -2,11 +2,8 @@ // Code: https://github.com/ChainSafe/Spectre // SPDX-License-Identifier: LGPL-3.0-only -#![allow(incomplete_features)] -#![feature(associated_type_bounds)] -#![feature(associated_type_defaults)] -#![feature(generic_const_exprs)] #![feature(trait_alias)] + mod spec; use halo2_base::utils::BigPrimeField; use halo2curves::ff::PrimeField; diff --git a/lightclient-circuits/src/gadget/crypto/sha256_flex.rs b/lightclient-circuits/src/gadget/crypto/sha256_flex.rs index c33b850..ff720ac 100644 --- a/lightclient-circuits/src/gadget/crypto/sha256_flex.rs +++ b/lightclient-circuits/src/gadget/crypto/sha256_flex.rs @@ -31,6 +31,8 @@ pub use self::spread::SpreadChip; use super::{HashInstructions, ShaCircuitBuilder}; +const SHA256_INPUT_LEN_PADDING_LEN: usize = 9; + /// [`Sha256Chip`] provides functions to compute SHA256 hash [`SpreadConfig`] gates. /// This is version of SHA256 chip is flexible by allowing do distribute advice cells into multiple sets of columns (`dense`, `spread`). /// It also heavily benefits from lookup tables (bigger `num_bits_lookup` is better). @@ -53,7 +55,7 @@ impl<'a, F: Field> HashInstructions for Sha256Chip<'a, F> { max_len: usize, ) -> Result>, Error> { let max_processed_bytes = { - let mut max_bytes = max_len + 9; + let mut max_bytes = max_len + SHA256_INPUT_LEN_PADDING_LEN; let remainder = max_bytes % 64; if remainder != 0 { max_bytes += 64 - remainder; @@ -72,7 +74,7 @@ impl<'a, F: Field> HashInstructions for Sha256Chip<'a, F> { .collect_vec(); let input_byte_size = assigned_input_bytes.len(); - let input_byte_size_with_9 = input_byte_size + 9; + let input_byte_size_with_9 = input_byte_size + SHA256_INPUT_LEN_PADDING_LEN; let range = self.spread.range(); let gate = &range.gate; diff --git a/lightclient-circuits/src/gadget/crypto/sha256_flex/compression.rs b/lightclient-circuits/src/gadget/crypto/sha256_flex/compression.rs index da9288a..808e740 100644 --- a/lightclient-circuits/src/gadget/crypto/sha256_flex/compression.rs +++ b/lightclient-circuits/src/gadget/crypto/sha256_flex/compression.rs @@ -558,7 +558,6 @@ fn sigma_lower1<'a, 'b: 'a, F: Field>( ) } -#[allow(clippy::too_many_arguments)] fn sigma_generic<'a, 'b: 'a, F: Field>( thread_pool: &mut ShaCircuitBuilder>, spread_chip: &SpreadChip<'a, F>, diff --git a/lightclient-circuits/src/gadget/crypto/sha256_flex/gate.rs b/lightclient-circuits/src/gadget/crypto/sha256_flex/gate.rs index a8248ad..a2ba470 100644 --- a/lightclient-circuits/src/gadget/crypto/sha256_flex/gate.rs +++ b/lightclient-circuits/src/gadget/crypto/sha256_flex/gate.rs @@ -145,7 +145,6 @@ impl VirtualRegionManager for ShaFlexGateManager { /// Pure advice witness assignment in a single phase. Uses preprocessed `break_points` to determine when /// to split a thread into a new column. -#[allow(clippy::type_complexity)] pub fn assign_threads_sha( threads_dense: &[Context], threads_spread: &[Context], diff --git a/lightclient-circuits/src/gadget/crypto/sha256_wide/gate.rs b/lightclient-circuits/src/gadget/crypto/sha256_wide/gate.rs index 5a39849..4ea3dbe 100644 --- a/lightclient-circuits/src/gadget/crypto/sha256_wide/gate.rs +++ b/lightclient-circuits/src/gadget/crypto/sha256_wide/gate.rs @@ -46,7 +46,6 @@ pub struct ShaBitGateManager { /// Witnesses of a sha256 which are necessary to be loaded into halo2-lib. #[derive(Clone, Copy, Debug, CopyGetters, Getters)] pub struct LoadedSha256 { - /// The output of this sha256. is_final/hash_lo/hash_hi come from the first row of the last round(NUM_ROUNDS). #[getset(get_copy = "pub")] pub is_final: AssignedValue, diff --git a/lightclient-circuits/src/lib.rs b/lightclient-circuits/src/lib.rs index b6e8d2e..e5e1364 100644 --- a/lightclient-circuits/src/lib.rs +++ b/lightclient-circuits/src/lib.rs @@ -3,12 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #![allow(incomplete_features)] -#![feature(int_roundings)] -#![feature(associated_type_bounds)] #![feature(generic_const_exprs)] -#![feature(stmt_expr_attributes)] -#![feature(trait_alias)] -#![feature(generic_arg_infer)] #![allow(clippy::needless_range_loop)] pub mod gadget; diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 798de0c..da8a49b 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -13,7 +13,6 @@ clap = { version = "4.2", features = ["derive"] } strum = { version = "=0.25", features = ["derive"] } hex = "0.4" eyre = "0.6" -anstyle = "1.0.0" axum = { version = "0.7", features = ["tracing", "tower-log"] } tokio = { version = "1.32", features = ["macros"] } jsonrpc-v2 = { version = "0.13", default-features = false, features = ["easy-errors", "macros", "bytes-v10", "hyper-integration"] } @@ -50,7 +49,6 @@ primitive-types = "0.12.2" reqwest = "0.11.22" beacon-api-client.workspace = true ethereum-consensus-types.workspace = true -futures = "0.3.29" ssz_rs.workspace = true [features] diff --git a/prover/src/args.rs b/prover/src/args.rs index 60bc1c6..daeda77 100644 --- a/prover/src/args.rs +++ b/prover/src/args.rs @@ -30,7 +30,6 @@ pub struct BaseArgs { } #[derive(Clone, clap::Parser)] -#[allow(clippy::large_enum_variant)] pub enum BaseCmd { /// Deploy prover RPC server. Rpc { diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 2fcf6f3..0cdf66a 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -2,8 +2,6 @@ // Code: https://github.com/ChainSafe/Spectre // SPDX-License-Identifier: LGPL-3.0-only -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] pub mod prover; pub mod rpc_api; diff --git a/prover/src/main.rs b/prover/src/main.rs index 2b09e4b..7365484 100644 --- a/prover/src/main.rs +++ b/prover/src/main.rs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: LGPL-3.0-only #![allow(incomplete_features)] -#![feature(associated_type_bounds)] #![feature(generic_const_exprs)] mod cli; mod rpc;