Skip to content

Commit

Permalink
lints and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
noel2004 committed Dec 5, 2023
1 parent 28fccb9 commit 4e98c60
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/constraint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<F: FromUniformBytes<64> + Ord> ConstraintBuilder<F> {
let mut lookup: Vec<_> = left
.into_iter()
.map(|q| q * condition.clone())
.zip(right.into_iter())
.zip(right)
.collect();
// If condition is true, every_row_selector must be enabled.
lookup.push((condition.into(), self.every_row_selector().into()));
Expand Down
2 changes: 1 addition & 1 deletion src/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl MptCircuitConfig {
meta: &mut VirtualCells<'_, F>,
) -> [Expression<F>; 8] {
std::iter::once(Query::from(self.selector.current()))
.chain(self.mpt_update.lookup().into_iter())
.chain(self.mpt_update.lookup())
.map(|q| q.run(meta))
.collect::<Vec<_>>()
.try_into()
Expand Down
20 changes: 10 additions & 10 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn verifying_key_constant() {
N_ROWS,
vec![(
MPTProofType::BalanceChanged,
serde_json::from_str(&include_str!(
serde_json::from_str(include_str!(
"traces/empty_account_type_1_balance_update.json"
))
.unwrap(),
Expand Down Expand Up @@ -164,8 +164,8 @@ fn empty_account_type_2() {
#[test]
fn empty_account_proofs_for_zero_value_updates() {
let traces: [SMTTrace; 2] = [
serde_json::from_str(&include_str!("traces/empty_account_type_1.json")).unwrap(),
serde_json::from_str(&include_str!("traces/empty_account_type_2.json")).unwrap(),
serde_json::from_str(include_str!("traces/empty_account_type_1.json")).unwrap(),
serde_json::from_str(include_str!("traces/empty_account_type_2.json")).unwrap(),
];
for trace in traces {
for proof_type in [
Expand Down Expand Up @@ -769,26 +769,26 @@ fn multiple_updates() {
let witness = vec![
(
MPTProofType::StorageChanged,
serde_json::from_str(&include_str!("traces/empty_storage_type_1_update_c.json"))
serde_json::from_str(include_str!("traces/empty_storage_type_1_update_c.json"))
.unwrap(),
),
(
MPTProofType::CodeHashExists,
serde_json::from_str(&include_str!(
serde_json::from_str(include_str!(
"traces/existing_account_keccak_codehash_update.json"
))
.unwrap(),
),
(
MPTProofType::BalanceChanged,
serde_json::from_str(&include_str!(
serde_json::from_str(include_str!(
"traces/empty_account_type_2_balance_update.json"
))
.unwrap(),
),
(
MPTProofType::AccountDoesNotExist,
serde_json::from_str(&include_str!("traces/empty_account_type_1.json")).unwrap(),
serde_json::from_str(include_str!("traces/empty_account_type_1.json")).unwrap(),
),
];
mock_prove(witness);
Expand Down Expand Up @@ -853,7 +853,7 @@ fn depth_1_type_1_storage() {
// because of an insertion or deletion.

let trace: SMTTrace =
serde_json::from_str(&include_str!("traces/depth_1_type_1_storage.json")).unwrap();
serde_json::from_str(include_str!("traces/depth_1_type_1_storage.json")).unwrap();
mock_prove(vec![(MPTProofType::StorageChanged, trace.clone())]);
mock_prove(vec![(MPTProofType::StorageChanged, reverse(trace))]);
}
Expand Down Expand Up @@ -1020,7 +1020,7 @@ fn create_name_registrator_per_txs_not_enough_gas_d0_g0_v0() {
// These mpt updates are by the test case at
// https://github.com/ethereum/tests/blob/747a4828f36c5fc8ab4f288d1cf4f1fe6662f3d6/src/GeneralStateTestsFiller/stCallCreateCallCodeTest/createNameRegistratorPerTxsNotEnoughGasFiller.json
mock_prove(
serde_json::from_str(&include_str!(
serde_json::from_str(include_str!(
"traces/createNameRegistratorPerTxsNotEnoughGas_d0_g0_v0.json"
))
.unwrap(),
Expand Down Expand Up @@ -1062,7 +1062,7 @@ fn test_n_rows_required() {
#[test]
fn verify_benchmark_trace() {
let witness: Vec<(MPTProofType, SMTTrace)> =
serde_json::from_str(&include_str!("../benches/traces.json")).unwrap();
serde_json::from_str(include_str!("../benches/traces.json")).unwrap();
let proofs: Vec<_> = witness.clone().into_iter().map(Proof::from).collect();

let n_rows_required = MptCircuitConfig::n_rows_required(&proofs);
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,12 @@ impl Proof {

assert_eq!(
self.old_account_hash_traces[5][2],
self.address_hash_traces.get(0).unwrap().2
self.address_hash_traces.first().unwrap().2
);

assert_eq!(
self.new_account_hash_traces[5][2],
self.address_hash_traces.get(0).unwrap().3
self.address_hash_traces.first().unwrap().3
);
if let Some(old_leaf) = self.leafs[0] {
assert_eq!(
Expand Down
12 changes: 6 additions & 6 deletions src/types/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,18 @@ impl TrieRows {
);
}
PathType::ExtensionOld => {
self.0
.get(i + 1)
.map(|row| assert_eq!(row.path_type, PathType::ExtensionOld));
if let Some(row) = self.0.get(i + 1) {
assert_eq!(row.path_type, PathType::ExtensionOld);
}
assert_eq!(
domain_hash(old_left, old_right, row.domain),
expected_old_hash
);
}
PathType::ExtensionNew => {
self.0
.get(i + 1)
.map(|row| assert_eq!(row.path_type, PathType::ExtensionNew));
if let Some(row) = self.0.get(i + 1) {
assert_eq!(row.path_type, PathType::ExtensionNew);
}
assert_eq!(
domain_hash(new_left, new_right, row.domain),
expected_new_hash
Expand Down

0 comments on commit 4e98c60

Please sign in to comment.