@@ -26,7 +26,7 @@ use halo2_proofs::{
26
26
poly:: Rotation ,
27
27
} ;
28
28
use itertools:: Itertools ;
29
- use std:: { array, collections:: BTreeMap , marker:: PhantomData } ;
29
+ use std:: { array, collections:: BTreeMap , iter , marker:: PhantomData } ;
30
30
31
31
use gadgets:: less_than:: { LtChip , LtConfig } ;
32
32
#[ cfg( feature = "onephase" ) ]
@@ -242,26 +242,28 @@ impl<F: Field> SubCircuitConfig<F> for CopyCircuitConfig<F> {
242
242
let is_not_back_mask_exprs = is_inbound_read. clone ( ) . map ( |chip| chip. is_lt ( meta, None ) ) ;
243
243
let is_inbound_read_exprs = is_inbound_read. clone ( ) . map ( |chip| chip. is_lt ( meta, None ) ) ;
244
244
245
- constrain_id (
246
- cb,
247
- meta,
248
- //is_bytecode,
249
- is_tx_log,
250
- is_tx_calldata,
251
- is_memory,
252
- id,
253
- is_pad,
254
- ) ;
245
+ // TODO: feat/copy-hi-lo
246
+ // constrain_id(
247
+ // cb,
248
+ // meta,
249
+ // //is_bytecode,
250
+ // is_tx_log,
251
+ // is_tx_calldata,
252
+ // is_memory,
253
+ // id,
254
+ // is_pad,
255
+ // );
255
256
256
257
let is_tx_log = meta. query_advice ( is_tx_log, CURRENT ) ;
257
258
let is_access_list = meta. query_advice ( is_access_list_address, CURRENT )
258
259
+ meta. query_advice ( is_access_list_storage_key, CURRENT ) ;
259
-
260
- constrain_first_last ( cb, is_reader. expr ( ) , is_first. expr ( ) , is_last. expr ( ) ) ;
261
-
262
- constrain_must_terminate ( cb, meta, q_enable, & tag) ;
263
-
264
- constrain_forward_parameters ( cb, meta, is_continue. expr ( ) , id, tag, src_addr_end) ;
260
+ // TODO: feat/copy-hi-lo
261
+ //
262
+ // constrain_first_last(cb, is_reader.expr(), is_first.expr(), is_last.expr());
263
+ //
264
+ // constrain_must_terminate(cb, meta, q_enable, &tag);
265
+ //
266
+ // constrain_forward_parameters(cb, meta, is_continue.expr(), id, tag, src_addr_end);
265
267
266
268
// let (is_pad, is_pad_next) = constrain_is_pad(
267
269
// cb,
@@ -292,6 +294,7 @@ impl<F: Field> SubCircuitConfig<F> for CopyCircuitConfig<F> {
292
294
// )
293
295
// };
294
296
297
+ // TODO: feat/copy-hi-lo
295
298
constrain_non_pad_non_mask (
296
299
cb,
297
300
meta,
@@ -303,20 +306,21 @@ impl<F: Field> SubCircuitConfig<F> for CopyCircuitConfig<F> {
303
306
304
307
//constrain_masked_value(cb, meta, mask.expr(), value, value_prev);
305
308
306
- constrain_value_rlc (
307
- cb,
308
- meta,
309
- is_first. expr ( ) ,
310
- is_continue. expr ( ) ,
311
- is_last_col,
312
- non_pad_non_mask,
313
- is_inbound_read. clone ( ) ,
314
- value_acc,
315
- value_limbs,
316
- challenges. keccak_input ( ) ,
317
- ) ;
318
-
319
- constrain_event_rlc_acc ( cb, meta, is_last_col, value_acc, rlc_acc, is_bytecode, tag) ;
309
+ // TODO: feat/copy-hi-lo
310
+ // constrain_value_rlc(
311
+ // cb,
312
+ // meta,
313
+ // is_first.expr(),
314
+ // is_continue.expr(),
315
+ // is_last_col,
316
+ // non_pad_non_mask,
317
+ // is_inbound_read.clone(),
318
+ // value_acc,
319
+ // value_limbs,
320
+ // challenges.keccak_input(),
321
+ // );
322
+ //
323
+ // constrain_event_rlc_acc(cb, meta, is_last_col, value_acc, rlc_acc, is_bytecode, tag);
320
324
321
325
// no word_rlc required after word hi lo
322
326
// Apply the same constraints for the RLCs of words before and after the write.
@@ -334,21 +338,22 @@ impl<F: Field> SubCircuitConfig<F> for CopyCircuitConfig<F> {
334
338
// );
335
339
// }
336
340
337
- constrain_address ( cb, meta, is_continue. expr ( ) , addr) ;
338
-
339
- {
340
- let is_rw_word_type = meta. query_advice ( is_memory, CURRENT ) + is_tx_log. expr ( ) ;
341
- let is_rw_type = is_rw_word_type. expr ( ) + is_access_list. expr ( ) ;
342
-
343
- constrain_rw_counter (
344
- cb,
345
- meta,
346
- is_last. expr ( ) ,
347
- is_rw_type. expr ( ) ,
348
- rw_counter,
349
- rwc_inc_left,
350
- ) ;
351
- }
341
+ // TODO: feat/copy-hi-lo
342
+ // constrain_address(cb, meta, is_continue.expr(), addr);
343
+ //
344
+ // {
345
+ // let is_rw_word_type = meta.query_advice(is_memory, CURRENT) + is_tx_log.expr();
346
+ // let is_rw_type = is_rw_word_type.expr() + is_access_list.expr();
347
+ //
348
+ // constrain_rw_counter(
349
+ // cb,
350
+ // meta,
351
+ // is_last.expr(),
352
+ // is_rw_type.expr(),
353
+ // rw_counter,
354
+ // rwc_inc_left,
355
+ // );
356
+ // }
352
357
353
358
cb. gate ( meta. query_fixed ( q_enable, CURRENT ) )
354
359
} ) ;
@@ -749,20 +754,28 @@ impl<F: Field> CopyCircuitConfig<F> {
749
754
region. name_column ( || "value_word" , self . value_word ) ;
750
755
region. name_column ( || "value_word_prev" , self . value_word_prev ) ;
751
756
region. name_column ( || "value_acc" , self . value_acc ) ;
757
+ for ( idx, ( chip, name) ) in self
758
+ . is_front_mask
759
+ . iter ( )
760
+ . zip ( iter:: repeat ( "is_front_mask" ) )
761
+ . enumerate ( )
762
+ . chain (
763
+ self . is_not_back_mask
764
+ . iter ( )
765
+ . zip ( iter:: repeat ( "is_not_back_mask" ) )
766
+ . enumerate ( ) ,
767
+ )
768
+ . chain (
769
+ self . is_inbound_read
770
+ . iter ( )
771
+ . zip ( iter:: repeat ( "is_inbound_read" ) )
772
+ . enumerate ( ) ,
773
+ )
774
+ {
775
+ chip. annotate ( & mut region, || format ! ( "{}[{}]" , name, idx) )
776
+ }
752
777
for i in 0 ..16 {
753
778
region. name_column ( || format ! ( "value_limbs[{}]" , i) , self . value_limbs [ i] ) ;
754
- region. name_column (
755
- || format ! ( "is_front_mask[{}].lt" , i) ,
756
- self . is_front_mask [ i] . lt ,
757
- ) ;
758
- region. name_column (
759
- || format ! ( "is_not_back_mask[{}].lt" , i) ,
760
- self . is_not_back_mask [ i] . lt ,
761
- ) ;
762
- region. name_column (
763
- || format ! ( "is_inbound_read[{}].lt" , i) ,
764
- self . is_inbound_read [ i] . lt ,
765
- ) ;
766
779
region. name_column (
767
780
|| format ! ( "non_pad_non_mask[{}]" , i) ,
768
781
self . non_pad_non_mask [ i] ,
@@ -890,6 +903,20 @@ impl<F: Field> CopyCircuitConfig<F> {
890
903
* offset,
891
904
|| Value :: known ( F :: one ( ) ) ,
892
905
) ?;
906
+ // addr_copy_start
907
+ region. assign_advice (
908
+ || format ! ( "assign addr_copy_start {}" , * offset) ,
909
+ self . copy_table . addr_copy_start ,
910
+ * offset,
911
+ || Value :: known ( F :: zero ( ) ) ,
912
+ ) ?;
913
+ // addr_copy_end
914
+ region. assign_advice (
915
+ || format ! ( "assign addr_copy_end {}" , * offset) ,
916
+ self . copy_table . addr_copy_end ,
917
+ * offset,
918
+ || Value :: known ( F :: zero ( ) ) ,
919
+ ) ?;
893
920
// real_bytes_left
894
921
region. assign_advice (
895
922
|| format ! ( "assign bytes_left {}" , * offset) ,
@@ -953,14 +980,16 @@ impl<F: Field> CopyCircuitConfig<F> {
953
980
// tag
954
981
tag_chip. assign ( region, * offset, & CopyDataType :: Padding ) ?;
955
982
956
- for ( ( is_front_mask, is_not_back_mask) , is_inbound_read) in is_front_mask_chip
983
+ for ( idx , ( ( is_front_mask, is_not_back_mask) , is_inbound_read) ) in is_front_mask_chip
957
984
. iter ( )
958
985
. zip ( is_not_back_mask_chip)
959
986
. zip ( is_inbound_read_chip)
987
+ . enumerate ( )
960
988
{
961
- is_front_mask. assign ( region, * offset, F :: one ( ) , F :: zero ( ) ) ?;
962
- is_not_back_mask. assign ( region, * offset, F :: one ( ) , F :: zero ( ) ) ?;
963
- is_inbound_read. assign ( region, * offset, F :: one ( ) , F :: zero ( ) ) ?;
989
+ let address = F :: from ( idx as u64 ) ;
990
+ is_front_mask. assign ( region, * offset, address, F :: zero ( ) ) ?;
991
+ is_not_back_mask. assign ( region, * offset, address, F :: zero ( ) ) ?;
992
+ is_inbound_read. assign ( region, * offset, address, F :: zero ( ) ) ?;
964
993
}
965
994
966
995
for ( idx, non_pad_non_mask) in self . non_pad_non_mask . iter ( ) . enumerate ( ) {
0 commit comments