-
Notifications
You must be signed in to change notification settings - Fork 853
[proof chunk] refactor evm_circuit/state_circuit to support proof chunk #1641
[proof chunk] refactor evm_circuit/state_circuit to support proof chunk #1641
Conversation
5d5252b
to
043b70e
Compare
1788efa
to
43ed90e
Compare
61a26ab
to
69680b8
Compare
4b4bffa
to
b97ba34
Compare
b97ba34
to
dd5c9bb
Compare
9eff5a5
to
aab44aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done a very quick overview and left some comments! I didn't find anything strange :) Note that I didn't check the fingerprint chip
zkevm-circuits/src/state_circuit.rs
Outdated
// annotate columns | ||
rw_table.annotate_columns(meta); | ||
mpt_table.annotate_columns(meta); | ||
u8_table.annotate_columns(meta); | ||
u10_table.annotate_columns(meta); | ||
u16_table.annotate_columns(meta); | ||
|
||
<RwTable as LookupTable<F>>::columns(&rw_table) | ||
.iter() | ||
.for_each(|c| meta.enable_equality(*c)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the enable_equality
I imagine that you're doing the fingerprint in another region and passing the cells via copy constraints. I think the fingerprint could be implemented as a gadget applied inline at every row of the state circuit, to skip the copy constraints. But this is an optimization, the current solution should work for now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Previously Rwtable continuity is carried over via a separate copy constraints, because the PermutationChip
is meant to only cover fingerprints related logic. After your reminding, I think rwtable continuity can be realized via fingerprints as well, because row of rwtable vs fingerprint are one to one mapping, so we can leverage PermutationChip
to do everything.
I have done the change to simplify design in new commit de55034 so we can save copy contraints effort on rw_table itself.
9d05903
to
d6be453
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
18734e7
to
d3d8c62
Compare
bc54696
to
dfe0fe3
Compare
@@ -8,7 +8,7 @@ use halo2_proofs::{ | |||
use std::collections::HashMap; | |||
|
|||
// Step dimension | |||
pub(crate) const STEP_WIDTH: usize = 128; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add extra columns 128 -> 131
to make EndBlock
height remain 1
@@ -64,7 +64,7 @@ pub const FIXED_TABLE_LOOKUPS: usize = 8; | |||
pub const TX_TABLE_LOOKUPS: usize = 4; | |||
|
|||
/// Rw Table lookups done in EVMCircuit | |||
pub const RW_TABLE_LOOKUPS: usize = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
increase 5 columns for rw_lookup to make sure EndChunk
height to be 1
, same as EndBlock
EndChunk
consume more rw_lookup thanEndBlock
is becauseEndChunk
write StepState fields intorw_table
dfe0fe3
to
b88ca08
Compare
b88ca08
to
88a6aeb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass of the review. Still have some parts to go through ( common_gadget and Chunkctx_table ), the rest LGTM.
943fa3b
to
47b4d06
Compare
will merge it first and left impromemt to future PR |
f5db508
into
privacy-scaling-explorations:proof-chunk
### Description Depends on #1641 with extra commit: adding fingerprint equality check on chronological/by address rw_table Fingerprint check gate will be enable in last chunk last row ### instance columns, top down order match instance array order chunk ctx - [current chunk index, total chunk, initial rwc] // equal with chunk_{i-1} - [next chunk index, total chunk, next rwc] equal with chunk_{i+1} pi circuit - [pi digest lo, pi digest hi] // same across all chunks state circuit - [prev permutation fingerprint] // equal with chunk_{i-1} - [next permutation fingerprint] // equal with chunk_{i+1} - [alpha, gamma] // same across all chunks evm circuit - [prev permutation fingerprint] // equal with chunk_{i-1} - [next permutation fingerprint] // equal with chunk_{i+1} - [alpha, gamma] // same across all chunks ### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update
Description
[PR description]
Issue Link
#1601
Type of change
Highlights
Rw::Start
and introduceRw::Padding
to support post-padding in address-sorted rwtable in last_chunk.inner_rw_counter
which is local rw_counter within each chunk. This is used to count valid rw_row and assure Rw::Padding are append consecutively inend_block.rs
logic => EndChunk should apply similar check later onHow Has This Been Tested?
[explanation]
More context on Rw::Padding (Not cover in current PR, will be handled in later multiple chunk PR to make scope smaller)
In new logic,
Rw::Start
will be insert in first chunk offset 0, while other holes are filled byRw::Padding
in last chunk(s). The address-sorted rwtable layout will beFor chronologically rwtable, since there is no in-row constraints to check each Rw operation, so theoretically Rw::Padding rows can be filled in any offset. However, we also need to assure there is no malicious insertion other than Rw::Padding. To do that, we will rewrite this logic in later PR https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/main/zkevm-circuits/src/evm_circuit/execution/end_block.rs#L86-L90 to lookup consecutive
Rw::Padding
at chronologically sorted table, at the END of EACH chunk.