Skip to content

Commit e927567

Browse files
fix lint errors
1 parent 00b71ea commit e927567

File tree

14 files changed

+33
-31
lines changed

14 files changed

+33
-31
lines changed

crates/circuits/sha-air/src/tests.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::{Sha384Config, ShaDigestColsRefMut, ShaRoundColsRef, ShaRoundColsRefMut};
21
use std::{borrow::BorrowMut, cmp::max, sync::Arc};
32

43
use openvm_circuit::arch::{
@@ -22,7 +21,10 @@ use openvm_stark_backend::{
2221
use openvm_stark_sdk::utils::create_seeded_rng;
2322
use rand::Rng;
2423

25-
use crate::{compose, small_sig0_field, Sha256Config, Sha2Air, Sha512Config, ShaConfig};
24+
use crate::{
25+
compose, small_sig0_field, Sha256Config, Sha2Air, Sha384Config, Sha512Config, ShaConfig,
26+
ShaDigestColsRefMut, ShaRoundColsRef, ShaRoundColsRefMut,
27+
};
2628

2729
// A wrapper AIR purely for testing purposes
2830
#[derive(Clone, Debug)]

crates/circuits/sha-macros/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ syn = { version = "2.0", features = ["full", "extra-traits"] }
1111
quote = "1.0"
1212
itertools = "0.14"
1313
proc-macro2 = "1.0"
14-
ndarray = "0.16"
1514

1615
[dev-dependencies]
1716
openvm-sha-air = { workspace = true }
@@ -20,3 +19,6 @@ ndarray.workspace = true
2019

2120
[lib]
2221
proc-macro = true
22+
23+
[package.metadata.cargo-shear]
24+
ignored = ["ndarray"]

crates/circuits/sha-macros/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ pub fn cols_ref(input: TokenStream) -> TokenStream {
2525

2626
let span = derive_input.ident.span();
2727
let res = cols_ref_impl(derive_input, config);
28-
if res.is_err() {
29-
syn::Error::new(span, res.err().unwrap().to_string())
30-
.to_compile_error()
31-
.into()
32-
} else {
33-
res.unwrap().into()
34-
}
28+
res.map_or_else(
29+
|err| {
30+
syn::Error::new(span, err.to_string())
31+
.to_compile_error()
32+
.into()
33+
},
34+
|ok| ok.into(),
35+
)
3536
}
3637

3738
fn cols_ref_impl(

crates/circuits/sha-macros/tests/aligned_borrow.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use openvm_sha_macros::ColsRef;
44
mod test_config;
55
use test_config::{TestConfig, TestConfigImpl};
66

7+
#[allow(dead_code)]
78
#[derive(ColsRef)]
89
#[config(TestConfig)]
910
struct TestCols<T, const N: usize> {
@@ -47,7 +48,7 @@ fn plain_from_mut() {
4748
test.a[0] = 1;
4849
test.b.a = 1;
4950
test.b.b[0] = 1;
50-
let test2: TestColsRef<u32> = TestColsRef::from_mut::<TestConfigImpl>(&mut test);
51+
let test2: TestColsRef<u32> = TestColsRef::from_mut::<TestConfigImpl>(&test);
5152
println!("{}", test2.a);
5253
println!("{:?}", test2.b);
5354
}

crates/circuits/sha-macros/tests/arrays.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use openvm_sha_macros::ColsRef;
33
mod test_config;
44
use test_config::{TestConfig, TestConfigImpl};
55

6+
#[allow(dead_code)]
67
#[derive(ColsRef)]
78
#[config(TestConfig)]
89
struct ArrayTest<T, const N: usize> {

crates/circuits/sha-macros/tests/const-len-arrays.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const THREE: usize = 3;
77
mod test_config;
88
use test_config::{TestConfig, TestConfigImpl};
99

10+
#[allow(dead_code)]
1011
#[derive(ColsRef)]
1112
#[config(TestConfig)]
1213
struct ConstLenArrayTest<T, const N: usize> {
@@ -18,7 +19,7 @@ struct ConstLenArrayTest<T, const N: usize> {
1819

1920
#[test]
2021
fn const_len_arrays() {
21-
let input = [1; 1 + TestConfigImpl::N * 2 + 1 * 2 * 3];
22+
let input = [1; 1 + TestConfigImpl::N * 2 + 2 * 3];
2223
let test: ConstLenArrayTestRef<u32> = ConstLenArrayTestRef::from::<TestConfigImpl>(&input);
2324
println!("{}", test.a);
2425
println!("{}", test.b);

crates/circuits/sha-macros/tests/nested.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
use openvm_sha_air::{Sha256Config, ShaConfig};
22
use openvm_sha_macros::ColsRef;
33

4+
#[allow(dead_code)]
45
#[derive(ColsRef)]
56
#[config(ShaConfig)]
67
struct Test1Cols<T, const WORD_BITS: usize> {
78
pub a: T,
89
pub nested: Test2Cols<T, WORD_BITS>,
910
}
1011

12+
#[allow(dead_code)]
1113
#[derive(ColsRef)]
1214
#[config(ShaConfig)]
1315
struct Test2Cols<T, const WORD_BITS: usize> {
@@ -34,8 +36,8 @@ fn nested_mut() {
3436
#[test]
3537
fn nested_from_mut() {
3638
let mut mut_input = [0; 1 + 1 + 32];
37-
let mut mut_test: Test1ColsRefMut<u32> = Test1ColsRefMut::from::<Sha256Config>(&mut mut_input);
38-
let const_test: Test1ColsRef<u32> = Test1ColsRef::from_mut::<Sha256Config>(&mut mut_test);
39+
let mut_test: Test1ColsRefMut<u32> = Test1ColsRefMut::from::<Sha256Config>(&mut mut_input);
40+
let const_test: Test1ColsRef<u32> = Test1ColsRef::from_mut::<Sha256Config>(&mut_test);
3941
println!(
4042
"{}, {}, {}",
4143
const_test.a, const_test.nested.b, const_test.nested.c

crates/circuits/sha-macros/tests/simple.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use openvm_sha_air::{Sha256Config, ShaConfig};
22
use openvm_sha_macros::ColsRef;
33

4+
#[allow(dead_code)]
45
#[derive(ColsRef)]
56
#[config(ShaConfig)]
67
struct Test<T, const WORD_BITS: usize, const ROUNDS_PER_ROW: usize, const WORD_U16S: usize> {

extensions/sha256/circuit/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ derive_more = { workspace = true, features = ["from"] }
2323
rand.workspace = true
2424
serde.workspace = true
2525
sha2 = { version = "0.10", default-features = false }
26-
strum = { workspace = true }
27-
ndarray.workspace = true
26+
ndarray = { workspace = true, default-features = false }
2827

2928
[dev-dependencies]
3029
openvm-stark-sdk = { workspace = true }
@@ -39,3 +38,6 @@ mimalloc = ["openvm-circuit/mimalloc"]
3938
jemalloc = ["openvm-circuit/jemalloc"]
4039
jemalloc-prof = ["openvm-circuit/jemalloc-prof"]
4140
nightly-features = ["openvm-circuit/nightly-features"]
41+
42+
[package.metadata.cargo-shear]
43+
ignored = ["ndarray"]

extensions/sha256/circuit/src/extension.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ impl<F: PrimeField32> VmExtension<F> for Sha2 {
8888
builder.system_config().memory_config.pointer_max_bits,
8989
bitwise_lu_chip.clone(),
9090
builder.new_bus_idx(),
91-
Rv32Sha2Opcode::CLASS_OFFSET,
9291
builder.system_base().offline_memory(),
9392
);
9493
inventory.add_executor(sha256_chip, vec![Rv32Sha2Opcode::SHA256.global_opcode()])?;
@@ -98,7 +97,6 @@ impl<F: PrimeField32> VmExtension<F> for Sha2 {
9897
builder.system_config().memory_config.pointer_max_bits,
9998
bitwise_lu_chip.clone(),
10099
builder.new_bus_idx(),
101-
Rv32Sha2Opcode::CLASS_OFFSET,
102100
builder.system_base().offline_memory(),
103101
);
104102
inventory.add_executor(sha512_chip, vec![Rv32Sha2Opcode::SHA512.global_opcode()])?;
@@ -108,7 +106,6 @@ impl<F: PrimeField32> VmExtension<F> for Sha2 {
108106
builder.system_config().memory_config.pointer_max_bits,
109107
bitwise_lu_chip,
110108
builder.new_bus_idx(),
111-
Rv32Sha2Opcode::CLASS_OFFSET,
112109
builder.system_base().offline_memory(),
113110
);
114111
inventory.add_executor(sha384_chip, vec![Rv32Sha2Opcode::SHA384.global_opcode()])?;

extensions/sha256/circuit/src/sha256_chip/air.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use std::cmp::min;
2-
use std::convert::TryInto;
1+
use std::{cmp::min, convert::TryInto};
32

43
use openvm_circuit::{
54
arch::ExecutionBridge,

extensions/sha256/circuit/src/sha256_chip/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub struct Sha2VmChip<F: PrimeField32, C: ShaChipConfig> {
4141
pub records: Vec<Sha2Record<F>>,
4242
pub offline_memory: Arc<Mutex<OfflineMemory<F>>>,
4343
pub bitwise_lookup_chip: SharedBitwiseOperationLookupChip<8>,
44-
offset: usize,
4544
}
4645

4746
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
@@ -65,7 +64,6 @@ impl<F: PrimeField32, C: ShaChipConfig> Sha2VmChip<F, C> {
6564
address_bits: usize,
6665
bitwise_lookup_chip: SharedBitwiseOperationLookupChip<8>,
6766
self_bus_idx: BusIndex,
68-
offset: usize,
6967
offline_memory: Arc<Mutex<OfflineMemory<F>>>,
7068
) -> Self {
7169
Self {
@@ -79,7 +77,6 @@ impl<F: PrimeField32, C: ShaChipConfig> Sha2VmChip<F, C> {
7977
),
8078
bitwise_lookup_chip,
8179
records: Vec::new(),
82-
offset,
8380
offline_memory,
8481
}
8582
}

extensions/sha256/circuit/src/sha256_chip/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ fn rand_sha_test<C: ShaChipConfig + 'static>(opcode: Rv32Sha2Opcode) {
9999
tester.address_bits(),
100100
bitwise_chip.clone(),
101101
BUS_IDX,
102-
Rv32Sha2Opcode::CLASS_OFFSET,
103102
tester.offline_memory_mutex_arc(),
104103
);
105104

@@ -146,7 +145,6 @@ fn execute_roundtrip_sanity_test<C: ShaChipConfig>(opcode: Rv32Sha2Opcode) {
146145
tester.address_bits(),
147146
bitwise_chip.clone(),
148147
BUS_IDX,
149-
Rv32Sha2Opcode::CLASS_OFFSET,
150148
tester.offline_memory_mutex_arc(),
151149
);
152150

extensions/sha256/circuit/src/sha256_chip/trace.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ where
316316
debug_assert_eq!(digest_writes.len(), 2);
317317
debug_assert_eq!(cols.writes_aux_base.len(), 2);
318318
debug_assert_eq!(cols.writes_aux_prev_data.nrows(), 2);
319-
for i in 0..C::NUM_WRITES {
319+
for (i, digest_write) in digest_writes.iter().enumerate() {
320320
let prev_data =
321321
cols.writes_aux_prev_data.row(i).to_vec();
322322
// write to a temporary MemoryWriteAuxCols object and then copy it over to the columns struct
@@ -327,10 +327,8 @@ where
327327
cols.writes_aux_base[i],
328328
prev_data.try_into().unwrap(),
329329
);
330-
memory_aux_cols_factory.generate_write_aux(
331-
digest_writes[i],
332-
&mut writes_aux,
333-
);
330+
memory_aux_cols_factory
331+
.generate_write_aux(digest_write, &mut writes_aux);
334332
cols.writes_aux_base[i] = writes_aux.get_base();
335333
cols.writes_aux_prev_data
336334
.row_mut(i)

0 commit comments

Comments
 (0)