@@ -223,6 +223,8 @@ impl RlpFsmRomTable {
223
223
pub struct RlpCircuitConfig < F > {
224
224
/// Whether the row is the first row.
225
225
q_first : Column < Fixed > ,
226
+ /// Whether the row is the last row.
227
+ q_last : Column < Fixed > ,
226
228
/// The state of RLP verifier at the current row.
227
229
state : Column < Advice > ,
228
230
/// A utility gadget to compare/query what state we are at.
@@ -336,6 +338,7 @@ impl<F: Field> RlpCircuitConfig<F> {
336
338
let q_enabled = rlp_table. q_enable ;
337
339
let (
338
340
q_first,
341
+ q_last,
339
342
byte_idx,
340
343
byte_rev_idx,
341
344
byte_value,
@@ -354,6 +357,7 @@ impl<F: Field> RlpCircuitConfig<F> {
354
357
transit_to_new_rlp_instance,
355
358
is_same_rlp_instance,
356
359
) = (
360
+ meta. fixed_column ( ) ,
357
361
meta. fixed_column ( ) ,
358
362
meta. advice_column ( ) ,
359
363
meta. advice_column ( ) ,
@@ -1429,8 +1433,17 @@ impl<F: Field> RlpCircuitConfig<F> {
1429
1433
] ) )
1430
1434
} ) ;
1431
1435
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
+
1432
1444
Self {
1433
1445
q_first,
1446
+ q_last,
1434
1447
state,
1435
1448
state_bits,
1436
1449
rlp_table,
@@ -1889,6 +1902,13 @@ impl<F: Field> RlpCircuitConfig<F> {
1889
1902
for i in sm_rows. len ( ) ..last_row {
1890
1903
self . assign_sm_end_row ( & mut region, i) ?;
1891
1904
}
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
+ ) ?;
1892
1912
1893
1913
Ok ( ( ) )
1894
1914
} ,
0 commit comments