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

Commit 3fd8977

Browse files
authored
Fix finding 17 (#602)
* add q_last * fix
1 parent 1243ef4 commit 3fd8977

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

zkevm-circuits/src/rlp_circuit_fsm.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ impl RlpFsmRomTable {
223223
pub struct RlpCircuitConfig<F> {
224224
/// Whether the row is the first row.
225225
q_first: Column<Fixed>,
226+
/// Whether the row is the last row.
227+
q_last: Column<Fixed>,
226228
/// The state of RLP verifier at the current row.
227229
state: Column<Advice>,
228230
/// A utility gadget to compare/query what state we are at.
@@ -336,6 +338,7 @@ impl<F: Field> RlpCircuitConfig<F> {
336338
let q_enabled = rlp_table.q_enable;
337339
let (
338340
q_first,
341+
q_last,
339342
byte_idx,
340343
byte_rev_idx,
341344
byte_value,
@@ -354,6 +357,7 @@ impl<F: Field> RlpCircuitConfig<F> {
354357
transit_to_new_rlp_instance,
355358
is_same_rlp_instance,
356359
) = (
360+
meta.fixed_column(),
357361
meta.fixed_column(),
358362
meta.advice_column(),
359363
meta.advice_column(),
@@ -1429,8 +1433,17 @@ impl<F: Field> RlpCircuitConfig<F> {
14291433
]))
14301434
});
14311435

1436+
meta.create_gate("sm ends in End state", |meta| {
1437+
let mut cb = BaseConstraintBuilder::default();
1438+
1439+
constrain_eq!(meta, cb, state, State::End);
1440+
1441+
cb.gate(meta.query_fixed(q_last, Rotation::cur()))
1442+
});
1443+
14321444
Self {
14331445
q_first,
1446+
q_last,
14341447
state,
14351448
state_bits,
14361449
rlp_table,
@@ -1889,6 +1902,13 @@ impl<F: Field> RlpCircuitConfig<F> {
18891902
for i in sm_rows.len()..last_row {
18901903
self.assign_sm_end_row(&mut region, i)?;
18911904
}
1905+
region.assign_fixed(|| "q_first", self.q_first, 0, || Value::known(F::one()))?;
1906+
region.assign_fixed(
1907+
|| "q_last",
1908+
self.q_last,
1909+
last_row - 1,
1910+
|| Value::known(F::one()),
1911+
)?;
18921912

18931913
Ok(())
18941914
},

0 commit comments

Comments
 (0)