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

Commit

Permalink
chore: add warning message while copy event > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiWu123 committed Jun 21, 2023
1 parent 3875fec commit 766881a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions zkevm-circuits/src/evm_circuit/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ impl<F: Field> ExecutionConfig<F> {
return;
}

let mut copy_lookup_included = false;
let mut copy_lookup_count = 0;
let mut assigned_rw_values = Vec::new();
for (name, v) in assigned_stored_expressions {
// If any `copy lookup` which dst_tag or src_tag is Memory in opcode execution,
Expand All @@ -1374,11 +1374,20 @@ impl<F: Field> ExecutionConfig<F> {
assigned_rw_values.push((name.clone(), *v));

if name.starts_with("copy lookup") {
copy_lookup_included = true;
copy_lookup_count += 1;
}
}
}

// TODO: We should find a better way to avoid this kind of special case.
// #1489 is the issue for this refactor.
if copy_lookup_count > 1 {
log::warn!("The number of copy events is more than 1, it's not supported by current design. Stop checking this step: {:?}",
step
);
return;
}

let rlc_assignments: BTreeSet<_> = (0..step.rw_indices_len())
.map(|index| block.get_rws(step, index))
.map(|rw| {
Expand All @@ -1402,24 +1411,23 @@ impl<F: Field> ExecutionConfig<F> {
}

// if copy_rw_counter_delta is zero, ignore `copy lookup` event.
if step.copy_rw_counter_delta == 0 && copy_lookup_included {
copy_lookup_included = false;
if step.copy_rw_counter_delta == 0 && copy_lookup_count > 0 {
copy_lookup_count = 0;
}

// Check that the number of rw operations generated from the bus-mapping
// correspond to the number of assigned rw lookups by the EVM Circuit
// plus the number of rw lookups done by the copy circuit
// minus the number of copy lookup event.
if step.rw_indices_len()
!= assigned_rw_values.len() + step.copy_rw_counter_delta as usize
- copy_lookup_included as usize
!= assigned_rw_values.len() + step.copy_rw_counter_delta as usize - copy_lookup_count
{
log::error!(
"step.rw_indices.len: {} != assigned_rw_values.len: {} + step.copy_rw_counter_delta: {} - copy_lookup_included: {} in step: {:?}",
"step.rw_indices.len: {} != assigned_rw_values.len: {} + step.copy_rw_counter_delta: {} - copy_lookup_count: {} in step: {:?}",
step.rw_indices_len(),
assigned_rw_values.len(),
step.copy_rw_counter_delta,
copy_lookup_included,
copy_lookup_count,
step
);
}
Expand Down

0 comments on commit 766881a

Please sign in to comment.