Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit fb836aa

Browse files
authored
clean some outdated feature flag (#437)
* clean some outdated feature flag * fmt * fix circuit degree
1 parent fe30847 commit fb836aa

File tree

8 files changed

+40
-106
lines changed

8 files changed

+40
-106
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ debug-assertions = false
2525
overflow-checks = false
2626
rpath = false
2727
lto = "thin"
28-
incremental = false
29-
codegen-units = 1
28+
incremental = true
3029

3130
[profile.release]
3231
opt-level = 3

rustfmt.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ comment_width = 100
44
imports_granularity = "Crate"
55
max_width = 100
66
newline_style = "Unix"
7-
normalize_comments = true
7+
#normalize_comments = true
88
reorder_imports = true
9-
wrap_comments = true
9+
wrap_comments = true

zkevm-circuits/Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ serde_json = "1.0.78"
5858

5959
[features]
6060
default = ["test", "test-circuits", "enable-sign-verify"]
61+
scroll = ["bus-mapping/scroll", "zktrie", "enable-sign-verify", "reject-eip2718", "poseidon-codehash"]
6162
test = ["ethers-signers", "mock"]
6263
test-circuits = []
6364
warn-unimplemented = ["eth-types/warn-unimplemented"]
64-
onephase = []
65+
onephase = [] # debug only
6566
zktrie = []
6667
enable-sign-verify = []
67-
codehash = []
6868
reject-eip2718 = []
6969
poseidon-codehash = []
70-
scroll = ["bus-mapping/scroll"]

zkevm-circuits/src/bytecode_circuit/circuit.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ impl<F: Field> SubCircuitConfig<F> for BytecodeCircuitConfig<F> {
378378
is_byte_to_header(meta),
379379
]))
380380
});
381-
#[cfg(feature = "codehash")]
382381
meta.lookup_any(
383382
"keccak256_table_lookup(cur.value_rlc, cur.length, cur.hash)",
384383
|meta| {
@@ -476,6 +475,9 @@ impl<F: Field> BytecodeCircuitConfig<F> {
476475
)?;
477476
return Ok(());
478477
}
478+
// annotate columns
479+
self.annotate_circuit(&mut region);
480+
479481
let mut offset = 0;
480482
for bytecode in witness.iter() {
481483
self.assign_bytecode(
@@ -577,21 +579,22 @@ impl<F: Field> BytecodeCircuitConfig<F> {
577579
length,
578580
F::from(push_data_size as u64),
579581
)?;
580-
581-
// trace!(
582-
// "bytecode.set_row({}): last:{} h:{:?} t:{:?} i:{:?} c:{:?} v:{:?} pdl:{} rlc:{:?}
583-
// l:{:?} pds:{:?}", offset,
584-
// offset == last_row_offset,
585-
// code_hash,
586-
// row.tag.get_lower_32(),
587-
// row.index.get_lower_32(),
588-
// row.is_code.get_lower_32(),
589-
// row.value.get_lower_32(),
590-
// push_data_left,
591-
// value_rlc,
592-
// length.get_lower_32(),
593-
// push_data_size
594-
// );
582+
/*
583+
trace!(
584+
"bytecode.set_row({}): last:{} h:{:?} t:{:?} i:{:?} c:{:?} v:{:?} pdl:{} rlc:{:?} l:{:?} pds:{:?}",
585+
offset,
586+
offset == last_row_offset,
587+
code_hash,
588+
row.tag.get_lower_32(),
589+
row.index.get_lower_32(),
590+
row.is_code.get_lower_32(),
591+
row.value.get_lower_32(),
592+
push_data_left,
593+
value_rlc,
594+
length.get_lower_32(),
595+
push_data_size
596+
);
597+
*/
595598

596599
*offset += 1;
597600
push_data_left = next_push_data_left
@@ -1040,7 +1043,6 @@ mod tests {
10401043
}
10411044

10421045
/// Test invalid code_hash data
1043-
#[cfg(feature = "codehash")]
10441046
#[test]
10451047
fn bytecode_invalid_hash_data() {
10461048
let k = 9;
@@ -1085,7 +1087,6 @@ mod tests {
10851087

10861088
/// Test invalid byte data
10871089
1088-
#[cfg(feature = "codehash")]
10891090
#[test]
10901091
fn bytecode_invalid_byte_data() {
10911092
let k = 9;

zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs

-5
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,14 @@ impl<F: Field, const BYTES_IN_FIELD: usize> ToHashBlockCircuitConfig<F, BYTES_IN
287287
// ]))
288288
// });
289289

290-
#[cfg(feature = "codehash")]
291290
let lookup_columns = [/* code_hash, */ field_input, control_length];
292-
#[cfg(feature = "codehash")]
293291
let pick_hash_tbl_cols = |inp_i: usize| {
294292
let cols =
295293
<PoseidonTable as crate::table::LookupTable<F>>::advice_columns(&poseidon_table);
296294
[/* cols[0], */ cols[inp_i + 1], cols[cols.len() - 2]]
297295
};
298296

299297
// we use a special selection exp for only 2 indexs
300-
#[cfg(feature = "codehash")]
301298
let field_selector = |meta: &mut VirtualCells<F>| {
302299
let field_index = meta.query_advice(field_index, Rotation::cur()) - 1.expr();
303300
[1.expr() - field_index.clone(), field_index]
@@ -308,7 +305,6 @@ impl<F: Field, const BYTES_IN_FIELD: usize> ToHashBlockCircuitConfig<F, BYTES_IN
308305
// * PoseidonTable::INPUT_WIDTH -1 lookups for the padded zero input
309306
// so we have 2*PoseidonTable::INPUT_WIDTH -1 lookups
310307

311-
#[cfg(feature = "codehash")]
312308
for i in 0..PoseidonTable::INPUT_WIDTH {
313309
meta.lookup_any("poseidon input", |meta| {
314310
// Conditions:
@@ -333,7 +329,6 @@ impl<F: Field, const BYTES_IN_FIELD: usize> ToHashBlockCircuitConfig<F, BYTES_IN
333329
}
334330

335331
// the canonical form should be `for i in 1..PoseidonTable::INPUT_WIDTH{...}`
336-
#[cfg(feature = "codehash")]
337332
meta.lookup_any("poseidon input padding zero for final", |meta| {
338333
// Conditions:
339334
// - On the row with the last byte (`is_byte_to_header == 1`)

zkevm-circuits/src/copy_circuit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ impl<F: Field> SubCircuitConfig<F> for CopyCircuitConfig<F> {
385385
});
386386

387387
// create case unimplemented for poseidon hash
388-
#[cfg(feature = "codehash")]
389388
meta.lookup_any("Bytecode lookup", |meta| {
390389
use crate::table::BytecodeFieldTag;
391390
let cond = meta.query_fixed(q_enable, Rotation::cur())

zkevm-circuits/src/state_circuit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,6 @@ fn queries<F: Field>(meta: &mut VirtualCells<'_, F>, c: &StateCircuitConfig<F>)
686686
+ final_bits_sum.clone() * (1.expr() - final_bits_sum),
687687
address: MpiQueries::new(meta, c.sort_keys.address),
688688
storage_key: RlcQueries::new(meta, c.sort_keys.storage_key),
689-
value_prev_col: meta.query_advice(c.rw_table.value_prev, Rotation::cur()),
690689
initial_value: meta.query_advice(c.initial_value, Rotation::cur()),
691690
initial_value_prev: meta.query_advice(c.initial_value, Rotation::prev()),
692691
is_non_exist: meta.query_advice(c.is_non_exist.is_zero, Rotation::cur()),

zkevm-circuits/src/state_circuit/constraint_builder.rs

+16-74
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ pub struct Queries<F: Field> {
5858
pub address: MpiQueries<F, N_LIMBS_ACCOUNT_ADDRESS>,
5959
pub storage_key: RlcQueries<F, N_BYTES_WORD>,
6060
pub initial_value: Expression<F>,
61-
pub value_prev_col: Expression<F>,
6261
pub initial_value_prev: Expression<F>,
6362
pub is_non_exist: Expression<F>,
6463
pub mpt_proof_type: Expression<F>,
@@ -159,12 +158,23 @@ impl<F: Field> ConstraintBuilder<F> {
159158
q.is_read() * (q.rw_table.value.clone() - q.initial_value()),
160159
);
161160
// FIXME
161+
// precompile should be warm
162162
// https://github.com/scroll-tech/zkevm-circuits/issues/343
163-
// cb.require_equal(
164-
// "value_prev column is initial_value for first access",
165-
// q.value_prev_column(),
166-
// q.initial_value.clone(),
167-
// );
163+
// If we decide to implement optional access list of tx later,
164+
// we need to revist this constraint.
165+
cb.condition(
166+
not::expr(
167+
q.tag_matches(RwTableTag::TxAccessListAccount)
168+
+ q.tag_matches(RwTableTag::TxAccessListAccountStorage),
169+
),
170+
|cb| {
171+
cb.require_equal(
172+
"value_prev column is initial_value for first access",
173+
q.value_prev_column(),
174+
q.initial_value.clone(),
175+
);
176+
},
177+
);
168178
});
169179

170180
// When all the keys in the current row and previous row are equal.
@@ -178,74 +188,6 @@ impl<F: Field> ConstraintBuilder<F> {
178188
q.initial_value.clone() - q.initial_value_prev(),
179189
);
180190
});
181-
182-
// Only reversible rws have `value_prev`.
183-
// There is no need to constain MemoryRw and StackRw since the 'read
184-
// consistency' part of the constaints are enough for them to behave
185-
// correctly.
186-
// For these 6 Rws whose `value_prev` need to be
187-
// constrained:
188-
// (1) `AccountStorage` and `Account`: they are related to storage
189-
// and they should be connected to MPT cricuit later to check the
190-
// `value_prev`.
191-
// (2)`TxAccessListAccount` and
192-
// `TxAccessListAccountStorage`: Default values of them should be
193-
// `false` indicating "not accessed yet".
194-
// (3) `AccountDestructed`: Since we probably
195-
// will not support this feature, it is skipped now.
196-
// (4) `TxRefund`: Default values should be '0'. BTW it may be moved out of rw table in the future. See https://github.com/privacy-scaling-explorations/zkevm-circuits/issues/395
197-
// for more details.
198-
199-
// FIXME: For RwTableTag::Account, this is a dummy placeholder to pass
200-
// constraints It should be aux2/committed_value.
201-
// We should fix this after the committed_value field of Rw::Account in
202-
// both bus-mapping and evm-circuits are implemented.
203-
// self.condition(q.first_access(), |cb| {
204-
// cb.require_equal(
205-
// "prev value when first access",
206-
// q.value_prev_col.clone(),
207-
// (q.tag_matches(RwTableTag::TxAccessListAccount)
208-
// + q.tag_matches(RwTableTag::TxAccessListAccountStorage)
209-
// + q.tag_matches(RwTableTag::AccountDestructed)
210-
// + q.tag_matches(RwTableTag::TxRefund))
211-
// 0u64.expr()
212-
// + q.tag_matches(RwTableTag::Account)
213-
// q.value_prev_col.clone()
214-
// + q.tag_matches(RwTableTag::AccountStorage)
215-
// q.aux2.clone(), // committed value
216-
// );
217-
// });
218-
// self.condition(q.not_first_access(), |cb| {
219-
// cb.require_equal(
220-
// "prev value when not first acccess",
221-
// q.value_prev_col.clone(),
222-
// (q.tag_matches(RwTableTag::TxAccessListAccount)
223-
// + q.tag_matches(RwTableTag::TxAccessListAccountStorage)
224-
// + q.tag_matches(RwTableTag::AccountDestructed)
225-
// + q.tag_matches(RwTableTag::TxRefund))
226-
// q.value_prev.clone()
227-
// + q.tag_matches(RwTableTag::Account) * q.value_prev_col.clone()
228-
// + q.tag_matches(RwTableTag::AccountStorage) * q.value_prev.clone(),
229-
// );
230-
// });
231-
// self.require_equal("rw table rlc", q.rw_rlc.clone(), {
232-
// rlc::expr(
233-
// &[
234-
// q.rw_counter.value.clone(),
235-
// q.is_write.clone(),
236-
// q.tag.clone(),
237-
// q.id.value.clone(),
238-
// q.address.value.clone(),
239-
// q.field_tag.clone(),
240-
// q.storage_key.encoded.clone(),
241-
// q.value.clone(),
242-
// q.value_prev_col.clone(),
243-
// 0u64.expr(), //q.aux1,
244-
// q.aux2.clone(),
245-
// ],
246-
// &q.power_of_randomness,
247-
// )
248-
// })
249191
}
250192

251193
fn build_start_constraints(&mut self, q: &Queries<F>) {

0 commit comments

Comments
 (0)