Skip to content

Commit 9787e88

Browse files
committed
make clippy happy
1 parent 193f529 commit 9787e88

File tree

2 files changed

+30
-35
lines changed

2 files changed

+30
-35
lines changed

src/gadgets/lookup.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::collections::BTreeMap;
44

55
use bellpepper::gadgets::Assignment;
66
use bellpepper_core::{num::AllocatedNum, ConstraintSystem, LinearCombination, SynthesisError};
7+
use std::cmp::Ord;
78

89
use crate::constants::NUM_CHALLENGE_BITS;
910
use crate::gadgets::nonnative::util::Num;
@@ -27,7 +28,7 @@ pub enum RWTrace<T> {
2728
}
2829

2930
/// Lookup in R1CS
30-
#[derive(Clone, Debug, PartialEq)]
31+
#[derive(Clone, Debug, Eq, PartialEq)]
3132
pub enum TableType {
3233
/// read only
3334
ReadOnly,
@@ -55,7 +56,7 @@ impl<'a, G: Group> LookupTransactionSimulate<'a, G> {
5556
/// read value from table
5657
pub fn read(&mut self, addr: G::Base) -> G::Base
5758
where
58-
<G as Group>::Base: std::cmp::Ord,
59+
<G as Group>::Base: Ord,
5960
{
6061
let key = &addr;
6162
let (value, _) = self.map_aux.entry(*key).or_insert_with(|| {
@@ -72,7 +73,7 @@ impl<'a, G: Group> LookupTransactionSimulate<'a, G> {
7273
/// write value to lookup table
7374
pub fn write(&mut self, addr: G::Base, value: G::Base)
7475
where
75-
<G as Group>::Base: std::cmp::Ord,
76+
<G as Group>::Base: Ord,
7677
{
7778
let _ = self.map_aux.insert(
7879
addr,
@@ -86,7 +87,7 @@ impl<'a, G: Group> LookupTransactionSimulate<'a, G> {
8687
/// commit rw_trace to lookup
8788
pub fn commit(&mut self, ro_consts: ROConstants<G>, prev_intermediate_gamma: G::Base) -> G::Base
8889
where
89-
<G as Group>::Base: std::cmp::Ord,
90+
<G as Group>::Base: Ord,
9091
{
9192
let mut hasher = <G as Group>::RO::new(ro_consts, 1 + self.rw_trace.len() * 3);
9293
hasher.absorb(prev_intermediate_gamma);
@@ -129,7 +130,7 @@ impl<'a, G: Group> LookupTransaction<'a, G> {
129130
addr: &AllocatedNum<G::Base>,
130131
) -> Result<AllocatedNum<G::Base>, SynthesisError>
131132
where
132-
<G as Group>::Base: std::cmp::Ord,
133+
<G as Group>::Base: Ord,
133134
{
134135
let key = &addr.get_value().unwrap_or_default();
135136
let (value, _) = self.map_aux.entry(*key).or_insert_with(|| {
@@ -155,7 +156,7 @@ impl<'a, G: Group> LookupTransaction<'a, G> {
155156
value: &AllocatedNum<G::Base>,
156157
) -> Result<(), SynthesisError>
157158
where
158-
<G as Group>::Base: std::cmp::Ord,
159+
<G as Group>::Base: Ord,
159160
{
160161
let _ = self.map_aux.insert(
161162
addr.get_value().unwrap_or_default(),
@@ -191,7 +192,7 @@ impl<'a, G: Group> LookupTransaction<'a, G> {
191192
SynthesisError,
192193
>
193194
where
194-
<G as Group>::Base: std::cmp::Ord,
195+
<G as Group>::Base: Ord,
195196
{
196197
let mut ro = G::ROCircuit::new(
197198
ro_const,
@@ -276,7 +277,7 @@ impl<F: PrimeField> Lookup<F> {
276277
initial_table: Vec<(F, F)>,
277278
) -> Lookup<F>
278279
where
279-
F: std::cmp::Ord,
280+
F: Ord,
280281
{
281282
let max_cap_rwcounter_log2 = max_cap_rwcounter.log_2();
282283
Self {
@@ -293,7 +294,7 @@ impl<F: PrimeField> Lookup<F> {
293294

294295
fn rw_operation(&mut self, is_read: bool, addr: F, external_value: F) -> (F, F)
295296
where
296-
F: std::cmp::Ord,
297+
F: Ord,
297298
{
298299
// write operations
299300
if !is_read {
@@ -344,7 +345,7 @@ impl<F: PrimeField> Lookup<F> {
344345
SynthesisError,
345346
>
346347
where
347-
F: std::cmp::Ord,
348+
F: Ord,
348349
{
349350
// extract challenge
350351
// get content from map
@@ -556,7 +557,7 @@ pub fn less_than<F: PrimeField + PartialOrd, CS: ConstraintSystem<F>>(
556557
let lt = AllocatedNum::alloc(cs.namespace(|| "lt"), || {
557558
a.get_value()
558559
.zip(b.get_value())
559-
.map(|(a, b)| F::from((a < b) as u64))
560+
.map(|(a, b)| F::from(u64::from(a < b)))
560561
.ok_or(SynthesisError::AssignmentMissing)
561562
})?;
562563
cs.enforce(

src/lib.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,10 @@ mod tests {
15291529
z0_secondary.clone(),
15301530
);
15311531

1532-
for mut circuit_primary in roots.iter_mut().take(num_steps) {
1532+
for circuit_primary in roots.iter_mut().take(num_steps) {
15331533
let res = recursive_snark.prove_step(
15341534
&pp,
1535-
&mut circuit_primary,
1535+
circuit_primary,
15361536
&mut circuit_secondary.clone(),
15371537
z0_primary.clone(),
15381538
z0_secondary.clone(),
@@ -1636,12 +1636,11 @@ mod tests {
16361636
test_ivc_base_with::<secp256k1::Point, secq256k1::Point>();
16371637
}
16381638

1639-
fn print_constraints_name_on_error_index<G1, G2, C1, C2>(err: &NovaError, mut c_primary: C1)
1639+
fn print_constraints_name_on_error_index<G1, G2, C1>(err: &NovaError, mut c_primary: C1)
16401640
where
16411641
G1: Group<Base = <G2 as Group>::Scalar>,
16421642
G2: Group<Base = <G1 as Group>::Scalar>,
16431643
C1: StepCircuit<G1::Scalar>,
1644-
C2: StepCircuit<G2::Scalar>,
16451644
{
16461645
match err {
16471646
NovaError::UnSatIndex(index) => {
@@ -1654,7 +1653,7 @@ mod tests {
16541653
&augmented_circuit_params_primary,
16551654
None,
16561655
&mut c_primary,
1657-
ro_consts_circuit_primary.clone(),
1656+
ro_consts_circuit_primary,
16581657
);
16591658
// let mut cs: ShapeCS<G1> = ShapeCS::new();
16601659
// let _ = circuit_primary.synthesize(&mut cs);
@@ -1683,7 +1682,7 @@ mod tests {
16831682

16841683
impl<G: Group> HeapifyCircuit<G>
16851684
where
1686-
<G as traits::Group>::Base: std::cmp::Ord,
1685+
<G as Group>::Base: Ord,
16871686
{
16881687
fn new(heap_size: usize, ro_consts: ROConstantsCircuit<G>) -> (Self, Vec<G::Base>) {
16891688
let n = heap_size; // assume complement binary tree
@@ -1706,11 +1705,8 @@ mod tests {
17061705
);
17071706

17081707
// TODO challenge should include final table (final table values + counters) commitment
1709-
let gamma = Self::pre_compute_global_challenge(
1710-
initial_intermediate_gamma,
1711-
((n - 4) / 2) as usize,
1712-
&lookup,
1713-
);
1708+
let gamma =
1709+
Self::pre_compute_global_challenge(initial_intermediate_gamma, (n - 4) / 2, &lookup);
17141710

17151711
(
17161712
HeapifyCircuit { lookup, ro_consts },
@@ -1739,7 +1735,7 @@ mod tests {
17391735
let num_steps = initial_index;
17401736
let mut intermediate_gamma = initial_intermediate_gamma;
17411737
// simulate folding step lookup io
1742-
for i in (0..num_steps + 1).into_iter() {
1738+
for i in 0..num_steps + 1 {
17431739
let mut lookup_transaction =
17441740
LookupTransactionSimulate::<G>::start_transaction(&mut lookup);
17451741
let addr = G::Base::from((num_steps - i) as u64);
@@ -1759,9 +1755,9 @@ mod tests {
17591755
}
17601756
}
17611757

1762-
impl<F: PrimeField, G: Group + traits::Group<Base = F>> StepCircuit<F> for HeapifyCircuit<G>
1758+
impl<F: PrimeField, G: Group + Group<Base = F>> StepCircuit<F> for HeapifyCircuit<G>
17631759
where
1764-
G::Base: std::cmp::Ord,
1760+
G::Base: Ord,
17651761
{
17661762
fn arity(&self) -> usize {
17671763
6
@@ -1804,7 +1800,7 @@ mod tests {
18041800
|lc| lc + CS::one(),
18051801
|lc| lc + right_child_index.get_variable(),
18061802
);
1807-
let parent = lookup_transaction.read(cs.namespace(|| "parent"), &index)?;
1803+
let parent = lookup_transaction.read(cs.namespace(|| "parent"), index)?;
18081804
let left_child =
18091805
lookup_transaction.read(cs.namespace(|| "left_child"), &left_child_index)?;
18101806
let right_child =
@@ -1838,15 +1834,15 @@ mod tests {
18381834
&is_right_child_smaller,
18391835
)?;
18401836

1841-
lookup_transaction.write(&index, &smallest)?;
1837+
lookup_transaction.write(index, &smallest)?;
18421838

18431839
// commit the rw change
18441840
let (next_R, next_W, next_rw_counter, next_intermediate_gamma) = lookup_transaction
18451841
.commit(
18461842
cs.namespace(|| "commit"),
18471843
self.ro_consts.clone(),
18481844
prev_intermediate_gamma,
1849-
&gamma,
1845+
gamma,
18501846
prev_W,
18511847
prev_R,
18521848
prev_rw_counter,
@@ -1914,7 +1910,7 @@ mod tests {
19141910
z0_secondary.clone(),
19151911
);
19161912

1917-
for i in (0..num_steps).into_iter() {
1913+
for i in 0..num_steps {
19181914
println!("step i {}", i);
19191915
let res = recursive_snark.prove_step(
19201916
&pp,
@@ -1934,12 +1930,10 @@ mod tests {
19341930
res
19351931
.clone()
19361932
.map_err(|err| {
1937-
print_constraints_name_on_error_index::<
1938-
G1,
1939-
G2,
1940-
HeapifyCircuit<G2>,
1941-
TrivialTestCircuit<<G2 as Group>::Scalar>,
1942-
>(&err, circuit_primary.clone())
1933+
print_constraints_name_on_error_index::<G1, G2, HeapifyCircuit<G2>>(
1934+
&err,
1935+
circuit_primary.clone(),
1936+
)
19431937
})
19441938
.unwrap();
19451939
assert!(res.is_ok());

0 commit comments

Comments
 (0)