Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix maintainability issues #67

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contract-tests/tests/spectre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async fn deploy_spectre_mock_verifiers<M: Middleware + 'static>(
U256::from(initial_sync_period),
initial_sync_committee_poseidon,
U256::from(slots_per_period),
U256::from(FINALITY_THRESHOLD)
U256::from(FINALITY_THRESHOLD),
),
)?
.send()
Expand Down
5 changes: 1 addition & 4 deletions eth-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions lightclient-circuits/src/gadget/crypto/sha256_flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -53,7 +55,7 @@ impl<'a, F: Field> HashInstructions<F> for Sha256Chip<'a, F> {
max_len: usize,
) -> Result<Vec<AssignedValue<F>>, 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;
Expand All @@ -72,7 +74,7 @@ impl<'a, F: Field> HashInstructions<F> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<F, ShaFlexGateManager<F>>,
spread_chip: &SpreadChip<'a, F>,
Expand Down
1 change: 0 additions & 1 deletion lightclient-circuits/src/gadget/crypto/sha256_flex/gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl<F: Field> VirtualRegionManager<F> for ShaFlexGateManager<F> {

/// 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<F: Field>(
threads_dense: &[Context<F>],
threads_spread: &[Context<F>],
Expand Down
1 change: 0 additions & 1 deletion lightclient-circuits/src/gadget/crypto/sha256_wide/gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub struct ShaBitGateManager<F: Field> {
/// Witnesses of a sha256 which are necessary to be loaded into halo2-lib.
#[derive(Clone, Copy, Debug, CopyGetters, Getters)]
pub struct LoadedSha256<F: Field> {

/// 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<F>,
Expand Down
5 changes: 0 additions & 5 deletions lightclient-circuits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion prover/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub struct BaseArgs {
}

#[derive(Clone, clap::Parser)]
#[allow(clippy::large_enum_variant)]
pub enum BaseCmd {
/// Deploy prover RPC server.
Rpc {
Expand Down
2 changes: 0 additions & 2 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion prover/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading