Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
constraint chunk_index < total_chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Dec 7, 2023
1 parent 7d30826 commit 5754924
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions zkevm-circuits/src/util/chunkctx_config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bus_mapping::circuit_input_builder::ChunkContext;
use gadgets::{
is_zero::{IsZeroChip, IsZeroConfig, IsZeroInstruction},
less_than::LtChip,
util::Expr,
};
use halo2_proofs::{
Expand Down Expand Up @@ -77,6 +78,18 @@ impl<F: Field> ChunkContextConfig<F> {
});
});

// assume max total_chunks < 2^8
let is_chunk_index_lt_total_chunks = LtChip::<_, 1>::configure(
meta,
|meta| meta.query_selector(q_chunk_context),
|meta| meta.query_advice(chunk_index, Rotation::cur()),
|meta| meta.query_advice(total_chunks, Rotation::cur()),
);

meta.create_gate("chunk_index < total_chunks", |meta| {
[1.expr() - is_chunk_index_lt_total_chunks.is_lt(meta, None)]
});

let is_first_chunk = IsZeroChip::configure(
meta,
|meta| meta.query_selector(q_chunk_context),
Expand Down

0 comments on commit 5754924

Please sign in to comment.