From 035459d2daa08198df49a5222d097fbeed7e17f1 Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Thu, 4 Jan 2024 10:52:57 +0800 Subject: [PATCH] Move access-list address and storage key from `value` and `value_prev` (deleted after refactor) columns to `word_rlc` and `word_rlc_prev` in copy circuit. --- zkevm-circuits/src/copy_circuit.rs | 12 ++++++------ zkevm-circuits/src/table.rs | 22 +++++++++------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/zkevm-circuits/src/copy_circuit.rs b/zkevm-circuits/src/copy_circuit.rs index 3ffe201d15..efa91ba80f 100644 --- a/zkevm-circuits/src/copy_circuit.rs +++ b/zkevm-circuits/src/copy_circuit.rs @@ -459,7 +459,7 @@ impl SubCircuitConfig for CopyCircuitConfig { let tx_id = meta.query_advice(id, CURRENT); let index = meta.query_advice(addr, CURRENT); - let address = meta.query_advice(value, CURRENT); + let address = meta.query_advice(value_word_rlc, CURRENT); vec![ 1.expr(), @@ -481,7 +481,7 @@ impl SubCircuitConfig for CopyCircuitConfig { * meta.query_advice(is_access_list_address, CURRENT); let tx_id = meta.query_advice(id, CURRENT); - let address = meta.query_advice(value, CURRENT); + let address = meta.query_advice(value_word_rlc, CURRENT); vec![ 1.expr(), @@ -511,8 +511,8 @@ impl SubCircuitConfig for CopyCircuitConfig { let tx_id = meta.query_advice(id, CURRENT); let index = meta.query_advice(addr, CURRENT); - let address = meta.query_advice(value, CURRENT); - let storage_key = meta.query_advice(value_prev, CURRENT); + let address = meta.query_advice(value_word_rlc, CURRENT); + let storage_key = meta.query_advice(value_word_rlc_prev, CURRENT); vec![ 1.expr(), @@ -534,8 +534,8 @@ impl SubCircuitConfig for CopyCircuitConfig { * meta.query_advice(is_access_list_storage_key, CURRENT); let tx_id = meta.query_advice(id, CURRENT); - let address = meta.query_advice(value, CURRENT); - let storage_key = meta.query_advice(value_prev, CURRENT); + let address = meta.query_advice(value_word_rlc, CURRENT); + let storage_key = meta.query_advice(value_word_rlc_prev, CURRENT); vec![ 1.expr(), diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 53e48da01b..754f396c3c 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -1840,19 +1840,8 @@ impl CopyTable { let is_pad = is_read_step && thread.addr >= thread.addr_end; - let [value, value_prev] = if is_access_list { - let address_pair = copy_event.access_list[step_idx / 2]; - [ - address_pair.0.to_scalar().unwrap(), - address_pair.1.to_scalar().unwrap(), - ] - } else { - [ - F::from(copy_step.value as u64), - F::from(copy_step.prev_value as u64), - ] - } - .map(Value::known); + let [value, value_prev] = [copy_step.value, copy_step.prev_value] + .map(|val| Value::known(F::from(val as u64))); let value_or_pad = if is_pad { Value::known(F::zero()) @@ -1876,6 +1865,13 @@ impl CopyTable { thread.word_rlc_prev * challenges.evm_word() + value_prev }; + if is_access_list { + let address_pair = copy_event.access_list[step_idx / 2]; + [thread.word_rlc, thread.word_rlc_prev] = + [address_pair.0.to_scalar(), address_pair.1.to_scalar()] + .map(|val| Value::known(val.unwrap())); + } + let word_index = (step_idx as u64 / 2) % 32; // For LOG, format the address including the log_id.