Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circuit-benchmarks/src/evm_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<F: FieldExt> Circuit<F> for TestCircuit<F> {

fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
let tx_table = [(); 4].map(|_| meta.advice_column());
let rw_table = [(); 8].map(|_| meta.advice_column());
let rw_table = [(); 10].map(|_| meta.advice_column());
let bytecode_table = [(); 4].map(|_| meta.advice_column());
let block_table = [(); 3].map(|_| meta.advice_column());
// Use constant expression to mock constant instance column for a more
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/tests/circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod test_evm_circuit {
#[derive(Clone)]
struct TestCircuitConfig<F> {
tx_table: [Column<Advice>; 4],
rw_table: [Column<Advice>; 8],
rw_table: [Column<Advice>; 10],
bytecode_table: [Column<Advice>; 4],
evm_circuit: EvmCircuit<F>,
}
Expand Down Expand Up @@ -185,7 +185,7 @@ mod test_evm_circuit {

fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
let tx_table = [(); 4].map(|_| meta.advice_column());
let rw_table = [(); 8].map(|_| meta.advice_column());
let rw_table = [(); 10].map(|_| meta.advice_column());
let bytecode_table = [(); 4].map(|_| meta.advice_column());
let block_table = [(); 3].map(|_| meta.advice_column());

Expand Down
6 changes: 3 additions & 3 deletions zkevm-circuits/src/evm_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<F: FieldExt> EvmCircuit<F> {
) -> Self
where
TxTable: LookupTable<F, 4>,
RwTable: LookupTable<F, 8>,
RwTable: LookupTable<F, 10>,
BytecodeTable: LookupTable<F, 4>,
BlockTable: LookupTable<F, 3>,
{
Expand Down Expand Up @@ -160,7 +160,7 @@ mod test {
#[derive(Clone)]
pub(crate) struct TestCircuitConfig<F> {
tx_table: [Column<Advice>; 4],
rw_table: [Column<Advice>; 8],
rw_table: [Column<Advice>; 10],
bytecode_table: [Column<Advice>; 4],
block_table: [Column<Advice>; 3],
evm_circuit: EvmCircuit<F>,
Expand Down Expand Up @@ -353,7 +353,7 @@ mod test {

fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
let tx_table = [(); 4].map(|_| meta.advice_column());
let rw_table = [(); 8].map(|_| meta.advice_column());
let rw_table = [(); 10].map(|_| meta.advice_column());
let bytecode_table = [(); 4].map(|_| meta.advice_column());
let block_table = [(); 3].map(|_| meta.advice_column());

Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/evm_circuit/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<F: FieldExt> ExecutionConfig<F> {
) -> Self
where
TxTable: LookupTable<F, 4>,
RwTable: LookupTable<F, 8>,
RwTable: LookupTable<F, 10>,
BytecodeTable: LookupTable<F, 4>,
BlockTable: LookupTable<F, 3>,
{
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<F: FieldExt> ExecutionConfig<F> {
independent_lookups: Vec<Vec<Lookup<F>>>,
) where
TxTable: LookupTable<F, 4>,
RwTable: LookupTable<F, 8>,
RwTable: LookupTable<F, 10>,
BytecodeTable: LookupTable<F, 4>,
BlockTable: LookupTable<F, 3>,
{
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/evm_circuit/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub(crate) enum Lookup<F> {
/// all tags.
tag: Expression<F>,
/// Values corresponding to the tag.
values: [Expression<F>; 5],
values: [Expression<F>; 7],
},
/// Lookup to bytecode table, which contains all used creation code and
/// contract code.
Expand Down
37 changes: 30 additions & 7 deletions zkevm-circuits/src/evm_circuit/util/constraint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
counter: Expression<F>,
is_write: Expression<F>,
tag: RwTableTag,
values: [Expression<F>; 5],
values: [Expression<F>; 7],
) {
self.add_lookup(Lookup::Rw {
counter,
Expand All @@ -476,7 +476,7 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
&mut self,
is_write: Expression<F>,
tag: RwTableTag,
values: [Expression<F>; 5],
values: [Expression<F>; 7],
) {
self.rw_lookup_with_counter(
self.curr.state.rw_counter.expr() + self.rw_counter_offset.expr(),
Expand All @@ -490,7 +490,7 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
fn state_write_with_reversion(
&mut self,
tag: RwTableTag,
mut values: [Expression<F>; 5],
mut values: [Expression<F>; 7],
is_persistent: Expression<F>,
rw_counter_end_of_reversion: Expression<F>,
) {
Expand All @@ -503,11 +503,12 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
+ cb.state_write_counter_offset.expr();
// Swap value and value_prev respect to tag
match tag {
RwTableTag::TxAccessListAccount => values.swap(2, 3),
RwTableTag::TxAccessListAccount => values.swap(3, 4),
RwTableTag::TxAccessListStorageSlot => values.swap(3, 4),
RwTableTag::Account => values.swap(2, 3),
RwTableTag::Account => values.swap(3, 4),
RwTableTag::AccountStorage => values.swap(3, 4),
RwTableTag::AccountDestructed => values.swap(2, 3),
RwTableTag::AccountDestructed => values.swap(3, 4),
RwTableTag::TxRefund => values.swap(3, 4),
_ => {}
}

Expand All @@ -534,7 +535,15 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
self.rw_lookup(
true.expr(),
RwTableTag::TxAccessListAccount,
[tx_id, account_address, value, value_prev, 0.expr()],
[
tx_id,
account_address,
0.expr(),
value,
value_prev,
0.expr(),
0.expr(),
],
);
}

Expand All @@ -552,9 +561,11 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
[
account_address,
field_tag.expr(),
0.expr(),
value.clone(),
value,
0.expr(),
0.expr(),
],
);
}
Expand All @@ -572,9 +583,11 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
[
account_address,
field_tag.expr(),
0.expr(),
value,
value_prev,
0.expr(),
0.expr(),
],
);
}
Expand All @@ -593,9 +606,11 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
[
account_address,
field_tag.expr(),
0.expr(),
value,
value_prev,
0.expr(),
0.expr(),
],
is_persistent,
rw_counter_end_of_reversion,
Expand Down Expand Up @@ -626,9 +641,11 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
[
call_id.unwrap_or_else(|| self.curr.state.call_id.expr()),
field_tag.expr(),
0.expr(),
value,
0.expr(),
0.expr(),
0.expr(),
],
);
}
Expand Down Expand Up @@ -661,9 +678,11 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
[
self.curr.state.call_id.expr(),
self.curr.state.stack_pointer.expr() + stack_pointer_offset,
0.expr(),
value,
0.expr(),
0.expr(),
0.expr(),
],
);
}
Expand All @@ -682,9 +701,11 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
[
self.curr.state.call_id.expr(),
memory_address,
0.expr(),
byte,
0.expr(),
0.expr(),
0.expr(),
],
);
}
Expand All @@ -703,9 +724,11 @@ impl<'a, F: FieldExt> ConstraintBuilder<'a, F> {
[
self.curr.state.call_id.expr(),
memory_address,
0.expr(),
byte,
0.expr(),
0.expr(),
0.expr(),
],
);
}
Expand Down
12 changes: 11 additions & 1 deletion zkevm-circuits/src/evm_circuit/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl Rw {
}
}

pub fn table_assignment<F: FieldExt>(&self, randomness: F) -> [F; 8] {
pub fn table_assignment<F: FieldExt>(&self, randomness: F) -> [F; 10] {
match self {
Self::TxAccessListAccount {
rw_counter,
Expand All @@ -459,9 +459,11 @@ impl Rw {
F::from(RwTableTag::TxAccessListAccount as u64),
F::from(*tx_id as u64),
account_address.to_scalar().unwrap(),
F::zero(),
F::from(*value as u64),
F::from(*value_prev as u64),
F::zero(),
F::zero(),
],
Self::Account {
rw_counter,
Expand All @@ -484,9 +486,11 @@ impl Rw {
F::from(RwTableTag::Account as u64),
account_address.to_scalar().unwrap(),
F::from(*field_tag as u64),
F::zero(),
to_scalar(value),
to_scalar(value_prev),
F::zero(),
F::zero(),
]
}
Self::CallContext {
Expand All @@ -501,6 +505,7 @@ impl Rw {
F::from(RwTableTag::CallContext as u64),
F::from(*call_id as u64),
F::from(*field_tag as u64),
F::zero(),
match field_tag {
CallContextFieldTag::OpcodeSource
| CallContextFieldTag::Value => {
Expand All @@ -516,6 +521,7 @@ impl Rw {
},
F::zero(),
F::zero(),
F::zero(),
],
Self::Stack {
rw_counter,
Expand All @@ -529,12 +535,14 @@ impl Rw {
F::from(RwTableTag::Stack as u64),
F::from(*call_id as u64),
F::from(*stack_pointer as u64),
F::zero(),
RandomLinearCombination::random_linear_combine(
value.to_le_bytes(),
randomness,
),
F::zero(),
F::zero(),
F::zero(),
],
Self::Memory {
rw_counter,
Expand All @@ -548,9 +556,11 @@ impl Rw {
F::from(RwTableTag::Memory as u64),
F::from(*call_id as u64),
F::from(*memory_address),
F::zero(),
F::from(*byte as u64),
F::zero(),
F::zero(),
F::zero(),
],
_ => unimplemented!(),
}
Expand Down