Skip to content

Commit ef0656a

Browse files
z2trillionMason Liang
andauthored
Remove disallow dead code and remove it (#103)
* deny warnings for clippy * don't allow dead code * fix clippy --------- Co-authored-by: Mason Liang <[email protected]>
1 parent 6232ff4 commit ef0656a

File tree

8 files changed

+6
-79
lines changed

8 files changed

+6
-79
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ fmt:
55
@cargo fmt
66

77
clippy:
8-
@cargo clippy --all-features
8+
@cargo clippy --all-features -- -D warnings

src/constraint_builder/query.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ use halo2_proofs::{
66
poly::Rotation,
77
};
88

9-
#[derive(Clone, Copy)]
10-
pub enum ColumnType {
11-
Advice,
12-
Fixed,
13-
Challenge,
14-
}
15-
169
#[derive(Clone)]
1710
pub enum Query<F: Clone> {
1811
Constant(F),

src/gadgets/byte_representation.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::{byte_bit::RangeCheck256Lookup, is_zero::IsZeroGadget, rlc_randomness
22
use crate::constraint_builder::{
33
AdviceColumn, ConstraintBuilder, Query, SecondPhaseAdviceColumn, SelectorColumn,
44
};
5-
use ethers_core::types::{Address, H256};
65
use halo2_proofs::{
76
arithmetic::FieldExt,
87
circuit::{Region, Value},
@@ -156,14 +155,6 @@ fn u128_to_big_endian(x: &u128) -> Vec<u8> {
156155
x.to_be_bytes().to_vec()
157156
}
158157

159-
fn address_to_big_endian(x: &Address) -> Vec<u8> {
160-
x.0.to_vec()
161-
}
162-
163-
fn h256_to_big_endian(x: &H256) -> Vec<u8> {
164-
x.0.to_vec()
165-
}
166-
167158
fn fr_to_big_endian(x: &Fr) -> Vec<u8> {
168159
let mut bytes = x.to_bytes();
169160
bytes.reverse();

src/gadgets/key_bit.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{
22
byte_bit::{ByteBitLookup, RangeCheck256Lookup, RangeCheck8Lookup},
33
canonical_representation::CanonicalRepresentationLookup,
44
};
5-
use crate::constraint_builder::{AdviceColumn, ConstraintBuilder, Query, SelectorColumn};
5+
use crate::constraint_builder::{AdviceColumn, ConstraintBuilder, Query};
66
use halo2_proofs::{
77
arithmetic::FieldExt, circuit::Region, halo2curves::bn256::Fr, plonk::ConstraintSystem,
88
};
@@ -13,8 +13,6 @@ pub trait KeyBitLookup {
1313

1414
#[derive(Clone)]
1515
pub struct KeyBitConfig {
16-
selector: SelectorColumn, // always enabled selector for constraints we want always enabled.
17-
1816
// Lookup columns
1917
value: AdviceColumn, // We're proving value.bit(i) = bit in this gadget
2018
index: AdviceColumn, // 0 <= index < 256
@@ -35,8 +33,7 @@ impl KeyBitConfig {
3533
range_check_256: &impl RangeCheck256Lookup,
3634
byte_bit: &impl ByteBitLookup,
3735
) -> Self {
38-
let ([selector], [], [value, index, bit, index_div_8, index_mod_8, byte]) =
39-
cb.build_columns(cs);
36+
let ([], [], [value, index, bit, index_div_8, index_mod_8, byte]) = cb.build_columns(cs);
4037

4138
cb.add_lookup(
4239
"0 <= index < 256",
@@ -76,7 +73,6 @@ impl KeyBitConfig {
7673
);
7774

7875
Self {
79-
selector,
8076
value,
8177
index,
8278
bit,
@@ -134,6 +130,7 @@ mod test {
134130
rlc_randomness::RlcRandomness,
135131
};
136132
use super::*;
133+
use crate::constraint_builder::SelectorColumn;
137134
use halo2_proofs::{
138135
circuit::{Layouter, SimpleFloorPlanner},
139136
dev::MockProver,

src/gadgets/mpt_update.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use ethers_core::types::Address;
3131
use halo2_proofs::{
3232
arithmetic::{Field, FieldExt},
3333
circuit::{Region, Value},
34-
halo2curves::{bn256::Fr, group::ff::PrimeField},
34+
halo2curves::bn256::Fr,
3535
plonk::ConstraintSystem,
3636
};
3737
use itertools::izip;
@@ -902,13 +902,6 @@ fn new_right<F: FieldExt>(config: &MptUpdateConfig) -> Query<F> {
902902
+ (Query::one() - config.direction.current()) * config.sibling.current()
903903
}
904904

905-
fn address_to_fr(a: Address) -> Fr {
906-
let mut bytes = [0u8; 32];
907-
bytes[32 - 20..].copy_from_slice(a.as_bytes());
908-
bytes.reverse();
909-
Fr::from_repr(bytes).unwrap()
910-
}
911-
912905
fn configure_segment_transitions<F: FieldExt>(
913906
cb: &mut ConstraintBuilder<F>,
914907
segment: &OneHot<SegmentType>,

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(dead_code)]
21
#![allow(clippy::too_many_arguments)]
32
#![deny(unsafe_code)]
43

src/types.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ pub struct Proof {
185185
pub struct EthAccount {
186186
pub nonce: u64,
187187
pub code_size: u64,
188-
poseidon_codehash: Fr,
189188
pub balance: Fr,
190189
pub keccak_codehash: U256,
191190
pub storage_root: Fr,
@@ -196,7 +195,6 @@ impl From<AccountData> for EthAccount {
196195
Self {
197196
nonce: account_data.nonce,
198197
code_size: account_data.code_size,
199-
poseidon_codehash: fr_from_biguint(&account_data.poseidon_code_hash),
200198
balance: fr_from_biguint(&account_data.balance),
201199
keccak_codehash: u256_from_biguint(&account_data.code_hash),
202200
storage_root: Fr::zero(), // TODO: fixmeeee!!!
@@ -957,39 +955,10 @@ fn check_hash_traces_new(traces: &[(bool, HashDomain, Fr, Fr, Fr, bool, bool)])
957955
}
958956
}
959957

960-
fn bits(x: usize, len: usize) -> Vec<bool> {
961-
let mut bits = vec![];
962-
let mut x = x;
963-
while x != 0 {
964-
bits.push(x % 2 == 1);
965-
x /= 2;
966-
}
967-
bits.resize(len, false);
968-
bits.reverse();
969-
bits
970-
}
971-
972958
fn fr(x: HexBytes<32>) -> Fr {
973959
Fr::from_bytes(&x.0).unwrap()
974960
}
975961

976-
fn split_word(x: U256) -> (Fr, Fr) {
977-
let mut bytes = [0; 32];
978-
x.to_big_endian(&mut bytes);
979-
let high_bytes: [u8; 16] = bytes[..16].try_into().unwrap();
980-
let low_bytes: [u8; 16] = bytes[16..].try_into().unwrap();
981-
982-
let high = Fr::from_u128(u128::from_be_bytes(high_bytes));
983-
let low = Fr::from_u128(u128::from_be_bytes(low_bytes));
984-
(high, low)
985-
986-
// TODO: what's wrong with this?
987-
// let [limb_0, limb_1, limb_2, limb_3] = key.0;
988-
// let key_high = Fr::from_u128(u128::from(limb_2) + u128::from(limb_3) << 64);
989-
// let key_low = Fr::from_u128(u128::from(limb_0) + u128::from(limb_1) << 64);
990-
// hash(key_high, key_low)
991-
}
992-
993962
fn big_uint_to_fr(i: &BigUint) -> Fr {
994963
i.to_u64_digits()
995964
.iter()

src/util.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{constraint_builder::Query, serde::HexBytes, types::HashDomain};
22
use ethers_core::types::{Address, U256};
33
use halo2_proofs::{
44
arithmetic::{Field, FieldExt},
5-
halo2curves::{bn256::Fr, group::ff::PrimeField},
5+
halo2curves::bn256::Fr,
66
};
77
use hash_circuit::hash::Hashable;
88
use num_bigint::BigUint;
@@ -50,15 +50,6 @@ pub(crate) fn split_word(x: U256) -> (Fr, Fr) {
5050
// hash(key_high, key_low)
5151
}
5252

53-
pub(crate) fn hi_lo(x: &BigUint) -> (Fr, Fr) {
54-
let mut u64_digits = x.to_u64_digits();
55-
u64_digits.resize(4, 0);
56-
(
57-
Fr::from_u128((u128::from(u64_digits[3]) << 64) + u128::from(u64_digits[2])),
58-
Fr::from_u128((u128::from(u64_digits[1]) << 64) + u128::from(u64_digits[0])),
59-
)
60-
}
61-
6253
pub(crate) fn u256_hi_lo(x: &U256) -> (u128, u128) {
6354
let u64_digits = x.0;
6455
(
@@ -86,12 +77,6 @@ pub fn u256_from_biguint(x: &BigUint) -> U256 {
8677
U256::from_big_endian(&x.to_bytes_be())
8778
}
8879

89-
pub fn u256_to_fr(x: U256) -> Fr {
90-
let mut bytes = [0u8; 32];
91-
x.to_little_endian(&mut bytes);
92-
Fr::from_repr(bytes).unwrap()
93-
}
94-
9580
pub fn u256_to_big_endian(x: &U256) -> Vec<u8> {
9681
let mut bytes = [0; 32];
9782
x.to_big_endian(&mut bytes);

0 commit comments

Comments
 (0)