Skip to content

Commit

Permalink
fix: fix memory table and frame table termination
Browse files Browse the repository at this point in the history
  • Loading branch information
junyu0312 committed Jul 1, 2024
1 parent 96a4aac commit 37827c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
30 changes: 14 additions & 16 deletions crates/zkwasm/src/circuits/jtable/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,23 @@ impl<F: FieldExt> JumpTableChip<F> {
)?;
}

if i == capability - 1 {
ctx.region.assign_advice_from_constant(
|| "frame table: entry terminate",
self.config.value,
ctx.offset + FrameTableValueOffset::CallOps as usize,
F::zero(),
)?;

ctx.region.assign_advice_from_constant(
|| "frame table: entry terminate",
self.config.value,
ctx.offset + FrameTableValueOffset::ReturnOps as usize,
F::zero(),
)?;
}

ctx.step(FrameTableValueOffset::Max as usize);
}

ctx.region.assign_advice_from_constant(
|| "frame table: entry terminate",
self.config.value,
ctx.offset + FrameTableValueOffset::CallOps as usize,
F::zero(),
)?;

ctx.region.assign_advice_from_constant(
|| "frame table: entry terminate",
self.config.value,
ctx.offset + FrameTableValueOffset::ReturnOps as usize,
F::zero(),
)?;

ctx.region.assign_fixed(
|| "frame table: inherited",
self.config.inherited,
Expand Down
34 changes: 16 additions & 18 deletions crates/zkwasm/src/circuits/mtable/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,32 @@ impl<F: FieldExt> MemoryTableChip<F> {
fn assign_fixed(&self, ctx: &mut Context<'_, F>) -> Result<(), Error> {
let capability = self.maximal_available_rows / MEMORY_TABLE_ENTRY_ROWS as usize;

for i in 0..capability {
for _ in 0..capability {
ctx.region.assign_fixed(
|| "mtable: sel",
self.config.entry_sel,
ctx.offset,
|| Ok(F::one()),
)?;

if i == capability - 1 {
ctx.region.assign_advice_from_constant(
|| "rest_mops terminate",
self.config.rest_mops_cell.cell.col,
ctx.offset + self.config.rest_mops_cell.cell.rot as usize,
F::zero(),
)?;

#[cfg(feature = "continuation")]
ctx.region.assign_advice_from_constant(
|| "rest_memory_finalize_ops terminate",
self.config.rest_memory_finalize_ops_cell.cell.col,
ctx.offset + self.config.rest_memory_finalize_ops_cell.cell.rot as usize,
F::zero(),
)?;
}

ctx.step(MEMORY_TABLE_ENTRY_ROWS as usize);
}

ctx.region.assign_advice_from_constant(
|| "rest_mops terminate",
self.config.rest_mops_cell.cell.col,
ctx.offset + self.config.rest_mops_cell.cell.rot as usize,
F::zero(),
)?;

#[cfg(feature = "continuation")]
ctx.region.assign_advice_from_constant(
|| "rest_memory_finalize_ops terminate",
self.config.rest_memory_finalize_ops_cell.cell.col,
ctx.offset + self.config.rest_memory_finalize_ops_cell.cell.rot as usize,
F::zero(),
)?;

Ok(())
}

Expand Down

0 comments on commit 37827c4

Please sign in to comment.